template <FormatConversionCharSet... C>
class ExtendedParsedFormat
Defined at line 220 of file ../../third_party/abseil-cpp/absl/strings/internal/str_format/parser.h
A value type representing a preparsed format. These can be created, copied
around, and reused to speed up formatting loops.
The user must specify through the template arguments the conversion
characters used in the format. This will be checked at compile time.
This class uses Conv enum values to specify each argument.
This allows for more flexibility as you can specify multiple possible
conversion characters for each argument.
ParsedFormat
<char
...> is a simplified alias for when the user only
needs to specify a single conversion character for each argument.
Example:
// Extended format supports multiple characters per argument:
using MyFormat = ExtendedParsedFormat
<Conv
::d | Conv::x>;
MyFormat GetFormat(bool use_hex) {
if (use_hex) return MyFormat("foo %x bar");
return MyFormat("foo %d bar");
}
// 'format' can be used with any value that supports 'd' and 'x',
// like `int`.
auto format = GetFormat(use_hex);
value = StringF(format, i);
This class also supports runtime format checking with the ::New() and
::NewAllowIgnored() factory functions.
This is the only API that allows the user to pass a runtime specified format
string. These factory functions will return NULL if the format does not match
the conversions requested by the user.
Public Methods
void ExtendedParsedFormat<C...> (string_view format)
Defined at line 222 of file ../../third_party/abseil-cpp/absl/strings/internal/str_format/parser.h
std::unique_ptr<ExtendedParsedFormat<C...>> New (string_view format)
ExtendedParsedFormat factory function.
The user still has to specify the conversion characters, but they will not
be checked at compile time. Instead, it will be checked at runtime.
This delays the checking to runtime, but allows the user to pass
dynamically sourced formats.
It returns NULL if the format does not match the conversion characters.
The user is responsible for checking the return value before using it.
The 'New' variant will check that all the specified arguments are being
consumed by the format and return NULL if any argument is being ignored.
The 'NewAllowIgnored' variant will not verify this and will allow formats
that ignore arguments.
Defined at line 245 of file ../../third_party/abseil-cpp/absl/strings/internal/str_format/parser.h
std::unique_ptr<ExtendedParsedFormat<C...>> NewAllowIgnored (string_view format)
Defined at line 248 of file ../../third_party/abseil-cpp/absl/strings/internal/str_format/parser.h