Imported Upstream version 7.1.0 upstream/7.1.0
authorJinWang An <jinwang.an@samsung.com>
Fri, 30 Oct 2020 05:35:26 +0000 (14:35 +0900)
committerJinWang An <jinwang.an@samsung.com>
Fri, 30 Oct 2020 05:35:26 +0000 (14:35 +0900)
CMakeLists.txt
LICENSE.txt [new file with mode: 0644]
dox
readme.md
tinyxml2.cpp
tinyxml2.h
xmltest.cpp [changed mode: 0644->0755]

index 378b48a0ce94731f308a92bbc121aed5d4cb3783..3eedc48332f7c641c8499c68db5814e810d5340d 100644 (file)
@@ -21,7 +21,7 @@ include(CTest)
 ################################\r
 # set lib version here\r
 \r
-set(GENERIC_LIB_VERSION "7.0.1")\r
+set(GENERIC_LIB_VERSION "7.1.0")\r
 set(GENERIC_LIB_SOVERSION "7")\r
 \r
 ################################\r
@@ -121,8 +121,14 @@ configure_package_config_file(
   "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake"\r
   INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}"\r
 )\r
+write_basic_package_version_file(\r
+  "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake"\r
+  VERSION ${GENERIC_LIB_VERSION}\r
+  COMPATIBILITY SameMajorVersion\r
+)\r
 install(FILES\r
         ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake\r
+        ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake\r
         DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})\r
 \r
 install(EXPORT ${CMAKE_PROJECT_NAME}Targets NAMESPACE tinyxml2::\r
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644 (file)
index 0000000..85a6a36
--- /dev/null
@@ -0,0 +1,18 @@
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
diff --git a/dox b/dox
index fd50e799e3865b0cfb35c8302ca6386b9cb40f07..d954a2065d02e6f457fbb2ac3eebe28497398e50 100644 (file)
--- a/dox
+++ b/dox
@@ -38,11 +38,7 @@ PROJECT_NAME           = "TinyXML-2"
 # could be handy for archiving the generated documentation or if some version\r
 # control system is used.\r
 \r
-<<<<<<< HEAD\r
-PROJECT_NUMBER = 7.0.1\r
-=======\r
-PROJECT_NUMBER = 7.0.1\r
->>>>>>> master\r
+PROJECT_NUMBER = 7.1.0\r
 \r
 # Using the PROJECT_BRIEF tag one can provide an optional one line description\r
 # for a project that appears at the top of each page and should give viewer a\r
index a519bfaf6597af2012b9c7f92fc27863d9813de8..7dad55d52298cc6fab43f93872194b3a729224bd 100644 (file)
--- a/readme.md
+++ b/readme.md
@@ -54,9 +54,8 @@ What it doesn't do.
 
 TinyXML-2 doesn't parse or use DTDs (Document Type Definitions) or XSLs
 (eXtensible Stylesheet Language.) There are other parsers out there
-that are much more fully featured. But they are also much bigger,
-take longer to set up in your project, have a higher learning curve,
-and often have a more restrictive license. If you are working with
+that are much more fully featured. But they are generally bigger and
+more difficult to use. If you are working with
 browsers or have more complete XML needs, TinyXML-2 is not the parser for you.
 
 TinyXML-1 vs. TinyXML-2
@@ -265,7 +264,7 @@ And additionally a test file:
 
 Simply compile and run. There is a visual studio 2017 project included, a simple Makefile,
 an Xcode project, a Code::Blocks project, and a cmake CMakeLists.txt included to help you.
-The top of tinyxml.h even has a simple g++ command line if you are are Unix/Linuk/BSD and
+The top of tinyxml.h even has a simple g++ command line if you are using Unix/Linux/BSD and
 don't want to use a build system.
 
 Versioning
@@ -279,7 +278,7 @@ common.
 Documentation
 -------------
 
-The documentation is build with Doxygen, using the 'dox'
+The documentation is built with Doxygen, using the 'dox'
 configuration file.
 
 License
index fd27f7888d279e8f66d4fda506945f38a909bad8..6b799171a99fcb138a05a6d84759f3875d736e77 100755 (executable)
@@ -45,14 +45,14 @@ distribution.
        {\r
                va_list va;\r
                va_start( va, format );\r
-               int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );\r
+               const int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );\r
                va_end( va );\r
                return result;\r
        }\r
 \r
        static inline int TIXML_VSNPRINTF( char* buffer, size_t size, const char* format, va_list va )\r
        {\r
-               int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );\r
+               const int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );\r
                return result;\r
        }\r
 \r
@@ -101,9 +101,9 @@ distribution.
 #endif\r
 \r
 \r
-static const char LINE_FEED                            = (char)0x0a;                   // all line endings are normalized to LF\r
+static const char LINE_FEED                            = static_cast<char>(0x0a);                      // all line endings are normalized to LF\r
 static const char LF = LINE_FEED;\r
