|
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. | |
| using | allocator_type = Alloc |
| Allocator 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. | |
| size_type | max_size () const noexcept |
| The most marks this object could hold. | |
| bool | empty () const noexcept |
| Whether there are no marks at all. | |
| const_reference | operator[] (size_type n) const |
The sub-match for group n. An out-of-range n yields an unmatched sub-match anchored at the sequence end, as libstdc++ and libc++ do; a token iterator's out-of-range selector relies on it. | |
| difference_type | position (size_type n=0) const |
Start offset of group n; an out-of-range group sits at the end, as in std. | |
| 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 |
| Iteration over the marks, group 0 first. | |
| const_iterator | end () const |
| End of the mark range. | |
| const_iterator | cbegin () const |
| Same as begin; the marks are const either way. | |
| const_iterator | cend () const |
| Same as end. | |
| allocator_type | get_allocator () const |
| The allocator of the sub-match vector. | |
| void | swap (match_results &other) noexcept |
Exchanges the whole state with other. | |
| template<typename OutputIter > | |
| OutputIter | format (OutputIter out, const char_type *fmt_first, const char_type *fmt_last, regex_constants::match_flag_type flags=regex_constants::format_default) const |
Writes [fmt_first, fmt_last) with its references replaced by this match's text (std::match_results::format). | |
| template<typename OutputIter , typename ST , typename SA > | |
| OutputIter | format (OutputIter out, const std::basic_string< char_type, ST, SA > &fmt, regex_constants::match_flag_type flags=regex_constants::format_default) const |
| format over a string format. | |
| template<typename ST , typename SA > | |
| std::basic_string< char_type, ST, SA > | format (const std::basic_string< char_type, ST, SA > &fmt, regex_constants::match_flag_type flags=regex_constants::format_default) const |
| format into a new string. | |
| string_type | format (const char_type *fmt, regex_constants::match_flag_type flags=regex_constants::format_default) const |
| format of a C-string format into a new string. | |
| 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 the result ready but empty, as std leaves it after a failed search or match. | |
| void | rebase_prefix (BidirIt first) |
Starts the prefix at first, as iteration requires; the std path gets this from std::regex_iterator. | |
| template<typename RealMatch > | |
| void | fill_from_real (const RealMatch &match, std::size_t lead=0) |
Fills from REAL's byte offsets over [first_, last_), from any match exposing size, start and end (an engine result, a detail::offset_match). | |
| template<typename RealMatch , typename Cursor > | |
| void | fill_from_real_at (const RealMatch &match, Cursor &at, std::size_t lead=0) |
Fills from REAL's offsets into a copy of a non-contiguous [first_, last_): marks are mapped through at in increasing offset order, so the walk covers their span once whatever the group order. | |
| template<typename StdMatch > | |
| void | fill_from_std (const StdMatch &match) |
Copies from a std::match_results (the fallback path) over the same sequence. | |
Private Member Functions | |
| template<typename OutputIter > | |
| OutputIter | copy_group (OutputIter out, size_type g) const |
Copies group g's text to out, nothing when it did not take part or does not exist. | |
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.
Holds both ends of the searched sequence: the suffix's end is not derivable from a base iterator. Filled from REAL's byte offsets, or copied from a std::match_results on the std path.
| BidirIt | A bidirectional iterator into the searched sequence. |
| Alloc | Allocator for the sub-match vector. |
|
inline |
Iteration over the marks, group 0 first.
std::match_results.
|
inline |
Same as begin; the marks are const either way.
|
inline |
Same as end.
|
inlineprivate |
Copies group g's text to out, nothing when it did not take part or does not exist.
| OutputIter | An output iterator over characters. |
| [out] | out | Where the text is written. |
| [in] | g | The group number. |
out advanced past it.
|
inlinenoexcept |
Whether there are no marks at all.
true when size is 0, i.e. no match was stored.
|
inline |
End of the mark range.
|
inline |
Fills from REAL's byte offsets over [first_, last_), from any match exposing size, start and end (an engine result, a detail::offset_match).
| [in] | match | The engine's result, whose group offsets are byte offsets into the searched view. |
| [in] | lead | How many characters the view holds before first_ (1 under match_prev_avail, the context it searched with); no match starts among them. |
|
inline |
Fills from REAL's offsets into a copy of a non-contiguous [first_, last_): marks are mapped through at in increasing offset order, so the walk covers their span once whatever the group order.
| Cursor | A detail::offset_cursor over the copied sequence. |
| [in] | match | The engine's result, whose offsets index the copy. |
| [in,out] | at | The cursor; at or before the match's start, left at its last mark. |
| [in] | lead | How many characters the copy holds before first_ (1 under match_prev_avail). |
|
inline |
Copies from a std::match_results (the fallback path) over the same sequence.
| [in] | match | The standard library's result to copy marks, prefix and suffix from. |
|
inline |
|
inline |
|
inline |
Writes [fmt_first, fmt_last) with its references replaced by this match's text (std::match_results::format).
ECMAScript rules: a dollar followed by a dollar, an ampersand, a backtick, a quote or one or two digits inserts a dollar, the match, the prefix, the suffix or that group (nothing for a group that does not exist); any other dollar is itself. $0 reads as the native std reads it. format_sed selects sed's.
| OutputIter | An output iterator over characters. |
| [out] | out | Where the result is written. |
| [in] | fmt_first | Start of the format. |
| [in] | fmt_last | One past its end. |
| [in] | flags | format_sed selects sed's rules; the other bits are ignored. |
out advanced past what was written.
|
inline |
format over a string format.
| OutputIter | An output iterator over characters. |
| ST | The format's traits. |
| SA | The format's allocator. |
| [out] | out | Where the result is written. |
| [in] | fmt | The format. |
| [in] | flags | format_sed selects sed's rules. |
out advanced past what was written.
|
inline |
The allocator of the sub-match vector.
|
inline |
Length of group n (0 if out of range or unmatched).
| [in] | n | Group index; 0 is the whole match. |
|
inlinenoexcept |
The most marks this object could hold.
|
inline |
The sub-match for group n. An out-of-range n yields an unmatched sub-match anchored at the sequence end, as libstdc++ and libc++ do; a token iterator's out-of-range selector relies on it.
| [in] | n | Group index; 0 is the whole match. |
n is out of range.
|
inline |
Start offset of group n; an out-of-range group sits at the end, as in std.
| [in] | n | Group index; 0 is the whole match. |
|
inline |
The unmatched prefix (sequence start up to the whole match).
|
inlinenoexcept |
Whether a successful match has been stored.
true once a search or match has filled this object.
|
inline |
Starts the prefix at first, as iteration requires; the std path gets this from std::regex_iterator.
| [in] | first | The previous match's end. |
|
inline |
Resets to the not-ready (no-match) state over the sequence [first, last).
| [in] | first | Start of the sequence this result will describe. |
| [in] | last | One past its end; kept so suffix and lengths stay exact. |
|
inlinenoexcept |
Number of marks (groups), including group 0; 0 when there was no match.
|
inline |
Matched text of group n (empty if out of range or unmatched).
| [in] | n | Group index; 0 is the whole match. |
|
inline |
The unmatched suffix (whole match end to sequence end).
|
inlinenoexcept |
Exchanges the whole state with other.
| [in,out] | other | The result to swap with. |