|
|
@@ -24,11 +24,13 @@ distribution.
|
|
|
#ifndef TINYXML2_INCLUDED
|
|
|
#define TINYXML2_INCLUDED
|
|
|
|
|
|
-
|
|
|
-#include <limits.h>
|
|
|
-#include <ctype.h>
|
|
|
-#include <stdio.h>
|
|
|
-#include <memory.h> // Needed by mac.
|
|
|
+#include <cctype>
|
|
|
+#include <climits>
|
|
|
+#include <cstdio>
|
|
|
+#include <cstring>
|
|
|
+#if __APPLE__
|
|
|
+# include <memory.h>
|
|
|
+#endif
|
|
|
|
|
|
/*
|
|
|
TODO: add 'lastAttribute' for faster parsing.
|
|
|
@@ -36,7 +38,6 @@ distribution.
|
|
|
*/
|
|
|
/*
|
|
|
gcc: g++ -Wall tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
|
|
|
-
|
|
|
*/
|
|
|
|
|
|
#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
|
|
|
@@ -120,15 +121,15 @@ public:
|
|
|
ATTRIBUTE_NAME = 0,
|
|
|
ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
|
|
|
ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
|
|
|
- COMMENT = NEEDS_NEWLINE_NORMALIZATION,
|
|
|
+ COMMENT = NEEDS_NEWLINE_NORMALIZATION
|
|
|
};
|
|
|
|
|
|
StrPair() : flags( 0 ), start( 0 ), end( 0 ) {}
|
|
|
~StrPair();
|
|
|
|
|
|
- void Set( char* start, char* end, int flags ) {
|
|
|
+ void Set( char* start_, char* end_, int flags_ ) {
|
|
|
Reset();
|
|
|
- this->start = start; this->end = end; this->flags = flags | NEEDS_FLUSH;
|
|
|
+ this->start = start_; this->end = end_; this->flags = flags_ | NEEDS_FLUSH;
|
|
|
}
|
|
|
const char* GetStr();
|
|
|
bool Empty() const { return start == end; }
|
|
|
@@ -381,7 +382,7 @@ public:
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
- inline static int IsUTF8Continuation( unsigned char p ) { return p & 0x80; }
|
|
|
+ inline static int IsUTF8Continuation( const char p ) { return p & 0x80; }
|
|
|
inline static int IsAlphaNum( unsigned char anyByte ) { return ( anyByte < 128 ) ? isalnum( anyByte ) : 1; }
|
|
|
inline static int IsAlpha( unsigned char anyByte ) { return ( anyByte < 128 ) ? isalpha( anyByte ) : 1; }
|
|
|
|
|
|
@@ -472,7 +473,7 @@ public:
|
|
|
element with the specified name.
|
|
|
*/
|
|
|
const XMLElement* FirstChildElement( const char* value=0 ) const;
|
|
|
- XMLElement* FirstChildElement( const char* value=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( value )); }
|
|
|
+ XMLElement* FirstChildElement( const char* value_=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( value_ )); }
|
|
|
|
|
|
/// Get the last child node, or null if none exists.
|
|
|
const XMLNode* LastChild() const { return lastChild; }
|
|
|
@@ -482,7 +483,7 @@ public:
|
|
|
element with the specified name.
|
|
|
*/
|
|
|
const XMLElement* LastChildElement( const char* value=0 ) const;
|
|
|
- XMLElement* LastChildElement( const char* value=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(value) ); }
|
|
|
+ XMLElement* LastChildElement( const char* value_=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(value_) ); }
|
|
|
|
|
|
/// Get the previous (left) sibling node of this node.
|
|
|
const XMLNode* PreviousSibling() const { return prev; }
|
|
|
@@ -490,7 +491,7 @@ public:
|
|
|
|
|
|
/// Get the previous (left) sibling element of this node, with an opitionally supplied name.
|
|
|
const XMLElement* PreviousSiblingElement( const char* value=0 ) const ;
|
|
|
- XMLElement* PreviousSiblingElement( const char* value=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( value ) ); }
|
|
|
+ XMLElement* PreviousSiblingElement( const char* value_=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( value_ ) ); }
|
|
|
|
|
|
/// Get the next (right) sibling node of this node.
|
|
|
const XMLNode* NextSibling() const { return next; }
|
|
|
@@ -498,7 +499,7 @@ public:
|
|
|
|
|
|
/// Get the next (right) sibling element of this node, with an opitionally supplied name.
|
|
|
const XMLElement* NextSiblingElement( const char* value=0 ) const;
|
|
|
- XMLElement* NextSiblingElement( const char* value=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( value ) ); }
|
|
|
+ XMLElement* NextSiblingElement( const char* value_=0 ) { return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( value_ ) ); }
|
|
|
|
|
|
/**
|
|
|
Add a child node as the last (right) child.
|
|
|
@@ -616,7 +617,7 @@ public:
|
|
|
virtual const XMLText* ToText() const { return this; }
|
|
|
|
|
|
/// Declare whether this should be CDATA or standard text.
|
|
|
- void SetCData( bool isCData ) { this->isCData = isCData; }
|
|
|
+ void SetCData( bool isCData_ ) { this->isCData = isCData_; }
|
|
|
/// Returns true if this is a CDATA text element.
|
|
|
bool CData() const { return isCData; }
|
|
|
|
|
|
@@ -724,22 +725,22 @@ enum {
|
|
|
XML_NO_ERROR = 0,
|
|
|
XML_SUCCESS = 0,
|
|
|
|
|
|
- NO_ATTRIBUTE,
|
|
|
- WRONG_ATTRIBUTE_TYPE,
|
|
|
-
|
|
|
- ERROR_FILE_NOT_FOUND,
|
|
|
- ERROR_ELEMENT_MISMATCH,
|
|
|
- ERROR_PARSING_ELEMENT,
|
|
|
- ERROR_PARSING_ATTRIBUTE,
|
|
|
- ERROR_IDENTIFYING_TAG,
|
|
|
- ERROR_PARSING_TEXT,
|
|
|
- ERROR_PARSING_CDATA,
|
|
|
- ERROR_PARSING_COMMENT,
|
|
|
- ERROR_PARSING_DECLARATION,
|
|
|
- ERROR_PARSING_UNKNOWN,
|
|
|
- ERROR_EMPTY_DOCUMENT,
|
|
|
- ERROR_MISMATCHED_ELEMENT,
|
|
|
- ERROR_PARSING
|
|
|
+ XML_NO_ATTRIBUTE,
|
|
|
+ XML_WRONG_ATTRIBUTE_TYPE,
|
|
|
+
|
|
|
+ XML_ERROR_FILE_NOT_FOUND,
|
|
|
+ XML_ERROR_ELEMENT_MISMATCH,
|
|
|
+ XML_ERROR_PARSING_ELEMENT,
|
|
|
+ XML_ERROR_PARSING_ATTRIBUTE,
|
|
|
+ XML_ERROR_IDENTIFYING_TAG,
|
|
|
+ XML_ERROR_PARSING_TEXT,
|
|
|
+ XML_ERROR_PARSING_CDATA,
|
|
|
+ XML_ERROR_PARSING_COMMENT,
|
|
|
+ XML_ERROR_PARSING_DECLARATION,
|
|
|
+ XML_ERROR_PARSING_UNKNOWN,
|
|
|
+ XML_ERROR_EMPTY_DOCUMENT,
|
|
|
+ XML_ERROR_MISMATCHED_ELEMENT,
|
|
|
+ XML_ERROR_PARSING
|
|
|
};
|
|
|
|
|
|
|
|
|
@@ -773,7 +774,7 @@ public:
|
|
|
|
|
|
/** QueryIntAttribute interprets the attribute as an integer, and returns the value
|
|
|
in the provided paremeter. The function will return XML_NO_ERROR on success,
|
|
|
- and WRONG_ATTRIBUTE_TYPE if the conversion is not successful.
|
|
|
+ and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful.
|
|
|
*/
|
|
|
int QueryIntValue( int* value ) const;
|
|
|
/// See QueryIntAttribute
|
|
|
@@ -855,8 +856,8 @@ public:
|
|
|
float FloatAttribute( const char* name ) const { float f=0; QueryFloatAttribute( name, &f ); return f; }
|
|
|
|
|
|
/** Given an attribute name, QueryIntAttribute() returns
|
|
|
- XML_NO_ERROR, WRONG_ATTRIBUTE_TYPE if the conversion
|
|
|
- can't be performed, or NO_ATTRIBUTE if the attribute
|
|
|
+ XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion
|
|
|
+ can't be performed, or XML_NO_ATTRIBUTE if the attribute
|
|
|
doesn't exist. If successful, the result of the conversion
|
|
|
will be written to 'value'. If not successful, nothing will
|
|
|
be written to 'value'. This allows you to provide default
|
|
|
@@ -867,15 +868,15 @@ public:
|
|
|
QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10
|
|
|
@endverbatim
|
|
|
*/
|
|
|
- int QueryIntAttribute( const char* name, int* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return NO_ATTRIBUTE; return a->QueryIntValue( value ); }
|
|
|
+ int QueryIntAttribute( const char* name, int* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryIntValue( value ); }
|
|
|
/// See QueryIntAttribute()
|
|
|
- int QueryUnsignedAttribute( const char* name, unsigned int* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return NO_ATTRIBUTE; return a->QueryUnsignedValue( value ); }
|
|
|
+ int QueryUnsignedAttribute( const char* name, unsigned int* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryUnsignedValue( value ); }
|
|
|
/// See QueryIntAttribute()
|
|
|
- int QueryBoolAttribute( const char* name, bool* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return NO_ATTRIBUTE; return a->QueryBoolValue( value ); }
|
|
|
+ int QueryBoolAttribute( const char* name, bool* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryBoolValue( value ); }
|
|
|
/// See QueryIntAttribute()
|
|
|
- int QueryDoubleAttribute( const char* name, double* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return NO_ATTRIBUTE; return a->QueryDoubleValue( value ); }
|
|
|
+ int QueryDoubleAttribute( const char* name, double* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryDoubleValue( value ); }
|
|
|
/// See QueryIntAttribute()
|
|
|
- int QueryFloatAttribute( const char* name, float* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return NO_ATTRIBUTE; return a->QueryFloatValue( value ); }
|
|
|
+ int QueryFloatAttribute( const char* name, float* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) return XML_NO_ATTRIBUTE; return a->QueryFloatValue( value ); }
|
|
|
|
|
|
/// Sets the named attribute to value.
|
|
|
void SetAttribute( const char* name, const char* value ) { XMLAttribute* a = FindOrCreateAttribute( name ); a->SetAttribute( value ); }
|
|
|
@@ -1219,7 +1220,7 @@ private:
|
|
|
};
|
|
|
|
|
|
|
|
|
-}; // tinyxml2
|
|
|
+} // tinyxml2
|
|
|
|
|
|
|
|
|
|