-static const char CARRIAGE_RETURN              = (char)0x0d;                   // CR gets filtered out\r
+static const char CARRIAGE_RETURN              = static_cast<char>(0x0d);                      // CR gets filtered out\r
 static const char CR = CARRIAGE_RETURN;\r
 static const char SINGLE_QUOTE                 = '\'';\r
 static const char DOUBLE_QUOTE                 = '\"';\r
@@ -197,7 +197,7 @@ char* StrPair::ParseText( char* p, const char* endTag, int strFlags, int* curLin
        TIXMLASSERT(curLineNumPtr);\r
 \r
     char* start = p;\r
-    char  endChar = *endTag;\r
+    const char  endChar = *endTag;\r
     size_t length = strlen( endTag );\r
 \r
     // Inner loop of text parsing.\r
@@ -310,7 +310,7 @@ const char* StrPair::GetStr()
                         const int buflen = 10;\r
                         char buf[buflen] = { 0 };\r
                         int len = 0;\r
-                        char* adjusted = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );\r
+                        const char* adjusted = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );\r
                         if ( adjusted == 0 ) {\r
                             *q = *p;\r
                             ++p;\r
@@ -430,22 +430,22 @@ void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length
     switch (*length) {\r
         case 4:\r
             --output;\r
-            *output = (char)((input | BYTE_MARK) & BYTE_MASK);\r
+            *output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);\r
             input >>= 6;\r
             //fall through\r
         case 3:\r
             --output;\r
-            *output = (char)((input | BYTE_MARK) & BYTE_MASK);\r
+            *output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);\r
             input >>= 6;\r
             //fall through\r
         case 2:\r
             --output;\r
-            *output = (char)((input | BYTE_MARK) & BYTE_MASK);\r
+            *output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);\r
             input >>= 6;\r
             //fall through\r
         case 1:\r
             --output;\r
-            *output = (char)(input | FIRST_BYTE_MARK[*length]);\r
+            *output = static_cast<char>(input | FIRST_BYTE_MARK[*length]);\r
             break;\r
         default:\r
             TIXMLASSERT( false );\r
@@ -582,12 +582,17 @@ void XMLUtil::ToStr( double v, char* buffer, int bufferSize )
 }\r
 \r
 \r
-void XMLUtil::ToStr(int64_t v, char* buffer, int bufferSize)\r
+void XMLUtil::ToStr( int64_t v, char* buffer, int bufferSize )\r
 {\r
        // horrible syntax trick to make the compiler happy about %lld\r
-       TIXML_SNPRINTF(buffer, bufferSize, "%lld", (long long)v);\r
+       TIXML_SNPRINTF(buffer, bufferSize, "%lld", static_cast<long long>(v));\r
 }\r
 \r
+void XMLUtil::ToStr( uint64_t v, char* buffer, int bufferSize )\r
+{\r
+    // horrible syntax trick to make the compiler happy about %llu\r
+    TIXML_SNPRINTF(buffer, bufferSize, "%llu", (long long)v);\r
+}\r
 \r
 bool XMLUtil::ToInt( const char* str, int* value )\r
 {\r
@@ -612,13 +617,20 @@ bool XMLUtil::ToBool( const char* str, bool* value )
         *value = (ival==0) ? false : true;\r
         return true;\r
     }\r
-    if ( StringEqual( str, "true" ) ) {\r
-        *value = true;\r
-        return true;\r
+    static const char* TRUE[] = { "true", "True", "TRUE", 0 };\r
+    static const char* FALSE[] = { "false", "False", "FALSE", 0 };\r
+\r
+    for (int i = 0; TRUE[i]; ++i) {\r
+        if (StringEqual(str, TRUE[i])) {\r
+            *value = true;\r
+            return true;\r
+        }\r
     }\r
-    else if ( StringEqual( str, "false" ) ) {\r
-        *value = false;\r
-        return true;\r
+    for (int i = 0; FALSE[i]; ++i) {\r
+        if (StringEqual(str, FALSE[i])) {\r
+            *value = false;\r
+            return true;\r
+        }\r
     }\r
     return false;\r
 }\r
@@ -646,13 +658,23 @@ bool XMLUtil::ToInt64(const char* str, int64_t* value)
 {\r
        long long v = 0;        // horrible syntax trick to make the compiler happy about %lld\r
        if (TIXML_SSCANF(str, "%lld", &v) == 1) {\r
-               *value = (int64_t)v;\r
+               *value = static_cast<int64_t>(v);\r
                return true;\r
        }\r
        return false;\r
 }\r
 \r
 \r
+bool XMLUtil::ToUnsigned64(const char* str, uint64_t* value) {\r
+    unsigned long long v = 0;  // horrible syntax trick to make the compiler happy about %llu\r
+    if(TIXML_SSCANF(str, "%llu", &v) == 1) {\r
+        *value = (uint64_t)v;\r
+        return true;\r
+    }\r
+    return false;\r
+}\r
+\r
+\r
 char* XMLDocument::Identify( char* p, XMLNode** node )\r
 {\r
     TIXMLASSERT( node );\r
@@ -1017,7 +1039,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
             break;\r
         }\r
 \r
-        int initialLineNum = node->_parseLineNum;\r
+       const int initialLineNum = node->_parseLineNum;\r
 \r
         StrPair endTag;\r
         p = node->ParseDeep( p, &endTag, curLineNumPtr );\r
@@ -1029,7 +1051,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
             break;\r
         }\r
 \r
