27 Commits
7.1.0 ... 8.0.0

Author SHA1 Message Date
Lee Thomason
bf15233ad8 Setting the version to 8.0.0 2020-03-01 17:40:07 -08:00
Lee Thomason
8504195843 fix vs version 2020-03-01 17:23:36 -08:00
Lee Thomason
8db004b74c Merge pull request #802 from LilyWangL/vcpkg-instructions
Add vcpkg installation instructions
2020-03-01 17:20:53 -08:00
Lee Thomason
3d6a5477a7 Merge pull request #797 from DanRStevens/gitIgnoreLinux
Add Makefile outputs to .gitignore
2020-03-01 17:12:24 -08:00
Lee Thomason
bbbb8c9a90 Merge branch 'master' of github.com:leethomason/tinyxml2 2020-03-01 17:11:07 -08:00
Lee Thomason
e444268103 add convenience methods 2020-03-01 17:10:38 -08:00
Lee Thomason
6ac05b2b9a Merge branch 'push' of https://github.com/ngc92/tinyxml2 into ngc92-push 2020-03-01 17:01:33 -08:00
Lee Thomason
655b15c078 Merge pull request #781 from daniel347x/patch-1
Change constants used in 'ToBool' to support MSVC
2020-03-01 16:53:40 -08:00
Lee Thomason
59b01033f3 Merge branch 'Alanscut-tinyxml2_addtestcase' 2020-03-01 16:53:00 -08:00
Lee Thomason
37ccc71008 fix some casting 2020-03-01 16:52:42 -08:00
Lee Thomason
3574d3e22f Merge branch 'tinyxml2_addtestcase' of https://github.com/Alanscut/tinyxml2 into Alanscut-tinyxml2_addtestcase 2020-03-01 16:49:10 -08:00
Lee Thomason
de62366e6a Merge branch 'master' of github.com:leethomason/tinyxml2 2020-03-01 16:47:26 -08:00
Lee Thomason
20f2d5eec7 Merge pull request #773 from Alanscut/fix_issue712
fix issue#712
2020-03-01 16:47:19 -08:00
Lee Thomason
a9c28ce3e3 Merge pull request #768 from Alanscut/fix_wrong_symbol
Fix wrong symbol in comment
2020-03-01 16:46:48 -08:00
Lee Thomason
2c642bf25e update to visstudio 2019 2020-03-01 16:46:30 -08:00
Lee Thomason
f4520c9905 Merge pull request #762 from orbitcowboy/master
Improved const correctness. There are no functional changes intended.
2020-03-01 16:42:35 -08:00
wangli28
1eb8a3f765 Add vcpkg installation instructions 2020-02-16 04:43:09 +00:00
Daniel Stevens
d09f879ada Add Makefile outputs to .gitignore 2020-02-04 03:05:01 -07:00
ngc92
e620245043 PushNewChild* family of convenience functions 2019-12-03 16:25:53 +01:00
Dan Nissenbaum
d7455034ea Change constants used in 'ToBool' to support MSVC
The tokens `TRUE` and `FALSE` are defined in current versions of MSVC, breaking compilation of tinyxml2.cpp in MSVC due to the use of these tokens as variable names in the function `XMLUtil::ToBool`.

Simply changing the variable names to something else resolves the problem.
2019-10-24 23:57:45 -04:00
Alanscut
7d9ca1e73c Supplementary test case
Update xmltest.cpp

Update xmltest.cpp
2019-09-27 16:22:49 +08:00
Alanscut
ad7bdf9ed2 fix issue#712 2019-09-21 15:51:14 +08:00
Alanscut
8916a3c587 fix wrong symbol 2019-09-16 17:03:12 +08:00
orbitcowboy
73f5409b62 Improved const correctness. There are no functional changes intended. 2019-08-14 09:30:30 +02:00
Lee Thomason
ff61650517 Merge branch 'master' of github.com:leethomason/tinyxml2 2019-08-10 18:05:53 -07:00
Lee Thomason
a9a0ea22fb Merge pull request #761 from untereiner/master
Add COMPONENT support at cmake install stage
2019-08-10 18:03:03 -07:00
Lionel Untereiner
d39b13bbb7 Add COMPONENT support at cmake install stage
It enables a per component install / packaging with cmake / cpack (but not mandatory)
2019-07-24 12:56:51 +02:00
9 changed files with 218 additions and 52 deletions

