# 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  

NLMISC::COXml Class Reference

Output xml stream. More...

#include <o_xml.h>

Inheritance diagram for NLMISC::COXml:

NLMISC::IStream List of all members.

Public Methods

 COXml ()
 Stream ctor. More...

bool init (IStream *stream, const char *version="1.0")
 Stream initialisation. More...

virtual ~COXml ()
 Default dstor. More...

void flush ()
 Flush the stream. More...

xmlDocPtr getDocument ()
 Get root XML document pointer. More...


Static Public Methods

bool isStringValidForProperties (const char *str)
 Return true if the string is valid to be stored in a XML property without modification. More...


Private Methods

virtual void serial (uint8 &b)
 From IStream. More...

virtual void serial (sint8 &b)
virtual void serial (uint16 &b)
virtual void serial (sint16 &b)
virtual void serial (uint32 &b)
virtual void serial (sint32 &b)
virtual void serial (uint64 &b)
virtual void serial (sint64 &b)
virtual void serial (float &b)
virtual void serial (double &b)
virtual void serial (bool &b)
virtual void serial (char &b)
virtual void serial (std::string &b)
virtual void serial (ucstring &b)
virtual void serialBuffer (uint8 *buf, uint len)
 Method to be specified by the Deriver. More...

virtual void serialBit (bool &bit)
virtual bool xmlPushBeginInternal (const char *nodeName)
 xmlPushBegin implementation. More...

virtual bool xmlPushEndInternal ()
 xmlPushEnd implementation. More...

virtual bool xmlPopInternal ()
 xmlPop implementation. More...

virtual bool xmlSetAttribInternal (const char *attribName)
 xmlBreakLine implementation. More...

virtual bool xmlBreakLineInternal ()
 xmlBreakLine implementation. More...

virtual bool xmlCommentInternal (const char *comment)
void serialSeparatedBufferOut (const char *value)
void flushContentString ()

Private Attributes

bool _PushBegin
bool _AttribPresent
std::string _AttribName
IStream_InternalStream
xmlDocPtr _Document
std::string _Version
xmlNodePtr _CurrentNode
std::string _ContentString

Friends

int xmlOutputWriteCallbackForNeL (void *context, const char *buffer, int len)
int xmlOutputCloseCallbackForNeL (void *context)

Detailed Description

Output xml stream.

This class is an xml formated output stream.

This stream use an internal stream to output final xml code.

        // Check exceptions
        try
        {
                // File stream
                COFile file;

                // Open the file
                file.open ("output.xml");

                // Create the XML stream
                COXml output;

                // Init
                if (output.init (&file, "1.0"))
                {
                        // Serial the class
                        myClass.serial (output);

                        // Flush the stream, write all the output file
                        output.flush ();
                }

                // Close the file
                file.close ();
        }
        catch (Exception &e)
        {
        }

Author:
Cyril 'Hulud' Corvazier , Nevrax France
Date:
2001

Definition at line 85 of file o_xml.h.


Constructor & Destructor Documentation

NLMISC::COXml::COXml  
 

Stream ctor.

Definition at line 72 of file o_xml.cpp.

References _ContentString, _CurrentNode, _Document, _InternalStream, _PushBegin, _Version, and NLMISC::IStream::setXMLMode.

NLMISC::COXml::~COXml   [virtual]
 

Default dstor.

Flush the stream.

Definition at line 133 of file o_xml.cpp.

References flush.


Member Function Documentation

void NLMISC::COXml::flush  
 

Flush the stream.

You can only flush the stream when all xmlPushBegin - xmlPop have been closed.

Definition at line 601 of file o_xml.cpp.

References _Document, nlassert, res, xmlOutputCloseCallbackForNeL, and xmlOutputWriteCallbackForNeL.

Referenced by ~COXml.

void NLMISC::COXml::flushContentString   [inline, private]
 

Definition at line 50 of file o_xml.cpp.

References _ContentString, _CurrentNode, and nlassert.

Referenced by xmlPopInternal, and xmlPushBeginInternal.

xmlDocPtr NLMISC::COXml::getDocument  
 

Get root XML document pointer.

Definition at line 654 of file o_xml.cpp.

References _Document, and _Version.

bool NLMISC::COXml::init IStream   stream,
const char *    version = "1.0"
 

