Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.
PrevUpHomeNext

The line position iterator

The line_pos_iterator is a lightweight line position iterator. This iterator adapter only stores the current line number, nothing else. Unlike Spirit.Classic's position_iterator, it does not store the column number and does not need an end iterator. The current column can be computed, if needed.

Class Reference

template <class Iterator>
class line_pos_iterator : public boost::iterator_adaptor<
    line_pos_iterator<Iterator>  // Derived
  , Iterator                     // Base
  , boost::use_default           // Value
  , boost::forward_traversal_tag // CategoryOrTraversal
> {
public:
    line_pos_iterator();

    explicit line_pos_iterator(Iterator);

    std::size_t position() const;

private:
    friend class boost::iterator_core_access;

    void increment();

    std::size_t line; // The line position.
    typename std::iterator_traits<Iterator>::value_type prev;
};

get_line

template <class Iterator>
inline std::size_t get_line(Iterator);

Get the line position. Returns -1 if Iterator is not a line_pos_iterator.

get_line_start

template <class Iterator>
inline Iterator get_line_start(Iterator lower_bound, Iterator current);

Get an iterator to the beginning of the line. Applicable to any iterator.

get_current_line

template <class Iterator>
inline iterator_range<Iterator>
get_current_line(Iterator lower_bound, Iterator current,
                 Iterator upper_bound);

Get an iterator_range containing the current line. Applicable to any iterator.

get_column

template <class Iterator>
inline std::size_t get_column(Iterator lower_bound, Iterator current,
                              std::size_t tabs = 4);

Get the current column. Applicable to any iterator.


PrevUpHomeNext