summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-08-28 19:18:19 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-08-28 19:18:19 +0300
commit8c7a670b1b6644aafb0fc78bd3039da45e7a7d37 (patch)
tree5561c16c3a5babe4cf6c8fec6d1de0bffe63f2ff /src
parent13d83eaa0e90fb04085f5554cf047206c363d3a7 (diff)
fixes #2038 (Update tinyxml2 to 7.1.0)
Diffstat (limited to 'src')
-rw-r--r--src/mir_core/src/mir_core.def16
-rw-r--r--src/mir_core/src/mir_core64.def16
-rw-r--r--src/mir_core/src/tinyxml2.cpp164
-rw-r--r--src/mir_core/src/tinyxml2.h73
4 files changed, 213 insertions, 56 deletions
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index 242519a0da..4bcb6da163 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1111,7 +1111,7 @@ db_event_edit @1268
?CStr@XMLPrinter@tinyxml2@@QBEPBDXZ @1326 NONAME
?CStrSize@XMLPrinter@tinyxml2@@QBEHXZ @1327 NONAME
?Clear@XMLDocument@tinyxml2@@QAEXXZ @1328 NONAME
-?ClearBuffer@XMLPrinter@tinyxml2@@QAEXXZ @1329 NONAME
+?ClearBuffer@XMLPrinter@tinyxml2@@QAEX_N@Z @1329 NONAME
?ClearError@XMLDocument@tinyxml2@@QAEXXZ @1330 NONAME
?CloseElement@XMLPrinter@tinyxml2@@UAEX_N@Z @1331 NONAME
?ClosingType@XMLElement@tinyxml2@@QBE?AW4ElementClosingType@12@XZ @1332 NONAME
@@ -1435,3 +1435,17 @@ XmlGetChildText @1645
?OnNotify@CCtrlDate@@EAEHHPAUtagNMHDR@@@Z @1650 NONAME
?SetTime@CCtrlDate@@QAEXPAU_SYSTEMTIME@@@Z @1651 NONAME
?SetMinSize@CDlgBase@@QAEXHH@Z @1652 NONAME
+?PushAttribute@XMLPrinter@tinyxml2@@QAEXPBD_K@Z @1653 NONAME
+?PushText@XMLPrinter@tinyxml2@@QAEX_K@Z @1654 NONAME
+?QueryAttribute@XMLElement@tinyxml2@@QBE?AW4XMLError@2@PBDPA_K@Z @1655 NONAME
+?QueryUnsigned64Attribute@XMLElement@tinyxml2@@QBE?AW4XMLError@2@PBDPA_K@Z @1656 NONAME
+?QueryUnsigned64Text@XMLElement@tinyxml2@@QBE?AW4XMLError@2@PA_K@Z @1657 NONAME
+?QueryUnsigned64Value@XMLAttribute@tinyxml2@@QBE?AW4XMLError@2@PA_K@Z @1658 NONAME
+?SetAttribute@XMLAttribute@tinyxml2@@QAEX_K@Z @1659 NONAME
+?SetAttribute@XMLElement@tinyxml2@@QAEXPBD_K@Z @1660 NONAME
+?SetText@XMLElement@tinyxml2@@QAEX_K@Z @1661 NONAME
+?ToStr@XMLUtil@tinyxml2@@SAX_KPADH@Z @1662 NONAME
+?ToUnsigned64@XMLUtil@tinyxml2@@SA_NPBDPA_K@Z @1663 NONAME
+?Unsigned64Attribute@XMLElement@tinyxml2@@QBE_KPBD_K@Z @1664 NONAME
+?Unsigned64Text@XMLElement@tinyxml2@@QBE_K_K@Z @1665 NONAME
+?Unsigned64Value@XMLAttribute@tinyxml2@@QBE_KXZ @1666 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index 8a75cfea10..8f8d58de25 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1111,7 +1111,7 @@ db_event_edit @1268
?CStr@XMLPrinter@tinyxml2@@QEBAPEBDXZ @1326 NONAME
?CStrSize@XMLPrinter@tinyxml2@@QEBAHXZ @1327 NONAME
?Clear@XMLDocument@tinyxml2@@QEAAXXZ @1328 NONAME
-?ClearBuffer@XMLPrinter@tinyxml2@@QEAAXXZ @1329 NONAME
+?ClearBuffer@XMLPrinter@tinyxml2@@QEAAX_N@Z @1329 NONAME
?ClearError@XMLDocument@tinyxml2@@QEAAXXZ @1330 NONAME
?CloseElement@XMLPrinter@tinyxml2@@UEAAX_N@Z @1331 NONAME
?ClosingType@XMLElement@tinyxml2@@QEBA?AW4ElementClosingType@12@XZ @1332 NONAME
@@ -1435,3 +1435,17 @@ XmlGetChildText @1645
?OnNotify@CCtrlDate@@EEAAHHPEAUtagNMHDR@@@Z @1650 NONAME
?SetTime@CCtrlDate@@QEAAXPEAU_SYSTEMTIME@@@Z @1651 NONAME
?SetMinSize@CDlgBase@@QEAAXHH@Z @1652 NONAME
+?PushAttribute@XMLPrinter@tinyxml2@@QEAAXPEBD_K@Z @1653 NONAME
+?PushText@XMLPrinter@tinyxml2@@QEAAX_K@Z @1654 NONAME
+?QueryAttribute@XMLElement@tinyxml2@@QEBA?AW4XMLError@2@PEBDPEA_K@Z @1655 NONAME
+?QueryUnsigned64Attribute@XMLElement@tinyxml2@@QEBA?AW4XMLError@2@PEBDPEA_K@Z @1656 NONAME
+?QueryUnsigned64Text@XMLElement@tinyxml2@@QEBA?AW4XMLError@2@PEA_K@Z @1657 NONAME
+?QueryUnsigned64Value@XMLAttribute@tinyxml2@@QEBA?AW4XMLError@2@PEA_K@Z @1658 NONAME
+?SetAttribute@XMLAttribute@tinyxml2@@QEAAX_K@Z @1659 NONAME
+?SetAttribute@XMLElement@tinyxml2@@QEAAXPEBD_K@Z @1660 NONAME
+?SetText@XMLElement@tinyxml2@@QEAAX_K@Z @1661 NONAME
+?ToStr@XMLUtil@tinyxml2@@SAX_KPEADH@Z @1662 NONAME
+?ToUnsigned64@XMLUtil@tinyxml2@@SA_NPEBDPEA_K@Z @1663 NONAME
+?Unsigned64Attribute@XMLElement@tinyxml2@@QEBA_KPEBD_K@Z @1664 NONAME
+?Unsigned64Text@XMLElement@tinyxml2@@QEBA_K_K@Z @1665 NONAME
+?Unsigned64Value@XMLAttribute@tinyxml2@@QEBA_KXZ @1666 NONAME
diff --git a/src/mir_core/src/tinyxml2.cpp b/src/mir_core/src/tinyxml2.cpp
index d11df4ff0b..5e4b1b22ad 100644
--- a/src/mir_core/src/tinyxml2.cpp
+++ b/src/mir_core/src/tinyxml2.cpp
@@ -45,14 +45,14 @@ distribution.
{
va_list va;
va_start( va, format );
- int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
+ const int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
va_end( va );
return result;
}
static inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va )
{
- int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
+ const int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
return result;
}
@@ -101,9 +101,9 @@ distribution.
#endif
-static const char LINE_FEED = (char)0x0a; // all line endings are normalized to LF
+static const char LINE_FEED = static_cast<char>(0x0a); // all line endings are normalized to LF
static const char LF = LINE_FEED;
-static const char CARRIAGE_RETURN = (char)0x0d; // CR gets filtered out
+static const char CARRIAGE_RETURN = static_cast<char>(0x0d); // CR gets filtered out
static const char CR = CARRIAGE_RETURN;
static const char SINGLE_QUOTE = '\'';
static const char DOUBLE_QUOTE = '\"';
@@ -197,7 +197,7 @@ char* StrPair::ParseText( char* p, const char* endTag, int strFlags, int* curLin
TIXMLASSERT(curLineNumPtr);
char* start = p;
- char endChar = *endTag;
+ const char endChar = *endTag;
size_t length = strlen( endTag );
// Inner loop of text parsing.
@@ -310,7 +310,7 @@ const char* StrPair::GetStr()
const int buflen = 10;
char buf[buflen] = { 0 };
int len = 0;
- char* adjusted = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );
+ const char* adjusted = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );
if ( adjusted == 0 ) {
*q = *p;
++p;
@@ -430,22 +430,22 @@ void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length
switch (*length) {
case 4:
--output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ *output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
//fall through
case 3:
--output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ *output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
//fall through
case 2:
--output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ *output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
input >>= 6;
//fall through
case 1:
--output;
- *output = (char)(input | FIRST_BYTE_MARK[*length]);
+ *output = static_cast<char>(input | FIRST_BYTE_MARK[*length]);
break;
default:
TIXMLASSERT( false );
@@ -582,12 +582,17 @@ void XMLUtil::ToStr( double v, char* buffer, int bufferSize )
}
-void XMLUtil::ToStr(int64_t v, char* buffer, int bufferSize)
+void XMLUtil::ToStr( int64_t v, char* buffer, int bufferSize )
{
// horrible syntax trick to make the compiler happy about %lld
- TIXML_SNPRINTF(buffer, bufferSize, "%lld", (long long)v);
+ TIXML_SNPRINTF(buffer, bufferSize, "%lld", static_cast<long long>(v));
}
+void XMLUtil::ToStr( uint64_t v, char* buffer, int bufferSize )
+{
+ // horrible syntax trick to make the compiler happy about %llu
+ TIXML_SNPRINTF(buffer, bufferSize, "%llu", (long long)v);
+}
bool XMLUtil::ToInt( const char* str, int* value )
{
@@ -612,13 +617,20 @@ bool XMLUtil::ToBool( const char* str, bool* value )
*value = (ival==0) ? false : true;
return true;
}
- if ( StringEqual( str, "true" ) ) {
- *value = true;
- return true;
+ static const char* ñTRUE[] = { "true", "True", "TRUE", 0 };
+ static const char* ñFALSE[] = { "false", "False", "FALSE", 0 };
+
+ for (int i = 0; ñTRUE[i]; ++i) {
+ if (StringEqual(str, ñTRUE[i])) {
+ *value = true;
+ return true;
+ }
}
- else if ( StringEqual( str, "false" ) ) {
- *value = false;
- return true;
+ for (int i = 0; ñFALSE[i]; ++i) {
+ if (StringEqual(str, ñFALSE[i])) {
+ *value = false;
+ return true;
+ }
}
return false;
}
@@ -646,13 +658,23 @@ bool XMLUtil::ToInt64(const char* str, int64_t* value)
{
long long v = 0; // horrible syntax trick to make the compiler happy about %lld
if (TIXML_SSCANF(str, "%lld", &v) == 1) {
- *value = (int64_t)v;
+ *value = static_cast<int64_t>(v);
return true;
}
return false;
}
+bool XMLUtil::ToUnsigned64(const char* str, uint64_t* value) {
+ unsigned long long v = 0; // horrible syntax trick to make the compiler happy about %llu
+ if(TIXML_SSCANF(str, "%llu", &v) == 1) {
+ *value = (uint64_t)v;
+ return true;
+ }
+ return false;
+}
+
+
char* XMLDocument::Identify( char* p, XMLNode** node )
{
TIXMLASSERT( node );
@@ -763,7 +785,7 @@ XMLNode::~XMLNode()
const char* XMLNode::Value() const
{
// Edge case: XMLDocuments don't have a Value. Return null.
- if ( this == nullptr || this->ToDocument() )
+ if ( this->ToDocument() )
return 0;
return _value.GetStr();
}
@@ -1017,7 +1039,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
break;
}
- int initialLineNum = node->_parseLineNum;
+ const int initialLineNum = node->_parseLineNum;
StrPair endTag;
p = node->ParseDeep( p, &endTag, curLineNumPtr );
@@ -1029,7 +1051,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
break;
}
- XMLDeclaration* decl = node->ToDeclaration();
+ const XMLDeclaration* const decl = node->ToDeclaration();
if ( decl ) {
// Declarations are only allowed at document level
//
@@ -1038,7 +1060,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
//
// Optimized due to a security test case. If the first node is
// a declaration, and the last node is a declaration, then only
- // declarations have so far been addded.
+ // declarations have so far been added.
bool wellLocated = false;
if (ToDocument()) {
@@ -1070,7 +1092,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
node->_memPool->SetTracked(); // created and then immediately deleted.
DeleteNode( node );
_document->_bytesParsed = (int)(p-_document->_charBuffer);
- return p;
+ return p;
}
// Handle an end tag returned to this level.
@@ -1375,7 +1397,7 @@ char* XMLAttribute::ParseDeep( char* p, bool processEntities, int* curLineNumPtr
return 0;
}
- char endTag[2] = { *p, 0 };
+ const char endTag[2] = { *p, 0 };
++p; // move past opening quote
p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES, curLineNumPtr );
@@ -1416,6 +1438,15 @@ XMLError XMLAttribute::QueryInt64Value(int64_t* value) const
}
+XMLError XMLAttribute::QueryUnsigned64Value(uint64_t* value) const
+{
+ if(XMLUtil::ToUnsigned64(Value(), value)) {
+ return XML_SUCCESS;
+ }
+ return XML_WRONG_ATTRIBUTE_TYPE;
+}
+
+
XMLError XMLAttribute::QueryBoolValue( bool* value ) const
{
if ( XMLUtil::ToBool( Value(), value )) {
@@ -1478,6 +1509,12 @@ void XMLAttribute::SetAttribute(int64_t v)
_value.SetStr(buf);
}
+void XMLAttribute::SetAttribute(uint64_t v)
+{
+ char buf[BUF_SIZE];
+ XMLUtil::ToStr(v, buf, BUF_SIZE);
+ _value.SetStr(buf);
+}
void XMLAttribute::SetAttribute( bool v )
@@ -1564,6 +1601,13 @@ int64_t XMLElement::Int64Attribute(const char* name, int64_t defaultValue) const
return i;
}
+uint64_t XMLElement::Unsigned64Attribute(const char* name, uint64_t defaultValue) const
+{
+ uint64_t i = defaultValue;
+ QueryUnsigned64Attribute(name, &i);
+ return i;
+}
+
bool XMLElement::BoolAttribute(const char* name, bool defaultValue) const
{
bool b = defaultValue;
@@ -1634,6 +1678,12 @@ void XMLElement::SetText(int64_t v)
SetText(buf);
}
+void XMLElement::SetText(uint64_t v) {
+ char buf[BUF_SIZE];
+ XMLUtil::ToStr(v, buf, BUF_SIZE);
+ SetText(buf);
+}
+
void XMLElement::SetText( bool v )
{
@@ -1698,6 +1748,19 @@ XMLError XMLElement::QueryInt64Text(int64_t* ival) const
}
+XMLError XMLElement::QueryUnsigned64Text(uint64_t* ival) const
+{
+ if(FirstChild() && FirstChild()->ToText()) {
+ const char* t = FirstChild()->Value();
+ if(XMLUtil::ToUnsigned64(t, ival)) {
+ return XML_SUCCESS;
+ }
+ return XML_CAN_NOT_CONVERT_TEXT;
+ }
+ return XML_NO_TEXT_NODE;
+}
+
+
XMLError XMLElement::QueryBoolText( bool* bval ) const
{
if ( FirstChild() && FirstChild()->ToText() ) {
@@ -1757,6 +1820,13 @@ int64_t XMLElement::Int64Text(int64_t defaultValue) const
return i;
}
+uint64_t XMLElement::Unsigned64Text(uint64_t defaultValue) const
+{
+ uint64_t i = defaultValue;
+ QueryUnsigned64Text(&i);
+ return i;
+}
+
bool XMLElement::BoolText(bool defaultValue) const
{
bool b = defaultValue;
@@ -1844,7 +1914,7 @@ char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr )
TIXMLASSERT( attrib );
attrib->_parseLineNum = _document->_parseCurLineNum;
- int attrLineNum = attrib->_parseLineNum;
+ const int attrLineNum = attrib->_parseLineNum;
p = attrib->ParseDeep( p, _document->ProcessEntities(), curLineNumPtr );
if ( !p || Attribute( attrib->Name() ) ) {
@@ -2150,7 +2220,7 @@ static FILE* callfopen( const char* filepath, const char* mode )
TIXMLASSERT( mode );
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
FILE* fp = 0;
- errno_t err = fopen_s( &fp, filepath, mode );
+ const errno_t err = fopen_s( &fp, filepath, mode );
if ( err ) {
return 0;
}
@@ -2208,7 +2278,7 @@ template
struct LongFitsIntoSizeTMinusOne {
static bool Fits( unsigned long value )
{
- return value < (size_t)-1;
+ return value < static_cast<size_t>(-1);
}
};
@@ -2253,7 +2323,7 @@ XMLError XMLDocument::LoadFile( FILE* fp )
const size_t size = filelength;
TIXMLASSERT( _charBuffer == 0 );
_charBuffer = new char[size+1];
- size_t read = fread( _charBuffer, 1, size, fp );
+ const size_t read = fread( _charBuffer, 1, size, fp );
if ( read != size ) {
SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );
return _errorID;
@@ -2304,7 +2374,7 @@ XMLError XMLDocument::Parse( const char* p, size_t len )
SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );
return _errorID;
}
- if ( len == (size_t)(-1) ) {
+ if ( len == static_cast<size_t>(-1) ) {
len = strlen( p );
}
TIXMLASSERT( _charBuffer == 0 );
@@ -2346,7 +2416,7 @@ void XMLDocument::SetError( XMLError error, int lineNum, const char* format, ...
_errorLineNum = lineNum;
_errorStr.Reset();
- size_t BUFFER_SIZE = 1000;
+ const size_t BUFFER_SIZE = 1000;
char* buffer = new char[BUFFER_SIZE];
TIXMLASSERT(sizeof(error) <= sizeof(int));
@@ -2439,13 +2509,13 @@ XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) :
}
for( int i=0; i<NUM_ENTITIES; ++i ) {
const char entityValue = entities[i].value;
- const unsigned char flagIndex = (unsigned char)entityValue;
+ const unsigned char flagIndex = static_cast<unsigned char>(entityValue);
TIXMLASSERT( flagIndex < ENTITY_RANGE );
_entityFlag[flagIndex] = true;
}
- _restrictedEntityFlag[(unsigned char)'&'] = true;
- _restrictedEntityFlag[(unsigned char)'<'] = true;
- _restrictedEntityFlag[(unsigned char)'>'] = true; // not required, but consistency is nice
+ _restrictedEntityFlag[static_cast<unsigned char>('&')] = true;
+ _restrictedEntityFlag[static_cast<unsigned char>('<')] = true;
+ _restrictedEntityFlag[static_cast<unsigned char>('>')] = true; // not required, but consistency is nice
_buffer.Push( 0 );
}
@@ -2520,10 +2590,10 @@ void XMLPrinter::PrintString( const char* p, bool restricted )
// Check for entities. If one is found, flush
// the stream up until the entity, write the
// entity, and keep looking.
- if ( flag[(unsigned char)(*q)] ) {
+ if ( flag[static_cast<unsigned char>(*q)] ) {
while ( p < q ) {
const size_t delta = q - p;
- const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta;
+ const int toPrint = ( INT_MAX < delta ) ? INT_MAX : static_cast<int>(delta);
Write( p, toPrint );
p += toPrint;
}
@@ -2551,7 +2621,7 @@ void XMLPrinter::PrintString( const char* p, bool restricted )
// string if an entity wasn't found.
if ( p < q ) {
const size_t delta = q - p;
- const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta;
+ const int toPrint = ( INT_MAX < delta ) ? INT_MAX : static_cast<int>(delta);
Write( p, toPrint );
}
}
@@ -2629,6 +2699,14 @@ void XMLPrinter::PushAttribute(const char* name, int64_t v)
}
+void XMLPrinter::PushAttribute(const char* name, uint64_t v)
+{
+ char buf[BUF_SIZE];
+ XMLUtil::ToStr(v, buf, BUF_SIZE);
+ PushAttribute(name, buf);
+}
+
+
void XMLPrinter::PushAttribute( const char* name, bool v )
{
char buf[BUF_SIZE];
@@ -2698,6 +2776,7 @@ void XMLPrinter::PushText( const char* text, bool cdata )
}
}
+
void XMLPrinter::PushText( int64_t value )
{
char buf[BUF_SIZE];
@@ -2705,6 +2784,15 @@ void XMLPrinter::PushText( int64_t value )
PushText( buf, false );
}
+
+void XMLPrinter::PushText( uint64_t value )
+{
+ char buf[BUF_SIZE];
+ XMLUtil::ToStr(value, buf, BUF_SIZE);
+ PushText(buf, false);
+}
+
+
void XMLPrinter::PushText( int value )
{
char buf[BUF_SIZE];
diff --git a/src/mir_core/src/tinyxml2.h b/src/mir_core/src/tinyxml2.h
index 40b3067e1c..44642078e9 100644
--- a/src/mir_core/src/tinyxml2.h
+++ b/src/mir_core/src/tinyxml2.h
@@ -99,12 +99,12 @@ distribution.
http://semver.org/
*/
static const int TIXML2_MAJOR_VERSION = 7;
-static const int TIXML2_MINOR_VERSION = 0;
-static const int TIXML2_PATCH_VERSION = 1;
+static const int TIXML2_MINOR_VERSION = 1;
+static const int TIXML2_PATCH_VERSION = 0;
#define TINYXML2_MAJOR_VERSION 7
-#define TINYXML2_MINOR_VERSION 0
-#define TINYXML2_PATCH_VERSION 1
+#define TINYXML2_MINOR_VERSION 1
+#define TINYXML2_PATCH_VERSION 0
// A fixed element depth limit is problematic. There needs to be a
// limit to avoid a stack overflow. However, that limit varies per
@@ -303,7 +303,7 @@ private:
TIXMLASSERT( cap > 0 );
if ( cap > _allocated ) {
TIXMLASSERT( cap <= INT_MAX / 2 );
- int newAllocated = cap * 2;
+ const int newAllocated = cap * 2;
T* newMem = new T[newAllocated];
TIXMLASSERT( newAllocated >= _size );
memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
@@ -617,6 +617,7 @@ public:
static void ToStr( float v, char* buffer, int bufferSize );
static void ToStr( double v, char* buffer, int bufferSize );
static void ToStr(int64_t v, char* buffer, int bufferSize);
+ static void ToStr(uint64_t v, char* buffer, int bufferSize);
// converts strings to primitive types
static bool ToInt( const char* str, int* value );
@@ -625,7 +626,7 @@ public:
static bool ToFloat( const char* str, float* value );
static bool ToDouble( const char* str, double* value );
static bool ToInt64(const char* str, int64_t* value);
-
+ static bool ToUnsigned64(const char* str, uint64_t* value);
// Changes what is serialized for a boolean value.
// Default to "true" and "false". Shouldn't be changed
// unless you have a special testing or compatibility need.
@@ -1164,6 +1165,12 @@ public:
return i;
}
+ uint64_t Unsigned64Value() const {
+ uint64_t i = 0;
+ QueryUnsigned64Value(&i);
+ return i;
+ }
+
/// Query as an unsigned integer. See IntValue()
unsigned UnsignedValue() const {
unsigned i=0;
@@ -1198,6 +1205,8 @@ public:
XMLError QueryUnsignedValue( unsigned int* value ) const;
/// See QueryIntValue
XMLError QueryInt64Value(int64_t* value) const;
+ /// See QueryIntValue
+ XMLError QueryUnsigned64Value(uint64_t* value) const;
/// See QueryIntValue
XMLError QueryBoolValue( bool* value ) const;
/// See QueryIntValue
@@ -1215,7 +1224,9 @@ public:
void SetAttribute( unsigned value );
/// Set the attribute to value.
void SetAttribute(int64_t value);
- /// Set the attribute to value.
+ /// Set the attribute to value.
+ void SetAttribute(uint64_t value);
+ /// Set the attribute to value.
void SetAttribute( bool value );
/// Set the attribute to value.
void SetAttribute( double value );
@@ -1303,6 +1314,8 @@ public:
unsigned UnsignedAttribute(const char* name, unsigned defaultValue = 0) const;
/// See IntAttribute()
int64_t Int64Attribute(const char* name, int64_t defaultValue = 0) const;
+ /// See IntAttribute()
+ uint64_t Unsigned64Attribute(const char* name, uint64_t defaultValue = 0) const;
/// See IntAttribute()
bool BoolAttribute(const char* name, bool defaultValue = false) const;
/// See IntAttribute()
@@ -1349,6 +1362,15 @@ public:
return a->QueryInt64Value(value);
}
+ /// See QueryIntAttribute()
+ XMLError QueryUnsigned64Attribute(const char* name, uint64_t* value) const {
+ const XMLAttribute* a = FindAttribute(name);
+ if(!a) {
+ return XML_NO_ATTRIBUTE;
+ }
+ return a->QueryUnsigned64Value(value);
+ }
+
/// See QueryIntAttribute()
XMLError QueryBoolAttribute( const char* name, bool* value ) const {
const XMLAttribute* a = FindAttribute( name );
@@ -1415,7 +1437,11 @@ public:
return QueryInt64Attribute(name, value);
}
- XMLError QueryAttribute( const char* name, bool* value ) const {
+ XMLError QueryAttribute(const char* name, uint64_t* value) const {
+ return QueryUnsigned64Attribute(name, value);
+ }
+
+ XMLError QueryAttribute( const char* name, bool* value ) const {
return QueryBoolAttribute( name, value );
}
@@ -1453,7 +1479,13 @@ public:
a->SetAttribute(value);
}
- /// Sets the named attribute to value.
+ /// Sets the named attribute to value.
+ void SetAttribute(const char* name, uint64_t 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 );
@@ -1553,6 +1585,8 @@ public:
void SetText( unsigned value );
/// Convenience method for setting text inside an element. See SetText() for important limitations.
void SetText(int64_t value);
+ /// Convenience method for setting text inside an element. See SetText() for important limitations.
+ void SetText(uint64_t value);
/// Convenience method for setting text inside an element. See SetText() for important limitations.
void SetText( bool value );
/// Convenience method for setting text inside an element. See SetText() for important limitations.
@@ -1592,6 +1626,8 @@ public:
/// See QueryIntText()
XMLError QueryInt64Text(int64_t* uval) const;
/// See QueryIntText()
+ XMLError QueryUnsigned64Text(uint64_t* uval) const;
+ /// See QueryIntText()
XMLError QueryBoolText( bool* bval ) const;
/// See QueryIntText()
XMLError QueryDoubleText( double* dval ) const;
@@ -1604,6 +1640,8 @@ public:
unsigned UnsignedText(unsigned defaultValue = 0) const;
/// See QueryIntText()
int64_t Int64Text(int64_t defaultValue = 0) const;
+ /// See QueryIntText()
+ uint64_t Unsigned64Text(uint64_t defaultValue = 0) const;
/// See QueryIntText()
bool BoolText(bool defaultValue = false) const;
/// See QueryIntText()
@@ -1691,7 +1729,7 @@ 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=static_cast<size_t>(-1) );
/**
Load an XML file from disk.
@@ -1887,8 +1925,8 @@ private:
int _errorLineNum;
char* _charBuffer;
int _parseCurLineNum;
- int _parsingDepth;
int _bytesParsed;
+ int _parsingDepth;
// Memory tracking does add some overhead.
// However, the code assumes that you don't
// have a bunch of unlinked nodes around.
@@ -2213,7 +2251,8 @@ public:
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, int64_t value);
+ void PushAttribute( const char* name, int64_t value );
+ void PushAttribute( const char* name, uint64_t value );
void PushAttribute( const char* name, bool value );
void PushAttribute( const char* name, double value );
/// If streaming, close the Element.
@@ -2225,8 +2264,10 @@ public:
void PushText( int value );
/// Add a text node from an unsigned.
void PushText( unsigned value );
- /// Add a text node from an unsigned.
- void PushText(int64_t value);
+ /// Add a text node from a signed 64bit integer.
+ void PushText( int64_t value );
+ /// Add a text node from an unsigned 64bit integer.
+ void PushText( uint64_t value );
/// Add a text node from a bool.
void PushText( bool value );
/// Add a text node from a float.
@@ -2272,10 +2313,10 @@ public:
If in print to memory mode, reset the buffer to the
beginning.
*/
- void ClearBuffer() {
+ void ClearBuffer( bool resetToFirstElement = true ) {
_buffer.Clear();
_buffer.Push(0);
- _firstElement = true;
+ _firstElement = resetToFirstElement;
}
protected: