tinyxml.h   tinyxml.h 
skipping to change at line 66 skipping to change at line 66
// new safe versions. This probably doesn't fully address the problem, // new safe versions. This probably doesn't fully address the problem,
// but it gets closer. There are too many compilers for me to fully // but it gets closer. There are too many compilers for me to fully
// test. If you get compilation troubles, undefine TIXML_SAFE // test. If you get compilation troubles, undefine TIXML_SAFE
#define TIXML_SAFE #define TIXML_SAFE
#ifdef TIXML_SAFE #ifdef TIXML_SAFE
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
// Microsoft visual studio, version 2005 and higher. // Microsoft visual studio, version 2005 and higher.
#define TIXML_SNPRINTF _snprintf_s #define TIXML_SNPRINTF _snprintf_s
#define TIXML_SNSCANF _snscanf_s #define TIXML_SNSCANF _snscanf_s
#define TIXML_SSCANF sscanf_s
#elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
// Microsoft visual studio, version 6 and higher. // Microsoft visual studio, version 6 and higher.
//#pragma message( "Using _sn* functions." ) //#pragma message( "Using _sn* functions." )
#define TIXML_SNPRINTF _snprintf #define TIXML_SNPRINTF _snprintf
#define TIXML_SNSCANF _snscanf #define TIXML_SNSCANF _snscanf
#define TIXML_SSCANF sscanf
#elif defined(__GNUC__) && (__GNUC__ >= 3 ) #elif defined(__GNUC__) && (__GNUC__ >= 3 )
// GCC version 3 and higher.s // GCC version 3 and higher.s
//#warning( "Using sn* functions." ) //#warning( "Using sn* functions." )
#define TIXML_SNPRINTF snprintf #define TIXML_SNPRINTF snprintf
#define TIXML_SNSCANF snscanf #define TIXML_SNSCANF snscanf
#define TIXML_SSCANF sscanf
#else
#define TIXML_SSCANF sscanf
#endif #endif
#endif #endif
class TiXmlDocument; class TiXmlDocument;
class TiXmlElement; class TiXmlElement;
class TiXmlComment; class TiXmlComment;
class TiXmlUnknown; class TiXmlUnknown;
class TiXmlAttribute; class TiXmlAttribute;
class TiXmlText; class TiXmlText;
class TiXmlDeclaration; class TiXmlDeclaration;
class TiXmlParsingData; class TiXmlParsingData;
const int TIXML_MAJOR_VERSION = 2; const int TIXML_MAJOR_VERSION = 2;
const int TIXML_MINOR_VERSION = 5; const int TIXML_MINOR_VERSION = 5;
const int TIXML_PATCH_VERSION = 2; const int TIXML_PATCH_VERSION = 3;
/* Internal structure for tracking location of items /* Internal structure for tracking location of items
in the XML file. in the XML file.
*/ */
struct TiXmlCursor struct TiXmlCursor
{ {
TiXmlCursor() { Clear(); } TiXmlCursor() { Clear(); }
void Clear() { row = col = -1; } void Clear() { row = col = -1; }
int row; // 0 based. int row; // 0 based.
skipping to change at line 128 skipping to change at line 133
You should never change the document from a callback. You should never change the document from a callback.
@sa TiXmlNode::Accept() @sa TiXmlNode::Accept()
*/ */
class TiXmlVisitor class TiXmlVisitor
{ {
public: public:
virtual ~TiXmlVisitor() {} virtual ~TiXmlVisitor() {}
/// Visit a document. /// Visit a document.
virtual bool VisitEnter( const TiXmlDocument& doc ) { return tru e; } virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; }
/// Visit a document. /// Visit a document.
virtual bool VisitExit( const TiXmlDocument& doc ) { return tru e; } virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; }
/// Visit an element. /// Visit an element.
virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAtt ribute* firstAttribute ) { return true; } virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXm lAttribute* /*firstAttribute*/ ) { return true; }
/// Visit an element. /// Visit an element.
virtual bool VisitExit( const TiXmlElement& element ) { retur n true; } virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; }
/// Visit a declaration /// Visit a declaration
virtual bool Visit( const TiXmlDeclaration& declaration ) { return true; } virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { re turn true; }
/// Visit a text node /// Visit a text node
virtual bool Visit( const TiXmlText& text ) { return true; } virtual bool Visit( const TiXmlText& /*text*/ ) { return true; }
/// Visit a comment node /// Visit a comment node
virtual bool Visit( const TiXmlComment& comment ) { return true; } virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; }
/// Visit an unknow node /// Visit an unknow node
virtual bool Visit( const TiXmlUnknown& unknown ) { return true; } virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; }
}; };
// Only used by Attribute::Query functions // Only used by Attribute::Query functions
enum enum
{ {
TIXML_SUCCESS, TIXML_SUCCESS,
TIXML_NO_ATTRIBUTE, TIXML_NO_ATTRIBUTE,
TIXML_WRONG_TYPE TIXML_WRONG_TYPE
}; };
skipping to change at line 252 skipping to change at line 257
const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data.
// Table that returs, for a given lead byte, the total number of byt es // Table that returs, for a given lead byte, the total number of byt es
// in the UTF-8 sequence. // in the UTF-8 sequence.
static const int utf8ByteTable[256]; static const int utf8ByteTable[256];
virtual const char* Parse( const char* p, virtual const char* Parse( const char* p,
TiXmlParsing Data* data, TiXmlParsing Data* data,
TiXmlEncodin g encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; TiXmlEncodin g encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
/** Expands entities in a string. Note this should not contian the t
ag's '<', '>', etc,
or they will be transformed into entities!
*/
static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out
);
enum enum
{ {
TIXML_NO_ERROR = 0, TIXML_NO_ERROR = 0,
TIXML_ERROR, TIXML_ERROR,
TIXML_ERROR_OPENING_FILE, TIXML_ERROR_OPENING_FILE,
TIXML_ERROR_OUT_OF_MEMORY, TIXML_ERROR_OUT_OF_MEMORY,
TIXML_ERROR_PARSING_ELEMENT, TIXML_ERROR_PARSING_ELEMENT,
TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
TIXML_ERROR_READING_ELEMENT_VALUE, TIXML_ERROR_READING_ELEMENT_VALUE,
TIXML_ERROR_READING_ATTRIBUTES, TIXML_ERROR_READING_ATTRIBUTES,
skipping to change at line 351 skipping to change at line 361
} }
return p + (*length); return p + (*length);
} }
else else
{ {
// Not valid text. // Not valid text.
return 0; return 0;
} }
} }
// Puts a string to a stream, expanding entities as it goes.
// Note this should not contian the '<', '>', etc, or they will be t
ransformed into entities!
static void PutString( const TIXML_STRING& str, TIXML_STRING* out );
// Return true if the next characters in the stream are any of the e ndTag sequences. // Return true if the next characters in the stream are any of the e ndTag sequences.
// Ignore case only works for english, and should only be relied on when comparing // Ignore case only works for english, and should only be relied on when comparing
// to English words: StringEqual( p, "version", true ) is fine. // to English words: StringEqual( p, "version", true ) is fine.
static bool StringEqual( const char* p, static bool StringEqual( const char* p,
const char* endTag, const char* endTag,
bool ignoreC ase, bool ignoreC ase,
TiXmlEncodin g encoding ); TiXmlEncodin g encoding );
static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
skipping to change at line 488 skipping to change at line 494
const char *Value() const { return value.c_str (); } const char *Value() const { return value.c_str (); }
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
/** Return Value() as a std::string. If you only use STL, /** Return Value() as a std::string. If you only use STL,
this is more efficient than calling Value(). this is more efficient than calling Value().
Only available in STL mode. Only available in STL mode.
*/ */
const std::string& ValueStr() const { return value; } const std::string& ValueStr() const { return value; }
#endif #endif
const TIXML_STRING& ValueTStr() const { return value; }
/** Changes the value of the node. Defined as: /** Changes the value of the node. Defined as:
@verbatim @verbatim
Document: filename of the xml file Document: filename of the xml file
Element: name of the element Element: name of the element
Comment: the comment text Comment: the comment text
Unknown: the tag contents Unknown: the tag contents
Text: the text string Text: the text string
@endverbatim @endverbatim
*/ */
void SetValue(const char * _value) { value = _value;} void SetValue(const char * _value) { value = _value;}
skipping to change at line 511 skipping to change at line 519
void SetValue( const std::string& _value ) { value = _value; } void SetValue( const std::string& _value ) { value = _value; }
#endif #endif
/// Delete all the children of this node. Does not affect 'this'. /// Delete all the children of this node. Does not affect 'this'.
void Clear(); void Clear();
/// One step up the DOM. /// One step up the DOM.
TiXmlNode* Parent() { return parent; } TiXmlNode* Parent() { return parent; }
const TiXmlNode* Parent() const { return par ent; } const TiXmlNode* Parent() const { return par ent; }
const TiXmlNode* FirstChild() const { return firstChild; } const TiXmlNode* FirstChild() const { return firstChild;
///< The first child of this node. Will be null if there are no childre } ///< The first child of this node. Will be null if there are no childre
n. n.
TiXmlNode* FirstChild() { return fir TiXmlNode* FirstChild() { re
stChild; } turn firstChild; }
const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Wi ll be null if none found. const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Wi ll be null if none found.
/// The first child of this node with the matching 'value'. Will be null if none found. /// The first child of this node with the matching 'value'. Will be null if none found.
TiXmlNode* FirstChild( const char * _value ) { TiXmlNode* FirstChild( const char * _value ) {
// Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
// call the method, cast the return back to non-const. // call the method, cast the return back to non-const.
return const_cast< TiXmlNode* > ((const_cast< const TiXmlNod e* >(this))->FirstChild( _value )); return const_cast< TiXmlNode* > ((const_cast< const TiXmlNod e* >(this))->FirstChild( _value ));
} }
const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children.
TiXmlNode* LastChild() { return lastChild; } TiXmlNode* LastChild() { return lastChild; }
skipping to change at line 985 skipping to change at line 993
int QueryDoubleAttribute( const char* name, double* _value ) const; int QueryDoubleAttribute( const char* name, double* _value ) const;
/// QueryFloatAttribute examines the attribute - see QueryIntAttribu te(). /// QueryFloatAttribute examines the attribute - see QueryIntAttribu te().
int QueryFloatAttribute( const char* name, float* _value ) const { int QueryFloatAttribute( const char* name, float* _value ) const {
double d; double d;
int result = QueryDoubleAttribute( name, &d ); int result = QueryDoubleAttribute( name, &d );
if ( result == TIXML_SUCCESS ) { if ( result == TIXML_SUCCESS ) {
*_value = (float)d; *_value = (float)d;
} }
return result; return result;
} }
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
/** Template form of the attribute query which will try to read the /** Template form of the attribute query which will try to read the
attribute into the specified type. Very easy, very powerful, but attribute into the specified type. Very easy, very powerful, but
be careful to make sure to call this with the correct type. be careful to make sure to call this with the correct type.
NOTE: This method doesn't work correctly for 'string' types.
@return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBU TE @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBU TE
*/ */
template< typename T > int QueryValueAttribute( const std::string& n ame, T* outValue ) const template< typename T > int QueryValueAttribute( const std::string& n ame, T* outValue ) const
{ {
const TiXmlAttribute* node = attributeSet.Find( name ); const TiXmlAttribute* node = attributeSet.Find( name );
if ( !node ) if ( !node )
return TIXML_NO_ATTRIBUTE; return TIXML_NO_ATTRIBUTE;
std::stringstream sstream( node->ValueStr() ); std::stringstream sstream( node->ValueStr() );
sstream >> *outValue; sstream >> *outValue;
if ( !sstream.fail() ) if ( !sstream.fail() )
return TIXML_SUCCESS; return TIXML_SUCCESS;
return TIXML_WRONG_TYPE; return TIXML_WRONG_TYPE;
} }
/*
This is - in theory - a bug fix for "QueryValueAtribute returns tru
ncated std::string"
but template specialization is hard to get working cross-compiler.
Leaving the bug for now.
// The above will fail for std::string because the space character i
s used as a seperator.
// Specialize for strings. Bug [ 1695429 ] QueryValueAtribute return
s truncated std::string
template<> int QueryValueAttribute( const std::string& name, std::st
ring* outValue ) const
{
const TiXmlAttribute* node = attributeSet.Find( name );
if ( !node )
return TIXML_NO_ATTRIBUTE;
*outValue = node->ValueStr();
return TIXML_SUCCESS;
}
*/
#endif #endif
/** Sets an attribute of name to a given value. The attribute /** Sets an attribute of name to a given value. The attribute
will be created if it does not exist, or changed if it does. will be created if it does not exist, or changed if it does.
*/ */
void SetAttribute( const char* name, const char * _value ); void SetAttribute( const char* name, const char * _value );
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
const std::string* Attribute( const std::string& name ) const; const std::string* Attribute( const std::string& name ) const;
const std::string* Attribute( const std::string& name, int* i ) cons t; const std::string* Attribute( const std::string& name, int* i ) cons t;
 End of changes. 19 change blocks. 
19 lines changed or deleted 51 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/