Updated tinyxml
This commit is contained in:
parent
94187c41c2
commit
dd1b5f9a30
|
@ -595,6 +595,10 @@ XMLNode::~XMLNode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* XMLNode::Value() const
|
||||||
|
{
|
||||||
|
return _value.GetStr();
|
||||||
|
}
|
||||||
|
|
||||||
void XMLNode::SetValue( const char* str, bool staticMem )
|
void XMLNode::SetValue( const char* str, bool staticMem )
|
||||||
{
|
{
|
||||||
|
@ -621,7 +625,6 @@ void XMLNode::DeleteChildren()
|
||||||
|
|
||||||
void XMLNode::Unlink( XMLNode* child )
|
void XMLNode::Unlink( XMLNode* child )
|
||||||
{
|
{
|
||||||
TIXMLASSERT( child->_parent == this );
|
|
||||||
if ( child == _firstChild ) {
|
if ( child == _firstChild ) {
|
||||||
_firstChild = _firstChild->_next;
|
_firstChild = _firstChild->_next;
|
||||||
}
|
}
|
||||||
|
@ -635,7 +638,7 @@ void XMLNode::Unlink( XMLNode* child )
|
||||||
if ( child->_next ) {
|
if ( child->_next ) {
|
||||||
child->_next->_prev = child->_prev;
|
child->_next->_prev = child->_prev;
|
||||||
}
|
}
|
||||||
child->_parent = 0;
|
child->_parent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -648,6 +651,14 @@ void XMLNode::DeleteChild( XMLNode* node )
|
||||||
|
|
||||||
XMLNode* XMLNode::InsertEndChild( XMLNode* addThis )
|
XMLNode* XMLNode::InsertEndChild( XMLNode* addThis )
|
||||||
{
|
{
|
||||||
|
if (addThis->_document != _document)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (addThis->_parent)
|
||||||
|
addThis->_parent->Unlink( addThis );
|
||||||
|
else
|
||||||
|
addThis->_memPool->SetTracked();
|
||||||
|
|
||||||
if ( _lastChild ) {
|
if ( _lastChild ) {
|
||||||
TIXMLASSERT( _firstChild );
|
TIXMLASSERT( _firstChild );
|
||||||
TIXMLASSERT( _lastChild->_next == 0 );
|
TIXMLASSERT( _lastChild->_next == 0 );
|
||||||
|
@ -665,13 +676,20 @@ XMLNode* XMLNode::InsertEndChild( XMLNode* addThis )
|
||||||
addThis->_next = 0;
|
addThis->_next = 0;
|
||||||
}
|
}
|
||||||
addThis->_parent = this;
|
addThis->_parent = this;
|
||||||
addThis->_memPool->SetTracked();
|
|
||||||
return addThis;
|
return addThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis )
|
XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis )
|
||||||
{
|
{
|
||||||
|
if (addThis->_document != _document)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (addThis->_parent)
|
||||||
|
addThis->_parent->Unlink( addThis );
|
||||||
|
else
|
||||||
|
addThis->_memPool->SetTracked();
|
||||||
|
|
||||||
if ( _firstChild ) {
|
if ( _firstChild ) {
|
||||||
TIXMLASSERT( _lastChild );
|
TIXMLASSERT( _lastChild );
|
||||||
TIXMLASSERT( _firstChild->_prev == 0 );
|
TIXMLASSERT( _firstChild->_prev == 0 );
|
||||||
|
@ -690,14 +708,17 @@ XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis )
|
||||||
addThis->_next = 0;
|
addThis->_next = 0;
|
||||||
}
|
}
|
||||||
addThis->_parent = this;
|
addThis->_parent = this;
|
||||||
addThis->_memPool->SetTracked();
|
return addThis;
|
||||||
return addThis;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis )
|
XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis )
|
||||||
{
|
{
|
||||||
|
if (addThis->_document != _document)
|
||||||
|
return 0;
|
||||||
|
|
||||||
TIXMLASSERT( afterThis->_parent == this );
|
TIXMLASSERT( afterThis->_parent == this );
|
||||||
|
|
||||||
if ( afterThis->_parent != this ) {
|
if ( afterThis->_parent != this ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -706,12 +727,15 @@ XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis )
|
||||||
// The last node or the only node.
|
// The last node or the only node.
|
||||||
return InsertEndChild( addThis );
|
return InsertEndChild( addThis );
|
||||||
}
|
}
|
||||||
|
if (addThis->_parent)
|
||||||
|
addThis->_parent->Unlink( addThis );
|
||||||
|
else
|
||||||
|
addThis->_memPool->SetTracked();
|
||||||
addThis->_prev = afterThis;
|
addThis->_prev = afterThis;
|
||||||
addThis->_next = afterThis->_next;
|
addThis->_next = afterThis->_next;
|
||||||
afterThis->_next->_prev = addThis;
|
afterThis->_next->_prev = addThis;
|
||||||
afterThis->_next = addThis;
|
afterThis->_next = addThis;
|
||||||
addThis->_parent = this;
|
addThis->_parent = this;
|
||||||
addThis->_memPool->SetTracked();
|
|
||||||
return addThis;
|
return addThis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1040,6 +1064,17 @@ bool XMLUnknown::Accept( XMLVisitor* visitor ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------- XMLAttribute ---------- //
|
// --------- XMLAttribute ---------- //
|
||||||
|
|
||||||
|
const char* XMLAttribute::Name() const
|
||||||
|
{
|
||||||
|
return _name.GetStr();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* XMLAttribute::Value() const
|
||||||
|
{
|
||||||
|
return _value.GetStr();
|
||||||
|
}
|
||||||
|
|
||||||
char* XMLAttribute::ParseDeep( char* p, bool processEntities )
|
char* XMLAttribute::ParseDeep( char* p, bool processEntities )
|
||||||
{
|
{
|
||||||
// Parse using the name rules: bug fix, was using ParseText before
|
// Parse using the name rules: bug fix, was using ParseText before
|
||||||
|
|
|
@ -118,7 +118,7 @@ inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
|
||||||
|
|
||||||
static const int TIXML2_MAJOR_VERSION = 1;
|
static const int TIXML2_MAJOR_VERSION = 1;
|
||||||
static const int TIXML2_MINOR_VERSION = 0;
|
static const int TIXML2_MINOR_VERSION = 0;
|
||||||
static const int TIXML2_PATCH_VERSION = 11;
|
static const int TIXML2_PATCH_VERSION = 12;
|
||||||
|
|
||||||
namespace tinyxml2
|
namespace tinyxml2
|
||||||
{
|
{
|
||||||
|
@ -251,6 +251,11 @@ public:
|
||||||
return _mem[i];
|
return _mem[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const T& PeekTop() const {
|
||||||
|
TIXMLASSERT( _size > 0 );
|
||||||
|
return _mem[ _size - 1];
|
||||||
|
}
|
||||||
|
|
||||||
int Size() const {
|
int Size() const {
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
@ -638,9 +643,7 @@ public:
|
||||||
Text: the text string
|
Text: the text string
|
||||||
@endverbatim
|
@endverbatim
|
||||||
*/
|
*/
|
||||||
const char* Value() const {
|
const char* Value() const;
|
||||||
return _value.GetStr();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set the Value of an XML node.
|
/** Set the Value of an XML node.
|
||||||
@sa Value()
|
@sa Value()
|
||||||
|
@ -731,6 +734,10 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Add a child node as the last (right) child.
|
Add a child node as the last (right) child.
|
||||||
|
If the child node is already part of the document,
|
||||||
|
it is moved from its old location to the new location.
|
||||||
|
Returns the addThis argument or 0 if the node does not
|
||||||
|
belong to the same document.
|
||||||
*/
|
*/
|
||||||
XMLNode* InsertEndChild( XMLNode* addThis );
|
XMLNode* InsertEndChild( XMLNode* addThis );
|
||||||
|
|
||||||
|
@ -739,10 +746,19 @@ public:
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
Add a child node as the first (left) child.
|
Add a child node as the first (left) child.
|
||||||
|
If the child node is already part of the document,
|
||||||
|
it is moved from its old location to the new location.
|
||||||
|
Returns the addThis argument or 0 if the node does not
|
||||||
|
belong to the same document.
|
||||||
*/
|
*/
|
||||||
XMLNode* InsertFirstChild( XMLNode* addThis );
|
XMLNode* InsertFirstChild( XMLNode* addThis );
|
||||||
/**
|
/**
|
||||||
Add a node after the specified child node.
|
Add a node after the specified child node.
|
||||||
|
If the child node is already part of the document,
|
||||||
|
it is moved from its old location to the new location.
|
||||||
|
Returns the addThis argument or 0 if the afterThis node
|
||||||
|
is not a child of this node, or if the node does not
|
||||||
|
belong to the same document.
|
||||||
*/
|
*/
|
||||||
XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
|
XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis );
|
||||||
|
|
||||||
|
@ -1009,13 +1025,11 @@ class TINYXML2_LIB XMLAttribute
|
||||||
friend class XMLElement;
|
friend class XMLElement;
|
||||||
public:
|
public:
|
||||||
/// The name of the attribute.
|
/// The name of the attribute.
|
||||||
const char* Name() const {
|
const char* Name() const;
|
||||||
return _name.GetStr();
|
|
||||||
}
|
|
||||||
/// The value of the attribute.
|
/// The value of the attribute.
|
||||||
const char* Value() const {
|
const char* Value() const;
|
||||||
return _value.GetStr();
|
|
||||||
}
|
|
||||||
/// The next attribute in the list.
|
/// The next attribute in the list.
|
||||||
const XMLAttribute* Next() const {
|
const XMLAttribute* Next() const {
|
||||||
return _next;
|
return _next;
|
||||||
|
@ -1884,7 +1898,7 @@ public:
|
||||||
with only required whitespace and newlines.
|
with only required whitespace and newlines.
|
||||||
*/
|
*/
|
||||||
XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );
|
XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );
|
||||||
~XMLPrinter() {}
|
virtual ~XMLPrinter() {}
|
||||||
|
|
||||||
/** If streaming, write the BOM and declaration. */
|
/** If streaming, write the BOM and declaration. */
|
||||||
void PushHeader( bool writeBOM, bool writeDeclaration );
|
void PushHeader( bool writeBOM, bool writeDeclaration );
|
||||||
|
@ -1899,7 +1913,7 @@ public:
|
||||||
void PushAttribute( const char* name, bool value );
|
void PushAttribute( const char* name, bool value );
|
||||||
void PushAttribute( const char* name, double value );
|
void PushAttribute( const char* name, double value );
|
||||||
/// If streaming, close the Element.
|
/// If streaming, close the Element.
|
||||||
void CloseElement();
|
virtual void CloseElement();
|
||||||
|
|
||||||
/// Add a text node.
|
/// Add a text node.
|
||||||
void PushText( const char* text, bool cdata=false );
|
void PushText( const char* text, bool cdata=false );
|
||||||
|
@ -1949,13 +1963,16 @@ public:
|
||||||
return _buffer.Size();
|
return _buffer.Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
void SealElement();
|
void SealElement();
|
||||||
|
bool _elementJustOpened;
|
||||||
|
DynArray< const char*, 10 > _stack;
|
||||||
|
|
||||||
|
private:
|
||||||
void PrintSpace( int depth );
|
void PrintSpace( int depth );
|
||||||
void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
|
void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities.
|
||||||
void Print( const char* format, ... );
|
void Print( const char* format, ... );
|
||||||
|
|
||||||
bool _elementJustOpened;
|
|
||||||
bool _firstElement;
|
bool _firstElement;
|
||||||
FILE* _fp;
|
FILE* _fp;
|
||||||
int _depth;
|
int _depth;
|
||||||
|
@ -1970,7 +1987,6 @@ private:
|
||||||
bool _entityFlag[ENTITY_RANGE];
|
bool _entityFlag[ENTITY_RANGE];
|
||||||
bool _restrictedEntityFlag[ENTITY_RANGE];
|
bool _restrictedEntityFlag[ENTITY_RANGE];
|
||||||
|
|
||||||
DynArray< const char*, 10 > _stack;
|
|
||||||
DynArray< char, 20 > _buffer;
|
DynArray< char, 20 > _buffer;
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
DynArray< char, 20 > _accumulator;
|
DynArray< char, 20 > _accumulator;
|
||||||
|
|
Loading…
Reference in New Issue