|
From: Christian P. <cp...@us...> - 2005-01-11 14:47:59
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9267/include/pclasses/XML Added Files: Makefile.am XMLParseError.h XMLPushParser.h Log Message: Added XMLParseError, XMLPushParser. --- NEW FILE: XMLParseError.h --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include <pclasses/Exception.h> #include <string> namespace P { namespace XML { //! XML parse error class XMLParseError: public RuntimeError { public: XMLParseError(int err, const std::string& text, const char* what, const SourceInfo& si); ~XMLParseError(); int errNo() const throw(); const std::string& text() const throw(); private: int _errNo; std::string _text; }; } // !namespace XML } // !namespace P --- NEW FILE: Makefile.am --- INCLUDES = METASOURCES = AUTO pkginclude_HEADERS = XMLPushParser.h --- NEW FILE: XMLPushParser.h --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef P_XML_XMLPushParser_h #define P_XML_XMLPushParser_h #include <pclasses/XML/XMLParseError.h> #include <pclasses/NonCopyable.h> #include <pclasses/Signal.h> #include <string> #include <map> namespace P { namespace XML { //! XML push parser class XMLPushParser: public NonCopyable { public: typedef std::map<std::string,std::string> AttributeMap; enum { XMLNS = 0x01 }; XMLPushParser(const std::string& encoding = std::string(), int flags = 0); XMLPushParser(const std::string& encoding, int flags, char separator); //! External entity sub-parser XMLPushParser(XMLPushParser& p, const std::string& encoding, const std::string& context); virtual ~XMLPushParser() throw(); enum EntityParsingMode { Never, UnlessStandalone, Always }; void setParamEntityParsing(EntityParsingMode m); void parse(const char* buffer, size_t count) throw(XMLParseError); void finish() throw(); void reset() throw(); Signal2<void, const std::string&, const std::string&> sig_namespaceDeclStart; Signal1<void, const std::string&> sig_namespaceDeclEnd; Signal1<void, const std::string&> sig_comment; Signal2<void, const std::string&, const AttributeMap&> sig_elementStart; Signal1<void, const std::string&> sig_elementEnd; Signal1<void, const std::string&> sig_characterData; Signal0<void> sig_cDataStart; Signal0<void> sig_cDataEnd; protected: virtual void namespaceDeclStart(const std::string& prefix, const std::string& uri); virtual void namespaceDeclEnd(const std::string& prefix); virtual void comment(const std::string& comment); virtual void elementStart(const std::string& el, const AttributeMap& attrs); virtual void elementEnd(const std::string& el); virtual void characterData(const std::string& data); virtual void cDataStart(); virtual void cDataEnd(); virtual void notationDecl(const std::string& notationName, const std::string& base, const std::string& systemId, const std::string& publicId); virtual bool externalEntityRef(const std::string& context, const std::string& base, const std::string& systemId, const std::string& publicId); private: struct ParserImpl; friend struct ParserImpl; ParserImpl* _impl; }; } // !namespace XML } // !namespace P #endif |