Nuspell
spell checker
finder.hxx
Go to the documentation of this file.
1 /* Copyright 2016-2023 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 
27 #include "defines.hxx"
28 #include "nuspell_export.h"
29 
30 #include <filesystem>
31 #include <string>
32 #include <utility>
33 #include <vector>
34 
35 #ifdef _MSC_VER
36 #define NUSPELL_MSVC_PRAGMA_WARNING(x) __pragma(warning(x))
37 #else
38 #define NUSPELL_MSVC_PRAGMA_WARNING(x)
39 #endif
40 NUSPELL_MSVC_PRAGMA_WARNING(push)
41 NUSPELL_MSVC_PRAGMA_WARNING(disable : 4251)
42 
43 namespace nuspell {
44 NUSPELL_BEGIN_INLINE_NAMESPACE
45 
46 NUSPELL_EXPORT auto
47 append_default_dir_paths(std::vector<std::filesystem::path>& paths) -> void;
48 NUSPELL_EXPORT auto
49 append_libreoffice_dir_paths(std::vector<std::filesystem::path>& paths) -> void;
50 NUSPELL_EXPORT auto
51 search_dirs_for_one_dict(const std::vector<std::filesystem::path>& dir_paths,
52  const std::filesystem::path& dict_name_stem)
53  -> std::filesystem::path;
54 NUSPELL_EXPORT auto
55 search_dirs_for_dicts(const std::vector<std::filesystem::path>& dir_paths,
56  std::vector<std::filesystem::path>& dict_list) -> void;
57 NUSPELL_EXPORT auto search_default_dirs_for_dicts()
58  -> std::vector<std::filesystem::path>;
59 
60 NUSPELL_DEPRECATED_EXPORT
61 auto append_default_dir_paths(std::vector<std::string>& paths) -> void;
62 
63 NUSPELL_DEPRECATED_EXPORT auto
64 append_libreoffice_dir_paths(std::vector<std::string>& paths) -> void;
65 
66 NUSPELL_DEPRECATED_EXPORT auto search_dir_for_dicts(
67  const std::string& dir_path,
68  std::vector<std::pair<std::string, std::string>>& dict_list) -> void;
69 
70 NUSPELL_DEPRECATED_EXPORT auto search_dirs_for_dicts(
71  const std::vector<std::string>& dir_paths,
72  std::vector<std::pair<std::string, std::string>>& dict_list) -> void;
73 
74 NUSPELL_DEPRECATED_EXPORT auto search_default_dirs_for_dicts(
75  std::vector<std::pair<std::string, std::string>>& dict_list) -> void;
76 
77 NUSPELL_DEPRECATED_EXPORT auto find_dictionary(
78  const std::vector<std::pair<std::string, std::string>>& dict_list,
79  const std::string& dict_name)
80  -> std::vector<std::pair<std::string, std::string>>::const_iterator;
81 
87 class NUSPELL_DEPRECATED_EXPORT Dict_Finder_For_CLI_Tool {
88  std::vector<std::string> dir_paths;
89  std::vector<std::pair<std::string, std::string>> dict_multimap;
90 
91  public:
93  auto& get_dir_paths() const { return dir_paths; }
94  auto& get_dictionaries() const { return dict_multimap; }
95  auto get_dictionary_path(const std::string& dict) const -> std::string;
96 };
97 
103 class NUSPELL_EXPORT Dict_Finder_For_CLI_Tool_2 {
104  using fs_path = std::filesystem::path;
105  std::vector<fs_path> dir_paths;
106 
107  public:
109  auto& get_dir_paths() const { return dir_paths; }
110  auto get_dictionary_path(const fs_path& dict) const -> fs_path;
111 };
112 
113 NUSPELL_END_INLINE_NAMESPACE
114 } // namespace nuspell
115 NUSPELL_MSVC_PRAGMA_WARNING(pop)
116 #endif // NUSPELL_FINDER_HXX
Don't use this except from Nuspell CLI tool.
Definition: finder.hxx:103
Don't use this except from Nuspell CLI tool.
Definition: finder.hxx:87
Library main namespace.
Definition: aff_data.cxx:33
auto append_default_dir_paths(vector< fs::path > &paths) -> void
Append the paths of the default directories to be searched for dictionaries.
Definition: finder.cxx:63
auto search_dirs_for_dicts(const vector< fs::path > &dir_paths, vector< fs::path > &dict_list) -> void
Search the directories for dictionaries.
Definition: finder.cxx:312
auto append_libreoffice_dir_paths(vector< fs::path > &paths) -> void
Append the paths of the LibreOffice's directories to be searched for dictionaries.
Definition: finder.cxx:164
auto search_default_dirs_for_dicts() -> vector< fs::path >
Search the default directories for dictionaries.
Definition: finder.cxx:327
auto search_dirs_for_one_dict(const vector< fs::path > &dir_paths, const fs::path &dict_name_stem) -> fs::path
Serach the directories for only one dictionary.
Definition: finder.cxx:261