1
0
mirror of https://github.com/leethomason/tinyxml2.git synced 2026-07-30 07:32:59 +04:00

Formally set version and testing to C++ 11

This commit is contained in:
Lee Thomason
2026-05-23 17:55:51 -07:00
parent 8224e427b6
commit 96a2dd3a43
5 changed files with 208 additions and 206 deletions
+88 -88
View File
@@ -37,7 +37,7 @@ distribution.
# include <cstdlib>
# include <cstring>
#endif
#include <stdint.h>
#include <cstdint>
#if defined( _DEBUG ) || defined (__DEBUG__)
# ifndef TINYXML2_DEBUG
@@ -143,7 +143,7 @@ public:
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 ) {
@@ -186,8 +186,8 @@ private:
char* _start;
char* _end;
StrPair( const StrPair& other ); // not supported
void operator=( const StrPair& other ); // not supported, use TransferTo()
StrPair( const StrPair& ) = delete;
StrPair& operator=( const StrPair& ) = delete;
};
@@ -289,8 +289,8 @@ public:
}
private:
DynArray( const DynArray& ); // not supported
void operator=( const DynArray& ); // not supported
DynArray( const DynArray& ) = delete;
DynArray& operator=( const DynArray& ) = delete;
void EnsureCapacity( size_t cap ) {
TIXMLASSERT( cap > 0 );
@@ -339,7 +339,7 @@ template< size_t ITEM_SIZE >
class MemPoolT : public MemPool
{
public:
MemPoolT() : _blockPtrs(), _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
MemPoolT() : _blockPtrs(), _root(nullptr), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
~MemPoolT() {
MemPoolT< ITEM_SIZE >::Clear();
}
@@ -350,7 +350,7 @@ public:
Block* lastBlock = _blockPtrs.Pop();
delete lastBlock;
}
_root = 0;
_root = nullptr;
_currentAllocs = 0;
_nAllocs = 0;
_maxAllocs = 0;
@@ -374,11 +374,11 @@ public:
for( size_t 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;
TIXMLASSERT( result != 0 );
TIXMLASSERT( result != nullptr );
_root = _root->next;
++_currentAllocs;
@@ -430,8 +430,8 @@ public:
enum { ITEMS_PER_BLOCK = (4 * 1024) / ITEM_SIZE };
private:
MemPoolT( const MemPoolT& ); // not supported
void operator=( const MemPoolT& ); // not supported
MemPoolT( const MemPoolT& ) = delete;
MemPoolT& operator=( const MemPoolT& ) = delete;
union Item {
Item* next;
@@ -682,46 +682,46 @@ public:
/// 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;
}
// ChildElementCount was originally suggested by msteiger on the sourceforge page for TinyXML and modified by KB1SPH for TinyXML-2.
@@ -775,9 +775,9 @@ 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 = nullptr ) const;
XMLElement* FirstChildElement( const char* name = 0 ) {
XMLElement* FirstChildElement( const char* name = nullptr ) {
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( name ));
}
@@ -793,9 +793,9 @@ 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 = nullptr ) const;
XMLElement* LastChildElement( const char* name = 0 ) {
XMLElement* LastChildElement( const char* name = nullptr ) {
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(name) );
}
@@ -809,9 +809,9 @@ 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 = nullptr ) const ;
XMLElement* PreviousSiblingElement( const char* name = 0 ) {
XMLElement* PreviousSiblingElement( const char* name = nullptr ) {
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( name ) );
}
@@ -825,9 +825,9 @@ 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 = nullptr ) const;
XMLElement* NextSiblingElement( const char* name = 0 ) {
XMLElement* NextSiblingElement( const char* name = nullptr ) {
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( name ) );
}
@@ -969,8 +969,8 @@ private:
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;
XMLNode& operator=( const XMLNode& ) = delete;
};
@@ -1020,8 +1020,8 @@ protected:
private:
bool _isCData;
XMLText( const XMLText& ); // not supported
XMLText& operator=( const XMLText& ); // not supported
XMLText( const XMLText& ) = delete;
XMLText& operator=( const XMLText& ) = delete;
};
@@ -1049,8 +1049,8 @@ protected:
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;
XMLComment& operator=( const XMLComment& ) = delete;
};
@@ -1088,8 +1088,8 @@ protected:
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;
XMLDeclaration& operator=( const XMLDeclaration& ) = delete;
};
@@ -1123,8 +1123,8 @@ protected:
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;
XMLUnknown& operator=( const XMLUnknown& ) = delete;
};
@@ -1238,11 +1238,11 @@ public:
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;
XMLAttribute& operator=( const XMLAttribute& ) = delete;
void SetName( const char* name );
char* ParseDeep( char* p, bool processEntities, int* curLineNumPtr );
@@ -1303,7 +1303,7 @@ public:
}
@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
@@ -1683,8 +1683,8 @@ protected:
private:
XMLElement( XMLDocument* doc );
virtual ~XMLElement();
XMLElement( const XMLElement& ); // not supported
void operator=( const XMLElement& ); // not supported
XMLElement( const XMLElement& ) = delete;
XMLElement& operator=( const XMLElement& ) = delete;
XMLAttribute* FindOrCreateAttribute( const char* name );
char* ParseAttributes( char* p, int* curLineNumPtr );
@@ -1827,7 +1827,7 @@ public:
// printer.CStr() has a const char* to the XML
@endverbatim
*/
void Print( XMLPrinter* streamer=0 ) const;
void Print( XMLPrinter* streamer=nullptr ) const;
virtual bool Accept( XMLVisitor* visitor ) const override;
/**
@@ -1859,7 +1859,7 @@ public:
<?xml version="1.0" encoding="UTF-8"?>
@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
@@ -1927,8 +1927,8 @@ public:
}
private:
XMLDocument( const XMLDocument& ); // not supported
void operator=( const XMLDocument& ); // not supported
XMLDocument( const XMLDocument& ) = delete;
XMLDocument& operator=( const XMLDocument& ) = delete;
bool _writeBOM;
bool _processEntities;
@@ -2068,35 +2068,35 @@ public:
/// 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.
@@ -2105,19 +2105,19 @@ public:
}
/// 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:
@@ -2145,28 +2145,28 @@ public:
}
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 );
}
@@ -2174,16 +2174,16 @@ public:
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:
@@ -2247,7 +2247,7 @@ 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, EscapeAposCharsInAttributes aposInAttributes = ESCAPE_APOS_CHARS_IN_ATTRIBUTES );
XMLPrinter( FILE* file=nullptr, bool compact = false, int depth = 0, EscapeAposCharsInAttributes aposInAttributes = ESCAPE_APOS_CHARS_IN_ATTRIBUTES );
virtual ~XMLPrinter() {}
/** If streaming, write the BOM and declaration. */
@@ -2369,9 +2369,9 @@ private:
DynArray< char, 20 > _buffer;
// Prohibit cloning, intentionally not implemented
XMLPrinter( const XMLPrinter& );
XMLPrinter& operator=( const XMLPrinter& );
// Prohibit cloning
XMLPrinter( const XMLPrinter& ) = delete;
XMLPrinter& operator=( const XMLPrinter& ) = delete;
};