Mercurial > minori
annotate dep/fmt/doc/html/_sources/syntax.rst.txt @ 368:6d37a998cf91
gui/dialog: consolidate win32 dark theme cruft into a single class
| author | Paper <paper@tflc.us> | 
|---|---|
| date | Fri, 25 Jul 2025 10:05:23 -0400 | 
| parents | 1faa72660932 | 
| children | 
| rev | line source | 
|---|---|
| 343 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 1 .. _syntax: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 2 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 3 ******************** | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 4 Format String Syntax | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 5 ******************** | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 6 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 7 Formatting functions such as :ref:`fmt::format() <format>` and | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 8 :ref:`fmt::print() <print>` use the same format string syntax described in this | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 9 section. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 10 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 11 Format strings contain "replacement fields" surrounded by curly braces ``{}``. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 12 Anything that is not contained in braces is considered literal text, which is | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 13 copied unchanged to the output. If you need to include a brace character in the | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 14 literal text, it can be escaped by doubling: ``{{`` and ``}}``. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 15 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 16 The grammar for a replacement field is as follows: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 17 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 18 .. productionlist:: sf | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 19 replacement_field: "{" [`arg_id`] [":" (`format_spec` | `chrono_format_spec`)] "}" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 20 arg_id: `integer` | `identifier` | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 21 integer: `digit`+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 22 digit: "0"..."9" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 23 identifier: `id_start` `id_continue`* | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 24 id_start: "a"..."z" | "A"..."Z" | "_" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 25 id_continue: `id_start` | `digit` | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 26 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 27 In less formal terms, the replacement field can start with an *arg_id* | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 28 that specifies the argument whose value is to be formatted and inserted into | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 29 the output instead of the replacement field. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 30 The *arg_id* is optionally followed by a *format_spec*, which is preceded by a | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 31 colon ``':'``. These specify a non-default format for the replacement value. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 32 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 33 See also the :ref:`formatspec` section. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 34 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 35 If the numerical arg_ids in a format string are 0, 1, 2, ... in sequence, | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 36 they can all be omitted (not just some) and the numbers 0, 1, 2, ... will be | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 37 automatically inserted in that order. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 38 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 39 Named arguments can be referred to by their names or indices. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 40 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 41 Some simple format string examples:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 42 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 43 "First, thou shalt count to {0}" // References the first argument | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 44 "Bring me a {}" // Implicitly references the first argument | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 45 "From {} to {}" // Same as "From {0} to {1}" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 46 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 47 The *format_spec* field contains a specification of how the value should be | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 48 presented, including such details as field width, alignment, padding, decimal | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 49 precision and so on. Each value type can define its own "formatting | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 50 mini-language" or interpretation of the *format_spec*. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 51 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 52 Most built-in types support a common formatting mini-language, which is | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 53 described in the next section. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 54 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 55 A *format_spec* field can also include nested replacement fields in certain | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 56 positions within it. These nested replacement fields can contain only an | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 57 argument id; format specifications are not allowed. This allows the formatting | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 58 of a value to be dynamically specified. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 59 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 60 See the :ref:`formatexamples` section for some examples. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 61 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 62 .. _formatspec: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 63 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 64 Format Specification Mini-Language | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 65 ================================== | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 66 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 67 "Format specifications" are used within replacement fields contained within a | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 68 format string to define how individual values are presented (see | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 69 :ref:`syntax`). Each formattable type may define how the format | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 70 specification is to be interpreted. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 71 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 72 Most built-in types implement the following options for format specifications, | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 73 although some of the formatting options are only supported by the numeric types. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 74 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 75 The general form of a *standard format specifier* is: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 76 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 77 .. productionlist:: sf | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 78 format_spec: [[`fill`]`align`][`sign`]["#"]["0"][`width`]["." `precision`]["L"][`type`] | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 79 fill: <a character other than '{' or '}'> | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 80 align: "<" | ">" | "^" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 81 sign: "+" | "-" | " " | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 82 width: `integer` | "{" [`arg_id`] "}" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 83 precision: `integer` | "{" [`arg_id`] "}" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 84 type: "a" | "A" | "b" | "B" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 85 : "o" | "p" | "s" | "x" | "X" | "?" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 86 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 87 The *fill* character can be any Unicode code point other than ``'{'`` or | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 88 ``'}'``. The presence of a fill character is signaled by the character following | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 89 it, which must be one of the alignment options. If the second character of | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 90 *format_spec* is not a valid alignment option, then it is assumed that both the | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 91 fill character and the alignment option are absent. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 92 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 93 The meaning of the various alignment options is as follows: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 94 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 95 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 96 | Option | Meaning | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 97 +=========+==========================================================+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 98 | ``'<'`` | Forces the field to be left-aligned within the available | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 99 | | space (this is the default for most objects). | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 100 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 101 | ``'>'`` | Forces the field to be right-aligned within the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 102 | | available space (this is the default for numbers). | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 103 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 104 | ``'^'`` | Forces the field to be centered within the available | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 105 | | space. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 106 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 107 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 108 Note that unless a minimum field width is defined, the field width will always | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 109 be the same size as the data to fill it, so that the alignment option has no | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 110 meaning in this case. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 111 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 112 The *sign* option is only valid for floating point and signed integer types, | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 113 and can be one of the following: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 114 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 115 +---------+------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 116 | Option | Meaning | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 117 +=========+============================================================+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 118 | ``'+'`` | indicates that a sign should be used for both | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 119 | | nonnegative as well as negative numbers. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 120 +---------+------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 121 | ``'-'`` | indicates that a sign should be used only for negative | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 122 | | numbers (this is the default behavior). | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 123 +---------+------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 124 | space | indicates that a leading space should be used on | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 125 | | nonnegative numbers, and a minus sign on negative numbers. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 126 +---------+------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 127 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 128 The ``'#'`` option causes the "alternate form" to be used for the | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 129 conversion. The alternate form is defined differently for different | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 130 types. This option is only valid for integer and floating-point types. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 131 For integers, when binary, octal, or hexadecimal output is used, this | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 132 option adds the prefix respective ``"0b"`` (``"0B"``), ``"0"``, or | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 133 ``"0x"`` (``"0X"``) to the output value. Whether the prefix is | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 134 lower-case or upper-case is determined by the case of the type | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 135 specifier, for example, the prefix ``"0x"`` is used for the type ``'x'`` | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 136 and ``"0X"`` is used for ``'X'``. For floating-point numbers the | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 137 alternate form causes the result of the conversion to always contain a | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 138 decimal-point character, even if no digits follow it. Normally, a | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 139 decimal-point character appears in the result of these conversions | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 140 only if a digit follows it. In addition, for ``'g'`` and ``'G'`` | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 141 conversions, trailing zeros are not removed from the result. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 142 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 143 .. ifconfig:: False | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 144 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 145 The ``','`` option signals the use of a comma for a thousands separator. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 146 For a locale aware separator, use the ``'L'`` integer presentation type | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 147 instead. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 148 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 149 *width* is a decimal integer defining the minimum field width. If not | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 150 specified, then the field width will be determined by the content. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 151 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 152 Preceding the *width* field by a zero (``'0'``) character enables sign-aware | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 153 zero-padding for numeric types. It forces the padding to be placed after the | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 154 sign or base (if any) but before the digits. This is used for printing fields in | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 155 the form '+000000120'. This option is only valid for numeric types and it has no | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 156 effect on formatting of infinity and NaN. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 157 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 158 The *precision* is a decimal number indicating how many digits should be | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 159 displayed after the decimal point for a floating-point value formatted with | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 160 ``'f'`` and ``'F'``, or before and after the decimal point for a floating-point | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 161 value formatted with ``'g'`` or ``'G'``. For non-number types the field | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 162 indicates the maximum field size - in other words, how many characters will be | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 163 used from the field content. The *precision* is not allowed for integer, | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 164 character, Boolean, and pointer values. Note that a C string must be | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 165 null-terminated even if precision is specified. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 166 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 167 The ``'L'`` option uses the current locale setting to insert the appropriate | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 168 number separator characters. This option is only valid for numeric types. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 169 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 170 Finally, the *type* determines how the data should be presented. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 171 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 172 The available string presentation types are: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 173 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 174 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 175 | Type | Meaning | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 176 +=========+==========================================================+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 177 | ``'s'`` | String format. This is the default type for strings and | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 178 | | may be omitted. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 179 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 180 | ``'?'`` | Debug format. The string is quoted and special | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 181 | | characters escaped. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 182 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 183 | none | The same as ``'s'``. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 184 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 185 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 186 The available character presentation types are: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 187 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 188 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 189 | Type | Meaning | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 190 +=========+==========================================================+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 191 | ``'c'`` | Character format. This is the default type for | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 192 | | characters and may be omitted. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 193 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 194 | ``'?'`` | Debug format. The character is quoted and special | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 195 | | characters escaped. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 196 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 197 | none | The same as ``'c'``. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 198 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 199 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 200 The available integer presentation types are: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 201 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 202 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 203 | Type | Meaning | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 204 +=========+==========================================================+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 205 | ``'b'`` | Binary format. Outputs the number in base 2. Using the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 206 | | ``'#'`` option with this type adds the prefix ``"0b"`` | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 207 | | to the output value. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 208 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 209 | ``'B'`` | Binary format. Outputs the number in base 2. Using the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 210 | | ``'#'`` option with this type adds the prefix ``"0B"`` | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 211 | | to the output value. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 212 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 213 | ``'c'`` | Character format. Outputs the number as a character. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 214 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 215 | ``'d'`` | Decimal integer. Outputs the number in base 10. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 216 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 217 | ``'o'`` | Octal format. Outputs the number in base 8. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 218 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 219 | ``'x'`` | Hex format. Outputs the number in base 16, using | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 220 | | lower-case letters for the digits above 9. Using the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 221 | | ``'#'`` option with this type adds the prefix ``"0x"`` | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 222 | | to the output value. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 223 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 224 | ``'X'`` | Hex format. Outputs the number in base 16, using | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 225 | | upper-case letters for the digits above 9. Using the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 226 | | ``'#'`` option with this type adds the prefix ``"0X"`` | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 227 | | to the output value. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 228 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 229 | none | The same as ``'d'``. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 230 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 231 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 232 Integer presentation types can also be used with character and Boolean values | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 233 with the only exception that ``'c'`` cannot be used with `bool`. Boolean values | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 234 are formatted using textual representation, either ``true`` or ``false``, if the | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 235 presentation type is not specified. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 236 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 237 The available presentation types for floating-point values are: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 238 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 239 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 240 | Type | Meaning | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 241 +=========+==========================================================+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 242 | ``'a'`` | Hexadecimal floating point format. Prints the number in | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 243 | | base 16 with prefix ``"0x"`` and lower-case letters for | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 244 | | digits above 9. Uses ``'p'`` to indicate the exponent. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 245 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 246 | ``'A'`` | Same as ``'a'`` except it uses upper-case letters for | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 247 | | the prefix, digits above 9 and to indicate the exponent. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 248 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 249 | ``'e'`` | Exponent notation. Prints the number in scientific | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 250 | | notation using the letter 'e' to indicate the exponent. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 251 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 252 | ``'E'`` | Exponent notation. Same as ``'e'`` except it uses an | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 253 | | upper-case ``'E'`` as the separator character. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 254 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 255 | ``'f'`` | Fixed point. Displays the number as a fixed-point | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 256 | | number. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 257 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 258 | ``'F'`` | Fixed point. Same as ``'f'``, but converts ``nan`` to | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 259 | | ``NAN`` and ``inf`` to ``INF``. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 260 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 261 | ``'g'`` | General format. For a given precision ``p >= 1``, | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 262 | | this rounds the number to ``p`` significant digits and | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 263 | | then formats the result in either fixed-point format | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 264 | | or in scientific notation, depending on its magnitude. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 265 | | | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 266 | | A precision of ``0`` is treated as equivalent to a | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 267 | | precision of ``1``. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 268 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 269 | ``'G'`` | General format. Same as ``'g'`` except switches to | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 270 | | ``'E'`` if the number gets too large. The | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 271 | | representations of infinity and NaN are uppercased, too. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 272 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 273 | none | Similar to ``'g'``, except that the default precision is | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 274 | | as high as needed to represent the particular value. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 275 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 276 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 277 .. ifconfig:: False | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 278 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 279 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 280 | | The precise rules are as follows: suppose that the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 281 | | result formatted with presentation type ``'e'`` and | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 282 | | precision ``p-1`` would have exponent ``exp``. Then | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 283 | | if ``-4 <= exp < p``, the number is formatted | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 284 | | with presentation type ``'f'`` and precision | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 285 | | ``p-1-exp``. Otherwise, the number is formatted | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 286 | | with presentation type ``'e'`` and precision ``p-1``. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 287 | | In both cases insignificant trailing zeros are removed | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 288 | | from the significand, and the decimal point is also | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 289 | | removed if there are no remaining digits following it. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 290 | | | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 291 | | Positive and negative infinity, positive and negative | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 292 | | zero, and nans, are formatted as ``inf``, ``-inf``, | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 293 | | ``0``, ``-0`` and ``nan`` respectively, regardless of | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 294 | | the precision. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 295 | | | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 296 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 297 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 298 The available presentation types for pointers are: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 299 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 300 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 301 | Type | Meaning | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 302 +=========+==========================================================+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 303 | ``'p'`` | Pointer format. This is the default type for | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 304 | | pointers and may be omitted. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 305 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 306 | none | The same as ``'p'``. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 307 +---------+----------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 308 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 309 .. _chrono-specs: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 310 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 311 Chrono Format Specifications | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 312 ============================ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 313 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 314 Format specifications for chrono duration and time point types as well as | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 315 ``std::tm`` have the following syntax: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 316 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 317 .. productionlist:: sf | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 318 chrono_format_spec: [[`fill`]`align`][`width`]["." `precision`][`chrono_specs`] | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 319 chrono_specs: [`chrono_specs`] `conversion_spec` | `chrono_specs` `literal_char` | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 320 conversion_spec: "%" [`modifier`] `chrono_type` | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 321 literal_char: <a character other than '{', '}' or '%'> | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 322 modifier: "E" | "O" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 323 chrono_type: "a" | "A" | "b" | "B" | "c" | "C" | "d" | "D" | "e" | "F" | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 324 : "g" | "G" | "h" | "H" | "I" | "j" | "m" | "M" | "n" | "p" | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 325 : "q" | "Q" | "r" | "R" | "S" | "t" | "T" | "u" | "U" | "V" | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 326 : "w" | "W" | "x" | "X" | "y" | "Y" | "z" | "Z" | "%" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 327 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 328 Literal chars are copied unchanged to the output. Precision is valid only for | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 329 ``std::chrono::duration`` types with a floating-point representation type. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 330 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 331 The available presentation types (*chrono_type*) are: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 332 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 333 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 334 | Type | Meaning | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 335 +=========+====================================================================+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 336 | ``'a'`` | The abbreviated weekday name, e.g. "Sat". If the value does not | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 337 | | contain a valid weekday, an exception of type ``format_error`` is | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 338 | | thrown. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 339 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 340 | ``'A'`` | The full weekday name, e.g. "Saturday". If the value does not | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 341 | | contain a valid weekday, an exception of type ``format_error`` is | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 342 | | thrown. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 343 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 344 | ``'b'`` | The abbreviated month name, e.g. "Nov". If the value does not | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 345 | | contain a valid month, an exception of type ``format_error`` is | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 346 | | thrown. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 347 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 348 | ``'B'`` | The full month name, e.g. "November". If the value does not | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 349 | | contain a valid month, an exception of type ``format_error`` is | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 350 | | thrown. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 351 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 352 | ``'c'`` | The date and time representation, e.g. "Sat Nov 12 22:04:00 1955". | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 353 | | The modified command ``%Ec`` produces the locale's alternate date | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 354 | | and time representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 355 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 356 | ``'C'`` | The year divided by 100 using floored division, e.g. "55". If the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 357 | | result is a single decimal digit, it is prefixed with 0. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 358 | | The modified command ``%EC`` produces the locale's alternative | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 359 | | representation of the century. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 360 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 361 | ``'d'`` | The day of month as a decimal number. If the result is a single | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 362 | | decimal digit, it is prefixed with 0. The modified command ``%Od`` | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 363 | | produces the locale's alternative representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 364 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 365 | ``'D'`` | Equivalent to ``%m/%d/%y``, e.g. "11/12/55". | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 366 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 367 | ``'e'`` | The day of month as a decimal number. If the result is a single | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 368 | | decimal digit, it is prefixed with a space. The modified command | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 369 | | ``%Oe`` produces the locale's alternative representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 370 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 371 | ``'F'`` | Equivalent to ``%Y-%m-%d``, e.g. "1955-11-12". | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 372 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 373 | ``'g'`` | The last two decimal digits of the ISO week-based year. If the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 374 | | result is a single digit it is prefixed by 0. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 375 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 376 | ``'G'`` | The ISO week-based year as a decimal number. If the result is less | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 377 | | than four digits it is left-padded with 0 to four digits. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 378 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 379 | ``'h'`` | Equivalent to ``%b``, e.g. "Nov". | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 380 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 381 | ``'H'`` | The hour (24-hour clock) as a decimal number. If the result is a | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 382 | | single digit, it is prefixed with 0. The modified command ``%OH`` | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 383 | | produces the locale's alternative representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 384 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 385 | ``'I'`` | The hour (12-hour clock) as a decimal number. If the result is a | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 386 | | single digit, it is prefixed with 0. The modified command ``%OI`` | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 387 | | produces the locale's alternative representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 388 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 389 | ``'j'`` | If the type being formatted is a specialization of duration, the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 390 | | decimal number of days without padding. Otherwise, the day of the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 391 | | year as a decimal number. Jan 1 is 001. If the result is less than | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 392 | | three digits, it is left-padded with 0 to three digits. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 393 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 394 | ``'m'`` | The month as a decimal number. Jan is 01. If the result is a | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 395 | | single digit, it is prefixed with 0. The modified command ``%Om`` | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 396 | | produces the locale's alternative representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 397 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 398 | ``'M'`` | The minute as a decimal number. If the result is a single digit, | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 399 | | it is prefixed with 0. The modified command ``%OM`` produces the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 400 | | locale's alternative representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 401 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 402 | ``'n'`` | A new-line character. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 403 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 404 | ``'p'`` | The AM/PM designations associated with a 12-hour clock. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 405 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 406 | ``'q'`` | The duration's unit suffix. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 407 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 408 | ``'Q'`` | The duration's numeric value (as if extracted via ``.count()``). | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 409 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 410 | ``'r'`` | The 12-hour clock time, e.g. "10:04:00 PM". | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 411 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 412 | ``'R'`` | Equivalent to ``%H:%M``, e.g. "22:04". | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 413 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 414 | ``'S'`` | Seconds as a decimal number. If the number of seconds is less than | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 415 | | 10, the result is prefixed with 0. If the precision of the input | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 416 | | cannot be exactly represented with seconds, then the format is a | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 417 | | decimal floating-point number with a fixed format and a precision | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 418 | | matching that of the precision of the input (or to a microseconds | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 419 | | precision if the conversion to floating-point decimal seconds | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 420 | | cannot be made within 18 fractional digits). The character for the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 421 | | decimal point is localized according to the locale. The modified | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 422 | | command ``%OS`` produces the locale's alternative representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 423 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 424 | ``'t'`` | A horizontal-tab character. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 425 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 426 | ``'T'`` | Equivalent to ``%H:%M:%S``. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 427 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 428 | ``'u'`` | The ISO weekday as a decimal number (1-7), where Monday is 1. The | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 429 | | modified command ``%Ou`` produces the locale's alternative | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 430 | | representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 431 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 432 | ``'U'`` | The week number of the year as a decimal number. The first Sunday | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 433 | | of the year is the first day of week 01. Days of the same year | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 434 | | prior to that are in week 00. If the result is a single digit, it | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 435 | | is prefixed with 0. The modified command ``%OU`` produces the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 436 | | locale's alternative representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 437 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 438 | ``'V'`` | The ISO week-based week number as a decimal number. If the result | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 439 | | is a single digit, it is prefixed with 0. The modified command | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 440 | | ``%OV`` produces the locale's alternative representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 441 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 442 | ``'w'`` | The weekday as a decimal number (0-6), where Sunday is 0. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 443 | | The modified command ``%Ow`` produces the locale's alternative | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 444 | | representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 445 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 446 | ``'W'`` | The week number of the year as a decimal number. The first Monday | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 447 | | of the year is the first day of week 01. Days of the same year | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 448 | | prior to that are in week 00. If the result is a single digit, it | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 449 | | is prefixed with 0. The modified command ``%OW`` produces the | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 450 | | locale's alternative representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 451 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 452 | ``'x'`` | The date representation, e.g. "11/12/55". The modified command | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 453 | | ``%Ex`` produces the locale's alternate date representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 454 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 455 | ``'X'`` | The time representation, e.g. "10:04:00". The modified command | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 456 | | ``%EX`` produces the locale's alternate time representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 457 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 458 | ``'y'`` | The last two decimal digits of the year. If the result is a single | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 459 | | digit it is prefixed by 0. The modified command ``%Oy`` produces | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 460 | | the locale's alternative representation. The modified command | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 461 | | ``%Ey`` produces the locale's alternative representation of offset | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 462 | | from ``%EC`` (year only). | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 463 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 464 | ``'Y'`` | The year as a decimal number. If the result is less than four | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 465 | | digits it is left-padded with 0 to four digits. The modified | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 466 | | command ``%EY`` produces the locale's alternative full year | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 467 | | representation. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 468 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 469 | ``'z'`` | The offset from UTC in the ISO 8601:2004 format. For example -0430 | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 470 | | refers to 4 hours 30 minutes behind UTC. If the offset is zero, | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 471 | | +0000 is used. The modified commands ``%Ez`` and ``%Oz`` insert a | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 472 | | ``:`` between the hours and minutes: -04:30. If the offset | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 473 | | information is not available, an exception of type | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 474 | | ``format_error`` is thrown. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 475 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 476 | ``'Z'`` | The time zone abbreviation. If the time zone abbreviation is not | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 477 | | available, an exception of type ``format_error`` is thrown. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 478 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 479 | ``'%'`` | A % character. | | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 480 +---------+--------------------------------------------------------------------+ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 481 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 482 Specifiers that have a calendaric component such as ``'d'`` (the day of month) | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 483 are valid only for ``std::tm`` and time points but not durations. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 484 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 485 .. range-specs: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 486 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 487 Range Format Specifications | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 488 =========================== | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 489 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 490 Format specifications for range types have the following syntax: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 491 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 492 .. productionlist:: sf | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 493 range_format_spec: [":" [`underlying_spec`]] | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 494 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 495 The `underlying_spec` is parsed based on the formatter of the range's | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 496 reference type. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 497 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 498 By default, a range of characters or strings is printed escaped and quoted. But | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 499 if any `underlying_spec` is provided (even if it is empty), then the characters | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 500 or strings are printed according to the provided specification. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 501 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 502 Examples:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 503 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 504 fmt::format("{}", std::vector{10, 20, 30}); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 505 // Result: [10, 20, 30] | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 506 fmt::format("{::#x}", std::vector{10, 20, 30}); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 507 // Result: [0xa, 0x14, 0x1e] | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 508 fmt::format("{}", vector{'h', 'e', 'l', 'l', 'o'}); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 509 // Result: ['h', 'e', 'l', 'l', 'o'] | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 510 fmt::format("{::}", vector{'h', 'e', 'l', 'l', 'o'}); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 511 // Result: [h, e, l, l, o] | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 512 fmt::format("{::d}", vector{'h', 'e', 'l', 'l', 'o'}); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 513 // Result: [104, 101, 108, 108, 111] | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 514 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 515 .. _formatexamples: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 516 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 517 Format Examples | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 518 =============== | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 519 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 520 This section contains examples of the format syntax and comparison with | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 521 the printf formatting. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 522 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 523 In most of the cases the syntax is similar to the printf formatting, with the | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 524 addition of the ``{}`` and with ``:`` used instead of ``%``. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 525 For example, ``"%03.2f"`` can be translated to ``"{:03.2f}"``. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 526 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 527 The new format syntax also supports new and different options, shown in the | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 528 following examples. | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 529 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 530 Accessing arguments by position:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 531 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 532 fmt::format("{0}, {1}, {2}", 'a', 'b', 'c'); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 533 // Result: "a, b, c" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 534 fmt::format("{}, {}, {}", 'a', 'b', 'c'); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 535 // Result: "a, b, c" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 536 fmt::format("{2}, {1}, {0}", 'a', 'b', 'c'); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 537 // Result: "c, b, a" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 538 fmt::format("{0}{1}{0}", "abra", "cad"); // arguments' indices can be repeated | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 539 // Result: "abracadabra" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 540 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 541 Aligning the text and specifying a width:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 542 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 543 fmt::format("{:<30}", "left aligned"); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 544 // Result: "left aligned " | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 545 fmt::format("{:>30}", "right aligned"); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 546 // Result: " right aligned" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 547 fmt::format("{:^30}", "centered"); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 548 // Result: " centered " | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 549 fmt::format("{:*^30}", "centered"); // use '*' as a fill char | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 550 // Result: "***********centered***********" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 551 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 552 Dynamic width:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 553 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 554 fmt::format("{:<{}}", "left aligned", 30); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 555 // Result: "left aligned " | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 556 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 557 Dynamic precision:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 558 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 559 fmt::format("{:.{}f}", 3.14, 1); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 560 // Result: "3.1" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 561 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 562 Replacing ``%+f``, ``%-f``, and ``% f`` and specifying a sign:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 563 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 564 fmt::format("{:+f}; {:+f}", 3.14, -3.14); // show it always | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 565 // Result: "+3.140000; -3.140000" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 566 fmt::format("{: f}; {: f}", 3.14, -3.14); // show a space for positive numbers | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 567 // Result: " 3.140000; -3.140000" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 568 fmt::format("{:-f}; {:-f}", 3.14, -3.14); // show only the minus -- same as '{:f}; {:f}' | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 569 // Result: "3.140000; -3.140000" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 570 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 571 Replacing ``%x`` and ``%o`` and converting the value to different bases:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 572 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 573 fmt::format("int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 574 // Result: "int: 42; hex: 2a; oct: 52; bin: 101010" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 575 // with 0x or 0 or 0b as prefix: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 576 fmt::format("int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}", 42); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 577 // Result: "int: 42; hex: 0x2a; oct: 052; bin: 0b101010" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 578 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 579 Padded hex byte with prefix and always prints both hex characters:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 580 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 581 fmt::format("{:#04x}", 0); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 582 // Result: "0x00" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 583 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 584 Box drawing using Unicode fill:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 585 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 586 fmt::print( | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 587 "┌{0:─^{2}}┐\n" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 588 "│{1: ^{2}}│\n" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 589 "└{0:─^{2}}┘\n", "", "Hello, world!", 20); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 590 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 591 prints:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 592 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 593 ┌────────────────────┐ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 594 │ Hello, world! │ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 595 └────────────────────┘ | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 596 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 597 Using type-specific formatting:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 598 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 599 #include <fmt/chrono.h> | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 600 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 601 auto t = tm(); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 602 t.tm_year = 2010 - 1900; | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 603 t.tm_mon = 7; | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 604 t.tm_mday = 4; | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 605 t.tm_hour = 12; | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 606 t.tm_min = 15; | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 607 t.tm_sec = 58; | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 608 fmt::print("{:%Y-%m-%d %H:%M:%S}", t); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 609 // Prints: 2010-08-04 12:15:58 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 610 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 611 Using the comma as a thousands separator:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 612 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 613 #include <fmt/format.h> | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 614 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 615 auto s = fmt::format(std::locale("en_US.UTF-8"), "{:L}", 1234567890); | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 616 // s == "1,234,567,890" | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 617 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 618 .. ifconfig:: False | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 619 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 620 Nesting arguments and more complex examples:: | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 621 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 622 >>> for align, text in zip('<^>', ['left', 'center', 'right']): | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 623 ... '{0:{fill}{align}16}") << text, fill=align, align=align) | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 624 ... | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 625 'left<<<<<<<<<<<<' | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 626 '^^^^^center^^^^^' | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 627 '>>>>>>>>>>>right' | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 628 >>> | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 629 >>> octets = [192, 168, 0, 1] | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 630 Format("{:02X}{:02X}{:02X}{:02X}") << *octets) | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 631 'C0A80001' | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 632 >>> int(_, 16) | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 633 3232235521 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 634 >>> | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 635 >>> width = 5 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 636 >>> for num in range(5,12): | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 637 ... for base in 'dXob': | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 638 ... print('{0:{width}{base}}") << num, base=base, width=width), end=' ') | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 639 ... print() | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 640 ... | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 641 5 5 5 101 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 642 6 6 6 110 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 643 7 7 7 111 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 644 8 8 10 1000 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 645 9 9 11 1001 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 646 10 A 12 1010 | 
| 
1faa72660932
*: transfer back to cmake from autotools
 Paper <paper@paper.us.eu.org> parents: diff
changeset | 647 11 B 13 1011 | 
