Base Framework
Classes | Static Public Member Functions | List of all members
Format Class Reference

#include <base/string/Format.h>

Classes

class  Subst
 

Static Public Member Functions

static String substImpl (const UTF8Stringify &text, const UTF8Stringify *args, MemorySize numberOfArgs)
 
static void printImpl (const UTF8Stringify &text, const UTF8Stringify *args, MemorySize numberOfArgs)
 
template<typename... ARGS>
static String subst (const UTF8Stringify &text, ARGS &&... args)
 

Detailed Description

String formatting support.

String result = Format::subst(MESSAGE("My name is %1 %2."), "John", "Doe");

You can do inline value formatting like this (hint format() is a StringOutputStream):

String result = Format::subst( MESSAGE("My value is %1."), format() << HEX << myValue, format() << ZEROPAD << setWidth(8) << 5432 );

You can also reuse to format object as a shorthand because each argument triggers automatic restart of the stream. format f; String result = Format::subst( MESSAGE("My value is %1 and %2."), f << HEX << myValue, f << ZEROPAD << setWidth(8) << 5432 );

Member Function Documentation

◆ printImpl()

static void Format::printImpl ( const UTF8Stringify text,
const UTF8Stringify args,
MemorySize  numberOfArgs 
)
static

Print string substitution.

◆ subst()

template<typename... ARGS>
static String Format::subst ( const UTF8Stringify text,
ARGS &&...  args 
)
inlinestatic

Simple string substitution.

String text = Format::subst(MESSAGE("My name is %1 and my last name is %2."), "John", "Doe");

◆ substImpl()

static String Format::substImpl ( const UTF8Stringify text,
const UTF8Stringify args,
MemorySize  numberOfArgs 
)
static

Simple string substitution.