MT Core (C++)
Core library for replacing C++ standard in project usage
|
Built-in formatting options and specifications. More...
Classes | |
struct | mtcore::io::FormatOptions |
Options for specifying formatting. More... | |
struct | mtcore::io::Formatter< T > |
Struct to override to specify how a type should be formatted. More... | |
struct | mtcore::io::PaddingOptions |
Represents parsed padding options for formatting output. More... | |
struct | mtcore::io::Padded< T > |
Formats data with padding into a writer's output stream Uses Formatter<T> under the hood Usually will use extract_padding_options to get padding options. More... | |
struct | mtcore::io::Formatter< char > |
Formatter for characters Format specifier options for output: More... | |
struct | mtcore::io::Formatter< T > |
Formats integer numbers (other than char) such as int, unsigned, long long, etc Format specifier options for output: More... | |
struct | mtcore::io::Formatter< char * > |
Format specifier for null-terminated char* (mutable C-strings) Has same format options as template<Iterable T> struct Formatter<T> More... | |
struct | mtcore::io::Formatter< const char * > |
Format specifier for null-terminated const char* (C-strings) Has same format options as template<Iterable T> struct Formatter<T> More... | |
struct | mtcore::io::Formatter< Optional< T > > |
Formatter for an optional Uses the formatter for the underlying value if available No formatting options. More... | |
struct | mtcore::io::Formatter< Result< V, E > > |
Formatter for a result Will check if the value has been moved out of the result Uses the formatter for the underlying value and/or error if available No formatting options. More... | |
struct | mtcore::io::Formatter< IPv4 > |
Formats IPv4 addresses No formatting options are available. More... | |
struct | mtcore::io::Formatter< IPv6 > |
Formats IPv6 addresses Formatting options: More... | |
struct | mtcore::io::Formatter< SubnetMaskV4 > |
Formats subnet v4 masks. More... | |
struct | mtcore::io::Formatter< SubnetMaskV6 > |
Formats subnet v4 masks. More... | |
struct | mtcore::io::Formatter< SubnetV4 > |
Formats a masked version 4 IP address with a subnet. More... | |
struct | mtcore::io::Formatter< SubnetV6 > |
Formats a masked version 6 IP address with a subnet. More... | |
Enumerations | |
enum class | mtcore::io::ContentAlignment { mtcore::io::ContentAlignment::LEFT , mtcore::io::ContentAlignment::RIGHT , mtcore::io::ContentAlignment::CENTER } |
Represents content alignment options for padded formatting options. More... | |
Functions | |
Optional< PaddingOptions > | mtcore::io::extract_padding_options (Slice< const char > formatStr) |
Extracts padding options from a format string if present Padding options are in the following form: (padChar)(padDirection)(padLen); Where padChar is the character to pad with (maybe escaped with \ to avoid interpretation as a control character), padDirection is either < for left pad, > for right pad, or ^ for center padding, and padLen is an integer of the minimum length the output should be. | |
template<WriterImpl WI, typename... Args> | |
Result< size_t, typename Writer< WI >::ErrType > | mtcore::io::print (Writer< WI > &writer, const char *fmt, const Args &...args) |
Prints arguments using a format string Element insert points are designated by a pair of curly braces {} Format parameters can be between the curly braces (e.g. | |
template<WriterImpl WI, typename... Args> | |
Result< size_t, typename Writer< WI >::ErrType > | mtcore::io::print (Writer< WI > &writer, const Slice< const char > &fmt, const Args &...args) |
Prints arguments using a format string Element insert points are designated by a pair of curly braces {} Format parameters can be between the curly braces (e.g. | |
Built-in formatting options and specifications.
|
strong |
Represents content alignment options for padded formatting options.
Enumerator | |
---|---|
LEFT | |
RIGHT | |
CENTER |
Definition at line 35 of file formats.hpp.
|
inline |
Extracts padding options from a format string if present Padding options are in the following form: (padChar)(padDirection)(padLen); Where padChar is the character to pad with (maybe escaped with \ to avoid interpretation as a control character), padDirection is either <
for left pad, >
for right pad, or ^
for center padding, and padLen is an integer of the minimum length the output should be.
Note that a semicolon at the end is required.
Examples:
0<12;
- Left pads with zeros for up to 12 characters\^>14;
- Right pads with carrots (^) for 14 characters^10;
- Centers with spaces for 10 character lengthformatStr | Format string to parse |
Definition at line 71 of file formats.hpp.
Result< size_t, typename Writer< WI >::ErrType > mtcore::io::print | ( | Writer< WI > & | writer, |
const char * | fmt, | ||
const Args &... | args ) |
Prints arguments using a format string Element insert points are designated by a pair of curly braces {}
Format parameters can be between the curly braces (e.g.
{d}
) Escaping characters with backslash \
is supported See the Formatter<> specialization for the type of objects your formatting for their specific formatting string options
General pattern is as follows:
For iterables
5!
to limit to 5 elements)<12;
to left pad to 12 with space),:
to join with comma)|
separating each (e.g. x|d| <12;
)For paddable elements
.
), padding direction (<
, ^
, or >
), padding length (12
), padding terminator ;
For numbers
d
for decimal, x
for hex, o
for octal, b
for binaryFor print, the arguments may be of different types (e.g. 1, 4.5, "hello")
WI | Writer implementation |
Args | Arguments to format |
writer | Writer to write to |
fmt | Format string to write with |
args | Arguments to write |
Definition at line 482 of file io/writer.hpp.
Result< size_t, typename Writer< WI >::ErrType > mtcore::io::print | ( | Writer< WI > & | writer, |
const Slice< const char > & | fmt, | ||
const Args &... | args ) |
Prints arguments using a format string Element insert points are designated by a pair of curly braces {}
Format parameters can be between the curly braces (e.g.
{d}
) Escaping characters with backslash \
is supported See the Formatter<> specialization for the type of objects your formatting for their specific formatting string options
General pattern is as follows:
For iterables
5!
to limit to 5 elements)<12;
to left pad to 12 with space),:
to join with comma)|
separating each (e.g. x|d| <12;
)For paddable elements
.
), padding direction (<
, ^
, or >
), padding length (12
), padding terminator ;
For numbers
d
for decimal, x
for hex, o
for octal, b
for binaryFor print, the arguments may be of different types (e.g. 1, 4.5, "hello")
WI | Writer implementation |
Args | Arguments to format |
writer | Writer to write to |
fmt | Format string to write with |
args | Arguments to write |
Definition at line 529 of file io/writer.hpp.