Snap for 7547121 from 357cfeb96f35871ef5d0664e8305570658a559f4 to mainline-permission-release

Change-Id: I054340072f344dcb4268afb86dcaaa70c0e33609
diff --git a/.gitignore b/.gitignore
index ca32242..3d32441 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,8 @@
 tinyxml2/tinyxml2-cbp/obj/
 tinyxml2/bin/
 tinyxml2/temp/
+.artifacts/
+.projects/
 *.sdf
 *.suo
 *.opensdf
@@ -15,4 +17,6 @@
 *.layout
 *.o
 *.vc.db
-*.vc.opendb
\ No newline at end of file
+*.vc.opendb
+libtinyxml2.a
+xmltest
diff --git a/Android.bp b/Android.bp
index 8c2f9c7..51cd41a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,7 +1,44 @@
+package {
+    default_applicable_licenses: ["external_tinyxml2_license"],
+}
+
+license {
+    name: "external_tinyxml2_license",
+    visibility: [":__subpackages__"],
+    license_kinds: [
+        "SPDX-license-identifier-BSD",
+        "SPDX-license-identifier-MIT",
+        "SPDX-license-identifier-Zlib",
+        "legacy_unencumbered",
+    ],
+    license_text: [
+        "LICENSE.txt",
+        "NOTICE",
+    ],
+}
+
+// The jquery stuff in docs/ is a bit ambiguous with its use of and/or when talking about the GPL,
+// so let's just make it clear that we don't use any of that stuff anyway...
+license {
+    name: "external_tinyxml2_docs_license",
+    license_kinds: ["SPDX-license-identifier-GPL"],
+    license_text: [
+        "LICENSE.txt",
+        "NOTICE",
+    ],
+}
+// ...and prevent anyone from trying to do so:
+filegroup {
+    name: "external_tinyxml2_docs",
+    srcs: ["docs/**/*"],
+    visibility: ["//visibility:private"],
+}
+
 cc_library {
     name: "libtinyxml2",
     host_supported: true,
     vendor_available: true,
+    product_available: true,
     recovery_available: true,
     vndk: {
         enabled: true,
@@ -32,10 +69,21 @@
 }
 
 cc_test {
-    name: "tinyxml2-tests",
+    name: "tinyxml2-xmltest",
     srcs: ["xmltest.cpp"],
     shared_libs: ["libtinyxml2"],
     data: [
         "resources/**/*",
     ],
 }
+
+sh_test {
+    name: "tinyxml2-tests",
+    src: "run-tinyxml2-tests-on-android.sh",
+    filename: "run-tinyxml2-tests-on-android.sh",
+    test_suites: ["general-tests"],
+    host_supported: true,
+    device_supported: false,
+    require_root: true,
+    target_required: ["tinyxml2-xmltest"],
+}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 378b48a..9f9ab07 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,8 +21,8 @@
 ################################

 # set lib version here

 

-set(GENERIC_LIB_VERSION "7.0.1")

-set(GENERIC_LIB_SOVERSION "7")

+set(GENERIC_LIB_VERSION "8.0.0")

+set(GENERIC_LIB_SOVERSION "8")

 

 ################################

 # Add definitions

@@ -79,9 +79,15 @@
 

 install(TARGETS tinyxml2

         EXPORT ${CMAKE_PROJECT_NAME}Targets

-        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}

-        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}

-        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

+        RUNTIME 

+                DESTINATION ${CMAKE_INSTALL_BINDIR}

+                COMPONENT tinyxml2_runtime

+        LIBRARY 

+                DESTINATION ${CMAKE_INSTALL_LIBDIR}

+                COMPONENT tinyxml2_libraries

+        ARCHIVE 

+                DESTINATION ${CMAKE_INSTALL_LIBDIR}

+                COMPONENT tinyxml2_libraries)

 

 if(BUILD_TESTING AND BUILD_TESTS)

   add_executable(xmltest xmltest.cpp)

@@ -98,10 +104,10 @@
   add_test(NAME xmltest COMMAND xmltest WORKING_DIRECTORY $<TARGET_FILE_DIR:xmltest>)

 endif()

 

-install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

+install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT tinyxml2_headers)

 

 configure_file(tinyxml2.pc.in tinyxml2.pc @ONLY)

-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT tinyxml2_config)

 

 # uninstall target

 if(NOT TARGET uninstall)

