1 /* Copyright 2016-2021 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 
19 /**
20  * @file
21  * @brief Dictionary spelling.
22  */
23 
24 #ifndef NUSPELL_DICTIONARY_HXX
25 #define NUSPELL_DICTIONARY_HXX
26 
27 #include "suggester.hxx"
28 
29 namespace nuspell {
30 inline namespace v5 {
31 
32 /**
33  * @brief The only important public exception
34  */
35 class Dictionary_Loading_Error : public std::runtime_error {
36       public:
37 	using std::runtime_error::runtime_error;
38 };
39 
40 /**
41  * @brief The only important public class
42  */
43 class NUSPELL_EXPORT Dictionary : private Suggester {
44 	Dictionary(std::istream& aff, std::istream& dic);
45 
46       public:
47 	Dictionary();
48 	auto static load_from_aff_dic(std::istream& aff, std::istream& dic)
49 	    -> Dictionary;
50 	auto static load_from_path(
51 	    const std::string& file_path_without_extension) -> Dictionary;
52 	auto spell(std::string_view word) const -> bool;
53 	auto suggest(std::string_view word, std::vector<std::string>& out) const
54 	    -> void;
55 };
56 
57 } // namespace v5
58 } // namespace nuspell
59 #endif // NUSPELL_DICTIONARY_HXX
60