...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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. NOTE: line counting considers position
inside multicharacter line-breaks (such as CRLF and LFCR) as being on the
next line already.
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 line_start = 1); std::size_t position() const; private: friend class boost::iterator_core_access; void increment(); std::size_t line; // The line position. bool prev_n; bool prev_r; };
template <class Iterator> inline std::size_t get_line(Iterator);
Get the line position. Returns -1 if Iterator is not a line_pos_iterator
.
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.
template <class Iterator> inline Iterator get_line_end(Iterator current, Iterator upper_bound);
Get an iterator to the end of the line. Applicable to any iterator.
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.
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.