X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fcompose.hpp;h=2c44f148bdf05e9bb5c48e7902c15d6e7a3bf7d9;hb=81fa6ec113fdcfce04aa4a2972cdef19ee038155;hp=ebabe671a7f40545b0a546294a485375de192134;hpb=422be0eece2bf6ee80db1d3c21553cd82efff789;p=dcpomatic.git diff --git a/src/lib/compose.hpp b/src/lib/compose.hpp index ebabe671a..2c44f148b 100644 --- a/src/lib/compose.hpp +++ b/src/lib/compose.hpp @@ -1,4 +1,5 @@ -/* Defines String::compose(fmt, arg...) for easy, i18n-friendly +/* -*- c-basic-offset: 2 -*- + * Defines String::compose(fmt, arg...) for easy, i18n-friendly * composition of strings. * * Version 1.0. @@ -33,10 +34,13 @@ #ifndef STRING_COMPOSE_H #define STRING_COMPOSE_H -#include +#include +#include #include #include -#include // for multimap +#include +#include +#include namespace StringPrivate { @@ -56,7 +60,7 @@ namespace StringPrivate std::string str() const; private: - locked_stringstream os; + std::string os; int arg_no; // we store the output as a list - when the output string is requested, the @@ -110,26 +114,21 @@ namespace StringPrivate } } - // implementation of class Composition template inline Composition &Composition::arg(const T &obj) { - os << obj; - - std::string rep = os.str(); + os += dcp::locale_convert(obj); - if (!rep.empty()) { // manipulators don't produce output - for (specification_map::const_iterator i = specs.lower_bound(arg_no), - end = specs.upper_bound(arg_no); i != end; ++i) { + if (!os.empty()) { // manipulators don't produce output + for (specification_map::const_iterator i = specs.lower_bound(arg_no), end = specs.upper_bound(arg_no); i != end; ++i) { output_list::iterator pos = i->second; ++pos; - output.insert(pos, rep); + output.insert(pos, os); } - os.str(std::string()); - //os.clear(); + os = ""; ++arg_no; }