hhcparser.h

00001 /*
00002 
00003   Copyright (C) 2003  Razvan Cojocaru <razvanco@gmx.net>
00004  
00005   This program is free software; you can redistribute it and/or modify
00006   it under the terms of the GNU General Public License as published by
00007   the Free Software Foundation; either version 2 of the License, or
00008   (at your option) any later version.
00009   
00010   This program is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013   GNU General Public License for more details.
00014   
00015   You should have received a copy of the GNU General Public License
00016   along with this program; if not, write to the Free Software
00017   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
00018   MA 02110-1301, USA.
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 // Forward declarations.
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   Local Variables:
00110   mode: c++
00111   c-basic-offset: 8
00112   tab-width: 8
00113   c-indent-comments-syntactically-p: t
00114   c-tab-always-indent: t
00115   indent-tabs-mode: t
00116   End:
00117 */
00118 
00119 // vim:shiftwidth=8:autoindent:tabstop=8:noexpandtab:softtabstop=8
00120 

Generated on Tue Apr 14 19:43:38 2009 for xCHM by  doxygen 1.5.4