Imported version 0.2-1
[mstardict] / src / lib / parsedata_plugin.h
1 #ifndef _STARDICT_PARSEDATA_PLUGIN_H_
2 #define _STARDICT_PARSEDATA_PLUGIN_H_
3
4 #include <gtk/gtk.h>
5 #include <string>
6 #include <list>
7
8 enum ParseResultItemType {
9         ParseResultItemType_mark,
10         ParseResultItemType_link,
11         ParseResultItemType_res,
12         ParseResultItemType_widget,
13 };
14
15 struct ParseResultMarkItem {
16         std::string pango;
17 };
18
19 struct LinkDesc {
20         std::string::size_type pos_;
21         std::string::size_type len_;
22         std::string link_;
23         LinkDesc(std::string::size_type pos, std::string::size_type len, std::string link):
24                 pos_(pos), len_(len), link_(link) {}
25 };
26
27 typedef std::list<LinkDesc> LinksPosList;
28
29 struct ParseResultLinkItem {
30         std::string pango;
31         LinksPosList links_list;
32 };
33
34 struct ParseResultResItem {
35         std::string type;
36         std::string key;
37 };
38
39 struct ParseResultWidgetItem {
40         GtkWidget *widget;
41 };
42
43 struct ParseResultItem {
44         ParseResultItemType type;
45         union {
46                 ParseResultMarkItem *mark;
47                 ParseResultLinkItem *link;
48                 ParseResultResItem *res;
49                 ParseResultWidgetItem *widget;
50         };
51 };
52
53 struct ParseResult {
54         ~ParseResult();
55         void clear();
56         std::list<ParseResultItem> item_list;
57 };
58
59 struct StarDictParseDataPlugInObject{
60         StarDictParseDataPlugInObject();
61
62         typedef bool (*parse_func_t)(const char *p, unsigned int *parsed_size, ParseResult &result, const char *oword);
63         parse_func_t parse_func;
64 };
65
66 #endif