@@ -121,9 +127,17 @@
   "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake"

   INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}"

 )

+write_basic_package_version_file(

+  "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake"

+  VERSION ${GENERIC_LIB_VERSION}

+  COMPATIBILITY SameMajorVersion

+)

 install(FILES

         ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake

-        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})

+        ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake

+        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}

+        COMPONENT tinyxml2_config)

 

 install(EXPORT ${CMAKE_PROJECT_NAME}Targets NAMESPACE tinyxml2::

-        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})

+        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}

+        COMPONENT tinyxml2_config)

diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..85a6a36
--- /dev/null
+++ b/LICENSE.txt
@@ -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/METADATA b/METADATA
index 391f0e5..88b2f71 100644
--- a/METADATA
+++ b/METADATA
@@ -6,13 +6,14 @@
     value: "https://github.com/leethomason/tinyxml2"
   }
   url {
-    type: ARCHIVE
-    value: "https://github.com/leethomason/tinyxml2/archive/7.0.1.zip"
+    type: GIT
+    value: "https://github.com/leethomason/tinyxml2.git"
   }
-  version: "7.0.1"
+  version: "8.0.0"
+  license_type: RESTRICTED
   last_upgrade_date {
-    year: 2018
-    month: 11
-    day: 17
+    year: 2020
+    month: 3
+    day: 23
   }
 }
diff --git a/TEST_MAPPING b/TEST_MAPPING
new file mode 100644
index 0000000..60222f9
--- /dev/null
+++ b/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+  "presubmit": [
+    {
+      "name": "tinyxml2-tests"
+    }
+  ]
+}
diff --git a/dox b/dox
index fd50e79..feebfba 100644
--- a/dox
+++ b/dox
@@ -38,11 +38,7 @@
 # could be handy for archiving the generated documentation or if some version

 # control system is used.

 

-<<<<<<< HEAD

-PROJECT_NUMBER = 7.0.1

-=======

-PROJECT_NUMBER = 7.0.1

->>>>>>> master

+PROJECT_NUMBER = 8.0.0

 

 # Using the PROJECT_BRIEF tag one can provide an optional one line description

 # for a project that appears at the top of each page and should give viewer a

diff --git a/readme.md b/readme.md
index a519bfa..e9933aa 100644
--- a/readme.md
+++ b/readme.md
@@ -54,9 +54,8 @@
 
 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
@@ -263,11 +262,24 @@
 And additionally a test file:
 * xmltest.cpp
 
-Simply compile and run. There is a visual studio 2017 project included, a simple Makefile,
+Simply compile and run. There is a visual studio 2019 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.
 
+Building TinyXML-2 - Using vcpkg
+--------------------------------
+
+You can download and install TinyXML-2 using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
+
+    git clone https://github.com/Microsoft/vcpkg.git
+    cd vcpkg
+    ./bootstrap-vcpkg.sh
+    ./vcpkg integrate install
+    ./vcpkg install tinyxml2
+
+The TinyXML-2 port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
+
 Versioning
 ----------
 
@@ -279,7 +291,7 @@
 Documentation
 -------------
 
-The documentation is build with Doxygen, using the 'dox'
+The documentation is built with Doxygen, using the 'dox'
 configuration file.
 
 License
