diff options
author | Dmitry Yunitsky <yunik@mapswithme.com> | 2016-04-28 15:32:36 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2016-05-01 10:28:03 +0300 |
commit | 9c12757d30e021641b17d48a50a8e8c8cb945b2e (patch) | |
tree | 978aaecf7f94449f72ef89673819bcdd2cf66572 /indexer/new_feature_categories.hpp | |
parent | 9d7fc9dbbe1a2fc816c5afa049b8eab4f827bb2c (diff) |
Fixed build : moved indexer-dependent file from editor.
Diffstat (limited to 'indexer/new_feature_categories.hpp')
-rw-r--r-- | indexer/new_feature_categories.hpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/indexer/new_feature_categories.hpp b/indexer/new_feature_categories.hpp new file mode 100644 index 0000000000..1191564539 --- /dev/null +++ b/indexer/new_feature_categories.hpp @@ -0,0 +1,58 @@ +#pragma once + +#include "indexer/categories_index.hpp" + +#include "editor/editor_config.hpp" + +#include "base/macros.hpp" + +#include "std/cstdint.hpp" +#include "std/map.hpp" +#include "std/string.hpp" +#include "std/utility.hpp" +#include "std/vector.hpp" + +namespace osm +{ +// This class holds an index of categories that can be set for a newly added feature. +class NewFeatureCategories +{ +public: + using TName = pair<string, uint32_t>; + using TNames = vector<TName>; + + NewFeatureCategories(editor::EditorConfig const & config); + + NewFeatureCategories(NewFeatureCategories && other); + + NewFeatureCategories() = default; + + NewFeatureCategories & operator=(NewFeatureCategories && other) = default; + + // Adds all known synonyms in language |lang| for all categories that + // can be applied to a newly added feature. + // If one language is added more than once, all the calls except for the + // first one are ignored. + // If |lang| is not supported, "en" is used. + void AddLanguage(string lang); + + // Returns names (in language |lang|) and types of categories that have a synonym containing + // the substring |query| (in any language that was added before). + // If |lang| is not supported, "en" is used. + // The returned list is sorted. + TNames Search(string const & query, string lang) const; + + // Returns all registered names of categories in language |lang| and + // types corresponding to these names. The language must have been added before. + // If |lang| is not supported, "en" is used. + // The returned list is sorted. + TNames const & GetAllCategoryNames(string const & lang) const; + +private: + indexer::CategoriesIndex m_index; + vector<uint32_t> m_types; + map<string, TNames> m_categoriesByLang; + + DISALLOW_COPY(NewFeatureCategories); +}; +} // namespace osm |