REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
Loading...
Searching...
No Matches
real::compat::regex_token_iterator< BidirIt, CharT, Traits > Class Template Reference

Enumerates selected sub-matches (or the text between matches) — std::regex_token_iterator. More...

#include <regex_iter.hpp>

Collaboration diagram for real::compat::regex_token_iterator< BidirIt, CharT, Traits >:
[legend]

Public Types

using regex_type = basic_regex< CharT, Traits >
 The pattern type.
 
using value_type = sub_match< BidirIt >
 Yielded token.
 
using difference_type = std::ptrdiff_t
 Iterator traits.
 
using pointer = const value_type *
 Arrow type.
 
using reference = const value_type &
 Dereference type.
 
using iterator_category = std::forward_iterator_tag
 std::regex_token_iterator parity.
 

Public Member Functions

 regex_token_iterator ()=default
 Constructs the end sentinel.
 
 regex_token_iterator (BidirIt first, BidirIt last, const regex_type &re, int submatch=0, regex_constants::match_flag_type flags=regex_constants::match_default)
 Selects a single sub-match field (0 = whole match, N = group N, -1 = split).
 
 regex_token_iterator (BidirIt first, BidirIt last, const regex_type &re, const std::vector< int > &submatches, regex_constants::match_flag_type flags=regex_constants::match_default)
 Selects a list of fields, cycled per match (e.g. {1, 2}, {-1}). The match flags are forwarded to the wrapped regex_iterator, so the nullable/honors routing is inherited.
 
 regex_token_iterator (BidirIt first, BidirIt last, const regex_type &re, std::initializer_list< int > submatches, regex_constants::match_flag_type flags=regex_constants::match_default)
 Selects a list of fields from a braced list (e.g. {-1}).
 
 regex_token_iterator (BidirIt first, BidirIt last, const regex_type &&re, int submatch=0, regex_constants::match_flag_type flags=regex_constants::match_default)=delete
 Constructing from a temporary regex would dangle (std::regex_token_iterator parity).
 
 regex_token_iterator (BidirIt first, BidirIt last, const regex_type &&re, const std::vector< int > &submatches, regex_constants::match_flag_type flags=regex_constants::match_default)=delete
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
reference operator* () const
 
pointer operator-> () const
 
regex_token_iteratoroperator++ ()
 
regex_token_iterator operator++ (int)
 
bool operator== (const regex_token_iterator &other) const
 
bool operator!= (const regex_token_iterator &other) const
 

Private Member Functions

void set_field ()
 Computes the current token from the current match and subs_[n_].
 
void init (BidirIt first, BidirIt last)
 Establishes the first token (or the whole-sequence token when there is no match).
 

Private Attributes

regex_iterator< BidirIt, CharT, Traits > position_
 The underlying match walk.
 
std::vector< int > subs_
 Field selectors, cycled per match.
 
std::size_t n_ {0}
 Current field index into subs_.
 
value_type current_
 Current token (by value — no aliasing).
 
bool has_m1_ {false}
 Whether a -1 (split) field is present.
 
bool suffix_mode_ {false}
 Emitting the trailing split suffix.
 
bool at_end_ {true}
 End-of-sequence.
 

Detailed Description

template<typename BidirIt, typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
class real::compat::regex_token_iterator< BidirIt, CharT, Traits >

Enumerates selected sub-matches (or the text between matches) — std::regex_token_iterator.

Wraps regex_iterator, so it inherits the per-operation nullable routing untouched (it never replays the engine choice). For each match it yields the requested fields in order: a field N >= 0 is capture group N (a non-participating group yields an empty matched == false token); the field -1 is the text before this match since the previous one — i.e. the match's prefix() — which turns -1 into a splitter. After the last match, a trailing -1 field yields the final suffix iff it is non-empty (std's rule; an empty field between adjacent matches is still produced, the asymmetry std pins). With -1 and no match at all, the whole sequence is the single token.

Template Parameters
BidirItA contiguous iterator into the searched sequence.

Definition at line 194 of file regex_iter.hpp.

Member Typedef Documentation

◆ difference_type

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
using real::compat::regex_token_iterator< BidirIt, CharT, Traits >::difference_type = std::ptrdiff_t

Iterator traits.

Definition at line 200 of file regex_iter.hpp.

◆ iterator_category

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
using real::compat::regex_token_iterator< BidirIt, CharT, Traits >::iterator_category = std::forward_iterator_tag

std::regex_token_iterator parity.

Definition at line 203 of file regex_iter.hpp.

◆ pointer

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
using real::compat::regex_token_iterator< BidirIt, CharT, Traits >::pointer = const value_type*

Arrow type.

Definition at line 201 of file regex_iter.hpp.

◆ reference

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
using real::compat::regex_token_iterator< BidirIt, CharT, Traits >::reference = const value_type&

Dereference type.

Definition at line 202 of file regex_iter.hpp.

◆ regex_type

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
using real::compat::regex_token_iterator< BidirIt, CharT, Traits >::regex_type = basic_regex<CharT, Traits>

The pattern type.

Definition at line 198 of file regex_iter.hpp.

◆ value_type

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
using real::compat::regex_token_iterator< BidirIt, CharT, Traits >::value_type = sub_match<BidirIt>

Yielded token.

Definition at line 199 of file regex_iter.hpp.

Constructor & Destructor Documentation

◆ regex_token_iterator() [1/6]

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
real::compat::regex_token_iterator< BidirIt, CharT, Traits >::regex_token_iterator ( )
default

Constructs the end sentinel.

