Welcome to mirror list, hosted at ThFree Co, Russian Federation.

query_params.hpp « search - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f3bc6f90eb025f73713248feea73be64baa9a163 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once

#include "base/string_utils.hpp"

#include "std/cstdint.hpp"
#include "std/unordered_set.hpp"
#include "std/vector.hpp"

namespace search
{
struct QueryParams
{
  using TString = strings::UniString;
  using TSynonymsVector = vector<TString>;
  using TLangsSet = unordered_set<int8_t>;

  vector<TSynonymsVector> m_tokens;
  TSynonymsVector m_prefixTokens;
  vector<bool> m_isCategorySynonym;

  TLangsSet m_langs;
  int m_scale;

  QueryParams();

  void Clear();

  /// @param[in] eraseInds Sorted vector of token's indexes.
  void EraseTokens(vector<size_t> & eraseInds);

  void ProcessAddressTokens();

  inline bool IsEmpty() const { return (m_tokens.empty() && m_prefixTokens.empty()); }
  inline bool CanSuggest() const { return (m_tokens.empty() && !m_prefixTokens.empty()); }
  inline bool IsLangExist(int8_t l) const { return (m_langs.count(l) > 0); }

  TSynonymsVector const & GetTokens(size_t i) const;
  TSynonymsVector & GetTokens(size_t i);

  /// @return true if all tokens in [start, end) range has number synonym.
  bool IsNumberTokens(size_t start, size_t end) const;

private:
  template <class ToDo>
  void ForEachToken(ToDo && toDo);
};

string DebugPrint(search::QueryParams const & params);
}  // namespace search