Evo C++ Library v0.5.1
|
This shows different approaches for string formatting.
Methods for direct formatting modify the string directly:
Strings can be appended to using the stream operator (<<), similar to output Stream Formatting:
Strings can also use explicit stream formatting to customize the output:
Formatting attributes must be explicitly passed with each value – String doesn't keep any formatting state.
Formatting types used with operator<<()
:
Create a String::Format object to keep formatting state and make formatting "sticky" through that object, similar to Stream::Format:
This can also be done as a one-liner using a temporary formatter:
Sticky formatting is useful for applying the same formatting to many fields. You may still use explicit stream formatting (see previous section) to override sticky formatting.
Formatting types for setting attributes with operator<<()
Generic conversion and formatting is supported via templates:
See also: String Conversion and Smart Quoting