|
|
constexpr | Arg () noexcept |
| | Default-constructs a no-op Arg (same as Arg(nullptr)).
|
| |
|
constexpr | Arg (std::nullptr_t) noexcept |
| | From nullptr — skips this submatch (always "succeeds", writes nothing).
|
| |
| template<typename T > |
| | Arg (T *dest) noexcept |
| | From a destination pointer — the common case (&i, &s, &d, …).
|
| |
| constexpr | Arg (void *dest, Parser parser) noexcept |
| | From an explicit destination and parser — the escape hatch for a custom radix or a caller-supplied type not covered by the T* constructor.
|
| |
| bool | parse (const char *text, std::size_t length) const |
| | Parses [text, text + length) into the destination.
|
| |
|
| static bool | parse_nothing (const char *, std::size_t, void *) |
| | The nullptr-destination parser: always succeeds, writes nothing.
|
| |
| static bool | parse_bool (const char *text, std::size_t length, bool &out) |
| | Parses into a bool: "1"/"true" -> true, "0"/"false" -> false, else fails.
|
| |
| template<typename T > |
| static bool | parse_integral (const char *text, std::size_t length, T &out) |
| | Parses into an integral type via std::from_chars (base 10, locale-free).
|
| |
| template<typename T > |
| static bool | parse_floating (const char *text, std::size_t length, T &out) |
| | Parses into a floating-point type via the strto* matching T, on a NUL-terminated buffer.
|
| |
| template<typename T > |
| static bool | parse_into (const char *text, std::size_t length, void *dest) |
| | Dispatches to the parser for T — the function stored as this Arg's Parser.
|
| |
A type-erased destination for one captured submatch, built implicitly from T*.
Constructed implicitly from a pointer to any supported destination type (std::string, std::string_view, bool, or an integral/floating-point type), or from nullptr to skip a group without extracting it. FullMatch/PartialMatch/Consume/FindAndConsume take these by value in a variadic pack; each successful parse writes into the pointee, a failed one (a submatch that does not convert, e.g. text into an int) fails the whole match call.
template<typename T >
| static bool real::compat::re2::Arg::parse_floating |
( |
const char * |
text, |
|
|
std::size_t |
length, |
|
|
T & |
out |
|
) |
| |
|
inlinestaticprivate |
Parses into a floating-point type via the strto* matching T, on a NUL-terminated buffer.
Not std::from_chars: some standard libraries explicitly delete its floating-point overload, so the strto* family is the portable floor rather than a preference. They are locale-sensitive in general, but this call site only ever sees digits, ., e, + and - from a regex submatch, and on those every locale agrees with "C".
The conversion is picked to match T rather than always going through double: parsing a float with strtod would accept a value the destination cannot hold and silently narrow it to infinity, where strtof reports the overflow through ERANGE. RE2 dispatches the same way.
- Template Parameters
-
| T | A floating-point destination type. |
- Parameters
-
| [in] | text | The submatch's first byte. |
| [in] | length | The submatch's length in bytes. |
| [out] | out | Set on success only. |
- Returns
true when the whole submatch is consumed and the value is within T's range.