-        XMLDeclaration* decl = node->ToDeclaration();\r
+        const XMLDeclaration* const decl = node->ToDeclaration();\r
         if ( decl ) {\r
             // Declarations are only allowed at document level\r
             //\r
@@ -1038,7 +1060,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr )
             //\r
             // Optimized due to a security test case. If the first node is \r
             // a declaration, and the last node is a declaration, then only \r
-            // declarations have so far been addded.\r
+            // declarations have so far been added.\r
             bool wellLocated = false;\r
 \r
             if (ToDocument()) {\r
@@ -1373,7 +1395,7 @@ char* XMLAttribute::ParseDeep( char* p, bool processEntities, int* curLineNumPtr
         return 0;\r
     }\r
 \r
-    char endTag[2] = { *p, 0 };\r
+    const char endTag[2] = { *p, 0 };\r
     ++p;       // move past opening quote\r
 \r
     p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES, curLineNumPtr );\r
@@ -1414,6 +1436,15 @@ XMLError XMLAttribute::QueryInt64Value(int64_t* value) const
 }\r
 \r
 \r
+XMLError XMLAttribute::QueryUnsigned64Value(uint64_t* value) const\r
+{\r
+    if(XMLUtil::ToUnsigned64(Value(), value)) {\r
+        return XML_SUCCESS;\r
+    }\r
+    return XML_WRONG_ATTRIBUTE_TYPE;\r
+}\r
+\r
+\r
 XMLError XMLAttribute::QueryBoolValue( bool* value ) const\r
 {\r
     if ( XMLUtil::ToBool( Value(), value )) {\r
@@ -1470,6 +1501,12 @@ void XMLAttribute::SetAttribute(int64_t v)
        _value.SetStr(buf);\r
 }\r
 \r
+void XMLAttribute::SetAttribute(uint64_t v)\r
+{\r
+    char buf[BUF_SIZE];\r
+    XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+    _value.SetStr(buf);\r
+}\r
 \r
 \r
 void XMLAttribute::SetAttribute( bool v )\r
@@ -1556,6 +1593,13 @@ int64_t XMLElement::Int64Attribute(const char* name, int64_t defaultValue) const
        return i;\r
 }\r
 \r
+uint64_t XMLElement::Unsigned64Attribute(const char* name, uint64_t defaultValue) const\r
+{\r
+       uint64_t i = defaultValue;\r
+       QueryUnsigned64Attribute(name, &i);\r
+       return i;\r
+}\r
+\r
 bool XMLElement::BoolAttribute(const char* name, bool defaultValue) const\r
 {\r
        bool b = defaultValue;\r
@@ -1620,6 +1664,12 @@ void XMLElement::SetText(int64_t v)
        SetText(buf);\r
 }\r
 \r
+void XMLElement::SetText(uint64_t v) {\r
+    char buf[BUF_SIZE];\r
+    XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+    SetText(buf);\r
+}\r
+\r
 \r
 void XMLElement::SetText( bool v )\r
 {\r
@@ -1684,6 +1734,19 @@ XMLError XMLElement::QueryInt64Text(int64_t* ival) const
 }\r
 \r
 \r
