Nuspell
spellchecker
finder.hxx
Go to the documentation of this file.
1 /* Copyright 2016-2018 Dimitrij Mijoski
2  *
3  * This file is part of Nuspell.
4  *
5  * Nuspell is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * Nuspell is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with Nuspell. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
24 #ifndef NUSPELL_FINDER_HXX
25 #define NUSPELL_FINDER_HXX
26 #include <string>
27 #include <utility>
28 #include <vector>
29 
30 namespace nuspell {
31 inline namespace v2 {
32 class Finder {
33  using Dict_List = std::vector<std::pair<std::string, std::string>>;
34 
35  std::vector<std::string> paths;
36  Dict_List dictionaries;
37 
38  public:
39  using const_iterator = Dict_List::const_iterator;
40 
41  auto add_default_dir_paths() -> void;
42  auto add_mozilla_dir_paths() -> void;
43  auto add_libreoffice_dir_paths() -> void;
44  auto add_openoffice_dir_paths() -> void;
45  auto search_for_dictionaries() -> void;
46 
47  auto static search_all_dirs_for_dicts() -> Finder;
48 
49  auto& get_dir_paths() const { return paths; }
50  auto& get_dictionaries() const { return dictionaries; }
51  auto begin() const { return dictionaries.begin(); }
52  auto end() const { return dictionaries.end(); }
53  auto find(const std::string& dict) const -> const_iterator;
54  auto equal_range(const std::string& dict) const
55  -> std::pair<const_iterator, const_iterator>;
56  auto get_dictionary_path(const std::string& dict) const -> std::string;
57 };
58 } // namespace v2
59 } // namespace nuspell
60 
61 #endif // NUSPELL_FINDER_HXX
auto add_mozilla_dir_paths() -> void
Adds the Mozilla directory paths which may containt dictionaries.
Definition: finder.cxx:433
auto add_openoffice_dir_paths() -> void
Adds the OpenOffice directory paths which may containt dictionaries.
Definition: finder.cxx:585
static auto search_all_dirs_for_dicts() -> Finder
Creates Finder object with all possible dictionaries found.
Definition: finder.cxx:658
auto add_libreoffice_dir_paths() -> void
Adds the LibreOffice directory paths which may containt dictionaries.
Definition: finder.cxx:508
Library main namespace.
Definition: aff_data.cxx:74
auto add_default_dir_paths() -> void
Adds the default directory paths which may containt dictionaries.
Definition: finder.cxx:117
auto get_dictionary_path(const std::string &dict) const -> std::string
Gets the dictionary path.
Definition: finder.cxx:694
auto search_for_dictionaries() -> void
Searches the added directories for dictionaries.
Definition: finder.cxx:644
Definition: finder.hxx:32