326 Commits
3.0.0 ... 5.0.1

Author SHA1 Message Date
Lee Thomason
37bc3aca42 upping the version to 5.0.1 to fix release vs. source problem 2017-06-26 16:56:16 -07:00
Lee Thomason
8c9e3133c4 remove error string inline. hopefully helps with odd linking issues 2017-06-26 16:55:01 -07:00
Lee Thomason
563ee82093 Merge pull request #571 from hyperair/cmake-add-test
Use CTest to add xmltest as a testcase so `make test` works
2017-06-26 16:40:06 -07:00
Lee Thomason
4ee9ebdfd2 Merge pull request #570 from jasjuang/master
fix issue #516
2017-06-26 16:37:42 -07:00
Lee Thomason
a4f48c1167 Merge pull request #572 from Dmitry-Me/swapFoundAndExpected
"Found" and "expected" were swapped in some tests
2017-06-26 16:37:21 -07:00
Dmitry-Me
9832a5f05d "Found" and "expected" were swapped in some tests 2017-06-23 18:29:16 +03:00
Chow Loong Jin
48d45b29a9 Use make test in travis.yml 2017-06-22 01:20:55 +08:00
Chow Loong Jin
5381145957 Use CTest to add xmltest as a testcase so make test works 2017-06-22 01:14:07 +08:00
jasjuang
a5ab98a582 fix issue #516 2017-06-20 17:25:42 -07:00
Lee Thomason
369f306b37 Merge branch 'master' of github.com:leethomason/tinyxml2 2017-06-20 09:18:54 -07:00
Lee Thomason
8bba8b41d6 mark unused enums 2017-06-20 09:18:41 -07:00
Lee Thomason
3f169ac424 Merge pull request #568 from Dmitry-Me/checkParsingErrorEarlier
Test parsing result as early as possible
2017-06-20 09:17:21 -07:00
Lee Thomason
86be0cdfe5 Merge pull request #566 from redagito/master
CMake fix for static library only build
2017-06-20 09:08:39 -07:00
Dmitry-Me
aea64c4b75 Test parsing result as early as possible 2017-06-20 18:20:15 +03:00
Robert J
dfcf5488ea CMake fix for static library only build 2017-06-20 13:41:17 +02:00
Lee Thomason
9201bb96d3 Merge pull request #563 from Dmitry-Me/betterParameterNameInClone
Better parameter name
2017-06-19 14:23:39 -07:00
Dmitry-Me
3f63f21cf5 Better parameter name 2017-06-19 18:25:19 +03:00
Lee Thomason
9e2d29b373 weird compile issues 2017-06-16 09:51:11 -07:00
Lee Thomason
82bb074b49 tweak test 2017-06-16 09:48:20 -07:00
Lee Thomason
224ef775c6 add test case 2017-06-16 09:45:26 -07:00
Lee Thomason
8a763619ac fix incorrect factoring 2017-06-16 09:30:16 -07:00
Lee Thomason
bc527554e8 Merge pull request #558 from leethomason/clone
Support clone (deep copy) of XMLDocument and XMLNode
2017-06-15 12:01:48 -07:00
Lee Thomason
5cfb946953 Merge pull request #562 from Dmitry-Me/testMemoryLeaksInDebugHeap
Programmatically check no leaks are reported in the VC++ debug heap
2017-06-15 10:30:30 -07:00
Lee Thomason
275067a91f Merge pull request #561 from Dmitry-Me/unlinkedElementsAssertions
Unlinked nodes assertions
2017-06-15 10:29:07 -07:00
Dmitry-Me
ed78570c66 Programmatically check no leaks are reported in the VC++ debug heap 2017-06-15 13:39:53 +03:00
Dmitry-Me
c2f677b05e Unlinked nodes assertions 2017-06-15 12:44:27 +03:00
Lee Thomason
1346a174ae tweak comments. fix copy to self case. 2017-06-14 15:14:19 -07:00
Lee Thomason
1bbc66b193 Merge branch 'master' into clone 2017-06-14 15:10:37 -07:00
Lee Thomason
e84f68a68a Merge branch 'memleak2' 2017-06-14 15:03:32 -07:00
Lee Thomason
b754ddf0fb address feedback from review 2017-06-14 15:02:38 -07:00
Lee Thomason
7ce75bc2bb Merge pull request #557 from jasjuang/master
Resolve issue #526
2017-06-14 14:50:53 -07:00
Lee Thomason
816d3fa0cd Fix string leaking (and destructors not getting called) when there are XMLNodes that aren't in the document tree 2017-06-05 14:35:55 -07:00
Lee Thomason
53858b4490 minor formatting fix and very strange memory tracker missing 2017-06-01 19:09:16 -07:00
Lee Thomason
ced18c05b9 missing var?? 2017-06-01 18:50:12 -07:00
Lee Thomason
a30f8bd136 Merge remote-tracking branch 'origin/master' into clone 2017-06-01 18:46:53 -07:00
Lee Thomason
b29f556ab0 comment 2017-06-01 18:45:32 -07:00
Lee Thomason
7085f00e40 deep copy and clone 2017-06-01 18:09:43 -07:00
jasjuang
f66441e3e7 add in support for cmake export, manual Findtinyxml2.cmake is no longer needed 2017-06-01 17:25:30 -07:00
Lee Thomason
33a1f8bd6c Merge pull request #552 from Dmitry-Me/ensureNoOverrunBeforeCopy
Ensure no overrun before copying
2017-05-18 21:13:48 -07:00
Lee Thomason
7538286750 Merge pull request #535 from jnguyen75/build-tests-option
Added BUILD_TESTS option to enable/disable xmltest
2017-05-18 20:57:41 -07:00
Dmitry-Me
243ddf5304 Ensure no overrun before copying 2017-05-18 17:27:14 +03:00
Jimmy Nguyen
105f32f64d Merge remote-tracking branch 'origin/master' into build-tests-option 2017-05-11 16:19:30 -07:00
Lee Thomason
174a5df3a3 Merge pull request #551 from eco/patch-1
Add "d" library suffix for debug builds
2017-05-05 19:55:08 -07:00
Brad Anderson
9333cfd394 Add "d" library suffix for debug builds 2017-05-04 12:25:56 -06:00
Lee Thomason
7b40ce1942 Merge pull request #534 from jnguyen75/ref-test-resources
Refactor test resources: Use CMake to replace mkdir()
2017-04-28 11:21:39 -07:00
Lee Thomason
b840b7e673 Merge pull request #547 from Dmitry-Me/clarifyVariableNames
Clarify variable names
2017-04-12 10:22:34 -07:00
Dmitry-Me
10b8ecc99b Clarify variable names 2017-04-12 17:57:44 +03:00
Lee Thomason
2b0453f43e Merge pull request #545 from Dmitry-Me/fullyUseEnum
Fully use enum
2017-04-06 13:27:29 -07:00
Dmitry-Me
e503563f47 Fully use enum 2017-04-05 18:02:40 +03:00
Lee Thomason
fc05f63575 Merge pull request #543 from Dmitry-Me/pointerAssertInShallowEqual
Pointer assertion
2017-03-22 14:36:32 -07:00
Dmitry-Me
ba68a3aea6 Pointer assertion 2017-03-21 11:39:48 +03:00
Lee Thomason
395ea09f83 Merge pull request #538 from Dmitry-Me/suppressC6011
Suppress C6011 code analysis false positive warning
2017-03-06 12:49:35 -08:00
Lee Thomason
71e2c08a7e Merge pull request #537 from Dmitry-Me/clearerMemberName
Clearer variable name
2017-03-06 12:48:33 -08:00
Dmitry-Me
7221b49fea Suppress C6011 code analysis false positive warning 2017-03-03 15:45:51 +03:00
Dmitry-Me
ae8a82a734 Clearer variable name 2017-03-03 15:40:32 +03:00
Lee Thomason
92c0ef327f Merge pull request #527 from Dmitry-Me/reuseNodesCreationCode
Extract and reuse nodes creation code
2017-03-01 13:15:52 -08:00
Dmitry-Me
2aebfb7123 Extract and reuse nodes creation code 2017-02-27 15:53:40 +03:00
Jimmy Nguyen
1e0b4e6b8a Use generator expression to specify target output directory for resources directory 2017-02-21 12:31:23 -08:00
Jimmy Nguyen
7f2ce0dc0e Updated Windows build script to change directory instead of copying files to run xmltest 2017-02-21 12:27:59 -08:00
Jimmy Nguyen
6bf64fb149 Use CMake to create resources/out directory 2017-02-21 12:00:38 -08:00
Jimmy Nguyen
47c7d70064 Added BUILD_TESTS option to enable/disable building of xmltest 2017-02-21 11:29:24 -08:00
Lee Thomason
b37cb42b78 Merge pull request #513 from leethomason/bool-write
Bool serialization.
2017-02-17 12:39:06 -08:00
Lee Thomason
0f42e24c47 Merge pull request #529 from Winestone/master
Fix typo in CMakeLists.txt
2017-02-14 11:24:51 -08:00
Jimmy Nguyen
969b8c2234 Replaced DATA_COPY target with post build command to copy the resources directory 2017-02-13 23:40:16 -08:00
Jimmy Nguyen
5277134efa Removed empty install() command 2017-02-13 23:24:38 -08:00
Winestone
4a07484e47 Fix typo in CMakeLists.txt 2017-02-11 23:04:14 +11:00
Lee Thomason
962732fd3e Merge pull request #520 from Dmitry-Me/initMemberVars2
Initialize member variable
2017-02-05 15:56:13 -08:00
Dmitry-Me
d120d64b86 Initialize member variable 2017-01-27 18:35:02 +03:00
Lee Thomason
1f5ab7cd0b Merge pull request #517 from Dmitry-Me/initMemberVars
Initialize member variables
2017-01-24 10:38:49 -08:00
Dmitry-Me
f89bd3ef68 Initialize member variables 2017-01-18 18:33:55 +03:00
Lee Thomason
c5c99c2ba0 tweaks to bool serialization 2016-12-29 11:19:17 -08:00
Lee Thomason
f458d265c1 fix const. hopefully. 2016-12-26 22:47:25 -08:00
Lee Thomason
ce667c9233 ability to set bool write values 2016-12-26 16:45:30 -08:00
Lee Thomason
5b733ff481 Merge pull request #504 from Dmitry-Me/ensureLinkPointersAreNotOverwritten
Ensure existing attributes are not leaked on attribute insertion
2016-12-24 07:39:17 -08:00
Lee Thomason
c3a19156ff Merge pull request #510 from leethomason/kezenator-line-numbering
Kezenator line numbering
2016-12-24 07:38:43 -08:00
Lee Thomason
e90e901041 tweaks, clarification to line numbers 2016-12-24 07:34:39 -08:00
Lee Thomason
002713856b Merge remote-tracking branch 'origin/master' into kezenator-line-numbering 2016-12-24 07:27:40 -08:00
Lee Thomason
855a66c0ff Merge pull request #509 from leethomason/fix-win-dll-build
Fix windows dll build/run
2016-12-24 07:27:25 -08:00
Lee Thomason
ef7fe0fd98 fix windows dll build/run 2016-12-24 07:07:56 -08:00
Dmitry-Me
34a3f8e34d Ensure existing attributes are not leaked on attribute insertion 2016-12-19 12:05:21 +03:00
kezenator
19d8ea836f CodeReview Fix: GetLineNum()? 2016-11-29 19:50:27 +10:00
kezenator
e353181a46 CodeReview Fix: initialLineNum? Something a little more descriptive? 2016-11-29 19:49:07 +10:00
kezenator
e3d44159e3 CodeReview Fix: The initializer syntax isn't used. Should be 'int unusedLineNum = 0` 2016-11-29 19:47:55 +10:00
kezenator
4f756161d0 CodeReview Fix: The non-const reference syntax isn't used in the codebase. Should be a pointer. 2016-11-29 19:46:27 +10:00
kezenator
2489afcc61 Merge branch 'master' of https://github.com/leethomason/tinyxml2 2016-11-29 19:33:44 +10:00
kezenator
a43ff7210e Removed line numbering support as an advantage of TinyXML-1.
Added error reporting system that discusses the support for line number information.
2016-11-26 17:33:12 +10:00
kezenator
ec6941503c Added line number reporting to parse errors and to all nodes and attributes for parsed documents. 2016-11-26 17:21:43 +10:00
Lee Thomason
156bc1b99f Merge pull request #502 from Dmitry-Me/reuseClearError
Reuse code for error clearing
2016-11-25 22:06:11 -08:00
Lee Thomason
5bbb6fb052 Merge pull request #500 from Dmitry-Me/reuseAttributeCreation
Reuse attribute creation code
2016-11-25 22:05:34 -08:00
kezenator
5a70071241 Added static method to convert arbitrary ErrorID to a string.
Updated tests to print ErrorID and bool values as strings.
2016-11-26 13:54:42 +10:00
Dmitry-Me
0d2cef0cba Reuse code for error clearing 2016-11-25 18:39:52 +03:00
Dmitry-Me
a60caa28cc Reuse attribute creation code 2016-11-22 18:28:08 +03:00
Lee Thomason
f80d78d938 Merge pull request #499 from Dmitry-Me/unifyNullComparisons
Unify null pointer checks
2016-11-17 14:43:55 -08:00
Dmitry-Me
ebb1660c2f Unify null pointer checks 2016-11-16 17:22:45 +03:00
Lee Thomason
7de0b6dd8c Merge pull request #493 from leethomason/jwittner
Friendly API for attribute query.
2016-11-15 14:09:03 -08:00
Lee Thomason
d04f21cab8 Merge pull request #496 from Dmitry-Me/detectDeclarationPlacement
Declarations should occur before anything else
2016-11-15 14:08:04 -08:00
Dmitry-Me
446c3bcae3 Declarations should occur before anything else 2016-11-11 10:34:56 +03:00
Lee Thomason
cd47f8e0d3 Merge pull request #495 from Dmitry-Me/pointerAssertionAfterIdentify
Pointer post-assertion
2016-11-10 14:36:10 -08:00
Dmitry-Me
4336431272 Pointer post-assertion 2016-11-07 18:48:50 +03:00
Lee Thomason
13cbc9a708 add test files. fix doc. 2016-10-27 14:55:07 -07:00
Lee Thomason
c9a6102bf1 Merge branch 'master' of git://github.com/jwittner/tinyxml2 into jwittner-master 2016-10-27 14:33:52 -07:00
Lee Thomason
6bbcda0215 Merge pull request #490 from Dmitry-Me/avoidCastToSigned
Avoid cast to signed integer type
2016-10-17 15:34:20 -07:00
Lee Thomason
15ad07170d Merge pull request #489 from Armagetron/master
Use correct file pointer
2016-10-17 15:33:57 -07:00
Lee Thomason
ed2627e5a7 Merge pull request #487 from jwittner/dev/slnFixes
Fixes for Visual Studio builds and gitignore output
2016-10-17 15:33:26 -07:00
Dmitry-Me
c5f1e7ce6e Avoid cast to signed integer type 2016-10-14 10:33:02 +03:00
Armagetron
3c21d6fbb7 Use correct file pointer 2016-10-13 13:31:23 +02:00
Lee Thomason
f6106bec9a Merge pull request #488 from Dmitry-Me/reuseElementWithNameCheck
Reuse "is element with name" check
2016-10-12 15:23:39 -07:00
Dmitry-Me
ecb9b07476 Reuse "is element with name" check 2016-10-12 16:44:59 +03:00
Josh Wittner
edb3261c51 Ignore SLn output dirs, VC files 2016-10-11 19:04:15 -07:00
Josh Wittner
01f6cca9e1 Standardize output directory - fixes conflicts 2016-10-11 19:03:10 -07:00
Josh Wittner
513e69ba68 Merge branch 'master' of https://github.com/leethomason/tinyxml2 2016-10-11 19:00:53 -07:00
Josh Wittner
cf3dd09b08 Move implementations to cpp 2016-10-11 18:57:17 -07:00
Lee Thomason
e8157ff9ae Merge pull request #484 from kainjow/patch-2
Fix warning on PowerPC
2016-10-11 13:52:45 -07:00
Lee Thomason
b2f4dc2a7b Merge pull request #483 from kainjow/patch-1
Fix typo
2016-10-11 13:45:35 -07:00
Lee Thomason
0d3de1edbe Merge pull request #482 from Dmitry-Me/stringEqualAssertions
Assertions in string comparison
2016-10-11 13:11:06 -07:00
Kevin Wojniak
318252a973 Fix warning on PowerPC
GCC 5+ will generate "error: comparison is always true due to limited range of data type" when -Wextra is used because PowerPC by default uses unsigned char, so it can never be less than 0.
2016-10-07 10:37:02 -07:00
Kevin Wojniak
3c97724d0e Fix typo 2016-10-06 16:05:59 -07:00
Dmitry-Me
21f996960d Assertions in string comparison 2016-10-03 13:01:57 +03:00
Lee Thomason
f00c179eba Merge pull request #480 from kurylo/fix/2016-09-29-cmake-warning
Fix cmake warnings on new cmake versions.
2016-10-02 21:24:49 -07:00
Lee Thomason
7fcf31b2c3 Merge pull request #477 from bejado/XML_NO_ERROR_Comments
Update comments to reflect single successful return type
2016-10-02 21:22:42 -07:00
Lee Thomason
6f1ad6153e Merge pull request #471 from Dmitry-Me/loopInvariantAssertions
Loop invariant pointer assertions
2016-10-02 21:21:38 -07:00
Łukasz Kuryło
aad61870a9 Fix cmake warnings on new cmake versions. 2016-09-29 18:59:07 +02:00
Benjamin Doherty
3b9cf99916 Update comments to reflect single successful return type 2016-09-23 18:42:23 -06:00
Lee Thomason
e9b547a9ee Merge pull request #475 from Dmitry-Me/splitAccessAndAdjustment
Split access and pointer adjustment
2016-09-14 10:31:10 -07:00
Josh Wittner
3a621f5b6e Added default values TypeText accessors 2016-09-12 19:17:54 -07:00
Dmitry-Me
fed511276f Split access and pointer adjustment 2016-09-06 18:08:55 +03:00
Lee Thomason
584af57086 fix error string memory errors 2016-09-05 14:14:16 -07:00
Lee Thomason
2e14517c89 Merge pull request #474 from Dmitry-Me/unifyIncDecOps
Unify increments and decrements
2016-09-05 13:52:58 -07:00
Lee Thomason
24694e9519 Merge pull request #473 from Dmitry-Me/preferConstAccess
Use const where const is enough
2016-09-05 13:52:22 -07:00
Lee Thomason
0d667f8fef Merge pull request #472 from Dmitry-Me/pointerAssertionsStrPairSet
Pointer assertions for substring
2016-09-05 13:51:59 -07:00
Dmitry-Me
3161a33c86 Unify increments and decrements 2016-09-02 16:58:06 +03:00
Dmitry-Me
2449582eaf Use const where const is enough 2016-09-02 16:53:32 +03:00
Dmitry-Me
6fc38ec7cc Pointer assertions for substring 2016-09-01 17:59:44 +03:00
Dmitry-Me
f9f3c3e85c Loop invariant pointer assertions 2016-08-30 15:51:55 +03:00
Lee Thomason
4fe8c102da Merge pull request #469 from Trebgarta/master
Bool true/false rather than 0/1 : #399
2016-08-28 17:21:04 -07:00
Lee Thomason
a369d4b614 Merge pull request #468 from Dmitry-Me/reuseDeleteChild
Reuse DeleteChild()
2016-08-28 17:13:28 -07:00
Doruk Turak
1f212f3ab0 Bool-related tests modified to pass 2016-08-28 20:54:17 +02:00
Doruk Turak
de45d04711 SetAttribute: true/false rather 1/0 2016-08-28 20:47:08 +02:00
Dmitry-Me
9cb4eca596 Reuse DeleteChild() 2016-08-18 18:10:59 +03:00
Lee Thomason
0bb5901961 Merge pull request #466 from Dmitry-Me/makeCommentMoreConcise
Make comment more concise
2016-08-11 07:34:16 -07:00
Lee Thomason
9faf14df53 Merge pull request #465 from Dmitry-Me/unifyNodeDeletion
Unify node deletion
2016-08-11 07:33:53 -07:00
Lee Thomason
cb6461ca9c Merge pull request #464 from mwoehlke-kitware/elf-visibility
ELF visibility
2016-08-11 07:32:50 -07:00
Lee Thomason
c7805c541c Merge pull request #463 from Dmitry-Me/clarifyMemoryPoolParts
Clarify "block" and "chunk"
2016-08-11 07:28:08 -07:00
Dmitry-Me
caa72a641e Make comment more concise 2016-08-10 17:34:34 +03:00
Dmitry-Me
4de7abb573 Unify node deletion 2016-08-10 17:30:02 +03:00
Matthew Woehlke
8170bdc693 Build with hidden symbols by default
Turn on options to tell CMake to use -fvisibility=hidden by default (on
applicable platforms). This has some optimization benefits, and more
closely mirrors the Windows behavior of only exporting symbols marked
for export, which can help catch errors doing so on non-Windows
platforms.

This requires CMake 2.8.12 to be effective. (Otherwise, the logic will
simply have no effect.)
2016-08-09 13:21:06 -04:00
Matthew Woehlke
a8e7ea7fb0 Set ELF visibility
Set symbol visibility to "default" on non-Windows platforms. This allows
building with -fvisibility=hidden, which has various advantages, and
which some projects will almost certainly want to do.
2016-08-09 13:16:26 -04:00
Dmitry-Me
88145b8ae6 Clarify "block" and "chunk" 2016-08-09 17:59:31 +03:00
Lee Thomason
75c8f40640 Merge pull request #459 from Elbrasch/master
Added void XMLPrinter::PushText( int64_t value ), which was declared …
2016-08-05 13:10:16 -07:00
Lee Thomason
1043f6feed Merge pull request #460 from Dmitry-Me/pointerAssertion
Pointer assertion for contract clarity
2016-08-05 13:09:25 -07:00
Dmitry-Me
db02b21bc5 Pointer assertion for contract clarity 2016-08-04 17:16:05 +03:00
Stefan Asbeck
e1a82c1a50 Added void XMLPrinter::PushText( int64_t value ), which was declared but not implemented. 2016-08-04 09:12:45 +02:00
Lee Thomason
74d44acb17 fix compile issues on clang 2016-07-17 22:57:36 -07:00
Lee Thomason
c9445466de fix permissive casting. 2016-07-17 22:53:48 -07:00
Lee Thomason
5bf60e9dc6 try to fix the lld issue 2016-07-17 22:49:40 -07:00
Lee Thomason
6ba2a077ed upping the major version. lots of small (incompatible) changes, and the addition of int64 support. 2016-07-17 22:40:43 -07:00
Lee Thomason
af9bce1762 support user data 2016-07-17 22:35:52 -07:00
Lee Thomason
536a4cde37 Merge branch 'master' into int64support 2016-07-17 21:37:39 -07:00
Lee Thomason
098bd1f17a fix project file version 2016-07-17 21:35:10 -07:00
Lee Thomason
53b0727037 Merge pull request #453 from morinim/issue425
Fixes issue #425
2016-07-17 21:33:54 -07:00
Manlio Morini
0f45b2422f Fixes issue #425 2016-07-11 12:14:59 +02:00
Lee Thomason
d7e5f47524 Merge pull request #445 from kurylo/master
Add INCLUDE_DIRECTORIES on the targets for supported cmake versions.
2016-06-23 13:50:24 -07:00
Lukasz Kurylo
2818e67f31 Add INCLUDE_DIRECTORIES on the targets for supported cmake versions. 2016-06-22 19:22:57 +02:00
Lee Thomason
2fe47ead77 Merge pull request #443 from TheZoc/patch-1
Standardized static library output name
2016-06-09 16:25:14 -07:00
Felipe "Zoc" Silveira
04639a59a5 Standardized static library output name
Renamed ```tinyxml2.a``` to ```libtinyxml2.a```, to allow proper linking using the ```-l``` flag on gcc.
2016-06-08 19:11:37 -03:00
Lee Thomason
1889c3e679 try to make gcc happier 2016-06-04 20:22:57 -07:00
Lee Thomason
51c1271797 add int64 support 2016-06-04 20:18:49 -07:00
Lee Thomason
a572db13cf ps3 support 2016-06-04 19:16:24 -07:00
Lee Thomason
8553625730 one successful return type. simplify build on vs2015 2016-06-04 19:10:53 -07:00
Lee Thomason
df4ffc00d6 fix warning up from vs2015 2016-06-04 11:32:46 -07:00
Lee Thomason
41599e2583 Merge branch 'master' of git://github.com/TheZoc/tinyxml2 into TheZoc-master 2016-06-04 11:26:08 -07:00
Lee Thomason
ceb646812a Merge pull request #438 from TheZoc/osx-makefile
Updated Makefile to allow building TinyXML2 as a static library
2016-06-03 07:56:17 -07:00
Lee Thomason
d3f5c318ae remove unused XMLBase 2016-06-03 07:49:35 -07:00
Felipe "Zoc" Silveira
48daa2dd81 Updated Makefile to allow building TinyXML2 as a static library 2016-05-22 00:21:53 -03:00
Lee Thomason
31d6c877bd Merge pull request #435 from ongjunjie/master
minimize file copying on incremental builds
2016-05-14 10:46:04 -07:00
Felipe "Zoc" Silveira
1f16f9ddf5 Updated to VS 2015 2016-05-12 06:31:28 -03:00
Jun Jie
47f9931130 minimize file copying on incremental builds 2016-04-22 13:37:44 +08:00
Lee Thomason
bb4d246f7b update to VS 2013 2016-03-25 20:08:32 -07:00
Lee Thomason
97837e77f4 Merge pull request #428 from wvvelzen/WarningsFix
Fix 2 "Condition is always true" compiler warnings.
2016-03-25 07:41:51 -07:00
Lee Thomason
3d60e25c4a Merge pull request #427 from wvvelzen/bcb6fix
Fix for Borland C++ Builder 6
2016-03-25 07:41:05 -07:00
Wilfred van Velzen
0aeac18ad3 Fix 2 "Condition is always true" compiler warnings. 2016-03-25 14:14:03 +01:00
Wilfred van Velzen
67abee5610 Fix for Borland C++ Builder 6 2016-03-25 14:01:15 +01:00
Lee Thomason
fe5dbdb817 Merge pull request #414 from ReadmeCritic/master
Correct the capitalization of Xcode in README
2016-03-24 07:49:15 -07:00
Lee Thomason
d175e9de0b Merge pull request #413 from Darksun2010/master
space misses in the comment of CMakeLists.txt
2016-02-17 11:39:22 -08:00
ReadmeCritic
ff714133bc Correct the capitalization of Xcode in README 2016-02-17 09:24:03 -08:00
Darksun
6bf8a07587 space misses in the comment of CMakeLists.txt 2016-02-16 16:10:57 +08:00
Lee Thomason
c8dad95d44 Merge pull request #410 from Dmitry-Me/assertForFTellReturn
Assert to ensure ftell() behaves as expected by later code
2016-02-09 08:39:14 -08:00
Dmitry-Me
96b110d25e Assert to ensure ftell() behaves as expected by later code 2016-02-09 15:12:40 +03:00
Lee Thomason
9ff6654174 Merge pull request #407 from JarleStrand/fix-deletechild
Error fix DeleteChild
2016-01-04 07:40:22 -08:00
Jarle Strand
81abfd6d4c Error fix DeleteChild
Added call to Unlink in XMLNode::DeleteChild() so that references to
node are removed before memory is unallocated. This will ensure the
child is removed from parent and that no pointers are referring to the
unallocated memory. (Code is now aligned with the code in
XMLNode::DeleteChildren() )
2015-12-27 17:30:04 +01:00
Lee Thomason
9c8582c7c3 Merge pull request #401 from Dmitry-Me/assertForNonNullString
Assertion in StrPair::SetStr()
2015-12-09 11:36:59 -08:00
Dmitry-Me
0515fa9d27 Assertion in StrPair::SetStr() 2015-12-09 11:54:06 +03:00
Lee Thomason
f47b20f114 fix readme syntax 2015-10-19 22:55:32 -07:00
Lee Thomason
dffea5747b remove mystery comment 2015-10-19 22:51:49 -07:00
Lee Thomason
fe5b7a5cac Merge pull request #393 from Dmitry-Me/fixSetTextDescription
Fix SetText() description spelling
2015-10-19 17:13:45 -07:00
Dmitry-Me
9e9c85b3ae Fix SetText() description spelling 2015-10-19 18:04:46 +03:00
Lee Thomason
7bc9201322 remove static-assert accidentally checked in. 2015-10-09 14:45:08 -07:00
Lee Thomason
598a88d9fd used stdlib strncmp function 2015-10-09 14:42:12 -07:00
Lee Thomason
e4c0738318 Merge pull request #383 from Chocobo1/travis
CI improvements
2015-10-09 11:28:55 -07:00
Chocobo1
f2c6b118da readme.md: add CI build status badges 2015-10-02 22:09:12 +08:00
Chocobo1
a58de11b42 Add appveyor.yml 2015-10-02 18:08:48 +08:00
Chocobo1
87a8e71c20 TravisCI: support osx build 2015-10-02 17:53:31 +08:00
Lee Thomason
e4f8ba89d0 Merge pull request #381 from ya1gaurav/patch-1
Travis also support clang.
2015-09-29 19:50:14 -07:00
Lee Thomason
a589da416c Merge pull request #380 from Dmitry-Me/getRidOfWtypeLimits
Get rid of -Wtype-limits warning
2015-09-29 19:49:46 -07:00
Gaurav
60af433d31 Travis also support clang.
Add clang compiler to travis build support.
2015-09-28 13:32:30 +05:30
Dmitry-Me
901fed5f19 Get rid of -Wtype-limits warning 2015-09-25 10:29:51 +03:00
Lee Thomason
2aee5e1b37 Merge pull request #379 from renu555/renu555-patch-5
Build with travis CI on every pull request or commit
2015-09-24 10:31:39 -07:00
Lee Thomason
27eb078329 Merge pull request #372 from jasjuang/master
add in support for sudo make uninstall
2015-09-24 10:23:04 -07:00
renu555
d7f2cce11f Create .travis.yml 2015-09-24 14:02:02 +05:30
Lee Thomason
8ac308d433 Merge pull request #376 from renu555/renu555-patch-1
Build tinyxml2 as static library
2015-09-21 07:40:39 -07:00
renu555
871d72f3a8 Build tinyxml2 as static library
By Default shared libs are built
To build static library also configure  cmake with -DBUILD_STATIC_LIBS:BOOL=ON
To build only static library configure cmake with -DBILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON
2015-09-18 13:39:51 +05:30
Lee Thomason
b5d51e8f90 Merge pull request #371 from PKEuS/master
Declared *PRINTF wrappers as static
2015-08-20 07:37:00 -07:00
jasjuang
f6002e6a99 add in support for sudo make uninstall 2015-08-15 16:50:55 -07:00
PKEuS
cac75789ba Declared *PRINTF wrappers as static 2015-08-15 18:19:53 +02:00
Lee Thomason
2beb560a3e Merge pull request #367 from Dmitry-Me/preAssertsToEnsureNoBufferLeaks
Asserts to ensure old buffer is not leaked when allocating a new one
2015-08-14 13:57:53 -07:00
Dmitry-Me
96f38cca95 Asserts to ensure old buffer is not leaked when allocating a new one 2015-08-10 16:45:12 +03:00
Lee Thomason
bb8fd3c29c Merge pull request #364 from PKEuS/master
Moved include of <cstdarg> to cpp file
2015-08-07 15:51:02 -07:00
Lee Thomason
7ae888a601 Merge pull request #363 from Dmitry-Me/outputLengthAsserts
Asserts for formatted output length
2015-08-07 15:50:16 -07:00
Lee Thomason
d101a9b1a6 Merge pull request #366 from yang-le/master
add *.o to .gitignore
2015-08-07 15:46:51 -07:00
Yang Le
14d5490618 add *.o to .gitignore 2015-08-06 22:38:48 +08:00
Philipp Kloke
358202c77a Moved include of <cstdarg> to cpp file 2015-07-30 16:02:26 +02:00
Dmitry-Me
1d32e586d5 Asserts for formatted output length 2015-07-27 17:11:51 +03:00
Lee Thomason
78fca3db83 Merge pull request #361 from RossBencina/master
fix compiler warning (XCode 4.6.1 x86_64) tinyxml2.cpp:2146:77: Impli…
2015-07-23 17:00:05 -07:00
Lee Thomason
fd6ad7e3a7 Merge pull request #362 from Dmitry-Me/useElementName
Use "name" for element name
2015-07-23 16:59:20 -07:00
Dmitry-Me
886ad9787c Use "name" for element name 2015-07-22 11:00:51 +03:00
Ross Bencina
e7fa0e159e fix compiler warning (XCode 4.6.1 x86_64) tinyxml2.cpp:2146:77: Implicit conversion loses integer precision: 'const size_t' (aka 'const unsigned long') to 'const int' 2015-07-22 16:58:05 +10:00
Lee Thomason
eb89ef6f0d Merge pull request #360 from Dmitry-Me/documentConsistencyAsserts
Document consistency asserts
2015-07-21 16:20:12 -07:00
Dmitry-Me
66487eb8f9 Document consistency asserts 2015-07-20 18:21:04 +03:00
Lee Thomason
400e5b2d60 Merge pull request #358 from Dmitry-Me/betterDocumentWarningSuppression
Better document warning suppression code
2015-07-06 14:17:30 -07:00
Dmitry-Me
8dd493b268 Better document warning suppression code 2015-07-02 13:59:30 +03:00
Lee Thomason
4824e95bc0 Merge pull request #343 from Dmitry-Me/checkEntityWasPrinted
Ensure proper pattern was found and printed
2015-07-01 14:18:15 -07:00
Lee Thomason
70fd52a574 Merge pull request #354 from Dmitry-Me/properCapsVisualStudio
Proper capitalize Visual Studio in comment
2015-06-23 16:30:01 -07:00
Dmitry-Me
1ca593c4ca Proper capitalize Visual Studio in comment 2015-06-22 12:49:32 +03:00
Lee Thomason
aebaeea687 Merge pull request #353 from Dmitry-Me/unselessConst
Useless const
2015-06-19 16:55:19 -07:00
Lee Thomason
73f08a3185 Merge pull request #352 from Dmitry-Me/consistencyAsserts
Consistency asserts
2015-06-19 16:54:54 -07:00
Lee Thomason
aa8566b137 fix a macro version check 2015-06-19 16:52:40 -07:00
Dmitry-Me
7865aad09b Useless const 2015-06-19 16:23:35 +03:00
Dmitry-Me
2f5a103992 Consistency asserts 2015-06-18 16:40:09 +03:00
Lee Thomason
53db4a6cf4 move to cpp file. 2015-06-11 22:52:08 -07:00
pffang
1527cf4b2f Patch for Visual Studio 2003 and earlier.
This patch will be easy to extend in the future.
2015-06-09 13:57:11 +08:00
Lee Thomason
2b2649e1e4 Merge pull request #349 from Dmitry-Me/properHandleSmallBufferOnCe
Don't use -1 as buffer length
2015-06-08 17:14:14 -07:00
Dmitry-Me
687bf8211f Don't use -1 as buffer length 2015-06-08 18:06:44 +03:00
Dmitry-Me
39c399a0f2 Ensure proper pattern was found and printed 2015-05-28 15:32:27 +03:00
Lee Thomason
91f2dcfb5c Merge pull request #342 from Dmitry-Me/testErrorNames
Test error name is non-empty for the whole range
2015-05-26 11:09:12 -07:00
Lee Thomason
32de9f02f5 Merge pull request #341 from Dmitry-Me/cleanupComment
Remove redundant comment, fix typo and formatting
2015-05-26 09:18:55 -07:00
Dmitry-Me
a1beddf486 Test error name is non-empty for the whole range 2015-05-26 16:19:21 +03:00
Dmitry-Me
962083b9d1 Remove redundant comment, fix typo and formatting 2015-05-26 11:38:30 +03:00
Lee Thomason
735ce51124 Merge pull request #339 from Dmitry-Me/properFixGccSignCompare
Proper fix gcc -Wsign-compare
2015-05-25 10:40:45 -07:00
Dmitry-Me
ca86a0fa2a Proper fix gcc -Wsign-compare 2015-05-25 11:29:14 +03:00
Lee Thomason
c879a4d48c Merge pull request #338 from Dmitry-Me/removeAmbiguousEnumItems
Get rid of two distinct enum items with same same
2015-05-22 11:09:33 -07:00
Lee Thomason
949ae37e0a Merge pull request #337 from Dmitry-Me/checkEntityFoundExplicitly
Explicitly check entity was not found
2015-05-22 11:08:31 -07:00
Lee Thomason
03d0f4ea25 Merge branch 'SirR4T-assert-fires-when-calling-XMLDocument--Value' 2015-05-22 11:07:58 -07:00
Lee Thomason
8549202800 clean up Value of XMLDocument 2015-05-22 11:07:45 -07:00
Lee Thomason
c52aa55a86 Merge branch 'SirR4T-patch-1' 2015-05-22 11:00:59 -07:00
Lee Thomason
7a93b33160 tighten up the error checks 2015-05-22 11:00:32 -07:00
Lee Thomason
2ecc203835 Merge branch 'patch-1' of https://github.com/SirR4T/tinyxml2 into SirR4T-patch-1 2015-05-22 10:57:00 -07:00
Dmitry-Me
5420e547d3 Get rid of two distinct enum items with same same 2015-05-20 10:51:26 +03:00
Dmitry-Me
764545e02a Explicitly check entity was not found 2015-05-20 10:29:24 +03:00
Sarat Addepalli
3df007ef9d Fix and use correct pointers and types.
Should have been `XMLDeclaration* decl = ...` instead of `XMLElement* ele = ...`
2015-05-20 10:43:51 +05:30
Sarat Addepalli
96b4346660 Remove unnecessary cast in XMLNode::Value() 2015-05-20 10:36:06 +05:30
Sarat Addepalli
d608c561e0 Fix up xmltest.cpp
Fixed coding style in XMLTest(), and removed unused variable in testcase.
2015-05-20 10:19:00 +05:30
Lee Thomason
ff53d7172c Merge pull request #335 from SirR4T/SirR4T-add-DEBUG-macro-in-CMakeLists_txt
Define the `DEBUG` macro in CMakeLists.txt
2015-05-19 09:37:33 -07:00
Lee Thomason
1bf04fd755 Merge pull request #330 from Dmitry-Me/avoidUnneededPrinterCreation
Avoid unneeded printer object creation
2015-05-19 09:31:41 -07:00
Sarat Addepalli
9afd1d0ceb Clarify meaning of 'empty'
When `XMLDocument::Value()` is called, we intend to return NULL (`( const char* )0`). State that explicitly in the documentation, so as to disambiguate between "empty string" (`""`) and NULL.
2015-05-19 12:56:27 +05:30
Sarat Addepalli
9c3122b89b Bypass asserts for XMLDocument::Value()
When the node is an XMLDocument, bypass calling the `_value.GetStr()` function, since we know we have to return `( const char* )0` inevitably.

This fixes #323
2015-05-19 12:49:32 +05:30
Sarat Addepalli
13b2d73427 Add null-checks in XMLTest()
When either `expected` or `found` is `NULL`, `XMLTest()` will segfault on `strcmp()`.
This patch adds null-checks, and passes the test if both `expected` and `found` are `NULL`.
2015-05-19 12:44:57 +05:30
Sarat Addepalli
a7edb883f0 Add a test case for issue #323
When compiled in "debug mode", this test case verifies that an assert is fired, when `XMLDocument::Value()` is called.
2015-05-19 12:39:27 +05:30
Sarat Addepalli
39a77dd825 Define the DEBUG macro in CMakeLists.txt
Fixes #334
2015-05-19 12:27:59 +05:30
Sarat Addepalli
8e85afa406 Fix whitespaces in xmltest.cpp 2015-05-19 09:07:03 +05:30
Sarat Addepalli
2f0d173f94 Fix whitespaces in tinyxml2.cpp 2015-05-19 09:02:16 +05:30
Sarat Addepalli
a0f499dda1 Fix ParseDeep() to close issue #332
If the node to be added is an XML Declaration, then check if the document has any children already.
XML Declarations can only be the FirstChild() s of an XML Document.
2015-05-18 09:25:17 +05:30
Sarat Addepalli
2bb6bb5bee Add a test case for issue #332
XML Declarations can occur only at the beginning of an XML Document.
Parse() should throw an error, for not well-formed XML Documents.
2015-05-18 09:16:34 +05:30
Dmitry-Me
67c429e4b4 Avoid unneeded printer object creation 2015-05-08 18:08:18 +03:00
Lee Thomason
e5e5541af6 Merge pull request #328 from Dmitry-Me/firstCheckThenConvert
First check, then convert
2015-05-07 13:54:31 -07:00
Dmitry-Me
72801b8b20 First check, then convert 2015-05-07 09:41:39 +03:00
Lee Thomason
89df56c046 Merge pull request #327 from Dmitry-Me/ensureFileSizeFitsInSizeT
Ensure file contents fit into size_t range
2015-05-06 16:40:01 -07:00
Dmitry-Me
2a8b1f5789 Ensure file contents fit into size_t range 2015-04-30 14:58:57 +03:00
Lee Thomason
882e89e601 Merge pull request #326 from Dmitry-Me/cleanupPointersComparison
Unify pointers comparison, consistency asserts
2015-04-27 16:57:37 -07:00
Lee Thomason
a295da4302 Merge pull request #324 from Dmitry-Me/checkWithoutClangTautological
Range check without clang "always true" warning
2015-04-27 16:56:24 -07:00
Dmitry-Me
69d521d354 Unify pointers comparison, consistency asserts 2015-04-20 18:05:53 +03:00
Dmitry-Me
2ad4320339 Range check without clang "always true" warning 2015-04-16 12:18:58 +03:00
Lee Thomason
4f0c2ffcab fix 'always true' warning 2015-04-13 13:58:20 -07:00
Lee Thomason
70f2c740c0 Merge pull request #322 from Dmitry-Me/detectParsingErrorEarlier
Detect parsing error earlier when looking at end of tag
2015-04-13 13:43:07 -07:00
Dmitry-Me
ccd267a782 Detect parsing error earlier when looking at end of tag 2015-04-10 15:42:54 +03:00
Lee Thomason
9f24acd369 Merge pull request #321 from Dmitry-Me/dontLeakTheElement
Don't leak the element
2015-04-09 14:49:59 -07:00
Lee Thomason
e3932d6b7f Merge pull request #319 from Dmitry-Me/getRidOfNull
Get rid of NULL, cleanup formatting
2015-04-09 14:49:25 -07:00
Lee Thomason
5ea4f3cb77 Merge pull request #315 from Dmitry-Me/orderPatternsAsTheyAreSearched
Order patterns the same way they are searched
2015-04-09 14:48:44 -07:00
Lee Thomason
2d39158eaa Merge pull request #317 from Dmitry-Me/moreConsistencyAsserts
More consistency asserts
2015-04-09 14:48:18 -07:00
Dmitry-Me
5daa54cf2b Don't leak the element 2015-04-08 17:45:07 +03:00
Dmitry-Me
e76b8519d1 Get rid of NULL, cleanup formatting 2015-04-08 13:41:40 +03:00
Dmitry-Me
9614f8ff74 More consistency asserts 2015-04-08 10:06:06 +03:00
Lee Thomason
4a0392dd9d Merge pull request #314 from Dmitry-Me/ensureEnumIsPrintedProperly
Ensure enum is printed properly
2015-04-07 09:55:18 -07:00
Lee Thomason
0aa957a352 Merge pull request #313 from Dmitry-Me/shouldBeNoErrorInitially
Test there's no error initially, proper swap "found" and "expected"
2015-04-07 09:53:24 -07:00
Dmitry-Me
400f1199ea Ensure enum is printed properly 2015-04-07 11:51:21 +03:00
Dmitry-Me
32533ca9c2 Test there's no error initially, proper swap "found" and "expected" 2015-04-07 10:37:39 +03:00
Lee Thomason
a1a4a13825 Merge pull request #312 from Dmitry-Me/newDocumentMustBeEmpty
Document must be initially empty
2015-04-06 14:26:23 -07:00
Lee Thomason
4034395d1a Merge pull request #311 from Dmitry-Me/betterParameterName
Better parameter name
2015-04-06 14:25:57 -07:00
Lee Thomason
2a2ed16ce1 Merge pull request #310 from Dmitry-Me/moreConst
Const qualifiers where access is const, unify formatting
2015-04-06 14:25:37 -07:00
Lee Thomason
1881344cb6 Merge pull request #309 from Dmitry-Me/makeParseDeepProtected
Make ParseDeep() protected
2015-04-06 14:25:00 -07:00
Dmitry-Me
48b5df0b9b Document must be initially empty 2015-04-06 18:20:25 +03:00
Dmitry-Me
040092215d Better parameter name 2015-04-06 18:07:18 +03:00
Dmitry-Me
2667aab551 Const qualifiers where access is const, unify formatting 2015-04-03 10:56:59 +03:00
Dmitry-Me
9b0f17753d Make ParseDeep() protected 2015-04-03 10:37:31 +03:00
Lee Thomason
51b33321be Merge pull request #308 from Dmitry-Me/mergePrintCalls
Merge Print() calls
2015-04-02 13:27:50 -07:00
Lee Thomason
8c067ab730 Merge pull request #307 from Dmitry-Me/simplifyOverengineeredCode
Simplify overengineered code
2015-04-02 13:27:17 -07:00
Lee Thomason
fb33e99a77 Merge pull request #306 from Dmitry-Me/printSubstringEntirely
Print entire substring instead of each character
2015-04-02 13:26:50 -07:00
Dmitry-Me
6a79c17c87 Merge Print() calls 2015-03-31 12:18:17 +03:00
Dmitry-Me
8d4e0ec528 Simplify overengineered code 2015-03-30 12:58:28 +03:00
Dmitry-Me
c505e136da Order patterns the same way they are searched 2015-03-30 09:54:36 +03:00
Dmitry-Me
d95172ba47 Print entire substring instead of each character 2015-03-30 08:11:18 +03:00
Lee Thomason
28c7c8c14f Merge pull request #305 from Dmitry-Me/errorShouldBeClearedAfterLoad
If LoadFile() fails then subsequent successful LoadFile() must clear the error
2015-03-26 11:19:28 -07:00
Lee Thomason
55c7879352 Merge branch 'Haloric-Issue-302' 2015-03-26 11:18:42 -07:00
Lee Thomason
f657783cf2 merge fix for save file error 2015-03-26 11:18:21 -07:00
Dmitry-Me
d9852a53af If LoadFile() fails then subsequent successful LoadFile() must clear the error 2015-03-25 10:17:49 +03:00
Lee Thomason
ea21390f28 Merge branch 'Haloric-Issue299' 2015-03-24 11:18:12 -07:00
Lee Thomason
3ccb1cec29 minor formatting cleanup 2015-03-24 11:17:44 -07:00
Ant Mitchell
189198f19c Issue 302: clear any previous save error 2015-03-24 16:20:36 +00:00
Ant Mitchell
148cc1a0a5 Issue 299 - test for code changes 2015-03-24 15:12:35 +00:00
Ant Mitchell
7e744771ad Issue299 - Allow Accept() to work with element trees that are not
linked in to the owning document.
2015-03-24 14:33:28 +00:00
Lee Thomason
32cca51ac5 Merge pull request #300 from davidsanfal/master
Add biicode support to TinyXML-2
2015-03-20 21:29:37 -07:00
Lee Thomason
01969dcde2 Merge remote-tracking branch 'origin/master' 2015-03-17 21:31:57 -07:00
Lee Thomason
2b1e18185c Merge pull request #298 from Dmitry-Me/fixCommentTypo
Fix comment typo
2015-03-16 11:57:38 -07:00
Lee Thomason
5ea1cf33f3 Merge pull request #297 from Dmitry-Me/betterAssertsInParsing
Better asserts in parsing
2015-03-16 11:57:13 -07:00
David
4633c3aa27 add biicode support 2015-03-16 10:41:00 +01:00
Dmitry-Me
2f465c412a Fix comment typo 2015-03-16 11:08:23 +03:00
Dmitry-Me
3dc797b2a4 Better asserts in parsing 2015-03-16 11:06:46 +03:00
15 changed files with 1857 additions and 622 deletions

5
.gitignore vendored
View File

@@ -5,9 +5,14 @@ ipch/
resources/out/
tinyxml2/tinyxml2-cbp/bin/
tinyxml2/tinyxml2-cbp/obj/
tinyxml2/bin/
tinyxml2/temp/
*.sdf
*.suo
*.opensdf
*.user
*.depend
*.layout
*.o
*.vc.db
*.vc.opendb

15
.travis.yml Normal file
View File

@@ -0,0 +1,15 @@
language: cpp
os:
- linux
- osx
compiler:
- g++
- clang
before_script: cmake .
script:
- make -j3
- make test

View File

@@ -1,8 +1,19 @@
IF(BIICODE)
ADD_BIICODE_TARGETS()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/resources)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
ENDIF()
RETURN()
ENDIF(BIICODE)
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
cmake_policy(VERSION 2.6)
if(POLICY CMP0063)
cmake_policy(SET CMP0063 OLD)
endif()
project(tinyxml2)
include(GNUInstallDirs)
include(CTest)
#enable_testing()
#CMAKE_BUILD_TOOL
@@ -10,59 +21,125 @@ include(GNUInstallDirs)
################################
# set lib version here
set(GENERIC_LIB_VERSION "3.0.0")
set(GENERIC_LIB_SOVERSION "3")
################################
# Add common source
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/.")
################################
# Add custom target to copy all data
set(TARGET_DATA_COPY DATA_COPY)
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
add_custom_target(
${TARGET_DATA_COPY}
COMMAND ${CMAKE_COMMAND} -E echo "In source build")
else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
make_directory(${CMAKE_CURRENT_BINARY_DIR}/resources/)
add_custom_target(
${TARGET_DATA_COPY}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/dream.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/empty.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/utf8test.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/utf8testverify.xml ${CMAKE_CURRENT_BINARY_DIR}/resources/)
endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
set(GENERIC_LIB_VERSION "5.0.1")
set(GENERIC_LIB_SOVERSION "5")
################################
# Add definitions
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
################################
# Add targets
option(BUILD_SHARED_LIBS "build shared or static libraries" ON)
add_library(tinyxml2 tinyxml2.cpp tinyxml2.h)
# By Default shared libray is being built
# To build static libs also - Do cmake . -DBUILD_STATIC_LIBS:BOOL=ON
# User can choose not to build shared library by using cmake -DBUILD_SHARED_LIBS:BOOL=OFF
# To build only static libs use cmake . -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON
# To build the tests, use cmake . -DBUILD_TESTS:BOOL=ON
# To disable the building of the tests, use cmake . -DBUILD_TESTS:BOOL=OFF
option(BUILD_SHARED_LIBS "build as shared library" ON)
option(BUILD_STATIC_LIBS "build as static library" OFF)
option(BUILD_TESTS "build xmltest (deprecated: Use BUILD_TESTING)" ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
# to distinguish between debug and release lib
set(CMAKE_DEBUG_POSTFIX "d")
if(BUILD_SHARED_LIBS)
add_library(tinyxml2 SHARED tinyxml2.cpp tinyxml2.h)
set_target_properties(tinyxml2 PROPERTIES
COMPILE_DEFINITIONS "TINYXML2_EXPORT"
VERSION "${GENERIC_LIB_VERSION}"
SOVERSION "${GENERIC_LIB_SOVERSION}")
add_executable(xmltest xmltest.cpp)
add_dependencies(xmltest tinyxml2)
add_dependencies(xmltest ${TARGET_DATA_COPY})
target_link_libraries(xmltest tinyxml2)
if(DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
target_include_directories(tinyxml2 PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>)
if(MSVC)
target_compile_definitions(tinyxml2 PUBLIC -D_CRT_SECURE_NO_WARNINGS)
endif(MSVC)
else()
include_directories(${PROJECT_SOURCE_DIR})
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif(MSVC)
endif()
# export targets for find_package config mode
export(TARGETS tinyxml2
FILE ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Targets.cmake)
install(TARGETS tinyxml2
EXPORT ${CMAKE_PROJECT_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(BUILD_STATIC_LIBS)
add_library(tinyxml2_static STATIC tinyxml2.cpp tinyxml2.h)
set_target_properties(tinyxml2_static PROPERTIES
COMPILE_DEFINITONS "TINYXML2_EXPORT"
VERSION "${GENERIC_LIB_VERSION}"
SOVERSION "${GENERIC_LIB_SOVERSION}")
set_target_properties( tinyxml2_static PROPERTIES OUTPUT_NAME tinyxml2 )
target_compile_definitions(tinyxml2_static PUBLIC -D_CRT_SECURE_NO_WARNINGS)
if(DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
target_include_directories(tinyxml2_static PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>)
if(MSVC)
target_compile_definitions(tinyxml2_static PUBLIC -D_CRT_SECURE_NO_WARNINGS)
endif(MSVC)
else()
include_directories(${PROJECT_SOURCE_DIR})
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif(MSVC)
endif()
# export targets for find_package config mode
export(TARGETS tinyxml2_static
FILE ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Targets.cmake)
install(TARGETS tinyxml2_static
EXPORT ${CMAKE_PROJECT_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(BUILD_TESTING AND BUILD_TESTS)
add_executable(xmltest xmltest.cpp)
if(BUILD_SHARED_LIBS)
add_dependencies(xmltest tinyxml2)
target_link_libraries(xmltest tinyxml2)
else(BUILD_STATIC_LIBS)
add_dependencies(xmltest tinyxml2_static)
target_link_libraries(xmltest tinyxml2_static)
endif()
# Copy test resources and create test output directory
add_custom_command(TARGET xmltest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources $<TARGET_FILE_DIR:xmltest>/resources
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:xmltest>/resources/out
COMMENT "Configuring xmltest resources directory: ${CMAKE_BINARY_DIR}/resources"
)
add_test(NAME xmltest COMMAND xmltest)
endif()
install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
@@ -76,4 +153,24 @@ endforeach()
configure_file(tinyxml2.pc.in tinyxml2.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
#add_test(xmltest ${SAMPLE_NAME} COMMAND $<TARGET_FILE:${SAMPLE_NAME}>)
# uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
file(WRITE
${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
"include(\${CMAKE_CURRENT_LIST_DIR}/${CMAKE_PROJECT_NAME}Targets.cmake)\n")
install(FILES
${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
DESTINATION lib/cmake/${CMAKE_PROJECT_NAME})
install(EXPORT ${CMAKE_PROJECT_NAME}Targets
DESTINATION lib/cmake/${CMAKE_PROJECT_NAME})

View File

@@ -1,6 +1,19 @@
all: xmltest
xmltest: xmltest.cpp tinyxml2.cpp tinyxml2.h
all: xmltest staticlib
rebuild: clean all
xmltest: xmltest.cpp libtinyxml2.a
clean:
$(RM) *.o xmltest libtinyxml2.a
test: clean xmltest
./xmltest
clean:
rm -f *.o xmltest
staticlib: libtinyxml2.a
libtinyxml2.a: tinyxml2.o
$(AR) $(ARFLAGS)s $@ $^
tinyxml2.o: tinyxml2.cpp tinyxml2.h

7
appveyor.yml Normal file
View File

@@ -0,0 +1,7 @@
before_build:
- cmake .
build_script:
- msbuild tinyxml2.sln /m /p:Configuration=Release /t:ALL_BUILD
- cd Release
- xmltest.exe

7
biicode.conf Normal file
View File

@@ -0,0 +1,7 @@
# Biicode configuration file
[paths]
/
[dependencies]
xmltest.cpp + resources/*.xml

21
cmake_uninstall.cmake.in Normal file
View File

@@ -0,0 +1,21 @@
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)

View File

@@ -65,7 +65,7 @@ public:
protected:
virtual void CloseElement () {
if (_elementJustOpened && !isVoidElement (_stack.PeekTop())) {
SealElement();
SealElementIfJustOpened();
}
XMLPrinter::CloseElement();
}

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 = 3.0.0
PROJECT_NUMBER = 5.0.1
# 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

@@ -1,4 +1,4 @@
TinyXML-2
TinyXML-2 [![TravisCI Status](https://travis-ci.org/leethomason/tinyxml2.svg?branch=master)](https://travis-ci.org/leethomason/tinyxml2) [![AppVeyor Status](https://ci.appveyor.com/api/projects/status/github/leethomason/tinyxml2?branch=master&svg=true)](https://ci.appveyor.com/project/leethomason/tinyxml2)
=========
![TinyXML-2 Logo](http://www.grinninglizard.com/tinyxml2/TinyXML2_small.png)
@@ -88,9 +88,8 @@ Advantages of TinyXML-2
Advantages of TinyXML-1
1. Can report the location of parsing errors.
2. Support for some C++ STL conventions: streams and strings
3. Very mature and well debugged code base.
1. Support for some C++ STL conventions: streams and strings
2. Very mature and well debugged code base.
Features
--------
@@ -111,7 +110,7 @@ by the Document. When the Document is deleted, so are all the nodes it contains.
Microsoft has an excellent article on white space: http://msdn.microsoft.com/en-us/library/ms256097.aspx
By default, TinyXML-2 preserves white space in a (hopefully) sane way that is almost complient with the
By default, TinyXML-2 preserves white space in a (hopefully) sane way that is almost compliant with the
spec. (TinyXML-1 used a completely different model, much more similar to 'collapse', below.)
As a first step, all newlines / carriage-returns / line-feeds are normalized to a
@@ -157,6 +156,15 @@ However, you may also use COLLAPSE_WHITESPACE, which will:
Note that (currently) there is a performance impact for using COLLAPSE_WHITESPACE.
It essentially causes the XML to be parsed twice.
#### Error Reporting
TinyXML-2 reports the line number of any errors in an XML document that
cannot be parsed correctly. In addition, all nodes (elements, declarations,
text, comments etc.) and attributes have a line number recorded as they are parsed.
This allows an application that performs additional validation of the parsed
XML document (e.g. application-implemented DTD validation) to report
line number information in it's errors.
### Entities
TinyXML-2 recognizes the pre-defined "character entities", meaning special
@@ -177,7 +185,7 @@ will have the Value() of "Far & Away" when queried from the XMLText object,
and will be written back to the XML stream/file as an ampersand.
Additionally, any character can be specified by its Unicode code point:
The syntax "&#xA0;" or "&#160;" are both to the non-breaking space characher.
The syntax `&#xA0;` or `&#160;` are both to the non-breaking space character.
This is called a 'numeric character reference'. Any numeric character reference
that isn't one of the special entities above, will be read, but written as a
regular code point. The output is correct, but the entity syntax isn't preserved.
@@ -264,8 +272,8 @@ There are 2 files in TinyXML-2:
And additionally a test file:
* xmltest.cpp
Simply compile and run. There is a visual studio 2010 project included, a simple Makefile,
an XCode project, a Code::Blocks project, and a cmake CMakeLists.txt included to help you.
Simply compile and run. There is a visual studio 2015 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 *nix and don't want
to use a build system.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug-Dll|Win32">
<Configuration>Debug-Dll</Configuration>
@@ -37,51 +37,60 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{E8FB2712-8666-4662-A5B8-2B5B0FB1A260}</ProjectGuid>
<RootNamespace>test</RootNamespace>
<WindowsTargetPlatformVersion>8.1</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>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<CharacterSet>Unicode</CharacterSet>
@@ -125,53 +134,49 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|Win32'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|Win32'">
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|Win32'">
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|Win32'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|Win32'">
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|Win32'">
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|Win32'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|Win32'">
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|Win32'">
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|Win32'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|Win32'">
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|Win32'">
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|x64'">
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)bin\$(ProjectName)\$(Platform)-$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|x64'">
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|x64'">
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)bin\$(ProjectName)\$(Platform)-$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|x64'">
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|x64'">
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)bin\$(ProjectName)\$(Platform)-$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|x64'">
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|x64'">
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)bin\$(ProjectName)\$(Platform)-$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|x64'">
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|Win32'">
<ClCompile>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug-Dll|Win32">
<Configuration>Debug-Dll</Configuration>
@@ -38,51 +38,60 @@
<ProjectGuid>{D1C528B6-AA02-4D29-9D61-DC08E317A70D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>tinyxml2</RootNamespace>
<WindowsTargetPlatformVersion>8.1</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>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ConfigurationType>StaticLibrary</ConfigurationType>
@@ -132,43 +141,43 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)bin\$(ProjectName)\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)bin\$(ProjectName)\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)bin\$(ProjectName)\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Dll|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)bin\$(ProjectName)\$(Platform)-$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)temp\$(ProjectName)\$(Platform)-$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|Win32'">
<ClCompile>

