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>2015-11-27 10:16:26 +0300
committerAlex Zolotarev <alex@maps.me>2015-11-28 15:00:13 +0300
commitb4b10b3e7d2bd804ad43b63268f5df62fa413c1c (patch)
treef3e8112d7c1ef60305e3ce059af8188ce1cfd60c /indexer/feature_meta.hpp
parentafae5a24f866080b196f53c0d8641fbfde8e023e (diff)
Fixed Metadata interface and implementation, added missing unit tests.
Diffstat (limited to 'indexer/feature_meta.hpp')
-rw-r--r--indexer/feature_meta.hpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/indexer/feature_meta.hpp b/indexer/feature_meta.hpp
index 363f899ded..3a082f32eb 100644
--- a/indexer/feature_meta.hpp
+++ b/indexer/feature_meta.hpp
@@ -42,14 +42,28 @@ namespace feature
static_assert(FMD_COUNT <= 255, "Meta types count is limited to one byte.");
- bool Add(EType type, string const & s)
+ /// Empty value drops (clears) corresponding type.
+ void Set(EType type, string const & value)
{
- string & val = m_metadata[type];
- if (val.empty())
- val = s;
+ auto found = m_metadata.find(type);
+ if (found == m_metadata.end())
+ {
+ if (!value.empty())
+ m_metadata[type] = value;
+ }
else
- val = val + ", " + s;
- return true;
+ {
+ if (value.empty())
+ m_metadata.erase(found);
+ else
+ found->second = value;
+ }
+ }
+
+ /// Synonym of Set(type, "").
+ void Drop(EType type)
+ {
+ Set(type, "");
}
string Get(EType type) const
@@ -69,11 +83,6 @@ namespace feature
return types;
}
- void Drop(EType type)
- {
- m_metadata.erase(type);
- }
-
inline bool Empty() const { return m_metadata.empty(); }
inline size_t Size() const { return m_metadata.size(); }