From fa4b6e00fd204998f6011420bdad60477b7a2f12 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 13 Apr 2016 08:47:41 -0400 Subject: parentheses --- include/tinyxml2.h | 780 ++++++++++++++++++++++++++--------------------------- 1 file changed, 390 insertions(+), 390 deletions(-) (limited to 'include/tinyxml2.h') diff --git a/include/tinyxml2.h b/include/tinyxml2.h index 4282642..8e51a6a 100755 --- a/include/tinyxml2.h +++ b/include/tinyxml2.h @@ -51,7 +51,7 @@ distribution. AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h */ -#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__) +#if defined(_DEBUG) || defined(DEBUG) || defined (__DEBUG__) # ifndef DEBUG # define DEBUG # endif @@ -78,16 +78,16 @@ distribution. #if defined(DEBUG) # if defined(_MSC_VER) # // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like -# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); } +# define TIXMLASSERT(x) if (!((void)0,(x))) { __debugbreak(); } # elif defined (ANDROID_NDK) # include -# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } +# define TIXMLASSERT(x) if (!(x)) { __android_log_assert("assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__); } # else # include # define TIXMLASSERT assert # endif #else -# define TIXMLASSERT( x ) {} +# define TIXMLASSERT(x) {} #endif @@ -131,10 +131,10 @@ public: COMMENT = NEEDS_NEWLINE_NORMALIZATION }; - StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {} + StrPair() : _flags(0), _start(0), _end(0) {} ~StrPair(); - void Set( char* start, char* end, int flags ) { + void Set(char* start, char* end, int flags) { Reset(); _start = start; _end = end; @@ -147,17 +147,17 @@ public: return _start == _end; } - void SetInternedStr( const char* str ) { + void SetInternedStr(const char* str) { Reset(); _start = const_cast(str); } - void SetStr( const char* str, int flags=0 ); + void SetStr(const char* str, int flags=0); - char* ParseText( char* in, const char* endTag, int strFlags ); - char* ParseName( char* in ); + char* ParseText(char* in, const char* endTag, int strFlags); + char* ParseName(char* in); - void TransferTo( StrPair* other ); + void TransferTo(StrPair* other); private: void Reset(); @@ -172,8 +172,8 @@ private: char* _start; char* _end; - StrPair( const StrPair& other ); // not supported - void operator=( StrPair& other ); // not supported, use TransferTo() + StrPair(const StrPair& other); // not supported + void operator=(StrPair& other); // not supported, use TransferTo() }; @@ -193,7 +193,7 @@ public: } ~DynArray() { - if ( _mem != _pool ) { + if (_mem != _pool) { delete [] _mem; } } @@ -202,28 +202,28 @@ public: _size = 0; } - void Push( T t ) { - TIXMLASSERT( _size < INT_MAX ); - EnsureCapacity( _size+1 ); + 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* PushArr(int count) { + TIXMLASSERT(count >= 0); + TIXMLASSERT(_size <= INT_MAX - count); + EnsureCapacity(_size+count); T* ret = &_mem[_size]; _size += count; return ret; } T Pop() { - TIXMLASSERT( _size > 0 ); + TIXMLASSERT(_size > 0); return _mem[--_size]; } - void PopArr( int count ) { - TIXMLASSERT( _size >= count ); + void PopArr(int count) { + TIXMLASSERT(_size >= count); _size -= count; } @@ -232,52 +232,52 @@ public: } T& operator[](int i) { - TIXMLASSERT( i>= 0 && i < _size ); + TIXMLASSERT(i>= 0 && i < _size); return _mem[i]; } const T& operator[](int i) const { - TIXMLASSERT( i>= 0 && i < _size ); + TIXMLASSERT(i>= 0 && i < _size); return _mem[i]; } const T& PeekTop() const { - TIXMLASSERT( _size > 0 ); + TIXMLASSERT(_size > 0); return _mem[ _size - 1]; } int Size() const { - TIXMLASSERT( _size >= 0 ); + TIXMLASSERT(_size >= 0); return _size; } int Capacity() const { - TIXMLASSERT( _allocated >= INITIAL_SIZE ); + TIXMLASSERT(_allocated >= INITIAL_SIZE); return _allocated; } const T* Mem() const { - TIXMLASSERT( _mem ); + TIXMLASSERT(_mem); return _mem; } T* Mem() { - TIXMLASSERT( _mem ); + TIXMLASSERT(_mem); return _mem; } private: - DynArray( const DynArray& ); // not supported - void operator=( const DynArray& ); // not supported + 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 ); + 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 - if ( _mem != _pool ) { + memcpy(newMem, _mem, sizeof(T)*_size); // warning: not using constructors, only works for PODs + if (_mem != _pool) { delete [] _mem; } _mem = newMem; @@ -304,7 +304,7 @@ public: virtual int ItemSize() const = 0; virtual void* Alloc() = 0; - virtual void Free( void* ) = 0; + virtual void Free(void*) = 0; virtual void SetTracked() = 0; virtual void Clear() = 0; }; @@ -324,7 +324,7 @@ public: void Clear() { // Delete the blocks. - while( !_blockPtrs.Empty()) { + while(!_blockPtrs.Empty()) { Block* b = _blockPtrs.Pop(); delete b; } @@ -343,12 +343,12 @@ public: } virtual void* Alloc() { - if ( !_root ) { + if (!_root) { // Need a new block. Block* block = new Block(); - _blockPtrs.Push( block ); + _blockPtrs.Push(block); - for( int i=0; ichunk[i].next = &block->chunk[i+1]; } block->chunk[COUNT-1].next = 0; @@ -358,7 +358,7 @@ public: _root = _root->next; ++_currentAllocs; - if ( _currentAllocs > _maxAllocs ) { + if (_currentAllocs > _maxAllocs) { _maxAllocs = _currentAllocs; } _nAllocs++; @@ -366,21 +366,21 @@ public: return result; } - virtual void Free( void* mem ) { - if ( !mem ) { + virtual void Free(void* mem) { + if (!mem) { return; } --_currentAllocs; - Chunk* chunk = static_cast( mem ); + Chunk* chunk = static_cast(mem); #ifdef DEBUG - memset( chunk, 0xfe, sizeof(Chunk) ); + memset(chunk, 0xfe, sizeof(Chunk)); #endif chunk->next = _root; _root = chunk; } - void Trace( const char* name ) { - 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() ); + void Trace(const char* name) { + 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()); } void SetTracked() { @@ -403,8 +403,8 @@ 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 + MemPoolT(const MemPoolT&); // not supported + void operator=(const MemPoolT&); // not supported union Chunk { Chunk* next; @@ -449,37 +449,37 @@ public: virtual ~XMLVisitor() {} /// Visit a document. - virtual bool VisitEnter( const XMLDocument& /*doc*/ ) { + virtual bool VisitEnter(const XMLDocument& /*doc*/) { return true; } /// Visit a document. - virtual bool VisitExit( const XMLDocument& /*doc*/ ) { + virtual bool VisitExit(const XMLDocument& /*doc*/) { return true; } /// Visit an element. - virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) { + virtual bool VisitEnter(const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/) { return true; } /// Visit an element. - virtual bool VisitExit( const XMLElement& /*element*/ ) { + virtual bool VisitExit(const XMLElement& /*element*/) { return true; } /// Visit a declaration. - virtual bool Visit( const XMLDeclaration& /*declaration*/ ) { + virtual bool Visit(const XMLDeclaration& /*declaration*/) { return true; } /// Visit a text node. - virtual bool Visit( const XMLText& /*text*/ ) { + virtual bool Visit(const XMLText& /*text*/) { return true; } /// Visit a comment node. - virtual bool Visit( const XMLComment& /*comment*/ ) { + virtual bool Visit(const XMLComment& /*comment*/) { return true; } /// Visit an unknown node. - virtual bool Visit( const XMLUnknown& /*unknown*/ ) { + virtual bool Visit(const XMLUnknown& /*unknown*/) { return true; } }; @@ -518,72 +518,72 @@ enum XMLError { class XMLUtil { public: - static const char* SkipWhiteSpace( const char* p ) { - TIXMLASSERT( p ); - while( IsWhiteSpace(*p) ) { + static const char* SkipWhiteSpace(const char* p) { + TIXMLASSERT(p); + while(IsWhiteSpace(*p)) { ++p; } - TIXMLASSERT( p ); + TIXMLASSERT(p); return p; } - static char* SkipWhiteSpace( char* p ) { - return const_cast( SkipWhiteSpace( const_cast(p) ) ); + static char* SkipWhiteSpace(char* p) { + return const_cast(SkipWhiteSpace(const_cast(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(p) ); + static bool IsWhiteSpace(char p) { + return !IsUTF8Continuation(p) && isspace(static_cast(p)); } - inline static bool IsNameStartChar( unsigned char ch ) { - if ( ch >= 128 ) { + inline static bool IsNameStartChar(unsigned char ch) { + if (ch >= 128) { // This is a heuristic guess in attempt to not implement Unicode-aware isalpha() return true; } - if ( isalpha( ch ) ) { + if (isalpha(ch)) { return true; } return ch == ':' || ch == '_'; } - inline static bool IsNameChar( unsigned char ch ) { - return IsNameStartChar( ch ) - || isdigit( ch ) + inline static bool IsNameChar(unsigned char ch) { + return IsNameStartChar(ch) + || isdigit(ch) || ch == '.' || ch == '-'; } - inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) { - if ( p == q ) { + inline static bool StringEqual(const char* p, const char* q, int nChar=INT_MAX) { + if (p == q) { return true; } - return strncmp( p, q, nChar ) == 0; + return strncmp(p, q, nChar) == 0; } - inline static bool IsUTF8Continuation( char p ) { - return ( p & 0x80 ) != 0; + inline static bool IsUTF8Continuation(char p) { + return (p & 0x80) != 0; } - static const char* ReadBOM( const char* p, bool* hasBOM ); + static const char* ReadBOM(const char* p, bool* hasBOM); // p is the starting location, // the UTF-8 value of the entity will be placed in value, and length filled in. - static const char* GetCharacterRef( const char* p, char* value, int* length ); - static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); + static const char* GetCharacterRef(const char* p, char* value, int* length); + static void ConvertUTF32ToUTF8(unsigned long input, char* output, int* length); // converts primitive types to strings - static void ToStr( int v, char* buffer, int bufferSize ); - static void ToStr( unsigned v, char* buffer, int bufferSize ); - 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(int v, char* buffer, int bufferSize); + static void ToStr(unsigned v, char* buffer, int bufferSize); + 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); // converts strings to primitive types - static bool ToInt( const char* str, int* value ); - static bool ToUnsigned( const char* str, unsigned* value ); - 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 ToInt(const char* str, int* value); + static bool ToUnsigned(const char* str, unsigned* value); + static bool ToBool(const char* str, bool* value); + static bool ToFloat(const char* str, float* value); + static bool ToDouble(const char* str, double* value); }; @@ -602,7 +602,7 @@ public: A Document can contain: Element (container or leaf) Comment (leaf) Unknown (leaf) - Declaration( leaf ) + Declaration(leaf) An Element can contain: Element (container or leaf) Text (leaf) @@ -620,12 +620,12 @@ public: /// Get the XMLDocument that owns this XMLNode. const XMLDocument* GetDocument() const { - TIXMLASSERT( _document ); + TIXMLASSERT(_document); return _document; } /// Get the XMLDocument that owns this XMLNode. XMLDocument* GetDocument() { - TIXMLASSERT( _document ); + TIXMLASSERT(_document); return _document; } @@ -687,7 +687,7 @@ public: /** Set the Value of an XML node. @sa Value() */ - void SetValue( const char* val, bool staticMem=false ); + void SetValue(const char* val, bool staticMem=false); /// Get the parent of this node on the DOM. const XMLNode* Parent() const { @@ -715,10 +715,10 @@ public: /** Get the first child element, or optionally the first child element with the specified name. */ - const XMLElement* FirstChildElement( const char* name = 0 ) const; + const XMLElement* FirstChildElement(const char* name = 0) const; - XMLElement* FirstChildElement( const char* name = 0 ) { - return const_cast(const_cast(this)->FirstChildElement( name )); + XMLElement* FirstChildElement(const char* name = 0) { + return const_cast(const_cast(this)->FirstChildElement(name)); } /// Get the last child node, or null if none exists. @@ -733,10 +733,10 @@ public: /** Get the last child element or optionally the last child element with the specified name. */ - const XMLElement* LastChildElement( const char* name = 0 ) const; + const XMLElement* LastChildElement(const char* name = 0) const; - XMLElement* LastChildElement( const char* name = 0 ) { - return const_cast(const_cast(this)->LastChildElement(name) ); + XMLElement* LastChildElement(const char* name = 0) { + return const_cast(const_cast(this)->LastChildElement(name)); } /// Get the previous (left) sibling node of this node. @@ -749,10 +749,10 @@ public: } /// Get the previous (left) sibling element of this node, with an optionally supplied name. - const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ; + const XMLElement* PreviousSiblingElement(const char* name = 0) const ; - XMLElement* PreviousSiblingElement( const char* name = 0 ) { - return const_cast(const_cast(this)->PreviousSiblingElement( name ) ); + XMLElement* PreviousSiblingElement(const char* name = 0) { + return const_cast(const_cast(this)->PreviousSiblingElement(name)); } /// Get the next (right) sibling node of this node. @@ -765,10 +765,10 @@ public: } /// Get the next (right) sibling element of this node, with an optionally supplied name. - const XMLElement* NextSiblingElement( const char* name = 0 ) const; + const XMLElement* NextSiblingElement(const char* name = 0) const; - XMLElement* NextSiblingElement( const char* name = 0 ) { - return const_cast(const_cast(this)->NextSiblingElement( name ) ); + XMLElement* NextSiblingElement(const char* name = 0) { + return const_cast(const_cast(this)->NextSiblingElement(name)); } /** @@ -778,10 +778,10 @@ public: Returns the addThis argument or 0 if the node does not belong to the same document. */ - XMLNode* InsertEndChild( XMLNode* addThis ); + XMLNode* InsertEndChild(XMLNode* addThis); - XMLNode* LinkEndChild( XMLNode* addThis ) { - return InsertEndChild( addThis ); + XMLNode* LinkEndChild(XMLNode* addThis) { + return InsertEndChild(addThis); } /** Add a child node as the first (left) child. @@ -790,7 +790,7 @@ public: 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. If the child node is already part of the document, @@ -799,7 +799,7 @@ public: 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); /** Delete all the children of this node. @@ -809,7 +809,7 @@ public: /** Delete a child of this node. */ - void DeleteChild( XMLNode* node ); + void DeleteChild(XMLNode* node); /** Make a copy of this node, but not its children. @@ -820,7 +820,7 @@ public: Note: if called on a XMLDocument, this will return null. */ - virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0; + virtual XMLNode* ShallowClone(XMLDocument* document) const = 0; /** Test if 2 nodes are the same, but don't test children. @@ -828,7 +828,7 @@ public: Note: if called on a XMLDocument, this will return false. */ - virtual bool ShallowEqual( const XMLNode* compare ) const = 0; + virtual bool ShallowEqual(const XMLNode* compare) const = 0; /** Accept a hierarchical visit of the nodes in the TinyXML-2 DOM. Every node in the XML tree will be conditionally visited and the host will be called back @@ -848,17 +848,17 @@ public: An example of using Accept(): @verbatim XMLPrinter printer; - tinyxmlDoc.Accept( &printer ); + tinyxmlDoc.Accept(&printer); const char* xmlcstr = printer.CStr(); @endverbatim */ - virtual bool Accept( XMLVisitor* visitor ) const = 0; + virtual bool Accept(XMLVisitor* visitor) const = 0; protected: - XMLNode( XMLDocument* ); + XMLNode(XMLDocument*); virtual ~XMLNode(); - virtual char* ParseDeep( char*, StrPair* ); + virtual char* ParseDeep(char*, StrPair*); XMLDocument* _document; XMLNode* _parent; @@ -872,12 +872,12 @@ protected: private: MemPool* _memPool; - void Unlink( XMLNode* child ); - static void DeleteNode( XMLNode* node ); - void InsertChildPreamble( XMLNode* insertThis ) const; + 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 + XMLNode(const XMLNode&); // not supported + XMLNode& operator=(const XMLNode&); // not supported }; @@ -898,7 +898,7 @@ class TINYXML2_LIB XMLText : public XMLNode friend class XMLBase; friend class XMLDocument; public: - virtual bool Accept( XMLVisitor* visitor ) const; + virtual bool Accept(XMLVisitor* visitor) const; virtual XMLText* ToText() { return this; @@ -908,7 +908,7 @@ public: } /// Declare whether this should be CDATA or standard text. - void SetCData( bool isCData ) { + void SetCData(bool isCData) { _isCData = isCData; } /// Returns true if this is a CDATA text element. @@ -916,20 +916,20 @@ public: return _isCData; } - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + virtual XMLNode* ShallowClone(XMLDocument* document) const; + virtual bool ShallowEqual(const XMLNode* compare) const; protected: - XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {} + XMLText(XMLDocument* doc) : XMLNode(doc), _isCData(false) {} virtual ~XMLText() {} - char* ParseDeep( char*, StrPair* endTag ); + char* ParseDeep(char*, StrPair* endTag); private: bool _isCData; - XMLText( const XMLText& ); // not supported - XMLText& operator=( const XMLText& ); // not supported + XMLText(const XMLText&); // not supported + XMLText& operator=(const XMLText&); // not supported }; @@ -945,20 +945,20 @@ public: return this; } - virtual bool Accept( XMLVisitor* visitor ) const; + virtual bool Accept(XMLVisitor* visitor) const; - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + virtual XMLNode* ShallowClone(XMLDocument* document) const; + virtual bool ShallowEqual(const XMLNode* compare) const; protected: - XMLComment( XMLDocument* doc ); + XMLComment(XMLDocument* doc); virtual ~XMLComment(); - char* ParseDeep( char*, StrPair* endTag ); + char* ParseDeep(char*, StrPair* endTag); private: - XMLComment( const XMLComment& ); // not supported - XMLComment& operator=( const XMLComment& ); // not supported + XMLComment(const XMLComment&); // not supported + XMLComment& operator=(const XMLComment&); // not supported }; @@ -984,20 +984,20 @@ public: return this; } - virtual bool Accept( XMLVisitor* visitor ) const; + virtual bool Accept(XMLVisitor* visitor) const; - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + virtual XMLNode* ShallowClone(XMLDocument* document) const; + virtual bool ShallowEqual(const XMLNode* compare) const; protected: - XMLDeclaration( XMLDocument* doc ); + XMLDeclaration(XMLDocument* doc); virtual ~XMLDeclaration(); - char* ParseDeep( char*, StrPair* endTag ); + char* ParseDeep(char*, StrPair* endTag); private: - XMLDeclaration( const XMLDeclaration& ); // not supported - XMLDeclaration& operator=( const XMLDeclaration& ); // not supported + XMLDeclaration(const XMLDeclaration&); // not supported + XMLDeclaration& operator=(const XMLDeclaration&); // not supported }; @@ -1019,20 +1019,20 @@ public: return this; } - virtual bool Accept( XMLVisitor* visitor ) const; + virtual bool Accept(XMLVisitor* visitor) const; - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + virtual XMLNode* ShallowClone(XMLDocument* document) const; + virtual bool ShallowEqual(const XMLNode* compare) const; protected: - XMLUnknown( XMLDocument* doc ); + XMLUnknown(XMLDocument* doc); virtual ~XMLUnknown(); - char* ParseDeep( char*, StrPair* endTag ); + char* ParseDeep(char*, StrPair* endTag); private: - XMLUnknown( const XMLUnknown& ); // not supported - XMLUnknown& operator=( const XMLUnknown& ); // not supported + XMLUnknown(const XMLUnknown&); // not supported + XMLUnknown& operator=(const XMLUnknown&); // not supported }; @@ -1064,31 +1064,31 @@ public: */ int IntValue() const { int i=0; - QueryIntValue( &i ); + QueryIntValue(&i); return i; } /// Query as an unsigned integer. See IntValue() unsigned UnsignedValue() const { unsigned i=0; - QueryUnsignedValue( &i ); + QueryUnsignedValue(&i); return i; } /// Query as a boolean. See IntValue() bool BoolValue() const { bool b=false; - QueryBoolValue( &b ); + QueryBoolValue(&b); return b; } /// Query as a double. See IntValue() double DoubleValue() const { double d=0; - QueryDoubleValue( &d ); + QueryDoubleValue(&d); return d; } /// Query as a float. See IntValue() float FloatValue() const { float f=0; - QueryFloatValue( &f ); + QueryFloatValue(&f); return f; } @@ -1096,40 +1096,40 @@ public: in the provided parameter. The function will return XML_NO_ERROR on success, and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful. */ - XMLError QueryIntValue( int* value ) const; + XMLError QueryIntValue(int* value) const; /// See QueryIntValue - XMLError QueryUnsignedValue( unsigned int* value ) const; + XMLError QueryUnsignedValue(unsigned int* value) const; /// See QueryIntValue - XMLError QueryBoolValue( bool* value ) const; + XMLError QueryBoolValue(bool* value) const; /// See QueryIntValue - XMLError QueryDoubleValue( double* value ) const; + XMLError QueryDoubleValue(double* value) const; /// See QueryIntValue - XMLError QueryFloatValue( float* value ) const; + XMLError QueryFloatValue(float* value) const; /// Set the attribute to a string value. - void SetAttribute( const char* value ); + void SetAttribute(const char* value); /// Set the attribute to value. - void SetAttribute( int value ); + void SetAttribute(int value); /// Set the attribute to value. - void SetAttribute( unsigned value ); + void SetAttribute(unsigned value); /// Set the attribute to value. - void SetAttribute( bool value ); + void SetAttribute(bool value); /// Set the attribute to value. - void SetAttribute( double value ); + void SetAttribute(double value); /// Set the attribute to value. - void SetAttribute( float value ); + void SetAttribute(float value); private: enum { BUF_SIZE = 200 }; - XMLAttribute() : _next( 0 ), _memPool( 0 ) {} + XMLAttribute() : _next(0), _memPool(0) {} virtual ~XMLAttribute() {} - XMLAttribute( const XMLAttribute& ); // not supported - void operator=( const XMLAttribute& ); // not supported - void SetName( const char* name ); + XMLAttribute(const XMLAttribute&); // not supported + void operator=(const XMLAttribute&); // not supported + void SetName(const char* name); - char* ParseDeep( char* p, bool processEntities ); + char* ParseDeep(char* p, bool processEntities); mutable StrPair _name; mutable StrPair _value; @@ -1152,8 +1152,8 @@ public: return Value(); } /// Set the name of the element. - void SetName( const char* str, bool staticMem=false ) { - SetValue( str, staticMem ); + void SetName(const char* str, bool staticMem=false) { + SetValue(str, staticMem); } virtual XMLElement* ToElement() { @@ -1162,14 +1162,14 @@ public: virtual const XMLElement* ToElement() const { return this; } - virtual bool Accept( XMLVisitor* visitor ) const; + virtual bool Accept(XMLVisitor* visitor) const; /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. For example: @verbatim - const char* value = ele->Attribute( "foo" ); + const char* value = ele->Attribute("foo"); @endverbatim The 'value' parameter is normally null. However, if specified, @@ -1177,55 +1177,55 @@ public: match. This allow you to write code: @verbatim - if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar(); + if (ele->Attribute("foo", "bar")) callFooIsBar(); @endverbatim rather than: @verbatim - if ( ele->Attribute( "foo" ) ) { - if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar(); + if (ele->Attribute("foo")) { + if (strcmp(ele->Attribute("foo"), "bar") == 0) callFooIsBar(); } @endverbatim */ - const char* Attribute( const char* name, const char* value=0 ) const; + const char* Attribute(const char* name, const char* value=0) const; /** Functions the same as Attribute(), but returns the result as a std::string. */ - std::string StrAttribute( const char* name, const char* value=0 ) const; + std::string StrAttribute(const char* name, const char* value=0) const; /** Given an attribute name, IntAttribute() returns the value of the attribute interpreted as an integer. 0 will be returned if there is an error. For a method with error checking, see QueryIntAttribute() */ - int IntAttribute( const char* name ) const { + int IntAttribute(const char* name) const { int i=0; - QueryIntAttribute( name, &i ); + QueryIntAttribute(name, &i); return i; } /// See IntAttribute() - unsigned UnsignedAttribute( const char* name ) const { + unsigned UnsignedAttribute(const char* name) const { unsigned i=0; - QueryUnsignedAttribute( name, &i ); + QueryUnsignedAttribute(name, &i); return i; } /// See IntAttribute() - bool BoolAttribute( const char* name ) const { + bool BoolAttribute(const char* name) const { bool b=false; - QueryBoolAttribute( name, &b ); + QueryBoolAttribute(name, &b); return b; } /// See IntAttribute() - double DoubleAttribute( const char* name ) const { + double DoubleAttribute(const char* name) const { double d=0; - QueryDoubleAttribute( name, &d ); + QueryDoubleAttribute(name, &d); return d; } /// See IntAttribute() - float FloatAttribute( const char* name ) const { + float FloatAttribute(const char* name) const { float f=0; - QueryFloatAttribute( name, &f ); + QueryFloatAttribute(name, &f); return f; } @@ -1239,47 +1239,47 @@ public: @verbatim int value = 10; - 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 */ - XMLError QueryIntAttribute( const char* name, int* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { + XMLError QueryIntAttribute(const char* name, int* value) const { + const XMLAttribute* a = FindAttribute(name); + if (!a) { return XML_NO_ATTRIBUTE; } - return a->QueryIntValue( value ); + return a->QueryIntValue(value); } /// See QueryIntAttribute() - XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { + XMLError QueryUnsignedAttribute(const char* name, unsigned int* value) const { + const XMLAttribute* a = FindAttribute(name); + if (!a) { return XML_NO_ATTRIBUTE; } - return a->QueryUnsignedValue( value ); + return a->QueryUnsignedValue(value); } /// See QueryIntAttribute() - XMLError QueryBoolAttribute( const char* name, bool* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { + XMLError QueryBoolAttribute(const char* name, bool* value) const { + const XMLAttribute* a = FindAttribute(name); + if (!a) { return XML_NO_ATTRIBUTE; } - return a->QueryBoolValue( value ); + return a->QueryBoolValue(value); } /// See QueryIntAttribute() - XMLError QueryDoubleAttribute( const char* name, double* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { + XMLError QueryDoubleAttribute(const char* name, double* value) const { + const XMLAttribute* a = FindAttribute(name); + if (!a) { return XML_NO_ATTRIBUTE; } - return a->QueryDoubleValue( value ); + return a->QueryDoubleValue(value); } /// See QueryIntAttribute() - XMLError QueryFloatAttribute( const char* name, float* value ) const { - const XMLAttribute* a = FindAttribute( name ); - if ( !a ) { + XMLError QueryFloatAttribute(const char* name, float* value) const { + const XMLAttribute* a = FindAttribute(name); + if (!a) { return XML_NO_ATTRIBUTE; } - return a->QueryFloatValue( value ); + return a->QueryFloatValue(value); } @@ -1297,71 +1297,71 @@ public: @verbatim int value = 10; - QueryAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 + QueryAttribute("foo", &value); // if "foo" isn't found, value will still be 10 @endverbatim */ - int QueryAttribute( const char* name, int* value ) const { - return QueryIntAttribute( name, value ); + int QueryAttribute(const char* name, int* value) const { + return QueryIntAttribute(name, value); } - int QueryAttribute( const char* name, unsigned int* value ) const { - return QueryUnsignedAttribute( name, value ); + int QueryAttribute(const char* name, unsigned int* value) const { + return QueryUnsignedAttribute(name, value); } - int QueryAttribute( const char* name, bool* value ) const { - return QueryBoolAttribute( name, value ); + int QueryAttribute(const char* name, bool* value) const { + return QueryBoolAttribute(name, value); } - int QueryAttribute( const char* name, double* value ) const { - return QueryDoubleAttribute( name, value ); + int QueryAttribute(const char* name, double* value) const { + return QueryDoubleAttribute(name, value); } - int QueryAttribute( const char* name, float* value ) const { - return QueryFloatAttribute( name, value ); + int QueryAttribute(const char* name, float* value) const { + return QueryFloatAttribute(name, value); } /// Sets the named attribute to value. - void SetAttribute( const char* name, const char* value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); + void SetAttribute(const char* name, const char* value) { + XMLAttribute* a = FindOrCreateAttribute(name); + a->SetAttribute(value); } /// Sets the named attribute to value. - void SetAttribute( const char* name, int value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); + void SetAttribute(const char* name, int value) { + XMLAttribute* a = FindOrCreateAttribute(name); + a->SetAttribute(value); } /// Sets the named attribute to value. - void SetAttribute( const char* name, unsigned value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); + void SetAttribute(const char* name, unsigned 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 ); - a->SetAttribute( value ); + void SetAttribute(const char* name, bool value) { + XMLAttribute* a = FindOrCreateAttribute(name); + a->SetAttribute(value); } /// Sets the named attribute to value. - void SetAttribute( const char* name, double value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); + void SetAttribute(const char* name, double value) { + XMLAttribute* a = FindOrCreateAttribute(name); + a->SetAttribute(value); } /// Sets the named attribute to value. - void SetAttribute( const char* name, float value ) { - XMLAttribute* a = FindOrCreateAttribute( name ); - a->SetAttribute( value ); + void SetAttribute(const char* name, float value) { + XMLAttribute* a = FindOrCreateAttribute(name); + a->SetAttribute(value); } /** Delete an attribute. */ - void DeleteAttribute( const char* name ); + void DeleteAttribute(const char* name); /// Return the first attribute in the list. const XMLAttribute* FirstAttribute() const { return _rootAttribute; } /// Query a specific attribute in the list. - const XMLAttribute* FindAttribute( const char* name ) const; + const XMLAttribute* FindAttribute(const char* name) const; /** Convenience function for easy access to the text inside an element. Although easy and concise, GetText() is limited compared to getting the XMLText child @@ -1403,7 +1403,7 @@ public: This is a convenient method for setting the text of simple contained text: @verbatim This is text - fooElement->SetText( "Hullaballoo!" ); + fooElement->SetText("Hullaballoo!"); Hullaballoo! @endverbatim @@ -1427,17 +1427,17 @@ public: Hullaballoo! @endverbatim */ - void SetText( const char* inText ); + void SetText(const char* inText); /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( int value ); + void SetText(int value); /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( unsigned value ); + void SetText(unsigned value); /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( bool value ); + void SetText(bool value); /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( double value ); + void SetText(double value); /// Convenience method for setting text inside an element. See SetText() for important limitations. - void SetText( float value ); + void SetText(float value); /** Convenience method to query the value of a child text node. This is probably best @@ -1455,25 +1455,25 @@ public: @verbatim int x = 0; float y = 0; // types of x and y are contrived for example - const XMLElement* xElement = pointElement->FirstChildElement( "x" ); - const XMLElement* yElement = pointElement->FirstChildElement( "y" ); - xElement->QueryIntText( &x ); - yElement->QueryFloatText( &y ); + const XMLElement* xElement = pointElement->FirstChildElement("x"); + const XMLElement* yElement = pointElement->FirstChildElement("y"); + xElement->QueryIntText(&x); + yElement->QueryFloatText(&y); @endverbatim @returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted to the requested type, and XML_NO_TEXT_NODE if there is no child text to query. */ - XMLError QueryIntText( int* ival ) const; + XMLError QueryIntText(int* ival) const; /// See QueryIntText() - XMLError QueryUnsignedText( unsigned* uval ) const; + XMLError QueryUnsignedText(unsigned* uval) const; /// See QueryIntText() - XMLError QueryBoolText( bool* bval ) const; + XMLError QueryBoolText(bool* bval) const; /// See QueryIntText() - XMLError QueryDoubleText( double* dval ) const; + XMLError QueryDoubleText(double* dval) const; /// See QueryIntText() - XMLError QueryFloatText( float* fval ) const; + XMLError QueryFloatText(float* fval) const; // internal: enum { @@ -1484,25 +1484,25 @@ public: int ClosingType() const { return _closingType; } - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + virtual XMLNode* ShallowClone(XMLDocument* document) const; + virtual bool ShallowEqual(const XMLNode* compare) const; protected: - char* ParseDeep( char* p, StrPair* endTag ); + char* ParseDeep(char* p, StrPair* endTag); private: - XMLElement( XMLDocument* doc ); + XMLElement(XMLDocument* doc); virtual ~XMLElement(); - XMLElement( const XMLElement& ); // not supported - void operator=( const XMLElement& ); // not supported + XMLElement(const XMLElement&); // not supported + void operator=(const XMLElement&); // not supported - XMLAttribute* FindAttribute( const char* name ) { - return const_cast(const_cast(this)->FindAttribute( name )); + XMLAttribute* FindAttribute(const char* name) { + return const_cast(const_cast(this)->FindAttribute(name)); } - XMLAttribute* FindOrCreateAttribute( const char* name ); - //void LinkAttribute( XMLAttribute* attrib ); - char* ParseAttributes( char* p ); - static void DeleteAttribute( XMLAttribute* attribute ); + XMLAttribute* FindOrCreateAttribute(const char* name); + //void LinkAttribute(XMLAttribute* attrib); + char* ParseAttributes(char* p); + static void DeleteAttribute(XMLAttribute* attribute); enum { BUF_SIZE = 200 }; int _closingType; @@ -1529,15 +1529,15 @@ class TINYXML2_LIB XMLDocument : public XMLNode friend class XMLElement; public: /// constructor - XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE ); + XMLDocument(bool processEntities = true, Whitespace = PRESERVE_WHITESPACE); ~XMLDocument(); virtual XMLDocument* ToDocument() { - TIXMLASSERT( this == _document ); + TIXMLASSERT(this == _document); return this; } virtual const XMLDocument* ToDocument() const { - TIXMLASSERT( this == _document ); + TIXMLASSERT(this == _document); return this; } @@ -1551,14 +1551,14 @@ public: specified, TinyXML-2 will assume 'xml' points to a null terminated string. */ - XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) ); + XMLError Parse(const char* xml, size_t nBytes=(size_t)(-1)); /** Load an XML file from disk. 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 @@ -1571,14 +1571,14 @@ public: Returns XML_NO_ERROR (0) on success, or an errorID. */ - XMLError LoadFile( FILE* ); + XMLError LoadFile(FILE*); /** Save the XML file to disk. Returns XML_NO_ERROR (0) on success, or an errorID. */ - XMLError SaveFile( const char* filename, bool compact = false ); + XMLError SaveFile(const char* filename, bool compact = false); /** Save the XML file to disk. You are responsible @@ -1587,7 +1587,7 @@ public: Returns XML_NO_ERROR (0) on success, or an errorID. */ - XMLError SaveFile( FILE* fp, bool compact = false ); + XMLError SaveFile(FILE* fp, bool compact = false); bool ProcessEntities() const { return _processEntities; @@ -1604,7 +1604,7 @@ public: } /** Sets whether to write the BOM when writing the file. */ - void SetBOM( bool useBOM ) { + void SetBOM(bool useBOM) { _writeBOM = useBOM; } @@ -1621,38 +1621,38 @@ public: /** Print the Document. If the Printer is not provided, it will print to stdout. If you provide Printer, this can print to a file: @verbatim - XMLPrinter printer( fp ); - doc.Print( &printer ); + XMLPrinter printer(fp); + doc.Print(&printer); @endverbatim Or you can use a printer to print to memory: @verbatim XMLPrinter printer; - doc.Print( &printer ); + doc.Print(&printer); // printer.CStr() has a const char* to the XML @endverbatim */ - void Print( XMLPrinter* streamer=0 ) const; - virtual bool Accept( XMLVisitor* visitor ) const; + void Print(XMLPrinter* streamer=0) const; + virtual bool Accept(XMLVisitor* visitor) const; /** Create a new Element associated with this Document. The memory for the Element is managed by the Document. */ - XMLElement* NewElement( const char* name ); + XMLElement* NewElement(const char* name); /** Create a new Comment associated with this Document. The memory for the Comment is managed by the Document. */ - XMLComment* NewComment( const char* comment ); + XMLComment* NewComment(const char* comment); /** Create a new Text associated with this Document. The memory for the Text is managed by the Document. */ - XMLText* NewText( const char* text ); + XMLText* NewText(const char* text); /** Create a new Declaration associated with this Document. The memory for the object @@ -1664,21 +1664,21 @@ public: @endverbatim */ - XMLDeclaration* NewDeclaration( const char* text=0 ); + XMLDeclaration* NewDeclaration(const char* text=0); /** Create a new Unknown associated with this Document. The memory for the object is managed by the Document. */ - XMLUnknown* NewUnknown( const char* text ); + XMLUnknown* NewUnknown(const char* text); /** Delete a node associated with this document. It will be unlinked from the DOM. */ - void DeleteNode( XMLNode* node ); + void DeleteNode(XMLNode* node); - void SetError( XMLError error, const char* str1, const char* str2 ); + void SetError(XMLError error, const char* str1, const char* str2); /// Return true if there was an error parsing the document. bool Error() const { @@ -1705,18 +1705,18 @@ public: void Clear(); // internal - char* Identify( char* p, XMLNode** node ); + char* Identify(char* p, XMLNode** node); - virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const { + virtual XMLNode* ShallowClone(XMLDocument* /*document*/) const { return 0; } - virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const { + virtual bool ShallowEqual(const XMLNode* /*compare*/) const { return false; } private: - XMLDocument( const XMLDocument& ); // not supported - void operator=( const XMLDocument& ); // not supported + XMLDocument(const XMLDocument&); // not supported + void operator=(const XMLDocument&); // not supported bool _writeBOM; bool _processEntities; @@ -1756,17 +1756,17 @@ private: easy to write a *lot* of code that looks like: @verbatim - XMLElement* root = document.FirstChildElement( "Document" ); - if ( root ) + XMLElement* root = document.FirstChildElement("Document"); + if (root) { - XMLElement* element = root->FirstChildElement( "Element" ); - if ( element ) + XMLElement* element = root->FirstChildElement("Element"); + if (element) { - XMLElement* child = element->FirstChildElement( "Child" ); - if ( child ) + XMLElement* child = element->FirstChildElement("Child"); + if (child) { - XMLElement* child2 = child->NextSiblingElement( "Child" ); - if ( child2 ) + XMLElement* child2 = child->NextSiblingElement("Child"); + if (child2) { // Finally do something useful. @endverbatim @@ -1776,9 +1776,9 @@ private: and correct to use: @verbatim - XMLHandle docHandle( &document ); - XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement(); - if ( child2 ) + XMLHandle docHandle(&document); + XMLElement* child2 = docHandle.FirstChildElement("Document").FirstChildElement("Element").FirstChildElement().NextSiblingElement(); + if (child2) { // do something useful @endverbatim @@ -1796,54 +1796,54 @@ class TINYXML2_LIB XMLHandle { public: /// 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; } /// Create a handle from a node. - XMLHandle( XMLNode& node ) { + XMLHandle(XMLNode& node) { _node = &node; } /// Copy constructor - XMLHandle( const XMLHandle& ref ) { + XMLHandle(const XMLHandle& ref) { _node = ref._node; } /// Assignment - XMLHandle& operator=( const XMLHandle& ref ) { + XMLHandle& operator=(const XMLHandle& ref) { _node = ref._node; return *this; } /// Get the first child of this handle. XMLHandle FirstChild() { - return XMLHandle( _node ? _node->FirstChild() : 0 ); + return XMLHandle(_node ? _node->FirstChild() : 0); } /// Get the first child element of this handle. - XMLHandle FirstChildElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->FirstChildElement( name ) : 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 ); + return XMLHandle(_node ? _node->LastChild() : 0); } /// Get the last child element of this handle. - XMLHandle LastChildElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->LastChildElement( name ) : 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 ); + return XMLHandle(_node ? _node->PreviousSibling() : 0); } /// Get the previous sibling element of this handle. - XMLHandle PreviousSiblingElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 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 ); + return XMLHandle(_node ? _node->NextSibling() : 0); } /// Get the next sibling element of this handle. - XMLHandle NextSiblingElement( const char* name = 0 ) { - return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 ); + XMLHandle NextSiblingElement(const char* name = 0) { + return XMLHandle(_node ? _node->NextSiblingElement(name) : 0); } /// Safe cast to XMLNode. This can return null. @@ -1852,19 +1852,19 @@ public: } /// Safe cast to XMLElement. This can return null. XMLElement* ToElement() { - return ( ( _node == 0 ) ? 0 : _node->ToElement() ); + return ((_node == 0) ? 0 : _node->ToElement()); } /// Safe cast to XMLText. This can return null. XMLText* ToText() { - return ( ( _node == 0 ) ? 0 : _node->ToText() ); + return ((_node == 0) ? 0 : _node->ToText()); } /// Safe cast to XMLUnknown. This can return null. XMLUnknown* ToUnknown() { - return ( ( _node == 0 ) ? 0 : _node->ToUnknown() ); + return ((_node == 0) ? 0 : _node->ToUnknown()); } /// Safe cast to XMLDeclaration. This can return null. XMLDeclaration* ToDeclaration() { - return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() ); + return ((_node == 0) ? 0 : _node->ToDeclaration()); } private: @@ -1879,44 +1879,44 @@ private: class TINYXML2_LIB XMLConstHandle { public: - XMLConstHandle( const XMLNode* node ) { + XMLConstHandle(const XMLNode* node) { _node = node; } - XMLConstHandle( const XMLNode& node ) { + XMLConstHandle(const XMLNode& node) { _node = &node; } - XMLConstHandle( const XMLConstHandle& ref ) { + XMLConstHandle(const XMLConstHandle& ref) { _node = ref._node; } - XMLConstHandle& operator=( const XMLConstHandle& ref ) { + XMLConstHandle& operator=(const XMLConstHandle& ref) { _node = ref._node; return *this; } const XMLConstHandle FirstChild() const { - return XMLConstHandle( _node ? _node->FirstChild() : 0 ); + return XMLConstHandle(_node ? _node->FirstChild() : 0); } - const XMLConstHandle FirstChildElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 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 ); + return XMLConstHandle(_node ? _node->LastChild() : 0); } - const XMLConstHandle LastChildElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->LastChildElement( name ) : 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 ); + return XMLConstHandle(_node ? _node->PreviousSibling() : 0); } - const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 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 ); + return XMLConstHandle(_node ? _node->NextSibling() : 0); } - const XMLConstHandle NextSiblingElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 ); + const XMLConstHandle NextSiblingElement(const char* name = 0) const { + return XMLConstHandle(_node ? _node->NextSiblingElement(name) : 0); } @@ -1924,16 +1924,16 @@ public: return _node; } const XMLElement* ToElement() const { - return ( ( _node == 0 ) ? 0 : _node->ToElement() ); + return ((_node == 0) ? 0 : _node->ToElement()); } const XMLText* ToText() const { - return ( ( _node == 0 ) ? 0 : _node->ToText() ); + return ((_node == 0) ? 0 : _node->ToText()); } const XMLUnknown* ToUnknown() const { - return ( ( _node == 0 ) ? 0 : _node->ToUnknown() ); + return ((_node == 0) ? 0 : _node->ToUnknown()); } const XMLDeclaration* ToDeclaration() const { - return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() ); + return ((_node == 0) ? 0 : _node->ToDeclaration()); } private: @@ -1954,16 +1954,16 @@ private: @verbatim XMLPrinter printer; - doc.Print( &printer ); - SomeFunction( printer.CStr() ); + doc.Print(&printer); + SomeFunction(printer.CStr()); @endverbatim Print to a File You provide the file pointer. @verbatim - XMLPrinter printer( fp ); - doc.Print( &printer ); + XMLPrinter printer(fp); + doc.Print(&printer); @endverbatim Print without a XMLDocument @@ -1977,9 +1977,9 @@ private: an XML document. @verbatim - XMLPrinter printer( fp ); - printer.OpenElement( "foo" ); - printer.PushAttribute( "foo", "bar" ); + XMLPrinter printer(fp); + printer.OpenElement("foo"); + printer.PushAttribute("foo", "bar"); printer.CloseElement(); @endverbatim */ @@ -1992,55 +1992,55 @@ public: If 'compact' is set to true, then output is created 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); virtual ~XMLPrinter() {} /** If streaming, write the BOM and declaration. */ - void PushHeader( bool writeBOM, bool writeDeclaration ); + void PushHeader(bool writeBOM, bool writeDeclaration); /** If streaming, start writing an element. The element must be closed with CloseElement() */ - void OpenElement( const char* name, bool compactMode=false ); + void OpenElement(const char* name, bool compactMode=false); /// If streaming, add an attribute to an open element. - 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, bool value ); - void PushAttribute( const char* name, double value ); + 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, bool value); + void PushAttribute(const char* name, double value); /// If streaming, close the Element. - virtual void CloseElement( bool compactMode=false ); + virtual void CloseElement(bool compactMode=false); /// Add a text node. - void PushText( const char* text, bool cdata=false ); + void PushText(const char* text, bool cdata=false); /// Add a text node from an integer. - void PushText( int value ); + void PushText(int value); /// Add a text node from an unsigned. - void PushText( unsigned value ); + void PushText(unsigned value); /// Add a text node from a bool. - void PushText( bool value ); + void PushText(bool value); /// Add a text node from a float. - void PushText( float value ); + void PushText(float value); /// Add a text node from a double. - void PushText( double value ); + void PushText(double value); /// Add a comment - void PushComment( const char* comment ); + void PushComment(const char* comment); - void PushDeclaration( const char* value ); - void PushUnknown( const char* value ); + void PushDeclaration(const char* value); + void PushUnknown(const char* value); - virtual bool VisitEnter( const XMLDocument& /*doc*/ ); - virtual bool VisitExit( const XMLDocument& /*doc*/ ) { + virtual bool VisitEnter(const XMLDocument& /*doc*/); + virtual bool VisitExit(const XMLDocument& /*doc*/) { return true; } - virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute ); - virtual bool VisitExit( const XMLElement& element ); + virtual bool VisitEnter(const XMLElement& element, const XMLAttribute* attribute); + virtual bool VisitExit(const XMLElement& element); - virtual bool Visit( const XMLText& text ); - virtual bool Visit( const XMLComment& comment ); - virtual bool Visit( const XMLDeclaration& declaration ); - virtual bool Visit( const XMLUnknown& unknown ); + virtual bool Visit(const XMLText& text); + virtual bool Visit(const XMLComment& comment); + virtual bool Visit(const XMLDeclaration& declaration); + virtual bool Visit(const XMLUnknown& unknown); /** If in print to memory mode, return a pointer to @@ -2067,20 +2067,20 @@ public: } protected: - virtual bool CompactMode( const XMLElement& ) { return _compactMode; } + virtual bool CompactMode(const XMLElement&) { return _compactMode; } /** Prints out the space before an element. You may override to change the space and tabs used. A PrintSpace() override should call Print(). */ - virtual void PrintSpace( int depth ); - void Print( const char* format, ... ); + virtual void PrintSpace(int depth); + void Print(const char* format, ...); void SealElementIfJustOpened(); bool _elementJustOpened; DynArray< const char*, 10 > _stack; private: - void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities. + void PrintString(const char*, bool restrictedEntitySet); // prints out, after detecting entities. bool _firstElement; FILE* _fp; -- cgit v1.2.3