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