mirror of https://github.com/AxioDL/tinyxml2.git
finally have the placement new working as desired.
This commit is contained in:
parent
2c85a711f1
commit
d198322032
72
tinyxml2.cpp
72
tinyxml2.cpp
|
@ -4,6 +4,9 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <new.h>
|
||||||
|
|
||||||
|
//#pragma warning ( disable : 4291 )
|
||||||
|
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
|
|
||||||
|
@ -123,7 +126,7 @@ const char* StringPool::Intern( const char* str )
|
||||||
|
|
||||||
|
|
||||||
// --------- XMLBase ----------- //
|
// --------- XMLBase ----------- //
|
||||||
// fixme: should take in the entity/newline flags as param
|
|
||||||
char* XMLBase::ParseText( char* p, StrPair* pair, const char* endTag, int strFlags )
|
char* XMLBase::ParseText( char* p, StrPair* pair, const char* endTag, int strFlags )
|
||||||
{
|
{
|
||||||
TIXMLASSERT( endTag && *endTag );
|
TIXMLASSERT( endTag && *endTag );
|
||||||
|
@ -175,11 +178,11 @@ char* XMLBase::ParseName( char* p, StrPair* pair )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* XMLBase::Identify( XMLDocument* document, char* p, XMLNode** node )
|
char* XMLDocument::Identify( char* p, XMLNode** node )
|
||||||
{
|
{
|
||||||
XMLNode* returnNode = 0;
|
XMLNode* returnNode = 0;
|
||||||
char* start = p;
|
char* start = p;
|
||||||
p = XMLNode::SkipWhiteSpace( p );
|
p = XMLBase::SkipWhiteSpace( p );
|
||||||
if( !p || !*p )
|
if( !p || !*p )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -204,18 +207,20 @@ char* XMLBase::Identify( XMLDocument* document, char* p, XMLNode** node )
|
||||||
static const int cdataHeaderLen = 9;
|
static const int cdataHeaderLen = 9;
|
||||||
static const int elementHeaderLen = 1;
|
static const int elementHeaderLen = 1;
|
||||||
|
|
||||||
if ( StringEqual( p, commentHeader, commentHeaderLen ) ) {
|
if ( XMLBase::StringEqual( p, commentHeader, commentHeaderLen ) ) {
|
||||||
returnNode = new XMLComment( document );
|
returnNode = new (commentPool.Alloc()) XMLComment( this );
|
||||||
|
returnNode->memPool = &commentPool;
|
||||||
p += commentHeaderLen;
|
p += commentHeaderLen;
|
||||||
}
|
}
|
||||||
else if ( StringEqual( p, elementHeader, elementHeaderLen ) ) {
|
else if ( XMLBase::StringEqual( p, elementHeader, elementHeaderLen ) ) {
|
||||||
returnNode = new XMLElement( document );
|
returnNode = new (elementPool.Alloc()) XMLElement( this );
|
||||||
|
returnNode->memPool = &elementPool;
|
||||||
p += elementHeaderLen;
|
p += elementHeaderLen;
|
||||||
}
|
}
|
||||||
// fixme: better text detection
|
// fixme: better text detection
|
||||||
else if ( (*p != '<') && IsAlphaNum( *p ) ) {
|
else if ( (*p != '<') && XMLBase::IsAlphaNum( *p ) ) {
|
||||||
// fixme: this is filtering out empty text...should it?
|
returnNode = new (textPool.Alloc()) XMLText( this );
|
||||||
returnNode = new XMLText( document );
|
returnNode->memPool = &textPool;
|
||||||
p = start; // Back it up, all the text counts.
|
p = start; // Back it up, all the text counts.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -254,7 +259,13 @@ void XMLNode::ClearChildren()
|
||||||
while( firstChild ) {
|
while( firstChild ) {
|
||||||
XMLNode* node = firstChild;
|
XMLNode* node = firstChild;
|
||||||
Unlink( node );
|
Unlink( node );
|
||||||
delete node;
|
|
||||||
|
//delete node;
|
||||||
|
// placement new!
|
||||||
|
MemPool* pool = node->memPool;
|
||||||
|
node->~XMLNode();
|
||||||
|
pool->Free( node );
|
||||||
|
// fixme: memory never free'd.
|
||||||
}
|
}
|
||||||
firstChild = lastChild = 0;
|
firstChild = lastChild = 0;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +321,7 @@ XMLElement* XMLNode::FirstChildElement( const char* value )
|
||||||
for( XMLNode* node=firstChild; node; node=node->next ) {
|
for( XMLNode* node=firstChild; node; node=node->next ) {
|
||||||
XMLElement* element = node->ToElement();
|
XMLElement* element = node->ToElement();
|
||||||
if ( element ) {
|
if ( element ) {
|
||||||
if ( !value || StringEqual( element->Name(), value ) ) {
|
if ( !value || XMLBase::StringEqual( element->Name(), value ) ) {
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,12 +342,15 @@ char* XMLNode::ParseDeep( char* p )
|
||||||
{
|
{
|
||||||
while( p && *p ) {
|
while( p && *p ) {
|
||||||
XMLNode* node = 0;
|
XMLNode* node = 0;
|
||||||
p = Identify( document, p, &node );
|
p = document->Identify( p, &node );
|
||||||
if ( p && node ) {
|
if ( p && node ) {
|
||||||
p = node->ParseDeep( p );
|
p = node->ParseDeep( p );
|
||||||
// FIXME: is it the correct closing element?
|
// FIXME: is it the correct closing element?
|
||||||
if ( node->IsClosingElement() ) {
|
if ( node->IsClosingElement() ) {
|
||||||
delete node;
|
//delete node;
|
||||||
|
MemPool* pool = node->memPool;
|
||||||
|
node->~XMLNode(); // fixme linked list memory not free
|
||||||
|
pool->Free( node );
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
this->InsertEndChild( node );
|
this->InsertEndChild( node );
|
||||||
|
@ -348,7 +362,7 @@ char* XMLNode::ParseDeep( char* p )
|
||||||
// --------- XMLText ---------- //
|
// --------- XMLText ---------- //
|
||||||
char* XMLText::ParseDeep( char* p )
|
char* XMLText::ParseDeep( char* p )
|
||||||
{
|
{
|
||||||
p = ParseText( p, &value, "<", StrPair::TEXT_ELEMENT );
|
p = XMLBase::ParseText( p, &value, "<", StrPair::TEXT_ELEMENT );
|
||||||
// consumes the end tag.
|
// consumes the end tag.
|
||||||
if ( p && *p ) {
|
if ( p && *p ) {
|
||||||
return p-1;
|
return p-1;
|
||||||
|
@ -388,19 +402,19 @@ void XMLComment::Print( XMLStreamer* streamer )
|
||||||
char* XMLComment::ParseDeep( char* p )
|
char* XMLComment::ParseDeep( char* p )
|
||||||
{
|
{
|
||||||
// Comment parses as text.
|
// Comment parses as text.
|
||||||
return ParseText( p, &value, "-->", StrPair::COMMENT );
|
return XMLBase::ParseText( p, &value, "-->", StrPair::COMMENT );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------- XMLAttribute ---------- //
|
// --------- XMLAttribute ---------- //
|
||||||
char* XMLAttribute::ParseDeep( char* p )
|
char* XMLAttribute::ParseDeep( char* p )
|
||||||
{
|
{
|
||||||
p = ParseText( p, &name, "=", StrPair::ATTRIBUTE_NAME );
|
p = XMLBase::ParseText( p, &name, "=", StrPair::ATTRIBUTE_NAME );
|
||||||
if ( !p || !*p ) return 0;
|
if ( !p || !*p ) return 0;
|
||||||
|
|
||||||
char endTag[2] = { *p, 0 };
|
char endTag[2] = { *p, 0 };
|
||||||
++p;
|
++p;
|
||||||
p = ParseText( p, &value, endTag, StrPair::ATTRIBUTE_VALUE );
|
p = XMLBase::ParseText( p, &value, endTag, StrPair::ATTRIBUTE_VALUE );
|
||||||
if ( value.Empty() ) return 0;
|
if ( value.Empty() ) return 0;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -443,15 +457,16 @@ char* XMLElement::ParseAttributes( char* p, bool* closedElement )
|
||||||
|
|
||||||
// Read the attributes.
|
// Read the attributes.
|
||||||
while( p ) {
|
while( p ) {
|
||||||
p = SkipWhiteSpace( p );
|
p = XMLBase::SkipWhiteSpace( p );
|
||||||
if ( !p || !(*p) ) {
|
if ( !p || !(*p) ) {
|
||||||
document->SetError( XMLDocument::ERROR_PARSING_ELEMENT, start, name.GetStr() );
|
document->SetError( XMLDocument::ERROR_PARSING_ELEMENT, start, Name() );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// attribute.
|
// attribute.
|
||||||
if ( IsAlpha( *p ) ) {
|
if ( XMLBase::IsAlpha( *p ) ) {
|
||||||
XMLAttribute* attrib = new XMLAttribute( this );
|
XMLAttribute* attrib = new XMLAttribute( this );
|
||||||
|
|
||||||
p = attrib->ParseDeep( p );
|
p = attrib->ParseDeep( p );
|
||||||
if ( !p ) {
|
if ( !p ) {
|
||||||
delete attrib;
|
delete attrib;
|
||||||
|
@ -497,7 +512,7 @@ char* XMLElement::ParseAttributes( char* p, bool* closedElement )
|
||||||
char* XMLElement::ParseDeep( char* p )
|
char* XMLElement::ParseDeep( char* p )
|
||||||
{
|
{
|
||||||
// Read the element name.
|
// Read the element name.
|
||||||
p = SkipWhiteSpace( p );
|
p = XMLBase::SkipWhiteSpace( p );
|
||||||
if ( !p ) return 0;
|
if ( !p ) return 0;
|
||||||
const char* start = p;
|
const char* start = p;
|
||||||
|
|
||||||
|
@ -509,8 +524,8 @@ char* XMLElement::ParseDeep( char* p )
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = ParseName( p, &name );
|
p = XMLBase::ParseName( p, &value );
|
||||||
if ( name.Empty() ) return 0;
|
if ( value.Empty() ) return 0;
|
||||||
|
|
||||||
bool elementClosed=false;
|
bool elementClosed=false;
|
||||||
p = ParseAttributes( p, &elementClosed );
|
p = ParseAttributes( p, &elementClosed );
|
||||||
|
@ -554,7 +569,13 @@ XMLDocument::XMLDocument() :
|
||||||
|
|
||||||
XMLDocument::~XMLDocument()
|
XMLDocument::~XMLDocument()
|
||||||
{
|
{
|
||||||
|
ClearChildren();
|
||||||
delete [] charBuffer;
|
delete [] charBuffer;
|
||||||
|
|
||||||
|
TIXMLASSERT( textPool.NAlloc() == 0 );
|
||||||
|
TIXMLASSERT( elementPool.NAlloc() == 0 );
|
||||||
|
TIXMLASSERT( commentPool.NAlloc() == 0 );
|
||||||
|
TIXMLASSERT( attributePool.NAlloc() == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -572,7 +593,8 @@ void XMLDocument::InitDocument()
|
||||||
|
|
||||||
XMLElement* XMLDocument::NewElement( const char* name )
|
XMLElement* XMLDocument::NewElement( const char* name )
|
||||||
{
|
{
|
||||||
XMLElement* ele = new XMLElement( this );
|
XMLElement* ele = new (elementPool.Alloc()) XMLElement( this );
|
||||||
|
ele->memPool = &elementPool;
|
||||||
ele->SetName( name );
|
ele->SetName( name );
|
||||||
return ele;
|
return ele;
|
||||||
}
|
}
|
||||||
|
|
117
tinyxml2.h
117
tinyxml2.h
|
@ -12,6 +12,17 @@
|
||||||
- make constructors protected
|
- make constructors protected
|
||||||
- hide copy constructor
|
- hide copy constructor
|
||||||
- hide = operator
|
- hide = operator
|
||||||
|
- #define to remove mem-pooling, and make thread safe
|
||||||
|
- UTF8 support: isAlpha, etc.
|
||||||
|
|
||||||
|
(No reason to ever cast to base)
|
||||||
|
XMLBase -> Utility
|
||||||
|
|
||||||
|
XMLNode
|
||||||
|
Document
|
||||||
|
Pooled
|
||||||
|
Element
|
||||||
|
Text
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
@ -150,6 +161,72 @@ private:
|
||||||
int size; // number objects in use
|
int size; // number objects in use
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MemPool
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MemPool() {}
|
||||||
|
virtual ~MemPool() {}
|
||||||
|
|
||||||
|
virtual int ItemSize() const = 0;
|
||||||
|
virtual void* Alloc() = 0;
|
||||||
|
virtual void Free( void* ) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< int SIZE >
|
||||||
|
class MemPoolT : public MemPool
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MemPoolT() : root( 0 ), nAlloc( 0 ) {}
|
||||||
|
~MemPoolT() {
|
||||||
|
// Delete the blocks.
|
||||||
|
for( int i=0; i<blockPtrs.Size(); ++i ) {
|
||||||
|
delete blockPtrs[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int ItemSize() const { return SIZE; }
|
||||||
|
int NAlloc() const { return nAlloc; }
|
||||||
|
|
||||||
|
virtual void* Alloc() {
|
||||||
|
if ( !root ) {
|
||||||
|
// Need a new block.
|
||||||
|
Block* block = new Block();
|
||||||
|
blockPtrs.Push( block );
|
||||||
|
|
||||||
|
for( int i=0; i<COUNT-1; ++i ) {
|
||||||
|
block->chunk[i].next = &block->chunk[i+1];
|
||||||
|
}
|
||||||
|
block->chunk[COUNT-1].next = 0;
|
||||||
|
root = block->chunk;
|
||||||
|
}
|
||||||
|
void* result = root;
|
||||||
|
root = root->next;
|
||||||
|
++nAlloc;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
virtual void Free( void* mem ) {
|
||||||
|
if ( !mem ) return;
|
||||||
|
--nAlloc;
|
||||||
|
Chunk* chunk = (Chunk*)mem;
|
||||||
|
memset( chunk, 0xfe, sizeof(Chunk) );
|
||||||
|
chunk->next = root;
|
||||||
|
root = chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum { COUNT = 1024/SIZE };
|
||||||
|
union Chunk {
|
||||||
|
Chunk* next;
|
||||||
|
char mem[SIZE];
|
||||||
|
};
|
||||||
|
struct Block {
|
||||||
|
Chunk chunk[COUNT];
|
||||||
|
};
|
||||||
|
DynArray< Block*, 10 > blockPtrs;
|
||||||
|
Chunk* root;
|
||||||
|
int nAlloc;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
class StringStack
|
class StringStack
|
||||||
|
@ -203,11 +280,12 @@ private:
|
||||||
|
|
||||||
class XMLBase
|
class XMLBase
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
XMLBase() {}
|
XMLBase() {}
|
||||||
virtual ~XMLBase() {}
|
virtual ~XMLBase() {}
|
||||||
|
|
||||||
protected:
|
|
||||||
static const char* SkipWhiteSpace( const char* p ) { while( isspace( *p ) ) { ++p; } return p; }
|
static const char* SkipWhiteSpace( const char* p ) { while( isspace( *p ) ) { ++p; } return p; }
|
||||||
static char* SkipWhiteSpace( char* p ) { while( isspace( *p ) ) { ++p; } return p; }
|
static char* SkipWhiteSpace( char* p ) { while( isspace( *p ) ) { ++p; } return p; }
|
||||||
|
|
||||||
|
@ -228,18 +306,20 @@ protected:
|
||||||
inline static int IsAlphaNum( unsigned char anyByte ) { return ( anyByte <= 127 ) ? isalnum( anyByte ) : 1; }
|
inline static int IsAlphaNum( unsigned char anyByte ) { return ( anyByte <= 127 ) ? isalnum( anyByte ) : 1; }
|
||||||
inline static int IsAlpha( unsigned char anyByte ) { return ( anyByte <= 127 ) ? isalpha( anyByte ) : 1; }
|
inline static int IsAlpha( unsigned char anyByte ) { return ( anyByte <= 127 ) ? isalpha( anyByte ) : 1; }
|
||||||
|
|
||||||
char* ParseText( char* in, StrPair* pair, const char* endTag, int strFlags );
|
static char* ParseText( char* in, StrPair* pair, const char* endTag, int strFlags );
|
||||||
char* ParseName( char* in, StrPair* pair );
|
static char* ParseName( char* in, StrPair* pair );
|
||||||
char* Identify( XMLDocument* document, char* p, XMLNode** node );
|
|
||||||
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class XMLNode : public XMLBase
|
class XMLNode
|
||||||
{
|
{
|
||||||
friend class XMLDocument;
|
friend class XMLDocument;
|
||||||
friend class XMLElement;
|
friend class XMLElement;
|
||||||
public:
|
public:
|
||||||
virtual ~XMLNode();
|
//void* operator new( size_t size, MemPool* pool );
|
||||||
|
//void operator delete( void* mem, MemPool* pool );
|
||||||
|
|
||||||
XMLNode* InsertEndChild( XMLNode* addThis );
|
XMLNode* InsertEndChild( XMLNode* addThis );
|
||||||
virtual void Print( XMLStreamer* streamer );
|
virtual void Print( XMLStreamer* streamer );
|
||||||
|
@ -263,6 +343,8 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
XMLNode( XMLDocument* );
|
XMLNode( XMLDocument* );
|
||||||
|
virtual ~XMLNode();
|
||||||
|
|
||||||
void ClearChildren();
|
void ClearChildren();
|
||||||
|
|
||||||
XMLDocument* document;
|
XMLDocument* document;
|
||||||
|
@ -277,6 +359,7 @@ protected:
|
||||||
XMLNode* next;
|
XMLNode* next;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
MemPool* memPool;
|
||||||
void Unlink( XMLNode* child );
|
void Unlink( XMLNode* child );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -286,7 +369,6 @@ class XMLText : public XMLNode
|
||||||
friend class XMLBase;
|
friend class XMLBase;
|
||||||
friend class XMLDocument;
|
friend class XMLDocument;
|
||||||
public:
|
public:
|
||||||
virtual ~XMLText() {}
|
|
||||||
virtual void Print( XMLStreamer* streamer );
|
virtual void Print( XMLStreamer* streamer );
|
||||||
const char* Value() { return value.GetStr(); }
|
const char* Value() { return value.GetStr(); }
|
||||||
void SetValue( const char* );
|
void SetValue( const char* );
|
||||||
|
@ -297,6 +379,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
XMLText( XMLDocument* doc ) : XMLNode( doc ) {}
|
XMLText( XMLDocument* doc ) : XMLNode( doc ) {}
|
||||||
|
virtual ~XMLText() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
@ -307,7 +390,6 @@ class XMLComment : public XMLNode
|
||||||
friend class XMLBase;
|
friend class XMLBase;
|
||||||
friend class XMLDocument;
|
friend class XMLDocument;
|
||||||
public:
|
public:
|
||||||
virtual ~XMLComment();
|
|
||||||
virtual void Print( XMLStreamer* );
|
virtual void Print( XMLStreamer* );
|
||||||
virtual XMLComment* ToComment() { return this; }
|
virtual XMLComment* ToComment() { return this; }
|
||||||
|
|
||||||
|
@ -317,7 +399,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
XMLComment( XMLDocument* doc );
|
XMLComment( XMLDocument* doc );
|
||||||
|
virtual ~XMLComment();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
@ -327,11 +409,11 @@ class XMLAttribute : public XMLBase
|
||||||
{
|
{
|
||||||
friend class XMLElement;
|
friend class XMLElement;
|
||||||
public:
|
public:
|
||||||
XMLAttribute( XMLElement* element ) : next( 0 ) {}
|
|
||||||
virtual ~XMLAttribute() {}
|
|
||||||
virtual void Print( XMLStreamer* streamer );
|
virtual void Print( XMLStreamer* streamer );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
XMLAttribute( XMLElement* element ) : next( 0 ) {}
|
||||||
|
virtual ~XMLAttribute() {}
|
||||||
char* ParseDeep( char* p );
|
char* ParseDeep( char* p );
|
||||||
|
|
||||||
StrPair name;
|
StrPair name;
|
||||||
|
@ -345,8 +427,6 @@ class XMLElement : public XMLNode
|
||||||
friend class XMLBase;
|
friend class XMLBase;
|
||||||
friend class XMLDocument;
|
friend class XMLDocument;
|
||||||
public:
|
public:
|
||||||
virtual ~XMLElement();
|
|
||||||
|
|
||||||
const char* Name() const { return Value(); }
|
const char* Name() const { return Value(); }
|
||||||
void SetName( const char* str ) { SetValue( str ); }
|
void SetName( const char* str ) { SetValue( str ); }
|
||||||
|
|
||||||
|
@ -360,11 +440,11 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
XMLElement( XMLDocument* doc );
|
XMLElement( XMLDocument* doc );
|
||||||
|
virtual ~XMLElement();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char* ParseAttributes( char* p, bool *closedElement );
|
char* ParseAttributes( char* p, bool *closedElement );
|
||||||
|
|
||||||
mutable StrPair name;
|
|
||||||
bool closing;
|
bool closing;
|
||||||
XMLAttribute* rootAttribute;
|
XMLAttribute* rootAttribute;
|
||||||
XMLAttribute* lastAttribute;
|
XMLAttribute* lastAttribute;
|
||||||
|
@ -373,6 +453,7 @@ private:
|
||||||
|
|
||||||
class XMLDocument : public XMLNode
|
class XMLDocument : public XMLNode
|
||||||
{
|
{
|
||||||
|
friend class XMLElement;
|
||||||
public:
|
public:
|
||||||
XMLDocument();
|
XMLDocument();
|
||||||
~XMLDocument();
|
~XMLDocument();
|
||||||
|
@ -398,9 +479,10 @@ public:
|
||||||
const char* GetErrorStr1() const { return errorStr1; }
|
const char* GetErrorStr1() const { return errorStr1; }
|
||||||
const char* GetErrorStr2() const { return errorStr2; }
|
const char* GetErrorStr2() const { return errorStr2; }
|
||||||
|
|
||||||
// const char* Intern( const char* );
|
char* Identify( char* p, XMLNode** node );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
XMLDocument( const XMLDocument& ); // intentionally not implemented
|
XMLDocument( const XMLDocument& ); // intentionally not implemented
|
||||||
void InitDocument();
|
void InitDocument();
|
||||||
|
|
||||||
|
@ -409,6 +491,11 @@ private:
|
||||||
const char* errorStr2;
|
const char* errorStr2;
|
||||||
char* charBuffer;
|
char* charBuffer;
|
||||||
//StringStack stringPool;
|
//StringStack stringPool;
|
||||||
|
|
||||||
|
MemPoolT< sizeof(XMLElement) > elementPool;
|
||||||
|
MemPoolT< sizeof(XMLAttribute) > attributePool;
|
||||||
|
MemPoolT< sizeof(XMLText) > textPool;
|
||||||
|
MemPoolT< sizeof(XMLComment) > commentPool;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,5 +61,11 @@ int main( int argc, const char* argv )
|
||||||
root->InsertEndChild( newElement );
|
root->InsertEndChild( newElement );
|
||||||
doc.Print();
|
doc.Print();
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
XMLDocument* doc = new XMLDocument();
|
||||||
|
static const char* test = "<element><sub/></element>";
|
||||||
|
doc->Parse( test );
|
||||||
|
delete doc;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue