REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
Loading...
Searching...
No Matches
real::basic_match_range< Storage, TrailingLA > Class Template Reference

A range of matches, returned by find_iter() and usable in range-for. More...

#include <real.hpp>

Collaboration diagram for real::basic_match_range< Storage, TrailingLA >:
[legend]

Public Member Functions

constexpr basic_match_range (detail::program_view prog, std::string_view pattern, std::string_view text, std::size_t start=0, match_semantics sem=match_semantics::first, bool matching_only=false)
 Binds the range to a compiled program and a subject.
 
constexpr basic_match_iterator< Storage, TrailingLA > begin () const
 Returns an iterator to the first match.
 
constexpr basic_match_iterator< Storage, TrailingLA > end () const
 Returns the end sentinel.
 

Private Attributes

detail::program_view prog_
 The program being run.
 
std::string_view pattern_
 Pattern text (named lookups).
 
std::string_view text_
 The text to iterate.
 
std::size_t start_ {}
 Byte offset to begin iterating from (region support).
 
match_semantics sem_ {match_semantics::first}
 leftmost-first (default) or longest.
 

Detailed Description

template<typename Storage, bool TrailingLA = false>
class real::basic_match_range< Storage, TrailingLA >

A range of matches, returned by find_iter() and usable in range-for.

The regex and the text must outlive the range. Empty matches follow Python: an empty match is yielded, then the scan advances one codepoint.

Template Parameters
StorageThe regex's storage policy.

Constructor & Destructor Documentation

◆ basic_match_range()

template<typename Storage , bool TrailingLA = false>
constexpr real::basic_match_range< Storage, TrailingLA >::basic_match_range ( detail::program_view  prog,
std::string_view  pattern,
std::string_view  text,
std::size_t  start = 0,
match_semantics  sem = match_semantics::first,
bool  matching_only = false 
)
inlineconstexpr

Binds the range to a compiled program and a subject.

Called by basic_regex::find_iter; not constructed by user code.

Parameters
[in]progThe compiled program.
[in]patternThe pattern text (for named-group resolution).
[in]textThe text to iterate over (borrowed).
[in]startByte offset to begin iterating from (0 = the whole text).
[in]semMatch semantics: leftmost-first (default) or leftmost-longest.
[in]matching_onlyCapture-free walk for a caller that reads no groups (basic_regex::count_matches). Ignored unless the program is structurally eligible.

Member Function Documentation

◆ begin()

template<typename Storage , bool TrailingLA = false>
constexpr basic_match_iterator< Storage, TrailingLA > real::basic_match_range< Storage, TrailingLA >::begin ( ) const
inlineconstexpr

Returns an iterator to the first match.

Returns
An iterator positioned on the first match, or equal to end when there is none.

◆ end()

template<typename Storage , bool TrailingLA = false>
constexpr basic_match_iterator< Storage, TrailingLA > real::basic_match_range< Storage, TrailingLA >::end ( ) const
inlineconstexpr

Returns the end sentinel.

Returns
The past-the-end iterator.

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