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., 675 Mass Ave, Cambridge, MA 02139, USA.
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 // Forward declarations.
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         unsigned getHTMLCode(const wxString& name);
00085 
00086 private:
00087         int _level;
00088         bool _inquote;
00089         bool _intag;
00090         bool _inobject;
00091         std::string _tag;
00092         std::string _name;
00093         std::string _value;
00094         wxTreeCtrl *_tree;
00095         CHMListCtrl *_list;
00096         wxTreeItemId _parents[TREE_BUF_SIZE];
00097         wxFontEncoding _enc;
00098         int _counter;
00099         wxCSConv _cv;
00100         bool _htmlChars;
00101 };
00102 
00103 
00104 #endif // __HHCPARSER_H_
00105 
00106 
00107 /*
00108   Local Variables:
00109   mode: c++
00110   c-basic-offset: 8
00111   tab-width: 8
00112   c-indent-comments-syntactically-p: t
00113   c-tab-always-indent: t
00114   indent-tabs-mode: t
00115   End:
00116 */
00117 
00118 // vim:shiftwidth=8:autoindent:tabstop=8:noexpandtab:softtabstop=8
00119 

Generated on Tue Apr 24 20:17:36 2007 for xCHM by  doxygen 1.4.7