template<typename RangeIterator>
struct SC::StringFormat< RangeIterator >
Formats String with a simple DSL embedded in the format string.
This is a small implementation to format using a minimal string based DSL, but good enough for simple usages. It uses the same {}
syntax and supports positional arguments.
StringFormat::format(output, "{1} {0}", "World", "Hello")
is formatted as "Hello World"
.
Inside the {}
after a colon (:
) a specification string can be used to indicate how to format the given value. As the backend for actual number to string formatting is snprintf
, such specification strings are the same as what would be given to snprintf. For example passing "{:02}"
is transformed to "%.02f"
when passed to snprintf.
{
is escaped if found near to another {
. In other words format("{{")
will print a single {
.
Example:
StringBuilder builder(buffer);
@ Ascii
Encoding is ASCII.
#define SC_TEST_EXPECT(e)
Records a test expectation (eventually aborting or breaking o n failed test)
Definition: Testing.h:113
- Note
- It's not convenient to use SC::StringFormat directly, as you should probably use SC::StringBuilder
- Template Parameters
-