Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

parser.hh

00001 /* Parser.h
00002  *
00003  * Copyright (C) 2002 Christian Neumann
00004  *
00005  * This file is part of Libxmlight
00006  * 
00007  * Libxmlight is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * Libxmlight is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public
00018  * License along with Libxmlight; if not, write to the Free
00019  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020  */
00021 
00022 #ifndef __Parser_h
00023 #define __Parser_h
00024 
00025 #include <iostream>
00026 #include <string>
00027 #include "attributes.hh"
00028 
00029 
00031 namespace xmlight {
00032 
00034 
00037 class TParser {
00038 public:
00040         TParser() : error_free(1), has_xmldecl(0), has_root_element(0), parsing_tag(0),
00041                 parsing_cdata(0), parsing_comment(0), parsing_dtd(0), data(), last_element(),
00042                 root_element(), dtd_count(0), element_count(0) { }
00043 
00045         virtual ~TParser() { }
00047 
00050         void parse_string(const std::string&);
00052 
00055         int state() { return error_free; }
00057         void parse_end();
00058 protected:
00060         virtual void on_start_document() { }
00062 
00067         virtual void on_start_element(const std::string&, const TAttributes&) { }
00069         virtual void on_end_element(const std::string&) { }
00071         virtual void on_data(const std::string&) { }
00073         virtual void on_comment(const std::string&) { }
00075         virtual void on_warning(const std::string&) { }
00077         virtual void on_error(const std::string&) { }
00079         virtual void on_fatal_error(const ::std::string&) { }
00081         virtual void on_end_document() { }
00082 private:
00084         void _on_error(const std::string& data) { error_free = false; on_error(data); }
00085 
00087 
00089         void parse_tag();
00090 
00091         bool error_free, has_xmldecl, has_root_element, parsing_tag, parsing_cdata, parsing_comment, parsing_dtd;
00092         std::string data, last_element, root_element;
00093         long dtd_count, element_count;
00094 
00095 };
00096 
00097 } // namespace xmlight
00098 
00099 #endif // __Parser_h

Generated on Mon Oct 13 02:35:23 2003 for MPCL by doxygen1.2.18