Formatting instructions

Top  Previous  Next

Scripts > Class elements and c++ instructions > Formatting instructions


Formatting commands are used to determine, how the generated output looks like. (See also: indentation)

The interpreter provides the Boost Format library from Samuel Krempp for formatting arguments according to a format-string(, similar to printf in c).


The syntax of the format string and the right number of the arguments will not be checked before the execution of the formatting command.


Remark: The following explanations are essentially restricted to the "%|spec|"  specification. Other possibilities more close to the traditional printf syntax can be found in Krempps original documentation.


A format object is constructed from a format-string, and is then given arguments through repeated calls to operator%. Each of those arguments are then converted to strings, who are in turn combined into one string, according to the format-string.


out << format("writing %|1$|,  x=%|2$| : %|3$|-th try")

                       % "toto" % 40.23 % 50;

// outputs: "writing toto,  x=40.230 : 50-th try"


This page belongs to the TextTransformer Documentation

Home  Content  German