diff --git a/run-tinyxml2-tests-on-android.sh b/run-tinyxml2-tests-on-android.sh
new file mode 100755
index 0000000..a3b2a41
--- /dev/null
+++ b/run-tinyxml2-tests-on-android.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# Copy the tests across.
+adb sync
+
+if tty -s; then
+  green="\033[1;32m"
+  red="\033[1;31m"
+  plain="\033[0m"
+else
+  green=""
+  red=""
+  plain=""
+fi
+
+failures=0
+
+check_failure() {
+  if [ $? -eq 0 ]; then
+    echo -e "${green}[PASS]${plain}"
+  else
+    failures=$(($failures+1))
+    echo -e "${red}[FAIL]${plain}"
+  fi
+}
+
+if [ -e "$ANDROID_PRODUCT_OUT/data/nativetest/tinyxml2-xmltest/tinyxml2-xmltest" ]; then
+  adb shell "cd /data/nativetest/tinyxml2-xmltest; ./tinyxml2-xmltest"
+  check_failure
+fi
+if [ -e "$ANDROID_PRODUCT_OUT/data/nativetest64/tinyxml2-xmltest/tinyxml2-xmltest" ]; then
+  adb shell "cd /data/nativetest64/tinyxml2-xmltest; ./tinyxml2-xmltest"
+  check_failure
+fi
+
+echo "_________________________________________________________________________"
+echo
+if [ $failures -ne 0 ]; then
+  echo -e "${red}FAILED${plain}: $failures"
+fi
+exit $failures
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
old mode 100644
new mode 100755
index fd27f78..9e7ff1a
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -45,14 +45,14 @@
 	{

 		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 @@
 #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 @@
 	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 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 @@
     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(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 @@
         *value = (ival==0) ? false : true;

         return true;

     }

-    if ( StringEqual( str, "true" ) ) {

-        *value = true;

-        return true;

+    static const char* TRUE_VALS[] = { "true", "True", "TRUE", 0 };

+    static const char* FALSE_VALS[] = { "false", "False", "FALSE", 0 };

+

+    for (int i = 0; TRUE_VALS[i]; ++i) {

+        if (StringEqual(str, TRUE_VALS[i])) {

+            *value = true;

+            return true;

+        }

     }

-    else if ( StringEqual( str, "false" ) ) {

-        *value = false;

-        return true;

+    for (int i = 0; FALSE_VALS[i]; ++i) {

+        if (StringEqual(str, FALSE_VALS[i])) {

+            *value = false;

+            return true;

+        }

     }

     return false;

 }

@@ -646,13 +658,23 @@
 {

 	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 );

@@ -1017,7 +1039,7 @@
             break;

         }

 

-        int initialLineNum = node->_parseLineNum;

+       const int initialLineNum = node->_parseLineNum;

 

         StrPair endTag;

         p = node->ParseDeep( p, &endTag, curLineNumPtr );

@@ -1029,7 +1051,7 @@
             break;

         }

 

-        XMLDeclaration* decl = node->ToDeclaration();

+        const XMLDeclaration* const decl = node->ToDeclaration();

         if ( decl ) {

             // Declarations are only allowed at document level

             //

@@ -1038,7 +1060,7 @@
             //

             // 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()) {

@@ -1373,7 +1395,7 @@
         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 );

@@ -1414,6 +1436,15 @@
 }

 

 

+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 )) {

@@ -1470,6 +1501,12 @@
 	_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 )

@@ -1556,6 +1593,13 @@
 	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;

@@ -1620,6 +1664,12 @@
 	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 )

 {

@@ -1684,6 +1734,19 @@
 }

 

 

+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() ) {

@@ -1743,6 +1806,13 @@
 	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;

@@ -1830,7 +1900,7 @@
             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() ) ) {

@@ -1891,6 +1961,39 @@
     return attrib;

 }

 

+

+XMLElement* XMLElement::InsertNewChildElement(const char* name)

+{

+    XMLElement* node = _document->NewElement(name);

+    return InsertEndChild(node) ? node : 0;

+}

+

+XMLComment* XMLElement::InsertNewComment(const char* comment)

+{

+    XMLComment* node = _document->NewComment(comment);

+    return InsertEndChild(node) ? node : 0;

+}

+

+XMLText* XMLElement::InsertNewText(const char* text)

+{

+    XMLText* node = _document->NewText(text);

+    return InsertEndChild(node) ? node : 0;

+}

+

+XMLDeclaration* XMLElement::InsertNewDeclaration(const char* text)

+{

+    XMLDeclaration* node = _document->NewDeclaration(text);

+    return InsertEndChild(node) ? node : 0;

+}

+

+XMLUnknown* XMLElement::InsertNewUnknown(const char* text)

+{

+    XMLUnknown* node = _document->NewUnknown(text);

+    return InsertEndChild(node) ? node : 0;

+}

+

+

+

 //

 //	<ele></ele>

 //	<ele>foo<b>bar</b></ele>

@@ -2031,7 +2134,7 @@
 }

 

 

-void XMLDocument::MarkInUse(XMLNode* node)

+void XMLDocument::MarkInUse(const XMLNode* const node)

 {

 	TIXMLASSERT(node);

 	TIXMLASSERT(node->_parent == 0);

@@ -2136,7 +2239,7 @@
     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;

     }

@@ -2194,7 +2297,7 @@
 struct LongFitsIntoSizeTMinusOne {

     static bool Fits( unsigned long value )

     {

-        return value < (size_t)-1;

+        return value < static_cast<size_t>(-1);

     }

 };

 

@@ -2239,7 +2342,7 @@
     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;

@@ -2290,7 +2393,7 @@
         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 );

@@ -2332,7 +2435,7 @@
     _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));

@@ -2424,13 +2527,13 @@
     }

     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 );

 }

 

@@ -2505,10 +2608,10 @@
                 // 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;

                     }

@@ -2536,7 +2639,7 @@
         // 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 );

         }

     }

@@ -2565,8 +2668,6 @@
 

     if ( _textDepth < 0 && !_firstElement && !compactMode ) {

         Putc( '\n' );

-    }

-    if ( !compactMode ) {

         PrintSpace( _depth );

     }

 

@@ -2614,6 +2715,14 @@
 }

 

 

+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];

@@ -2683,6 +2792,7 @@
     }

 }

 

+

 void XMLPrinter::PushText( int64_t value )

 {

     char buf[BUF_SIZE];

@@ -2690,6 +2800,15 @@
     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/tinyxml2.h b/tinyxml2.h
old mode 100644
new mode 100755
index ee83d2c..1beadaa
--- a/tinyxml2.h
+++ b/tinyxml2.h
@@ -98,13 +98,13 @@
 /* Versioning, past 1.0.14:

 	http://semver.org/

 */

-static const int TIXML2_MAJOR_VERSION = 7;

+static const int TIXML2_MAJOR_VERSION = 8;

 static const int TIXML2_MINOR_VERSION = 0;

-static const int TIXML2_PATCH_VERSION = 1;

+static const int TIXML2_PATCH_VERSION = 0;

 

-#define TINYXML2_MAJOR_VERSION 7

+#define TINYXML2_MAJOR_VERSION 8

 #define TINYXML2_MINOR_VERSION 0

-#define TINYXML2_PATCH_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 @@
         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

@@ -562,7 +562,7 @@
         TIXMLASSERT( p );

         return p;

     }

-    static char* SkipWhiteSpace( char* p, int* curLineNumPtr )				{

+    static char* SkipWhiteSpace( char* const p, int* curLineNumPtr ) {

         return const_cast<char*>( SkipWhiteSpace( const_cast<const char*>(p), curLineNumPtr ) );

     }

 

@@ -600,7 +600,7 @@
         return strncmp( p, q, nChar ) == 0;

     }

 

-    inline static bool IsUTF8Continuation( char p ) {

+    inline static bool IsUTF8Continuation( const char p ) {

         return ( p & 0x80 ) != 0;

     }

 

@@ -617,6 +617,7 @@
     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 @@
     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 @@
 		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 @@
     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

@@ -1213,7 +1222,9 @@
     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 );

@@ -1301,6 +1312,8 @@
 	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()

@@ -1347,6 +1360,15 @@
 		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 );

@@ -1413,7 +1435,11 @@
 		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 );

 	}

 

@@ -1447,7 +1473,13 @@
 		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 );

@@ -1546,6 +1578,8 @@
     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.

@@ -1585,6 +1619,8 @@
 	/// 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;

@@ -1597,12 +1633,29 @@
 	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()

 	double DoubleText(double defaultValue = 0) const;

 	/// See QueryIntText()

-	float FloatText(float defaultValue = 0) const;

+    float FloatText(float defaultValue = 0) const;

+

+    /**

+        Convenience method to create a new XMLElement and add it as last (right)

+        child of this node. Returns the created and inserted element.

+    */

+    XMLElement* InsertNewChildElement(const char* name);

+    /// See InsertNewChildElement()

+    XMLComment* InsertNewComment(const char* comment);

+    /// See InsertNewChildElement()

+    XMLText* InsertNewText(const char* text);

+    /// See InsertNewChildElement()

+    XMLDeclaration* InsertNewDeclaration(const char* text);

+    /// See InsertNewChildElement()

+    XMLUnknown* InsertNewUnknown(const char* text);

