REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
Loading...
Searching...
No Matches
real::compat::re2::RE2::Set Class Reference

RE2::Set — a set of patterns tested together. Mirrors real RE2's Set: buffer patterns with Add, Compile once, then Match repeatedly. Maps directly onto REAL's native real::regex_set::which() (index-list semantics match exactly). More...

#include <re2.hpp>

Collaboration diagram for real::compat::re2::RE2::Set:
[legend]

Public Member Functions

 Set (const Options &options, Anchor anchor)
 Starts an empty set.
 
int Add (std::string_view pattern, std::string *error)
 Buffers one pattern (validated immediately, like real RE2's Add).
 
bool Compile ()
 Compiles every buffered pattern into one real::regex_set.
 
bool Match (std::string_view text, std::vector< int > *v) const
 Tests text against every compiled member.
 

Private Member Functions

std::string anchor_wrap (std::string_view pattern) const
 Synthesizes anchor_'s semantics by wrapping pattern, since real::regex_set is natively unanchored.
 

Private Attributes

Options options_
 Options shared by every member.
 
Anchor anchor_
 The anchor mode every member is matched with.
 
std::vector< std::string > patterns_
 Buffered, already anchor-wrapped member patterns.
 
std::optional< real::regex_setset_
 Engaged once Compile succeeds.
 

Detailed Description

RE2::Set — a set of patterns tested together. Mirrors real RE2's Set: buffer patterns with Add, Compile once, then Match repeatedly. Maps directly onto REAL's native real::regex_set::which() (index-list semantics match exactly).

Anchor is synthesized by wrapping each added pattern (^(?:…)/^(?:…)$) before compiling, since real::regex_set itself is natively unanchored-search only — documented here rather than silently assumed.

Constructor & Destructor Documentation

◆ Set()

real::compat::re2::RE2::Set::Set ( const Options options,
Anchor  anchor 
)
inline

Starts an empty set.

Parameters
[in]optionsThe options applied to every member pattern.
[in]anchorThe anchor mode every member is matched with.

Member Function Documentation

◆ Add()

int real::compat::re2::RE2::Set::Add ( std::string_view  pattern,
std::string *  error 
)
inline

Buffers one pattern (validated immediately, like real RE2's Add).

Parameters
[in]patternThe pattern text.
[out]errorIf non-null and the pattern is rejected, set to a human-readable reason.
Returns
The pattern's index (matches Match's output indices) on success, or -1.

◆ anchor_wrap()

std::string real::compat::re2::RE2::Set::anchor_wrap ( std::string_view  pattern) const
inlineprivate

Synthesizes anchor_'s semantics by wrapping pattern, since real::regex_set is natively unanchored.

Parameters
[in]patternThe raw member pattern text.
Returns
The pattern text to actually compile.

◆ Compile()

bool real::compat::re2::RE2::Set::Compile ( )
inline

Compiles every buffered pattern into one real::regex_set.

Returns
true on success. false should not happen if every Add already succeeded (each pattern was already probe-compiled individually); kept for API fidelity.

◆ Match()

bool real::compat::re2::RE2::Set::Match ( std::string_view  text,
std::vector< int > *  v 
) const
inline

Tests text against every compiled member.

Parameters
[in]textThe subject text.
[out]vIf non-null, cleared and filled with the indices of every matching member.
Returns
true if at least one member matched.

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