tinystr.h | tinystr.h | |||
---|---|---|---|---|
skipping to change at line 25 | skipping to change at line 25 | |||
software in a product, an acknowledgment in the product documentation | software in a product, an acknowledgment in the product documentation | |||
would be appreciated but is not required. | would be appreciated but is not required. | |||
2. Altered source versions must be plainly marked as such, and | 2. Altered source versions must be plainly marked as such, and | |||
must not be misrepresented as being the original software. | must not be misrepresented as being the original software. | |||
3. This notice may not be removed or altered from any source | 3. This notice may not be removed or altered from any source | |||
distribution. | distribution. | |||
*/ | */ | |||
#include "tinyxml.h" | ||||
#ifndef TIXML_USE_STL | ||||
#ifndef TIXML_STRING_INCLUDED | #ifndef TIXML_STRING_INCLUDED | |||
#define TIXML_STRING_INCLUDED | #define TIXML_STRING_INCLUDED | |||
#pragma warning( disable : 4514 ) | #pragma warning( disable : 4514 ) | |||
#include <assert.h> | #include <assert.h> | |||
/* | /* | |||
TiXmlString is an emulation of the std::string template. | TiXmlString is an emulation of the std::string template. | |||
Its purpose is to allow compiling TinyXML on compilers with no or poor S TL support. | Its purpose is to allow compiling TinyXML on compilers with no or poor S TL support. | |||
skipping to change at line 197 | skipping to change at line 201 | |||
{ | { | |||
char smallstr [2]; | char smallstr [2]; | |||
smallstr [0] = single; | smallstr [0] = single; | |||
smallstr [1] = 0; | smallstr [1] = 0; | |||
append (smallstr); | append (smallstr); | |||
} | } | |||
} ; | } ; | |||
/* | /* | |||
TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlStri ng. \n | TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlStri ng. | |||
Only the operators that we need for TinyXML have been developped. | Only the operators that we need for TinyXML have been developped. | |||
*/ | */ | |||
class TiXmlOutStream : public TiXmlString | class TiXmlOutStream : public TiXmlString | |||
{ | { | |||
public : | public : | |||
TiXmlOutStream () : TiXmlString () {} | TiXmlOutStream () : TiXmlString () {} | |||
// TiXmlOutStream << operator. Maps to TiXmlString::append | // TiXmlOutStream << operator. Maps to TiXmlString::append | |||
TiXmlOutStream & operator << (const char * in) | TiXmlOutStream & operator << (const char * in) | |||
{ | { | |||
skipping to change at line 220 | skipping to change at line 224 | |||
} | } | |||
// TiXmlOutStream << operator. Maps to TiXmlString::append | // TiXmlOutStream << operator. Maps to TiXmlString::append | |||
TiXmlOutStream & operator << (const TiXmlString & in) | TiXmlOutStream & operator << (const TiXmlString & in) | |||
{ | { | |||
append (in . c_str ()); | append (in . c_str ()); | |||
return (* this); | return (* this); | |||
} | } | |||
} ; | } ; | |||
#endif | #endif // TIXML_STRING_INCLUDED | |||
#endif // TIXML_USE_STL | ||||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 5 lines changed or added | |||
tinyxml.h | tinyxml.h | |||
---|---|---|---|---|
skipping to change at line 28 | skipping to change at line 28 | |||
2. Altered source versions must be plainly marked as such, and | 2. Altered source versions must be plainly marked as such, and | |||
must not be misrepresented as being the original software. | must not be misrepresented as being the original software. | |||
3. This notice may not be removed or altered from any source | 3. This notice may not be removed or altered from any source | |||
distribution. | distribution. | |||
*/ | */ | |||
#ifndef TINYXML_INCLUDED | #ifndef TINYXML_INCLUDED | |||
#define TINYXML_INCLUDED | #define TINYXML_INCLUDED | |||
#ifdef _MSC_VER | ||||
#pragma warning( disable : 4530 ) | #pragma warning( disable : 4530 ) | |||
#pragma warning( disable : 4786 ) | #pragma warning( disable : 4786 ) | |||
#endif | ||||
#include <ctype.h> | #include <ctype.h> | |||
#include <stdio.h> | #include <stdio.h> | |||
#include <stdlib.h> | #include <stdlib.h> | |||
#include <string.h> | #include <string.h> | |||
#include <assert.h> | #include <assert.h> | |||
// Help out windows: | // Help out windows: | |||
#if defined( _DEBUG ) && !defined( DEBUG ) | #if defined( _DEBUG ) && !defined( DEBUG ) | |||
#define DEBUG | #define DEBUG | |||
skipping to change at line 427 | skipping to change at line 429 | |||
TiXmlDocument* ToDocument() const { return ( this && t ype == DOCUMENT ) ? (TiXmlDocument*) this : 0; } ///< Cast to a more define d type. Will return null not of the requested type. | TiXmlDocument* ToDocument() const { return ( this && t ype == DOCUMENT ) ? (TiXmlDocument*) this : 0; } ///< Cast to a more define d type. Will return null not of the requested type. | |||
TiXmlElement* ToElement() const { return ( this && t ype == ELEMENT ) ? (TiXmlElement*) this : 0; } ///< Cast to a more define d type. Will return null not of the requested type. | TiXmlElement* ToElement() const { return ( this && t ype == ELEMENT ) ? (TiXmlElement*) this : 0; } ///< Cast to a more define d type. Will return null not of the requested type. | |||
TiXmlComment* ToComment() const { return ( this && t ype == COMMENT ) ? (TiXmlComment*) this : 0; } ///< Cast to a more define d type. Will return null not of the requested type. | TiXmlComment* ToComment() const { return ( this && t ype == COMMENT ) ? (TiXmlComment*) this : 0; } ///< Cast to a more define d type. Will return null not of the requested type. | |||
TiXmlUnknown* ToUnknown() const { return ( this && t ype == UNKNOWN ) ? (TiXmlUnknown*) this : 0; } ///< Cast to a more define d type. Will return null not of the requested type. | TiXmlUnknown* ToUnknown() const { return ( this && t ype == UNKNOWN ) ? (TiXmlUnknown*) this : 0; } ///< Cast to a more define d type. Will return null not of the requested type. | |||
TiXmlText* ToText() const { return ( this && t ype == TEXT ) ? (TiXmlText*) this : 0; } ///< Cast to a more define d type. Will return null not of the requested type. | TiXmlText* ToText() const { return ( this && t ype == TEXT ) ? (TiXmlText*) this : 0; } ///< Cast to a more define d type. Will return null not of the requested type. | |||
TiXmlDeclaration* ToDeclaration() const { return ( this && type == D ECLARATION ) ? (TiXmlDeclaration*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. | TiXmlDeclaration* ToDeclaration() const { return ( this && type == D ECLARATION ) ? (TiXmlDeclaration*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. | |||
virtual TiXmlNode* Clone() const = 0; | virtual TiXmlNode* Clone() const = 0; | |||
void SetUserData( void* user ) { userData = user; } | ||||
void* GetUserData() { re | ||||
turn userData; } | ||||
protected: | protected: | |||
TiXmlNode( NodeType type ); | TiXmlNode( NodeType type ); | |||
#ifdef TIXML_USE_STL | #ifdef TIXML_USE_STL | |||
// The real work of the input operator. | // The real work of the input operator. | |||
virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0; | virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0; | |||
#endif | #endif | |||
// The node is passed in by ownership. This object will delete it. | // The node is passed in by ownership. This object will delete it. | |||
TiXmlNode* LinkEndChild( TiXmlNode* addThis ); | TiXmlNode* LinkEndChild( TiXmlNode* addThis ); | |||
// Figure out what is at *p, and parse it. Returns null if it is not an xml node. | // Figure out what is at *p, and parse it. Returns null if it is not an xml node. | |||
TiXmlNode* Identify( const char* start ); | TiXmlNode* Identify( const char* start ); | |||
void CopyToClone( TiXmlNode* target ) const { target->SetValue ( | void CopyToClone( TiXmlNode* target ) const { target->SetValue ( | |||
value.c_str() ); } | value.c_str() ); | |||
target->userData = userData; } | ||||
// Internal Value function returning a TIXML_STRING | // Internal Value function returning a TIXML_STRING | |||
TIXML_STRING SValue() const { return value ; } | TIXML_STRING SValue() const { return value ; } | |||
TiXmlNode* parent; | TiXmlNode* parent; | |||
NodeType type; | NodeType type; | |||
TiXmlNode* firstChild; | TiXmlNode* firstChild; | |||
TiXmlNode* lastChild; | TiXmlNode* lastChild; | |||
TIXML_STRING value; | TIXML_STRING value; | |||
TiXmlNode* prev; | TiXmlNode* prev; | |||
TiXmlNode* next; | TiXmlNode* next; | |||
void* userData; | ||||
}; | }; | |||
/** An attribute is a name-value pair. Elements have an arbitrary | /** An attribute is a name-value pair. Elements have an arbitrary | |||
number of attributes, each with a unique name. | number of attributes, each with a unique name. | |||
@note The attributes are not TiXmlNodes, since they are not | @note The attributes are not TiXmlNodes, since they are not | |||
part of the tinyXML document object model. There are other | part of the tinyXML document object model. There are other | |||
suggested ways to look at this problem. | suggested ways to look at this problem. | |||
@note Attributes have a parent | @note Attributes have a parent | |||
skipping to change at line 686 | skipping to change at line 693 | |||
{ | { | |||
friend class TiXmlElement; | friend class TiXmlElement; | |||
public: | public: | |||
/// Constructor. | /// Constructor. | |||
TiXmlText (const char * initValue) : TiXmlNode (TiXmlNode::TEXT) | TiXmlText (const char * initValue) : TiXmlNode (TiXmlNode::TEXT) | |||
{ | { | |||
SetValue( initValue ); | SetValue( initValue ); | |||
} | } | |||
virtual ~TiXmlText() {} | virtual ~TiXmlText() {} | |||
#ifdef TIXML_USE_STL | #ifdef TIXML_USE_STL | |||
/// Constructor. | /// Constructor. | |||
TiXmlText( const std::string& initValue ); | TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TE | |||
#endif | XT) | |||
{ | ||||
SetValue( initValue ); | ||||
} | ||||
#endif | ||||
protected : | protected : | |||
// [internal use] Creates a new Element and returns it. | // [internal use] Creates a new Element and returns it. | |||
virtual TiXmlNode* Clone() const; | virtual TiXmlNode* Clone() const; | |||
// [internal use] | // [internal use] | |||
virtual void Print( FILE* cfile, int depth ) const; | virtual void Print( FILE* cfile, int depth ) const; | |||
virtual void StreamOut ( TIXML_OSTREAM * out ) const; | virtual void StreamOut ( TIXML_OSTREAM * out ) const; | |||
// [internal use] | // [internal use] | |||
bool Blank() const; // returns true if all white space and new l ines | bool Blank() const; // returns true if all white space and new l ines | |||
/* [internal use] | /* [internal use] | |||
skipping to change at line 825 | skipping to change at line 835 | |||
/// Create an empty document, that has no name. | /// Create an empty document, that has no name. | |||
TiXmlDocument(); | TiXmlDocument(); | |||
/// Create a document with a name. The name of the document is also the filename of the xml. | /// Create a document with a name. The name of the document is also the filename of the xml. | |||
TiXmlDocument( const char * documentName ); | TiXmlDocument( const char * documentName ); | |||
#ifdef TIXML_USE_STL | #ifdef TIXML_USE_STL | |||
/// Constructor. | /// Constructor. | |||
TiXmlDocument( const std::string& documentName ) : | TiXmlDocument( const std::string& documentName ) : | |||
TiXmlNode( TiXmlNode::DOCUMENT ) | TiXmlNode( TiXmlNode::DOCUMENT ) | |||
{ | { | |||
value = documentName; | ||||
error = false; | error = false; | |||
} | } | |||
#endif | #endif | |||
virtual ~TiXmlDocument() {} | virtual ~TiXmlDocument() {} | |||
/** Load a file using the current document value. | /** Load a file using the current document value. | |||
Returns true if successful. Will delete any existing | Returns true if successful. Will delete any existing | |||
document data before loading. | document data before loading. | |||
*/ | */ | |||
bool LoadFile(); | bool LoadFile(); | |||
/// Save a file using the current document value. Returns true if su ccessful. | /// Save a file using the current document value. Returns true if su ccessful. | |||
bool SaveFile() const; | bool SaveFile() const; | |||
/// Load a file using the given filename. Returns true if successful . | /// Load a file using the given filename. Returns true if successful . | |||
bool LoadFile( const char * filename ); | bool LoadFile( const char * filename ); | |||
/// Save a file using the given filename. Returns true if successful . | /// Save a file using the given filename. Returns true if successful . | |||
bool SaveFile( const char * filename ) const; | bool SaveFile( const char * filename ) const; | |||
#ifdef TIXML_USE_STL | #ifdef TIXML_USE_STL | |||
bool LoadFile( const std::string& filename ); ///< | bool LoadFile( const std::string& filename ) ///< | |||
STL std::string version. | STL std::string version. | |||
bool SaveFile( const std::string& filename ) const; ///< | { | |||
STL std::string version. | return LoadFile (filename.c_str ()); | |||
} | ||||
bool SaveFile( const std::string& filename ) const ///< | ||||
STL std::string version. | ||||
{ | ||||
return SaveFile (filename.c_str ()); | ||||
} | ||||
#endif | #endif | |||
/// Parse the given null terminated block of xml data. | /// Parse the given null terminated block of xml data. | |||
virtual const char* Parse( const char* p ); | virtual const char* Parse( const char* p ); | |||
/** Get the root element -- the only top level element -- of the doc ument. | /** Get the root element -- the only top level element -- of the doc ument. | |||
In well formed XML, there should only be one. TinyXml is tol erant of | In well formed XML, there should only be one. TinyXml is tol erant of | |||
multiple elements at the document level. | multiple elements at the document level. | |||
*/ | */ | |||
TiXmlElement* RootElement() const { return FirstChildE lement(); } | TiXmlElement* RootElement() const { return FirstChildE lement(); } | |||
End of changes. 9 change blocks. | ||||
9 lines changed or deleted | 29 lines changed or added | |||