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:
String buffer(StringEncoding::Ascii);
#define SC_TEST_EXPECT(e)
Records a test expectation (eventually aborting or breaking o n failed test)
Definition Testing.h:159
static bool format(T &buffer, StringView fmt, Types &&... args)
Helper to format a StringView against args, replacing destination contents, in a single function call...
Definition StringBuilder.h:36
A non-modifiable owning string with associated encoding.
Definition String.h:29
- Note
- It's not convenient to use SC::StringFormat directly, as you should probably use SC::StringBuilder
- Template Parameters
-