Updating tinyxml to 2.6.1 (fixes small xml issues).
This commit is contained in:
+75
-52
@@ -21,7 +21,7 @@ must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
#define TIXML_USE_STL
|
||||
|
||||
|
||||
#ifndef TINYXML_INCLUDED
|
||||
#define TINYXML_INCLUDED
|
||||
@@ -63,17 +63,20 @@ distribution.
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
||||
// Microsoft visual studio, version 2005 and higher.
|
||||
#define TIXML_SNPRINTF _snprintf_s
|
||||
#define TIXML_SNSCANF _snscanf_s
|
||||
#define TIXML_SSCANF sscanf_s
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
|
||||
// Microsoft visual studio, version 6 and higher.
|
||||
//#pragma message( "Using _sn* functions." )
|
||||
#define TIXML_SNPRINTF _snprintf
|
||||
#define TIXML_SNSCANF _snscanf
|
||||
#define TIXML_SSCANF sscanf
|
||||
#elif defined(__GNUC__) && (__GNUC__ >= 3 )
|
||||
// GCC version 3 and higher.s
|
||||
//#warning( "Using sn* functions." )
|
||||
#define TIXML_SNPRINTF snprintf
|
||||
#define TIXML_SNSCANF snscanf
|
||||
#define TIXML_SSCANF sscanf
|
||||
#else
|
||||
#define TIXML_SNPRINTF snprintf
|
||||
#define TIXML_SSCANF sscanf
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -87,8 +90,8 @@ class TiXmlDeclaration;
|
||||
class TiXmlParsingData;
|
||||
|
||||
const int TIXML_MAJOR_VERSION = 2;
|
||||
const int TIXML_MINOR_VERSION = 5;
|
||||
const int TIXML_PATCH_VERSION = 2;
|
||||
const int TIXML_MINOR_VERSION = 6;
|
||||
const int TIXML_PATCH_VERSION = 1;
|
||||
|
||||
/* Internal structure for tracking location of items
|
||||
in the XML file.
|
||||
@@ -104,10 +107,11 @@ struct TiXmlCursor
|
||||
|
||||
|
||||
/**
|
||||
Implements the interface to the "Visitor pattern" (see the Accept() method.)
|
||||
If you call the Accept() method, it requires being passed a TiXmlVisitor
|
||||
class to handle callbacks. For nodes that contain other nodes (Document, Element)
|
||||
you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves
|
||||
are simple called with Visit().
|
||||
are simply called with Visit().
|
||||
|
||||
If you return 'true' from a Visit method, recursive parsing will continue. If you return
|
||||
false, <b>no children of this node or its sibilings</b> will be Visited.
|
||||
@@ -127,23 +131,23 @@ public:
|
||||
virtual ~TiXmlVisitor() {}
|
||||
|
||||
/// Visit a document.
|
||||
virtual bool VisitEnter( const TiXmlDocument& doc ) { return true; }
|
||||
virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; }
|
||||
/// Visit a document.
|
||||
virtual bool VisitExit( const TiXmlDocument& doc ) { return true; }
|
||||
virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; }
|
||||
|
||||
/// Visit an element.
|
||||
virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) { return true; }
|
||||
virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; }
|
||||
/// Visit an element.
|
||||
virtual bool VisitExit( const TiXmlElement& element ) { return true; }
|
||||
virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; }
|
||||
|
||||
/// Visit a declaration
|
||||
virtual bool Visit( const TiXmlDeclaration& declaration ) { return true; }
|
||||
virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; }
|
||||
/// Visit a text node
|
||||
virtual bool Visit( const TiXmlText& text ) { return true; }
|
||||
virtual bool Visit( const TiXmlText& /*text*/ ) { return true; }
|
||||
/// Visit a comment node
|
||||
virtual bool Visit( const TiXmlComment& comment ) { return true; }
|
||||
virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; }
|
||||
/// 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
|
||||
@@ -252,12 +256,16 @@ public:
|
||||
TiXmlParsingData* data,
|
||||
TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
|
||||
|
||||
/** Expands entities in a string. Note this should not contian the tag's '<', '>', etc,
|
||||
or they will be transformed into entities!
|
||||
*/
|
||||
static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
|
||||
|
||||
enum
|
||||
{
|
||||
TIXML_NO_ERROR = 0,
|
||||
TIXML_ERROR,
|
||||
TIXML_ERROR_OPENING_FILE,
|
||||
TIXML_ERROR_OUT_OF_MEMORY,
|
||||
TIXML_ERROR_PARSING_ELEMENT,
|
||||
TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
|
||||
TIXML_ERROR_READING_ELEMENT_VALUE,
|
||||
@@ -278,6 +286,7 @@ public:
|
||||
protected:
|
||||
|
||||
static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
|
||||
|
||||
inline static bool IsWhiteSpace( char c )
|
||||
{
|
||||
return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
|
||||
@@ -351,10 +360,6 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
// Puts a string to a stream, expanding entities as it goes.
|
||||
// Note this should not contian the '<', '>', etc, or they will be transformed 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 endTag sequences.
|
||||
// Ignore case only works for english, and should only be relied on when comparing
|
||||
// to English words: StringEqual( p, "version", true ) is fine.
|
||||
@@ -456,13 +461,13 @@ public:
|
||||
*/
|
||||
enum NodeType
|
||||
{
|
||||
DOCUMENT,
|
||||
ELEMENT,
|
||||
COMMENT,
|
||||
UNKNOWN,
|
||||
TEXT,
|
||||
DECLARATION,
|
||||
TYPECOUNT
|
||||
TINYXML_DOCUMENT,
|
||||
TINYXML_ELEMENT,
|
||||
TINYXML_COMMENT,
|
||||
TINYXML_UNKNOWN,
|
||||
TINYXML_TEXT,
|
||||
TINYXML_DECLARATION,
|
||||
TINYXML_TYPECOUNT
|
||||
};
|
||||
|
||||
virtual ~TiXmlNode();
|
||||
@@ -489,6 +494,8 @@ public:
|
||||
const std::string& ValueStr() const { return value; }
|
||||
#endif
|
||||
|
||||
const TIXML_STRING& ValueTStr() const { return value; }
|
||||
|
||||
/** Changes the value of the node. Defined as:
|
||||
@verbatim
|
||||
Document: filename of the xml file
|
||||
@@ -512,8 +519,8 @@ public:
|
||||
TiXmlNode* Parent() { return parent; }
|
||||
const TiXmlNode* Parent() const { return parent; }
|
||||
|
||||
const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children.
|
||||
TiXmlNode* FirstChild() { return firstChild; }
|
||||
const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children.
|
||||
TiXmlNode* FirstChild() { return firstChild; }
|
||||
const TiXmlNode* FirstChild( const char * value ) const; ///< 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 ) {
|
||||
@@ -907,17 +914,14 @@ public:
|
||||
const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
|
||||
TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
|
||||
|
||||
const TiXmlAttribute* Find( const char* _name ) const;
|
||||
TiXmlAttribute* Find( const char* _name ) {
|
||||
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
|
||||
}
|
||||
#ifdef TIXML_USE_STL
|
||||
const TiXmlAttribute* Find( const std::string& _name ) const;
|
||||
TiXmlAttribute* Find( const std::string& _name ) {
|
||||
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
|
||||
}
|
||||
TiXmlAttribute* Find( const char* _name ) const;
|
||||
TiXmlAttribute* FindOrCreate( const char* _name );
|
||||
|
||||
# ifdef TIXML_USE_STL
|
||||
TiXmlAttribute* Find( const std::string& _name ) const;
|
||||
TiXmlAttribute* FindOrCreate( const std::string& _name );
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
//*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
|
||||
@@ -990,10 +994,23 @@ public:
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef TIXML_USE_STL
|
||||
/// QueryStringAttribute examines the attribute - see QueryIntAttribute().
|
||||
int QueryStringAttribute( const char* name, std::string* _value ) const {
|
||||
const char* cstr = Attribute( name );
|
||||
if ( cstr ) {
|
||||
*_value = std::string( cstr );
|
||||
return TIXML_SUCCESS;
|
||||
}
|
||||
return TIXML_NO_ATTRIBUTE;
|
||||
}
|
||||
|
||||
/** Template form of the attribute query which will try to read the
|
||||
attribute into the specified type. Very easy, very powerful, but
|
||||
be careful to make sure to call this with the correct type.
|
||||
|
||||
NOTE: This method doesn't work correctly for 'string' types that contain spaces.
|
||||
|
||||
@return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE
|
||||
*/
|
||||
@@ -1009,6 +1026,15 @@ public:
|
||||
return TIXML_SUCCESS;
|
||||
return TIXML_WRONG_TYPE;
|
||||
}
|
||||
|
||||
int QueryValueAttribute( const std::string& name, std::string* outValue ) const
|
||||
{
|
||||
const TiXmlAttribute* node = attributeSet.Find( name );
|
||||
if ( !node )
|
||||
return TIXML_NO_ATTRIBUTE;
|
||||
*outValue = node->ValueStr();
|
||||
return TIXML_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Sets an attribute of name to a given value. The attribute
|
||||
@@ -1027,6 +1053,8 @@ public:
|
||||
void SetAttribute( const std::string& name, const std::string& _value );
|
||||
///< STL std::string form.
|
||||
void SetAttribute( const std::string& name, int _value );
|
||||
///< STL std::string form.
|
||||
void SetDoubleAttribute( const std::string& name, double value );
|
||||
#endif
|
||||
|
||||
/** Sets an attribute of name to a given value. The attribute
|
||||
@@ -1118,7 +1146,6 @@ protected:
|
||||
const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
|
||||
|
||||
private:
|
||||
|
||||
TiXmlAttributeSet attributeSet;
|
||||
};
|
||||
|
||||
@@ -1129,9 +1156,9 @@ class TiXmlComment : public TiXmlNode
|
||||
{
|
||||
public:
|
||||
/// Constructs an empty comment.
|
||||
TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
|
||||
TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {}
|
||||
/// Construct a comment from text.
|
||||
TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) {
|
||||
TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {
|
||||
SetValue( _value );
|
||||
}
|
||||
TiXmlComment( const TiXmlComment& );
|
||||
@@ -1183,7 +1210,7 @@ public:
|
||||
normal, encoded text. If you want it be output as a CDATA text
|
||||
element, set the parameter _cdata to 'true'
|
||||
*/
|
||||
TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT)
|
||||
TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
|
||||
{
|
||||
SetValue( initValue );
|
||||
cdata = false;
|
||||
@@ -1192,14 +1219,14 @@ public:
|
||||
|
||||
#ifdef TIXML_USE_STL
|
||||
/// Constructor.
|
||||
TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
|
||||
TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT)
|
||||
{
|
||||
SetValue( initValue );
|
||||
cdata = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); }
|
||||
TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); }
|
||||
void operator=( const TiXmlText& base ) { base.CopyTo( this ); }
|
||||
|
||||
// Write this text object to a FILE stream.
|
||||
@@ -1252,7 +1279,7 @@ class TiXmlDeclaration : public TiXmlNode
|
||||
{
|
||||
public:
|
||||
/// Construct an empty declaration.
|
||||
TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {}
|
||||
TiXmlDeclaration() : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) {}
|
||||
|
||||
#ifdef TIXML_USE_STL
|
||||
/// Constructor.
|
||||
@@ -1320,10 +1347,10 @@ private:
|
||||
class TiXmlUnknown : public TiXmlNode
|
||||
{
|
||||
public:
|
||||
TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {}
|
||||
TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {}
|
||||
virtual ~TiXmlUnknown() {}
|
||||
|
||||
TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); }
|
||||
TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); }
|
||||
void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
|
||||
|
||||
/// Creates a copy of this Unknown and returns it.
|
||||
@@ -1397,14 +1424,10 @@ public:
|
||||
#ifdef TIXML_USE_STL
|
||||
bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version.
|
||||
{
|
||||
// StringToBuffer f( filename );
|
||||
// return ( f.buffer && LoadFile( f.buffer, encoding ));
|
||||
return LoadFile( filename.c_str(), encoding );
|
||||
}
|
||||
bool SaveFile( const std::string& filename ) const ///< STL std::string version.
|
||||
{
|
||||
// StringToBuffer f( filename );
|
||||
// return ( f.buffer && SaveFile( f.buffer ));
|
||||
return SaveFile( filename.c_str() );
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user