# 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  

o_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_O_XML_H
00027 #define NL_O_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 
00041 namespace NLMISC {
00042 
00043 
00085 class COXml : public IStream
00086 {
00087         friend int xmlOutputWriteCallbackForNeL ( void *context, const char *buffer, int len );
00088         friend int xmlOutputCloseCallbackForNeL ( void *context );
00089 public:
00090 
00094         COXml ();
00095 
00103         bool init (IStream *stream, const char *version="1.0");
00104 
00109         virtual ~COXml ();
00110 
00115         void flush ();
00116 
00119         xmlDocPtr getDocument ();
00120 
00123         static bool             isStringValidForProperties (const char *str);
00124 
00125 private:
00126 
00128         virtual void    serial(uint8 &b);
00129         virtual void    serial(sint8 &b);
00130         virtual void    serial(uint16 &b);
00131         virtual void    serial(sint16 &b);
00132         virtual void    serial(uint32 &b);
00133         virtual void    serial(sint32 &b);
00134         virtual void    serial(uint64 &b);
00135         virtual void    serial(sint64 &b);
00136         virtual void    serial(float &b);
00137         virtual void    serial(double &b);
00138         virtual void    serial(bool &b);
00139 #ifndef NL_OS_CYGWIN
00140         virtual void    serial(char &b);
00141 #endif
00142         virtual void    serial(std::string &b);
00143         virtual void    serial(ucstring &b);
00144         virtual void    serialBuffer(uint8 *buf, uint len);
00145         virtual void    serialBit(bool &bit);
00146 
00147         virtual bool    xmlPushBeginInternal (const char *nodeName);
00148         virtual bool    xmlPushEndInternal ();
00149         virtual bool    xmlPopInternal ();
00150         virtual bool    xmlSetAttribInternal (const char *attribName);
00151         virtual bool    xmlBreakLineInternal ();
00152         virtual bool    xmlCommentInternal (const char *comment);
00153 
00154         // Internal functions
00155         void                    serialSeparatedBufferOut( const char *value );
00156         inline void             flushContentString ();
00157 
00158         // Push mode
00159         bool                    _PushBegin;
00160 
00161         // Attribute defined
00162         bool                    _AttribPresent;
00163 
00164         // Attribute name
00165         std::string             _AttribName;
00166 
00167         // The internal stream
00168         IStream                 *_InternalStream;
00169         
00170         // Document pointer
00171         xmlDocPtr               _Document;
00172 
00173         // Document version
00174         std::string             _Version;
00175 
00176         // Current nodes
00177         xmlNodePtr              _CurrentNode;
00178 
00179         // Current content string
00180         std::string             _ContentString;
00181 };
00182 
00183 
00184 } // NLMISC
00185 
00186 #endif // NL_DONT_USE_EXTERNAL_CODE
00187 
00188 #endif // NL_O_XML_H
00189 
00190 /* End of o_xml.h */