◆ regex_token_iterator() [2/6]

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
real::compat::regex_token_iterator< BidirIt, CharT, Traits >::regex_token_iterator ( BidirIt  first,
BidirIt  last,
const regex_type re,
int  submatch = 0,
regex_constants::match_flag_type  flags = regex_constants::match_default 
)
inline

Selects a single sub-match field (0 = whole match, N = group N, -1 = split).

Definition at line 209 of file regex_iter.hpp.

◆ regex_token_iterator() [3/6]

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
real::compat::regex_token_iterator< BidirIt, CharT, Traits >::regex_token_iterator ( BidirIt  first,
BidirIt  last,
const regex_type re,
const std::vector< int > &  submatches,
regex_constants::match_flag_type  flags = regex_constants::match_default 
)
inline

Selects a list of fields, cycled per match (e.g. {1, 2}, {-1}). The match flags are forwarded to the wrapped regex_iterator, so the nullable/honors routing is inherited.

Definition at line 223 of file regex_iter.hpp.

◆ regex_token_iterator() [4/6]

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
real::compat::regex_token_iterator< BidirIt, CharT, Traits >::regex_token_iterator ( BidirIt  first,
BidirIt  last,
const regex_type re,
std::initializer_list< int >  submatches,
regex_constants::match_flag_type  flags = regex_constants::match_default 
)
inline

Selects a list of fields from a braced list (e.g. {-1}).

Definition at line 243 of file regex_iter.hpp.

◆ regex_token_iterator() [5/6]

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
real::compat::regex_token_iterator< BidirIt, CharT, Traits >::regex_token_iterator ( BidirIt  first,
BidirIt  last,
const regex_type &&  re,
int  submatch = 0,
regex_constants::match_flag_type  flags = regex_constants::match_default 
)
delete

Constructing from a temporary regex would dangle (std::regex_token_iterator parity).

◆ regex_token_iterator() [6/6]

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
real::compat::regex_token_iterator< BidirIt, CharT, Traits >::regex_token_iterator ( BidirIt  first,
BidirIt  last,
const regex_type &&  re,
const std::vector< int > &  submatches,
regex_constants::match_flag_type  flags = regex_constants::match_default 
)
delete

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Member Function Documentation

◆ init()

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
void real::compat::regex_token_iterator< BidirIt, CharT, Traits >::init ( BidirIt  first,
BidirIt  last 
)
inlineprivate

Establishes the first token (or the whole-sequence token when there is no match).

Definition at line 349 of file regex_iter.hpp.

◆ operator!=()

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
bool real::compat::regex_token_iterator< BidirIt, CharT, Traits >::operator!= ( const regex_token_iterator< BidirIt, CharT, Traits > &  other) const
inline

Definition at line 327 of file regex_iter.hpp.

◆ operator*()

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
reference real::compat::regex_token_iterator< BidirIt, CharT, Traits >::operator* ( ) const
inline

Definition at line 267 of file regex_iter.hpp.

◆ operator++() [1/2]

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
regex_token_iterator & real::compat::regex_token_iterator< BidirIt, CharT, Traits >::operator++ ( )
inline

Definition at line 277 of file regex_iter.hpp.

◆ operator++() [2/2]

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
regex_token_iterator real::compat::regex_token_iterator< BidirIt, CharT, Traits >::operator++ ( int  )
inline

Definition at line 308 of file regex_iter.hpp.

◆ operator->()

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
pointer real::compat::regex_token_iterator< BidirIt, CharT, Traits >::operator-> ( ) const
inline

Definition at line 272 of file regex_iter.hpp.

◆ operator==()

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
bool real::compat::regex_token_iterator< BidirIt, CharT, Traits >::operator== ( const regex_token_iterator< BidirIt, CharT, Traits > &  other) const
inline

Definition at line 315 of file regex_iter.hpp.

◆ set_field()

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
void real::compat::regex_token_iterator< BidirIt, CharT, Traits >::set_field ( )
inlineprivate

Computes the current token from the current match and subs_[n_].

Definition at line 343 of file regex_iter.hpp.

Member Data Documentation

◆ at_end_

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
bool real::compat::regex_token_iterator< BidirIt, CharT, Traits >::at_end_ {true}
private

End-of-sequence.

Definition at line 340 of file regex_iter.hpp.

◆ current_

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
value_type real::compat::regex_token_iterator< BidirIt, CharT, Traits >::current_
private

Current token (by value — no aliasing).

Definition at line 337 of file regex_iter.hpp.

◆ has_m1_

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
bool real::compat::regex_token_iterator< BidirIt, CharT, Traits >::has_m1_ {false}
private

Whether a -1 (split) field is present.

Definition at line 338 of file regex_iter.hpp.

◆ n_

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
std::size_t real::compat::regex_token_iterator< BidirIt, CharT, Traits >::n_ {0}
private

Current field index into subs_.

Definition at line 336 of file regex_iter.hpp.

◆ position_

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
regex_iterator<BidirIt, CharT, Traits> real::compat::regex_token_iterator< BidirIt, CharT, Traits >::position_
private

The underlying match walk.

Definition at line 334 of file regex_iter.hpp.

◆ subs_

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
std::vector<int> real::compat::regex_token_iterator< BidirIt, CharT, Traits >::subs_
private

Field selectors, cycled per match.

Definition at line 335 of file regex_iter.hpp.

◆ suffix_mode_

template<typename BidirIt , typename CharT = typename std::iterator_traits<BidirIt>::value_type, typename Traits = std::regex_traits<CharT>>
bool real::compat::regex_token_iterator< BidirIt, CharT, Traits >::suffix_mode_ {false}
private

Emitting the trailing split suffix.

Definition at line 339 of file regex_iter.hpp.


The documentation for this class was generated from the following file: