summaryrefslogtreecommitdiff
path: root/src/compose.hpp
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-03-12 16:24:46 +0000
committerCarl Hetherington <cth@carlh.net>2019-03-12 16:24:46 +0000
commit5038e68ad9eb66e007211c8f1b707612a0c01e29 (patch)
tree70d5aa5d3f414defc3d3cd0b34de0725bf8760a9 /src/compose.hpp
parenta8b629085c404d7a947ed242fbf64d8e0e91edcd (diff)
Remove sstream dependency.
Diffstat (limited to 'src/compose.hpp')
-rw-r--r--src/compose.hpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/compose.hpp b/src/compose.hpp
index ebabe67..bcddd43 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,10 +34,13 @@
#ifndef STRING_COMPOSE_H
#define STRING_COMPOSE_H
-#include <locked_sstream.h>
+#include "locale_convert.h"
+#include <boost/filesystem.hpp>
#include <string>
#include <list>
-#include <map> // for multimap
+#include <map>
+#include <inttypes.h>
+#include <cstdio>
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 <typename T>
inline Composition &Composition::arg(const T &obj)
{
- os << obj;
-
- std::string rep = os.str();
+ os += sub::locale_convert<std::string>(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;
}