Stream initialisation.

Parameters:
stream  is the stream the class will use to output xml code. this pointer is held by the class but won't be deleted.
version  is the version to write in the XML header. Default is 1.0.
Returns:
true if initialisation is successful, false if the stream passed is not an output stream.

Definition at line 98 of file o_xml.cpp.

References _ContentString, _CurrentNode, _Document, _InternalStream, _PushBegin, _Version, and NLMISC::IStream::setXMLMode.

bool NLMISC::COXml::isStringValidForProperties const char *    str [static]
 

Return true if the string is valid to be stored in a XML property without modification.

Definition at line 667 of file o_xml.cpp.

void NLMISC::COXml::serial ucstring   b [private, virtual]
 

Reimplemented from NLMISC::IStream.

Definition at line 321 of file o_xml.cpp.

References NLMISC::IStream::isReading, nlassert, nlwarning, and serial.

void NLMISC::COXml::serial std::string &    b [private, virtual]
 

Reimplemented from NLMISC::IStream.

Definition at line 296 of file o_xml.cpp.

References NLMISC::IStream::isReading, nlassert, serialSeparatedBufferOut, NLMISC::IStream::xmlPop, and NLMISC::IStream::xmlPush.

void NLMISC::COXml::serial char &    b [private, virtual]
 

Reimplemented from NLMISC::IStream.

Definition at line 287 of file o_xml.cpp.

References serialSeparatedBufferOut.

void NLMISC::COXml::serial bool &    b [private, virtual]
 

Reimplemented from NLMISC::IStream.

Definition at line 271 of file o_xml.cpp.

References serialBit.

void NLMISC::COXml::serial double &    b [private, virtual]
 

Reimplemented from NLMISC::IStream.

Definition at line 264 of file o_xml.cpp.

References writenumber.

void NLMISC::COXml::serial float &    b [private, virtual]
 

Reimplemented from NLMISC::IStream.

Definition at line 257 of file o_xml.cpp.

References writenumber.

void NLMISC::COXml::serial sint64   b [private, virtual]
 

Reimplemented from NLMISC::IStream.

Definition at line 250 of file o_xml.cpp.

References writenumber.

void NLMISC::COXml::serial uint64   b [private, virtual]
 

Reimplemented from NLMISC::IStream.

Definition at line 243 of file o_xml.cpp.

References writenumber.

void NLMISC::COXml::serial sint32   b [private, virtual]
 

Reimplemented from NLMISC::IStream.

Definition at line 236 of file o_xml.cpp.

References writenumber.

void NLMISC::COXml::serial uint32   b [private, virtual]
 

Reimplemented from NLMISC::IStream.

Definition at line 229 of file o_xml.cpp.

References writenumber.

void NLMISC::COXml::serial sint16   b [private, virtual]
 

Reimplemented from NLMISC::IStream.

Definition at line 222 of file o_xml.cpp.

References writenumber.

void NLMISC::COXml::serial uint16   b [private, virtual]
 

Reimplemented from NLMISC::IStream.

Definition at line 215 of file o_xml.cpp.

References writenumber.

void NLMISC::COXml::serial sint8   b [private, virtual]
 

Reimplemented from NLMISC::IStream.

Definition at line 208 of file o_xml.cpp.

References writenumber.

void NLMISC::COXml::serial uint8   b [private, virtual]
 

From IStream.

Reimplemented from NLMISC::IStream.

Definition at line 200 of file o_xml.cpp.

References writenumber.

Referenced by serial, serialBit, and serialBuffer.

void NLMISC::COXml::serialBit bool &    bit [private, virtual]
 

Implements NLMISC::IStream.

Definition at line 278 of file o_xml.cpp.

References serial.

Referenced by serial.

void NLMISC::COXml::serialBuffer uint8   buf,
uint    len
[private, virtual]
 

Method to be specified by the Deriver.

Warning:
Do not call these methods from outside, unless you really know what you are doing. Using them instead of serial() can lead to communication problems between different platforms !

Implements NLMISC::IStream.

Definition at line 354 of file o_xml.cpp.

References serial, NLMISC::IStream::xmlPop, and NLMISC::IStream::xmlPush.

void NLMISC::COXml::serialSeparatedBufferOut const char *    value [private]
 

