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:
authorvng <viktor.govako@gmail.com>2011-11-17 21:33:13 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:28:17 +0300
commitd571623f99a2abed39e323065b31c169255a3bc7 (patch)
tree8467127e1f095487339b16b6bf9900da60bcb278 /indexer/data_header.cpp
parentb1f3746bd71e620c5b09f064f00bfbb2b48e528b (diff)
Add native languages support to mwm header.
Diffstat (limited to 'indexer/data_header.cpp')
-rw-r--r--indexer/data_header.cpp37
1 files changed, 32 insertions, 5 deletions
diff --git a/indexer/data_header.cpp b/indexer/data_header.cpp
index 581743f9ee..fadef04e4e 100644
--- a/indexer/data_header.cpp
+++ b/indexer/data_header.cpp
@@ -52,6 +52,34 @@ namespace feature
}
}
+ namespace
+ {
+ template <class TSink, class TCont>
+ void SaveBytes(TSink & sink, TCont const & cont)
+ {
+ STATIC_ASSERT(sizeof(typename TCont::value_type) == 1);
+
+ uint32_t const count = cont.size();
+ WriteVarUint(sink, count);
+ if (count > 0)
+ sink.Write(&cont[0], count);
+ }
+
+ template <class TSource, class TCont>
+ void LoadBytes(TSource & src, TCont & cont)
+ {
+ STATIC_ASSERT(sizeof(typename TCont::value_type) == 1);
+ ASSERT ( cont.empty(), () );
+
+ uint32_t const count = ReadVarUint<uint32_t>(src);
+ if (count > 0)
+ {
+ cont.resize(count);
+ src.Read(&cont[0], count);
+ }
+ }
+ }
+
void DataHeader::Save(FileWriter & w) const
{
m_codingParams.Save(w);
@@ -59,8 +87,8 @@ namespace feature
WriteVarInt(w, m_bounds.first);
WriteVarInt(w, m_bounds.second);
- WriteVarUint(w, m_scales.size());
- w.Write(m_scales.data(), m_scales.size());
+ SaveBytes(w, m_scales);
+ SaveBytes(w, m_langs);
WriteVarInt(w, static_cast<int32_t>(m_type));
}
@@ -73,9 +101,8 @@ namespace feature
m_bounds.first = ReadVarInt<int64_t>(src);
m_bounds.second = ReadVarInt<int64_t>(src);
- uint32_t const count = ReadVarUint<uint32_t>(src);
- m_scales.resize(count);
- src.Read(m_scales.data(), count);
+ LoadBytes(src, m_scales);
+ LoadBytes(src, m_langs);
m_type = static_cast<MapType>(ReadVarInt<int32_t>(src));