xmlparser.h

Go to the documentation of this file.
00001 ///
00002 /// \file       xmlparser.h
00003 ///             A simple XML parser (use callback on start, end and data block
00004 ///
00005 
00006 /*
00007     Copyright (C) 2010, Nicolas VIVIEN
00008     Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/)
00009 
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 
00019     See the GNU General Public License in the COPYING file at the
00020     root directory of this project for more details.
00021 */
00022 
00023 #ifndef __XMLPARSER_H__
00024 #define __XMLPARSER_H__
00025 
00026 
00027 #include <iostream>
00028 
00029 #include "dll.h"
00030 #include "a_common.h"
00031 
00032 namespace Barry {
00033 
00034 namespace XML {
00035 
00036 
00037 class BXEXPORT XMLParser : public xmlpp::SaxParser
00038 {
00039 public:
00040         XMLParser(std::istream& input, const char *charset="UTF-8");
00041         virtual ~XMLParser(void);
00042 
00043         virtual bool Run(void);
00044         virtual const unsigned long GetDepth(void) const;
00045 
00046 protected:
00047         std::string charset;
00048         std::istream& input;
00049         unsigned long depth;
00050 
00051         // SaxParser overrides:
00052         virtual void on_start_document();
00053         virtual void on_end_document();
00054         virtual void on_start_element(const Glib::ustring& name,
00055                 const xmlpp::SaxParser::AttributeList& properties);
00056         virtual void on_end_element(const Glib::ustring& name);
00057         virtual void on_characters(const Glib::ustring& characters);
00058         virtual void on_comment(const Glib::ustring& text);
00059         virtual void on_warning(const Glib::ustring& text);
00060         virtual void on_error(const Glib::ustring& text);
00061         virtual void on_fatal_error(const Glib::ustring& text);
00062 };
00063 
00064 
00065 } // namespace XML
00066 
00067 } // namespace Barry
00068 
00069 #endif
00070