Merge branch 'push' of https://github.com/ngc92/tinyxml2 into ngc92-push
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 4ff722b..0467d17 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -2141,7 +2141,7 @@
}
-void XMLDocument::MarkInUse(XMLNode* node)
+void XMLDocument::MarkInUse(const XMLNode* const node)
{
TIXMLASSERT(node);
TIXMLASSERT(node->_parent == 0);
@@ -2675,8 +2675,6 @@
if ( _textDepth < 0 && !_firstElement && !compactMode ) {
Putc( '\n' );
- }
- if ( !compactMode ) {
PrintSpace( _depth );
}
diff --git a/tinyxml2.h b/tinyxml2.h
index c589fdb..25b59c3 100755
--- a/tinyxml2.h
+++ b/tinyxml2.h
@@ -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;
}
@@ -1909,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;
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
index 5a07547..adcba6d 100755
--- a/xmltest.cpp
+++ b/xmltest.cpp
@@ -968,8 +968,8 @@
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-uint64", uint64_t(37));
+ printer.PushAttribute("attrib-bool", true);
printer.PushAttribute("attrib-double", 4.0);
printer.CloseElement();
fclose(printerfp);
@@ -989,14 +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");
+ 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);
+ }
}
@@ -1290,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;