+XMLError XMLElement::QueryUnsigned64Text(uint64_t* ival) const\r
+{\r
+    if(FirstChild() && FirstChild()->ToText()) {\r
+        const char* t = FirstChild()->Value();\r
+        if(XMLUtil::ToUnsigned64(t, ival)) {\r
+            return XML_SUCCESS;\r
+        }\r
+        return XML_CAN_NOT_CONVERT_TEXT;\r
+    }\r
+    return XML_NO_TEXT_NODE;\r
+}\r
+\r
+\r
 XMLError XMLElement::QueryBoolText( bool* bval ) const\r
 {\r
     if ( FirstChild() && FirstChild()->ToText() ) {\r
@@ -1743,6 +1806,13 @@ int64_t XMLElement::Int64Text(int64_t defaultValue) const
        return i;\r
 }\r
 \r
+uint64_t XMLElement::Unsigned64Text(uint64_t defaultValue) const\r
+{\r
+       uint64_t i = defaultValue;\r
+       QueryUnsigned64Text(&i);\r
+       return i;\r
+}\r
+\r
 bool XMLElement::BoolText(bool defaultValue) const\r
 {\r
        bool b = defaultValue;\r
@@ -1830,7 +1900,7 @@ char* XMLElement::ParseAttributes( char* p, int* curLineNumPtr )
             TIXMLASSERT( attrib );\r
             attrib->_parseLineNum = _document->_parseCurLineNum;\r
 \r
-            int attrLineNum = attrib->_parseLineNum;\r
+            const int attrLineNum = attrib->_parseLineNum;\r
 \r
             p = attrib->ParseDeep( p, _document->ProcessEntities(), curLineNumPtr );\r
             if ( !p || Attribute( attrib->Name() ) ) {\r
@@ -2136,7 +2206,7 @@ static FILE* callfopen( const char* filepath, const char* mode )
     TIXMLASSERT( mode );\r
 #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)\r
     FILE* fp = 0;\r
-    errno_t err = fopen_s( &fp, filepath, mode );\r
+    const errno_t err = fopen_s( &fp, filepath, mode );\r
     if ( err ) {\r
         return 0;\r
     }\r
@@ -2194,7 +2264,7 @@ template
 struct LongFitsIntoSizeTMinusOne {\r
     static bool Fits( unsigned long value )\r
     {\r
-        return value < (size_t)-1;\r
+        return value < static_cast<size_t>(-1);\r
     }\r
 };\r
 \r
@@ -2239,7 +2309,7 @@ XMLError XMLDocument::LoadFile( FILE* fp )
     const size_t size = filelength;\r
     TIXMLASSERT( _charBuffer == 0 );\r
     _charBuffer = new char[size+1];\r
-    size_t read = fread( _charBuffer, 1, size, fp );\r
+    const size_t read = fread( _charBuffer, 1, size, fp );\r
     if ( read != size ) {\r
         SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );\r
         return _errorID;\r
@@ -2290,7 +2360,7 @@ XMLError XMLDocument::Parse( const char* p, size_t len )
         SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );\r
         return _errorID;\r
     }\r
-    if ( len == (size_t)(-1) ) {\r
+    if ( len == static_cast<size_t>(-1) ) {\r
         len = strlen( p );\r
     }\r
     TIXMLASSERT( _charBuffer == 0 );\r
@@ -2332,7 +2402,7 @@ void XMLDocument::SetError( XMLError error, int lineNum, const char* format, ...
     _errorLineNum = lineNum;\r
        _errorStr.Reset();\r
 \r
-    size_t BUFFER_SIZE = 1000;\r
+    const size_t BUFFER_SIZE = 1000;\r
     char* buffer = new char[BUFFER_SIZE];\r
 \r
     TIXMLASSERT(sizeof(error) <= sizeof(int));\r
@@ -2424,13 +2494,13 @@ XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) :
     }\r
     for( int i=0; i<NUM_ENTITIES; ++i ) {\r
         const char entityValue = entities[i].value;\r
-        const unsigned char flagIndex = (unsigned char)entityValue;\r
+        const unsigned char flagIndex = static_cast<unsigned char>(entityValue);\r
         TIXMLASSERT( flagIndex < ENTITY_RANGE );\r
         _entityFlag[flagIndex] = true;\r
     }\r
-    _restrictedEntityFlag[(unsigned char)'&'] = true;\r
-    _restrictedEntityFlag[(unsigned char)'<'] = true;\r
-    _restrictedEntityFlag[(unsigned char)'>'] = true;  // not required, but consistency is nice\r
+    _restrictedEntityFlag[static_cast<unsigned char>('&')] = true;\r
+    _restrictedEntityFlag[static_cast<unsigned char>('<')] = true;\r
+    _restrictedEntityFlag[static_cast<unsigned char>('>')] = true;     // not required, but consistency is nice\r
     _buffer.Push( 0 );\r
 }\r
 \r
@@ -2505,10 +2575,10 @@ void XMLPrinter::PrintString( const char* p, bool restricted )
                 // Check for entities. If one is found, flush\r
                 // the stream up until the entity, write the\r
                 // entity, and keep looking.\r
-                if ( flag[(unsigned char)(*q)] ) {\r
+                if ( flag[static_cast<unsigned char>(*q)] ) {\r
                     while ( p < q ) {\r
                         const size_t delta = q - p;\r
-                        const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta;\r
+                        const int toPrint = ( INT_MAX < delta ) ? INT_MAX : static_cast<int>(delta);\r
                         Write( p, toPrint );\r
                         p += toPrint;\r
                     }\r
@@ -2536,7 +2606,7 @@ void XMLPrinter::PrintString( const char* p, bool restricted )
         // string if an entity wasn't found.\r
         if ( p < q ) {\r
             const size_t delta = q - p;\r
-            const int toPrint = ( INT_MAX < delta ) ? INT_MAX : (int)delta;\r
+            const int toPrint = ( INT_MAX < delta ) ? INT_MAX : static_cast<int>(delta);\r
             Write( p, toPrint );\r
         }\r
     }\r
@@ -2614,6 +2684,14 @@ void XMLPrinter::PushAttribute(const char* name, int64_t v)
 }\r
 \r
 \r
