X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fcompose.hpp;h=faffc41c2a42cfcc36f1281a6a24fded01831cbc;hb=06f0ba166ff4b811ff0c635434d06dc8abfaa5ab;hp=185e00a4de64c24eaf8bbd129b71835caf2f6461;hpb=455475575bcfa30aa60a377235bfaf2fd7bc2da7;p=libdcp.git diff --git a/src/compose.hpp b/src/compose.hpp index 185e00a4..faffc41c 100644 --- a/src/compose.hpp +++ b/src/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,12 +34,13 @@ #ifndef STRING_COMPOSE_H #define STRING_COMPOSE_H -#include +#include "locale_convert.h" +#include #include #include -#include // for multimap - -namespace dcp { +#include +#include +#include namespace StringPrivate { @@ -58,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 @@ -112,26 +114,21 @@ namespace StringPrivate } } - // implementation of class Composition template inline Composition &Composition::arg(const T &obj) { - os << obj; + os += dcp::locale_convert (obj); - std::string rep = os.str(); - - 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; } @@ -391,6 +388,5 @@ namespace String } } -} #endif // STRING_COMPOSE_H