forked from organicmaps/organicmaps
Uncomment categories test and move CategoriesHolder to the global namespace.
This commit is contained in:
parent
468dc81fe8
commit
7213aade43
7 changed files with 29 additions and 34 deletions
|
@ -9,7 +9,7 @@
|
|||
#include "../base/logging.hpp"
|
||||
|
||||
|
||||
namespace search
|
||||
namespace
|
||||
{
|
||||
|
||||
struct Splitter
|
||||
|
@ -27,6 +27,8 @@ enum State {
|
|||
EParseLanguages
|
||||
};
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
size_t CategoriesHolder::LoadFromStream(string const & buffer)
|
||||
{
|
||||
m_categories.clear();
|
||||
|
@ -128,4 +130,3 @@ CategoriesHolder::CategoriesHolder(Reader const & reader)
|
|||
LoadFromStream(buffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,31 +7,26 @@
|
|||
|
||||
class Reader;
|
||||
|
||||
namespace search
|
||||
{
|
||||
|
||||
struct Category
|
||||
{
|
||||
/// Classificator types
|
||||
vector<uint32_t> m_types;
|
||||
|
||||
struct Name
|
||||
{
|
||||
string m_name;
|
||||
int8_t m_lang;
|
||||
uint8_t m_prefixLengthToSuggest;
|
||||
};
|
||||
|
||||
/// <language, synonym>
|
||||
vector<Name> m_synonyms;
|
||||
};
|
||||
|
||||
class CategoriesHolder
|
||||
{
|
||||
typedef vector<Category> ContainerT;
|
||||
ContainerT m_categories;
|
||||
|
||||
public:
|
||||
struct Category
|
||||
{
|
||||
/// Classificator types
|
||||
vector<uint32_t> m_types;
|
||||
|
||||
struct Name
|
||||
{
|
||||
string m_name;
|
||||
int8_t m_lang;
|
||||
uint8_t m_prefixLengthToSuggest;
|
||||
};
|
||||
|
||||
/// <language, synonym>
|
||||
vector<Name> m_synonyms;
|
||||
};
|
||||
|
||||
typedef vector<Category> ContainerT;
|
||||
typedef ContainerT::const_iterator const_iterator;
|
||||
|
||||
CategoriesHolder();
|
||||
|
@ -50,11 +45,12 @@ public:
|
|||
const_iterator end() const { return m_categories.end(); }
|
||||
|
||||
void swap(CategoriesHolder & o);
|
||||
|
||||
private:
|
||||
ContainerT m_categories;
|
||||
};
|
||||
|
||||
inline void swap(CategoriesHolder & a, CategoriesHolder & b)
|
||||
{
|
||||
return a.swap(b);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ struct Checker
|
|||
{
|
||||
size_t & m_count;
|
||||
Checker(size_t & count) : m_count(count) {}
|
||||
void operator()(search::Category const & cat)
|
||||
void operator()(CategoriesHolder::Category const & cat)
|
||||
{
|
||||
switch (m_count)
|
||||
{
|
||||
|
@ -74,14 +74,12 @@ UNIT_TEST(LoadCategories)
|
|||
p.GetReader("classificator.txt"),
|
||||
p.GetReader("visibility.txt"),
|
||||
p.GetReader("types.txt"));
|
||||
/*
|
||||
search::CategoriesHolder h;
|
||||
CategoriesHolder h;
|
||||
string buffer = TEST_STRING;
|
||||
TEST_GREATER(h.LoadFromStream(buffer), 0, ());
|
||||
size_t count = 0;
|
||||
Checker f(count);
|
||||
h.ForEachCategory(f);
|
||||
TEST_EQUAL(count, 2, ());
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
|
@ -681,7 +681,7 @@ search::Engine * Framework<TModel>::GetSearchEngine()
|
|||
{
|
||||
scoped_ptr<Reader> pReader(GetPlatform().GetReader(SEARCH_CATEGORIES_FILE_NAME));
|
||||
m_pSearchEngine.reset(
|
||||
new search::Engine(&m_model.GetIndex(), new search::CategoriesHolder(*pReader)));
|
||||
new search::Engine(&m_model.GetIndex(), new CategoriesHolder(*pReader)));
|
||||
}
|
||||
}
|
||||
return m_pSearchEngine.get();
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
#include "../std/scoped_ptr.hpp"
|
||||
#include "../std/string.hpp"
|
||||
|
||||
class CategoriesHolder;
|
||||
class Index;
|
||||
|
||||
namespace search
|
||||
{
|
||||
|
||||
class CategoriesHolder;
|
||||
class Query;
|
||||
class Result;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
namespace search
|
||||
{
|
||||
|
||||
Query::Query(Index const * pIndex, search::CategoriesHolder const * pCategories)
|
||||
Query::Query(Index const * pIndex, CategoriesHolder const * pCategories)
|
||||
: m_pIndex(pIndex), m_pCategories(pCategories), m_viewport(m2::RectD::GetEmptyRect()),
|
||||
m_viewportExtended(m2::RectD::GetEmptyRect()), m_bOffsetsCacheIsValid(false)
|
||||
{
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
#include "../std/unordered_set.hpp"
|
||||
#include "../std/vector.hpp"
|
||||
|
||||
class CategoriesHolder;
|
||||
class FeatureType;
|
||||
class Index;
|
||||
|
||||
namespace search
|
||||
{
|
||||
|
||||
class CategoriesHolder;
|
||||
class KeywordMatcher;
|
||||
namespace impl { class IntermediateResult; struct FeatureLoader; class BestNameFinder; }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue