6#ifndef REAL_STD_REGEX_ITER_HPP
7#define REAL_STD_REGEX_ITER_HPP
28 template <
typename BidirIt,
29 typename CharT =
typename std::iterator_traits<BidirIt>::value_type,
30 typename Traits = std::regex_traits<CharT>>
56 if constexpr (detail::real_eligible<CharT, Traits>) {
90 if constexpr (detail::real_eligible<CharT, Traits>) {
122 return !(*
this == other);
133 std::optional<std::regex_iterator<BidirIt>>
std_it_;
140 const std::string_view sv {std::to_address(
begin_),
141 static_cast<std::size_t
>(std::distance(
begin_,
end_))};
146 if (!result.matched()) {
161 if (*
std_it_ == std::regex_iterator<BidirIt> {}) {
191 template <
typename BidirIt,
192 typename CharT =
typename std::iterator_traits<BidirIt>::value_type,
193 typename Traits = std::regex_traits<CharT>>
217 std::vector<int> {submatch},
226 const std::vector<int>& submatches,
233 for (
const int s :
subs_) {
246 std::initializer_list<int> submatches,
251 std::vector<int>(submatches),
264 const std::vector<int>& submatches,
297 else if (
has_m1_ && prev->suffix().length() != 0) {
329 return !(*
this == other);
A compiled regular expression, parameterized on its storage policy.
A std::basic_regex-compatible pattern, backed by real where proven, else std.
bool posix_longest() const noexcept
Whether this is a POSIX-ERE pattern routed to REAL: search/match must use leftmost-**longest** bounds...
const std::basic_regex< CharT, Traits > & std_engine() const
The std::regex for the std / lazy-std path (built once on demand for a real-backed pattern reached vi...
const std::variant< std::basic_regex< CharT, Traits >, real::regex > & engine() const noexcept
Access the active backend (engine-facing; used by the free functions).
bool uses_real_traversal() const noexcept
Whether replace/iterate run on the real traversal (real-backed AND non-nullable). A nullable pattern ...
The result of a match: group sub-matches plus the prefix and suffix.
void fill_from_real(const RealMatch &match)
Fills from real's byte offsets over the sequence [first_, last_). Templated on the match type — real:...
difference_type position(size_type n=0) const
Start offset of group n from the sequence start. For an out-of-range group std anchors the sub_match ...
void fill_from_std(const StdMatch &match)
Copies from a std::match_results (the fallback path) over the same sequence.
void rebase_prefix(BidirIt first)
Re-bases the unmatched prefix to start at first — for iteration, where a match's prefix runs from the...
void reset(BidirIt first, BidirIt last)
Resets to the not-ready (no-match) state over the sequence [first, last).
difference_type length(size_type n=0) const
Length of group n (0 if out of range or unmatched).
Iterates the non-overlapping matches of a pattern in a sequence (std::regex_iterator).
std::ptrdiff_t difference_type
Iterator traits.
std::forward_iterator_tag iterator_category
std::regex_iterator parity.
regex_iterator(BidirIt first, BidirIt last, const regex_type &&re, regex_constants::match_flag_type flags=regex_constants::match_default)=delete
Constructing from a temporary regex would dangle (std::regex_iterator parity).
void next_real()
Advances the real path: next region search from real_pos_.
pointer operator->() const
bool operator!=(const regex_iterator &other) const
regex_iterator operator++(int)
regex_iterator(BidirIt first, BidirIt last, const regex_type &re, regex_constants::match_flag_type flags=regex_constants::match_default)
Constructs a begin iterator over [first, last) and finds the first match. A constraining match flag (...
regex_constants::match_flag_type flags_
regex_iterator & operator++()
reference operator*() const
bool operator==(const regex_iterator &other) const
void sync_std()
Syncs the std path from the wrapped std::regex_iterator.
std::optional< std::regex_iterator< BidirIt > > std_it_
regex_iterator()=default
Constructs the end sentinel.
Enumerates selected sub-matches (or the text between matches) — std::regex_token_iterator.
pointer operator->() const
void init(BidirIt first, BidirIt last)
Establishes the first token (or the whole-sequence token when there is no match).
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).
bool operator==(const regex_token_iterator &other) const
value_type current_
Current token (by value — no aliasing).
reference operator*() const
bool has_m1_
Whether a -1 (split) field is present.
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).
bool operator!=(const regex_token_iterator &other) const
bool suffix_mode_
Emitting the trailing split suffix.
bool at_end_
End-of-sequence.
regex_token_iterator & operator++()
regex_iterator< BidirIt, CharT, Traits > position_
The underlying match walk.
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 ...
void set_field()
Computes the current token from the current match and subs_[n_].
std::vector< int > subs_
Field selectors, cycled per match.
regex_token_iterator()=default
Constructs the end sentinel.
std::forward_iterator_tag iterator_category
std::regex_token_iterator parity.
std::ptrdiff_t difference_type
Iterator 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)
Selects a list of fields from a braced list (e.g. {-1}).
std::size_t n_
Current field index into subs_.
regex_token_iterator operator++(int)
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 o...
A matched sub-expression: a [first, second) range into the searched sequence.
BidirIt second
One past the end of the sub-match.
BidirIt first
Start of the sub-match.
std::regex_constants::match_flag_type to_std_match(regex_constants::match_flag_type f) noexcept
Maps compat match/format flags to std::regex_constants — exhaustive (the std path).
bool real_honors(regex_constants::match_flag_type mf) noexcept
Whether real can honor the requested match flags, so the operation may stay on it.
match_flag_type
Match-control flags: the common subset.
@ first
Leftmost-first (Perl / Python re / the crate): source-order thread priority decides....
flags
Compilation flags, mirroring Python's re.I, re.M and re.S.
std::regex-compatibility layer, part 2/3: sub_match, match_results, the shared runner,...