b7cd6d3adb99c1fdec34656fe2be7559b26cd24a
[mstardict] / src / libwrapper.hpp
1 #ifndef _LIBWRAPPER_HPP_
2 #define _LIBWRAPPER_HPP_
3
4 #include <string>
5 #include <vector>
6
7 #include "file.hpp"
8 #include "lib.h"
9
10 using std::string;
11 using std::vector;
12
13 //this structure is wrapper and it need for unification
14 //results of search whith return Dicts class
15 struct TSearchResult {
16         string bookname;
17         string def;
18         string exp;
19
20         TSearchResult(const string& bookname_, const string& def_, const string& exp_)
21                 : bookname(bookname_), def(def_), exp(exp_)
22                 {
23                 }
24 };
25
26 typedef vector<TSearchResult> TSearchResultList;
27 typedef TSearchResultList::iterator PSearchResult;
28
29 //this class is wrapper around Dicts class for easy use
30 //of it
31 class Library : public Libs {
32 public:
33         Library(bool uinput, bool uoutput) : 
34                 Libs(NULL, FALSE, 0, 0), utf8_input(uinput), utf8_output(uoutput)  {}
35
36         bool process_phrase(const char *loc_str, TSearchResultList &res_list);
37         std::vector<InstantDictIndex> query_dictmask;
38
39 private:
40         bool utf8_input, utf8_output;
41
42         void SimpleLookup(const string &str, TSearchResultList& res_list);
43         void LookupWithFuzzy(const string &str, TSearchResultList& res_list);
44         void LookupWithRule(const string &str, TSearchResultList& res_lsit);
45         void LookupData(const string &str, TSearchResultList& res_list);
46 };
47
48 #endif//!_LIBWRAPPER_HPP_