mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-29 03:33:48 +00:00
Merge branch 'experimental' into controllerfixup
This commit is contained in:
commit
daca65d20a
4 changed files with 938 additions and 507 deletions
|
@ -43,6 +43,7 @@ notifications:
|
|||
- "irc.esper.net#bitblot"
|
||||
skip_join: true
|
||||
use_notice: true
|
||||
on_success: change
|
||||
template:
|
||||
#- "[%{commit}: %{author}] %{message}"
|
||||
#- "%{build_url}"
|
||||
|
|
|
@ -9611,7 +9611,7 @@ luaFunc(loadXMLTable)
|
|||
|
||||
tinyxml2::XMLDocument xml;
|
||||
tinyxml2::XMLError err = readXML(fn, xml);
|
||||
if(err != tinyxml2::XML_NO_ERROR)
|
||||
if(err != tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
lua_pushboolean(L, false);
|
||||
lua_pushinteger(L, err);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -14,7 +14,6 @@ not claim that you wrote the original software. If you use this
|
|||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
|
@ -25,21 +24,23 @@ distribution.
|
|||
#ifndef TINYXML2_INCLUDED
|
||||
#define TINYXML2_INCLUDED
|
||||
|
||||
#if defined(ANDROID_NDK) || defined(__BORLANDC__)
|
||||
#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
|
||||
# include <ctype.h>
|
||||
# include <limits.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <stdarg.h>
|
||||
# if defined(__PS3__)
|
||||
# include <stddef.h>
|
||||
# endif
|
||||
#else
|
||||
# include <cctype>
|
||||
# include <climits>
|
||||
# include <cstdio>
|
||||
# include <cstdlib>
|
||||
# include <cstring>
|
||||
# include <cstdarg>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
TODO: intern strings instead of allocation.
|
||||
|
@ -78,7 +79,8 @@ distribution.
|
|||
|
||||
#if defined(DEBUG)
|
||||
# if defined(_MSC_VER)
|
||||
# define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
|
||||
# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
|
||||
# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); }
|
||||
# elif defined (ANDROID_NDK)
|
||||
# include <android/log.h>
|
||||
# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
|
||||
|
@ -91,37 +93,12 @@ distribution.
|
|||
#endif
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
||||
// Microsoft visual studio, version 2005 and higher.
|
||||
/*int _snprintf_s(
|
||||
char *buffer,
|
||||
size_t sizeOfBuffer,
|
||||
size_t count,
|
||||
const char *format [,
|
||||
argument] ...
|
||||
);*/
|
||||
inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
|
||||
{
|
||||
va_list va;
|
||||
va_start( va, format );
|
||||
int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
|
||||
va_end( va );
|
||||
return result;
|
||||
}
|
||||
#define TIXML_SSCANF sscanf_s
|
||||
#else
|
||||
// GCC version 3 and higher
|
||||
//#warning( "Using sn* functions." )
|
||||
#define TIXML_SNPRINTF snprintf
|
||||
#define TIXML_SSCANF sscanf
|
||||
#endif
|
||||
|
||||
/* Versioning, past 1.0.14:
|
||||
http://semver.org/
|
||||
*/
|
||||
static const int TIXML2_MAJOR_VERSION = 2;
|
||||
static const int TIXML2_MINOR_VERSION = 1;
|
||||
static const int TIXML2_PATCH_VERSION = 0;
|
||||
static const int TIXML2_MAJOR_VERSION = 4;
|
||||
static const int TIXML2_MINOR_VERSION = 0;
|
||||
static const int TIXML2_PATCH_VERSION = 1;
|
||||
|
||||
namespace tinyxml2
|
||||
{
|
||||
|
@ -146,7 +123,7 @@ public:
|
|||
enum {
|
||||
NEEDS_ENTITY_PROCESSING = 0x01,
|
||||
NEEDS_NEWLINE_NORMALIZATION = 0x02,
|
||||
COLLAPSE_WHITESPACE = 0x04,
|
||||
NEEDS_WHITESPACE_COLLAPSING = 0x04,
|
||||
|
||||
TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
|
||||
TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
|
||||
|
@ -182,6 +159,8 @@ public:
|
|||
char* ParseText( char* in, const char* endTag, int strFlags );
|
||||
char* ParseName( char* in );
|
||||
|
||||
void TransferTo( StrPair* other );
|
||||
|
||||
private:
|
||||
void Reset();
|
||||
void CollapseWhitespace();
|
||||
|
@ -191,10 +170,12 @@ private:
|
|||
NEEDS_DELETE = 0x200
|
||||
};
|
||||
|
||||
// After parsing, if *_end != 0, it can be set to zero.
|
||||
int _flags;
|
||||
char* _start;
|
||||
char* _end;
|
||||
|
||||
StrPair( const StrPair& other ); // not supported
|
||||
void operator=( StrPair& other ); // not supported, use TransferTo()
|
||||
};
|
||||
|
||||
|
||||
|
@ -203,13 +184,13 @@ private:
|
|||
Has a small initial memory pool, so that low or no usage will not
|
||||
cause a call to new/delete
|
||||
*/
|
||||
template <class T, int INIT>
|
||||
template <class T, int INITIAL_SIZE>
|
||||
class DynArray
|
||||
{
|
||||
public:
|
||||
DynArray< T, INIT >() {
|
||||
DynArray() {
|
||||
_mem = _pool;
|
||||
_allocated = INIT;
|
||||
_allocated = INITIAL_SIZE;
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
|
@ -224,11 +205,14 @@ public:
|
|||
}
|
||||
|
||||
void Push( T t ) {
|
||||
TIXMLASSERT( _size < INT_MAX );
|
||||
EnsureCapacity( _size+1 );
|
||||
_mem[_size++] = t;
|
||||
}
|
||||
|
||||
T* PushArr( int count ) {
|
||||
TIXMLASSERT( count >= 0 );
|
||||
TIXMLASSERT( _size <= INT_MAX - count );
|
||||
EnsureCapacity( _size+count );
|
||||
T* ret = &_mem[_size];
|
||||
_size += count;
|
||||
|
@ -236,6 +220,7 @@ public:
|
|||
}
|
||||
|
||||
T Pop() {
|
||||
TIXMLASSERT( _size > 0 );
|
||||
return _mem[--_size];
|
||||
}
|
||||
|
||||
|
@ -264,24 +249,33 @@ public:
|
|||
}
|
||||
|
||||
int Size() const {
|
||||
TIXMLASSERT( _size >= 0 );
|
||||
return _size;
|
||||
}
|
||||
|
||||
int Capacity() const {
|
||||
TIXMLASSERT( _allocated >= INITIAL_SIZE );
|
||||
return _allocated;
|
||||
}
|
||||
|
||||
const T* Mem() const {
|
||||
TIXMLASSERT( _mem );
|
||||
return _mem;
|
||||
}
|
||||
|
||||
T* Mem() {
|
||||
TIXMLASSERT( _mem );
|
||||
return _mem;
|
||||
}
|
||||
|
||||
private:
|
||||
DynArray( const DynArray& ); // not supported
|
||||
void operator=( const DynArray& ); // not supported
|
||||
|
||||
void EnsureCapacity( int cap ) {
|
||||
TIXMLASSERT( cap > 0 );
|
||||
if ( cap > _allocated ) {
|
||||
TIXMLASSERT( cap <= INT_MAX / 2 );
|
||||
int newAllocated = cap * 2;
|
||||
T* newMem = new T[newAllocated];
|
||||
memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
|
||||
|
@ -294,7 +288,7 @@ private:
|
|||
}
|
||||
|
||||
T* _mem;
|
||||
T _pool[INIT];
|
||||
T _pool[INITIAL_SIZE];
|
||||
int _allocated; // objects allocated
|
||||
int _size; // number objects in use
|
||||
};
|
||||
|
@ -314,6 +308,7 @@ public:
|
|||
virtual void* Alloc() = 0;
|
||||
virtual void Free( void* ) = 0;
|
||||
virtual void SetTracked() = 0;
|
||||
virtual void Clear() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -326,10 +321,20 @@ class MemPoolT : public MemPool
|
|||
public:
|
||||
MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
|
||||
~MemPoolT() {
|
||||
// Delete the blocks.
|
||||
for( int i=0; i<_blockPtrs.Size(); ++i ) {
|
||||
delete _blockPtrs[i];
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Clear() {
|
||||
// Delete the blocks.
|
||||
while( !_blockPtrs.Empty()) {
|
||||
Block* b = _blockPtrs.Pop();
|
||||
delete b;
|
||||
}
|
||||
_root = 0;
|
||||
_currentAllocs = 0;
|
||||
_nAllocs = 0;
|
||||
_maxAllocs = 0;
|
||||
_nUntracked = 0;
|
||||
}
|
||||
|
||||
virtual int ItemSize() const {
|
||||
|
@ -362,12 +367,13 @@ public:
|
|||
_nUntracked++;
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual void Free( void* mem ) {
|
||||
if ( !mem ) {
|
||||
return;
|
||||
}
|
||||
--_currentAllocs;
|
||||
Chunk* chunk = (Chunk*)mem;
|
||||
Chunk* chunk = static_cast<Chunk*>( mem );
|
||||
#ifdef DEBUG
|
||||
memset( chunk, 0xfe, sizeof(Chunk) );
|
||||
#endif
|
||||
|
@ -399,6 +405,9 @@ public:
|
|||
enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
|
||||
|
||||
private:
|
||||
MemPoolT( const MemPoolT& ); // not supported
|
||||
void operator=( const MemPoolT& ); // not supported
|
||||
|
||||
union Chunk {
|
||||
Chunk* next;
|
||||
char mem[SIZE];
|
||||
|
@ -477,6 +486,32 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// WARNING: must match XMLDocument::_errorNames[]
|
||||
enum XMLError {
|
||||
XML_SUCCESS = 0,
|
||||
XML_NO_ATTRIBUTE,
|
||||
XML_WRONG_ATTRIBUTE_TYPE,
|
||||
XML_ERROR_FILE_NOT_FOUND,
|
||||
XML_ERROR_FILE_COULD_NOT_BE_OPENED,
|
||||
XML_ERROR_FILE_READ_ERROR,
|
||||
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,
|
||||
XML_CAN_NOT_CONVERT_TEXT,
|
||||
XML_NO_TEXT_NODE,
|
||||
|
||||
XML_ERROR_COUNT
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Utility functionality.
|
||||
|
@ -484,28 +519,33 @@ public:
|
|||
class XMLUtil
|
||||
{
|
||||
public:
|
||||
// Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
|
||||
// correct, but simple, and usually works.
|
||||
static const char* SkipWhiteSpace( const char* p ) {
|
||||
while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<const unsigned char*>(p) ) ) {
|
||||
TIXMLASSERT( p );
|
||||
while( IsWhiteSpace(*p) ) {
|
||||
++p;
|
||||
}
|
||||
TIXMLASSERT( p );
|
||||
return p;
|
||||
}
|
||||
static char* SkipWhiteSpace( char* p ) {
|
||||
while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<unsigned char*>(p) ) ) {
|
||||
++p;
|
||||
}
|
||||
return p;
|
||||
return const_cast<char*>( SkipWhiteSpace( const_cast<const char*>(p) ) );
|
||||
}
|
||||
|
||||
// Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
|
||||
// correct, but simple, and usually works.
|
||||
static bool IsWhiteSpace( char p ) {
|
||||
return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
|
||||
}
|
||||
|
||||
inline static bool IsNameStartChar( unsigned char ch ) {
|
||||
return ( ( ch < 128 ) ? isalpha( ch ) : 1 )
|
||||
|| ch == ':'
|
||||
|| ch == '_';
|
||||
if ( ch >= 128 ) {
|
||||
// This is a heuristic guess in attempt to not implement Unicode-aware isalpha()
|
||||
return true;
|
||||
}
|
||||
if ( isalpha( ch ) ) {
|
||||
return true;
|
||||
}
|
||||
return ch == ':' || ch == '_';
|
||||
}
|
||||
|
||||
inline static bool IsNameChar( unsigned char ch ) {
|
||||
|
@ -516,23 +556,14 @@ public:
|
|||
}
|
||||
|
||||
inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
|
||||
int n = 0;
|
||||
if ( p == q ) {
|
||||
return true;
|
||||
}
|
||||
while( *p && *q && *p == *q && n<nChar ) {
|
||||
++p;
|
||||
++q;
|
||||
++n;
|
||||
}
|
||||
if ( (n == nChar) || ( *p == 0 && *q == 0 ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return strncmp( p, q, nChar ) == 0;
|
||||
}
|
||||
|
||||
inline static int IsUTF8Continuation( const char p ) {
|
||||
return p & 0x80;
|
||||
inline static bool IsUTF8Continuation( char p ) {
|
||||
return ( p & 0x80 ) != 0;
|
||||
}
|
||||
|
||||
static const char* ReadBOM( const char* p, bool* hasBOM );
|
||||
|
@ -547,6 +578,7 @@ public:
|
|||
static void ToStr( bool v, char* buffer, int bufferSize );
|
||||
static void ToStr( float v, char* buffer, int bufferSize );
|
||||
static void ToStr( double v, char* buffer, int bufferSize );
|
||||
static void ToStr(int64_t v, char* buffer, int bufferSize);
|
||||
|
||||
// converts strings to primitive types
|
||||
static bool ToInt( const char* str, int* value );
|
||||
|
@ -554,6 +586,7 @@ public:
|
|||
static bool ToBool( const char* str, bool* value );
|
||||
static bool ToFloat( const char* str, float* value );
|
||||
static bool ToDouble( const char* str, double* value );
|
||||
static bool ToInt64(const char* str, int64_t* value);
|
||||
};
|
||||
|
||||
|
||||
|
@ -590,10 +623,12 @@ public:
|
|||
|
||||
/// Get the XMLDocument that owns this XMLNode.
|
||||
const XMLDocument* GetDocument() const {
|
||||
TIXMLASSERT( _document );
|
||||
return _document;
|
||||
}
|
||||
/// Get the XMLDocument that owns this XMLNode.
|
||||
XMLDocument* GetDocument() {
|
||||
TIXMLASSERT( _document );
|
||||
return _document;
|
||||
}
|
||||
|
||||
|
@ -643,7 +678,7 @@ public:
|
|||
|
||||
/** The meaning of 'value' changes for the specific type.
|
||||
@verbatim
|
||||
Document: empty
|
||||
Document: empty (NULL is returned, not an empty string)
|
||||
Element: name of the element
|
||||
Comment: the comment text
|
||||
Unknown: the tag contents
|
||||
|
@ -683,10 +718,10 @@ public:
|
|||
/** Get the first child element, or optionally the first child
|
||||
element with the specified name.
|
||||
*/
|
||||
const XMLElement* FirstChildElement( const char* value=0 ) const;
|
||||
const XMLElement* FirstChildElement( const char* name = 0 ) const;
|
||||
|
||||
XMLElement* FirstChildElement( const char* value=0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( value ));
|
||||
XMLElement* FirstChildElement( const char* name = 0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( name ));
|
||||
}
|
||||
|
||||
/// Get the last child node, or null if none exists.
|
||||
|
@ -695,16 +730,16 @@ public:
|
|||
}
|
||||
|
||||
XMLNode* LastChild() {
|
||||
return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild() );
|
||||
return _lastChild;
|
||||
}
|
||||
|
||||
/** Get the last child element or optionally the last child
|
||||
element with the specified name.
|
||||
*/
|
||||
const XMLElement* LastChildElement( const char* value=0 ) const;
|
||||
const XMLElement* LastChildElement( const char* name = 0 ) const;
|
||||
|
||||
XMLElement* LastChildElement( const char* value=0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(value) );
|
||||
XMLElement* LastChildElement( const char* name = 0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(name) );
|
||||
}
|
||||
|
||||
/// Get the previous (left) sibling node of this node.
|
||||
|
@ -717,10 +752,10 @@ public:
|
|||
}
|
||||
|
||||
/// Get the previous (left) sibling element of this node, with an optionally supplied name.
|
||||
const XMLElement* PreviousSiblingElement( const char* value=0 ) const ;
|
||||
const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ;
|
||||
|
||||
XMLElement* PreviousSiblingElement( const char* value=0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( value ) );
|
||||
XMLElement* PreviousSiblingElement( const char* name = 0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( name ) );
|
||||
}
|
||||
|
||||
/// Get the next (right) sibling node of this node.
|
||||
|
@ -733,10 +768,10 @@ public:
|
|||
}
|
||||
|
||||
/// Get the next (right) sibling element of this node, with an optionally supplied name.
|
||||
const XMLElement* NextSiblingElement( const char* value=0 ) const;
|
||||
const XMLElement* NextSiblingElement( const char* name = 0 ) const;
|
||||
|
||||
XMLElement* NextSiblingElement( const char* value=0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( value ) );
|
||||
XMLElement* NextSiblingElement( const char* name = 0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( name ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -822,14 +857,25 @@ public:
|
|||
*/
|
||||
virtual bool Accept( XMLVisitor* visitor ) const = 0;
|
||||
|
||||
// internal
|
||||
virtual char* ParseDeep( char*, StrPair* );
|
||||
/**
|
||||
Set user data into the XMLNode. TinyXML-2 in
|
||||
no way processes or interprets user data.
|
||||
It is initially 0.
|
||||
*/
|
||||
void SetUserData(void* userData) { _userData = userData; }
|
||||
|
||||
/**
|
||||
Get user data set into the XMLNode. TinyXML-2 in
|
||||
no way processes or interprets user data.
|
||||
It is initially 0.
|
||||
*/
|
||||
void* GetUserData() const { return _userData; }
|
||||
|
||||
protected:
|
||||
XMLNode( XMLDocument* );
|
||||
virtual ~XMLNode();
|
||||
XMLNode( const XMLNode& ); // not supported
|
||||
XMLNode& operator=( const XMLNode& ); // not supported
|
||||
|
||||
virtual char* ParseDeep( char*, StrPair* );
|
||||
|
||||
XMLDocument* _document;
|
||||
XMLNode* _parent;
|
||||
|
@ -841,9 +887,16 @@ protected:
|
|||
XMLNode* _prev;
|
||||
XMLNode* _next;
|
||||
|
||||
void* _userData;
|
||||
|
||||
private:
|
||||
MemPool* _memPool;
|
||||
void Unlink( XMLNode* child );
|
||||
static void DeleteNode( XMLNode* node );
|
||||
void InsertChildPreamble( XMLNode* insertThis ) const;
|
||||
|
||||
XMLNode( const XMLNode& ); // not supported
|
||||
XMLNode& operator=( const XMLNode& ); // not supported
|
||||
};
|
||||
|
||||
|
||||
|
@ -861,7 +914,6 @@ private:
|
|||
*/
|
||||
class TINYXML2_LIB XMLText : public XMLNode
|
||||
{
|
||||
friend class XMLBase;
|
||||
friend class XMLDocument;
|
||||
public:
|
||||
virtual bool Accept( XMLVisitor* visitor ) const;
|
||||
|
@ -882,18 +934,20 @@ public:
|
|||
return _isCData;
|
||||
}
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
virtual XMLNode* ShallowClone( XMLDocument* document ) const;
|
||||
virtual bool ShallowEqual( const XMLNode* compare ) const;
|
||||
|
||||
protected:
|
||||
XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
|
||||
virtual ~XMLText() {}
|
||||
XMLText( const XMLText& ); // not supported
|
||||
XMLText& operator=( const XMLText& ); // not supported
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
|
||||
private:
|
||||
bool _isCData;
|
||||
|
||||
XMLText( const XMLText& ); // not supported
|
||||
XMLText& operator=( const XMLText& ); // not supported
|
||||
};
|
||||
|
||||
|
||||
|
@ -911,17 +965,18 @@ public:
|
|||
|
||||
virtual bool Accept( XMLVisitor* visitor ) const;
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
virtual XMLNode* ShallowClone( XMLDocument* document ) const;
|
||||
virtual bool ShallowEqual( const XMLNode* compare ) const;
|
||||
|
||||
protected:
|
||||
XMLComment( XMLDocument* doc );
|
||||
virtual ~XMLComment();
|
||||
XMLComment( const XMLComment& ); // not supported
|
||||
XMLComment& operator=( const XMLComment& ); // not supported
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
|
||||
private:
|
||||
XMLComment( const XMLComment& ); // not supported
|
||||
XMLComment& operator=( const XMLComment& ); // not supported
|
||||
};
|
||||
|
||||
|
||||
|
@ -949,13 +1004,16 @@ public:
|
|||
|
||||
virtual bool Accept( XMLVisitor* visitor ) const;
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
virtual XMLNode* ShallowClone( XMLDocument* document ) const;
|
||||
virtual bool ShallowEqual( const XMLNode* compare ) const;
|
||||
|
||||
protected:
|
||||
XMLDeclaration( XMLDocument* doc );
|
||||
virtual ~XMLDeclaration();
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
|
||||
private:
|
||||
XMLDeclaration( const XMLDeclaration& ); // not supported
|
||||
XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
|
||||
};
|
||||
|
@ -981,45 +1039,21 @@ public:
|
|||
|
||||
virtual bool Accept( XMLVisitor* visitor ) const;
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
virtual XMLNode* ShallowClone( XMLDocument* document ) const;
|
||||
virtual bool ShallowEqual( const XMLNode* compare ) const;
|
||||
|
||||
protected:
|
||||
XMLUnknown( XMLDocument* doc );
|
||||
virtual ~XMLUnknown();
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
|
||||
private:
|
||||
XMLUnknown( const XMLUnknown& ); // not supported
|
||||
XMLUnknown& operator=( const XMLUnknown& ); // not supported
|
||||
};
|
||||
|
||||
|
||||
enum XMLError {
|
||||
XML_NO_ERROR = 0,
|
||||
XML_SUCCESS = 0,
|
||||
|
||||
XML_NO_ATTRIBUTE,
|
||||
XML_WRONG_ATTRIBUTE_TYPE,
|
||||
|
||||
XML_ERROR_FILE_NOT_FOUND,
|
||||
XML_ERROR_FILE_COULD_NOT_BE_OPENED,
|
||||
XML_ERROR_FILE_READ_ERROR,
|
||||
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,
|
||||
|
||||
XML_CAN_NOT_CONVERT_TEXT,
|
||||
XML_NO_TEXT_NODE
|
||||
};
|
||||
|
||||
|
||||
/** An attribute is a name-value pair. Elements have an arbitrary
|
||||
number of attributes, each with a unique name.
|
||||
|
@ -1051,6 +1085,13 @@ public:
|
|||
QueryIntValue(&i);
|
||||
return i;
|
||||
}
|
||||
|
||||
int64_t Int64Value() const {
|
||||
int64_t i = 0;
|
||||
QueryInt64Value(&i);
|
||||
return i;
|
||||
}
|
||||
|
||||
/// Query as an unsigned integer. See IntValue()
|
||||
unsigned UnsignedValue() const {
|
||||
unsigned i=0;
|
||||
|
@ -1084,6 +1125,8 @@ public:
|
|||
/// See QueryIntValue
|
||||
XMLError QueryUnsignedValue( unsigned int* value ) const;
|
||||
/// See QueryIntValue
|
||||
XMLError QueryInt64Value(int64_t* value) const;
|
||||
/// See QueryIntValue
|
||||
XMLError QueryBoolValue( bool* value ) const;
|
||||
/// See QueryIntValue
|
||||
XMLError QueryDoubleValue( double* value ) const;
|
||||
|
@ -1097,6 +1140,8 @@ public:
|
|||
/// Set the attribute to value.
|
||||
void SetAttribute( unsigned value );
|
||||
/// Set the attribute to value.
|
||||
void SetAttribute(int64_t value);
|
||||
/// Set the attribute to value.
|
||||
void SetAttribute( bool value );
|
||||
/// Set the attribute to value.
|
||||
void SetAttribute( double value );
|
||||
|
@ -1128,7 +1173,6 @@ private:
|
|||
*/
|
||||
class TINYXML2_LIB XMLElement : public XMLNode
|
||||
{
|
||||
friend class XMLBase;
|
||||
friend class XMLDocument;
|
||||
public:
|
||||
/// Get the name of an element (which is the Value() of the node.)
|
||||
|
@ -1183,12 +1227,21 @@ public:
|
|||
QueryIntAttribute( name, &i );
|
||||
return i;
|
||||
}
|
||||
|
||||
/// See IntAttribute()
|
||||
unsigned UnsignedAttribute( const char* name ) const {
|
||||
unsigned i=0;
|
||||
QueryUnsignedAttribute( name, &i );
|
||||
return i;
|
||||
}
|
||||
|
||||
/// See IntAttribute()
|
||||
int64_t Int64Attribute(const char* name) const {
|
||||
int64_t i = 0;
|
||||
QueryInt64Attribute(name, &i);
|
||||
return i;
|
||||
}
|
||||
|
||||
/// See IntAttribute()
|
||||
bool BoolAttribute( const char* name ) const {
|
||||
bool b=false;
|
||||
|
@ -1228,6 +1281,7 @@ public:
|
|||
}
|
||||
return a->QueryIntValue( value );
|
||||
}
|
||||
|
||||
/// See QueryIntAttribute()
|
||||
XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const {
|
||||
const XMLAttribute* a = FindAttribute( name );
|
||||
|
@ -1236,6 +1290,16 @@ public:
|
|||
}
|
||||
return a->QueryUnsignedValue( value );
|
||||
}
|
||||
|
||||
/// See QueryIntAttribute()
|
||||
XMLError QueryInt64Attribute(const char* name, int64_t* value) const {
|
||||
const XMLAttribute* a = FindAttribute(name);
|
||||
if (!a) {
|
||||
return XML_NO_ATTRIBUTE;
|
||||
}
|
||||
return a->QueryInt64Value(value);
|
||||
}
|
||||
|
||||
/// See QueryIntAttribute()
|
||||
XMLError QueryBoolAttribute( const char* name, bool* value ) const {
|
||||
const XMLAttribute* a = FindAttribute( name );
|
||||
|
@ -1287,6 +1351,10 @@ public:
|
|||
return QueryUnsignedAttribute( name, value );
|
||||
}
|
||||
|
||||
int QueryAttribute(const char* name, int64_t* value) const {
|
||||
return QueryInt64Attribute(name, value);
|
||||
}
|
||||
|
||||
int QueryAttribute( const char* name, bool* value ) const {
|
||||
return QueryBoolAttribute( name, value );
|
||||
}
|
||||
|
@ -1314,6 +1382,13 @@ public:
|
|||
XMLAttribute* a = FindOrCreateAttribute( name );
|
||||
a->SetAttribute( value );
|
||||
}
|
||||
|
||||
/// Sets the named attribute to value.
|
||||
void SetAttribute(const char* name, int64_t value) {
|
||||
XMLAttribute* a = FindOrCreateAttribute(name);
|
||||
a->SetAttribute(value);
|
||||
}
|
||||
|
||||
/// Sets the named attribute to value.
|
||||
void SetAttribute( const char* name, bool value ) {
|
||||
XMLAttribute* a = FindOrCreateAttribute( name );
|
||||
|
@ -1407,15 +1482,17 @@ public:
|
|||
@endverbatim
|
||||
*/
|
||||
void SetText( const char* inText );
|
||||
/// Convenience method for setting text inside and element. See SetText() for important limitations.
|
||||
/// Convenience method for setting text inside an element. See SetText() for important limitations.
|
||||
void SetText( int value );
|
||||
/// Convenience method for setting text inside and element. See SetText() for important limitations.
|
||||
/// Convenience method for setting text inside an element. See SetText() for important limitations.
|
||||
void SetText( unsigned value );
|
||||
/// Convenience method for setting text inside and element. See SetText() for important limitations.
|
||||
/// Convenience method for setting text inside an element. See SetText() for important limitations.
|
||||
void SetText(int64_t value);
|
||||
/// Convenience method for setting text inside an element. See SetText() for important limitations.
|
||||
void SetText( bool value );
|
||||
/// Convenience method for setting text inside and element. See SetText() for important limitations.
|
||||
/// Convenience method for setting text inside an element. See SetText() for important limitations.
|
||||
void SetText( double value );
|
||||
/// Convenience method for setting text inside and element. See SetText() for important limitations.
|
||||
/// Convenience method for setting text inside an element. See SetText() for important limitations.
|
||||
void SetText( float value );
|
||||
|
||||
/**
|
||||
|
@ -1448,6 +1525,8 @@ public:
|
|||
/// See QueryIntText()
|
||||
XMLError QueryUnsignedText( unsigned* uval ) const;
|
||||
/// See QueryIntText()
|
||||
XMLError QueryInt64Text(int64_t* uval) const;
|
||||
/// See QueryIntText()
|
||||
XMLError QueryBoolText( bool* bval ) const;
|
||||
/// See QueryIntText()
|
||||
XMLError QueryDoubleText( double* dval ) const;
|
||||
|
@ -1463,20 +1542,25 @@ public:
|
|||
int ClosingType() const {
|
||||
return _closingType;
|
||||
}
|
||||
char* ParseDeep( char* p, StrPair* endTag );
|
||||
virtual XMLNode* ShallowClone( XMLDocument* document ) const;
|
||||
virtual bool ShallowEqual( const XMLNode* compare ) const;
|
||||
|
||||
protected:
|
||||
char* ParseDeep( char* p, StrPair* endTag );
|
||||
|
||||
private:
|
||||
XMLElement( XMLDocument* doc );
|
||||
virtual ~XMLElement();
|
||||
XMLElement( const XMLElement& ); // not supported
|
||||
void operator=( const XMLElement& ); // not supported
|
||||
|
||||
XMLAttribute* FindAttribute( const char* name );
|
||||
XMLAttribute* FindAttribute( const char* name ) {
|
||||
return const_cast<XMLAttribute*>(const_cast<const XMLElement*>(this)->FindAttribute( name ));
|
||||
}
|
||||
XMLAttribute* FindOrCreateAttribute( const char* name );
|
||||
//void LinkAttribute( XMLAttribute* attrib );
|
||||
char* ParseAttributes( char* p );
|
||||
static void DeleteAttribute( XMLAttribute* attribute );
|
||||
|
||||
enum { BUF_SIZE = 200 };
|
||||
int _closingType;
|
||||
|
@ -1507,9 +1591,11 @@ public:
|
|||
~XMLDocument();
|
||||
|
||||
virtual XMLDocument* ToDocument() {
|
||||
TIXMLASSERT( this == _document );
|
||||
return this;
|
||||
}
|
||||
virtual const XMLDocument* ToDocument() const {
|
||||
TIXMLASSERT( this == _document );
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -1530,16 +1616,20 @@ public:
|
|||
Returns XML_NO_ERROR (0) on success, or
|
||||
an errorID.
|
||||
*/
|
||||
//XMLError LoadFile( const char* filename );
|
||||
XMLError LoadFile( const char* filename );
|
||||
|
||||
/**
|
||||
Load an XML file from disk. You are responsible
|
||||
for providing and closing the FILE*.
|
||||
|
||||
NOTE: The file should be opened as binary ("rb")
|
||||
not text in order for TinyXML-2 to correctly
|
||||
do newline normalization.
|
||||
|
||||
Returns XML_NO_ERROR (0) on success, or
|
||||
an errorID.
|
||||
*/
|
||||
//XMLError LoadFile( FILE* );
|
||||
XMLError LoadFile( FILE* );
|
||||
|
||||
/**
|
||||
Save the XML file to disk.
|
||||
|
@ -1644,20 +1734,20 @@ public:
|
|||
Delete a node associated with this document.
|
||||
It will be unlinked from the DOM.
|
||||
*/
|
||||
void DeleteNode( XMLNode* node ) {
|
||||
node->_parent->DeleteChild( node );
|
||||
}
|
||||
void DeleteNode( XMLNode* node );
|
||||
|
||||
void SetError( XMLError error, const char* str1, const char* str2 );
|
||||
|
||||
/// Return true if there was an error parsing the document.
|
||||
bool Error() const {
|
||||
return _errorID != XML_NO_ERROR;
|
||||
return _errorID != XML_SUCCESS;
|
||||
}
|
||||
/// Return the errorID.
|
||||
XMLError ErrorID() const {
|
||||
return _errorID;
|
||||
}
|
||||
const char* ErrorName() const;
|
||||
|
||||
/// Return a possibly helpful diagnostic location or string.
|
||||
const char* GetErrorStr1() const {
|
||||
return _errorStr1;
|
||||
|
@ -1698,6 +1788,10 @@ private:
|
|||
MemPoolT< sizeof(XMLAttribute) > _attributePool;
|
||||
MemPoolT< sizeof(XMLText) > _textPool;
|
||||
MemPoolT< sizeof(XMLComment) > _commentPool;
|
||||
|
||||
static const char* _errorNames[XML_ERROR_COUNT];
|
||||
|
||||
void Parse();
|
||||
};
|
||||
|
||||
|
||||
|
@ -1741,7 +1835,7 @@ private:
|
|||
|
||||
@verbatim
|
||||
XMLHandle docHandle( &document );
|
||||
XMLElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild().NextSibling().ToElement();
|
||||
XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement();
|
||||
if ( child2 )
|
||||
{
|
||||
// do something useful
|
||||
|
@ -1782,32 +1876,32 @@ public:
|
|||
return XMLHandle( _node ? _node->FirstChild() : 0 );
|
||||
}
|
||||
/// Get the first child element of this handle.
|
||||
XMLHandle FirstChildElement( const char* value=0 ) {
|
||||
return XMLHandle( _node ? _node->FirstChildElement( value ) : 0 );
|
||||
XMLHandle FirstChildElement( const char* name = 0 ) {
|
||||
return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
|
||||
}
|
||||
/// Get the last child of this handle.
|
||||
XMLHandle LastChild() {
|
||||
return XMLHandle( _node ? _node->LastChild() : 0 );
|
||||
}
|
||||
/// Get the last child element of this handle.
|
||||
XMLHandle LastChildElement( const char* _value=0 ) {
|
||||
return XMLHandle( _node ? _node->LastChildElement( _value ) : 0 );
|
||||
XMLHandle LastChildElement( const char* name = 0 ) {
|
||||
return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
|
||||
}
|
||||
/// Get the previous sibling of this handle.
|
||||
XMLHandle PreviousSibling() {
|
||||
return XMLHandle( _node ? _node->PreviousSibling() : 0 );
|
||||
}
|
||||
/// Get the previous sibling element of this handle.
|
||||
XMLHandle PreviousSiblingElement( const char* _value=0 ) {
|
||||
return XMLHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
|
||||
XMLHandle PreviousSiblingElement( const char* name = 0 ) {
|
||||
return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
|
||||
}
|
||||
/// Get the next sibling of this handle.
|
||||
XMLHandle NextSibling() {
|
||||
return XMLHandle( _node ? _node->NextSibling() : 0 );
|
||||
}
|
||||
/// Get the next sibling element of this handle.
|
||||
XMLHandle NextSiblingElement( const char* _value=0 ) {
|
||||
return XMLHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
|
||||
XMLHandle NextSiblingElement( const char* name = 0 ) {
|
||||
return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
|
||||
}
|
||||
|
||||
/// Safe cast to XMLNode. This can return null.
|
||||
|
@ -1816,19 +1910,19 @@ public:
|
|||
}
|
||||
/// Safe cast to XMLElement. This can return null.
|
||||
XMLElement* ToElement() {
|
||||
return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToElement() );
|
||||
}
|
||||
/// Safe cast to XMLText. This can return null.
|
||||
XMLText* ToText() {
|
||||
return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToText() );
|
||||
}
|
||||
/// Safe cast to XMLUnknown. This can return null.
|
||||
XMLUnknown* ToUnknown() {
|
||||
return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
|
||||
}
|
||||
/// Safe cast to XMLDeclaration. This can return null.
|
||||
XMLDeclaration* ToDeclaration() {
|
||||
return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1861,26 +1955,26 @@ public:
|
|||
const XMLConstHandle FirstChild() const {
|
||||
return XMLConstHandle( _node ? _node->FirstChild() : 0 );
|
||||
}
|
||||
const XMLConstHandle FirstChildElement( const char* value=0 ) const {
|
||||
return XMLConstHandle( _node ? _node->FirstChildElement( value ) : 0 );
|
||||
const XMLConstHandle FirstChildElement( const char* name = 0 ) const {
|
||||
return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
|
||||
}
|
||||
const XMLConstHandle LastChild() const {
|
||||
return XMLConstHandle( _node ? _node->LastChild() : 0 );
|
||||
}
|
||||
const XMLConstHandle LastChildElement( const char* _value=0 ) const {
|
||||
return XMLConstHandle( _node ? _node->LastChildElement( _value ) : 0 );
|
||||
const XMLConstHandle LastChildElement( const char* name = 0 ) const {
|
||||
return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
|
||||
}
|
||||
const XMLConstHandle PreviousSibling() const {
|
||||
return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
|
||||
}
|
||||
const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const {
|
||||
return XMLConstHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
|
||||
const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const {
|
||||
return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
|
||||
}
|
||||
const XMLConstHandle NextSibling() const {
|
||||
return XMLConstHandle( _node ? _node->NextSibling() : 0 );
|
||||
}
|
||||
const XMLConstHandle NextSiblingElement( const char* _value=0 ) const {
|
||||
return XMLConstHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
|
||||
const XMLConstHandle NextSiblingElement( const char* name = 0 ) const {
|
||||
return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1888,16 +1982,16 @@ public:
|
|||
return _node;
|
||||
}
|
||||
const XMLElement* ToElement() const {
|
||||
return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToElement() );
|
||||
}
|
||||
const XMLText* ToText() const {
|
||||
return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToText() );
|
||||
}
|
||||
const XMLUnknown* ToUnknown() const {
|
||||
return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
|
||||
}
|
||||
const XMLDeclaration* ToDeclaration() const {
|
||||
return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1969,6 +2063,7 @@ public:
|
|||
void PushAttribute( const char* name, const char* value );
|
||||
void PushAttribute( const char* name, int value );
|
||||
void PushAttribute( const char* name, unsigned value );
|
||||
void PushAttribute(const char* name, int64_t value);
|
||||
void PushAttribute( const char* name, bool value );
|
||||
void PushAttribute( const char* name, double value );
|
||||
/// If streaming, close the Element.
|
||||
|
@ -1980,6 +2075,8 @@ public:
|
|||
void PushText( int value );
|
||||
/// Add a text node from an unsigned.
|
||||
void PushText( unsigned value );
|
||||
/// Add a text node from an unsigned.
|
||||
void PushText(int64_t value);
|
||||
/// Add a text node from a bool.
|
||||
void PushText( bool value );
|
||||
/// Add a text node from a float.
|
||||
|
@ -2039,7 +2136,7 @@ protected:
|
|||
virtual void PrintSpace( int depth );
|
||||
void Print( const char* format, ... );
|
||||
|
||||
void SealElement();
|
||||
void SealElementIfJustOpened();
|
||||
bool _elementJustOpened;
|
||||
DynArray< const char*, 10 > _stack;
|
||||
|
||||
|
@ -2061,9 +2158,6 @@ private:
|
|||
bool _restrictedEntityFlag[ENTITY_RANGE];
|
||||
|
||||
DynArray< char, 20 > _buffer;
|
||||
#ifdef _MSC_VER
|
||||
DynArray< char, 20 > _accumulator;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue