00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __HHCPARSER_H_
00023 #define __HHCPARSER_H_
00024
00025
00026 #include <wx/font.h>
00027 #include <wx/treectrl.h>
00028 #include <string>
00029
00030
00031
00032 class CHMListCtrl;
00033
00034
00036 #define TREE_BUF_SIZE 128
00037
00038
00039
00045 struct URLTreeItem : public wxTreeItemData {
00046
00048 URLTreeItem(const wxString& str) : _url(str) {}
00049
00051 wxString _url;
00052 };
00053
00054
00056 class HHCParser {
00057
00058 public:
00060 HHCParser(wxFontEncoding enc, wxTreeCtrl *tree, CHMListCtrl *list);
00061
00062 public:
00064 void parse(const char* chunk);
00065
00066 private:
00068 void handleTag(const std::string& tag);
00069
00071 bool getParameters(const char* input, std::string& name,
00072 std::string& value);
00073
00075 void addToTree(const wxString& name, const wxString& value);
00076
00078 void addToList(const wxString& name, const wxString& value);
00079
00081 wxString replaceHTMLChars(const wxString& input);
00082
00084 wxString translateEncoding(const wxString& input);
00085
00087 unsigned getHTMLCode(const wxString& name);
00088
00090 wxChar charForCode(unsigned code);
00091
00092 private:
00093 int _level;
00094 bool _inquote;
00095 bool _intag;
00096 bool _inobject;
00097 std::string _tag;
00098 std::string _name;
00099 std::string _value;
00100 wxTreeCtrl *_tree;
00101 CHMListCtrl *_list;
00102 wxTreeItemId _parents[TREE_BUF_SIZE];
00103 wxFontEncoding _enc;
00104 int _counter;
00105 wxCSConv _cv;
00106 bool _htmlChars;
00107 };
00108
00109
00110 #endif // __HHCPARSER_H_
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125