# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

i_xml.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000, 2001 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL 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, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_I_XML_H
00027 #define NL_I_XML_H
00028 
00029 //#define NL_DONT_USE_EXTERNAL_CODE
00030 #undef NL_DONT_USE_EXTERNAL_CODE
00031 
00032 #ifndef NL_DONT_USE_EXTERNAL_CODE
00033 
00034 #include "nel/misc/types_nl.h"
00035 #include "nel/misc/stream.h"
00036 
00037 // Include from libxml2
00038 #include <libxml/parser.h>
00039 
00040 namespace NLMISC {
00041 
00042 
00043 struct EXmlParsingError : public EStream
00044 {
00045         EXmlParsingError ( const std::string& str ) : EStream( str ) {};
00046 };
00047 
00086 class CIXml : public IStream
00087 {
00088         friend void xmlGenericErrorFuncForNeL (void *ctx, const char *msg, ...);
00089 public:
00090 
00093         CIXml ();
00094 
00097         virtual ~CIXml ();
00098 
00106         bool                    init (IStream &stream);
00107 
00110         void                    release ();
00111 
00114         xmlNodePtr              getRootNode () const;
00115 
00118         static xmlNodePtr getFirstChildNode (xmlNodePtr parent, const char *childName);
00119 
00122         static xmlNodePtr getNextChildNode (xmlNodePtr last, const char *childName);
00123 
00126         static xmlNodePtr getFirstChildNode (xmlNodePtr parent, xmlElementType type);
00127 
00130         static xmlNodePtr getNextChildNode (xmlNodePtr last, xmlElementType type);
00131 
00134         static uint             countChildren (xmlNodePtr node, const char *childName);
00135 
00138         static uint             countChildren (xmlNodePtr node, xmlElementType type);
00139 
00140 private:
00141 
00143         virtual void    serial(uint8 &b);
00144         virtual void    serial(sint8 &b);
00145         virtual void    serial(uint16 &b);
00146         virtual void    serial(sint16 &b);
00147         virtual void    serial(uint32 &b);
00148         virtual void    serial(sint32 &b);
00149         virtual void    serial(uint64 &b);
00150         virtual void    serial(sint64 &b);
00151         virtual void    serial(float &b);
00152         virtual void    serial(double &b);
00153         virtual void    serial(bool &b);
00154 #ifndef NL_OS_CYGWIN
00155         virtual void    serial(char &b);
00156 #endif
00157         virtual void    serial(std::string &b);
00158         virtual void    serial(ucstring &b);
00159         virtual void    serialBuffer(uint8 *buf, uint len);
00160         virtual void    serialBit(bool &bit);
00161 
00162         virtual bool    xmlPushBeginInternal (const char *nodeName);
00163         virtual bool    xmlPushEndInternal ();
00164         virtual bool    xmlPopInternal ();
00165         virtual bool    xmlSetAttribInternal (const char *attribName);
00166         virtual bool    xmlBreakLineInternal ();
00167         virtual bool    xmlCommentInternal (const char *comment);
00168 
00169         // Internal functions
00170         void                    serialSeparatedBufferIn ( std::string &value, bool checkSeparator = true );
00171         inline void             flushContentString ();
00172 
00173         // Push has began
00174         bool                    _PushBegin;
00175 
00176         // Attribute present
00177         bool                    _AttribPresent;
00178 
00179         // Attribute name
00180         std::string             _AttribName;
00181 
00182         // Current libxml node
00183         xmlNodePtr              _CurrentNode;
00184 
00185         // Current libxml header node opened
00186         xmlNodePtr              _CurrentElement;
00187 
00188         // Parser pointer
00189         xmlParserCtxtPtr        _Parser;
00190 
00191         // Current node text
00192         std::string             _ContentString;
00193 
00194         // Current index in the node string
00195         uint                    _ContentStringIndex;
00196 
00197         // Error message
00198         std::string             _ErrorString;
00199 };
00200 
00201 
00202 } // NLMISC
00203 
00204 #endif // NL_DONT_USE_EXTERNAL_CODE
00205 
00206 #endif // NL_I_XML_H
00207 
00208 /* End of o_xml.h */