kodi
TextSearch.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <string>
12 #include <vector>
13 
14 typedef enum TextSearchDefault
15 {
16  SEARCH_DEFAULT_AND = 0,
17  SEARCH_DEFAULT_OR,
18  SEARCH_DEFAULT_NOT
19 } TextSearchDefault;
20 
21 class CTextSearch final
22 {
23 public:
24  CTextSearch(const std::string &strSearchTerms, bool bCaseSensitive = false, TextSearchDefault defaultSearchMode = SEARCH_DEFAULT_OR);
25 
26  bool Search(const std::string &strHaystack) const;
27  bool IsValid(void) const;
28 
29 private:
30  static void GetAndCutNextTerm(std::string &strSearchTerm, std::string &strNextTerm);
31  void ExtractSearchTerms(const std::string &strSearchTerm, TextSearchDefault defaultSearchMode);
32 
33  bool m_bCaseSensitive;
34  std::vector<std::string> m_AND;
35  std::vector<std::string> m_OR;
36  std::vector<std::string> m_NOT;
37 };
Definition: TextSearch.h:21