mirror of
https://github.com/leethomason/tinyxml2.git
synced 2026-07-30 15:42:59 +04:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b765a210b3 | |||
| 6e246aec4d | |||
| 30dee1efa0 | |||
| a93163d2f5 | |||
| f87d0e3077 | |||
| 487f42aa69 | |||
| afff7bf328 | |||
| 9148bdf719 | |||
| 57eea48c5b | |||
| 198cb82c9b | |||
| c6ab6d76e8 | |||
| 008e32968f | |||
| 0ca3584fa4 | |||
| 57ec94127b |
@@ -6,7 +6,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ windows-2019, macos-latest, ubuntu-20.04 ]
|
os: [ windows-2019, macos-latest, ubuntu-22.04 ]
|
||||||
cmake: [ 3.15, 3.x ]
|
cmake: [ 3.15, 3.x ]
|
||||||
include:
|
include:
|
||||||
- os: windows-2019
|
- os: windows-2019
|
||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
tree: tree /F
|
tree: tree /F
|
||||||
CXX: cl
|
CXX: cl
|
||||||
|
|
||||||
- os: ubuntu-20.04
|
- os: ubuntu-22.04
|
||||||
tree: tree
|
tree: tree
|
||||||
|
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
|
|||||||
+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',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+7
-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
|
||||||
@@ -2577,7 +2577,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 ),
|
||||||
@@ -2594,9 +2594,11 @@ 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;
|
||||||
const unsigned char flagIndex = static_cast<unsigned char>(entityValue);
|
if ((aposInAttributes == ESCAPE_APOS_CHARS_IN_ATTRIBUTES) || (entityValue != SINGLE_QUOTE)) {
|
||||||
TIXMLASSERT( flagIndex < ENTITY_RANGE );
|
const unsigned char flagIndex = static_cast<unsigned char>(entityValue);
|
||||||
_entityFlag[flagIndex] = true;
|
TIXMLASSERT( flagIndex < ENTITY_RANGE );
|
||||||
|
_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;
|
||||||
|
|||||||
+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. */
|
||||||
|
|||||||
+38
-3
@@ -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");
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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 )
|
||||||
|
|||||||
Reference in New Issue
Block a user