FormatSpec Struct
Thin wrapper around FormatTag with implicit string conversions. More...
Declaration
Included Headers
Public Constructors Index
| constexpr | FormatSpec ()=default |
|
Default-construct as unset (Auto). More... | |
| constexpr | FormatSpec (FormatTag value) |
|
Construct from a FormatTag value. More... | |
| FormatSpec (const std::string &value) | |
|
Parse from a string token (case-insensitive); unknown tokens become Auto. More... | |
| FormatSpec (const char *value) | |
|
Parse from a C string token; null pointer treated as empty. More... | |
Public Operators Index
| FormatSpec & | operator= (FormatTag value) |
|
Assign from a FormatTag. More... | |
| FormatSpec & | operator= (const std::string &value) |
|
Assign from a parsed string token. More... | |
| FormatSpec & | operator= (const char *value) |
|
Assign from a parsed C string token. More... | |
| bool | operator== (const FormatSpec &other) const |
|
Equality compares the underlying tag. More... | |
| bool | operator!= (const FormatSpec &other) const |
|
Inequality compares the underlying tag. More... | |
| operator bool () const | |
|
True iff the tag is set (anything other than Auto). More... | |
| operator std::string () const | |
|
Implicit conversion to canonical string token. More... | |
Public Member Functions Index
| bool | empty () const |
|
True iff the tag is Auto (unset). More... | |
| std::string | str () const |
|
Canonical string form of the tag. More... | |
Public Member Attributes Index
| FormatTag | tag = FormatTag::Auto |
|
Underlying tag (defaults to unset). More... | |
Description
Thin wrapper around FormatTag with implicit string conversions.
Used in option structs and caps fields where a format may arrive as either a FormatTag enum value or a string token. Implicit conversions to/from std::string keep call sites compact; the empty() and operator bool() predicates both treat Auto as "unset".
- See Also
Definition at line 285 of file FormatSpec.h.
Public Constructors
FormatSpec()
| constexpr default |
Default-construct as unset (Auto).
Definition at line 289 of file FormatSpec.h.
FormatSpec()
| inline constexpr |
Construct from a FormatTag value.
Definition at line 291 of file FormatSpec.h.
FormatSpec()
| inline |
Parse from a string token (case-insensitive); unknown tokens become Auto.
Definition at line 293 of file FormatSpec.h.
FormatSpec()
| inline |
Parse from a C string token; null pointer treated as empty.
Definition at line 295 of file FormatSpec.h.
Public Operators
operator bool()
| inline explicit |
True iff the tag is set (anything other than Auto).
Definition at line 331 of file FormatSpec.h.