Formats integer numbers (other than char) such as int, unsigned, long long, etc Format specifier options for output:
More...
|
template<WriterImpl WI> |
static Result< size_t, typename Writer< WI >::ErrType > | fmt (Writer< WI > &writer, const FormatOptions &opts, const T &val) |
|
static size_t | num_digits (const T &val) |
|
template<WriterImpl WI> |
static Result< size_t, typename Writer< WI >::ErrType > | fmt (Writer< WI > &writer, const FormatOptions &opts, T val) |
|
template<WriterImpl WI> |
static Result< size_t, typename Writer< WI >::ErrType > | fmt (Writer< WI > &writer, FormatOptions opts, const T &iterable) |
|
template<WriterImpl WI> |
static Result< size_t, typename Writer< WI >::ErrType > | fmt (Writer< WI > &writer, FormatOptions opts, const T &iterable) |
|
template<WriterImpl WI> |
static Result< size_t, typename Writer< WI >::ErrType > | fmt (Writer< WI > &writer, const FormatOptions &opts, T ptr) |
|
template<WriterImpl WI> |
static Result< size_t, typename Writer< WI >::ErrType > | fmt (Writer< WI > &writer, const FormatOptions &opts, const T &f) |
|
template<std::integral T>
struct mtcore::io::Formatter< T >
Formats integer numbers (other than char) such as int, unsigned, long long, etc Format specifier options for output:
Formatter for pointers Will print "nullptr" if the pointer is null If no formatting options are given, will print the address as "Addr 0x{}" Format options are one of the following:
Formatter for C++ standard iterables (with begin(), end() and C++ iterators) Allows using normal C++ collections for formatting if desired Format specifiers have the slice specifiers left of a colon and the element specifiers on the right of the colon.
Formatter for mtcore iterables (different from C++ standard iterables) Format specifiers have the slice specifiers left of a colon and the element specifiers on the right of the colon.
Formatter for 32-bit floats Format specifiers have the following format: (padding)?(+|())?(f|F)?(e|E)?(+)?(\d+)?(.
- Format padding options (e.g.
0<2;
) - Must come before other options if present (i.e. 0<2;x
not x0<2;
)
x
for lowercase hex
X
for uppercase hex
b
for binary
o
for octal
d
(or none) for decimal (numeric, base 10)
- Template Parameters
-
T | Integer number type (other than char) |
- See also
- extract_padding_options
\d+(-\d+)?)? Where padding is the padding options, + indicates always print plus for positive while () indicates to print negatives with parenthesis (these are mutually exclusive), f indicates lowercase scientific notation, F indicates uppercase scientific location, e indicates forced scientific notation, E indicated forced uppercase scientific notation (overrides f), + indicates that a positive exponent should have +, (\d+) indicates the minimum digits of precision (between 0-16), and period indicates decimal place precision (will round). Decimal place precision can be an exact number (e.g. .2
for 2 decimals) or a range (e.g. .2-4
for 2-4 decimals). Note: decimal place will override minimum precision if there is a conflict
E.g. +F+4.2
is "Print always with sign for number end sci notation, have uppercase E, at least 4 digits of precision
and exactly 2 decimal places"
In the format of: (maxElems)?(iterablePadding)?(separator):(elemFormat)(|(nextElemFormat))* Where maxElems is a number followed by an exclamation pont (!) which limits how meny items to print, slicePadding is overall padding requirements for the whole iterable (this is optional), the separator is any number of characters (including escaped characters) up to the colon. If a colon is present but there is no separator, then the formatter will assume no separation (useful for printing strings). If there is no colon, it will either default to a space (if it's an iterable of anything other than char) or nothing (if it's an iterable of char). After the colon comes element formats. If there's only one format, it will be applied to all elements. Multiple element formats may be specified by putting a pipe between each format. Each format will be used once, with the exception being that the last format will be repeated for all remaining elements. This is useful if you are trying to format a table of results, and you want different paddings for different sections.
Examples:
,:
Will separate each element by a comma
^100;, :
Will separate each element by a comma and a space, and will print the whole slice centered inside 100 characters
:x
No separator, will pass the format string "x" to all elements
:x|b|x
Separates by space, will pass the format string "x" to the first element, "b" to the second, and "x" to remaining elements
| : <10;| ^15;| >14;
Separates with the string " | ". First element left padded by spaces to 10, second element center padded to 15 by space, remaining elements right padded by space to 14.
- Template Parameters
-
x
Hex only (no prefix)
s
Short prefix (0x{})
- '' Try to print value at address (if not null). Relies on formatter for underlying type. Will prefix with asterisk "</em>"
- Template Parameters
-
Definition at line 195 of file formats.hpp.