00001 // LICENSE: (Please see the file COPYING for details) 00002 // 00003 // NUS - Nemesis Utilities System: A C++ application development framework 00004 // Copyright (C) 2006, 2008 Otavio Rodolfo Piske 00005 // 00006 // This file is part of NUS 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Lesser General Public 00010 // License as published by the Free Software Foundation version 2.1 00011 // of the License. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Lesser General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Lesser General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 // 00022 #ifndef NXMLREADER_H 00023 #define NXMLREADER_H 00024 00033 #include <libxml/xmlreader.h> 00034 00035 #include "ndefs.h" 00036 #include "nstring.h" 00037 #include "nfile.h" 00038 #include "nxmldocument.h" 00039 #include "nexception.h" 00040 #include "nxmlerror.h" 00041 #include "nxmlabstractparser.h" 00042 #include "nxmlparser.h" 00043 #include "nxmlschemaparser.h" 00044 00048 class DllDeclSpec NXmlReader { 00049 public: 00053 NXmlReader(void); 00054 00058 ~NXmlReader(void); 00059 00060 00065 void setSchema(NXmlAbstractParser::XmlSchema schema); 00066 00073 NXmlAbstractParser::XmlSchema getSchema(void) const; 00074 00080 void setEncoding(const NString &encoding); 00081 00086 NString getEncoding(void) const; 00087 00092 void setDefinitionUrl(const NString &url); 00093 00098 NString getDefinitionUrl(void) const; 00099 00104 void load(const NString &path); 00105 00111 void load(const NString &buffer, nint32 size); 00112 00117 void load(const NFile *file); 00118 00123 NXmlDocument *getDocument(void); 00124 00125 private: 00126 xmlTextReaderPtr m_reader; 00127 xmlDocPtr m_doc; 00128 NXmlDocument *m_xml_doc; 00129 NXmlAbstractParser::XmlSchema m_schema; 00130 NXmlAbstractParser *m_parser; 00131 NString m_url; 00132 NString m_encoding; 00133 00134 const char *evalEncoding(const NString &encoding); 00135 void initDocument(void); 00136 void setupRootElement(void); 00137 00138 void loadNoParse(const NString &path); 00139 void loadNoParse(const NString &buffer, nint32 size); 00140 void loadNoParse(const NFile *file); 00141 00142 NXmlReader(const NXmlReader &other); 00143 NXmlReader &operator=(const NXmlReader &other); 00144 00145 00146 }; 00147 00148 #endif // NXMLREADER_H