2
.gitignore vendored
View File

@@ -18,3 +18,5 @@ tinyxml2/temp/
*.o
*.vc.db
*.vc.opendb
libtinyxml2.a
xmltest

View File

@@ -21,8 +21,8 @@ include(CTest)
################################
# set lib version here
set(GENERIC_LIB_VERSION "7.1.0")
set(GENERIC_LIB_SOVERSION "7")
set(GENERIC_LIB_VERSION "8.0.0")
set(GENERIC_LIB_SOVERSION "8")
################################
# Add definitions
@@ -79,9 +79,15 @@ export(TARGETS tinyxml2
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 @@ if(BUILD_TESTING AND BUILD_TESTS)
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)
@@ -129,7 +135,9 @@ write_basic_package_version_file(
install(FILES
${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})
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)

2
dox
View File

@@ -38,7 +38,7 @@ PROJECT_NAME = "TinyXML-2"
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 7.1.0
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

View File

@@ -262,11 +262,24 @@ There are 2 files in TinyXML-2:
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 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
----------

View File

@@ -617,17 +617,17 @@ bool XMLUtil::ToBool( const char* str, bool* value )
*value = (ival==0) ? false : true;
return true;
}
static const char* TRUE[] = { "true", "True", "TRUE", 0 };
static const char* FALSE[] = { "false", "False", "FALSE", 0 };
static const char* TRUE_VALS[] = { "true", "True", "TRUE", 0 };
static const char* FALSE_VALS[] = { "false", "False", "FALSE", 0 };
for (int i = 0; TRUE[i]; ++i) {
if (StringEqual(str, TRUE[i])) {
for (int i = 0; TRUE_VALS[i]; ++i) {
if (StringEqual(str, TRUE_VALS[i])) {
*value = true;
return true;
}
}
for (int i = 0; FALSE[i]; ++i) {
if (StringEqual(str, FALSE[i])) {
for (int i = 0; FALSE_VALS[i]; ++i) {
if (StringEqual(str, FALSE_VALS[i])) {
*value = false;
return true;
}
@@ -1961,6 +1961,39 @@ XMLAttribute* XMLElement::CreateAttribute()
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>
@@ -2101,7 +2134,7 @@ XMLDocument::~XMLDocument()
}
void XMLDocument::MarkInUse(XMLNode* node)
void XMLDocument::MarkInUse(const XMLNode* const node)
{
TIXMLASSERT(node);
TIXMLASSERT(node->_parent == 0);
@@ -2635,8 +2668,6 @@ void XMLPrinter::OpenElement( const char* name, bool compactMode )
if ( _textDepth < 0 && !_firstElement && !compactMode ) {
Putc( '\n' );
}
if ( !compactMode ) {
PrintSpace( _depth );
}

View File

@@ -98,12 +98,12 @@ distribution.
/* Versioning, past 1.0.14:
http://semver.org/
*/
static const int TIXML2_MAJOR_VERSION = 7;
static const int TIXML2_MINOR_VERSION = 1;
static const int TIXML2_MAJOR_VERSION = 8;
static const int TIXML2_MINOR_VERSION = 0;
static const int TIXML2_PATCH_VERSION = 0;
#define TINYXML2_MAJOR_VERSION 7
#define TINYXML2_MINOR_VERSION 1
#define TINYXML2_MAJOR_VERSION 8
#define TINYXML2_MINOR_VERSION 0
#define TINYXML2_PATCH_VERSION 0
// A fixed element depth limit is problematic. There needs to be a
@@ -562,7 +562,7 @@ public:
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 @@ public:
return strncmp( p, q, nChar ) == 0;
}
inline static bool IsUTF8Continuation( char p ) {
inline static bool IsUTF8Continuation( const char p ) {
return ( p & 0x80 ) != 0;
}
@@ -1640,7 +1640,22 @@ public:
/// 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 {
@@ -1894,7 +1909,7 @@ public:
char* Identify( char* p, XMLNode** node );
// internal
void MarkInUse(XMLNode*);
void MarkInUse(const XMLNode* const);
virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const {
return 0;

View File

@@ -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>

View File

@@ -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>

View File

@@ -968,8 +968,8 @@ int main( int argc, const char ** argv )
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 @@ int main( int argc, const char ** argv )
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 @@ int main( int argc, const char ** argv )
}
{
// 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;