+void XMLPrinter::PushAttribute(const char* name, uint64_t v)\r
+{\r
+       char buf[BUF_SIZE];\r
+       XMLUtil::ToStr(v, buf, BUF_SIZE);\r
+       PushAttribute(name, buf);\r
+}\r
+\r
+\r
 void XMLPrinter::PushAttribute( const char* name, bool v )\r
 {\r
     char buf[BUF_SIZE];\r
@@ -2683,6 +2761,7 @@ void XMLPrinter::PushText( const char* text, bool cdata )
     }\r
 }\r
 \r
+\r
 void XMLPrinter::PushText( int64_t value )\r
 {\r
     char buf[BUF_SIZE];\r
@@ -2690,6 +2769,15 @@ void XMLPrinter::PushText( int64_t value )
     PushText( buf, false );\r
 }\r
 \r
+\r
+void XMLPrinter::PushText( uint64_t value )\r
+{\r
+       char buf[BUF_SIZE];\r
+       XMLUtil::ToStr(value, buf, BUF_SIZE);\r
+       PushText(buf, false);\r
+}\r
+\r
+\r
 void XMLPrinter::PushText( int value )\r
 {\r
     char buf[BUF_SIZE];\r
index ee83d2cc9a4db51b2c945e8a38ffcf078c6f17c3..a432f7ee70b90b8b6e4bce74caedaed36f8a2e52 100755 (executable)
@@ -99,12 +99,12 @@ distribution.
        http://semver.org/\r
 */\r
 static const int TIXML2_MAJOR_VERSION = 7;\r
-static const int TIXML2_MINOR_VERSION = 0;\r
-static const int TIXML2_PATCH_VERSION = 1;\r
+static const int TIXML2_MINOR_VERSION = 1;\r
+static const int TIXML2_PATCH_VERSION = 0;\r
 \r
 #define TINYXML2_MAJOR_VERSION 7\r
-#define TINYXML2_MINOR_VERSION 0\r
-#define TINYXML2_PATCH_VERSION 1\r
+#define TINYXML2_MINOR_VERSION 1\r
+#define TINYXML2_PATCH_VERSION 0\r
 \r
 // A fixed element depth limit is problematic. There needs to be a\r
 // limit to avoid a stack overflow. However, that limit varies per\r
@@ -303,7 +303,7 @@ private:
         TIXMLASSERT( cap > 0 );\r
         if ( cap > _allocated ) {\r
             TIXMLASSERT( cap <= INT_MAX / 2 );\r
-            int newAllocated = cap * 2;\r
+            const int newAllocated = cap * 2;\r
             T* newMem = new T[newAllocated];\r
             TIXMLASSERT( newAllocated >= _size );\r
             memcpy( newMem, _mem, sizeof(T)*_size );   // warning: not using constructors, only works for PODs\r
@@ -617,6 +617,7 @@ public:
     static void ToStr( float v, char* buffer, int bufferSize );\r
     static void ToStr( double v, char* buffer, int bufferSize );\r
        static void ToStr(int64_t v, char* buffer, int bufferSize);\r
+    static void ToStr(uint64_t v, char* buffer, int bufferSize);\r
 \r
     // converts strings to primitive types\r
     static bool        ToInt( const char* str, int* value );\r
@@ -625,7 +626,7 @@ public:
     static bool        ToFloat( const char* str, float* value );\r
     static bool ToDouble( const char* str, double* value );\r
        static bool ToInt64(const char* str, int64_t* value);\r
-\r
+    static bool ToUnsigned64(const char* str, uint64_t* value);\r
        // Changes what is serialized for a boolean value.\r
        // Default to "true" and "false". Shouldn't be changed\r
        // unless you have a special testing or compatibility need.\r
@@ -1164,6 +1165,12 @@ public:
                return i;\r
        }\r
 \r
+    uint64_t Unsigned64Value() const {\r
+        uint64_t i = 0;\r
+        QueryUnsigned64Value(&i);\r
+        return i;\r
+    }\r
+\r
     /// Query as an unsigned integer. See IntValue()\r
     unsigned UnsignedValue() const                     {\r
         unsigned i=0;\r
@@ -1198,6 +1205,8 @@ public:
     XMLError QueryUnsignedValue( unsigned int* value ) const;\r
        /// See QueryIntValue\r
        XMLError QueryInt64Value(int64_t* value) const;\r
+    /// See QueryIntValue\r
+    XMLError QueryUnsigned64Value(uint64_t* value) const;\r
        /// See QueryIntValue\r
     XMLError QueryBoolValue( bool* value ) const;\r
     /// See QueryIntValue\r
@@ -1213,7 +1222,9 @@ public:
     void SetAttribute( unsigned value );\r
        /// Set the attribute to value.\r
        void SetAttribute(int64_t value);\r
-       /// Set the attribute to value.\r
+    /// Set the attribute to value.\r
+    void SetAttribute(uint64_t value);\r
+    /// Set the attribute to value.\r
     void SetAttribute( bool value );\r
     /// Set the attribute to value.\r
     void SetAttribute( double value );\r
@@ -1301,6 +1312,8 @@ public:
        unsigned UnsignedAttribute(const char* name, unsigned defaultValue = 0) const;\r
        /// See IntAttribute()\r
        int64_t Int64Attribute(const char* name, int64_t defaultValue = 0) const;\r
+    /// See IntAttribute()\r
+    uint64_t Unsigned64Attribute(const char* name, uint64_t defaultValue = 0) const;\r
        /// See IntAttribute()\r
        bool BoolAttribute(const char* name, bool defaultValue = false) const;\r
     /// See IntAttribute()\r
@@ -1347,6 +1360,15 @@ public:
                return a->QueryInt64Value(value);\r
        }\r
 \r
+    /// See QueryIntAttribute()\r
+    XMLError QueryUnsigned64Attribute(const char* name, uint64_t* value) const {\r
+        const XMLAttribute* a = FindAttribute(name);\r
+        if(!a) {\r
+            return XML_NO_ATTRIBUTE;\r
+        }\r
+        return a->QueryUnsigned64Value(value);\r
+    }\r
+\r
        /// See QueryIntAttribute()\r
     XMLError QueryBoolAttribute( const char* name, bool* value ) const                         {\r
         const XMLAttribute* a = FindAttribute( name );\r
@@ -1413,7 +1435,11 @@ public:
                return QueryInt64Attribute(name, value);\r
        }\r
 \r
-       XMLError QueryAttribute( const char* name, bool* value ) const {\r
+    XMLError QueryAttribute(const char* name, uint64_t* value) const {\r
+        return QueryUnsigned64Attribute(name, value);\r
+    }\r
+\r
+    XMLError QueryAttribute( const char* name, bool* value ) const {\r
                return QueryBoolAttribute( name, value );\r
        }\r
 \r
@@ -1447,7 +1473,13 @@ public:
                a->SetAttribute(value);\r
        }\r
 \r
-       /// Sets the named attribute to value.\r
+    /// Sets the named attribute to value.\r
+    void SetAttribute(const char* name, uint64_t value) {\r
+        XMLAttribute* a = FindOrCreateAttribute(name);\r
+        a->SetAttribute(value);\r
+    }\r
+    \r
+    /// Sets the named attribute to value.\r
     void SetAttribute( const char* name, bool value )                  {\r
         XMLAttribute* a = FindOrCreateAttribute( name );\r
         a->SetAttribute( value );\r
@@ -1546,6 +1578,8 @@ public:
     void SetText( unsigned value );\r
        /// Convenience method for setting text inside an element. See SetText() for important limitations.\r
        void SetText(int64_t value);\r
+    /// Convenience method for setting text inside an element. See SetText() for important limitations.\r
+    void SetText(uint64_t value);\r
        /// Convenience method for setting text inside an element. See SetText() for important limitations.\r
     void SetText( bool value );\r
     /// Convenience method for setting text inside an element. See SetText() for important limitations.\r
@@ -1585,6 +1619,8 @@ public:
        /// See QueryIntText()\r
        XMLError QueryInt64Text(int64_t* uval) const;\r
        /// See QueryIntText()\r
+       XMLError QueryUnsigned64Text(uint64_t* uval) const;\r
+       /// See QueryIntText()\r
     XMLError QueryBoolText( bool* bval ) const;\r
     /// See QueryIntText()\r
     XMLError QueryDoubleText( double* dval ) const;\r
@@ -1597,6 +1633,8 @@ public:
        unsigned UnsignedText(unsigned defaultValue = 0) const;\r
        /// See QueryIntText()\r
        int64_t Int64Text(int64_t defaultValue = 0) const;\r
+    /// See QueryIntText()\r
+    uint64_t Unsigned64Text(uint64_t defaultValue = 0) const;\r
        /// See QueryIntText()\r
        bool BoolText(bool defaultValue = false) const;\r
        /// See QueryIntText()\r
@@ -1684,7 +1722,7 @@ public:
        specified, TinyXML-2 will assume 'xml' points to a\r
        null terminated string.\r
     */\r
-    XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) );\r
+    XMLError Parse( const char* xml, size_t nBytes=static_cast<size_t>(-1) );\r
 \r
     /**\r
        Load an XML file from disk.\r
@@ -2194,7 +2232,8 @@ public:
     void PushAttribute( const char* name, const char* value );\r
     void PushAttribute( const char* name, int value );\r
     void PushAttribute( const char* name, unsigned value );\r
-       void PushAttribute(const char* name, int64_t value);\r
+       void PushAttribute( const char* name, int64_t value );\r
+       void PushAttribute( const char* name, uint64_t value );\r
        void PushAttribute( const char* name, bool value );\r
     void PushAttribute( const char* name, double value );\r
     /// If streaming, close the Element.\r
@@ -2206,8 +2245,10 @@ public:
     void PushText( int value );\r
     /// Add a text node from an unsigned.\r
     void PushText( unsigned value );\r
-       /// Add a text node from an unsigned.\r
-       void PushText(int64_t value);\r
+       /// Add a text node from a signed 64bit integer.\r
+       void PushText( int64_t value );\r
+       /// Add a text node from an unsigned 64bit integer.\r
+       void PushText( uint64_t value );\r
        /// Add a text node from a bool.\r
     void PushText( bool value );\r
     /// Add a text node from a float.\r
@@ -2253,10 +2294,10 @@ public:
        If in print to memory mode, reset the buffer to the\r
        beginning.\r
     */\r
