20a7acc3860943de252dfba0738db83ddd8a5a3a
[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();
34         ~Library();
35
36         std::vector<InstantDictIndex> query_dictmask;
37         CurrentIndex *iCurrentIndex;
38
39         void ListWords(CurrentIndex* iIndex);
40         bool BuildResultData(std::vector<InstantDictIndex> &dictmask, const char* sWord, CurrentIndex *iIndex, int iLib, TSearchResultList& res_list);
41
42         bool SimpleLookup(const gchar* sWord, CurrentIndex* piIndex);
43         void LookupWithFuzzy(const gchar* sWord);
44         void LookupWithRule(const gchar* sWord);
45 private:
46         void LookupData(const string &str, TSearchResultList& res_list);
47 };
48
49 #endif//!_LIBWRAPPER_HPP_