Compare commits
442 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81b2194462 | ||
|
|
9201bb96d3 | ||
|
|
3f63f21cf5 | ||
|
|
9e2d29b373 | ||
|
|
82bb074b49 | ||
|
|
224ef775c6 | ||
|
|
8a763619ac | ||
|
|
bc527554e8 | ||
|
|
5cfb946953 | ||
|
|
275067a91f | ||
|
|
ed78570c66 | ||
|
|
c2f677b05e | ||
|
|
1346a174ae | ||
|
|
1bbc66b193 | ||
|
|
e84f68a68a | ||
|
|
b754ddf0fb | ||
|
|
7ce75bc2bb | ||
|
|
816d3fa0cd | ||
|
|
53858b4490 | ||
|
|
ced18c05b9 | ||
|
|
a30f8bd136 | ||
|
|
b29f556ab0 | ||
|
|
7085f00e40 | ||
|
|
f66441e3e7 | ||
|
|
33a1f8bd6c | ||
|
|
7538286750 | ||
|
|
243ddf5304 | ||
|
|
105f32f64d | ||
|
|
174a5df3a3 | ||
|
|
9333cfd394 | ||
|
|
7b40ce1942 | ||
|
|
b840b7e673 | ||
|
|
10b8ecc99b | ||
|
|
2b0453f43e | ||
|
|
e503563f47 | ||
|
|
fc05f63575 | ||
|
|
ba68a3aea6 | ||
|
|
395ea09f83 | ||
|
|
71e2c08a7e | ||
|
|
7221b49fea | ||
|
|
ae8a82a734 | ||
|
|
92c0ef327f | ||
|
|
2aebfb7123 | ||
|
|
1e0b4e6b8a | ||
|
|
7f2ce0dc0e | ||
|
|
6bf64fb149 | ||
|
|
47c7d70064 | ||
|
|
b37cb42b78 | ||
|
|
0f42e24c47 | ||
|
|
969b8c2234 | ||
|
|
5277134efa | ||
|
|
4a07484e47 | ||
|
|
962732fd3e | ||
|
|
d120d64b86 | ||
|
|
1f5ab7cd0b | ||
|
|
f89bd3ef68 | ||
|
|
c5c99c2ba0 | ||
|
|
f458d265c1 | ||
|
|
ce667c9233 | ||
|
|
5b733ff481 | ||
|
|
c3a19156ff | ||
|
|
e90e901041 | ||
|
|
002713856b | ||
|
|
855a66c0ff | ||
|
|
ef7fe0fd98 | ||
|
|
34a3f8e34d | ||
|
|
19d8ea836f | ||
|
|
e353181a46 | ||
|
|
e3d44159e3 | ||
|
|
4f756161d0 | ||
|
|
2489afcc61 | ||
|
|
a43ff7210e | ||
|
|
ec6941503c | ||
|
|
156bc1b99f | ||
|
|
5bbb6fb052 | ||
|
|
5a70071241 | ||
|
|
0d2cef0cba | ||
|
|
a60caa28cc | ||
|
|
f80d78d938 | ||
|
|
ebb1660c2f | ||
|
|
7de0b6dd8c | ||
|
|
d04f21cab8 | ||
|
|
446c3bcae3 | ||
|
|
cd47f8e0d3 | ||
|
|
4336431272 | ||
|
|
13cbc9a708 | ||
|
|
c9a6102bf1 | ||
|
|
6bbcda0215 | ||
|
|
15ad07170d | ||
|
|
ed2627e5a7 | ||
|
|
c5f1e7ce6e | ||
|
|
3c21d6fbb7 | ||
|
|
f6106bec9a | ||
|
|
ecb9b07476 | ||
|
|
edb3261c51 | ||
|
|
01f6cca9e1 | ||
|
|
513e69ba68 | ||
|
|
cf3dd09b08 | ||
|
|
e8157ff9ae | ||
|
|
b2f4dc2a7b | ||
|
|
0d3de1edbe | ||
|
|
318252a973 | ||
|
|
3c97724d0e | ||
|
|
21f996960d | ||
|
|
f00c179eba | ||
|
|
7fcf31b2c3 | ||
|
|
6f1ad6153e | ||
|
|
aad61870a9 | ||
|
|
3b9cf99916 | ||
|
|
e9b547a9ee | ||
|
|
3a621f5b6e | ||
|
|
fed511276f | ||
|
|
584af57086 | ||
|
|
2e14517c89 | ||
|
|
24694e9519 | ||
|
|
0d667f8fef | ||
|
|
3161a33c86 | ||
|
|
2449582eaf | ||
|
|
6fc38ec7cc | ||
|
|
f9f3c3e85c | ||
|
|
4fe8c102da | ||
|
|
a369d4b614 | ||
|
|
1f212f3ab0 | ||
|
|
de45d04711 | ||
|
|
9cb4eca596 | ||
|
|
0bb5901961 | ||
|
|
9faf14df53 | ||
|
|
cb6461ca9c | ||
|
|
c7805c541c | ||
|
|
caa72a641e | ||
|
|
4de7abb573 | ||
|
|
8170bdc693 | ||
|
|
a8e7ea7fb0 | ||
|
|
88145b8ae6 | ||
|
|
75c8f40640 | ||
|
|
1043f6feed | ||
|
|
db02b21bc5 | ||
|
|
e1a82c1a50 | ||
|
|
74d44acb17 | ||
|
|
c9445466de | ||
|
|
5bf60e9dc6 | ||
|
|
6ba2a077ed | ||
|
|
af9bce1762 | ||
|
|
536a4cde37 | ||
|
|
098bd1f17a | ||
|
|
53b0727037 | ||
|
|
0f45b2422f | ||
|
|
d7e5f47524 | ||
|
|
2818e67f31 | ||
|
|
2fe47ead77 | ||
|
|
04639a59a5 | ||
|
|
1889c3e679 | ||
|
|
51c1271797 | ||
|
|
a572db13cf | ||
|
|
8553625730 | ||
|
|
df4ffc00d6 | ||
|
|
41599e2583 | ||
|
|
ceb646812a | ||
|
|
d3f5c318ae | ||
|
|
48daa2dd81 | ||
|
|
31d6c877bd | ||
|
|
1f16f9ddf5 | ||
|
|
47f9931130 | ||
|
|
bb4d246f7b | ||
|
|
97837e77f4 | ||
|
|
3d60e25c4a | ||
|
|
0aeac18ad3 | ||
|
|
67abee5610 | ||
|
|
fe5dbdb817 | ||
|
|
d175e9de0b | ||
|
|
ff714133bc | ||
|
|
6bf8a07587 | ||
|
|
c8dad95d44 | ||
|
|
96b110d25e | ||
|
|
9ff6654174 | ||
|
|
81abfd6d4c | ||
|
|
9c8582c7c3 | ||
|
|
0515fa9d27 | ||
|
|
f47b20f114 | ||
|
|
dffea5747b | ||
|
|
fe5b7a5cac | ||
|
|
9e9c85b3ae | ||
|
|
7bc9201322 | ||
|
|
598a88d9fd | ||
|
|
e4c0738318 | ||
|
|
f2c6b118da | ||
|
|
a58de11b42 | ||
|
|
87a8e71c20 | ||
|
|
e4f8ba89d0 | ||
|
|
a589da416c | ||
|
|
60af433d31 | ||
|
|
901fed5f19 | ||
|
|
2aee5e1b37 | ||
|
|
27eb078329 | ||
|
|
d7f2cce11f | ||
|
|
8ac308d433 | ||
|
|
871d72f3a8 | ||
|
|
b5d51e8f90 | ||
|
|
f6002e6a99 | ||
|
|
cac75789ba | ||
|
|
2beb560a3e | ||
|
|
96f38cca95 | ||
|
|
bb8fd3c29c | ||
|
|
7ae888a601 | ||
|
|
d101a9b1a6 | ||
|
|
14d5490618 | ||
|
|
358202c77a | ||
|
|
1d32e586d5 | ||
|
|
78fca3db83 | ||
|
|
fd6ad7e3a7 | ||
|
|
886ad9787c | ||
|
|
e7fa0e159e | ||
|
|
eb89ef6f0d | ||
|
|
66487eb8f9 | ||
|
|
400e5b2d60 | ||
|
|
8dd493b268 | ||
|
|
4824e95bc0 | ||
|
|
70fd52a574 | ||
|
|
1ca593c4ca | ||
|
|
aebaeea687 | ||
|
|
73f08a3185 | ||
|
|
aa8566b137 | ||
|
|
7865aad09b | ||
|
|
2f5a103992 | ||
|
|
53db4a6cf4 | ||
|
|
1527cf4b2f | ||
|
|
2b2649e1e4 | ||
|
|
687bf8211f | ||
|
|
39c399a0f2 | ||
|
|
91f2dcfb5c | ||
|
|
32de9f02f5 | ||
|
|
a1beddf486 | ||
|
|
962083b9d1 | ||
|
|
735ce51124 | ||
|
|
ca86a0fa2a | ||
|
|
c879a4d48c | ||
|
|
949ae37e0a | ||
|
|
03d0f4ea25 | ||
|
|
8549202800 | ||
|
|
c52aa55a86 | ||
|
|
7a93b33160 | ||
|
|
2ecc203835 | ||
|
|
5420e547d3 | ||
|
|
764545e02a | ||
|
|
3df007ef9d | ||
|
|
96b4346660 | ||
|
|
d608c561e0 | ||
|
|
ff53d7172c | ||
|
|
1bf04fd755 | ||
|
|
9afd1d0ceb | ||
|
|
9c3122b89b | ||
|
|
13b2d73427 | ||
|
|
a7edb883f0 | ||
|
|
39a77dd825 | ||
|
|
8e85afa406 | ||
|
|
2f0d173f94 | ||
|
|
a0f499dda1 | ||
|
|
2bb6bb5bee | ||
|
|
67c429e4b4 | ||
|
|
e5e5541af6 | ||
|
|
72801b8b20 | ||
|
|
89df56c046 | ||
|
|
2a8b1f5789 | ||
|
|
882e89e601 | ||
|
|
a295da4302 | ||
|
|
69d521d354 | ||
|
|
2ad4320339 | ||
|
|
4f0c2ffcab | ||
|
|
70f2c740c0 | ||
|
|
ccd267a782 | ||
|
|
9f24acd369 | ||
|
|
e3932d6b7f | ||
|
|
5ea4f3cb77 | ||
|
|
2d39158eaa | ||
|
|
5daa54cf2b | ||
|
|
e76b8519d1 | ||
|
|
9614f8ff74 | ||
|
|
4a0392dd9d | ||
|
|
0aa957a352 | ||
|
|
400f1199ea | ||
|
|
32533ca9c2 | ||
|
|
a1a4a13825 | ||
|
|
4034395d1a | ||
|
|
2a2ed16ce1 | ||
|
|
1881344cb6 | ||
|
|
48b5df0b9b | ||
|
|
040092215d | ||
|
|
2667aab551 | ||
|
|
9b0f17753d | ||
|
|
51b33321be | ||
|
|
8c067ab730 | ||
|
|
fb33e99a77 | ||
|
|
6a79c17c87 | ||
|
|
8d4e0ec528 | ||
|
|
c505e136da | ||
|
|
d95172ba47 | ||
|
|
28c7c8c14f | ||
|
|
55c7879352 | ||
|
|
f657783cf2 | ||
|
|
d9852a53af | ||
|
|
ea21390f28 | ||
|
|
3ccb1cec29 | ||
|
|
189198f19c | ||
|
|
148cc1a0a5 | ||
|
|
7e744771ad | ||
|
|
32cca51ac5 | ||
|
|
01969dcde2 | ||
|
|
1977a7258c | ||
|
|
2b1e18185c | ||
|
|
5ea1cf33f3 | ||
|
|
4633c3aa27 | ||
|
|
2f465c412a | ||
|
|
3dc797b2a4 | ||
|
|
b53aaa885d | ||
|
|
245bee08d6 | ||
|
|
80647bde2e | ||
|
|
7265b763fc | ||
|
|
ed9aa5a48e | ||
|
|
33bb764d12 | ||
|
|
bab9b6d59c | ||
|
|
6f51c803a1 | ||
|
|
0f922e7c9a | ||
|
|
9fcb876d3b | ||
|
|
f12ece06fa | ||
|
|
023846628d | ||
|
|
1354ffabb6 | ||
|
|
aaa4ceab5e | ||
|
|
03824c305d | ||
|
|
6acc9a5469 | ||
|
|
b733c26bfe | ||
|
|
2875d842de | ||
|
|
e94bde04d2 | ||
|
|
ed7a7dc985 | ||
|
|
30bdc9735b | ||
|
|
9a5a48dbd2 | ||
|
|
38b49ae042 | ||
|
|
d95716bd79 | ||
|
|
22f34982dc | ||
|
|
74fb870c36 | ||
|
|
7e67bc89de | ||
|
|
ba7d9df976 | ||
|
|
bbaf1e1498 | ||
|
|
9f56e12c16 | ||
|
|
778b391286 | ||
|
|
d15686653a | ||
|
|
f802660f7d | ||
|
|
e4fe285427 | ||
|
|
b389252931 | ||
|
|
e53740ec6a | ||
|
|
257e11b25b | ||
|
|
3ae4f3eb3c | ||
|
|
3e0af3793e | ||
|
|
f547a99619 | ||
|
|
e28be7530c | ||
|
|
3cebdc4fac | ||
|
|
75b4e23957 | ||
|
|
6e504e9baf | ||
|
|
59946f6f1a | ||
|
|
625402a01f | ||
|
|
56223ddaea | ||
|
|
deccff765f | ||
|
|
7a7e5dc525 | ||
|
|
5ffa73e979 | ||
|
|
ea617f9380 | ||
|
|
74e394023a | ||
|
|
97476b7b9e | ||
|
|
b4e81b014e | ||
|
|
6d12b7bc3d | ||
|
|
5f06297230 | ||
|
|
9af6ccb3da | ||
|
|
78120c2a1e | ||
|
|
ac503ea88a | ||
|
|
20806ce4e4 | ||
|
|
e4bf6e360d | ||
|
|
4bcbf142a8 | ||
|
|
588bb8de49 | ||
|
|
ee525dba4d | ||
|
|
bb836dce57 | ||
|
|
69242c4b9b | ||
|
|
ffee345723 | ||
|
|
a092bc1f5a | ||
|
|
5b4a5169e3 | ||
|
|
eaddfd8768 | ||
|
|
4e5900c5e8 | ||
|
|
0b4bdd2a47 | ||
|
|
9fae869124 | ||
|
|
8b67d741d4 | ||
|
|
ebb0c8f904 | ||
|
|
7334f9efab | ||
|
|
cd011bc1b7 | ||
|
|
dbfdd8fdd5 | ||
|
|
ee2c46928e | ||
|
|
ed2a407a88 | ||
|
|
b38d29a8c5 | ||
|
|
e6a95ce50e | ||
|
|
f0e8fac4ee | ||
|
|
489e5f30a2 | ||
|
|
abb2d046d0 | ||
|
|
9bcd9c7674 | ||
|
|
e6328b81f7 | ||
|
|
a317bd66a6 | ||
|
|
5c5307013a | ||
|
|
1227d51ed0 | ||
|
|
7254cf7e57 | ||
|
|
ab37df8d67 | ||
|
|
2114e47453 | ||
|
|
18f5d7f133 | ||
|
|
2965880447 | ||
|
|
8a0006ceda | ||
|
|
f59e2d6a89 | ||
|
|
f5d1d9ead2 | ||
|
|
b2ec17dd5f | ||
|
|
a94fc98396 | ||
|
|
c82446c81e | ||
|
|
03494b189c | ||
|
|
575f190412 | ||
|
|
327d5c142e | ||
|
|
92e521b431 | ||
|
|
0b2c22bd46 | ||
|
|
c8ec6fcab4 | ||
|
|
08b40dd8a5 | ||
|
|
1cd7e7422c | ||
|
|
66d2a84715 | ||
|
|
97cfa03865 | ||
|
|
fa20b227a3 | ||
|
|
0826e9632f | ||
|
|
78eee7299f | ||
|
|
4de01a9489 | ||
|
|
f07b952296 | ||
|
|
99916599da | ||
|
|
d211bb1351 | ||
|
|
d048f1e8e3 | ||
|
|
0895e78549 | ||
|
|
097339a099 | ||
|
|
f2496f5824 | ||
|
|
853de8169b | ||
|
|
869f1487e2 | ||
|
|
6d202ff20e | ||
|
|
72bb0ecc39 | ||
|
|
9de541f465 | ||
|
|
b0776aeead | ||
|
|
9fb2b0f42c |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -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
15
.travis.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
language: cpp
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
compiler:
|
||||
- g++
|
||||
- clang
|
||||
|
||||
before_script: cmake .
|
||||
|
||||
script:
|
||||
- make -j3
|
||||
- ./xmltest
|
||||
179
CMakeLists.txt
179
CMakeLists.txt
@@ -1,5 +1,15 @@
|
||||
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)
|
||||
@@ -10,69 +20,124 @@ include(GNUInstallDirs)
|
||||
################################
|
||||
# set lib version here
|
||||
|
||||
set(GENERIC_LIB_VERSION "2.2.0")
|
||||
set(GENERIC_LIB_SOVERSION "2")
|
||||
|
||||
|
||||
################################
|
||||
# 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.0")
|
||||
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
|
||||
set(BUILD_STATIC_LIBS ON CACHE BOOL "Set to ON to build static libraries")
|
||||
if(BUILD_STATIC_LIBS)
|
||||
add_library(tinyxml2static STATIC tinyxml2.cpp tinyxml2.h)
|
||||
set_target_properties(tinyxml2static PROPERTIES OUTPUT_NAME tinyxml2)
|
||||
endif(BUILD_STATIC_LIBS)
|
||||
# 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" 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(test xmltest.cpp)
|
||||
add_dependencies(test tinyxml2)
|
||||
add_dependencies(test ${TARGET_DATA_COPY})
|
||||
target_link_libraries(test 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)
|
||||
install(TARGETS tinyxml2 tinyxml2static
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
else(BUILD_STATIC_LIBS)
|
||||
install(TARGETS tinyxml2
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(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 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 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_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"
|
||||
)
|
||||
endif()
|
||||
|
||||
install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
foreach(p LIB INCLUDE)
|
||||
@@ -85,4 +150,22 @@ endforeach()
|
||||
configure_file(tinyxml2.pc.in tinyxml2.pc @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
|
||||
#add_test(test ${SAMPLE_NAME} COMMAND $<TARGET_FILE:${SAMPLE_NAME}>)
|
||||
# uninstall target
|
||||
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)
|
||||
|
||||
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})
|
||||
21
Makefile
21
Makefile
@@ -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
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 326 KiB After Width: | Height: | Size: 210 KiB |
7
appveyor.yml
Normal file
7
appveyor.yml
Normal 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
7
biicode.conf
Normal file
@@ -0,0 +1,7 @@
|
||||
# Biicode configuration file
|
||||
|
||||
[paths]
|
||||
/
|
||||
|
||||
[dependencies]
|
||||
xmltest.cpp + resources/*.xml
|
||||
21
cmake_uninstall.cmake.in
Normal file
21
cmake_uninstall.cmake.in
Normal 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)
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
protected:
|
||||
virtual void CloseElement () {
|
||||
if (_elementJustOpened && !isVoidElement (_stack.PeekTop())) {
|
||||
SealElement();
|
||||
SealElementIfJustOpened();
|
||||
}
|
||||
XMLPrinter::CloseElement();
|
||||
}
|
||||
|
||||
2
dox
2
dox
@@ -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 = 2.2.0
|
||||
PROJECT_NUMBER = 5.0.0
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
||||
24
readme.md
24
readme.md
@@ -1,4 +1,4 @@
|
||||
TinyXML-2
|
||||
TinyXML-2 [](https://travis-ci.org/leethomason/tinyxml2) [](https://ci.appveyor.com/project/leethomason/tinyxml2)
|
||||
=========
|
||||

|
||||
|
||||
@@ -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 " " or " " are both to the non-breaking space characher.
|
||||
The syntax ` ` or ` ` 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.
|
||||
|
||||
|
||||
1259
tinyxml2.cpp
1259
tinyxml2.cpp
File diff suppressed because it is too large
Load Diff
666
tinyxml2.h
666
tinyxml2.h
File diff suppressed because it is too large
Load Diff
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -96,6 +96,9 @@
|
||||
/* Begin PBXProject section */
|
||||
037AE058151CCC5200E0F29F /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0610;
|
||||
};
|
||||
buildConfigurationList = 037AE05B151CCC5200E0F29F /* Build configuration list for PBXProject "tinyxml2" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
@@ -134,6 +137,8 @@
|
||||
buildSettings = {
|
||||
CONFIGURATION_BUILD_DIR = "$(SYMROOT)/Debug";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
"GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = DEBUG;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SYMROOT = build;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -156,6 +161,7 @@
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
INSTALL_PATH = /usr/local/bin;
|
||||
MACOSX_DEPLOYMENT_TARGET = "";
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = xmltest;
|
||||
};
|
||||
@@ -171,6 +177,7 @@
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
INSTALL_PATH = /usr/local/bin;
|
||||
MACOSX_DEPLOYMENT_TARGET = "";
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = tinyxml2;
|
||||
ZERO_LINK = NO;
|
||||
|
||||
668
xmltest.cpp
668
xmltest.cpp
@@ -10,26 +10,28 @@
|
||||
#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;
|
||||
using namespace std;
|
||||
int gPass = 0;
|
||||
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
|
||||
@@ -56,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 )
|
||||
{
|
||||
@@ -279,27 +290,26 @@ int main( int argc, const char ** argv )
|
||||
{
|
||||
#if defined( _MSC_VER ) && defined( DEBUG )
|
||||
_CrtMemCheckpoint( &startMemState );
|
||||
// Enable MS Visual C++ debug heap memory leaks dump on exit
|
||||
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
|
||||
{
|
||||
int leaksOnStart = _CrtDumpMemoryLeaks();
|
||||
XMLTest( "No leaks on start?", FALSE, leaksOnStart );
|
||||
}
|
||||
#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);
|
||||
#endif
|
||||
{
|
||||
TIXMLASSERT( true );
|
||||
}
|
||||
|
||||
if ( argc > 1 ) {
|
||||
XMLDocument* doc = new XMLDocument();
|
||||
clock_t startTime = clock();
|
||||
doc->LoadFile( argv[1] );
|
||||
clock_t loadTime = clock();
|
||||
clock_t loadTime = clock();
|
||||
int errorID = doc->ErrorID();
|
||||
delete doc; doc = 0;
|
||||
clock_t deleteTime = clock();
|
||||
clock_t deleteTime = clock();
|
||||
|
||||
printf( "Test file '%s' loaded. ErrorID=%d\n", argv[1], errorID );
|
||||
if ( !errorID ) {
|
||||
@@ -403,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!" ));
|
||||
@@ -412,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] );
|
||||
@@ -421,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 );
|
||||
int value1 = 10;
|
||||
int value2 = doc->FirstChildElement()->LastChildElement()->IntAttribute( "attrib", 10 );
|
||||
int result = doc->FirstChildElement()->LastChildElement()->QueryIntAttribute( "attrib", &value1 );
|
||||
XMLTest( "Programmatic DOM", result, (int)XML_NO_ATTRIBUTE );
|
||||
XMLTest( "Programmatic DOM", value, 10 );
|
||||
XMLTest( "Programmatic DOM", value1, 10 );
|
||||
XMLTest( "Programmatic DOM", value2, 10 );
|
||||
|
||||
doc->Print();
|
||||
|
||||
@@ -436,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 );
|
||||
@@ -500,18 +514,26 @@ int main( int argc, const char ** argv )
|
||||
double dVal;
|
||||
|
||||
result = ele->QueryDoubleAttribute( "attr0", &dVal );
|
||||
XMLTest( "Query attribute: int as double", result, (int)XML_NO_ERROR );
|
||||
XMLTest( "Query attribute: int as double", result, (int)XML_SUCCESS);
|
||||
XMLTest( "Query attribute: int as double", (int)dVal, 1 );
|
||||
XMLTest( "Query attribute: int as double", (int)ele->DoubleAttribute("attr0"), 1);
|
||||
|
||||
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", result, (int)XML_SUCCESS);
|
||||
XMLTest( "Query attribute: double as double", dVal, 2.0 );
|
||||
XMLTest( "Query attribute: double as double", ele->DoubleAttribute("attr1"), 2.0 );
|
||||
|
||||
result = ele->QueryIntAttribute( "attr1", &iVal );
|
||||
XMLTest( "Query attribute: double as int", result, (int)XML_NO_ERROR );
|
||||
XMLTest( "Query attribute: double as int", result, (int)XML_SUCCESS);
|
||||
XMLTest( "Query attribute: double as int", iVal, 2 );
|
||||
|
||||
result = ele->QueryIntAttribute( "attr2", &iVal );
|
||||
XMLTest( "Query attribute: not a number", result, (int)XML_WRONG_ATTRIBUTE_TYPE );
|
||||
XMLTest( "Query attribute: not a number", ele->DoubleAttribute("attr2", 4.0), 4.0 );
|
||||
|
||||
result = ele->QueryIntAttribute( "bar", &iVal );
|
||||
XMLTest( "Query attribute: does not exist", result, (int)XML_NO_ATTRIBUTE );
|
||||
XMLTest( "Query attribute: does not exist", ele->BoolAttribute("bar", true), true );
|
||||
}
|
||||
|
||||
{
|
||||
@@ -542,6 +564,8 @@ int main( int argc, const char ** argv )
|
||||
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") );
|
||||
}
|
||||
|
||||
{
|
||||
@@ -664,7 +688,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() );
|
||||
@@ -673,6 +697,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", doc.ErrorID(), XML_SUCCESS, 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 ---------------
|
||||
{
|
||||
@@ -860,12 +1003,20 @@ int main( int argc, const char ** argv )
|
||||
|
||||
{
|
||||
// Empty documents should return TIXML_XML_ERROR_PARSING_EMPTY, bug 1070717
|
||||
const char* str = " ";
|
||||
const char* str = "";
|
||||
XMLDocument doc;
|
||||
doc.Parse( str );
|
||||
XMLTest( "Empty document error", XML_ERROR_EMPTY_DOCUMENT, doc.ErrorID() );
|
||||
}
|
||||
|
||||
{
|
||||
// Documents with all whitespaces should return TIXML_XML_ERROR_PARSING_EMPTY, bug 1070717
|
||||
const char* str = " ";
|
||||
XMLDocument doc;
|
||||
doc.Parse( str );
|
||||
XMLTest( "All whitespaces document error", XML_ERROR_EMPTY_DOCUMENT, doc.ErrorID() );
|
||||
}
|
||||
|
||||
{
|
||||
// Low entities
|
||||
XMLDocument doc;
|
||||
@@ -980,9 +1131,89 @@ int main( int argc, const char ** argv )
|
||||
}
|
||||
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
@@ -1152,7 +1383,11 @@ int main( int argc, const char ** argv )
|
||||
|
||||
{
|
||||
XMLDocument doc;
|
||||
XMLTest( "Document is initially empty", doc.NoChildren(), true );
|
||||
doc.Clear();
|
||||
XMLTest( "Empty is empty after Clear()", doc.NoChildren(), true );
|
||||
doc.LoadFile( "resources/dream.xml" );
|
||||
XMLTest( "Document has something to Clear()", doc.NoChildren(), false );
|
||||
doc.Clear();
|
||||
XMLTest( "Document Clear()'s", doc.NoChildren(), true );
|
||||
}
|
||||
@@ -1231,7 +1466,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 );
|
||||
|
||||
@@ -1329,6 +1564,14 @@ int main( int argc, const char ** argv )
|
||||
doc.Print();
|
||||
}
|
||||
|
||||
{
|
||||
// Test that it doesn't crash.
|
||||
const char* xml = "<?xml version=\"1.0\"?><root><sample><field0><1</field0><field1>2</field1></sample></root>";
|
||||
XMLDocument doc;
|
||||
doc.Parse(xml);
|
||||
doc.PrintError();
|
||||
}
|
||||
|
||||
#if 1
|
||||
// the question being explored is what kind of print to use:
|
||||
// https://github.com/leethomason/tinyxml2/issues/63
|
||||
@@ -1364,42 +1607,368 @@ int main( int argc, const char ** argv )
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
// Issue #184
|
||||
// If it doesn't assert, it passes. Caused by objects
|
||||
// getting created during parsing which are then
|
||||
// inaccessible in the memory pools.
|
||||
{
|
||||
XMLDocument doc;
|
||||
doc.Parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test>");
|
||||
}
|
||||
{
|
||||
XMLDocument doc;
|
||||
doc.Parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test>");
|
||||
doc.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// If this doesn't assert in DEBUG, all is well.
|
||||
tinyxml2::XMLDocument doc;
|
||||
tinyxml2::XMLElement *pRoot = doc.NewElement("Root");
|
||||
doc.DeleteNode(pRoot);
|
||||
}
|
||||
|
||||
// ----------- Performance tracking --------------
|
||||
{
|
||||
// Should not assert in DEBUG
|
||||
XMLPrinter printer;
|
||||
}
|
||||
|
||||
{
|
||||
// Issue 291. Should not crash
|
||||
const char* xml = "�</a>";
|
||||
XMLDocument doc;
|
||||
doc.Parse( xml );
|
||||
|
||||
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", doc.Error(), false);
|
||||
doc.Parse(xml1);
|
||||
XMLTest("Test that the second declaration is allowed", doc.Error(), false);
|
||||
doc.Parse(xml2);
|
||||
XMLTest("Test that declaration after a child is not allowed", doc.ErrorID(), XML_ERROR_PARSING_DECLARATION);
|
||||
doc.Parse(xml3);
|
||||
XMLTest("Test that declaration after a child is not allowed", doc.ErrorID(), XML_ERROR_PARSING_DECLARATION);
|
||||
doc.Parse(xml4);
|
||||
XMLTest("Test that declaration inside a child is not allowed", doc.ErrorID(), XML_ERROR_PARSING_DECLARATION);
|
||||
}
|
||||
|
||||
{
|
||||
// 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);
|
||||
XMLElement* playlist = doc.FirstChildElement("playlist");
|
||||
|
||||
XMLTest("Crash bug parsing", err, XML_SUCCESS);
|
||||
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", nProperty, 2);
|
||||
}
|
||||
|
||||
// ----------- 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 --------------
|
||||
{
|
||||
#if defined( _MSC_VER )
|
||||
__int64 start, end, freq;
|
||||
QueryPerformanceFrequency( (LARGE_INTEGER*) &freq );
|
||||
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 );
|
||||
char* mem = new char[size + 1];
|
||||
fread(mem, size, 1, perfFP);
|
||||
fclose(perfFP);
|
||||
mem[size] = 0;
|
||||
|
||||
#if defined( _MSC_VER )
|
||||
QueryPerformanceCounter( (LARGE_INTEGER*) &start );
|
||||
QueryPerformanceCounter((LARGE_INTEGER*)&start);
|
||||
#else
|
||||
clock_t cstart = clock();
|
||||
#endif
|
||||
static const int COUNT = 10;
|
||||
for( int i=0; i<COUNT; ++i ) {
|
||||
for (int i = 0; i < COUNT; ++i) {
|
||||
XMLDocument doc;
|
||||
doc.Parse( mem );
|
||||
doc.Parse(mem);
|
||||
}
|
||||
#if defined( _MSC_VER )
|
||||
QueryPerformanceCounter( (LARGE_INTEGER*) &end );
|
||||
QueryPerformanceCounter((LARGE_INTEGER*)&end);
|
||||
#else
|
||||
clock_t cend = clock();
|
||||
#endif
|
||||
|
||||
delete [] mem;
|
||||
delete[] mem;
|
||||
|
||||
static const char* note =
|
||||
#ifdef DEBUG
|
||||
@@ -1409,20 +1978,23 @@ int main( int argc, const char ** argv )
|
||||
#endif
|
||||
|
||||
#if defined( _MSC_VER )
|
||||
printf( "\nParsing %s of dream.xml: %.3f milli-seconds\n", note, 1000.0 * (double)(end-start) / ( (double)freq * (double)COUNT) );
|
||||
printf("\nParsing %s of dream.xml: %.3f milli-seconds\n", note, 1000.0 * (double)(end - start) / ((double)freq * (double)COUNT));
|
||||
#else
|
||||
printf( "\nParsing %s of dream.xml: %.3f milli-seconds\n", note, (double)(cend - cstart)/(double)COUNT );
|
||||
printf("\nParsing %s of dream.xml: %.3f milli-seconds\n", note, (double)(cend - cstart) / (double)COUNT);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined( _MSC_VER ) && defined( DEBUG )
|
||||
_CrtMemCheckpoint( &endMemState );
|
||||
//_CrtMemDumpStatistics( &endMemState );
|
||||
|
||||
_CrtMemState diffMemState;
|
||||
_CrtMemDifference( &diffMemState, &startMemState, &endMemState );
|
||||
_CrtMemDumpStatistics( &diffMemState );
|
||||
//printf( "new total=%d\n", gNewTotal );
|
||||
|
||||
{
|
||||
int leaksBeforeExit = _CrtDumpMemoryLeaks();
|
||||
XMLTest( "No leaks before exit?", FALSE, leaksBeforeExit );
|
||||
}
|
||||
#endif
|
||||
|
||||
printf ("\nPass %d, Fail %d\n", gPass, gFail);
|
||||
|
||||
Reference in New Issue
Block a user