Definition at line 141 of file o_xml.cpp.

References _AttribName, _AttribPresent, _ContentString, _CurrentNode, NLMISC::IStream::isReading, nlassert, nlerror, NLMISC::SEPARATOR, and value.

Referenced by serial.

bool NLMISC::COXml::xmlBreakLineInternal   [private, virtual]
 

xmlBreakLine implementation.

Reimplemented from NLMISC::IStream.

Definition at line 537 of file o_xml.cpp.

References _ContentString, _PushBegin, NLMISC::IStream::isReading, nlassert, and nlwarning.

bool NLMISC::COXml::xmlCommentInternal const char *    comment [private, virtual]
 

Definition at line 568 of file o_xml.cpp.

References _CurrentNode, comment, NLMISC::IStream::isReading, nlassert, and nlwarning.

bool NLMISC::COXml::xmlPopInternal   [private, virtual]
 

xmlPop implementation.

Reimplemented from NLMISC::IStream.

Definition at line 469 of file o_xml.cpp.

References _CurrentNode, _PushBegin, flushContentString, NLMISC::IStream::isReading, nlassert, and nlwarning.

bool NLMISC::COXml::xmlPushBeginInternal const char *    nodeName [private, virtual]
 

xmlPushBegin implementation.

Reimplemented from NLMISC::IStream.

Definition at line 375 of file o_xml.cpp.

References _CurrentNode, _Document, _PushBegin, _Version, flushContentString, NLMISC::IStream::isReading, nlassert, and nlwarning.

bool NLMISC::COXml::xmlPushEndInternal   [private, virtual]
 

xmlPushEnd implementation.

Reimplemented from NLMISC::IStream.

Definition at line 438 of file o_xml.cpp.

References _PushBegin, NLMISC::IStream::isReading, nlassert, and nlwarning.

bool NLMISC::COXml::xmlSetAttribInternal const char *    attribName [private, virtual]
 

xmlBreakLine implementation.

Reimplemented from NLMISC::IStream.

Definition at line 503 of file o_xml.cpp.

References _AttribName, _AttribPresent, NLMISC::IStream::isReading, nlassert, and nlwarning.


Friends And Related Function Documentation

int xmlOutputCloseCallbackForNeL void *    context [friend]
 

Definition at line 643 of file o_xml.cpp.

Referenced by flush.

int xmlOutputWriteCallbackForNeL void *    context,
const char *    buffer,
int    len
[friend]
 

Definition at line 629 of file o_xml.cpp.

Referenced by flush.


Member Data Documentation

std::string NLMISC::COXml::_AttribName [private]
 

Definition at line 165 of file o_xml.h.

Referenced by serialSeparatedBufferOut, and xmlSetAttribInternal.

bool NLMISC::COXml::_AttribPresent [private]
 

Definition at line 162 of file o_xml.h.

Referenced by serialSeparatedBufferOut, and xmlSetAttribInternal.

std::string NLMISC::COXml::_ContentString [private]
 

Definition at line 180 of file o_xml.h.

Referenced by COXml, flushContentString, init, serialSeparatedBufferOut, and xmlBreakLineInternal.

xmlNodePtr NLMISC::COXml::_CurrentNode [private]
 

Definition at line 177 of file o_xml.h.

Referenced by COXml, flushContentString, init, serialSeparatedBufferOut, xmlCommentInternal, xmlPopInternal, and xmlPushBeginInternal.

xmlDocPtr NLMISC::COXml::_Document [private]
 

Definition at line 171 of file o_xml.h.

Referenced by COXml, flush, getDocument, init, and xmlPushBeginInternal.

IStream* NLMISC::COXml::_InternalStream [private]
 

Definition at line 168 of file o_xml.h.

Referenced by COXml, and init.

bool NLMISC::COXml::_PushBegin [private]
 

Definition at line 159 of file o_xml.h.

Referenced by COXml, init, xmlBreakLineInternal, xmlPopInternal, xmlPushBeginInternal, and xmlPushEndInternal.

std::string NLMISC::COXml::_Version [private]
 

Definition at line 174 of file o_xml.h.

Referenced by COXml, getDocument, init, and xmlPushBeginInternal.


The documentation for this class was generated from the following files: