mirror of
https://github.com/leethomason/tinyxml2.git
synced 2026-07-29 15:13:01 +04:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 118358092a | |||
| 888bbb912a | |||
| 9c09e46619 | |||
| 6d6285b18a | |||
| 2722500313 | |||
| be7b5a107f | |||
| b5e767a6b9 | |||
| e186491558 | |||
| 36ff404c34 | |||
| 302f4661a7 | |||
| e6caeae857 | |||
| b765a210b3 | |||
| 6e246aec4d | |||
| 30dee1efa0 | |||
| a93163d2f5 | |||
| f87d0e3077 | |||
| 487f42aa69 | |||
| afff7bf328 | |||
| 9148bdf719 | |||
| 57eea48c5b | |||
| 198cb82c9b | |||
| c6ab6d76e8 | |||
| 008e32968f | |||
| 0ca3584fa4 | |||
| 57ec94127b | |||
| 1fadaae0c9 | |||
| 4cbb25155c |
@@ -6,15 +6,15 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ windows-2019, macos-latest, ubuntu-20.04 ]
|
os: [ windows-latest, macos-latest, ubuntu-latest ]
|
||||||
cmake: [ 3.15, 3.x ]
|
cmake: [ 3.15, 3.x ]
|
||||||
include:
|
include:
|
||||||
- os: windows-2019
|
- os: windows-latest
|
||||||
static_postfix: _static
|
static_postfix: _static
|
||||||
tree: tree /F
|
tree: tree /F
|
||||||
CXX: cl
|
CXX: cl
|
||||||
|
|
||||||
- os: ubuntu-20.04
|
- os: ubuntu-latest
|
||||||
tree: tree
|
tree: tree
|
||||||
|
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
@@ -33,7 +33,7 @@ jobs:
|
|||||||
# System set-up
|
# System set-up
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: ilammy/msvc-dev-cmd@v1
|
- uses: ilammy/msvc-dev-cmd@v1
|
||||||
- uses: seanmiddleditch/gha-setup-ninja@master
|
- uses: seanmiddleditch/gha-setup-ninja@v4
|
||||||
- uses: jwlawson/actions-setup-cmake@v2
|
- uses: jwlawson/actions-setup-cmake@v2
|
||||||
with:
|
with:
|
||||||
cmake-version: ${{ matrix.cmake }}
|
cmake-version: ${{ matrix.cmake }}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.15)
|
cmake_minimum_required(VERSION 3.15)
|
||||||
project(tinyxml2 VERSION 10.0.0)
|
project(tinyxml2 VERSION 11.0.0)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
option(tinyxml2_BUILD_TESTING "Build tests for tinyxml2" "${BUILD_TESTING}")
|
option(tinyxml2_BUILD_TESTING "Build tests for tinyxml2" "${BUILD_TESTING}")
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ PROJECT_NAME = "TinyXML-2"
|
|||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = 10.0.0
|
PROJECT_NUMBER = 11.0.0
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# 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
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@
|
|||||||
project(
|
project(
|
||||||
'tinyxml2',
|
'tinyxml2',
|
||||||
['cpp'],
|
['cpp'],
|
||||||
version : '10.0.0',
|
version : '11.0.0',
|
||||||
meson_version : '>= 0.49.0',
|
meson_version : '>= 0.49.0',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+33
-5
@@ -24,7 +24,7 @@ distribution.
|
|||||||
#include "tinyxml2.h"
|
#include "tinyxml2.h"
|
||||||
|
|
||||||
#include <new> // yes, this one new style header, is in the Android SDK.
|
#include <new> // yes, this one new style header, is in the Android SDK.
|
||||||
#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
|
#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) || defined(__CC_ARM)
|
||||||
# include <stddef.h>
|
# include <stddef.h>
|
||||||
# include <stdarg.h>
|
# include <stdarg.h>
|
||||||
#else
|
#else
|
||||||
@@ -32,6 +32,27 @@ distribution.
|
|||||||
# include <cstdarg>
|
# include <cstdarg>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Handle fallthrough attribute for different compilers
|
||||||
|
#ifndef __has_attribute
|
||||||
|
# define __has_attribute(x) 0
|
||||||
|
#endif
|
||||||
|
#ifndef __has_cpp_attribute
|
||||||
|
# define __has_cpp_attribute(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# define TIXML_FALLTHROUGH (void(0))
|
||||||
|
#elif (__cplusplus >= 201703L && __has_cpp_attribute(fallthrough))
|
||||||
|
# define TIXML_FALLTHROUGH [[fallthrough]]
|
||||||
|
#elif __has_cpp_attribute(clang::fallthrough)
|
||||||
|
# define TIXML_FALLTHROUGH [[clang::fallthrough]]
|
||||||
|
#elif __has_attribute(fallthrough)
|
||||||
|
# define TIXML_FALLTHROUGH __attribute__((fallthrough))
|
||||||
|
#else
|
||||||
|
# define TIXML_FALLTHROUGH (void(0))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
|
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
|
||||||
// Microsoft Visual Studio, version 2005 and higher. Not WinCE.
|
// Microsoft Visual Studio, version 2005 and higher. Not WinCE.
|
||||||
/*int _snprintf_s(
|
/*int _snprintf_s(
|
||||||
@@ -446,17 +467,17 @@ void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length
|
|||||||
--output;
|
--output;
|
||||||
*output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
|
*output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
|
||||||
input >>= 6;
|
input >>= 6;
|
||||||
//fall through
|
TIXML_FALLTHROUGH;
|
||||||
case 3:
|
case 3:
|
||||||
--output;
|
--output;
|
||||||
*output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
|
*output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
|
||||||
input >>= 6;
|
input >>= 6;
|
||||||
//fall through
|
TIXML_FALLTHROUGH;
|
||||||
case 2:
|
case 2:
|
||||||
--output;
|
--output;
|
||||||
*output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
|
*output = static_cast<char>((input | BYTE_MARK) & BYTE_MASK);
|
||||||
input >>= 6;
|
input >>= 6;
|
||||||
//fall through
|
TIXML_FALLTHROUGH;
|
||||||
case 1:
|
case 1:
|
||||||
--output;
|
--output;
|
||||||
*output = static_cast<char>(input | FIRST_BYTE_MARK[*length]);
|
*output = static_cast<char>(input | FIRST_BYTE_MARK[*length]);
|
||||||
@@ -545,6 +566,11 @@ const char* XMLUtil::GetCharacterRef(const char* p, char* value, int* length)
|
|||||||
}
|
}
|
||||||
// convert the UCS to UTF-8
|
// convert the UCS to UTF-8
|
||||||
ConvertUTF32ToUTF8(ucs, value, length);
|
ConvertUTF32ToUTF8(ucs, value, length);
|
||||||
|
if (length == 0) {
|
||||||
|
// If length is 0, there was an error. (Security? Bad input?)
|
||||||
|
// Fail safely.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return p + delta + 1;
|
return p + delta + 1;
|
||||||
}
|
}
|
||||||
return p + 1;
|
return p + 1;
|
||||||
@@ -2572,7 +2598,7 @@ void XMLDocument::PopDepth()
|
|||||||
--_parsingDepth;
|
--_parsingDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) :
|
XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth, EscapeAposCharsInAttributes aposInAttributes ) :
|
||||||
_elementJustOpened( false ),
|
_elementJustOpened( false ),
|
||||||
_stack(),
|
_stack(),
|
||||||
_firstElement( true ),
|
_firstElement( true ),
|
||||||
@@ -2589,10 +2615,12 @@ XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) :
|
|||||||
}
|
}
|
||||||
for( int i=0; i<NUM_ENTITIES; ++i ) {
|
for( int i=0; i<NUM_ENTITIES; ++i ) {
|
||||||
const char entityValue = entities[i].value;
|
const char entityValue = entities[i].value;
|
||||||
|
if ((aposInAttributes == ESCAPE_APOS_CHARS_IN_ATTRIBUTES) || (entityValue != SINGLE_QUOTE)) {
|
||||||
const unsigned char flagIndex = static_cast<unsigned char>(entityValue);
|
const unsigned char flagIndex = static_cast<unsigned char>(entityValue);
|
||||||
TIXMLASSERT( flagIndex < ENTITY_RANGE );
|
TIXMLASSERT( flagIndex < ENTITY_RANGE );
|
||||||
_entityFlag[flagIndex] = true;
|
_entityFlag[flagIndex] = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
_restrictedEntityFlag[static_cast<unsigned char>('&')] = true;
|
_restrictedEntityFlag[static_cast<unsigned char>('&')] = true;
|
||||||
_restrictedEntityFlag[static_cast<unsigned char>('<')] = true;
|
_restrictedEntityFlag[static_cast<unsigned char>('<')] = true;
|
||||||
_restrictedEntityFlag[static_cast<unsigned char>('>')] = true; // not required, but consistency is nice
|
_restrictedEntityFlag[static_cast<unsigned char>('>')] = true; // not required, but consistency is nice
|
||||||
|
|||||||
+8
-4
@@ -96,11 +96,11 @@ distribution.
|
|||||||
/* Versioning, past 1.0.14:
|
/* Versioning, past 1.0.14:
|
||||||
http://semver.org/
|
http://semver.org/
|
||||||
*/
|
*/
|
||||||
static const int TIXML2_MAJOR_VERSION = 10;
|
static const int TIXML2_MAJOR_VERSION = 11;
|
||||||
static const int TIXML2_MINOR_VERSION = 0;
|
static const int TIXML2_MINOR_VERSION = 0;
|
||||||
static const int TIXML2_PATCH_VERSION = 0;
|
static const int TIXML2_PATCH_VERSION = 0;
|
||||||
|
|
||||||
#define TINYXML2_MAJOR_VERSION 10
|
#define TINYXML2_MAJOR_VERSION 11
|
||||||
#define TINYXML2_MINOR_VERSION 0
|
#define TINYXML2_MINOR_VERSION 0
|
||||||
#define TINYXML2_PATCH_VERSION 0
|
#define TINYXML2_PATCH_VERSION 0
|
||||||
|
|
||||||
@@ -266,7 +266,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t Size() const {
|
size_t Size() const {
|
||||||
TIXMLASSERT( _size >= 0 );
|
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2240,13 +2239,18 @@ private:
|
|||||||
class TINYXML2_LIB XMLPrinter : public XMLVisitor
|
class TINYXML2_LIB XMLPrinter : public XMLVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum EscapeAposCharsInAttributes {
|
||||||
|
ESCAPE_APOS_CHARS_IN_ATTRIBUTES,
|
||||||
|
DONT_ESCAPE_APOS_CHARS_IN_ATTRIBUTES
|
||||||
|
};
|
||||||
|
|
||||||
/** Construct the printer. If the FILE* is specified,
|
/** Construct the printer. If the FILE* is specified,
|
||||||
this will print to the FILE. Else it will print
|
this will print to the FILE. Else it will print
|
||||||
to memory, and the result is available in CStr().
|
to memory, and the result is available in CStr().
|
||||||
If 'compact' is set to true, then output is created
|
If 'compact' is set to true, then output is created
|
||||||
with only required whitespace and newlines.
|
with only required whitespace and newlines.
|
||||||
*/
|
*/
|
||||||
XMLPrinter( FILE* file=0, bool compact = false, int depth = 0 );
|
XMLPrinter( FILE* file=0, bool compact = false, int depth = 0, EscapeAposCharsInAttributes aposInAttributes = ESCAPE_APOS_CHARS_IN_ATTRIBUTES );
|
||||||
virtual ~XMLPrinter() {}
|
virtual ~XMLPrinter() {}
|
||||||
|
|
||||||
/** If streaming, write the BOM and declaration. */
|
/** If streaming, write the BOM and declaration. */
|
||||||
|
|||||||
+62
-27
@@ -324,9 +324,9 @@ int main( int argc, const char ** argv )
|
|||||||
|
|
||||||
printf( "Test file '%s' loaded. ErrorID=%d\n", argv[1], errorID );
|
printf( "Test file '%s' loaded. ErrorID=%d\n", argv[1], errorID );
|
||||||
if ( !errorID ) {
|
if ( !errorID ) {
|
||||||
printf( "Load time=%u\n", (unsigned)(loadTime - startTime) );
|
printf( "Load time=%u\n", static_cast<unsigned>(loadTime - startTime) );
|
||||||
printf( "Delete time=%u\n", (unsigned)(deleteTime - loadTime) );
|
printf( "Delete time=%u\n", static_cast<unsigned>(deleteTime - loadTime) );
|
||||||
printf( "Total time=%u\n", (unsigned)(deleteTime - startTime) );
|
printf( "Total time=%u\n", static_cast<unsigned>(deleteTime - startTime) );
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -595,8 +595,8 @@ int main( int argc, const char ** argv )
|
|||||||
|
|
||||||
result = ele->QueryDoubleAttribute( "attr0", &dVal );
|
result = ele->QueryDoubleAttribute( "attr0", &dVal );
|
||||||
XMLTest( "Query attribute: int as double", XML_SUCCESS, result);
|
XMLTest( "Query attribute: int as double", XML_SUCCESS, result);
|
||||||
XMLTest( "Query attribute: int as double", 1, (int)dVal );
|
XMLTest( "Query attribute: int as double", 1, static_cast<int>(dVal) );
|
||||||
XMLTest( "Query attribute: int as double", 1, (int)ele->DoubleAttribute("attr0"));
|
XMLTest( "Query attribute: int as double", 1, static_cast<int>(ele->DoubleAttribute("attr0")));
|
||||||
|
|
||||||
result = ele->QueryDoubleAttribute( "attr1", &dVal );
|
result = ele->QueryDoubleAttribute( "attr1", &dVal );
|
||||||
XMLTest( "Query attribute: double as double", XML_SUCCESS, result);
|
XMLTest( "Query attribute: double as double", XML_SUCCESS, result);
|
||||||
@@ -648,17 +648,17 @@ int main( int argc, const char ** argv )
|
|||||||
|
|
||||||
{
|
{
|
||||||
XMLError queryResult = ele->QueryAttribute( "int", &iVal2 );
|
XMLError queryResult = ele->QueryAttribute( "int", &iVal2 );
|
||||||
XMLTest( "Query int attribute generic", (int)XML_SUCCESS, queryResult);
|
XMLTest( "Query int attribute generic", static_cast<int>(XML_SUCCESS), queryResult);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
XMLError queryResult = ele->QueryAttribute( "double", &dVal2 );
|
XMLError queryResult = ele->QueryAttribute( "double", &dVal2 );
|
||||||
XMLTest( "Query double attribute generic", (int)XML_SUCCESS, queryResult);
|
XMLTest( "Query double attribute generic", static_cast<int>(XML_SUCCESS), queryResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLTest( "Attribute match test", "strValue", ele->Attribute( "str", "strValue" ) );
|
XMLTest( "Attribute match test", "strValue", ele->Attribute( "str", "strValue" ) );
|
||||||
XMLTest( "Attribute round trip. c-string.", "strValue", cStr );
|
XMLTest( "Attribute round trip. c-string.", "strValue", cStr );
|
||||||
XMLTest( "Attribute round trip. int.", 1, iVal );
|
XMLTest( "Attribute round trip. int.", 1, iVal );
|
||||||
XMLTest( "Attribute round trip. double.", -1, (int)dVal );
|
XMLTest( "Attribute round trip. double.", -1, static_cast<int>(dVal) );
|
||||||
XMLTest( "Alternate query", true, iVal == iVal2 );
|
XMLTest( "Alternate query", true, iVal == iVal2 );
|
||||||
XMLTest( "Alternate query", true, dVal == dVal2 );
|
XMLTest( "Alternate query", true, dVal == dVal2 );
|
||||||
XMLTest( "Alternate query", true, iVal == ele->IntAttribute("int") );
|
XMLTest( "Alternate query", true, iVal == ele->IntAttribute("int") );
|
||||||
@@ -675,7 +675,7 @@ int main( int argc, const char ** argv )
|
|||||||
const unsigned char correctValue[] = { 0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU,
|
const unsigned char correctValue[] = { 0xd1U, 0x86U, 0xd0U, 0xb5U, 0xd0U, 0xbdU, 0xd0U, 0xbdU,
|
||||||
0xd0U, 0xbeU, 0xd1U, 0x81U, 0xd1U, 0x82U, 0xd1U, 0x8cU, 0 };
|
0xd0U, 0xbeU, 0xd1U, 0x81U, 0xd1U, 0x82U, 0xd1U, 0x8cU, 0 };
|
||||||
|
|
||||||
XMLTest( "UTF-8: Russian value.", (const char*)correctValue, element->Attribute( "value" ) );
|
XMLTest( "UTF-8: Russian value.", reinterpret_cast<const char*>(correctValue), element->Attribute( "value" ) );
|
||||||
|
|
||||||
const unsigned char russianElementName[] = { 0xd0U, 0xa0U, 0xd1U, 0x83U,
|
const unsigned char russianElementName[] = { 0xd0U, 0xa0U, 0xd1U, 0x83U,
|
||||||
0xd1U, 0x81U, 0xd1U, 0x81U,
|
0xd1U, 0x81U, 0xd1U, 0x81U,
|
||||||
@@ -683,7 +683,7 @@ int main( int argc, const char ** argv )
|
|||||||
0xd0U, 0xb9U, 0 };
|
0xd0U, 0xb9U, 0 };
|
||||||
const char russianText[] = "<\xD0\xB8\xD0\xBC\xD0\xB5\xD0\xB5\xD1\x82>";
|
const char russianText[] = "<\xD0\xB8\xD0\xBC\xD0\xB5\xD0\xB5\xD1\x82>";
|
||||||
|
|
||||||
XMLText* text = doc.FirstChildElement( "document" )->FirstChildElement( (const char*) russianElementName )->FirstChild()->ToText();
|
XMLText* text = doc.FirstChildElement( "document" )->FirstChildElement( reinterpret_cast<const char*>(russianElementName) )->FirstChild()->ToText();
|
||||||
XMLTest( "UTF-8: Browsing russian element name.",
|
XMLTest( "UTF-8: Browsing russian element name.",
|
||||||
russianText,
|
russianText,
|
||||||
text->Value() );
|
text->Value() );
|
||||||
@@ -824,7 +824,7 @@ int main( int argc, const char ** argv )
|
|||||||
{
|
{
|
||||||
int v = 0;
|
int v = 0;
|
||||||
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
||||||
XMLTest("Attribute: int", (int)XML_SUCCESS, queryResult, true);
|
XMLTest("Attribute: int", static_cast<int>(XML_SUCCESS), queryResult, true);
|
||||||
XMLTest("Attribute: int", -100, v, true);
|
XMLTest("Attribute: int", -100, v, true);
|
||||||
}
|
}
|
||||||
XMLTest("Attribute: int", -100, element->IntAttribute("attrib"), true);
|
XMLTest("Attribute: int", -100, element->IntAttribute("attrib"), true);
|
||||||
@@ -840,7 +840,7 @@ int main( int argc, const char ** argv )
|
|||||||
{
|
{
|
||||||
unsigned v = 0;
|
unsigned v = 0;
|
||||||
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
||||||
XMLTest("Attribute: unsigned", (int)XML_SUCCESS, queryResult, true);
|
XMLTest("Attribute: unsigned", static_cast<int>(XML_SUCCESS), queryResult, true);
|
||||||
XMLTest("Attribute: unsigned", unsigned(100), v, true);
|
XMLTest("Attribute: unsigned", unsigned(100), v, true);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -864,7 +864,7 @@ int main( int argc, const char ** argv )
|
|||||||
{
|
{
|
||||||
int64_t v = 0;
|
int64_t v = 0;
|
||||||
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
||||||
XMLTest("Attribute: int64_t", (int)XML_SUCCESS, queryResult, true);
|
XMLTest("Attribute: int64_t", static_cast<int>(XML_SUCCESS), queryResult, true);
|
||||||
XMLTest("Attribute: int64_t", BIG, v, true);
|
XMLTest("Attribute: int64_t", BIG, v, true);
|
||||||
}
|
}
|
||||||
XMLTest("Attribute: int64_t", BIG, element->Int64Attribute("attrib"), true);
|
XMLTest("Attribute: int64_t", BIG, element->Int64Attribute("attrib"), true);
|
||||||
@@ -880,7 +880,7 @@ int main( int argc, const char ** argv )
|
|||||||
{
|
{
|
||||||
uint64_t v = 0;
|
uint64_t v = 0;
|
||||||
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
||||||
XMLTest("Attribute: uint64_t", (int)XML_SUCCESS, queryResult, true);
|
XMLTest("Attribute: uint64_t", static_cast<int>(XML_SUCCESS), queryResult, true);
|
||||||
XMLTest("Attribute: uint64_t", BIG_POS, v, true);
|
XMLTest("Attribute: uint64_t", BIG_POS, v, true);
|
||||||
}
|
}
|
||||||
XMLTest("Attribute: uint64_t", BIG_POS, element->Unsigned64Attribute("attrib"), true);
|
XMLTest("Attribute: uint64_t", BIG_POS, element->Unsigned64Attribute("attrib"), true);
|
||||||
@@ -896,7 +896,7 @@ int main( int argc, const char ** argv )
|
|||||||
{
|
{
|
||||||
bool v = false;
|
bool v = false;
|
||||||
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
||||||
XMLTest("Attribute: bool", (int)XML_SUCCESS, queryResult, true);
|
XMLTest("Attribute: bool", static_cast<int>(XML_SUCCESS), queryResult, true);
|
||||||
XMLTest("Attribute: bool", true, v, true);
|
XMLTest("Attribute: bool", true, v, true);
|
||||||
}
|
}
|
||||||
XMLTest("Attribute: bool", true, element->BoolAttribute("attrib"), true);
|
XMLTest("Attribute: bool", true, element->BoolAttribute("attrib"), true);
|
||||||
@@ -924,7 +924,7 @@ int main( int argc, const char ** argv )
|
|||||||
{
|
{
|
||||||
double v = 0;
|
double v = 0;
|
||||||
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
||||||
XMLTest("Attribute: bool", (int)XML_SUCCESS, queryResult, true);
|
XMLTest("Attribute: bool", static_cast<int>(XML_SUCCESS), queryResult, true);
|
||||||
XMLTest("Attribute: double", 100.0, v, true);
|
XMLTest("Attribute: double", 100.0, v, true);
|
||||||
}
|
}
|
||||||
XMLTest("Attribute: double", 100.0, element->DoubleAttribute("attrib"), true);
|
XMLTest("Attribute: double", 100.0, element->DoubleAttribute("attrib"), true);
|
||||||
@@ -940,7 +940,7 @@ int main( int argc, const char ** argv )
|
|||||||
{
|
{
|
||||||
float v = 0;
|
float v = 0;
|
||||||
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
XMLError queryResult = element->QueryAttribute("attrib", &v);
|
||||||
XMLTest("Attribute: float", (int)XML_SUCCESS, queryResult, true);
|
XMLTest("Attribute: float", static_cast<int>(XML_SUCCESS), queryResult, true);
|
||||||
XMLTest("Attribute: float", 100.0f, v, true);
|
XMLTest("Attribute: float", 100.0f, v, true);
|
||||||
}
|
}
|
||||||
XMLTest("Attribute: float", 100.0f, element->FloatAttribute("attrib"), true);
|
XMLTest("Attribute: float", 100.0f, element->FloatAttribute("attrib"), true);
|
||||||
@@ -1005,7 +1005,7 @@ int main( int argc, const char ** argv )
|
|||||||
FILE* fp1 = fopen("resources/out/printer_1.xml", "w");
|
FILE* fp1 = fopen("resources/out/printer_1.xml", "w");
|
||||||
XMLPrinter printer(fp1);
|
XMLPrinter printer(fp1);
|
||||||
|
|
||||||
printer.PushDeclaration("version = '1.0' enconding = 'utf-8'");
|
printer.PushDeclaration("version = '1.0' encoding = 'utf-8'");
|
||||||
|
|
||||||
printer.OpenElement("foo");
|
printer.OpenElement("foo");
|
||||||
printer.PushAttribute("attrib-text", "text");
|
printer.PushAttribute("attrib-text", "text");
|
||||||
@@ -1068,15 +1068,15 @@ int main( int argc, const char ** argv )
|
|||||||
|
|
||||||
unsigned unsigned_value;
|
unsigned unsigned_value;
|
||||||
unsigned_value = root->FirstChildElement("unsigned")->UnsignedText();
|
unsigned_value = root->FirstChildElement("unsigned")->UnsignedText();
|
||||||
XMLTest("PushText( unsigned value ) test", (unsigned)12, unsigned_value);
|
XMLTest("PushText( unsigned value ) test", static_cast<unsigned>(12), unsigned_value);
|
||||||
|
|
||||||
int64_t int64_t_value;
|
int64_t int64_t_value;
|
||||||
int64_t_value = root->FirstChildElement("int64_t")->Int64Text();
|
int64_t_value = root->FirstChildElement("int64_t")->Int64Text();
|
||||||
XMLTest("PushText( int64_t value ) test", (int64_t) 13, int64_t_value);
|
XMLTest("PushText( int64_t value ) test", static_cast<int64_t>(13), int64_t_value);
|
||||||
|
|
||||||
uint64_t uint64_t_value;
|
uint64_t uint64_t_value;
|
||||||
uint64_t_value = root->FirstChildElement("uint64_t")->Unsigned64Text();
|
uint64_t_value = root->FirstChildElement("uint64_t")->Unsigned64Text();
|
||||||
XMLTest("PushText( uint64_t value ) test", (uint64_t) 14, uint64_t_value);
|
XMLTest("PushText( uint64_t value ) test", static_cast<uint64_t>(14), uint64_t_value);
|
||||||
|
|
||||||
float float_value;
|
float float_value;
|
||||||
float_value = root->FirstChildElement("float")->FloatText();
|
float_value = root->FirstChildElement("float")->FloatText();
|
||||||
@@ -1096,7 +1096,7 @@ int main( int argc, const char ** argv )
|
|||||||
|
|
||||||
const XMLDeclaration* declaration = cdoc.FirstChild()->ToDeclaration();
|
const XMLDeclaration* declaration = cdoc.FirstChild()->ToDeclaration();
|
||||||
const char* declaration_value = declaration->Value();
|
const char* declaration_value = declaration->Value();
|
||||||
XMLTest("PushDeclaration() test", "version = '1.0' enconding = 'utf-8'", declaration_value);
|
XMLTest("PushDeclaration() test", "version = '1.0' encoding = 'utf-8'", declaration_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1397,7 +1397,7 @@ int main( int argc, const char ** argv )
|
|||||||
buf[61] = 0;
|
buf[61] = 0;
|
||||||
|
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( (const char*)buf);
|
doc.Parse( reinterpret_cast<const char*>(buf) );
|
||||||
XMLTest( "Broken CDATA", true, doc.Error() );
|
XMLTest( "Broken CDATA", true, doc.Error() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1753,7 +1753,7 @@ int main( int argc, const char ** argv )
|
|||||||
unsigned unsignedValue = 0;
|
unsigned unsignedValue = 0;
|
||||||
XMLError queryResult = pointElement->FirstChildElement( "y" )->QueryUnsignedText( &unsignedValue );
|
XMLError queryResult = pointElement->FirstChildElement( "y" )->QueryUnsignedText( &unsignedValue );
|
||||||
XMLTest( "QueryUnsignedText result", XML_SUCCESS, queryResult, false );
|
XMLTest( "QueryUnsignedText result", XML_SUCCESS, queryResult, false );
|
||||||
XMLTest( "QueryUnsignedText", (unsigned)1, unsignedValue, false );
|
XMLTest( "QueryUnsignedText", static_cast<unsigned>(1), unsignedValue, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -2639,7 +2639,7 @@ int main( int argc, const char ** argv )
|
|||||||
"<?xml version=\"1.0\"?>\n" // 2 DecL
|
"<?xml version=\"1.0\"?>\n" // 2 DecL
|
||||||
"<root>\r\n" // 3 Element
|
"<root>\r\n" // 3 Element
|
||||||
"\n" // 4
|
"\n" // 4
|
||||||
"text contining new line \n" // 5 Text
|
"text containing new line \n" // 5 Text
|
||||||
" and also containing crlf \r\n" // 6
|
" and also containing crlf \r\n" // 6
|
||||||
"<sub><![CDATA[\n" // 7 Element Text
|
"<sub><![CDATA[\n" // 7 Element Text
|
||||||
"cdata containing new line \n" // 8
|
"cdata containing new line \n" // 8
|
||||||
@@ -2695,6 +2695,41 @@ int main( int argc, const char ** argv )
|
|||||||
XMLTest("Test attribute encode with a Hex value", value5, "!"); // hex value in unicode value
|
XMLTest("Test attribute encode with a Hex value", value5, "!"); // hex value in unicode value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------- XMLPrinter Apos Escaping ------
|
||||||
|
{
|
||||||
|
const char* testText = "text containing a ' character";
|
||||||
|
XMLDocument doc;
|
||||||
|
XMLElement* element = doc.NewElement( "element" );
|
||||||
|
doc.InsertEndChild( element );
|
||||||
|
element->SetAttribute( "attrib", testText );
|
||||||
|
{
|
||||||
|
XMLPrinter defaultPrinter;
|
||||||
|
doc.Print( &defaultPrinter );
|
||||||
|
const char* defaultOutput = defaultPrinter.CStr();
|
||||||
|
const bool foundTextWithUnescapedApos = (strstr(defaultOutput, testText) != nullptr);
|
||||||
|
XMLTest("Default XMLPrinter should escape ' characters", false, foundTextWithUnescapedApos);
|
||||||
|
{
|
||||||
|
XMLDocument parsingDoc;
|
||||||
|
parsingDoc.Parse(defaultOutput);
|
||||||
|
const XMLAttribute* attrib = parsingDoc.FirstChildElement("element")->FindAttribute("attrib");
|
||||||
|
XMLTest("Default XMLPrinter should output parsable xml", testText, attrib->Value(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
XMLPrinter customPrinter(0, false, 0, XMLPrinter::DONT_ESCAPE_APOS_CHARS_IN_ATTRIBUTES);
|
||||||
|
doc.Print( &customPrinter );
|
||||||
|
const char* customOutput = customPrinter.CStr();
|
||||||
|
const bool foundTextWithUnescapedApos = (strstr(customOutput, testText) != nullptr);
|
||||||
|
XMLTest("Custom XMLPrinter should not escape ' characters", true, foundTextWithUnescapedApos);
|
||||||
|
{
|
||||||
|
XMLDocument parsingDoc;
|
||||||
|
parsingDoc.Parse(customOutput);
|
||||||
|
const XMLAttribute* attrib = parsingDoc.FirstChildElement("element")->FindAttribute("attrib");
|
||||||
|
XMLTest("Custom XMLPrinter should output parsable xml", testText, attrib->Value(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------- Performance tracking --------------
|
// ----------- Performance tracking --------------
|
||||||
{
|
{
|
||||||
#if defined( _MSC_VER )
|
#if defined( _MSC_VER )
|
||||||
@@ -2744,9 +2779,9 @@ int main( int argc, const char ** argv )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( _MSC_VER )
|
#if defined( _MSC_VER )
|
||||||
const double duration = 1000.0 * (double)(end - start) / ((double)freq * (double)COUNT);
|
const double duration = 1000.0 * static_cast<double>(end - start) / (static_cast<double>(freq) * static_cast<double>(COUNT));
|
||||||
#else
|
#else
|
||||||
const double duration = (double)(cend - cstart) / (double)COUNT;
|
const double duration = static_cast<double>(cend - cstart) / static_cast<double>(COUNT);
|
||||||
#endif
|
#endif
|
||||||
printf("\nParsing dream.xml (%s): %.3f milli-seconds\n", note, duration);
|
printf("\nParsing dream.xml (%s): %.3f milli-seconds\n", note, duration);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user