diff --git a/CondFormats/EgammaObjects/src/GBRTree.cxx b/CondFormats/EgammaObjects/src/GBRTree.cxx index 8fc0e1bc3d4a9..c8fd1a8ee9f7e 100644 --- a/CondFormats/EgammaObjects/src/GBRTree.cxx +++ b/CondFormats/EgammaObjects/src/GBRTree.cxx @@ -35,7 +35,7 @@ GBRTree::GBRTree(tinyxml2::XMLElement* binaryTree, double scale, bool isregressi AddNode(root, scale, isregression, useyesnoleaf, adjustboundary); //special case, root node is terminal, create fake intermediate node at root - if (fCutIndices.size()==0) { + if (fCutIndices.empty()) { fCutIndices.push_back(0); fCutVals.push_back(0); fLeftIndices.push_back(0); diff --git a/Utilities/General/interface/tinyxml2.h b/Utilities/General/interface/tinyxml2.h index f91803b16a745..71ac0e2bf4d25 100644 --- a/Utilities/General/interface/tinyxml2.h +++ b/Utilities/General/interface/tinyxml2.h @@ -40,7 +40,7 @@ distribution. # include # include #endif -#include +#include /* TODO: intern strings instead of allocation. @@ -146,7 +146,7 @@ class StrPair COMMENT = NEEDS_NEWLINE_NORMALIZATION }; - StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {} + StrPair() : _flags( 0 ), _start( nullptr ), _end( nullptr ) {} ~StrPair(); void Set( char* start, char* end, int flags ) { @@ -189,8 +189,8 @@ class StrPair char* _start; char* _end; - StrPair( const StrPair& other ); // not supported - void operator=( StrPair& other ); // not supported, use TransferTo() + StrPair( const StrPair& other ) = delete; // not supported + void operator=( StrPair& other ) = delete; // not supported, use TransferTo() }; @@ -294,8 +294,8 @@ class DynArray } private: - DynArray( const DynArray& ); // not supported - void operator=( const DynArray& ); // not supported + DynArray( const DynArray& ) = delete; // not supported + void operator=( const DynArray& ) = delete; // not supported void EnsureCapacity( int cap ) { TIXMLASSERT( cap > 0 ); @@ -344,8 +344,8 @@ template< int ITEM_SIZE > class MemPoolT : public MemPool { public: - MemPoolT() : _blockPtrs(), _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {} - ~MemPoolT() { + MemPoolT() : _blockPtrs(), _root(nullptr), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {} + ~MemPoolT() override { MemPoolT< ITEM_SIZE >::Clear(); } @@ -355,21 +355,21 @@ class MemPoolT : public MemPool Block* lastBlock = _blockPtrs.Pop(); delete lastBlock; } - _root = 0; + _root = nullptr; _currentAllocs = 0; _nAllocs = 0; _maxAllocs = 0; _nUntracked = 0; } - virtual int ItemSize() const { + int ItemSize() const override { return ITEM_SIZE; } int CurrentAllocs() const { return _currentAllocs; } - virtual void* Alloc() { + void* Alloc() override { if ( !_root ) { // Need a new block. Block* block = new Block(); @@ -379,7 +379,7 @@ class MemPoolT : public MemPool for( int i = 0; i < ITEMS_PER_BLOCK - 1; ++i ) { blockItems[i].next = &(blockItems[i + 1]); } - blockItems[ITEMS_PER_BLOCK - 1].next = 0; + blockItems[ITEMS_PER_BLOCK - 1].next = nullptr; _root = blockItems; } Item* const result = _root; @@ -395,7 +395,7 @@ class MemPoolT : public MemPool return result; } - virtual void Free( void* mem ) { + void Free( void* mem ) override { if ( !mem ) { return; } @@ -413,7 +413,7 @@ class MemPoolT : public MemPool ITEM_SIZE, _nAllocs, _blockPtrs.Size() ); } - void SetTracked() { + void SetTracked() override { --_nUntracked; } @@ -435,8 +435,8 @@ class MemPoolT : public MemPool enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE }; private: - MemPoolT( const MemPoolT& ); // not supported - void operator=( const MemPoolT& ); // not supported + MemPoolT( const MemPoolT& ) = delete; // not supported + void operator=( const MemPoolT& ) = delete; // not supported union Item { Item* next; @@ -681,46 +681,46 @@ class TINYXML2_LIB XMLNode /// Safely cast to an Element, or null. virtual XMLElement* ToElement() { - return 0; + return nullptr; } /// Safely cast to Text, or null. virtual XMLText* ToText() { - return 0; + return nullptr; } /// Safely cast to a Comment, or null. virtual XMLComment* ToComment() { - return 0; + return nullptr; } /// Safely cast to a Document, or null. virtual XMLDocument* ToDocument() { - return 0; + return nullptr; } /// Safely cast to a Declaration, or null. virtual XMLDeclaration* ToDeclaration() { - return 0; + return nullptr; } /// Safely cast to an Unknown, or null. virtual XMLUnknown* ToUnknown() { - return 0; + return nullptr; } virtual const XMLElement* ToElement() const { - return 0; + return nullptr; } virtual const XMLText* ToText() const { - return 0; + return nullptr; } virtual const XMLComment* ToComment() const { - return 0; + return nullptr; } virtual const XMLDocument* ToDocument() const { - return 0; + return nullptr; } virtual const XMLDeclaration* ToDeclaration() const { - return 0; + return nullptr; } virtual const XMLUnknown* ToUnknown() const { - return 0; + return nullptr; } /** The meaning of 'value' changes for the specific type. @@ -768,9 +768,9 @@ class TINYXML2_LIB XMLNode /** 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 = nullptr ) const; - XMLElement* FirstChildElement( const char* name = 0 ) { + XMLElement* FirstChildElement( const char* name = nullptr ) { return const_cast(const_cast(this)->FirstChildElement( name )); } @@ -786,9 +786,9 @@ class TINYXML2_LIB XMLNode /** 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 = nullptr ) const; - XMLElement* LastChildElement( const char* name = 0 ) { + XMLElement* LastChildElement( const char* name = nullptr ) { return const_cast(const_cast(this)->LastChildElement(name) ); } @@ -802,9 +802,9 @@ class TINYXML2_LIB XMLNode } /// 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 = nullptr ) const ; - XMLElement* PreviousSiblingElement( const char* name = 0 ) { + XMLElement* PreviousSiblingElement( const char* name = nullptr ) { return const_cast(const_cast(this)->PreviousSiblingElement( name ) ); } @@ -818,9 +818,9 @@ class TINYXML2_LIB XMLNode } /// 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 = nullptr ) const; - XMLElement* NextSiblingElement( const char* name = 0 ) { + XMLElement* NextSiblingElement( const char* name = nullptr ) { return const_cast(const_cast(this)->NextSiblingElement( name ) ); } @@ -962,8 +962,8 @@ class TINYXML2_LIB XMLNode void InsertChildPreamble( XMLNode* insertThis ) const; const XMLElement* ToElementWithName( const char* name ) const; - XMLNode( const XMLNode& ); // not supported - XMLNode& operator=( const XMLNode& ); // not supported + XMLNode( const XMLNode& ) = delete; // not supported + XMLNode& operator=( const XMLNode& ) = delete; // not supported }; @@ -983,12 +983,12 @@ class TINYXML2_LIB XMLText : public XMLNode { friend class XMLDocument; public: - virtual bool Accept( XMLVisitor* visitor ) const; + bool Accept( XMLVisitor* visitor ) const override; - virtual XMLText* ToText() { + XMLText* ToText() override { return this; } - virtual const XMLText* ToText() const { + const XMLText* ToText() const override { return this; } @@ -1001,20 +1001,20 @@ class TINYXML2_LIB XMLText : public XMLNode return _isCData; } - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + XMLNode* ShallowClone( XMLDocument* document ) const override; + bool ShallowEqual( const XMLNode* compare ) const override; protected: XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {} - virtual ~XMLText() {} + ~XMLText() override {} - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ); + char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) override; private: bool _isCData; - XMLText( const XMLText& ); // not supported - XMLText& operator=( const XMLText& ); // not supported + XMLText( const XMLText& ) = delete; // not supported + XMLText& operator=( const XMLText& ) = delete; // not supported }; @@ -1023,27 +1023,27 @@ class TINYXML2_LIB XMLComment : public XMLNode { friend class XMLDocument; public: - virtual XMLComment* ToComment() { + XMLComment* ToComment() override { return this; } - virtual const XMLComment* ToComment() const { + const XMLComment* ToComment() const override { return this; } - virtual bool Accept( XMLVisitor* visitor ) const; + bool Accept( XMLVisitor* visitor ) const override; - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + XMLNode* ShallowClone( XMLDocument* document ) const override; + bool ShallowEqual( const XMLNode* compare ) const override; protected: XMLComment( XMLDocument* doc ); - virtual ~XMLComment(); + ~XMLComment() override; - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr); + char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr) override; private: - XMLComment( const XMLComment& ); // not supported - XMLComment& operator=( const XMLComment& ); // not supported + XMLComment( const XMLComment& ) = delete; // not supported + XMLComment& operator=( const XMLComment& ) = delete; // not supported }; @@ -1062,27 +1062,27 @@ class TINYXML2_LIB XMLDeclaration : public XMLNode { friend class XMLDocument; public: - virtual XMLDeclaration* ToDeclaration() { + XMLDeclaration* ToDeclaration() override { return this; } - virtual const XMLDeclaration* ToDeclaration() const { + const XMLDeclaration* ToDeclaration() const override { return this; } - virtual bool Accept( XMLVisitor* visitor ) const; + bool Accept( XMLVisitor* visitor ) const override; - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + XMLNode* ShallowClone( XMLDocument* document ) const override; + bool ShallowEqual( const XMLNode* compare ) const override; protected: XMLDeclaration( XMLDocument* doc ); - virtual ~XMLDeclaration(); + ~XMLDeclaration() override; - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ); + char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) override; private: - XMLDeclaration( const XMLDeclaration& ); // not supported - XMLDeclaration& operator=( const XMLDeclaration& ); // not supported + XMLDeclaration( const XMLDeclaration& ) = delete; // not supported + XMLDeclaration& operator=( const XMLDeclaration& ) = delete; // not supported }; @@ -1097,27 +1097,27 @@ class TINYXML2_LIB XMLUnknown : public XMLNode { friend class XMLDocument; public: - virtual XMLUnknown* ToUnknown() { + XMLUnknown* ToUnknown() override { return this; } - virtual const XMLUnknown* ToUnknown() const { + const XMLUnknown* ToUnknown() const override { return this; } - virtual bool Accept( XMLVisitor* visitor ) const; + bool Accept( XMLVisitor* visitor ) const override; - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + XMLNode* ShallowClone( XMLDocument* document ) const override; + bool ShallowEqual( const XMLNode* compare ) const override; protected: XMLUnknown( XMLDocument* doc ); - virtual ~XMLUnknown(); + ~XMLUnknown() override; - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ); + char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) override; private: - XMLUnknown( const XMLUnknown& ); // not supported - XMLUnknown& operator=( const XMLUnknown& ); // not supported + XMLUnknown( const XMLUnknown& ) = delete; // not supported + XMLUnknown& operator=( const XMLUnknown& ) = delete; // not supported }; @@ -1221,11 +1221,11 @@ class TINYXML2_LIB XMLAttribute private: enum { BUF_SIZE = 200 }; - XMLAttribute() : _name(), _value(),_parseLineNum( 0 ), _next( 0 ), _memPool( 0 ) {} + XMLAttribute() : _name(), _value(),_parseLineNum( 0 ), _next( nullptr ), _memPool( nullptr ) {} virtual ~XMLAttribute() {} - XMLAttribute( const XMLAttribute& ); // not supported - void operator=( const XMLAttribute& ); // not supported + XMLAttribute( const XMLAttribute& ) = delete; // not supported + void operator=( const XMLAttribute& ) = delete; // not supported void SetName( const char* name ); char* ParseDeep( char* p, bool processEntities, int* curLineNumPtr ); @@ -1255,13 +1255,13 @@ class TINYXML2_LIB XMLElement : public XMLNode SetValue( str, staticMem ); } - virtual XMLElement* ToElement() { + XMLElement* ToElement() override { return this; } - virtual const XMLElement* ToElement() const { + const XMLElement* ToElement() const override { return this; } - virtual bool Accept( XMLVisitor* visitor ) const; + bool Accept( XMLVisitor* visitor ) const override; /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none @@ -1286,7 +1286,7 @@ class TINYXML2_LIB XMLElement : public XMLNode } @endverbatim */ - const char* Attribute( const char* name, const char* value=0 ) const; + const char* Attribute( const char* name, const char* value=nullptr ) const; /** Given an attribute name, IntAttribute() returns the value of the attribute interpreted as an integer. The default @@ -1611,17 +1611,17 @@ class TINYXML2_LIB XMLElement : public XMLNode ElementClosingType ClosingType() const { return _closingType; } - virtual XMLNode* ShallowClone( XMLDocument* document ) const; - virtual bool ShallowEqual( const XMLNode* compare ) const; + XMLNode* ShallowClone( XMLDocument* document ) const override; + bool ShallowEqual( const XMLNode* compare ) const override; protected: - char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ); + char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) override; private: XMLElement( XMLDocument* doc ); - virtual ~XMLElement(); - XMLElement( const XMLElement& ); // not supported - void operator=( const XMLElement& ); // not supported + ~XMLElement() override; + XMLElement( const XMLElement& ) = delete; // not supported + void operator=( const XMLElement& ) = delete; // not supported XMLAttribute* FindOrCreateAttribute( const char* name ); char* ParseAttributes( char* p, int* curLineNumPtr ); @@ -1661,13 +1661,13 @@ class TINYXML2_LIB XMLDocument : public XMLNode public: /// constructor XMLDocument( bool processEntities = true, Whitespace whitespaceMode = PRESERVE_WHITESPACE ); - ~XMLDocument(); + ~XMLDocument() override; - virtual XMLDocument* ToDocument() { + XMLDocument* ToDocument() override { TIXMLASSERT( this == _document ); return this; } - virtual const XMLDocument* ToDocument() const { + const XMLDocument* ToDocument() const override { TIXMLASSERT( this == _document ); return this; } @@ -1763,8 +1763,8 @@ class TINYXML2_LIB XMLDocument : public XMLNode // 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=nullptr ) const; + bool Accept( XMLVisitor* visitor ) const override; /** Create a new Element associated with @@ -1795,7 +1795,7 @@ class TINYXML2_LIB XMLDocument : public XMLNode @endverbatim */ - XMLDeclaration* NewDeclaration( const char* text=0 ); + XMLDeclaration* NewDeclaration( const char* text=nullptr ); /** Create a new Unknown associated with this Document. The memory for the object @@ -1810,7 +1810,7 @@ class TINYXML2_LIB XMLDocument : public XMLNode void DeleteNode( XMLNode* node ); void ClearError() { - SetError(XML_SUCCESS, 0, 0); + SetError(XML_SUCCESS, 0, nullptr); } /// Return true if there was an error parsing the document. @@ -1856,16 +1856,16 @@ class TINYXML2_LIB XMLDocument : public XMLNode // internal void MarkInUse(XMLNode*); - virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const { - return 0; + XMLNode* ShallowClone( XMLDocument* /*document*/ ) const override { + return nullptr; } - virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const { + bool ShallowEqual( const XMLNode* /*compare*/ ) const override { return false; } private: - XMLDocument( const XMLDocument& ); // not supported - void operator=( const XMLDocument& ); // not supported + XMLDocument( const XMLDocument& ) = delete; // not supported + void operator=( const XMLDocument& ) = delete; // not supported bool _writeBOM; bool _processEntities; @@ -2005,35 +2005,35 @@ class TINYXML2_LIB XMLHandle /// Get the first child of this handle. XMLHandle FirstChild() { - return XMLHandle( _node ? _node->FirstChild() : 0 ); + return XMLHandle( _node ? _node->FirstChild() : nullptr ); } /// 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 = nullptr ) { + return XMLHandle( _node ? _node->FirstChildElement( name ) : nullptr ); } /// Get the last child of this handle. XMLHandle LastChild() { - return XMLHandle( _node ? _node->LastChild() : 0 ); + return XMLHandle( _node ? _node->LastChild() : nullptr ); } /// 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 = nullptr ) { + return XMLHandle( _node ? _node->LastChildElement( name ) : nullptr ); } /// Get the previous sibling of this handle. XMLHandle PreviousSibling() { - return XMLHandle( _node ? _node->PreviousSibling() : 0 ); + return XMLHandle( _node ? _node->PreviousSibling() : nullptr ); } /// 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 = nullptr ) { + return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : nullptr ); } /// Get the next sibling of this handle. XMLHandle NextSibling() { - return XMLHandle( _node ? _node->NextSibling() : 0 ); + return XMLHandle( _node ? _node->NextSibling() : nullptr ); } /// 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 = nullptr ) { + return XMLHandle( _node ? _node->NextSiblingElement( name ) : nullptr ); } /// Safe cast to XMLNode. This can return null. @@ -2042,19 +2042,19 @@ class TINYXML2_LIB XMLHandle } /// Safe cast to XMLElement. This can return null. XMLElement* ToElement() { - return ( _node ? _node->ToElement() : 0 ); + return ( _node ? _node->ToElement() : nullptr ); } /// Safe cast to XMLText. This can return null. XMLText* ToText() { - return ( _node ? _node->ToText() : 0 ); + return ( _node ? _node->ToText() : nullptr ); } /// Safe cast to XMLUnknown. This can return null. XMLUnknown* ToUnknown() { - return ( _node ? _node->ToUnknown() : 0 ); + return ( _node ? _node->ToUnknown() : nullptr ); } /// Safe cast to XMLDeclaration. This can return null. XMLDeclaration* ToDeclaration() { - return ( _node ? _node->ToDeclaration() : 0 ); + return ( _node ? _node->ToDeclaration() : nullptr ); } private: @@ -2082,28 +2082,28 @@ class TINYXML2_LIB XMLConstHandle } const XMLConstHandle FirstChild() const { - return XMLConstHandle( _node ? _node->FirstChild() : 0 ); + return XMLConstHandle( _node ? _node->FirstChild() : nullptr ); } - const XMLConstHandle FirstChildElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 ); + const XMLConstHandle FirstChildElement( const char* name = nullptr ) const { + return XMLConstHandle( _node ? _node->FirstChildElement( name ) : nullptr ); } const XMLConstHandle LastChild() const { - return XMLConstHandle( _node ? _node->LastChild() : 0 ); + return XMLConstHandle( _node ? _node->LastChild() : nullptr ); } - const XMLConstHandle LastChildElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 ); + const XMLConstHandle LastChildElement( const char* name = nullptr ) const { + return XMLConstHandle( _node ? _node->LastChildElement( name ) : nullptr ); } const XMLConstHandle PreviousSibling() const { - return XMLConstHandle( _node ? _node->PreviousSibling() : 0 ); + return XMLConstHandle( _node ? _node->PreviousSibling() : nullptr ); } - const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 ); + const XMLConstHandle PreviousSiblingElement( const char* name = nullptr ) const { + return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : nullptr ); } const XMLConstHandle NextSibling() const { - return XMLConstHandle( _node ? _node->NextSibling() : 0 ); + return XMLConstHandle( _node ? _node->NextSibling() : nullptr ); } - const XMLConstHandle NextSiblingElement( const char* name = 0 ) const { - return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 ); + const XMLConstHandle NextSiblingElement( const char* name = nullptr ) const { + return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : nullptr ); } @@ -2111,16 +2111,16 @@ class TINYXML2_LIB XMLConstHandle return _node; } const XMLElement* ToElement() const { - return ( _node ? _node->ToElement() : 0 ); + return ( _node ? _node->ToElement() : nullptr ); } const XMLText* ToText() const { - return ( _node ? _node->ToText() : 0 ); + return ( _node ? _node->ToText() : nullptr ); } const XMLUnknown* ToUnknown() const { - return ( _node ? _node->ToUnknown() : 0 ); + return ( _node ? _node->ToUnknown() : nullptr ); } const XMLDeclaration* ToDeclaration() const { - return ( _node ? _node->ToDeclaration() : 0 ); + return ( _node ? _node->ToDeclaration() : nullptr ); } private: @@ -2179,8 +2179,8 @@ class TINYXML2_LIB XMLPrinter : public XMLVisitor 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 ); - virtual ~XMLPrinter() {} + XMLPrinter( FILE* file=nullptr, bool compact = false, int depth = 0 ); + ~XMLPrinter() override {} /** If streaming, write the BOM and declaration. */ void PushHeader( bool writeBOM, bool writeDeclaration ); @@ -2219,18 +2219,18 @@ class TINYXML2_LIB XMLPrinter : public XMLVisitor void PushDeclaration( const char* value ); void PushUnknown( const char* value ); - virtual bool VisitEnter( const XMLDocument& /*doc*/ ); - virtual bool VisitExit( const XMLDocument& /*doc*/ ) { + bool VisitEnter( const XMLDocument& /*doc*/ ) override; + bool VisitExit( const XMLDocument& /*doc*/ ) override { return true; } - virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute ); - virtual bool VisitExit( const XMLElement& element ); + bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute ) override; + bool VisitExit( const XMLElement& element ) override; - virtual bool Visit( const XMLText& text ); - virtual bool Visit( const XMLComment& comment ); - virtual bool Visit( const XMLDeclaration& declaration ); - virtual bool Visit( const XMLUnknown& unknown ); + bool Visit( const XMLText& text ) override; + bool Visit( const XMLComment& comment ) override; + bool Visit( const XMLDeclaration& declaration ) override; + bool Visit( const XMLUnknown& unknown ) override; /** If in print to memory mode, return a pointer to @@ -2293,8 +2293,8 @@ class TINYXML2_LIB XMLPrinter : public XMLVisitor DynArray< char, 20 > _buffer; // Prohibit cloning, intentionally not implemented - XMLPrinter( const XMLPrinter& ); - XMLPrinter& operator=( const XMLPrinter& ); + XMLPrinter( const XMLPrinter& ) = delete; + XMLPrinter& operator=( const XMLPrinter& ) = delete; }; diff --git a/Utilities/General/src/tinyxml2.cpp b/Utilities/General/src/tinyxml2.cpp index a48893d93d075..4b1b0a86f6775 100644 --- a/Utilities/General/src/tinyxml2.cpp +++ b/Utilities/General/src/tinyxml2.cpp @@ -93,7 +93,7 @@ distribution. #define TIXML_VSNPRINTF vsnprintf static inline int TIXML_VSCPRINTF( const char* format, va_list va ) { - int len = vsnprintf( 0, 0, format, va ); + int len = vsnprintf( nullptr, 0, format, va ); TIXMLASSERT( len >= 0 ); return len; } @@ -161,8 +161,8 @@ void StrPair::TransferTo( StrPair* other ) other->_end = _end; _flags = 0; - _start = 0; - _end = 0; + _start = nullptr; + _end = nullptr; } @@ -172,8 +172,8 @@ void StrPair::Reset() delete [] _start; } _flags = 0; - _start = 0; - _end = 0; + _start = nullptr; + _end = nullptr; } @@ -211,17 +211,17 @@ char* StrPair::ParseText( char* p, const char* endTag, int strFlags, int* curLin ++p; TIXMLASSERT( p ); } - return 0; + return nullptr; } char* StrPair::ParseName( char* p ) { if ( !p || !(*p) ) { - return 0; + return nullptr; } if ( !XMLUtil::IsNameStartChar( *p ) ) { - return 0; + return nullptr; } char* const start = p; @@ -240,7 +240,7 @@ void StrPair::CollapseWhitespace() // Adjusting _start would cause undefined behavior on delete[] TIXMLASSERT( ( _flags & NEEDS_DELETE ) == 0 ); // Trim leading space. - _start = XMLUtil::SkipWhiteSpace( _start, 0 ); + _start = XMLUtil::SkipWhiteSpace( _start, nullptr ); if ( *_start ) { const char* p = _start; // the read pointer @@ -248,7 +248,7 @@ void StrPair::CollapseWhitespace() while( *p ) { if ( XMLUtil::IsWhiteSpace( *p )) { - p = XMLUtil::SkipWhiteSpace( p, 0 ); + p = XMLUtil::SkipWhiteSpace( p, nullptr ); if ( *p == 0 ) { break; // don't write to q; this trims the trailing space. } @@ -311,7 +311,7 @@ const char* StrPair::GetStr() char buf[buflen] = { 0 }; int len = 0; char* adjusted = const_cast( XMLUtil::GetCharacterRef( p, buf, &len ) ); - if ( adjusted == 0 ) { + if ( adjusted == nullptr ) { *q = *p; ++p; ++q; @@ -469,13 +469,13 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) // Hexadecimal. const char* q = p+3; if ( !(*q) ) { - return 0; + return nullptr; } q = strchr( q, SEMICOLON ); if ( !q ) { - return 0; + return nullptr; } TIXMLASSERT( *q == SEMICOLON ); @@ -495,7 +495,7 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) digit = *q - 'A' + 10; } else { - return 0; + return nullptr; } TIXMLASSERT( digit < 16 ); TIXMLASSERT( digit == 0 || mult <= UINT_MAX / digit ); @@ -511,13 +511,13 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) // Decimal. const char* q = p+2; if ( !(*q) ) { - return 0; + return nullptr; } q = strchr( q, SEMICOLON ); if ( !q ) { - return 0; + return nullptr; } TIXMLASSERT( *q == SEMICOLON ); @@ -534,7 +534,7 @@ const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) ucs += digitScaled; } else { - return 0; + return nullptr; } TIXMLASSERT( mult <= UINT_MAX / 10 ); mult *= 10; @@ -661,7 +661,7 @@ char* XMLDocument::Identify( char* p, XMLNode** node ) int const startLine = _parseCurLineNum; p = XMLUtil::SkipWhiteSpace( p, &_parseCurLineNum ); if( !*p ) { - *node = 0; + *node = nullptr; TIXMLASSERT( p ); return p; } @@ -681,7 +681,7 @@ char* XMLDocument::Identify( char* p, XMLNode** node ) TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLUnknown ) ); // use same memory pool TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLDeclaration ) ); // use same memory pool - XMLNode* returnNode = 0; + XMLNode* returnNode = nullptr; if ( XMLUtil::StringEqual( p, xmlHeader, xmlHeaderLen ) ) { returnNode = CreateUnlinkedNode( _commentPool ); returnNode->_parseLineNum = _parseCurLineNum; @@ -741,13 +741,13 @@ bool XMLDocument::Accept( XMLVisitor* visitor ) const XMLNode::XMLNode( XMLDocument* doc ) : _document( doc ), - _parent( 0 ), + _parent( nullptr ), _value(), _parseLineNum( 0 ), - _firstChild( 0 ), _lastChild( 0 ), - _prev( 0 ), _next( 0 ), - _userData( 0 ), - _memPool( 0 ) + _firstChild( nullptr ), _lastChild( nullptr ), + _prev( nullptr ), _next( nullptr ), + _userData( nullptr ), + _memPool( nullptr ) { } @@ -764,7 +764,7 @@ const char* XMLNode::Value() const { // Edge case: XMLDocuments don't have a Value. Return null. if ( this->ToDocument() ) - return 0; + return nullptr; return _value.GetStr(); } @@ -781,7 +781,7 @@ void XMLNode::SetValue( const char* str, bool staticMem ) XMLNode* XMLNode::DeepClone(XMLDocument* target) const { XMLNode* clone = this->ShallowClone(target); - if (!clone) return 0; + if (!clone) return nullptr; for (const XMLNode* child = this->FirstChild(); child; child = child->NextSibling()) { XMLNode* childClone = child->DeepClone(target); @@ -797,7 +797,7 @@ void XMLNode::DeleteChildren() TIXMLASSERT( _lastChild ); DeleteChild( _firstChild ); } - _firstChild = _lastChild = 0; + _firstChild = _lastChild = nullptr; } @@ -819,9 +819,9 @@ void XMLNode::Unlink( XMLNode* child ) if ( child->_next ) { child->_next->_prev = child->_prev; } - child->_next = 0; - child->_prev = 0; - child->_parent = 0; + child->_next = nullptr; + child->_prev = nullptr; + child->_parent = nullptr; } @@ -843,7 +843,7 @@ XMLNode* XMLNode::InsertEndChild( XMLNode* addThis ) TIXMLASSERT( addThis ); if ( addThis->_document != _document ) { TIXMLASSERT( false ); - return 0; + return nullptr; } InsertChildPreamble( addThis ); @@ -854,14 +854,14 @@ XMLNode* XMLNode::InsertEndChild( XMLNode* addThis ) addThis->_prev = _lastChild; _lastChild = addThis; - addThis->_next = 0; + addThis->_next = nullptr; } else { TIXMLASSERT( _firstChild == 0 ); _firstChild = _lastChild = addThis; - addThis->_prev = 0; - addThis->_next = 0; + addThis->_prev = nullptr; + addThis->_next = nullptr; } addThis->_parent = this; return addThis; @@ -873,7 +873,7 @@ XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis ) TIXMLASSERT( addThis ); if ( addThis->_document != _document ) { TIXMLASSERT( false ); - return 0; + return nullptr; } InsertChildPreamble( addThis ); @@ -885,14 +885,14 @@ XMLNode* XMLNode::InsertFirstChild( XMLNode* addThis ) addThis->_next = _firstChild; _firstChild = addThis; - addThis->_prev = 0; + addThis->_prev = nullptr; } else { TIXMLASSERT( _lastChild == 0 ); _firstChild = _lastChild = addThis; - addThis->_prev = 0; - addThis->_next = 0; + addThis->_prev = nullptr; + addThis->_next = nullptr; } addThis->_parent = this; return addThis; @@ -904,14 +904,14 @@ XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ) TIXMLASSERT( addThis ); if ( addThis->_document != _document ) { TIXMLASSERT( false ); - return 0; + return nullptr; } TIXMLASSERT( afterThis ); if ( afterThis->_parent != this ) { TIXMLASSERT( false ); - return 0; + return nullptr; } if ( afterThis == addThis ) { // Current state: BeforeThis -> AddThis -> OneAfterAddThis @@ -921,7 +921,7 @@ XMLNode* XMLNode::InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ) return addThis; } - if ( afterThis->_next == 0 ) { + if ( afterThis->_next == nullptr ) { // The last node or the only node. return InsertEndChild( addThis ); } @@ -945,7 +945,7 @@ const XMLElement* XMLNode::FirstChildElement( const char* name ) const return element; } } - return 0; + return nullptr; } @@ -957,7 +957,7 @@ const XMLElement* XMLNode::LastChildElement( const char* name ) const return element; } } - return 0; + return nullptr; } @@ -969,7 +969,7 @@ const XMLElement* XMLNode::NextSiblingElement( const char* name ) const return element; } } - return 0; + return nullptr; } @@ -981,7 +981,7 @@ const XMLElement* XMLNode::PreviousSiblingElement( const char* name ) const return element; } } - return 0; + return nullptr; } @@ -1006,14 +1006,14 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) XMLDocument::DepthTracker tracker(_document); if (_document->Error()) - return 0; + return nullptr; while( p && *p ) { - XMLNode* node = 0; + XMLNode* node = nullptr; p = _document->Identify( p, &node ); TIXMLASSERT( p ); - if ( node == 0 ) { + if ( node == nullptr ) { break; } @@ -1024,7 +1024,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) if ( !p ) { DeleteNode( node ); if ( !_document->Error() ) { - _document->SetError( XML_ERROR_PARSING, initialLineNum, 0); + _document->SetError( XML_ERROR_PARSING, initialLineNum, nullptr); } break; } @@ -1096,12 +1096,12 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) } InsertEndChild( node ); } - return 0; + return nullptr; } /*static*/ void XMLNode::DeleteNode( XMLNode* node ) { - if ( node == 0 ) { + if ( node == nullptr ) { return; } TIXMLASSERT(node->_document); @@ -1131,16 +1131,16 @@ void XMLNode::InsertChildPreamble( XMLNode* insertThis ) const const XMLElement* XMLNode::ToElementWithName( const char* name ) const { const XMLElement* element = this->ToElement(); - if ( element == 0 ) { - return 0; + if ( element == nullptr ) { + return nullptr; } - if ( name == 0 ) { + if ( name == nullptr ) { return element; } if ( XMLUtil::StringEqual( element->Name(), name ) ) { return element; } - return 0; + return nullptr; } // --------- XMLText ---------- // @@ -1149,7 +1149,7 @@ char* XMLText::ParseDeep( char* p, StrPair*, int* curLineNumPtr ) if ( this->CData() ) { p = _value.ParseText( p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION, curLineNumPtr ); if ( !p ) { - _document->SetError( XML_ERROR_PARSING_CDATA, _parseLineNum, 0 ); + _document->SetError( XML_ERROR_PARSING_CDATA, _parseLineNum, nullptr ); } return p; } @@ -1164,10 +1164,10 @@ char* XMLText::ParseDeep( char* p, StrPair*, int* curLineNumPtr ) return p-1; } if ( !p ) { - _document->SetError( XML_ERROR_PARSING_TEXT, _parseLineNum, 0 ); + _document->SetError( XML_ERROR_PARSING_TEXT, _parseLineNum, nullptr ); } } - return 0; + return nullptr; } @@ -1213,8 +1213,8 @@ char* XMLComment::ParseDeep( char* p, StrPair*, int* curLineNumPtr ) { // Comment parses as text. p = _value.ParseText( p, "-->", StrPair::COMMENT, curLineNumPtr ); - if ( p == 0 ) { - _document->SetError( XML_ERROR_PARSING_COMMENT, _parseLineNum, 0 ); + if ( p == nullptr ) { + _document->SetError( XML_ERROR_PARSING_COMMENT, _parseLineNum, nullptr ); } return p; } @@ -1262,8 +1262,8 @@ char* XMLDeclaration::ParseDeep( char* p, StrPair*, int* curLineNumPtr ) { // Declaration parses as text. p = _value.ParseText( p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION, curLineNumPtr ); - if ( p == 0 ) { - _document->SetError( XML_ERROR_PARSING_DECLARATION, _parseLineNum, 0 ); + if ( p == nullptr ) { + _document->SetError( XML_ERROR_PARSING_DECLARATION, _parseLineNum, nullptr ); } return p; } @@ -1311,7 +1311,7 @@ char* XMLUnknown::ParseDeep( char* p, StrPair*, int* curLineNumPtr ) // Unknown parses as text. p = _value.ParseText( p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION, curLineNumPtr ); if ( !p ) { - _document->SetError( XML_ERROR_PARSING_UNKNOWN, _parseLineNum, 0 ); + _document->SetError( XML_ERROR_PARSING_UNKNOWN, _parseLineNum, nullptr ); } return p; } @@ -1358,19 +1358,19 @@ char* XMLAttribute::ParseDeep( char* p, bool processEntities, int* curLineNumPtr // Parse using the name rules: bug fix, was using ParseText before p = _name.ParseName( p ); if ( !p || !*p ) { - return 0; + return nullptr; } // Skip white space before = p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr ); if ( *p != '=' ) { - return 0; + return nullptr; } ++p; // move up to opening quote p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr ); if ( *p != '\"' && *p != '\'' ) { - return 0; + return nullptr; } char endTag[2] = { *p, 0 }; @@ -1497,7 +1497,7 @@ void XMLAttribute::SetAttribute( float v ) // --------- XMLElement ---------- // XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ), _closingType( OPEN ), - _rootAttribute( 0 ) + _rootAttribute( nullptr ) { } @@ -1519,7 +1519,7 @@ const XMLAttribute* XMLElement::FindAttribute( const char* name ) const return a; } } - return 0; + return nullptr; } @@ -1527,12 +1527,12 @@ const char* XMLElement::Attribute( const char* name, const char* value ) const { const XMLAttribute* a = FindAttribute( name ); if ( !a ) { - return 0; + return nullptr; } if ( !value || XMLUtil::StringEqual( a->Value(), value )) { return a->Value(); } - return 0; + return nullptr; } int XMLElement::IntAttribute(const char* name, int defaultValue) const @@ -1582,7 +1582,7 @@ const char* XMLElement::GetText() const if ( FirstChild() && FirstChild()->ToText() ) { return FirstChild()->Value(); } - return 0; + return nullptr; } @@ -1767,8 +1767,8 @@ float XMLElement::FloatText(float defaultValue) const XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name ) { - XMLAttribute* last = 0; - XMLAttribute* attrib = 0; + XMLAttribute* last = nullptr; + XMLAttribute* attrib = nullptr; for( attrib = _rootAttribute; attrib; last = attrib, attrib = attrib->_next ) { @@ -1795,7 +1795,7 @@ XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name ) void XMLElement::DeleteAttribute( const char* name ) { - XMLAttribute* prev = 0; + XMLAttribute* prev = nullptr; for( XMLAttribute* a=_rootAttribute; a; a=a->_next ) { if ( XMLUtil::StringEqual( name, a->Name() ) ) { if ( prev ) { @@ -1814,14 +1814,14 @@ void XMLElement::DeleteAttribute( const char* name ) char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr ) { - XMLAttribute* prevAttribute = 0; + XMLAttribute* prevAttribute = nullptr; // Read the attributes. while( p ) { p = XMLUtil::SkipWhiteSpace( p, curLineNumPtr ); if ( !(*p) ) { _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, "XMLElement name=%s", Name() ); - return 0; + return nullptr; } // attribute. @@ -1836,7 +1836,7 @@ char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr ) if ( !p || Attribute( attrib->Name() ) ) { DeleteAttribute( attrib ); _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, attrLineNum, "XMLElement name=%s", Name() ); - return 0; + return nullptr; } // There is a minor bug here: if the attribute in the source xml // document is duplicated, it will not be detected and the @@ -1864,8 +1864,8 @@ char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr ) return p+2; // done; sealed element. } else { - _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, 0 ); - return 0; + _document->SetError( XML_ERROR_PARSING_ELEMENT, _parseLineNum, nullptr ); + return nullptr; } } return p; @@ -1873,7 +1873,7 @@ char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr ) void XMLElement::DeleteAttribute( XMLAttribute* attribute ) { - if ( attribute == 0 ) { + if ( attribute == nullptr ) { return; } MemPool* pool = attribute->_memPool; @@ -1910,7 +1910,7 @@ char* XMLElement::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr p = _value.ParseName( p ); if ( _value.Empty() ) { - return 0; + return nullptr; } p = ParseAttributes( p, curLineNumPtr ); @@ -2004,14 +2004,14 @@ const char* XMLDocument::_errorNames[XML_ERROR_COUNT] = { XMLDocument::XMLDocument( bool processEntities, Whitespace whitespaceMode ) : - XMLNode( 0 ), + XMLNode( nullptr ), _writeBOM( false ), _processEntities( processEntities ), _errorID(XML_SUCCESS), _whitespaceMode( whitespaceMode ), _errorStr(), _errorLineNum( 0 ), - _charBuffer( 0 ), + _charBuffer( nullptr ), _parseCurLineNum( 0 ), _parsingDepth(0), _unlinked(), @@ -2057,7 +2057,7 @@ void XMLDocument::Clear() ClearError(); delete [] _charBuffer; - _charBuffer = 0; + _charBuffer = nullptr; _parsingDepth = 0; #if 0 @@ -2212,7 +2212,7 @@ XMLError XMLDocument::LoadFile( FILE* fp ) fseek( fp, 0, SEEK_SET ); if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + SetError( XML_ERROR_FILE_READ_ERROR, 0, nullptr ); return _errorID; } @@ -2220,19 +2220,19 @@ XMLError XMLDocument::LoadFile( FILE* fp ) const long filelength = ftell( fp ); fseek( fp, 0, SEEK_SET ); if ( filelength == -1L ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + SetError( XML_ERROR_FILE_READ_ERROR, 0, nullptr ); return _errorID; } TIXMLASSERT( filelength >= 0 ); if ( !LongFitsIntoSizeTMinusOne<>::Fits( filelength ) ) { // Cannot handle files which won't fit in buffer together with null terminator - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + SetError( XML_ERROR_FILE_READ_ERROR, 0, nullptr ); return _errorID; } if ( filelength == 0 ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); + SetError( XML_ERROR_EMPTY_DOCUMENT, 0, nullptr ); return _errorID; } @@ -2241,7 +2241,7 @@ XMLError XMLDocument::LoadFile( FILE* fp ) _charBuffer = new char[size+1]; size_t read = fread( _charBuffer, 1, size, fp ); if ( read != size ) { - SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + SetError( XML_ERROR_FILE_READ_ERROR, 0, nullptr ); return _errorID; } @@ -2287,7 +2287,7 @@ XMLError XMLDocument::Parse( const char* p, size_t len ) Clear(); if ( len == 0 || !p || !*p ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); + SetError( XML_ERROR_EMPTY_DOCUMENT, 0, nullptr ); return _errorID; } if ( len == (size_t)(-1) ) { @@ -2387,10 +2387,10 @@ void XMLDocument::Parse() p = XMLUtil::SkipWhiteSpace( p, &_parseCurLineNum ); p = const_cast( XMLUtil::ReadBOM( p, &_writeBOM ) ); if ( !*p ) { - SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); + SetError( XML_ERROR_EMPTY_DOCUMENT, 0, nullptr ); return; } - ParseDeep(p, 0, &_parseCurLineNum ); + ParseDeep(p, nullptr, &_parseCurLineNum ); } void XMLDocument::PushDepth() @@ -2787,7 +2787,7 @@ bool XMLPrinter::VisitEnter( const XMLDocument& doc ) bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute ) { - const XMLElement* parentElem = 0; + const XMLElement* parentElem = nullptr; if ( element.Parent() ) { parentElem = element.Parent()->ToElement(); }