+

 

     // internal:

     enum ElementClosingType {

@@ -1684,7 +1737,7 @@
     	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.

@@ -1856,7 +1909,7 @@
     char* Identify( char* p, XMLNode** node );

 

 	// internal

-	void MarkInUse(XMLNode*);

+	void MarkInUse(const XMLNode* const);

 

     virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const	{

         return 0;

@@ -2194,7 +2247,8 @@
     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.

@@ -2206,8 +2260,10 @@
     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.

@@ -2253,10 +2309,10 @@
     	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:

diff --git a/tinyxml2/test.vcxproj b/tinyxml2/test.vcxproj
index 02bec85..df15660 100644
--- a/tinyxml2/test.vcxproj
+++ b/tinyxml2/test.vcxproj
@@ -37,60 +37,60 @@
   <PropertyGroup Label="Globals">

     <ProjectGuid>{E8FB2712-8666-4662-A5B8-2B5B0FB1A260}</ProjectGuid>

     <RootNamespace>test</RootNamespace>

-    <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>

+    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>

   </PropertyGroup>

   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|Win32'" Label="Configuration">

     <ConfigurationType>Application</ConfigurationType>

     <UseDebugLibraries>true</UseDebugLibraries>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|x64'" Label="Configuration">

     <ConfigurationType>Application</ConfigurationType>

     <UseDebugLibraries>true</UseDebugLibraries>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|Win32'" Label="Configuration">

     <ConfigurationType>Application</ConfigurationType>

     <UseDebugLibraries>true</UseDebugLibraries>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|x64'" Label="Configuration">

     <ConfigurationType>Application</ConfigurationType>

     <UseDebugLibraries>true</UseDebugLibraries>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|Win32'" Label="Configuration">

     <ConfigurationType>Application</ConfigurationType>

     <UseDebugLibraries>false</UseDebugLibraries>

     <WholeProgramOptimization>true</WholeProgramOptimization>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|x64'" Label="Configuration">

     <ConfigurationType>Application</ConfigurationType>

     <UseDebugLibraries>false</UseDebugLibraries>

     <WholeProgramOptimization>true</WholeProgramOptimization>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|Win32'" Label="Configuration">

     <ConfigurationType>Application</ConfigurationType>

     <UseDebugLibraries>false</UseDebugLibraries>

     <WholeProgramOptimization>true</WholeProgramOptimization>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|x64'" Label="Configuration">

     <ConfigurationType>Application</ConfigurationType>

     <UseDebugLibraries>false</UseDebugLibraries>

     <WholeProgramOptimization>true</WholeProgramOptimization>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">

     <CharacterSet>Unicode</CharacterSet>

diff --git a/tinyxml2/tinyxml2.vcxproj b/tinyxml2/tinyxml2.vcxproj
index 5a7b7ee..4e34f97 100755
--- a/tinyxml2/tinyxml2.vcxproj
+++ b/tinyxml2/tinyxml2.vcxproj
@@ -38,60 +38,60 @@
     <ProjectGuid>{D1C528B6-AA02-4D29-9D61-DC08E317A70D}</ProjectGuid>

     <Keyword>Win32Proj</Keyword>

     <RootNamespace>tinyxml2</RootNamespace>

-    <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>

+    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>

   </PropertyGroup>

   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|Win32'" Label="Configuration">

     <ConfigurationType>StaticLibrary</ConfigurationType>

     <UseDebugLibraries>true</UseDebugLibraries>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|Win32'" Label="Configuration">

     <ConfigurationType>DynamicLibrary</ConfigurationType>

     <UseDebugLibraries>true</UseDebugLibraries>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|x64'" Label="Configuration">

     <ConfigurationType>StaticLibrary</ConfigurationType>

     <UseDebugLibraries>true</UseDebugLibraries>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|x64'" Label="Configuration">

     <ConfigurationType>DynamicLibrary</ConfigurationType>

     <UseDebugLibraries>true</UseDebugLibraries>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|Win32'" Label="Configuration">

     <ConfigurationType>StaticLibrary</ConfigurationType>

     <UseDebugLibraries>false</UseDebugLibraries>

     <WholeProgramOptimization>true</WholeProgramOptimization>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|Win32'" Label="Configuration">

     <ConfigurationType>DynamicLibrary</ConfigurationType>

     <UseDebugLibraries>false</UseDebugLibraries>

     <WholeProgramOptimization>true</WholeProgramOptimization>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|x64'" Label="Configuration">

     <ConfigurationType>StaticLibrary</ConfigurationType>

     <UseDebugLibraries>false</UseDebugLibraries>

     <WholeProgramOptimization>true</WholeProgramOptimization>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|x64'" Label="Configuration">

     <ConfigurationType>DynamicLibrary</ConfigurationType>

     <UseDebugLibraries>false</UseDebugLibraries>

     <WholeProgramOptimization>true</WholeProgramOptimization>

     <CharacterSet>Unicode</CharacterSet>

-    <PlatformToolset>v141</PlatformToolset>

+    <PlatformToolset>v142</PlatformToolset>

   </PropertyGroup>

   <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">

     <ConfigurationType>StaticLibrary</ConfigurationType>

diff --git a/xmltest.cpp b/xmltest.cpp
old mode 100644
new mode 100755
index a0aaee7..adcba6d
--- a/xmltest.cpp
+++ b/xmltest.cpp
@@ -461,9 +461,9 @@
 		// Build:

 		//		<element>

 		//			<!--comment-->

+		//			<sub attrib="0" />

 		//			<sub attrib="1" />

-		//			<sub attrib="2" />

-		//			<sub attrib="3" >& Text!</sub>

+		//			<sub attrib="2" >& Text!</sub>

 		//		<element>

 

 		XMLDocument* doc = new XMLDocument();

@@ -804,6 +804,7 @@
 	// ---------- Attributes ---------

 	{

 		static const int64_t BIG = -123456789012345678;

+        static const uint64_t BIG_POS = 123456789012345678;

 		XMLDocument doc;

 		XMLElement* element = doc.NewElement("element");

 		doc.InsertFirstChild(element);

@@ -864,7 +865,23 @@
 			}

 			XMLTest("Attribute: int64_t", BIG, element->Int64Attribute("attrib"), true);

 		}

-		{

+        {

+            element->SetAttribute("attrib", BIG_POS);

+            {

+                uint64_t v = 0;

+                XMLError queryResult = element->QueryUnsigned64Attribute("attrib", &v);

+                XMLTest("Attribute: uint64_t", XML_SUCCESS, queryResult, true);

+                XMLTest("Attribute: uint64_t", BIG_POS, v, true);

+            }

+            {

+                uint64_t v = 0;

+                int queryResult = element->QueryAttribute("attrib", &v);

+                XMLTest("Attribute: uint64_t", (int)XML_SUCCESS, queryResult, true);

+                XMLTest("Attribute: uint64_t", BIG_POS, v, true);

+            }

+            XMLTest("Attribute: uint64_t", BIG_POS, element->Unsigned64Attribute("attrib"), true);

+        }

+        {

 			element->SetAttribute("attrib", true);

 			{

 				bool v = false;

@@ -931,7 +948,14 @@
 			XMLTest("Element: int64_t", XML_SUCCESS, queryResult, true);

 			XMLTest("Element: int64_t", BIG, v, true);

 		}

-	}

+        {

+            element->SetText(BIG_POS);

+            uint64_t v = 0;

+            XMLError queryResult = element->QueryUnsigned64Text(&v);

+            XMLTest("Element: uint64_t", XML_SUCCESS, queryResult, true);

+            XMLTest("Element: uint64_t", BIG_POS, v, true);

+        }

+    }

 

 	// ---------- XMLPrinter stream mode ------

 	{

@@ -944,6 +968,7 @@
 			printer.PushAttribute("attrib-int", int(1));

 			printer.PushAttribute("attrib-unsigned", unsigned(2));

 			printer.PushAttribute("attrib-int64", int64_t(3));

+			printer.PushAttribute("attrib-uint64", uint64_t(37));

 			printer.PushAttribute("attrib-bool", true);

 			printer.PushAttribute("attrib-double", 4.0);

 			printer.CloseElement();

@@ -964,12 +989,111 @@
 			XMLTest("attrib-unsigned", unsigned(2), attrib->UnsignedValue(), true);

 			attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-int64");

 			XMLTest("attrib-int64", int64_t(3), attrib->Int64Value(), true);

+			attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-uint64");

+			XMLTest("attrib-uint64", uint64_t(37), attrib->Unsigned64Value(), true);

 			attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-bool");

 			XMLTest("attrib-bool", true, attrib->BoolValue(), true);

 			attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-double");

 			XMLTest("attrib-double", 4.0, attrib->DoubleValue(), true);

 		}

+		// Add API_testcatse :PushDeclaration();PushText();PushComment()

+		{

+			FILE* fp1 = fopen("resources/out/printer_1.xml", "w");

+			XMLPrinter printer(fp1);

 

+			printer.PushDeclaration("version = '1.0' enconding = 'utf-8'");

+

+			printer.OpenElement("foo");

+			printer.PushAttribute("attrib-text", "text");

+

+			printer.OpenElement("text");

+			printer.PushText("Tinyxml2");

+			printer.CloseElement();

+

+			printer.OpenElement("int");

+			printer.PushText(int(11));

+			printer.CloseElement();

+

+			printer.OpenElement("unsigned");

+			printer.PushText(unsigned(12));

+			printer.CloseElement();

+

+			printer.OpenElement("int64_t");

+			printer.PushText(int64_t(13));

+			printer.CloseElement();

+

+			printer.OpenElement("uint64_t");

+			printer.PushText(uint64_t(14));

+			printer.CloseElement();

+

+			printer.OpenElement("bool");

+			printer.PushText(true);

+			printer.CloseElement();

+

+			printer.OpenElement("float");

+			printer.PushText("1.56");

+			printer.CloseElement();

+

+			printer.OpenElement("double");

+			printer.PushText("12.12");

+			printer.CloseElement();

+

+			printer.OpenElement("comment");

+			printer.PushComment("this is Tinyxml2");

+			printer.CloseElement();

+

+			printer.CloseElement();

+			fclose(fp1);

+		}

+		{

+			XMLDocument doc;

+			doc.LoadFile("resources/out/printer_1.xml");

+			XMLTest("XMLPrinter Stream mode: load", XML_SUCCESS, doc.ErrorID(), true);

+

+			const XMLDocument& cdoc = doc;

+

+			const  XMLElement* root = cdoc.FirstChildElement("foo");

+

+			const char* text_value;

+			text_value = root->FirstChildElement("text")->GetText();

+			XMLTest("PushText( const char* text, bool cdata=false ) test", "Tinyxml2", text_value);

+

+			int  int_value;

+			int_value = root->FirstChildElement("int")->IntText();

+			XMLTest("PushText( int value ) test", 11, int_value);

+

+			unsigned  unsigned_value;

+			unsigned_value = root->FirstChildElement("unsigned")->UnsignedText();

+			XMLTest("PushText( unsigned value ) test", (unsigned)12, unsigned_value);

+

+			int64_t  int64_t_value;

+			int64_t_value = root->FirstChildElement("int64_t")->Int64Text();

+			XMLTest("PushText( int64_t value ) test", (int64_t) 13, int64_t_value);

+

+			uint64_t uint64_t_value;

+			uint64_t_value = root->FirstChildElement("uint64_t")->Unsigned64Text();

+			XMLTest("PushText( uint64_t value ) test", (uint64_t) 14, uint64_t_value);

+

+			float  float_value;

+			float_value = root->FirstChildElement("float")->FloatText();

+			XMLTest("PushText( float value ) test", 1.56f, float_value);

+

+			double double_value;

+			double_value = root->FirstChildElement("double")->DoubleText();

+			XMLTest("PushText( double value ) test", 12.12, double_value);

+

+			bool bool_value;

+			bool_value = root->FirstChildElement("bool")->BoolText();

+			XMLTest("PushText( bool value ) test", true, bool_value);

+

+			const XMLComment* comment = root->FirstChildElement("comment")->FirstChild()->ToComment();

+			const char* comment_value = comment->Value();

+			XMLTest("PushComment() test", "this is Tinyxml2", comment_value);

+

+			const XMLDeclaration* declaration = cdoc.FirstChild()->ToDeclaration();

+			const char* declaration_value = declaration->Value();

+			XMLTest("PushDeclaration() test", "version = '1.0' enconding = 'utf-8'", declaration_value);

+		}

 	}

 

 