-    void ClearBuffer() {\r
+    void ClearBuffer( bool resetToFirstElement = true ) {\r
         _buffer.Clear();\r
         _buffer.Push(0);\r
-               _firstElement = true;\r
+               _firstElement = resetToFirstElement;\r
     }\r
 \r
 protected:\r
old mode 100644 (file)
new mode 100755 (executable)
index a0aaee7..5a07547
@@ -461,9 +461,9 @@ int main( int argc, const char ** argv )
                // Build:\r
                //              <element>\r
                //                      <!--comment-->\r
+               //                      <sub attrib="0" />\r
                //                      <sub attrib="1" />\r
-               //                      <sub attrib="2" />\r
-               //                      <sub attrib="3" >& Text!</sub>\r
+               //                      <sub attrib="2" >& Text!</sub>\r
                //              <element>\r
 \r
                XMLDocument* doc = new XMLDocument();\r
@@ -804,6 +804,7 @@ int main( int argc, const char ** argv )
        // ---------- Attributes ---------\r
        {\r
                static const int64_t BIG = -123456789012345678;\r
+        static const uint64_t BIG_POS = 123456789012345678;\r
                XMLDocument doc;\r
                XMLElement* element = doc.NewElement("element");\r
                doc.InsertFirstChild(element);\r
@@ -864,7 +865,23 @@ int main( int argc, const char ** argv )
                        }\r
                        XMLTest("Attribute: int64_t", BIG, element->Int64Attribute("attrib"), true);\r
                }\r