View File

@@ -10,16 +10,11 @@
#include <ctime>
#if defined( _MSC_VER )
#include <direct.h> // _mkdir
#include <crtdbg.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
_CrtMemState startMemState;
_CrtMemState endMemState;
#elif defined(MINGW32) || defined(__MINGW32__)
#include <io.h> // mkdir
#else
#include <sys/stat.h> // mkdir
#endif
using namespace tinyxml2;
@@ -30,7 +25,13 @@ int gFail = 0;
bool XMLTest (const char* testString, const char* expected, const char* found, bool echo=true, bool extraNL=false )
{
bool pass = !strcmp( expected, found );
bool pass;
if ( !expected && !found )
pass = true;
else if ( !expected || !found )
pass = false;
else
pass = !strcmp( expected, found );
if ( pass )
printf ("[pass]");
else
@@ -57,6 +58,15 @@ bool XMLTest (const char* testString, const char* expected, const char* found, b
return pass;
}
bool XMLTest(const char* testString, XMLError expected, XMLError found, bool echo = true, bool extraNL = false)
{
return XMLTest(testString, XMLDocument::ErrorIDToName(expected), XMLDocument::ErrorIDToName(found), echo, extraNL);
}
bool XMLTest(const char* testString, bool expected, bool found, bool echo = true, bool extraNL = false)
{
return XMLTest(testString, expected ? "true" : "false", found ? "true" : "false", echo, extraNL);
}
template< class T > bool XMLTest( const char* testString, T expected, T found, bool echo=true )
{
@@ -282,17 +292,10 @@ int main( int argc, const char ** argv )
_CrtMemCheckpoint( &startMemState );
// Enable MS Visual C++ debug heap memory leaks dump on exit
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
#endif
#if defined(_MSC_VER) || defined(MINGW32) || defined(__MINGW32__)
#if defined __MINGW64_VERSION_MAJOR && defined __MINGW64_VERSION_MINOR
//MINGW64: both 32 and 64-bit
mkdir( "resources/out/" );
#else
_mkdir( "resources/out/" );
#endif
#else
mkdir( "resources/out/", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
{
int leaksOnStart = _CrtDumpMemoryLeaks();
XMLTest( "No leaks on start?", FALSE, leaksOnStart );
}
#endif
{
@@ -410,6 +413,7 @@ int main( int argc, const char ** argv )
}
element->InsertEndChild( sub[2] );
XMLNode* comment = element->InsertFirstChild( doc->NewComment( "comment" ) );
comment->SetUserData((void*)2);
element->InsertAfterChild( comment, sub[0] );
element->InsertAfterChild( sub[0], sub[1] );
sub[2]->InsertFirstChild( doc->NewText( "& Text!" ));
@@ -419,6 +423,7 @@ int main( int argc, const char ** argv )
XMLTest( "Programmatic DOM", 2, doc->FirstChildElement()->LastChildElement( "sub" )->IntAttribute( "attrib" ) );
XMLTest( "Programmatic DOM", "& Text!",
doc->FirstChildElement()->LastChildElement( "sub" )->FirstChild()->ToText()->Value() );
XMLTest("User data", (void*)2 == comment->GetUserData(), true, false);
// And now deletion:
element->DeleteChild( sub[2] );
@@ -428,10 +433,12 @@ int main( int argc, const char ** argv )
element->LastChildElement()->DeleteAttribute( "attrib" );
XMLTest( "Programmatic DOM", true, doc->FirstChildElement()->FirstChildElement()->BoolAttribute( "attrib" ) );
int value = 10;
int result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value );
XMLTest( "Programmatic DOM", result, (int)XML_NO_ATTRIBUTE );
XMLTest( "Programmatic DOM", value, 10 );
int value1 = 10;
int value2 = doc->FirstChildElement()->LastChildElement()->IntAttribute( "attrib", 10 );
XMLError result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value1 );
XMLTest( "Programmatic DOM", XML_NO_ATTRIBUTE, result );
XMLTest( "Programmatic DOM", 10, value1 );
XMLTest( "Programmatic DOM", 10, value2 );
doc->Print();
@@ -443,7 +450,7 @@ int main( int argc, const char ** argv )
{
XMLPrinter streamer( 0, true );
doc->Print( &streamer );
XMLTest( "Compact mode", "<element><sub attrib=\"1\"/><sub/></element>", streamer.CStr(), false );
XMLTest( "Compact mode", "<element><sub attrib=\"true\"/><sub/></element>", streamer.CStr(), false );
}
doc->SaveFile( "./resources/out/pretty.xml" );
doc->SaveFile( "./resources/out/compact.xml", true );
@@ -492,7 +499,7 @@ int main( int argc, const char ** argv )
XMLDocument doc;
doc.Parse( error );
XMLTest( "Bad XML", doc.ErrorID(), XML_ERROR_PARSING_ATTRIBUTE );
XMLTest( "Bad XML", XML_ERROR_PARSING_ATTRIBUTE, doc.ErrorID() );
}
{
@@ -503,22 +510,31 @@ int main( int argc, const char ** argv )
XMLElement* ele = doc.FirstChildElement();
int iVal, result;
int iVal;
XMLError result;
double dVal;
result = ele->QueryDoubleAttribute( "attr0", &dVal );
XMLTest( "Query attribute: int as double", result, (int)XML_NO_ERROR );
XMLTest( "Query attribute: int as double", (int)dVal, 1 );
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, (int)ele->DoubleAttribute("attr0"));
result = ele->QueryDoubleAttribute( "attr1", &dVal );
XMLTest( "Query attribute: double as double", result, (int)XML_NO_ERROR );
XMLTest( "Query attribute: double as double", (int)dVal, 2 );
XMLTest( "Query attribute: double as double", XML_SUCCESS, result);
XMLTest( "Query attribute: double as double", 2.0, dVal );
XMLTest( "Query attribute: double as double", 2.0, ele->DoubleAttribute("attr1") );
result = ele->QueryIntAttribute( "attr1", &iVal );
XMLTest( "Query attribute: double as int", result, (int)XML_NO_ERROR );
XMLTest( "Query attribute: double as int", iVal, 2 );
XMLTest( "Query attribute: double as int", XML_SUCCESS, result);
XMLTest( "Query attribute: double as int", 2, iVal );
result = ele->QueryIntAttribute( "attr2", &iVal );
XMLTest( "Query attribute: not a number", result, (int)XML_WRONG_ATTRIBUTE_TYPE );
XMLTest( "Query attribute: not a number", XML_WRONG_ATTRIBUTE_TYPE, result );
XMLTest( "Query attribute: not a number", 4.0, ele->DoubleAttribute("attr2", 4.0) );
result = ele->QueryIntAttribute( "bar", &iVal );
XMLTest( "Query attribute: does not exist", result, (int)XML_NO_ATTRIBUTE );
XMLTest( "Query attribute: does not exist", XML_NO_ATTRIBUTE, result );
XMLTest( "Query attribute: does not exist", true, ele->BoolAttribute("bar", true) );
}
{
@@ -543,12 +559,14 @@ int main( int argc, const char ** argv )
ele->QueryAttribute( "int", &iVal2 );
ele->QueryAttribute( "double", &dVal2 );
XMLTest( "Attribute match test", ele->Attribute( "str", "strValue" ), "strValue" );
XMLTest( "Attribute match test", "strValue", ele->Attribute( "str", "strValue" ) );
XMLTest( "Attribute round trip. c-string.", "strValue", cStr );
XMLTest( "Attribute round trip. int.", 1, iVal );
XMLTest( "Attribute round trip. double.", -1, (int)dVal );
XMLTest( "Alternate query", true, iVal == iVal2 );
XMLTest( "Alternate query", true, dVal == dVal2 );
XMLTest( "Alternate query", true, iVal == ele->IntAttribute("int") );
XMLTest( "Alternate query", true, dVal == ele->DoubleAttribute("double") );
}
{
@@ -671,7 +689,7 @@ int main( int argc, const char ** argv )
XMLTest( "SetText types", "1", element->GetText() );
element->SetText( true );
XMLTest( "SetText types", "1", element->GetText() ); // TODO: should be 'true'?
XMLTest( "SetText types", "true", element->GetText() );
element->SetText( 1.5f );
XMLTest( "SetText types", "1.5", element->GetText() );
@@ -680,6 +698,125 @@ int main( int argc, const char ** argv )
XMLTest( "SetText types", "1.5", element->GetText() );
}
// ---------- Attributes ---------
{
static const int64_t BIG = -123456789012345678;
XMLDocument doc;
XMLElement* element = doc.NewElement("element");
doc.InsertFirstChild(element);
{
element->SetAttribute("attrib", int(-100));
int v = 0;
element->QueryIntAttribute("attrib", &v);
XMLTest("Attribute: int", -100, v, true);
element->QueryAttribute("attrib", &v);
XMLTest("Attribute: int", -100, v, true);
XMLTest("Attribute: int", -100, element->IntAttribute("attrib"), true);
}
{
element->SetAttribute("attrib", unsigned(100));
unsigned v = 0;
element->QueryUnsignedAttribute("attrib", &v);
XMLTest("Attribute: unsigned", unsigned(100), v, true);
element->QueryAttribute("attrib", &v);
XMLTest("Attribute: unsigned", unsigned(100), v, true);
XMLTest("Attribute: unsigned", unsigned(100), element->UnsignedAttribute("attrib"), true);
}
{
element->SetAttribute("attrib", BIG);
int64_t v = 0;
element->QueryInt64Attribute("attrib", &v);
XMLTest("Attribute: int64_t", BIG, v, true);
element->QueryAttribute("attrib", &v);
XMLTest("Attribute: int64_t", BIG, v, true);
XMLTest("Attribute: int64_t", BIG, element->Int64Attribute("attrib"), true);
}
{
element->SetAttribute("attrib", true);
bool v = false;
element->QueryBoolAttribute("attrib", &v);
XMLTest("Attribute: bool", true, v, true);
element->QueryAttribute("attrib", &v);
XMLTest("Attribute: bool", true, v, true);
XMLTest("Attribute: bool", true, element->BoolAttribute("attrib"), true);
}
{
element->SetAttribute("attrib", true);
const char* result = element->Attribute("attrib");
XMLTest("Bool true is 'true'", "true", result);
XMLUtil::SetBoolSerialization("1", "0");
element->SetAttribute("attrib", true);
result = element->Attribute("attrib");
XMLTest("Bool true is '1'", "1", result);
XMLUtil::SetBoolSerialization(0, 0);
}
{
element->SetAttribute("attrib", 100.0);
double v = 0;
element->QueryDoubleAttribute("attrib", &v);
XMLTest("Attribute: double", 100.0, v, true);
element->QueryAttribute("attrib", &v);
XMLTest("Attribute: double", 100.0, v, true);
XMLTest("Attribute: double", 100.0, element->DoubleAttribute("attrib"), true);
}
{
element->SetAttribute("attrib", 100.0f);
float v = 0;
element->QueryFloatAttribute("attrib", &v);
XMLTest("Attribute: float", 100.0f, v, true);
element->QueryAttribute("attrib", &v);
XMLTest("Attribute: float", 100.0f, v, true);
XMLTest("Attribute: float", 100.0f, element->FloatAttribute("attrib"), true);
}
{
element->SetText(BIG);
int64_t v = 0;
element->QueryInt64Text(&v);
XMLTest("Element: int64_t", BIG, v, true);
}
}
// ---------- XMLPrinter stream mode ------
{
{
FILE* printerfp = fopen("resources/printer.xml", "w");
XMLPrinter printer(printerfp);
printer.OpenElement("foo");
printer.PushAttribute("attrib-text", "text");
printer.PushAttribute("attrib-int", int(1));
printer.PushAttribute("attrib-unsigned", unsigned(2));
printer.PushAttribute("attrib-int64", int64_t(3));
printer.PushAttribute("attrib-bool", true);
printer.PushAttribute("attrib-double", 4.0);
printer.CloseElement();
fclose(printerfp);
}
{
XMLDocument doc;
doc.LoadFile("resources/printer.xml");
XMLTest("XMLPrinter Stream mode: load", XML_SUCCESS, doc.ErrorID(), true);
const XMLDocument& cdoc = doc;
const XMLAttribute* attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-text");
XMLTest("attrib-text", "text", attrib->Value(), true);
attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-int");
XMLTest("attrib-int", int(1), attrib->IntValue(), true);
attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-unsigned");
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-bool");
XMLTest("attrib-bool", true, attrib->BoolValue(), true);
attrib = cdoc.FirstChildElement("foo")->FindAttribute("attrib-double");
XMLTest("attrib-double", 4.0, attrib->DoubleValue(), true);
}
}
// ---------- CDATA ---------------
{
@@ -693,8 +830,8 @@ int main( int argc, const char ** argv )
doc.Parse( str );
doc.Print();
XMLTest( "CDATA parse.", doc.FirstChildElement()->FirstChild()->Value(),
"I am > the rules!\n...since I make symbolic puns",
XMLTest( "CDATA parse.", "I am > the rules!\n...since I make symbolic puns",
doc.FirstChildElement()->FirstChild()->Value(),
false );
}
@@ -710,8 +847,9 @@ int main( int argc, const char ** argv )
doc.Parse( str );
doc.Print();
XMLTest( "CDATA parse. [ tixml1:1480107 ]", doc.FirstChildElement()->FirstChild()->Value(),
XMLTest( "CDATA parse. [ tixml1:1480107 ]",
"<b>I am > the rules!</b>\n...since I make symbolic puns",
doc.FirstChildElement()->FirstChild()->Value(),
false );
}
@@ -728,7 +866,7 @@ int main( int argc, const char ** argv )
XMLNode* childNode0 = parent->InsertEndChild( childText0 );
XMLNode* childNode1 = parent->InsertAfterChild( childNode0, childText1 );
XMLTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent->LastChild() ), true );
XMLTest( "Test InsertAfterChild on empty node. ", true, ( childNode1 == parent->LastChild() ) );
}
{
@@ -783,10 +921,11 @@ int main( int argc, const char ** argv )
XMLDocument doc( false );
doc.Parse( passages );
XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->Attribute( "context" ),
"Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;." );
XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->FirstChild()->Value(),
"Crazy &ttk;" );
XMLTest( "No entity parsing.",
"Line 5 has &quot;quotation marks&quot; and &apos;apostrophe marks&apos;.",
doc.FirstChildElement()->FirstChildElement()->Attribute( "context" ) );
XMLTest( "No entity parsing.", "Crazy &ttk;",
doc.FirstChildElement()->FirstChildElement()->FirstChild()->Value() );
doc.Print();
}
@@ -795,9 +934,9 @@ int main( int argc, const char ** argv )
XMLDocument doc;
doc.Parse( test );
XMLTest( "dot in names", doc.Error(), false );
XMLTest( "dot in names", doc.FirstChildElement()->Name(), "a.elem" );
XMLTest( "dot in names", doc.FirstChildElement()->Attribute( "xmi.version" ), "2.0" );
XMLTest( "dot in names", false, doc.Error() );
XMLTest( "dot in names", "a.elem", doc.FirstChildElement()->Name() );
XMLTest( "dot in names", "2.0", doc.FirstChildElement()->Attribute( "xmi.version" ) );
}
{
@@ -808,7 +947,7 @@ int main( int argc, const char ** argv )
XMLText* text = doc.FirstChildElement()->FirstChildElement()->FirstChild()->ToText();
XMLTest( "Entity with one digit.",
text->Value(), "1.1 Start easy ignore fin thickness\n",
"1.1 Start easy ignore fin thickness\n", text->Value(),
false );
}
@@ -886,7 +1025,7 @@ int main( int argc, const char ** argv )
XMLDocument doc;
doc.Parse( "<test>&#x0e;</test>" );
const char result[] = { 0x0e, 0 };
XMLTest( "Low entities.", doc.FirstChildElement()->GetText(), result );
XMLTest( "Low entities.", result, doc.FirstChildElement()->GetText() );
doc.Print();
}
@@ -894,18 +1033,18 @@ int main( int argc, const char ** argv )
// Attribute values with trailing quotes not handled correctly
XMLDocument doc;
doc.Parse( "<foo attribute=bar\" />" );
XMLTest( "Throw error with bad end quotes.", doc.Error(), true );
XMLTest( "Throw error with bad end quotes.", true, doc.Error() );
}
{
// [ 1663758 ] Failure to report error on bad XML
XMLDocument xml;
xml.Parse("<x>");
XMLTest("Missing end tag at end of input", xml.Error(), true);
XMLTest("Missing end tag at end of input", true, xml.Error());
xml.Parse("<x> ");
XMLTest("Missing end tag with trailing whitespace", xml.Error(), true);
XMLTest("Missing end tag with trailing whitespace", true, xml.Error());
xml.Parse("<x></y>");
XMLTest("Mismatched tags", xml.ErrorID(), XML_ERROR_MISMATCHED_ELEMENT);
XMLTest("Mismatched tags", XML_ERROR_MISMATCHED_ELEMENT, xml.ErrorID() );
}
@@ -994,10 +1133,90 @@ int main( int argc, const char ** argv )
XMLTest( "Clone and Equal", 4, count );
}
{
// Deep Cloning of root element.
XMLDocument doc2;
XMLPrinter printer1;
{
// Make sure doc1 is deleted before we test doc2
const char* xml =
"<root>"
" <child1 foo='bar'/>"
" <!-- comment thing -->"
" <child2 val='1'>Text</child2>"
"</root>";
XMLDocument doc;
doc.Parse(xml);
doc.Print(&printer1);
XMLNode* root = doc.RootElement()->DeepClone(&doc2);
doc2.InsertFirstChild(root);
}
XMLPrinter printer2;
doc2.Print(&printer2);
XMLTest("Deep clone of element.", printer1.CStr(), printer2.CStr(), true);
}
{
// Deep Cloning of sub element.
XMLDocument doc2;
XMLPrinter printer1;
{
// Make sure doc1 is deleted before we test doc2
const char* xml =
"<?xml version ='1.0'?>"
"<root>"
" <child1 foo='bar'/>"
" <!-- comment thing -->"
" <child2 val='1'>Text</child2>"
"</root>";
XMLDocument doc;
doc.Parse(xml);
const XMLElement* subElement = doc.FirstChildElement("root")->FirstChildElement("child2");
subElement->Accept(&printer1);
XMLNode* clonedSubElement = subElement->DeepClone(&doc2);
doc2.InsertFirstChild(clonedSubElement);
}
XMLPrinter printer2;
doc2.Print(&printer2);
XMLTest("Deep clone of sub-element.", printer1.CStr(), printer2.CStr(), true);
}
{
// Deep cloning of document.
XMLDocument doc2;
XMLPrinter printer1;
{
// Make sure doc1 is deleted before we test doc2
const char* xml =
"<?xml version ='1.0'?>"
"<!-- Top level comment. -->"
"<root>"
" <child1 foo='bar'/>"
" <!-- comment thing -->"
" <child2 val='1'>Text</child2>"
"</root>";
XMLDocument doc;
doc.Parse(xml);
doc.Print(&printer1);
doc.DeepCopy(&doc2);
}
XMLPrinter printer2;
doc2.Print(&printer2);
XMLTest("DeepCopy of document.", printer1.CStr(), printer2.CStr(), true);
}
{
// This shouldn't crash.
XMLDocument doc;
if(XML_NO_ERROR != doc.LoadFile( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
if(XML_SUCCESS != doc.LoadFile( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
{
doc.PrintError();
}
@@ -1070,7 +1289,7 @@ int main( int argc, const char ** argv )
doc.Parse( xml );
XMLElement* ele = XMLHandle( doc ).FirstChildElement( "element" ).FirstChild().ToElement();
XMLTest( "Handle, success, mutable", ele->Value(), "sub" );
XMLTest( "Handle, success, mutable", "sub", ele->Value() );
XMLHandle docH( doc );
ele = docH.FirstChildElement( "none" ).FirstChildElement( "element" ).ToElement();
@@ -1099,8 +1318,8 @@ int main( int argc, const char ** argv )
doc.Print( &printer );
static const char* result = "\xef\xbb\xbf<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
XMLTest( "BOM and default declaration", printer.CStr(), result, false );
XMLTest( "CStrSize", printer.CStrSize(), 42, false );
XMLTest( "BOM and default declaration", result, printer.CStr(), false );
XMLTest( "CStrSize", 42, printer.CStrSize(), false );
}
{
const char* xml = "<ipxml ws='1'><info bla=' /></ipxml>";
@@ -1130,47 +1349,50 @@ int main( int argc, const char ** argv )
pointElement->FirstChildElement( "valid" )->QueryBoolText( &boolValue );
XMLTest( "QueryIntText", intValue, 1, false );
XMLTest( "QueryUnsignedText", unsignedValue, (unsigned)1, false );
XMLTest( "QueryFloatText", floatValue, 1.2f, false );
XMLTest( "QueryDoubleText", doubleValue, 1.2, false );
XMLTest( "QueryBoolText", boolValue, true, false );
XMLTest( "QueryIntText", 1, intValue, false );
XMLTest( "QueryUnsignedText", (unsigned)1, unsignedValue, false );
XMLTest( "QueryFloatText", 1.2f, floatValue, false );
XMLTest( "QueryDoubleText", 1.2, doubleValue, false );
XMLTest( "QueryBoolText", true, boolValue, false );
}
{
const char* xml = "<element><_sub/><:sub/><sub:sub/><sub-sub/></element>";
XMLDocument doc;
doc.Parse( xml );
XMLTest( "Non-alpha element lead letter parses.", doc.Error(), false );
XMLTest( "Non-alpha element lead letter parses.", false, doc.Error() );
}
{
const char* xml = "<element _attr1=\"foo\" :attr2=\"bar\"></element>";
XMLDocument doc;
doc.Parse( xml );
XMLTest("Non-alpha attribute lead character parses.", doc.Error(), false);
XMLTest("Non-alpha attribute lead character parses.", false, doc.Error());
}
{
const char* xml = "<3lement></3lement>";
XMLDocument doc;
doc.Parse( xml );
XMLTest("Element names with lead digit fail to parse.", doc.Error(), true);
XMLTest("Element names with lead digit fail to parse.", true, doc.Error());
}
{
const char* xml = "<element/>WOA THIS ISN'T GOING TO PARSE";
XMLDocument doc;
doc.Parse( xml, 10 );
XMLTest( "Set length of incoming data", doc.Error(), false );
XMLTest( "Set length of incoming data", false, doc.Error() );
}
{
XMLDocument doc;
doc.LoadFile( "resources/dream.xml" );
XMLTest( "Document has something to Clear()", doc.NoChildren(), false );
XMLTest( "Document is initially empty", true, doc.NoChildren() );
doc.Clear();
XMLTest( "Document Clear()'s", doc.NoChildren(), true );
XMLTest( "Empty is empty after Clear()", true, doc.NoChildren() );
doc.LoadFile( "resources/dream.xml" );
XMLTest( "Document has something to Clear()", false, doc.NoChildren() );
doc.Clear();
XMLTest( "Document Clear()'s", true, doc.NoChildren() );
}
// ----------- Whitespace ------------
@@ -1247,7 +1469,7 @@ int main( int argc, const char ** argv )
static const char* xml_bom_preservation = "\xef\xbb\xbf<element/>\n";
{
XMLDocument doc;
XMLTest( "BOM preservation (parse)", XML_NO_ERROR, doc.Parse( xml_bom_preservation ), false );
XMLTest( "BOM preservation (parse)", XML_SUCCESS, doc.Parse( xml_bom_preservation ), false );
XMLPrinter printer;
doc.Print( &printer );
@@ -1425,6 +1647,296 @@ int main( int argc, const char ** argv )
XMLPrinter printer;
doc.Print( &printer );
}
{
// Issue 299. Can print elements that are not linked in.
// Will crash if issue not fixed.
XMLDocument doc;
XMLElement* newElement = doc.NewElement( "printme" );
XMLPrinter printer;
newElement->Accept( &printer );
// Delete the node to avoid possible memory leak report in debug output
doc.DeleteNode( newElement );
}
{
// Issue 302. Clear errors from LoadFile/SaveFile
XMLDocument doc;
XMLTest( "Issue 302. Should be no error initially", "XML_SUCCESS", doc.ErrorName() );
doc.SaveFile( "./no/such/path/pretty.xml" );
XMLTest( "Issue 302. Fail to save", "XML_ERROR_FILE_COULD_NOT_BE_OPENED", doc.ErrorName() );
doc.SaveFile( "./resources/out/compact.xml", true );
XMLTest( "Issue 302. Subsequent success in saving", "XML_SUCCESS", doc.ErrorName() );
}
{
// If a document fails to load then subsequent
// successful loads should clear the error
XMLDocument doc;
XMLTest( "Should be no error initially", false, doc.Error() );
doc.LoadFile( "resources/no-such-file.xml" );
XMLTest( "No such file - should fail", true, doc.Error() );
doc.LoadFile( "resources/dream.xml" );
XMLTest( "Error should be cleared", false, doc.Error() );
}
{
// Check that declarations are allowed only at beginning of document
const char* xml0 = "<?xml version=\"1.0\" ?>"
" <!-- xml version=\"1.1\" -->"
"<first />";
const char* xml1 = "<?xml version=\"1.0\" ?>"
"<?xml-stylesheet type=\"text/xsl\" href=\"Anything.xsl\"?>"
"<first />";
const char* xml2 = "<first />"
"<?xml version=\"1.0\" ?>";
const char* xml3 = "<first></first>"
"<?xml version=\"1.0\" ?>";
const char* xml4 = "<first><?xml version=\"1.0\" ?></first>";
XMLDocument doc;
doc.Parse(xml0);
XMLTest("Test that the code changes do not affect normal parsing", false, doc.Error() );
doc.Parse(xml1);
XMLTest("Test that the second declaration is allowed", false, doc.Error() );
doc.Parse(xml2);
XMLTest("Test that declaration after a child is not allowed", XML_ERROR_PARSING_DECLARATION, doc.ErrorID() );
doc.Parse(xml3);
XMLTest("Test that declaration after a child is not allowed", XML_ERROR_PARSING_DECLARATION, doc.ErrorID() );
doc.Parse(xml4);
XMLTest("Test that declaration inside a child is not allowed", XML_ERROR_PARSING_DECLARATION, doc.ErrorID() );
}
{
// No matter - before or after successfully parsing a text -
// calling XMLDocument::Value() causes an assert in debug.
const char* validXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
"<first />"
"<second />";
XMLDocument* doc = new XMLDocument();
XMLTest( "XMLDocument::Value() returns null?", NULL, doc->Value() );
doc->Parse( validXml );
XMLTest( "XMLDocument::Value() returns null?", NULL, doc->Value() );
delete doc;
}
{
XMLDocument doc;
for( int i = 0; i < XML_ERROR_COUNT; i++ ) {
doc.SetError( (XMLError)i, 0, 0, 0 );
doc.ErrorName();
}
}
{
// Evil memory leaks.
// If an XMLElement (etc) is allocated via NewElement() (etc.)
// and NOT added to the XMLDocument, what happens?
//
// Previously (buggy):
// The memory would be free'd when the XMLDocument is
// destructed. But the destructor wasn't called, so that
// memory allocated by the XMLElement would not be free'd.
// In practice this meant strings allocated by the XMLElement
// would leak. An edge case, but annoying.
// Now:
// The destructor is called. But the list of unlinked nodes
// has to be tracked. This has a minor performance impact
// that can become significant if you have a lot. (But why
// would you do that?)
// The only way to see this bug is in a leak tracker. This
// is compiled in by default on Windows Debug.
{
XMLDocument doc;
doc.NewElement("LEAK 1");
}
{
XMLDocument doc;
XMLElement* ele = doc.NewElement("LEAK 2");
doc.DeleteNode(ele);
}
}
{
// Crashing reported via email.
const char* xml =
"<playlist id='playlist1'>"
"<property name='track_name'>voice</property>"
"<property name='audio_track'>1</property>"
"<entry out = '604' producer = '4_playlist1' in = '0' />"
"<blank length = '1' />"
"<entry out = '1625' producer = '3_playlist' in = '0' />"
"<blank length = '2' />"
"<entry out = '946' producer = '2_playlist1' in = '0' />"
"<blank length = '1' />"
"<entry out = '128' producer = '1_playlist1' in = '0' />"
"</playlist>";
// It's not a good idea to delete elements as you walk the
// list. I'm not sure this technically should work; but it's
// an interesting test case.
XMLDocument doc;
XMLError err = doc.Parse(xml);
XMLTest("Crash bug parsing", XML_SUCCESS, err );
XMLElement* playlist = doc.FirstChildElement("playlist");
XMLTest("Crash bug parsing", true, playlist != 0);
tinyxml2::XMLElement* entry = playlist->FirstChildElement("entry");
XMLTest("Crash bug parsing", true, entry != 0);
while (entry) {
tinyxml2::XMLElement* todelete = entry;
entry = entry->NextSiblingElement("entry");
playlist->DeleteChild(todelete);
};
tinyxml2::XMLElement* blank = playlist->FirstChildElement("blank");
while (blank) {
tinyxml2::XMLElement* todelete = blank;
blank = blank->NextSiblingElement("blank");
playlist->DeleteChild(todelete);
};
tinyxml2::XMLPrinter printer;
playlist->Accept(&printer);
printf("%s\n", printer.CStr());
// No test; it only need to not crash.
// Still, wrap it up with a sanity check
int nProperty = 0;
for (const XMLElement* p = playlist->FirstChildElement("property"); p; p = p->NextSiblingElement("property")) {
nProperty++;
}
XMLTest("Crash bug parsing", 2, nProperty);
}
// ----------- Line Number Tracking --------------
{
struct TestUtil: XMLVisitor
{
void TestParseError(const char *testString, const char *docStr, XMLError expected_error, int expectedLine)
{
XMLDocument doc;
XMLError err = doc.Parse(docStr);
XMLTest(testString, true, doc.Error());
XMLTest(testString, expected_error, err);
XMLTest(testString, expectedLine, doc.GetErrorLineNum());
};
void TestStringLines(const char *testString, const char *docStr, const char *expectedLines)
{
XMLDocument doc;
doc.Parse(docStr);
XMLTest(testString, false, doc.Error());
TestDocLines(testString, doc, expectedLines);
}
void TestFileLines(const char *testString, const char *file_name, const char *expectedLines)
{
XMLDocument doc;
doc.LoadFile(file_name);
XMLTest(testString, false, doc.Error());
TestDocLines(testString, doc, expectedLines);
}
private:
DynArray<char, 10> str;
void Push(char type, int lineNum)
{
str.Push(type);
str.Push(char('0' + (lineNum / 10)));
str.Push(char('0' + (lineNum % 10)));
}
bool VisitEnter(const XMLDocument& doc)
{
Push('D', doc.GetLineNum());
return true;
}
bool VisitEnter(const XMLElement& element, const XMLAttribute* firstAttribute)
{
Push('E', element.GetLineNum());
for (const XMLAttribute *attr = firstAttribute; attr != 0; attr = attr->Next())
Push('A', attr->GetLineNum());
return true;
}
bool Visit(const XMLDeclaration& declaration)
{
Push('L', declaration.GetLineNum());
return true;
}
bool Visit(const XMLText& text)
{
Push('T', text.GetLineNum());
return true;
}
bool Visit(const XMLComment& comment)
{
Push('C', comment.GetLineNum());
return true;
}
bool Visit(const XMLUnknown& unknown)
{
Push('U', unknown.GetLineNum());
return true;
}
void TestDocLines(const char *testString, XMLDocument &doc, const char *expectedLines)
{
str.Clear();
doc.Accept(this);
str.Push(0);
XMLTest(testString, expectedLines, str.Mem());
}
} tester;
tester.TestParseError("ErrorLine-Parsing", "\n<root>\n foo \n<unclosed/>", XML_ERROR_PARSING, 2);
tester.TestParseError("ErrorLine-Declaration", "<root>\n<?xml version=\"1.0\"?>", XML_ERROR_PARSING_DECLARATION, 2);
tester.TestParseError("ErrorLine-Mismatch", "\n<root>\n</mismatch>", XML_ERROR_MISMATCHED_ELEMENT, 2);
tester.TestParseError("ErrorLine-CData", "\n<root><![CDATA[ \n foo bar \n", XML_ERROR_PARSING_CDATA, 2);
tester.TestParseError("ErrorLine-Text", "\n<root>\n foo bar \n", XML_ERROR_PARSING_TEXT, 3);
tester.TestParseError("ErrorLine-Comment", "\n<root>\n<!-- >\n", XML_ERROR_PARSING_COMMENT, 3);
tester.TestParseError("ErrorLine-Declaration", "\n<root>\n<? >\n", XML_ERROR_PARSING_DECLARATION, 3);
tester.TestParseError("ErrorLine-Unknown", "\n<root>\n<! \n", XML_ERROR_PARSING_UNKNOWN, 3);
tester.TestParseError("ErrorLine-Element", "\n<root>\n<unclosed \n", XML_ERROR_PARSING_ELEMENT, 3);
tester.TestParseError("ErrorLine-Attribute", "\n<root>\n<unclosed \n att\n", XML_ERROR_PARSING_ATTRIBUTE, 4);
tester.TestParseError("ErrorLine-ElementClose", "\n<root>\n<unclosed \n/unexpected", XML_ERROR_PARSING_ELEMENT, 3);
tester.TestStringLines(
"LineNumbers-String",
"<?xml version=\"1.0\"?>\n" // 1 Doc, DecL
"<root a='b' \n" // 2 Element Attribute
"c='d'> d <blah/> \n" // 3 Attribute Text Element
"newline in text \n" // 4 Text
"and second <zxcv/><![CDATA[\n" // 5 Element Text
" cdata test ]]><!-- comment -->\n" // 6 Comment
"<! unknown></root>", // 7 Unknown
"D01L01E02A02A03T03E03T04E05T05C06U07");
tester.TestStringLines(
"LineNumbers-CRLF",
"\r\n" // 1 Doc (arguably should be line 2)
"<?xml version=\"1.0\"?>\n" // 2 DecL
"<root>\r\n" // 3 Element
"\n" // 4
"text contining new line \n" // 5 Text
" and also containing crlf \r\n" // 6
"<sub><![CDATA[\n" // 7 Element Text
"cdata containing new line \n" // 8
" and also containing cflr\r\n" // 9
"]]></sub><sub2/></root>", // 10 Element
"D01L02E03T05E07T07E10");
tester.TestFileLines(
"LineNumbers-File",
"resources/utf8test.xml",
"D01L01E02E03A03A03T03E04A04A04T04E05A05A05T05E06A06A06T06E07A07A07T07E08A08A08T08E09T09E10T10");
}
// ----------- Performance tracking --------------
{
@@ -1433,14 +1945,14 @@ int main( int argc, const char ** argv )
QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
#endif
FILE* fp = fopen( "resources/dream.xml", "r" );
fseek( fp, 0, SEEK_END );
long size = ftell( fp );
fseek( fp, 0, SEEK_SET );
FILE* perfFP = fopen("resources/dream.xml", "r");
fseek(perfFP, 0, SEEK_END);
long size = ftell(perfFP);
fseek(perfFP, 0, SEEK_SET);
char* mem = new char[size + 1];
fread( mem, size, 1, fp );
fclose( fp );
fread(mem, size, 1, perfFP);
fclose(perfFP);
mem[size] = 0;
#if defined( _MSC_VER )
@@ -1481,6 +1993,11 @@ int main( int argc, const char ** argv )
_CrtMemState diffMemState;
_CrtMemDifference( &diffMemState, &startMemState, &endMemState );
_CrtMemDumpStatistics( &diffMemState );
{
int leaksBeforeExit = _CrtDumpMemoryLeaks();
XMLTest( "No leaks before exit?", FALSE, leaksBeforeExit );
}
#endif
printf ("\nPass %d, Fail %d\n", gPass, gFail);