finish switching to _ for member vars

This commit is contained in:
Lee Thomason 2012-10-12 10:58:48 -07:00
parent ed5c879dfe
commit 624d43fc05
2 changed files with 462 additions and 453 deletions

File diff suppressed because it is too large Load Diff

View File

@ -189,58 +189,58 @@ class DynArray
{ {
public: public:
DynArray< T, INIT >() { DynArray< T, INIT >() {
_mem = pool; _mem = _pool;
allocated = INIT; _allocated = INIT;
size = 0; _size = 0;
} }
~DynArray() { ~DynArray() {
if ( _mem != pool ) { if ( _mem != _pool ) {
delete [] _mem; delete [] _mem;
} }
} }
void Push( T t ) { void Push( T t ) {
EnsureCapacity( size+1 ); EnsureCapacity( _size+1 );
_mem[size++] = t; _mem[_size++] = t;
} }
T* PushArr( int count ) { T* PushArr( int count ) {
EnsureCapacity( size+count ); EnsureCapacity( _size+count );
T* ret = &_mem[size]; T* ret = &_mem[_size];
size += count; _size += count;
return ret; return ret;
} }
T Pop() { T Pop() {
return _mem[--size]; return _mem[--_size];
} }
void PopArr( int count ) { void PopArr( int count ) {
TIXMLASSERT( size >= count ); TIXMLASSERT( _size >= count );
size -= count; _size -= count;
} }
bool Empty() const { bool Empty() const {
return size == 0; return _size == 0;
} }
T& operator[](int i) { T& operator[](int i) {
TIXMLASSERT( i>= 0 && i < size ); TIXMLASSERT( i>= 0 && i < _size );
return _mem[i]; return _mem[i];
} }
const T& operator[](int i) const { const T& operator[](int i) const {
TIXMLASSERT( i>= 0 && i < size ); TIXMLASSERT( i>= 0 && i < _size );
return _mem[i]; return _mem[i];
} }
int Size() const { int Size() const {
return size; return _size;
} }
int Capacity() const { int Capacity() const {
return allocated; return _allocated;
} }
const T* Mem() const { const T* Mem() const {
@ -253,22 +253,22 @@ public:
private: private:
void EnsureCapacity( int cap ) { void EnsureCapacity( int cap ) {
if ( cap > allocated ) { if ( cap > _allocated ) {
int newAllocated = cap * 2; int newAllocated = cap * 2;
T* newMem = new T[newAllocated]; T* newMem = new T[newAllocated];
memcpy( newMem, _mem, sizeof(T)*size ); // warning: not using constructors, only works for PODs memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
if ( _mem != pool ) { if ( _mem != _pool ) {
delete [] _mem; delete [] _mem;
} }
_mem = newMem; _mem = newMem;
allocated = newAllocated; _allocated = newAllocated;
} }
} }
T* _mem; T* _mem;
T pool[INIT]; T _pool[INIT];
int allocated; // objects allocated int _allocated; // objects allocated
int size; // number objects in use int _size; // number objects in use
}; };
@ -295,11 +295,11 @@ template< int SIZE >
class MemPoolT : public MemPool class MemPoolT : public MemPool
{ {
public: public:
MemPoolT() : root(0), currentAllocs(0), nAllocs(0), maxAllocs(0) {} MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0) {}
~MemPoolT() { ~MemPoolT() {
// Delete the blocks. // Delete the blocks.
for( int i=0; i<blockPtrs.Size(); ++i ) { for( int i=0; i<_blockPtrs.Size(); ++i ) {
delete blockPtrs[i]; delete _blockPtrs[i];
} }
} }
@ -307,46 +307,46 @@ public:
return SIZE; return SIZE;
} }
int CurrentAllocs() const { int CurrentAllocs() const {
return currentAllocs; return _currentAllocs;
} }
virtual void* Alloc() { virtual void* Alloc() {
if ( !root ) { if ( !_root ) {
// Need a new block. // Need a new block.
Block* block = new Block(); Block* block = new Block();
blockPtrs.Push( block ); _blockPtrs.Push( block );
for( int i=0; i<COUNT-1; ++i ) { for( int i=0; i<COUNT-1; ++i ) {
block->chunk[i].next = &block->chunk[i+1]; block->chunk[i].next = &block->chunk[i+1];
} }
block->chunk[COUNT-1].next = 0; block->chunk[COUNT-1].next = 0;
root = block->chunk; _root = block->chunk;
} }
void* result = root; void* result = _root;
root = root->next; _root = _root->next;
++currentAllocs; ++_currentAllocs;
if ( currentAllocs > maxAllocs ) { if ( _currentAllocs > _maxAllocs ) {
maxAllocs = currentAllocs; _maxAllocs = _currentAllocs;
} }
nAllocs++; _nAllocs++;
return result; return result;
} }
virtual void Free( void* mem ) { virtual void Free( void* mem ) {
if ( !mem ) { if ( !mem ) {
return; return;
} }
--currentAllocs; --_currentAllocs;
Chunk* chunk = (Chunk*)mem; Chunk* chunk = (Chunk*)mem;
#ifdef DEBUG #ifdef DEBUG
memset( chunk, 0xfe, sizeof(Chunk) ); memset( chunk, 0xfe, sizeof(Chunk) );
#endif #endif
chunk->next = root; chunk->next = _root;
root = chunk; _root = chunk;
} }
void Trace( const char* name ) { void Trace( const char* name ) {
printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n", printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",
name, maxAllocs, maxAllocs*SIZE/1024, currentAllocs, SIZE, nAllocs, blockPtrs.Size() ); name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() );
} }
private: private:
@ -358,12 +358,12 @@ private:
struct Block { struct Block {
Chunk chunk[COUNT]; Chunk chunk[COUNT];
}; };
DynArray< Block*, 10 > blockPtrs; DynArray< Block*, 10 > _blockPtrs;
Chunk* root; Chunk* _root;
int currentAllocs; int _currentAllocs;
int nAllocs; int _nAllocs;
int maxAllocs; int _maxAllocs;
}; };
@ -533,11 +533,11 @@ public:
/// Get the XMLDocument that owns this XMLNode. /// Get the XMLDocument that owns this XMLNode.
const XMLDocument* GetDocument() const { const XMLDocument* GetDocument() const {
return document; return _document;
} }
/// Get the XMLDocument that owns this XMLNode. /// Get the XMLDocument that owns this XMLNode.
XMLDocument* GetDocument() { XMLDocument* GetDocument() {
return document; return _document;
} }
virtual XMLElement* ToElement() { virtual XMLElement* ToElement() {
@ -588,8 +588,9 @@ public:
@endverbatim @endverbatim
*/ */
const char* Value() const { const char* Value() const {
return value.GetStr(); return _value.GetStr();
} }
/** Set the Value of an XML node. /** Set the Value of an XML node.
@sa Value() @sa Value()
*/ */
@ -597,36 +598,41 @@ public:
/// Get the parent of this node on the DOM. /// Get the parent of this node on the DOM.
const XMLNode* Parent() const { const XMLNode* Parent() const {
return parent; return _parent;
} }
XMLNode* Parent() { XMLNode* Parent() {
return parent; return _parent;
} }
/// Returns true if this node has no children. /// Returns true if this node has no children.
bool NoChildren() const { bool NoChildren() const {
return !firstChild; return !_firstChild;
} }
/// Get the first child node, or null if none exists. /// Get the first child node, or null if none exists.
const XMLNode* FirstChild() const { const XMLNode* FirstChild() const {
return firstChild; return _firstChild;
} }
XMLNode* FirstChild() { XMLNode* FirstChild() {
return firstChild; return _firstChild;
} }
/** Get the first child element, or optionally the first child /** Get the first child element, or optionally the first child
element with the specified name. element with the specified name.
*/ */
const XMLElement* FirstChildElement( const char* value=0 ) const; 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. /// Get the last child node, or null if none exists.
const XMLNode* LastChild() const { const XMLNode* LastChild() const {
return lastChild; return _lastChild;
} }
XMLNode* LastChild() { XMLNode* LastChild() {
return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild() ); return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild() );
} }
@ -635,36 +641,41 @@ public:
element with the specified name. element with the specified name.
*/ */
const XMLElement* LastChildElement( const char* value=0 ) const; 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. /// Get the previous (left) sibling node of this node.
const XMLNode* PreviousSibling() const { const XMLNode* PreviousSibling() const {
return prev; return _prev;
} }
XMLNode* PreviousSibling() { XMLNode* PreviousSibling() {
return prev; return _prev;
} }
/// Get the previous (left) sibling element of this node, with an opitionally supplied name. /// Get the previous (left) sibling element of this node, with an opitionally supplied name.
const XMLElement* PreviousSiblingElement( const char* value=0 ) const ; 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. /// Get the next (right) sibling node of this node.
const XMLNode* NextSibling() const { const XMLNode* NextSibling() const {
return next; return _next;
} }
XMLNode* NextSibling() { XMLNode* NextSibling() {
return next; return _next;
} }
/// Get the next (right) sibling element of this node, with an opitionally supplied name. /// Get the next (right) sibling element of this node, with an opitionally supplied name.
const XMLElement* NextSiblingElement( const char* value=0 ) const; 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 ) );
} }
/** /**
@ -746,18 +757,18 @@ protected:
XMLNode( const XMLNode& ); // not supported XMLNode( const XMLNode& ); // not supported
XMLNode& operator=( const XMLNode& ); // not supported XMLNode& operator=( const XMLNode& ); // not supported
XMLDocument* document; XMLDocument* _document;
XMLNode* parent; XMLNode* _parent;
mutable StrPair value; mutable StrPair _value;
XMLNode* firstChild; XMLNode* _firstChild;
XMLNode* lastChild; XMLNode* _lastChild;
XMLNode* prev; XMLNode* _prev;
XMLNode* next; XMLNode* _next;
private: private:
MemPool* memPool; MemPool* _memPool;
void Unlink( XMLNode* child ); void Unlink( XMLNode* child );
}; };
@ -789,27 +800,26 @@ public:
} }
/// Declare whether this should be CDATA or standard text. /// Declare whether this should be CDATA or standard text.
void SetCData( bool _isCData ) { void SetCData( bool isCData ) {
this->isCData = _isCData; _isCData = isCData;
} }
/// Returns true if this is a CDATA text element. /// Returns true if this is a CDATA text element.
bool CData() const { bool CData() const {
return isCData; return _isCData;
} }
char* ParseDeep( char*, StrPair* endTag ); char* ParseDeep( char*, StrPair* endTag );
virtual XMLNode* ShallowClone( XMLDocument* document ) const; virtual XMLNode* ShallowClone( XMLDocument* document ) const;
virtual bool ShallowEqual( const XMLNode* compare ) const; virtual bool ShallowEqual( const XMLNode* compare ) const;
protected: protected:
XMLText( XMLDocument* doc ) : XMLNode( doc ), isCData( false ) {} XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
virtual ~XMLText() {} virtual ~XMLText() {}
XMLText( const XMLText& ); // not supported XMLText( const XMLText& ); // not supported
XMLText& operator=( const XMLText& ); // not supported XMLText& operator=( const XMLText& ); // not supported
private: private:
bool isCData; bool _isCData;
}; };
@ -948,13 +958,13 @@ class XMLAttribute
friend class XMLElement; friend class XMLElement;
public: public:
const char* Name() const { const char* Name() const {
return name.GetStr(); ///< The name of the attribute. return _name.GetStr(); ///< The name of the attribute.
} }
const char* Value() const { const char* Value() const {
return value.GetStr(); ///< The value of the attribute. return _value.GetStr(); ///< The value of the attribute.
} }
const XMLAttribute* Next() const { const XMLAttribute* Next() const {
return next; ///< The next attribute in the list. return _next; ///< The next attribute in the list.
} }
/** IntAttribute interprets the attribute as an integer, and returns the value. /** IntAttribute interprets the attribute as an integer, and returns the value.
@ -1021,18 +1031,19 @@ public:
private: private:
enum { BUF_SIZE = 200 }; enum { BUF_SIZE = 200 };
XMLAttribute() : next( 0 ) {} XMLAttribute() : _next( 0 ) {}
virtual ~XMLAttribute() {} virtual ~XMLAttribute() {}
XMLAttribute( const XMLAttribute& ); // not supported XMLAttribute( const XMLAttribute& ); // not supported
void operator=( const XMLAttribute& ); // not supported void operator=( const XMLAttribute& ); // not supported
void SetName( const char* name ); void SetName( const char* name );
char* ParseDeep( char* p, bool processEntities ); char* ParseDeep( char* p, bool processEntities );
mutable StrPair name; mutable StrPair _name;
mutable StrPair value; mutable StrPair _value;
XMLAttribute* next; XMLAttribute* _next;
MemPool* memPool; MemPool* _memPool;
}; };
@ -1135,70 +1146,70 @@ public:
QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10
@endverbatim @endverbatim
*/ */
int QueryIntAttribute( const char* name, int* _value ) const { int QueryIntAttribute( const char* name, int* value ) const {
const XMLAttribute* a = FindAttribute( name ); const XMLAttribute* a = FindAttribute( name );
if ( !a ) { if ( !a ) {
return XML_NO_ATTRIBUTE; return XML_NO_ATTRIBUTE;
} }
return a->QueryIntValue( _value ); return a->QueryIntValue( value );
} }
/// See QueryIntAttribute() /// See QueryIntAttribute()
int QueryUnsignedAttribute( const char* name, unsigned int* _value ) const { int QueryUnsignedAttribute( const char* name, unsigned int* value ) const {
const XMLAttribute* a = FindAttribute( name ); const XMLAttribute* a = FindAttribute( name );
if ( !a ) { if ( !a ) {
return XML_NO_ATTRIBUTE; return XML_NO_ATTRIBUTE;
} }
return a->QueryUnsignedValue( _value ); return a->QueryUnsignedValue( value );
} }
/// See QueryIntAttribute() /// See QueryIntAttribute()
int QueryBoolAttribute( const char* name, bool* _value ) const { int QueryBoolAttribute( const char* name, bool* value ) const {
const XMLAttribute* a = FindAttribute( name ); const XMLAttribute* a = FindAttribute( name );
if ( !a ) { if ( !a ) {
return XML_NO_ATTRIBUTE; return XML_NO_ATTRIBUTE;
} }
return a->QueryBoolValue( _value ); return a->QueryBoolValue( value );
} }
/// See QueryIntAttribute() /// See QueryIntAttribute()
int QueryDoubleAttribute( const char* name, double* _value ) const { int QueryDoubleAttribute( const char* name, double* value ) const {
const XMLAttribute* a = FindAttribute( name ); const XMLAttribute* a = FindAttribute( name );
if ( !a ) { if ( !a ) {
return XML_NO_ATTRIBUTE; return XML_NO_ATTRIBUTE;
} }
return a->QueryDoubleValue( _value ); return a->QueryDoubleValue( value );
} }
/// See QueryIntAttribute() /// See QueryIntAttribute()
int QueryFloatAttribute( const char* name, float* _value ) const { int QueryFloatAttribute( const char* name, float* value ) const {
const XMLAttribute* a = FindAttribute( name ); const XMLAttribute* a = FindAttribute( name );
if ( !a ) { if ( !a ) {
return XML_NO_ATTRIBUTE; return XML_NO_ATTRIBUTE;
} }
return a->QueryFloatValue( _value ); return a->QueryFloatValue( value );
} }
/// Sets the named attribute to value. /// Sets the named attribute to value.
void SetAttribute( const char* name, const char* _value ) { void SetAttribute( const char* name, const char* value ) {
XMLAttribute* a = FindOrCreateAttribute( name ); XMLAttribute* a = FindOrCreateAttribute( name );
a->SetAttribute( _value ); a->SetAttribute( value );
} }
/// Sets the named attribute to value. /// Sets the named attribute to value.
void SetAttribute( const char* name, int _value ) { void SetAttribute( const char* name, int value ) {
XMLAttribute* a = FindOrCreateAttribute( name ); XMLAttribute* a = FindOrCreateAttribute( name );
a->SetAttribute( _value ); a->SetAttribute( value );
} }
/// Sets the named attribute to value. /// Sets the named attribute to value.
void SetAttribute( const char* name, unsigned _value ) { void SetAttribute( const char* name, unsigned value ) {
XMLAttribute* a = FindOrCreateAttribute( name ); XMLAttribute* a = FindOrCreateAttribute( name );
a->SetAttribute( _value ); a->SetAttribute( value );
} }
/// Sets the named attribute to value. /// Sets the named attribute to value.
void SetAttribute( const char* name, bool _value ) { void SetAttribute( const char* name, bool value ) {
XMLAttribute* a = FindOrCreateAttribute( name ); XMLAttribute* a = FindOrCreateAttribute( name );
a->SetAttribute( _value ); a->SetAttribute( value );
} }
/// Sets the named attribute to value. /// Sets the named attribute to value.
void SetAttribute( const char* name, double _value ) { void SetAttribute( const char* name, double value ) {
XMLAttribute* a = FindOrCreateAttribute( name ); XMLAttribute* a = FindOrCreateAttribute( name );
a->SetAttribute( _value ); a->SetAttribute( value );
} }
/** /**
@ -1208,7 +1219,7 @@ public:
/// Return the first attribute in the list. /// Return the first attribute in the list.
const XMLAttribute* FirstAttribute() const { const XMLAttribute* FirstAttribute() const {
return rootAttribute; return _rootAttribute;
} }
/// Query a specific attribute in the list. /// Query a specific attribute in the list.
const XMLAttribute* FindAttribute( const char* name ) const; const XMLAttribute* FindAttribute( const char* name ) const;
@ -1286,7 +1297,7 @@ public:
CLOSING // </foo> CLOSING // </foo>
}; };
int ClosingType() const { int ClosingType() const {
return closingType; return _closingType;
} }
char* ParseDeep( char* p, StrPair* endTag ); char* ParseDeep( char* p, StrPair* endTag );
virtual XMLNode* ShallowClone( XMLDocument* document ) const; virtual XMLNode* ShallowClone( XMLDocument* document ) const;
@ -1303,11 +1314,11 @@ private:
//void LinkAttribute( XMLAttribute* attrib ); //void LinkAttribute( XMLAttribute* attrib );
char* ParseAttributes( char* p ); char* ParseAttributes( char* p );
int closingType; int _closingType;
// The attribute list is ordered; there is no 'lastAttribute' // The attribute list is ordered; there is no 'lastAttribute'
// because the list needs to be scanned for dupes before adding // because the list needs to be scanned for dupes before adding
// a new attribute. // a new attribute.
XMLAttribute* rootAttribute; XMLAttribute* _rootAttribute;
}; };
@ -1382,22 +1393,22 @@ public:
int SaveFile( FILE* fp, bool compact = false ); int SaveFile( FILE* fp, bool compact = false );
bool ProcessEntities() const { bool ProcessEntities() const {
return processEntities; return _processEntities;
} }
Whitespace WhitespaceMode() const { Whitespace WhitespaceMode() const {
return whitespace; return _whitespace;
} }
/** /**
Returns true if this document has a leading Byte Order Mark of UTF8. Returns true if this document has a leading Byte Order Mark of UTF8.
*/ */
bool HasBOM() const { bool HasBOM() const {
return writeBOM; return _writeBOM;
} }
/** Sets whether to write the BOM when writing the file. /** Sets whether to write the BOM when writing the file.
*/ */
void SetBOM( bool useBOM ) { void SetBOM( bool useBOM ) {
writeBOM = useBOM; _writeBOM = useBOM;
} }
/** Return the root element of DOM. Equivalent to FirstChildElement(). /** Return the root element of DOM. Equivalent to FirstChildElement().
@ -1469,26 +1480,26 @@ public:
It will be unlinked from the DOM. It will be unlinked from the DOM.
*/ */
void DeleteNode( XMLNode* node ) { void DeleteNode( XMLNode* node ) {
node->parent->DeleteChild( node ); node->_parent->DeleteChild( node );
} }
void SetError( int error, const char* str1, const char* str2 ); void SetError( int error, const char* str1, const char* str2 );
/// Return true if there was an error parsing the document. /// Return true if there was an error parsing the document.
bool Error() const { bool Error() const {
return errorID != XML_NO_ERROR; return _errorID != XML_NO_ERROR;
} }
/// Return the errorID. /// Return the errorID.
int ErrorID() const { int ErrorID() const {
return errorID; return _errorID;
} }
/// Return a possibly helpful diagnostic location or string. /// Return a possibly helpful diagnostic location or string.
const char* GetErrorStr1() const { const char* GetErrorStr1() const {
return errorStr1; return _errorStr1;
} }
/// Return a possibly helpful secondary diagnostic location or string. /// Return a possibly helpful secondary diagnostic location or string.
const char* GetErrorStr2() const { const char* GetErrorStr2() const {
return errorStr2; return _errorStr2;
} }
/// If there is an error, print it to stdout. /// If there is an error, print it to stdout.
void PrintError() const; void PrintError() const;
@ -1508,18 +1519,18 @@ private:
void operator=( const XMLDocument& ); // not supported void operator=( const XMLDocument& ); // not supported
void InitDocument(); void InitDocument();
bool writeBOM; bool _writeBOM;
bool processEntities; bool _processEntities;
int errorID; int _errorID;
Whitespace whitespace; Whitespace _whitespace;
const char* errorStr1; const char* _errorStr1;
const char* errorStr2; const char* _errorStr2;
char* charBuffer; char* _charBuffer;
MemPoolT< sizeof(XMLElement) > elementPool; MemPoolT< sizeof(XMLElement) > _elementPool;
MemPoolT< sizeof(XMLAttribute) > attributePool; MemPoolT< sizeof(XMLAttribute) > _attributePool;
MemPoolT< sizeof(XMLText) > textPool; MemPoolT< sizeof(XMLText) > _textPool;
MemPoolT< sizeof(XMLComment) > commentPool; MemPoolT< sizeof(XMLComment) > _commentPool;
}; };
@ -1582,79 +1593,79 @@ class XMLHandle
{ {
public: public:
/// Create a handle from any node (at any depth of the tree.) This can be a null pointer. /// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
XMLHandle( XMLNode* _node ) { XMLHandle( XMLNode* node ) {
node = _node; _node = node;
} }
/// Create a handle from a node. /// Create a handle from a node.
XMLHandle( XMLNode& _node ) { XMLHandle( XMLNode& node ) {
node = &_node; _node = &node;
} }
/// Copy constructor /// Copy constructor
XMLHandle( const XMLHandle& ref ) { XMLHandle( const XMLHandle& ref ) {
node = ref.node; _node = ref._node;
} }
/// Assignment /// Assignment
XMLHandle& operator=( const XMLHandle& ref ) { XMLHandle& operator=( const XMLHandle& ref ) {
node = ref.node; _node = ref._node;
return *this; return *this;
} }
/// Get the first child of this handle. /// Get the first child of this handle.
XMLHandle FirstChild() { XMLHandle FirstChild() {
return XMLHandle( node ? node->FirstChild() : 0 ); return XMLHandle( _node ? _node->FirstChild() : 0 );
} }
/// Get the first child element of this handle. /// Get the first child element of this handle.
XMLHandle FirstChildElement( const char* value=0 ) { XMLHandle FirstChildElement( const char* value=0 ) {
return XMLHandle( node ? node->FirstChildElement( value ) : 0 ); return XMLHandle( _node ? _node->FirstChildElement( value ) : 0 );
} }
/// Get the last child of this handle. /// Get the last child of this handle.
XMLHandle LastChild() { XMLHandle LastChild() {
return XMLHandle( node ? node->LastChild() : 0 ); return XMLHandle( _node ? _node->LastChild() : 0 );
} }
/// Get the last child element of this handle. /// Get the last child element of this handle.
XMLHandle LastChildElement( const char* _value=0 ) { XMLHandle LastChildElement( const char* _value=0 ) {
return XMLHandle( node ? node->LastChildElement( _value ) : 0 ); return XMLHandle( _node ? _node->LastChildElement( _value ) : 0 );
} }
/// Get the previous sibling of this handle. /// Get the previous sibling of this handle.
XMLHandle PreviousSibling() { XMLHandle PreviousSibling() {
return XMLHandle( node ? node->PreviousSibling() : 0 ); return XMLHandle( _node ? _node->PreviousSibling() : 0 );
} }
/// Get the previous sibling element of this handle. /// Get the previous sibling element of this handle.
XMLHandle PreviousSiblingElement( const char* _value=0 ) { XMLHandle PreviousSiblingElement( const char* _value=0 ) {
return XMLHandle( node ? node->PreviousSiblingElement( _value ) : 0 ); return XMLHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
} }
/// Get the next sibling of this handle. /// Get the next sibling of this handle.
XMLHandle NextSibling() { XMLHandle NextSibling() {
return XMLHandle( node ? node->NextSibling() : 0 ); return XMLHandle( _node ? _node->NextSibling() : 0 );
} }
/// Get the next sibling element of this handle. /// Get the next sibling element of this handle.
XMLHandle NextSiblingElement( const char* _value=0 ) { XMLHandle NextSiblingElement( const char* _value=0 ) {
return XMLHandle( node ? node->NextSiblingElement( _value ) : 0 ); return XMLHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
} }
/// Safe cast to XMLNode. This can return null. /// Safe cast to XMLNode. This can return null.
XMLNode* ToNode() { XMLNode* ToNode() {
return node; return _node;
} }
/// Safe cast to XMLElement. This can return null. /// Safe cast to XMLElement. This can return null.
XMLElement* ToElement() { XMLElement* ToElement() {
return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
} }
/// Safe cast to XMLText. This can return null. /// Safe cast to XMLText. This can return null.
XMLText* ToText() { XMLText* ToText() {
return ( ( node && node->ToText() ) ? node->ToText() : 0 ); return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
} }
/// Safe cast to XMLUnknown. This can return null. /// Safe cast to XMLUnknown. This can return null.
XMLUnknown* ToUnknown() { XMLUnknown* ToUnknown() {
return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
} }
/// Safe cast to XMLDeclaration. This can return null. /// Safe cast to XMLDeclaration. This can return null.
XMLDeclaration* ToDeclaration() { XMLDeclaration* ToDeclaration() {
return ( ( node && node->ToDeclaration() ) ? node->ToDeclaration() : 0 ); return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
} }
private: private:
XMLNode* node; XMLNode* _node;
}; };
@ -1665,65 +1676,65 @@ private:
class XMLConstHandle class XMLConstHandle
{ {
public: public:
XMLConstHandle( const XMLNode* _node ) { XMLConstHandle( const XMLNode* node ) {
node = _node; _node = node;
} }
XMLConstHandle( const XMLNode& _node ) { XMLConstHandle( const XMLNode& node ) {
node = &_node; _node = &node;
} }
XMLConstHandle( const XMLConstHandle& ref ) { XMLConstHandle( const XMLConstHandle& ref ) {
node = ref.node; _node = ref._node;
} }
XMLConstHandle& operator=( const XMLConstHandle& ref ) { XMLConstHandle& operator=( const XMLConstHandle& ref ) {
node = ref.node; _node = ref._node;
return *this; return *this;
} }
const XMLConstHandle FirstChild() const { const XMLConstHandle FirstChild() const {
return XMLConstHandle( node ? node->FirstChild() : 0 ); return XMLConstHandle( _node ? _node->FirstChild() : 0 );
} }
const XMLConstHandle FirstChildElement( const char* value=0 ) const { const XMLConstHandle FirstChildElement( const char* value=0 ) const {
return XMLConstHandle( node ? node->FirstChildElement( value ) : 0 ); return XMLConstHandle( _node ? _node->FirstChildElement( value ) : 0 );
} }
const XMLConstHandle LastChild() const { const XMLConstHandle LastChild() const {
return XMLConstHandle( node ? node->LastChild() : 0 ); return XMLConstHandle( _node ? _node->LastChild() : 0 );
} }
const XMLConstHandle LastChildElement( const char* _value=0 ) const { const XMLConstHandle LastChildElement( const char* _value=0 ) const {
return XMLConstHandle( node ? node->LastChildElement( _value ) : 0 ); return XMLConstHandle( _node ? _node->LastChildElement( _value ) : 0 );
} }
const XMLConstHandle PreviousSibling() const { const XMLConstHandle PreviousSibling() const {
return XMLConstHandle( node ? node->PreviousSibling() : 0 ); return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
} }
const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const { const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const {
return XMLConstHandle( node ? node->PreviousSiblingElement( _value ) : 0 ); return XMLConstHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
} }
const XMLConstHandle NextSibling() const { const XMLConstHandle NextSibling() const {
return XMLConstHandle( node ? node->NextSibling() : 0 ); return XMLConstHandle( _node ? _node->NextSibling() : 0 );
} }
const XMLConstHandle NextSiblingElement( const char* _value=0 ) const { const XMLConstHandle NextSiblingElement( const char* _value=0 ) const {
return XMLConstHandle( node ? node->NextSiblingElement( _value ) : 0 ); return XMLConstHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
} }
const XMLNode* ToNode() const { const XMLNode* ToNode() const {
return node; return _node;
} }
const XMLElement* ToElement() const { const XMLElement* ToElement() const {
return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
} }
const XMLText* ToText() const { const XMLText* ToText() const {
return ( ( node && node->ToText() ) ? node->ToText() : 0 ); return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
} }
const XMLUnknown* ToUnknown() const { const XMLUnknown* ToUnknown() const {
return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
} }
const XMLDeclaration* ToDeclaration() const { const XMLDeclaration* ToDeclaration() const {
return ( ( node && node->ToDeclaration() ) ? node->ToDeclaration() : 0 ); return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
} }
private: private:
const XMLNode* node; const XMLNode* _node;
}; };
@ -1833,7 +1844,7 @@ public:
the XML file in memory. the XML file in memory.
*/ */
const char* CStr() const { const char* CStr() const {
return buffer.Mem(); return _buffer.Mem();
} }
/** /**
If in print to memory mode, return the size If in print to memory mode, return the size
@ -1841,7 +1852,7 @@ public:
includes the terminating null.) includes the terminating null.)
*/ */
int CStrSize() const { int CStrSize() const {
return buffer.Size(); return _buffer.Size();
} }
private: private:
@ -1850,25 +1861,25 @@ private:
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 _elementJustOpened;
bool firstElement; bool _firstElement;
FILE* fp; FILE* _fp;
int depth; int _depth;
int textDepth; int _textDepth;
bool processEntities; bool _processEntities;
bool compactMode; bool _compactMode;
enum { enum {
ENTITY_RANGE = 64, ENTITY_RANGE = 64,
BUF_SIZE = 200 BUF_SIZE = 200
}; };
bool entityFlag[ENTITY_RANGE]; bool _entityFlag[ENTITY_RANGE];
bool restrictedEntityFlag[ENTITY_RANGE]; bool _restrictedEntityFlag[ENTITY_RANGE];
DynArray< const char*, 10 > stack; 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;
#endif #endif
}; };