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:
authorAlex Zolotarev <alex@maps.me>2016-02-26 21:15:36 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:49:30 +0300
commit011ca81098074880462905ded6e3c4a5c50ba255 (patch)
tree7808b3d22d1dba943f585fabc5f8f2e7072fe1b2 /platform
parentefbed49e4971b84323189070607f0913c295aef2 (diff)
GetTextById::GetAllSortedTranslations().
Diffstat (limited to 'platform')
-rw-r--r--platform/get_text_by_id.cpp12
-rw-r--r--platform/get_text_by_id.hpp3
2 files changed, 15 insertions, 0 deletions
diff --git a/platform/get_text_by_id.cpp b/platform/get_text_by_id.cpp
index e86c1bea58..35730d3e0a 100644
--- a/platform/get_text_by_id.cpp
+++ b/platform/get_text_by_id.cpp
@@ -7,6 +7,7 @@
#include "3party/jansson/myjansson.hpp"
+#include "std/algorithm.hpp"
#include "std/target_os.hpp"
namespace
@@ -120,4 +121,15 @@ string GetTextById::operator()(string const & textId) const
return string();
return textIt->second;
}
+
+TTranslations GetTextById::GetAllSortedTranslations() const
+{
+ TTranslations all;
+ all.reserve(m_localeTexts.size());
+ for (auto const & tr : m_localeTexts)
+ all.emplace_back(tr.first, tr.second);
+ using TValue = TTranslations::value_type;
+ sort(all.begin(), all.end(), [](TValue const & v1, TValue const & v2) { return v1.second < v2.second; });
+ return all;
+}
} // namespace platform
diff --git a/platform/get_text_by_id.hpp b/platform/get_text_by_id.hpp
index 8a54a5e506..3daf102018 100644
--- a/platform/get_text_by_id.hpp
+++ b/platform/get_text_by_id.hpp
@@ -4,6 +4,7 @@
#include "std/unique_ptr.hpp"
#include "std/unordered_map.hpp"
#include "std/utility.hpp"
+#include "std/vector.hpp"
namespace platform
{
@@ -18,6 +19,7 @@ enum class TextSource
class GetTextById;
using TGetTextByIdPtr = unique_ptr<GetTextById>;
+using TTranslations = vector<pair<string, string>>;
/// GetTextById represents text messages which are saved in textsDir
/// in a specified locale.
@@ -29,6 +31,7 @@ public:
/// The boolean flag is set to false otherwise.
string operator()(string const & textId) const;
string GetLocale() const { return m_locale; }
+ TTranslations GetAllSortedTranslations() const;
private:
friend TGetTextByIdPtr GetTextByIdFactory(TextSource textSource, string const & localeName);