1 /* 2 * Copyright (C) 2007 Tommi Maekitalo 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License as 6 * published by the Free Software Foundation; either version 2 of the 7 * License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, but 10 * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied 11 * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and 12 * NON-INFRINGEMENT. See the GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 * 18 */ 19 20 #ifndef ZIM_SEARCH_H 21 #define ZIM_SEARCH_H 22 23 #include "search_iterator.h" 24 #include <vector> 25 #include <string> 26 #include <map> 27 28 namespace zim 29 { 30 31 class File; 32 class Search 33 { 34 friend class search_iterator; 35 friend struct search_iterator::InternalData; 36 public: 37 typedef search_iterator iterator; 38 39 explicit Search(const std::vector<const File*> zimfiles); 40 explicit Search(const File* zimfile); 41 Search(const Search& it); 42 Search& operator=(const Search& it); 43 Search(Search&& it); 44 Search& operator=(Search&& it); 45 ~Search(); 46 47 void set_verbose(bool verbose); 48 49 Search& add_zimfile(const File* zimfile); 50 Search& set_query(const std::string& query); 51 Search& set_georange(float latitude, float longitude, float distance); 52 Search& set_range(int start, int end); 53 Search& set_suggestion_mode(bool suggestion_mode); 54 55 search_iterator begin() const; 56 search_iterator end() const; 57 int get_matches_estimated() const; 58 59 private: 60 struct InternalData; 61 std::unique_ptr<InternalData> internal; 62 std::vector<const File*> zimfiles; 63 64 mutable std::map<std::string, int> valuesmap; 65 mutable std::string prefixes; 66 std::string query; 67 float latitude; 68 float longitude; 69 float distance; 70 int range_start; 71 int range_end; 72 bool suggestion_mode; 73 bool geo_query; 74 mutable bool search_started; 75 mutable bool has_database; 76 mutable bool verbose; 77 mutable int estimated_matches_number; 78 }; 79 80 } //namespace zim 81 82 #endif // ZIM_SEARCH_H 83