diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-07-22 09:20:58 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-07-22 09:20:58 +0100 |
| commit | 455475575bcfa30aa60a377235bfaf2fd7bc2da7 (patch) | |
| tree | 691c69e3e25722a4fa6ffe632179243907be8240 /src/compose.hpp | |
| parent | 1eb9ba017214698de3fd41de5291604b4fe839c5 (diff) | |
Use locked_sstream. Replace once parse_stream with parse_memory.
Diffstat (limited to 'src/compose.hpp')
| -rw-r--r-- | src/compose.hpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/compose.hpp b/src/compose.hpp index f7bd4282..185e00a4 100644 --- a/src/compose.hpp +++ b/src/compose.hpp @@ -33,7 +33,7 @@ #ifndef STRING_COMPOSE_H #define STRING_COMPOSE_H -#include <sstream> +#include <locked_sstream.h> #include <string> #include <list> #include <map> // for multimap @@ -58,7 +58,7 @@ namespace StringPrivate std::string str() const; private: - std::ostringstream os; + locked_stringstream os; int arg_no; // we store the output as a list - when the output string is requested, the @@ -106,7 +106,7 @@ namespace StringPrivate case '8': case '9': return true; - + default: return false; } @@ -120,21 +120,21 @@ namespace StringPrivate os << 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) { output_list::iterator pos = i->second; ++pos; - + output.insert(pos, rep); } - + os.str(std::string()); //os.clear(); ++arg_no; } - + return *this; } @@ -142,7 +142,7 @@ namespace StringPrivate : arg_no(1) { std::string::size_type b = 0, i = 0; - + // fill in output with the strings between the %1 %2 %3 etc. and // fill in specs with the positions while (i < fmt.length()) { @@ -154,7 +154,7 @@ namespace StringPrivate else if (is_number(fmt[i + 1])) { // aha! a spec! // save string output.push_back(fmt.substr(b, i - b)); - + int n = 1; // number of digits int spec_no = 0; @@ -167,9 +167,9 @@ namespace StringPrivate spec_no /= 10; output_list::iterator pos = output.end(); --pos; // safe since we have just inserted a string> - + specs.insert(specification_map::value_type(spec_no, pos)); - + // jump over spec string i += n; b = i; @@ -180,7 +180,7 @@ namespace StringPrivate else ++i; } - + if (i - b > 0) // add the rest of the string output.push_back(fmt.substr(b, i - b)); } @@ -189,17 +189,17 @@ namespace StringPrivate { // assemble string std::string str; - + for (output_list::const_iterator i = output.begin(), end = output.end(); i != end; ++i) str += *i; - + return str; } } // now for the real thing(s) -namespace String +namespace String { // a series of functions which accept a format string on the form "text %1 // more %2 less %3" and a number of templated parameters and spits out the @@ -310,7 +310,7 @@ namespace String .arg(o10); return c.str(); } - + template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10, typename T11> |
