|
REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
|
The result of a match: group sub-matches plus the prefix and suffix. More...
#include <regex_match.hpp>
Public Types | |
| using | value_type = sub_match< BidirIt > |
| Element type. | |
| using | const_reference = const value_type & |
| Reference type. | |
| using | reference = value_type & |
| Reference type. | |
| using | const_iterator = typename std::vector< value_type, Alloc >::const_iterator |
| Iterator. | |
| using | iterator = const_iterator |
| Iterators are const (std parity). | |
| using | difference_type = typename std::iterator_traits< BidirIt >::difference_type |
| Distance type. | |
| using | size_type = std::size_t |
| Size type. | |
| using | char_type = typename std::iterator_traits< BidirIt >::value_type |
| Character type. | |
| using | string_type = std::basic_string< char_type > |
| Owning string type. | |
Public Member Functions | |
| bool | ready () const noexcept |
| Whether a successful match has been stored. | |
| size_type | size () const noexcept |
| Number of marks (groups), including group 0; 0 when there was no match. | |
| bool | empty () const noexcept |
| const_reference | operator[] (size_type n) const |
The sub-match for group n (group 0 is the whole match). Out-of-range n returns a reference to an unmatched sub_match anchored at the sequence end {last_, last_, false}, exactly like std::match_results::operator[] (verified on libc++ and libstdc++) — never out-of-bounds. A token selector {2}/{5} or a negative field relies on this. | |
| 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 at the end, so the offset is the full sequence length. | |
| difference_type | length (size_type n=0) const |
Length of group n (0 if out of range or unmatched). | |
| string_type | str (size_type n=0) const |
Matched text of group n (empty if out of range or unmatched). | |
| const value_type & | prefix () const |
| The unmatched prefix (sequence start up to the whole match). | |
| const value_type & | suffix () const |
| The unmatched suffix (whole match end to sequence end). | |
| const_iterator | begin () const |
| const_iterator | end () const |
| const_iterator | cbegin () const |
| const_iterator | cend () const |
| void | reset (BidirIt first, BidirIt last) |
Resets to the not-ready (no-match) state over the sequence [first, last). | |
| void | set_ready_no_match () |
Marks a ready but unmatched result — after a failed search/match std leaves ready() == true with size() == 0 (a not-ready result would be a divergence). | |
| void | rebase_prefix (BidirIt first) |
Re-bases the unmatched prefix to start at first — for iteration, where a match's prefix runs from the previous match's end (not the sequence start). The std path already gets this from the wrapped std::regex_iterator; the real path needs it. | |
| template<typename RealMatch > | |
| void | fill_from_real (const RealMatch &match) |
Fills from real's byte offsets over the sequence [first_, last_). Templated on the match type — real::regex::search returns an SBO-backed result, not the std::vector-backed real::match_result alias. | |
| template<typename StdMatch > | |
| void | fill_from_std (const StdMatch &match) |
| Copies from a std::match_results (the fallback path) over the same sequence. | |
Private Attributes | |
| BidirIt | first_ {} |
| Start of the searched sequence. | |
| BidirIt | last_ {} |
| End of the searched sequence. | |
| std::vector< value_type, Alloc > | groups_ |
| Group sub-matches (0 = whole match). | |
| value_type | prefix_ {} |
| Unmatched prefix. | |
| value_type | suffix_ {} |
| Unmatched suffix. | |
| value_type | unmatched_ {} |
| Sentinel for out-of-range operator[] (anchored at last_). | |
| bool | ready_ {false} |
| Whether a match is stored. | |
The result of a match: group sub-matches plus the prefix and suffix.
Stores both ends of the searched sequence (first_, last_) so suffix() and lengths are exact (the end is not derivable from a base pointer alone). Filled either from real's byte offsets or copied from a std::match_results on the fallback path.
| BidirIt | A contiguous iterator into the searched sequence. |
| Alloc | Allocator for the sub-match vector (std parity; default suffices). |
Definition at line 116 of file regex_match.hpp.
| using real::compat::match_results< BidirIt, Alloc >::char_type = typename std::iterator_traits<BidirIt>::value_type |
Character type.
Definition at line 127 of file regex_match.hpp.
| using real::compat::match_results< BidirIt, Alloc >::const_iterator = typename std::vector<value_type, Alloc>::const_iterator |
Iterator.
Definition at line 123 of file regex_match.hpp.
| using real::compat::match_results< BidirIt, Alloc >::const_reference = const value_type& |
Reference type.
Definition at line 121 of file regex_match.hpp.
| using real::compat::match_results< BidirIt, Alloc >::difference_type = typename std::iterator_traits<BidirIt>::difference_type |
Distance type.
Definition at line 125 of file regex_match.hpp.
| using real::compat::match_results< BidirIt, Alloc >::iterator = const_iterator |
Iterators are const (std parity).
Definition at line 124 of file regex_match.hpp.
| using real::compat::match_results< BidirIt, Alloc >::reference = value_type& |
Reference type.
Definition at line 122 of file regex_match.hpp.
| using real::compat::match_results< BidirIt, Alloc >::size_type = std::size_t |
Size type.
Definition at line 126 of file regex_match.hpp.
| using real::compat::match_results< BidirIt, Alloc >::string_type = std::basic_string<char_type> |
Owning string type.
Definition at line 128 of file regex_match.hpp.
| using real::compat::match_results< BidirIt, Alloc >::value_type = sub_match<BidirIt> |
Element type.
Definition at line 120 of file regex_match.hpp.
|
inline |
Definition at line 188 of file regex_match.hpp.
|
inline |
Definition at line 198 of file regex_match.hpp.
|
inline |
Definition at line 203 of file regex_match.hpp.
|
inlinenoexcept |
Definition at line 142 of file regex_match.hpp.
|
inline |
Definition at line 193 of file regex_match.hpp.
|
inline |
Fills from real's byte offsets over the sequence [first_, last_). Templated on the match type — real::regex::search returns an SBO-backed result, not the std::vector-backed real::match_result alias.
Definition at line 243 of file regex_match.hpp.
|
inline |
Copies from a std::match_results (the fallback path) over the same sequence.
Definition at line 273 of file regex_match.hpp.
|
inline |
Length of group n (0 if out of range or unmatched).
Definition at line 165 of file regex_match.hpp.
|
inline |
The sub-match for group n (group 0 is the whole match). Out-of-range n returns a reference to an unmatched sub_match anchored at the sequence end {last_, last_, false}, exactly like std::match_results::operator[] (verified on libc++ and libstdc++) — never out-of-bounds. A token selector {2}/{5} or a negative field relies on this.
Definition at line 151 of file regex_match.hpp.
|
inline |
Start offset of group n from the sequence start. For an out-of-range group std anchors the sub_match at the end, so the offset is the full sequence length.
Definition at line 158 of file regex_match.hpp.
|
inline |
The unmatched prefix (sequence start up to the whole match).
Definition at line 177 of file regex_match.hpp.
|
inlinenoexcept |
Whether a successful match has been stored.
Definition at line 131 of file regex_match.hpp.
|
inline |
Re-bases the unmatched prefix to start at first — for iteration, where a match's prefix runs from the previous match's end (not the sequence start). The std path already gets this from the wrapped std::regex_iterator; the real path needs it.
Definition at line 233 of file regex_match.hpp.
|
inline |
Resets to the not-ready (no-match) state over the sequence [first, last).
Definition at line 211 of file regex_match.hpp.
|
inline |
Marks a ready but unmatched result — after a failed search/match std leaves ready() == true with size() == 0 (a not-ready result would be a divergence).
Definition at line 224 of file regex_match.hpp.
|
inlinenoexcept |
Number of marks (groups), including group 0; 0 when there was no match.
Definition at line 137 of file regex_match.hpp.
|
inline |
Matched text of group n (empty if out of range or unmatched).
Definition at line 171 of file regex_match.hpp.
|
inline |
The unmatched suffix (whole match end to sequence end).
Definition at line 183 of file regex_match.hpp.
|
private |
Start of the searched sequence.
Definition at line 289 of file regex_match.hpp.
|
private |
Group sub-matches (0 = whole match).
Definition at line 291 of file regex_match.hpp.
|
private |
End of the searched sequence.
Definition at line 290 of file regex_match.hpp.
|
private |
Unmatched prefix.
Definition at line 292 of file regex_match.hpp.
|
private |
Whether a match is stored.
Definition at line 295 of file regex_match.hpp.
|
private |
Unmatched suffix.
Definition at line 293 of file regex_match.hpp.
|
private |
Sentinel for out-of-range operator[] (anchored at last_).
Definition at line 294 of file regex_match.hpp.