-               {\r
+        {\r
+            element->SetAttribute("attrib", BIG_POS);\r
+            {\r
+                uint64_t v = 0;\r
+                XMLError queryResult = element->QueryUnsigned64Attribute("attrib", &v);\r
+                XMLTest("Attribute: uint64_t", XML_SUCCESS, queryResult, true);\r
+                XMLTest("Attribute: uint64_t", BIG_POS, v, true);\r
+            }\r
+            {\r
+                uint64_t v = 0;\r
+                int queryResult = element->QueryAttribute("attrib", &v);\r
+                XMLTest("Attribute: uint64_t", (int)XML_SUCCESS, queryResult, true);\r
+                XMLTest("Attribute: uint64_t", BIG_POS, v, true);\r
+            }\r
+            XMLTest("Attribute: uint64_t", BIG_POS, element->Unsigned64Attribute("attrib"), true);\r
+        }\r
+        {\r
                        element->SetAttribute("attrib", true);\r
                        {\r
                                bool v = false;\r
@@ -931,7 +948,14 @@ int main( int argc, const char ** argv )
                        XMLTest("Element: int64_t", XML_SUCCESS, queryResult, true);\r
                        XMLTest("Element: int64_t", BIG, v, true);\r
                }\r
-       }\r
+        {\r
+            element->SetText(BIG_POS);\r
+            uint64_t v = 0;\r
+            XMLError queryResult = element->QueryUnsigned64Text(&v);\r
+            XMLTest("Element: uint64_t", XML_SUCCESS, queryResult, true);\r
+            XMLTest("Element: uint64_t", BIG_POS, v, true);\r
+        }\r
+    }\r
 \r
        // ---------- XMLPrinter stream mode ------\r
        {\r
@@ -944,7 +968,8 @@ int main( int argc, const char ** argv )
                        printer.PushAttribute("attrib-int", int(1));\r
                        printer.PushAttribute("attrib-unsigned", unsigned(2));\r
                        printer.PushAttribute("attrib-int64", int64_t(3));\r
-                       printer.PushAttribute("attrib-bool", true);\r
+            printer.PushAttribute("attrib-uint64", uint64_t(37));\r
+            printer.PushAttribute("attrib-bool", true);\r
                        printer.PushAttribute("attrib-double", 4.0);\r
                        printer.CloseElement();\r
                        fclose(printerfp);\r
@@ -964,7 +989,9 @@ int main( int argc, const char ** argv )
                        XMLTest("attrib-unsigned", unsigned(2), attrib->UnsignedValue(), true);\r
                        attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-int64");\r
                        XMLTest("attrib-int64", int64_t(3), attrib->Int64Value(), true);\r
-                       attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-bool");\r
+            attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-uint64");\r
+            XMLTest("attrib-uint64", uint64_t(37), attrib->Unsigned64Value(), true);\r
+            attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-bool");\r
                        XMLTest("attrib-bool", true, attrib->BoolValue(), true);\r
                        attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-double");\r
                        XMLTest("attrib-double", 4.0, attrib->DoubleValue(), true);\r
@@ -1523,6 +1550,70 @@ int main( int argc, const char ** argv )
                XMLTest( "Ill formed XML", true, doc.Error() );\r
        }\r
 \r
