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

RE2-compatible construction options. Mirrors real RE2's RE2::Options field-for-field (names, defaults); see the file-level doc comment for which fields this layer honors. More...

#include <re2.hpp>

Public Types

enum  Encoding : std::uint8_t { EncodingUTF8 , EncodingLatin1 }
 Pattern/text encoding — real::compat::re2 supports EncodingUTF8 only. More...
 

Public Member Functions

 Options ()=default
 Default options: UTF-8, leftmost-first, case-sensitive, every RE2 default kept.
 
 Options (CannedOptions canned)
 One of RE2's canned option sets. Implicit, as RE2's own, so a canned set passes where Options is taken.
 
std::int64_t max_mem () const noexcept
 The compiled-pattern budget, as RE2's: a program past two thirds of it fails with ErrorPatternTooLarge (at most 1, a 100 000-instruction bound applies instead). Counted in REAL's program bytes (12 per instruction against RE2's 8, no shared prefixes), so a lowered budget does not reject exactly what RE2 rejects; the default rejects nothing REAL compiles.
 
void set_max_mem (std::int64_t value) noexcept
 Sets max_mem.
 
Encoding encoding () const noexcept
 The pattern/text encoding.
 
void set_encoding (Encoding value) noexcept
 Sets encoding. EncodingLatin1 makes the owning RE2 reject at construction.
 
bool posix_syntax () const noexcept
 Whether the pattern is restricted to POSIX egrep syntax; true is rejected at construction.
 
void set_posix_syntax (bool value) noexcept
 Sets posix_syntax.
 
bool longest_match () const noexcept
 Whether to search for the longest match instead of the first; honored by every unanchored search.
 
void set_longest_match (bool value) noexcept
 Sets longest_match.
 
bool log_errors () const noexcept
 Whether compile errors are logged. Reads true by default, as RE2's does; logging itself is opt-in here (see set_log_errors), and RE2::ok()/RE2::error() report errors either way.
 
void set_log_errors (bool value) noexcept
 Sets log_errors. Only an explicit set_log_errors(true) arms RE2's stderr message on a failed compile; set_log_errors(false) disarms it.
 
bool literal () const noexcept
 Whether the pattern is matched as a literal string rather than parsed as a regex. Honored by escaping the pattern (QuoteMeta) before compiling.
 
void set_literal (bool value) noexcept
 Sets literal.
 
bool never_nl () const noexcept
 Whether the pattern must never match \n; true is rejected at construction.
 
void set_never_nl (bool value) noexcept
 Sets never_nl.
 
bool dot_nl () const noexcept
 Whether . also matches \n. Honored via flags::dotall.
 
void set_dot_nl (bool value) noexcept
 Sets dot_nl.
 
bool never_capture () const noexcept
 Whether every (...) parses as non-capturing; true is rejected at construction, since ignoring it would change NumberOfCapturingGroups() and the Arg extractions.
 
void set_never_capture (bool value) noexcept
 Sets never_capture.
 
bool case_sensitive () const noexcept
 Whether matching is case-sensitive (a pattern's (?i) overrides it, as in RE2).
 
void set_case_sensitive (bool value) noexcept
 Sets case_sensitive.
 
bool perl_classes () const noexcept
 Read by RE2 only under posix_syntax, which this layer rejects: inert, as in RE2 without it.
 
void set_perl_classes (bool value) noexcept
 Sets perl_classes (inert; see the getter).
 
bool word_boundary () const noexcept
 Inert, as perl_classes is.
 
void set_word_boundary (bool value) noexcept
 Sets word_boundary (inert; see the getter).
 
bool one_line () const noexcept
 Inert, as perl_classes is.
 
void set_one_line (bool value) noexcept
 Sets one_line (inert; see the getter).
 

Private Attributes

std::int64_t max_mem_ {8 << 20}
 RE2's default budget (see max_mem).
 
Encoding encoding_ {EncodingUTF8}
 The pattern/text encoding.
 
bool posix_syntax_ {false}
 POSIX egrep syntax restriction.
 
bool longest_match_ {false}
 Leftmost-longest vs leftmost-first.
 
bool log_errors_ {true}
 The log_errors setting, true by default as RE2's.
 
bool log_errors_armed_ {false}
 Set by an explicit set_log_errors(true): only then is anything logged.
 
bool literal_ {false}
 Match the pattern as a literal string.
 
bool never_nl_ {false}
 Never match \n.
 
bool dot_nl_ {false}
 . also matches \n.
 
bool never_capture_ {false}
 Parse every (...) as non-capturing.
 
bool case_sensitive_ {true}
 Case-sensitive by default.
 
bool perl_classes_ {false}
 POSIX-mode-only; inert here.
 
bool word_boundary_ {false}
 POSIX-mode-only; inert here.
 
bool one_line_ {false}
 POSIX-mode-only; inert here.
 

Friends

class RE2
 

Detailed Description

RE2-compatible construction options. Mirrors real RE2's RE2::Options field-for-field (names, defaults); see the file-level doc comment for which fields this layer honors.

Member Enumeration Documentation

◆ Encoding

Pattern/text encoding — real::compat::re2 supports EncodingUTF8 only.

Enumerator
EncodingUTF8 

UTF-8 (the default, and the only encoding this layer honors).

EncodingLatin1 

Latin-1 — accepted for API shape, rejected at RE2 construction.

Constructor & Destructor Documentation

◆ Options()

real::compat::re2::RE2::Options::Options ( CannedOptions  canned)
inline

One of RE2's canned option sets. Implicit, as RE2's own, so a canned set passes where Options is taken.

Parameters
[in]cannedThe set.

Member Function Documentation

◆ case_sensitive()

bool real::compat::re2::RE2::Options::case_sensitive ( ) const
inlinenoexcept

Whether matching is case-sensitive (a pattern's (?i) overrides it, as in RE2).

Returns
Whether matching is case-sensitive.

◆ dot_nl()

bool real::compat::re2::RE2::Options::dot_nl ( ) const
inlinenoexcept

Whether . also matches \n. Honored via flags::dotall.

Returns
Whether . matches a newline.

◆ encoding()

Encoding real::compat::re2::RE2::Options::encoding ( ) const
inlinenoexcept

The pattern/text encoding.

Returns
The configured encoding.

◆ literal()

bool real::compat::re2::RE2::Options::literal ( ) const
inlinenoexcept

Whether the pattern is matched as a literal string rather than parsed as a regex. Honored by escaping the pattern (QuoteMeta) before compiling.

Returns
Whether the pattern is treated as a literal string.

◆ log_errors()

bool real::compat::re2::RE2::Options::log_errors ( ) const
inlinenoexcept

Whether compile errors are logged. Reads true by default, as RE2's does; logging itself is opt-in here (see set_log_errors), and RE2::ok()/RE2::error() report errors either way.

Returns
The setting.

◆ longest_match()

bool real::compat::re2::RE2::Options::longest_match ( ) const
inlinenoexcept

Whether to search for the longest match instead of the first; honored by every unanchored search.

Returns
Whether leftmost-longest semantics are selected.

◆ max_mem()

std::int64_t real::compat::re2::RE2::Options::max_mem ( ) const
inlinenoexcept

The compiled-pattern budget, as RE2's: a program past two thirds of it fails with ErrorPatternTooLarge (at most 1, a 100 000-instruction bound applies instead). Counted in REAL's program bytes (12 per instruction against RE2's 8, no shared prefixes), so a lowered budget does not reject exactly what RE2 rejects; the default rejects nothing REAL compiles.

Returns
The budget, in bytes.

◆ never_capture()

bool real::compat::re2::RE2::Options::never_capture ( ) const
inlinenoexcept

Whether every (...) parses as non-capturing; true is rejected at construction, since ignoring it would change NumberOfCapturingGroups() and the Arg extractions.

Returns
Whether capturing groups are demoted to non-capturing.

◆ never_nl()

bool real::compat::re2::RE2::Options::never_nl ( ) const
inlinenoexcept

Whether the pattern must never match \n; true is rejected at construction.

Returns
Whether . and negated classes are barred from matching a newline.

◆ one_line()

bool real::compat::re2::RE2::Options::one_line ( ) const
inlinenoexcept

Inert, as perl_classes is.

Returns
Whether ^/$ match only at the text edges.

◆ perl_classes()

bool real::compat::re2::RE2::Options::perl_classes ( ) const
inlinenoexcept

Read by RE2 only under posix_syntax, which this layer rejects: inert, as in RE2 without it.

Returns
Whether Perl classes (\\d, \\s, \\w) are enabled.

◆ posix_syntax()

bool real::compat::re2::RE2::Options::posix_syntax ( ) const
inlinenoexcept

Whether the pattern is restricted to POSIX egrep syntax; true is rejected at construction.

Returns
Whether POSIX-ERE syntax is selected.

◆ set_case_sensitive()

void real::compat::re2::RE2::Options::set_case_sensitive ( bool  value)
inlinenoexcept

Sets case_sensitive.

Parameters
[in]valueThe new setting.

◆ set_dot_nl()

void real::compat::re2::RE2::Options::set_dot_nl ( bool  value)
inlinenoexcept

Sets dot_nl.

Parameters
[in]valueThe new setting.

◆ set_encoding()

void real::compat::re2::RE2::Options::set_encoding ( Encoding  value)
inlinenoexcept

Sets encoding. EncodingLatin1 makes the owning RE2 reject at construction.

Parameters
[in]valueThe new encoding.

◆ set_literal()

void real::compat::re2::RE2::Options::set_literal ( bool  value)
inlinenoexcept

Sets literal.

Parameters
[in]valueThe new setting.

◆ set_log_errors()

void real::compat::re2::RE2::Options::set_log_errors ( bool  value)
inlinenoexcept

Sets log_errors. Only an explicit set_log_errors(true) arms RE2's stderr message on a failed compile; set_log_errors(false) disarms it.

Parameters
[in]valueThe new setting.

◆ set_longest_match()

void real::compat::re2::RE2::Options::set_longest_match ( bool  value)
inlinenoexcept

Sets longest_match.

Parameters
[in]valueThe new setting.

◆ set_max_mem()

void real::compat::re2::RE2::Options::set_max_mem ( std::int64_t  value)
inlinenoexcept

Sets max_mem.

Parameters
[in]valueThe new budget, in bytes.

◆ set_never_capture()

void real::compat::re2::RE2::Options::set_never_capture ( bool  value)
inlinenoexcept

Sets never_capture.

Parameters
[in]valuetrue makes the owning RE2 reject at construction.

◆ set_never_nl()

void real::compat::re2::RE2::Options::set_never_nl ( bool  value)
inlinenoexcept

Sets never_nl.

Parameters
[in]valuetrue makes the owning RE2 reject at construction.

◆ set_one_line()

void real::compat::re2::RE2::Options::set_one_line ( bool  value)
inlinenoexcept

Sets one_line (inert; see the getter).

Parameters
[in]valueStored, not consulted.

◆ set_perl_classes()

void real::compat::re2::RE2::Options::set_perl_classes ( bool  value)
inlinenoexcept

Sets perl_classes (inert; see the getter).

Parameters
[in]valueStored, not consulted.

◆ set_posix_syntax()

void real::compat::re2::RE2::Options::set_posix_syntax ( bool  value)
inlinenoexcept

Sets posix_syntax.

Parameters
[in]valuetrue makes the owning RE2 reject at construction.

◆ set_word_boundary()

void real::compat::re2::RE2::Options::set_word_boundary ( bool  value)
inlinenoexcept

Sets word_boundary (inert; see the getter).

Parameters
[in]valueStored, not consulted.

◆ word_boundary()

bool real::compat::re2::RE2::Options::word_boundary ( ) const
inlinenoexcept

Inert, as perl_classes is.

Returns
Whether \\b and \\B are enabled.

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