2#ifndef __ASE_FORMATTER_HH__
3#define __ASE_FORMATTER_HH__
16template<
class ...Args>
std::string string_format (
const char *format,
const Args &...args) __attribute__ ((__format__ (__printf__, 1, 0)));
20 locale_t saved_locale_ = {};
26 static locale_t posix_locale();
34 using StringFormatVariant::operator=;
35 void assign (
const char *s,
SL &h) { *
this = s; }
36 void assign (
const std::string &s,
SL &h) { *
this = s.c_str(); }
38 void assign (
const void *p,
SL &h) { *
this =
uint64_t (ptrdiff_t (p)); }
40 ::type assign (
const T &v,
SL &h) { *
this =
uint64_t (v); }
42 ::type assign (
const T &v,
SL &h) { *
this =
double (v); }
44 ::type assign (
const T &o,
SL &h) {
std::ostringstream s; s << o; h.push_back (s.
str()); *
this = h.back().c_str(); }
63template<
class ...Args> __attribute__ ((noinline))
std::string
66 constexpr size_t N =
sizeof... (Args);
70 (sfa[i++].assign (args, templist), ...);
71 return sfa[0].string_format_args (format, N, sfa);
Class to push the POSIX/C locale_t (UTF-8) for the scope of its lifetime.
The Anklang C++ API namespace.
std::string string_format(const char *format, const Args &...args) __attribute__((__format__(__printf__
Format a string similar to sprintf(3) with support for std::string and std::ostringstream convertible...