+    {\r
+        //API:IntText(),UnsignedText(),Int64Text(),DoubleText(),BoolText() and FloatText() test\r
+        const char* xml = "<point> <IntText>-24</IntText> <UnsignedText>42</UnsignedText> \\r
+                                                  <Int64Text>38</Int64Text> <BoolText>true</BoolText> <DoubleText>2.35</DoubleText> </point>";\r
+        XMLDocument doc;\r
+        doc.Parse(xml);\r
+\r
+        const XMLElement* pointElement = doc.RootElement();\r
+        int test1 = pointElement->FirstChildElement("IntText")->IntText();\r
+        XMLTest("IntText() test", -24, test1);\r
+\r
+        unsigned test2 = pointElement->FirstChildElement("UnsignedText")->UnsignedText();\r
+        XMLTest("UnsignedText() test", static_cast<unsigned>(42), test2);\r
+\r
+        int64_t test3 = pointElement->FirstChildElement("Int64Text")->Int64Text();\r
+        XMLTest("Int64Text() test", static_cast<int64_t>(38), test3);\r
+\r
+        double test4 = pointElement->FirstChildElement("DoubleText")->DoubleText();\r
+        XMLTest("DoubleText() test", 2.35, test4);\r
+\r
+        float test5 = pointElement->FirstChildElement("DoubleText")->FloatText();\r
+        XMLTest("FloatText()) test", 2.35f, test5);\r
+\r
+        bool test6 = pointElement->FirstChildElement("BoolText")->BoolText();\r
+        XMLTest("FloatText()) test", true, test6);\r
+    }\r
+\r
+       {\r
+               //API:ShallowEqual() test\r
+               const char* xml = "<playlist id = 'playlist'>"\r
+                                                   "<property name = 'track_name'>voice</property>"\r
+                                                 "</playlist>";\r
+               XMLDocument doc;\r
+               doc.Parse( xml );\r
+               const XMLNode* PlaylistNode = doc.RootElement();\r
+               const XMLNode* PropertyNode = PlaylistNode->FirstChildElement();\r
+               bool result;\r
+               result = PlaylistNode->ShallowEqual(PropertyNode);\r
+               XMLTest("ShallowEqual() test",false,result);\r
+               result = PlaylistNode->ShallowEqual(PlaylistNode);\r
+               XMLTest("ShallowEqual() test",true,result);\r
+       }\r
+\r
+       {\r
+               //API: previousSiblingElement() and NextSiblingElement() test\r
+               const char* xml = "<playlist id = 'playlist'>"\r
+                                                   "<property name = 'track_name'>voice</property>"\r
+                                                   "<entry out = '946' producer = '2_playlist1' in = '0'/>"\r
+                                                       "<blank length = '1'/>"\r
+                                                 "</playlist>";\r
+               XMLDocument doc;\r
+               doc.Parse( xml );\r
+               XMLElement* ElementPlaylist = doc.FirstChildElement("playlist");\r
+               XMLTest("previousSiblingElement() test",true,ElementPlaylist != 0);\r
+               const XMLElement* pre = ElementPlaylist->PreviousSiblingElement();\r
+               XMLTest("previousSiblingElement() test",true,pre == 0);\r
+               const XMLElement* ElementBlank = ElementPlaylist->FirstChildElement("entry")->NextSiblingElement("blank");\r
+               XMLTest("NextSiblingElement() test",true,ElementBlank != 0);\r
+               const XMLElement* next = ElementBlank->NextSiblingElement();\r
+               XMLTest("NextSiblingElement() test",true,next == 0);\r
+               const XMLElement* ElementEntry = ElementBlank->PreviousSiblingElement("entry");\r
+               XMLTest("PreviousSiblingElement test",true,ElementEntry != 0);\r
+       }\r
+\r
        // QueryXYZText\r
        {\r
                const char* xml = "<point> <x>1.2</x> <y>1</y> <z>38</z> <valid>true</valid> </point>";\r
@@ -1702,12 +1793,12 @@ int main( int argc, const char ** argv )
             doc.Print( &printer );\r
 \r
             XMLTest( "BOM preservation (compare)", xml_bom_preservation, printer.CStr(), false, true );\r
-                       doc.SaveFile( "resources/bomtest.xml" );\r
+                       doc.SaveFile( "resources/out/bomtest.xml" );\r
                        XMLTest( "Save bomtest.xml", false, doc.Error() );\r
         }\r
                {\r
                        XMLDocument doc;\r
-                       doc.LoadFile( "resources/bomtest.xml" );\r
+                       doc.LoadFile( "resources/out/bomtest.xml" );\r
                        XMLTest( "Load bomtest.xml", false, doc.Error() );\r
                        XMLTest( "BOM preservation (load)", true, doc.HasBOM(), false );\r
 \r