template<fly::StandardCharacter CharType>
struct fly::detail::BasicFormatSpecifier< CharType >
Structure to encapsulate positional and formatting options (which constitute a replacement field) based strongly upon:
https://en.cppreference.com/w/cpp/utility/format/format
https://en.cppreference.com/w/cpp/utility/format/formatter#Standard_format_specification
A replacement field has the following format:
1. An introductory "{" character.
2. An optional non-negative position.
3. An optional colon ":" following by formatting options.
4. A final "}" character.
The postition option specifies the index of the format parameter whose value is to be used for this replacement field. If not specified, the format parameters are used in order. The position option must be specified in all replacements fields or not in any replacement field; mixing of manual and automatic indexing is an error.
Formatting options have the following format, where every field is optional:
1. An optional fill character (which may be any ASCII character other than "{" or "}"),
followed by an alignment option. The alignment option may be one of:
"<" - Forces the field to be aligned to the start of the available space.
">" - Forces the field to be aligned to the end of the available space.
"^" - Forces the field to be centered within the available space.
2. A sign indicator. The sign character may be one of:
"+" - A sign should be used for both non-negative and negative numbers.
"-" - A sign should be used for negative numbers only.
" " - A sign should be used for negative numbers and a leading space should be used
for non-negative numbers.
3. An alternate form indicator (a literal "#" character). If present, the following alternate
forms will be used:
Integral types - If binary, octal, or hexadecimal presentation types are used, the
alternate form inserts 0b, 0, or 0x prefixes, respectively, before the value.
Floating-point types - A decimal point character will always be inserted even if no digits
follow it.
4. A zero-padding indicator (a literal "0" character). If present, the value is padded with
leading zeros. This option is ignored if an alignment option is also specified.
5. A width value. A width is either a positive decimal number or a nested replacement field
(*). If present, it specifies the minimum field width.
6. A precision value. A precision is a decimal (".") followed by a non-negative decimal
number or a nested replacement field (*). If present, it specifies the precision or
maximum field size. It may only be used for the following value types:
String types - precision specifies the maxiumum number of characters to be used.
Floating-point types - precision specifies the formatting precision.
7. A locale-specific form indicator (a literal "L" character). It may only be used for the
following value types:
Integral types - locale-specific form inserts appropriate digit group separator
characters.
Floating-point types - locale-specific form inserts appropriate digit group and radix
separator characters.
Boolean types - locale-specific form uses the appropriate string for textual
representation.
8. A presentation type. The type determines how the value should be presented, where the
allowed presentation type varies by value type:
Character types - Valid presentations: none, "c", b", "B", "o", "d", "x", "X".
String types - Valid presentations: none, "s".
Pointer types - Valid presentations: none, "p".
Integral types - Valid presentations: none, "c", b", "B", "o", "d", "x", "X".
Floating-point types - Valid presentations: none, "a", A", "e", "E", "f", "F", "g", "G".
Boolean types - Valid presentations: none, "c", s", b", "B", "o", "d", "x", "X".
For details on each presentation type, see the above links.
(*) Nested replacement fields are a subset of the full replacement field, and may be of the form "{}" or "{n}", where n is an optional non-negative position. The corresponding format parameter must be an integral type. Its value has the same restrictions as the formatting option it is used for.
- Author
- Timothy Flynn (trfly.nosp@m.nn89.nosp@m.@pm.m.nosp@m.e)
- Version
- January 3, 2021