Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members

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         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   Local Variables:
00115   mode: c++
00116   c-basic-offset: 8
00117   tab-width: 8
00118   c-indent-comments-syntactically-p: t
00119   c-tab-always-indent: t
00120   indent-tabs-mode: t
00121   End:
00122 */
00123 
00124 // vim:shiftwidth=8:autoindent:tabstop=8:noexpandtab:softtabstop=8
00125 

Generated on Fri Nov 17 12:35:46 2006 for xCHM by  doxygen 1.4.4