@@ -1263,7 +1387,7 @@
 	}

 

 	{

-		// trying to repro ]1874301]. If it doesn't go into an infinite loop, all is well.

+		// trying to repro [1874301]. If it doesn't go into an infinite loop, all is well.

 		unsigned char buf[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?><feed><![CDATA[Test XMLblablablalblbl";

 		buf[60] = 239;

 		buf[61] = 0;

@@ -1523,6 +1647,70 @@
 		XMLTest( "Ill formed XML", true, doc.Error() );

 	}

 

+    {

+        //API:IntText(),UnsignedText(),Int64Text(),DoubleText(),BoolText() and FloatText() test

+        const char* xml = "<point> <IntText>-24</IntText> <UnsignedText>42</UnsignedText> \

+						   <Int64Text>38</Int64Text> <BoolText>true</BoolText> <DoubleText>2.35</DoubleText> </point>";

+        XMLDocument doc;

+        doc.Parse(xml);

+

+        const XMLElement* pointElement = doc.RootElement();

+        int test1 = pointElement->FirstChildElement("IntText")->IntText();

+        XMLTest("IntText() test", -24, test1);

+

+        unsigned test2 = pointElement->FirstChildElement("UnsignedText")->UnsignedText();

+        XMLTest("UnsignedText() test", static_cast<unsigned>(42), test2);

+

+        int64_t test3 = pointElement->FirstChildElement("Int64Text")->Int64Text();

+        XMLTest("Int64Text() test", static_cast<int64_t>(38), test3);

+

+        double test4 = pointElement->FirstChildElement("DoubleText")->DoubleText();

+        XMLTest("DoubleText() test", 2.35, test4);

+

+        float test5 = pointElement->FirstChildElement("DoubleText")->FloatText();

+        XMLTest("FloatText()) test", 2.35f, test5);

+

+        bool test6 = pointElement->FirstChildElement("BoolText")->BoolText();

+        XMLTest("FloatText()) test", true, test6);

+    }

+

+	{

+		//API:ShallowEqual() test

+		const char* xml = "<playlist id = 'playlist'>"

+						    "<property name = 'track_name'>voice</property>"

+						  "</playlist>";

+		XMLDocument doc;

+		doc.Parse( xml );

+		const XMLNode* PlaylistNode = doc.RootElement();

+		const XMLNode* PropertyNode = PlaylistNode->FirstChildElement();

+		bool result;

+		result = PlaylistNode->ShallowEqual(PropertyNode);

+		XMLTest("ShallowEqual() test",false,result);

+		result = PlaylistNode->ShallowEqual(PlaylistNode);

+		XMLTest("ShallowEqual() test",true,result);

+	}

+

+	{

+		//API: previousSiblingElement() and NextSiblingElement() test

+		const char* xml = "<playlist id = 'playlist'>"

+						    "<property name = 'track_name'>voice</property>"

+						    "<entry out = '946' producer = '2_playlist1' in = '0'/>"

+							"<blank length = '1'/>"

+						  "</playlist>";

+		XMLDocument doc;

+		doc.Parse( xml );

+		XMLElement* ElementPlaylist = doc.FirstChildElement("playlist");

+		XMLTest("previousSiblingElement() test",true,ElementPlaylist != 0);

+		const XMLElement* pre = ElementPlaylist->PreviousSiblingElement();

+		XMLTest("previousSiblingElement() test",true,pre == 0);

+		const XMLElement* ElementBlank = ElementPlaylist->FirstChildElement("entry")->NextSiblingElement("blank");

+		XMLTest("NextSiblingElement() test",true,ElementBlank != 0);

+		const XMLElement* next = ElementBlank->NextSiblingElement();

+		XMLTest("NextSiblingElement() test",true,next == 0);

+		const XMLElement* ElementEntry = ElementBlank->PreviousSiblingElement("entry");

+		XMLTest("PreviousSiblingElement test",true,ElementEntry != 0);

+	}

+

 	// QueryXYZText

 	{

 		const char* xml = "<point> <x>1.2</x> <y>1</y> <z>38</z> <valid>true</valid> </point>";

@@ -1702,12 +1890,12 @@
             doc.Print( &printer );

 

             XMLTest( "BOM preservation (compare)", xml_bom_preservation, printer.CStr(), false, true );

-			doc.SaveFile( "resources/bomtest.xml" );

+			doc.SaveFile( "resources/out/bomtest.xml" );

 			XMLTest( "Save bomtest.xml", false, doc.Error() );

         }

 		{

 			XMLDocument doc;

-			doc.LoadFile( "resources/bomtest.xml" );

+			doc.LoadFile( "resources/out/bomtest.xml" );

 			XMLTest( "Load bomtest.xml", false, doc.Error() );

 			XMLTest( "BOM preservation (load)", true, doc.HasBOM(), false );