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>
|
| | 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.
|
| |
|
|
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_set > | set_ |
| | Engaged once Compile succeeds.
|
| |
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.
◆ Set()
| real::compat::re2::RE2::Set::Set |
( |
const Options & |
options, |
|
|
Anchor |
anchor |
|
) |
| |
|
inline |
Starts an empty set.
- Parameters
-
| [in] | options | The options applied to every member pattern. |
| [in] | anchor | The anchor mode every member is matched with. |
◆ 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] | pattern | The pattern text. |
| [out] | error | If 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] | pattern | The 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] | text | The subject text. |
| [out] | v | If 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: