diff options
author | Sergey Yershov <yershov@corp.mail.ru> | 2014-12-25 20:32:07 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:35:26 +0300 |
commit | 8f6b34bdb4e0e3ffb4010d5bd44df96bb4467a22 (patch) | |
tree | 2a02f3ce859edf2397c83d1fd2f3e48efa0b9bc0 /indexer/feature_data.hpp | |
parent | af6bd463306aad0bc7154d5550a298a104bad143 (diff) |
Moved work with metadata to separated files
Diffstat (limited to 'indexer/feature_data.hpp')
-rw-r--r-- | indexer/feature_data.hpp | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/indexer/feature_data.hpp b/indexer/feature_data.hpp index 216ee08936..a638a61e02 100644 --- a/indexer/feature_data.hpp +++ b/indexer/feature_data.hpp @@ -11,6 +11,7 @@ #include "../std/vector.hpp" #include "../std/algorithm.hpp" +#include "feature_meta.hpp" class FeatureBase; @@ -205,17 +206,10 @@ class FeatureParams : public FeatureParamsBase /// We use it now only for search unit tests string m_street; -public: + feature::FeatureMetadata m_metadata; - enum additional_info_types { - AIT_CUISINE = 1, - AIT_OPEN_HOURS, - AIT_PHONE_NUMBER, - AIT_FAX_NUMBER - }; +public: - typedef map<uint8_t, string> AdditionalInfoT; - AdditionalInfoT m_additional_info; typedef vector<uint32_t> types_t; types_t m_Types; @@ -228,8 +222,6 @@ public: bool AddHouseName(string const & s); bool AddHouseNumber(string const & s); - bool AddAdditionalInfo(additional_info_types type, string const & s); - /// @name Used in storing full street address only. //@{ void AddStreetAddress(string const & s); @@ -244,7 +236,7 @@ public: m_Types = rhs.m_Types; m_street = rhs.m_street; - m_additional_info = rhs.m_additional_info; + m_metadata = rhs.m_metadata; } inline bool IsValid() const { return !m_Types.empty(); } @@ -270,7 +262,10 @@ public: uint8_t GetHeader() const; - template <class SinkT> void Write(SinkT & sink, bool needStoreAdditionalInfo = true) const + feature::FeatureMetadata const & GetMetadata() const { return m_metadata; } + feature::FeatureMetadata & GetMetadata() { return m_metadata; } + + template <class SinkT> void Write(SinkT & sink, bool needStoreMetadata = true) const { uint8_t const header = GetHeader(); @@ -279,24 +274,13 @@ public: for (size_t i = 0; i < m_Types.size(); ++i) WriteVarUint(sink, GetIndexForType(m_Types[i])); - if (needStoreAdditionalInfo) - { - uint8_t const ait_size = m_additional_info.size(); - WriteToSink(sink, ait_size); - if (ait_size) - { - for(auto & it: m_additional_info) - { - WriteToSink(sink, uint8_t(it.first)); - utils::WriteString(sink, it.second); - } - } - } + if (needStoreMetadata) + m_metadata.Serialize(sink); BaseT::Write(sink, header); } - template <class SrcT> void Read(SrcT & src, bool needReadAdditionalInfo = true) + template <class SrcT> void Read(SrcT & src, bool needReadMetadata = true) { using namespace feature; @@ -307,17 +291,8 @@ public: for (size_t i = 0; i < count; ++i) m_Types.push_back(GetTypeForIndex(ReadVarUint<uint32_t>(src))); - if (needReadAdditionalInfo) - { - uint8_t const ait_size = ReadPrimitiveFromSource<uint8_t>(src); - for (size_t i=0; i < ait_size; ++i) - { - uint8_t const key = ReadPrimitiveFromSource<uint8_t>(src); - string value; - utils::ReadString(src, value); - m_additional_info.insert(make_pair(key, value)); - } - } + if (needReadMetadata) + m_metadata.Deserialize(src); BaseT::Read(src, header); } |