Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrachytski <siarhei.rachytski@gmail.com>2012-06-05 21:38:15 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:39:27 +0300
commit966d2a6f6288c52e3a004ca5f7d2530368c24442 (patch)
tree8307f483bcc51b8f06d8c9f1535c3d18d92b24fa /base/string_format.hpp
parent1bd70241ca3d79de5df024d0dcd14fdca558261a (diff)
added strings localization mechanism and used it in CountryStatusDisplay.
Diffstat (limited to 'base/string_format.hpp')
-rw-r--r--base/string_format.hpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/base/string_format.hpp b/base/string_format.hpp
new file mode 100644
index 0000000000..d97a8faeb9
--- /dev/null
+++ b/base/string_format.hpp
@@ -0,0 +1,73 @@
+#pragma once
+
+#include "../std/string.hpp"
+#include "../std/sstream.hpp"
+#include "../std/list.hpp"
+
+namespace strings
+{
+ template <typename T>
+ string ToString(T t)
+ {
+ ostringstream out;
+ out << t;
+ return out.str();
+ }
+
+ string const FormatImpl(string const & s, list<string> const & l);
+
+ template <typename T1>
+ string const Format(string const & s, T1 const & t1)
+ {
+ list<string> l;
+ l.push_back(ToString(t1));
+
+ return FormatImpl(s, l);
+ }
+
+ template <typename T1, typename T2>
+ string const Format(string const & s, T1 const & t1, T2 const & t2)
+ {
+ list<string> l;
+ l.push_back(ToString(t1));
+ l.push_back(ToString(t2));
+
+ return FormatImpl(s, l);
+ }
+
+ template <typename T1, typename T2, typename T3>
+ string const Format(string const & s, T1 const & t1, T2 const & t2, T3 const & t3)
+ {
+ list<string> l;
+ l.push_back(ToString(t1));
+ l.push_back(ToString(t2));
+ l.push_back(ToString(t3));
+
+ return FormatImpl(s, l);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4>
+ string const Format(string const & s, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4)
+ {
+ list<string> l;
+ l.push_back(ToString(t1));
+ l.push_back(ToString(t2));
+ l.push_back(ToString(t3));
+ l.push_back(ToString(t4));
+
+ return FormatImpl(s, l);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5>
+ string const Format(string const & s, T1 const & t1, T2 const & t2, T3 const & t3, T4 const & t4, T5 const & t5)
+ {
+ list<string> l;
+ l.push_back(ToString(t1));
+ l.push_back(ToString(t2));
+ l.push_back(ToString(t3));
+ l.push_back(ToString(t4));
+ l.push_back(ToString(t5));
+
+ return FormatImpl(s, l);
+ }
+}