Ase::Lib::StringFormatter class

StringFormatter - sprintf() like string formatting for C++.

See format() for supported flags, modifiers and conversions. To find source code strings with size modifiers for possible cleanups, use: egrep "\"([^\"]|\\\")*%[0-9$]*[-+#0 \'I]*[<em>0-9$]</em>[.*0-9$]*[hlLqjzt]+[nSspmCcdiouXxFfGgEeAa]"

Public static functions

template <LocaleContext LC = POSIX_LOCALE, class ... Args>
static __attribute__((__format__(printf, 2, 0), noinline)) std

Function documentation

template <LocaleContext LC = POSIX_LOCALE, class ... Args>
static Ase::Lib::StringFormatter::__attribute__((__format__(printf, 2, 0), noinline)) std

Returns A formatted string.

Format a string according to an sprintf() format string with arguments. Refer to sprintf() for the format string details, this function is designed to serve as an sprintf() replacement and mimick its behaviour as close as possible. Supported format directive features are:

  • Formatting flags (sign conversion, padding, alignment), i.e. the flags: [-#0+ ']
  • Field width and precision specifications.
  • Positional arguments for field width, precision and value.
  • Length modifiers are tolerated: i.e. any of [hlLjztqZ].
  • The conversion specifiers [spmcCdiouXxFfGgEeAa].

Additionally, arguments can be transformed after conversion by passing a std::string conversion function as arg_transform. This may e.g. be used for XML character escaping of the format argument values.
@NOTE Format errors, e.g. missing arguments will produce a warning on stderr and return the format string unmodified.