Compare commits
337 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
5321a0e21f | ||
|
|
c755667aa0 | ||
|
|
331596e83c | ||
|
|
cd8550c29c | ||
|
|
9f52ad5289 | ||
|
|
003368429f | ||
|
|
8f5d3f8e80 | ||
|
|
bb5ffac22d | ||
|
|
fb732f97d4 | ||
|
|
3659fe1d33 | ||
|
|
cf6d886903 | ||
|
|
e3225b1c64 | ||
|
|
30152836da | ||
|
|
83a6d8c373 | ||
|
|
d526944e3c | ||
|
|
b6b4e82626 | ||
|
|
59b9aaea43 | ||
|
|
ec19a0e513 | ||
|
|
b6ea923f0f | ||
|
|
63f3de1a3c | ||
|
|
dc50a31758 | ||
|
|
67a5bb0ac1 | ||
|
|
0b26702ac9 | ||
|
|
01578db56b | ||
|
|
2af5679b26 | ||
|
|
5657176b61 | ||
|
|
73c822c201 | ||
|
|
acb9c9c260 | ||
|
|
fca00d0ebc | ||
|
|
08e7f7be59 | ||
|
|
84bd9624c6 | ||
|
|
91d34a0989 | ||
|
|
cf33e37d25 | ||
|
|
d740b64044 | ||
|
|
500fb6aa21 | ||
|
|
ca5d684a2b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,3 +11,4 @@ tinyxml2/tinyxml2-cbp/obj/
|
||||
*.user
|
||||
*.depend
|
||||
*.layout
|
||||
*.o
|
||||
|
||||
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
|
||||
112
CMakeLists.txt
112
CMakeLists.txt
@@ -1,3 +1,10 @@
|
||||
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)
|
||||
|
||||
@@ -10,8 +17,8 @@ include(GNUInstallDirs)
|
||||
################################
|
||||
# set lib version here
|
||||
|
||||
set(GENERIC_LIB_VERSION "2.1.0")
|
||||
set(GENERIC_LIB_SOVERSION "2")
|
||||
set(GENERIC_LIB_VERSION "4.0.0")
|
||||
set(GENERIC_LIB_SOVERSION "4")
|
||||
|
||||
|
||||
################################
|
||||
@@ -23,19 +30,20 @@ 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(DATA_COPY_FILES)
|
||||
if(NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
|
||||
foreach(data dream.xml empty.xml utf8test.xml utf8testverify.xml)
|
||||
set(DATA_COPY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources/${data})
|
||||
set(DATA_COPY_DEST ${CMAKE_CURRENT_BINARY_DIR}/resources/${data})
|
||||
add_custom_command(
|
||||
OUTPUT ${DATA_COPY_DEST}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy ${DATA_COPY_SRC} ${DATA_COPY_DEST}
|
||||
DEPENDS ${DATA_COPY_SRC})
|
||||
list(APPEND DATA_COPY_FILES ${DATA_COPY_DEST})
|
||||
endforeach(data)
|
||||
endif(NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_custom_target(${TARGET_DATA_COPY} DEPENDS ${DATA_COPY_FILES})
|
||||
|
||||
################################
|
||||
# Add definitions
|
||||
@@ -44,35 +52,66 @@ 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 -BUILD_SHARED_LIBS:BOOL:OFF
|
||||
# To build only static libs use cmake . -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON
|
||||
|
||||
option(BUILD_SHARED_LIBS "build as shared library" ON)
|
||||
option(BUILD_STATIC_LIBS "build as static library" OFF)
|
||||
|
||||
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 INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/.")
|
||||
endif()
|
||||
|
||||
|
||||
if(BUILD_STATIC_LIBS)
|
||||
install(TARGETS tinyxml2 tinyxml2static
|
||||
install(TARGETS tinyxml2
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
else(BUILD_STATIC_LIBS)
|
||||
install(TARGETS tinyxml2
|
||||
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 )
|
||||
|
||||
if(DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
|
||||
target_include_directories(tinyxml2_static INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/.")
|
||||
endif()
|
||||
|
||||
install(TARGETS tinyxml2_static
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(BUILD_STATIC_LIBS)
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
add_executable(xmltest xmltest.cpp)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_dependencies(xmltest tinyxml2)
|
||||
add_dependencies(xmltest ${TARGET_DATA_COPY})
|
||||
target_link_libraries(xmltest tinyxml2)
|
||||
else(BUILD_STATIC_LIBS)
|
||||
add_dependencies(xmltest tinyxml2_static)
|
||||
add_dependencies(xmltest ${TARGET_DATA_COPY})
|
||||
target_link_libraries(xmltest tinyxml2_static)
|
||||
endif()
|
||||
install(TARGETS DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
foreach(p LIB INCLUDE)
|
||||
@@ -85,4 +124,13 @@ 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}>)
|
||||
#add_test(xmltest ${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)
|
||||
|
||||
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
|
||||
- copy Release\xmltest.exe .\ && copy Release\tinyxml2.dll .\
|
||||
- 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.1.0
|
||||
PROJECT_NUMBER = 4.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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
TinyXML-2
|
||||
TinyXML-2 [](https://travis-ci.org/leethomason/tinyxml2) [](https://ci.appveyor.com/project/leethomason/tinyxml2)
|
||||
=========
|
||||

|
||||
|
||||
@@ -177,7 +177,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 +264,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.
|
||||
|
||||
|
||||
@@ -116,6 +116,8 @@ print( "Release note:" )
|
||||
print( '1. Build. g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe' )
|
||||
print( '2. Commit. git commit -am"setting the version to ' + versionStr + '"' )
|
||||
print( '3. Tag. git tag ' + versionStr )
|
||||
print( ' OR git tag -a ' + versionStr + ' -m <tag message>' )
|
||||
print( 'Remember to "git push" both code and tag.' )
|
||||
print( ' OR git tag -a ' + versionStr + ' -m [tag message]' )
|
||||
print( 'Remember to "git push" both code and tag. For the tag:' )
|
||||
print( 'git push origin [tagname]')
|
||||
|
||||
|
||||
929
tinyxml2.cpp
929
tinyxml2.cpp
File diff suppressed because it is too large
Load Diff
420
tinyxml2.h
420
tinyxml2.h
@@ -14,7 +14,6 @@ not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
@@ -25,21 +24,23 @@ distribution.
|
||||
#ifndef TINYXML2_INCLUDED
|
||||
#define TINYXML2_INCLUDED
|
||||
|
||||
#if defined(ANDROID_NDK) || defined(__BORLANDC__)
|
||||
#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
|
||||
# include <ctype.h>
|
||||
# include <limits.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <stdarg.h>
|
||||
# if defined(__PS3__)
|
||||
# include <stddef.h>
|
||||
# endif
|
||||
#else
|
||||
# include <cctype>
|
||||
# include <climits>
|
||||
# include <cstdio>
|
||||
# include <cstdlib>
|
||||
# include <cstring>
|
||||
# include <cstdarg>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
TODO: intern strings instead of allocation.
|
||||
@@ -78,7 +79,8 @@ distribution.
|
||||
|
||||
#if defined(DEBUG)
|
||||
# if defined(_MSC_VER)
|
||||
# define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak()
|
||||
# // "(void)0," is for suppressing C4127 warning in "assert(false)", "assert(true)" and the like
|
||||
# define TIXMLASSERT( x ) if ( !((void)0,(x))) { __debugbreak(); }
|
||||
# elif defined (ANDROID_NDK)
|
||||
# include <android/log.h>
|
||||
# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); }
|
||||
@@ -86,41 +88,16 @@ distribution.
|
||||
# include <assert.h>
|
||||
# define TIXMLASSERT assert
|
||||
# endif
|
||||
# else
|
||||
#else
|
||||
# define TIXMLASSERT( x ) {}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
|
||||
// Microsoft visual studio, version 2005 and higher.
|
||||
/*int _snprintf_s(
|
||||
char *buffer,
|
||||
size_t sizeOfBuffer,
|
||||
size_t count,
|
||||
const char *format [,
|
||||
argument] ...
|
||||
);*/
|
||||
inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
|
||||
{
|
||||
va_list va;
|
||||
va_start( va, format );
|
||||
int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va );
|
||||
va_end( va );
|
||||
return result;
|
||||
}
|
||||
#define TIXML_SSCANF sscanf_s
|
||||
#else
|
||||
// GCC version 3 and higher
|
||||
//#warning( "Using sn* functions." )
|
||||
#define TIXML_SNPRINTF snprintf
|
||||
#define TIXML_SSCANF sscanf
|
||||
#endif
|
||||
|
||||
/* Versioning, past 1.0.14:
|
||||
http://semver.org/
|
||||
*/
|
||||
static const int TIXML2_MAJOR_VERSION = 2;
|
||||
static const int TIXML2_MINOR_VERSION = 1;
|
||||
static const int TIXML2_MAJOR_VERSION = 4;
|
||||
static const int TIXML2_MINOR_VERSION = 0;
|
||||
static const int TIXML2_PATCH_VERSION = 0;
|
||||
|
||||
namespace tinyxml2
|
||||
@@ -146,7 +123,7 @@ public:
|
||||
enum {
|
||||
NEEDS_ENTITY_PROCESSING = 0x01,
|
||||
NEEDS_NEWLINE_NORMALIZATION = 0x02,
|
||||
COLLAPSE_WHITESPACE = 0x04,
|
||||
NEEDS_WHITESPACE_COLLAPSING = 0x04,
|
||||
|
||||
TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION,
|
||||
TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION,
|
||||
@@ -182,6 +159,8 @@ public:
|
||||
char* ParseText( char* in, const char* endTag, int strFlags );
|
||||
char* ParseName( char* in );
|
||||
|
||||
void TransferTo( StrPair* other );
|
||||
|
||||
private:
|
||||
void Reset();
|
||||
void CollapseWhitespace();
|
||||
@@ -191,10 +170,12 @@ private:
|
||||
NEEDS_DELETE = 0x200
|
||||
};
|
||||
|
||||
// After parsing, if *_end != 0, it can be set to zero.
|
||||
int _flags;
|
||||
char* _start;
|
||||
char* _end;
|
||||
|
||||
StrPair( const StrPair& other ); // not supported
|
||||
void operator=( StrPair& other ); // not supported, use TransferTo()
|
||||
};
|
||||
|
||||
|
||||
@@ -203,13 +184,13 @@ private:
|
||||
Has a small initial memory pool, so that low or no usage will not
|
||||
cause a call to new/delete
|
||||
*/
|
||||
template <class T, int INIT>
|
||||
template <class T, int INITIAL_SIZE>
|
||||
class DynArray
|
||||
{
|
||||
public:
|
||||
DynArray< T, INIT >() {
|
||||
DynArray() {
|
||||
_mem = _pool;
|
||||
_allocated = INIT;
|
||||
_allocated = INITIAL_SIZE;
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
@@ -224,11 +205,14 @@ public:
|
||||
}
|
||||
|
||||
void Push( T t ) {
|
||||
TIXMLASSERT( _size < INT_MAX );
|
||||
EnsureCapacity( _size+1 );
|
||||
_mem[_size++] = t;
|
||||
}
|
||||
|
||||
T* PushArr( int count ) {
|
||||
TIXMLASSERT( count >= 0 );
|
||||
TIXMLASSERT( _size <= INT_MAX - count );
|
||||
EnsureCapacity( _size+count );
|
||||
T* ret = &_mem[_size];
|
||||
_size += count;
|
||||
@@ -236,6 +220,7 @@ public:
|
||||
}
|
||||
|
||||
T Pop() {
|
||||
TIXMLASSERT( _size > 0 );
|
||||
return _mem[--_size];
|
||||
}
|
||||
|
||||
@@ -264,24 +249,33 @@ public:
|
||||
}
|
||||
|
||||
int Size() const {
|
||||
TIXMLASSERT( _size >= 0 );
|
||||
return _size;
|
||||
}
|
||||
|
||||
int Capacity() const {
|
||||
TIXMLASSERT( _allocated >= INITIAL_SIZE );
|
||||
return _allocated;
|
||||
}
|
||||
|
||||
const T* Mem() const {
|
||||
TIXMLASSERT( _mem );
|
||||
return _mem;
|
||||
}
|
||||
|
||||
T* Mem() {
|
||||
TIXMLASSERT( _mem );
|
||||
return _mem;
|
||||
}
|
||||
|
||||
private:
|
||||
DynArray( const DynArray& ); // not supported
|
||||
void operator=( const DynArray& ); // not supported
|
||||
|
||||
void EnsureCapacity( int cap ) {
|
||||
TIXMLASSERT( cap > 0 );
|
||||
if ( cap > _allocated ) {
|
||||
TIXMLASSERT( cap <= INT_MAX / 2 );
|
||||
int newAllocated = cap * 2;
|
||||
T* newMem = new T[newAllocated];
|
||||
memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
|
||||
@@ -294,7 +288,7 @@ private:
|
||||
}
|
||||
|
||||
T* _mem;
|
||||
T _pool[INIT];
|
||||
T _pool[INITIAL_SIZE];
|
||||
int _allocated; // objects allocated
|
||||
int _size; // number objects in use
|
||||
};
|
||||
@@ -314,6 +308,7 @@ public:
|
||||
virtual void* Alloc() = 0;
|
||||
virtual void Free( void* ) = 0;
|
||||
virtual void SetTracked() = 0;
|
||||
virtual void Clear() = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -326,10 +321,20 @@ class MemPoolT : public MemPool
|
||||
public:
|
||||
MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
|
||||
~MemPoolT() {
|
||||
// Delete the blocks.
|
||||
for( int i=0; i<_blockPtrs.Size(); ++i ) {
|
||||
delete _blockPtrs[i];
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Clear() {
|
||||
// Delete the blocks.
|
||||
while( !_blockPtrs.Empty()) {
|
||||
Block* b = _blockPtrs.Pop();
|
||||
delete b;
|
||||
}
|
||||
_root = 0;
|
||||
_currentAllocs = 0;
|
||||
_nAllocs = 0;
|
||||
_maxAllocs = 0;
|
||||
_nUntracked = 0;
|
||||
}
|
||||
|
||||
virtual int ItemSize() const {
|
||||
@@ -362,12 +367,13 @@ public:
|
||||
_nUntracked++;
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual void Free( void* mem ) {
|
||||
if ( !mem ) {
|
||||
return;
|
||||
}
|
||||
--_currentAllocs;
|
||||
Chunk* chunk = (Chunk*)mem;
|
||||
Chunk* chunk = static_cast<Chunk*>( mem );
|
||||
#ifdef DEBUG
|
||||
memset( chunk, 0xfe, sizeof(Chunk) );
|
||||
#endif
|
||||
@@ -399,6 +405,9 @@ public:
|
||||
enum { COUNT = (4*1024)/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private
|
||||
|
||||
private:
|
||||
MemPoolT( const MemPoolT& ); // not supported
|
||||
void operator=( const MemPoolT& ); // not supported
|
||||
|
||||
union Chunk {
|
||||
Chunk* next;
|
||||
char mem[SIZE];
|
||||
@@ -477,6 +486,32 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// WARNING: must match XMLDocument::_errorNames[]
|
||||
enum XMLError {
|
||||
XML_SUCCESS = 0,
|
||||
XML_NO_ATTRIBUTE,
|
||||
XML_WRONG_ATTRIBUTE_TYPE,
|
||||
XML_ERROR_FILE_NOT_FOUND,
|
||||
XML_ERROR_FILE_COULD_NOT_BE_OPENED,
|
||||
XML_ERROR_FILE_READ_ERROR,
|
||||
XML_ERROR_ELEMENT_MISMATCH,
|
||||
XML_ERROR_PARSING_ELEMENT,
|
||||
XML_ERROR_PARSING_ATTRIBUTE,
|
||||
XML_ERROR_IDENTIFYING_TAG,
|
||||
XML_ERROR_PARSING_TEXT,
|
||||
XML_ERROR_PARSING_CDATA,
|
||||
XML_ERROR_PARSING_COMMENT,
|
||||
XML_ERROR_PARSING_DECLARATION,
|
||||
XML_ERROR_PARSING_UNKNOWN,
|
||||
XML_ERROR_EMPTY_DOCUMENT,
|
||||
XML_ERROR_MISMATCHED_ELEMENT,
|
||||
XML_ERROR_PARSING,
|
||||
XML_CAN_NOT_CONVERT_TEXT,
|
||||
XML_NO_TEXT_NODE,
|
||||
|
||||
XML_ERROR_COUNT
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Utility functionality.
|
||||
@@ -484,28 +519,33 @@ public:
|
||||
class XMLUtil
|
||||
{
|
||||
public:
|
||||
// Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
|
||||
// correct, but simple, and usually works.
|
||||
static const char* SkipWhiteSpace( const char* p ) {
|
||||
while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<const unsigned char*>(p) ) ) {
|
||||
TIXMLASSERT( p );
|
||||
while( IsWhiteSpace(*p) ) {
|
||||
++p;
|
||||
}
|
||||
TIXMLASSERT( p );
|
||||
return p;
|
||||
}
|
||||
static char* SkipWhiteSpace( char* p ) {
|
||||
while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast<unsigned char*>(p) ) ) {
|
||||
++p;
|
||||
}
|
||||
return p;
|
||||
return const_cast<char*>( SkipWhiteSpace( const_cast<const char*>(p) ) );
|
||||
}
|
||||
|
||||
// Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't
|
||||
// correct, but simple, and usually works.
|
||||
static bool IsWhiteSpace( char p ) {
|
||||
return !IsUTF8Continuation(p) && isspace( static_cast<unsigned char>(p) );
|
||||
}
|
||||
|
||||
inline static bool IsNameStartChar( unsigned char ch ) {
|
||||
return ( ( ch < 128 ) ? isalpha( ch ) : 1 )
|
||||
|| ch == ':'
|
||||
|| ch == '_';
|
||||
if ( ch >= 128 ) {
|
||||
// This is a heuristic guess in attempt to not implement Unicode-aware isalpha()
|
||||
return true;
|
||||
}
|
||||
if ( isalpha( ch ) ) {
|
||||
return true;
|
||||
}
|
||||
return ch == ':' || ch == '_';
|
||||
}
|
||||
|
||||
inline static bool IsNameChar( unsigned char ch ) {
|
||||
@@ -516,23 +556,14 @@ public:
|
||||
}
|
||||
|
||||
inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
|
||||
int n = 0;
|
||||
if ( p == q ) {
|
||||
return true;
|
||||
}
|
||||
while( *p && *q && *p == *q && n<nChar ) {
|
||||
++p;
|
||||
++q;
|
||||
++n;
|
||||
}
|
||||
if ( (n == nChar) || ( *p == 0 && *q == 0 ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return strncmp( p, q, nChar ) == 0;
|
||||
}
|
||||
|
||||
inline static int IsUTF8Continuation( const char p ) {
|
||||
return p & 0x80;
|
||||
inline static bool IsUTF8Continuation( char p ) {
|
||||
return ( p & 0x80 ) != 0;
|
||||
}
|
||||
|
||||
static const char* ReadBOM( const char* p, bool* hasBOM );
|
||||
@@ -547,6 +578,7 @@ public:
|
||||
static void ToStr( bool v, char* buffer, int bufferSize );
|
||||
static void ToStr( float v, char* buffer, int bufferSize );
|
||||
static void ToStr( double v, char* buffer, int bufferSize );
|
||||
static void ToStr(int64_t v, char* buffer, int bufferSize);
|
||||
|
||||
// converts strings to primitive types
|
||||
static bool ToInt( const char* str, int* value );
|
||||
@@ -554,6 +586,7 @@ public:
|
||||
static bool ToBool( const char* str, bool* value );
|
||||
static bool ToFloat( const char* str, float* value );
|
||||
static bool ToDouble( const char* str, double* value );
|
||||
static bool ToInt64(const char* str, int64_t* value);
|
||||
};
|
||||
|
||||
|
||||
@@ -590,10 +623,12 @@ public:
|
||||
|
||||
/// Get the XMLDocument that owns this XMLNode.
|
||||
const XMLDocument* GetDocument() const {
|
||||
TIXMLASSERT( _document );
|
||||
return _document;
|
||||
}
|
||||
/// Get the XMLDocument that owns this XMLNode.
|
||||
XMLDocument* GetDocument() {
|
||||
TIXMLASSERT( _document );
|
||||
return _document;
|
||||
}
|
||||
|
||||
@@ -643,7 +678,7 @@ public:
|
||||
|
||||
/** The meaning of 'value' changes for the specific type.
|
||||
@verbatim
|
||||
Document: empty
|
||||
Document: empty (NULL is returned, not an empty string)
|
||||
Element: name of the element
|
||||
Comment: the comment text
|
||||
Unknown: the tag contents
|
||||
@@ -683,10 +718,10 @@ public:
|
||||
/** Get the first child element, or optionally the first child
|
||||
element with the specified name.
|
||||
*/
|
||||
const XMLElement* FirstChildElement( const char* value=0 ) const;
|
||||
const XMLElement* FirstChildElement( const char* name = 0 ) const;
|
||||
|
||||
XMLElement* FirstChildElement( const char* value=0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( value ));
|
||||
XMLElement* FirstChildElement( const char* name = 0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->FirstChildElement( name ));
|
||||
}
|
||||
|
||||
/// Get the last child node, or null if none exists.
|
||||
@@ -695,16 +730,16 @@ public:
|
||||
}
|
||||
|
||||
XMLNode* LastChild() {
|
||||
return const_cast<XMLNode*>(const_cast<const XMLNode*>(this)->LastChild() );
|
||||
return _lastChild;
|
||||
}
|
||||
|
||||
/** Get the last child element or optionally the last child
|
||||
element with the specified name.
|
||||
*/
|
||||
const XMLElement* LastChildElement( const char* value=0 ) const;
|
||||
const XMLElement* LastChildElement( const char* name = 0 ) const;
|
||||
|
||||
XMLElement* LastChildElement( const char* value=0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(value) );
|
||||
XMLElement* LastChildElement( const char* name = 0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->LastChildElement(name) );
|
||||
}
|
||||
|
||||
/// Get the previous (left) sibling node of this node.
|
||||
@@ -717,10 +752,10 @@ public:
|
||||
}
|
||||
|
||||
/// Get the previous (left) sibling element of this node, with an optionally supplied name.
|
||||
const XMLElement* PreviousSiblingElement( const char* value=0 ) const ;
|
||||
const XMLElement* PreviousSiblingElement( const char* name = 0 ) const ;
|
||||
|
||||
XMLElement* PreviousSiblingElement( const char* value=0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( value ) );
|
||||
XMLElement* PreviousSiblingElement( const char* name = 0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->PreviousSiblingElement( name ) );
|
||||
}
|
||||
|
||||
/// Get the next (right) sibling node of this node.
|
||||
@@ -733,10 +768,10 @@ public:
|
||||
}
|
||||
|
||||
/// Get the next (right) sibling element of this node, with an optionally supplied name.
|
||||
const XMLElement* NextSiblingElement( const char* value=0 ) const;
|
||||
const XMLElement* NextSiblingElement( const char* name = 0 ) const;
|
||||
|
||||
XMLElement* NextSiblingElement( const char* value=0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( value ) );
|
||||
XMLElement* NextSiblingElement( const char* name = 0 ) {
|
||||
return const_cast<XMLElement*>(const_cast<const XMLNode*>(this)->NextSiblingElement( name ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -822,14 +857,25 @@ public:
|
||||
*/
|
||||
virtual bool Accept( XMLVisitor* visitor ) const = 0;
|
||||
|
||||
// internal
|
||||
virtual char* ParseDeep( char*, StrPair* );
|
||||
/**
|
||||
Set user data into the XMLNode. TinyXML-2 in
|
||||
no way processes or interprets user data.
|
||||
It is initially 0.
|
||||
*/
|
||||
void SetUserData(void* userData) { _userData = userData; }
|
||||
|
||||
/**
|
||||
Get user data set into the XMLNode. TinyXML-2 in
|
||||
no way processes or interprets user data.
|
||||
It is initially 0.
|
||||
*/
|
||||
void* GetUserData() const { return _userData; }
|
||||
|
||||
protected:
|
||||
XMLNode( XMLDocument* );
|
||||
virtual ~XMLNode();
|
||||
XMLNode( const XMLNode& ); // not supported
|
||||
XMLNode& operator=( const XMLNode& ); // not supported
|
||||
|
||||
virtual char* ParseDeep( char*, StrPair* );
|
||||
|
||||
XMLDocument* _document;
|
||||
XMLNode* _parent;
|
||||
@@ -841,9 +887,16 @@ protected:
|
||||
XMLNode* _prev;
|
||||
XMLNode* _next;
|
||||
|
||||
void* _userData;
|
||||
|
||||
private:
|
||||
MemPool* _memPool;
|
||||
void Unlink( XMLNode* child );
|
||||
static void DeleteNode( XMLNode* node );
|
||||
void InsertChildPreamble( XMLNode* insertThis ) const;
|
||||
|
||||
XMLNode( const XMLNode& ); // not supported
|
||||
XMLNode& operator=( const XMLNode& ); // not supported
|
||||
};
|
||||
|
||||
|
||||
@@ -861,7 +914,6 @@ private:
|
||||
*/
|
||||
class TINYXML2_LIB XMLText : public XMLNode
|
||||
{
|
||||
friend class XMLBase;
|
||||
friend class XMLDocument;
|
||||
public:
|
||||
virtual bool Accept( XMLVisitor* visitor ) const;
|
||||
@@ -882,18 +934,20 @@ public:
|
||||
return _isCData;
|
||||
}
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
virtual XMLNode* ShallowClone( XMLDocument* document ) const;
|
||||
virtual bool ShallowEqual( const XMLNode* compare ) const;
|
||||
|
||||
protected:
|
||||
XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
|
||||
virtual ~XMLText() {}
|
||||
XMLText( const XMLText& ); // not supported
|
||||
XMLText& operator=( const XMLText& ); // not supported
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
|
||||
private:
|
||||
bool _isCData;
|
||||
|
||||
XMLText( const XMLText& ); // not supported
|
||||
XMLText& operator=( const XMLText& ); // not supported
|
||||
};
|
||||
|
||||
|
||||
@@ -911,17 +965,18 @@ public:
|
||||
|
||||
virtual bool Accept( XMLVisitor* visitor ) const;
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
virtual XMLNode* ShallowClone( XMLDocument* document ) const;
|
||||
virtual bool ShallowEqual( const XMLNode* compare ) const;
|
||||
|
||||
protected:
|
||||
XMLComment( XMLDocument* doc );
|
||||
virtual ~XMLComment();
|
||||
XMLComment( const XMLComment& ); // not supported
|
||||
XMLComment& operator=( const XMLComment& ); // not supported
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
|
||||
private:
|
||||
XMLComment( const XMLComment& ); // not supported
|
||||
XMLComment& operator=( const XMLComment& ); // not supported
|
||||
};
|
||||
|
||||
|
||||
@@ -949,13 +1004,16 @@ public:
|
||||
|
||||
virtual bool Accept( XMLVisitor* visitor ) const;
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
virtual XMLNode* ShallowClone( XMLDocument* document ) const;
|
||||
virtual bool ShallowEqual( const XMLNode* compare ) const;
|
||||
|
||||
protected:
|
||||
XMLDeclaration( XMLDocument* doc );
|
||||
virtual ~XMLDeclaration();
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
|
||||
private:
|
||||
XMLDeclaration( const XMLDeclaration& ); // not supported
|
||||
XMLDeclaration& operator=( const XMLDeclaration& ); // not supported
|
||||
};
|
||||
@@ -981,45 +1039,21 @@ public:
|
||||
|
||||
virtual bool Accept( XMLVisitor* visitor ) const;
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
virtual XMLNode* ShallowClone( XMLDocument* document ) const;
|
||||
virtual bool ShallowEqual( const XMLNode* compare ) const;
|
||||
|
||||
protected:
|
||||
XMLUnknown( XMLDocument* doc );
|
||||
virtual ~XMLUnknown();
|
||||
|
||||
char* ParseDeep( char*, StrPair* endTag );
|
||||
|
||||
private:
|
||||
XMLUnknown( const XMLUnknown& ); // not supported
|
||||
XMLUnknown& operator=( const XMLUnknown& ); // not supported
|
||||
};
|
||||
|
||||
|
||||
enum XMLError {
|
||||
XML_NO_ERROR = 0,
|
||||
XML_SUCCESS = 0,
|
||||
|
||||
XML_NO_ATTRIBUTE,
|
||||
XML_WRONG_ATTRIBUTE_TYPE,
|
||||
|
||||
XML_ERROR_FILE_NOT_FOUND,
|
||||
XML_ERROR_FILE_COULD_NOT_BE_OPENED,
|
||||
XML_ERROR_FILE_READ_ERROR,
|
||||
XML_ERROR_ELEMENT_MISMATCH,
|
||||
XML_ERROR_PARSING_ELEMENT,
|
||||
XML_ERROR_PARSING_ATTRIBUTE,
|
||||
XML_ERROR_IDENTIFYING_TAG,
|
||||
XML_ERROR_PARSING_TEXT,
|
||||
XML_ERROR_PARSING_CDATA,
|
||||
XML_ERROR_PARSING_COMMENT,
|
||||
XML_ERROR_PARSING_DECLARATION,
|
||||
XML_ERROR_PARSING_UNKNOWN,
|
||||
XML_ERROR_EMPTY_DOCUMENT,
|
||||
XML_ERROR_MISMATCHED_ELEMENT,
|
||||
XML_ERROR_PARSING,
|
||||
|
||||
XML_CAN_NOT_CONVERT_TEXT,
|
||||
XML_NO_TEXT_NODE
|
||||
};
|
||||
|
||||
|
||||
/** An attribute is a name-value pair. Elements have an arbitrary
|
||||
number of attributes, each with a unique name.
|
||||
@@ -1047,10 +1081,17 @@ public:
|
||||
use QueryIntValue() if you need error checking.
|
||||
*/
|
||||
int IntValue() const {
|
||||
int i=0;
|
||||
QueryIntValue( &i );
|
||||
int i = 0;
|
||||
QueryIntValue(&i);
|
||||
return i;
|
||||
}
|
||||
|
||||
int64_t Int64Value() const {
|
||||
int64_t i = 0;
|
||||
QueryInt64Value(&i);
|
||||
return i;
|
||||
}
|
||||
|
||||
/// Query as an unsigned integer. See IntValue()
|
||||
unsigned UnsignedValue() const {
|
||||
unsigned i=0;
|
||||
@@ -1084,6 +1125,8 @@ public:
|
||||
/// See QueryIntValue
|
||||
XMLError QueryUnsignedValue( unsigned int* value ) const;
|
||||
/// See QueryIntValue
|
||||
XMLError QueryInt64Value(int64_t* value) const;
|
||||
/// See QueryIntValue
|
||||
XMLError QueryBoolValue( bool* value ) const;
|
||||
/// See QueryIntValue
|
||||
XMLError QueryDoubleValue( double* value ) const;
|
||||
@@ -1097,6 +1140,8 @@ public:
|
||||
/// Set the attribute to value.
|
||||
void SetAttribute( unsigned value );
|
||||
/// Set the attribute to value.
|
||||
void SetAttribute(int64_t value);
|
||||
/// Set the attribute to value.
|
||||
void SetAttribute( bool value );
|
||||
/// Set the attribute to value.
|
||||
void SetAttribute( double value );
|
||||
@@ -1128,7 +1173,6 @@ private:
|
||||
*/
|
||||
class TINYXML2_LIB XMLElement : public XMLNode
|
||||
{
|
||||
friend class XMLBase;
|
||||
friend class XMLDocument;
|
||||
public:
|
||||
/// Get the name of an element (which is the Value() of the node.)
|
||||
@@ -1183,12 +1227,21 @@ public:
|
||||
QueryIntAttribute( name, &i );
|
||||
return i;
|
||||
}
|
||||
|
||||
/// See IntAttribute()
|
||||
unsigned UnsignedAttribute( const char* name ) const {
|
||||
unsigned i=0;
|
||||
QueryUnsignedAttribute( name, &i );
|
||||
return i;
|
||||
}
|
||||
|
||||
/// See IntAttribute()
|
||||
int64_t Int64Attribute(const char* name) const {
|
||||
int64_t i = 0;
|
||||
QueryInt64Attribute(name, &i);
|
||||
return i;
|
||||
}
|
||||
|
||||
/// See IntAttribute()
|
||||
bool BoolAttribute( const char* name ) const {
|
||||
bool b=false;
|
||||
@@ -1228,6 +1281,7 @@ public:
|
||||
}
|
||||
return a->QueryIntValue( value );
|
||||
}
|
||||
|
||||
/// See QueryIntAttribute()
|
||||
XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const {
|
||||
const XMLAttribute* a = FindAttribute( name );
|
||||
@@ -1236,6 +1290,16 @@ public:
|
||||
}
|
||||
return a->QueryUnsignedValue( value );
|
||||
}
|
||||
|
||||
/// See QueryIntAttribute()
|
||||
XMLError QueryInt64Attribute(const char* name, int64_t* value) const {
|
||||
const XMLAttribute* a = FindAttribute(name);
|
||||
if (!a) {
|
||||
return XML_NO_ATTRIBUTE;
|
||||
}
|
||||
return a->QueryInt64Value(value);
|
||||
}
|
||||
|
||||
/// See QueryIntAttribute()
|
||||
XMLError QueryBoolAttribute( const char* name, bool* value ) const {
|
||||
const XMLAttribute* a = FindAttribute( name );
|
||||
@@ -1287,6 +1351,10 @@ public:
|
||||
return QueryUnsignedAttribute( name, value );
|
||||
}
|
||||
|
||||
int QueryAttribute(const char* name, int64_t* value) const {
|
||||
return QueryInt64Attribute(name, value);
|
||||
}
|
||||
|
||||
int QueryAttribute( const char* name, bool* value ) const {
|
||||
return QueryBoolAttribute( name, value );
|
||||
}
|
||||
@@ -1314,6 +1382,13 @@ public:
|
||||
XMLAttribute* a = FindOrCreateAttribute( name );
|
||||
a->SetAttribute( value );
|
||||
}
|
||||
|
||||
/// Sets the named attribute to value.
|
||||
void SetAttribute(const char* name, int64_t value) {
|
||||
XMLAttribute* a = FindOrCreateAttribute(name);
|
||||
a->SetAttribute(value);
|
||||
}
|
||||
|
||||
/// Sets the named attribute to value.
|
||||
void SetAttribute( const char* name, bool value ) {
|
||||
XMLAttribute* a = FindOrCreateAttribute( name );
|
||||
@@ -1407,15 +1482,17 @@ public:
|
||||
@endverbatim
|
||||
*/
|
||||
void SetText( const char* inText );
|
||||
/// Convenience method for setting text inside and element. See SetText() for important limitations.
|
||||
/// Convenience method for setting text inside an element. See SetText() for important limitations.
|
||||
void SetText( int value );
|
||||
/// Convenience method for setting text inside and element. See SetText() for important limitations.
|
||||
/// Convenience method for setting text inside an element. See SetText() for important limitations.
|
||||
void SetText( unsigned value );
|
||||
/// Convenience method for setting text inside and element. See SetText() for important limitations.
|
||||
/// Convenience method for setting text inside an element. See SetText() for important limitations.
|
||||
void SetText(int64_t value);
|
||||
/// Convenience method for setting text inside an element. See SetText() for important limitations.
|
||||
void SetText( bool value );
|
||||
/// Convenience method for setting text inside and element. See SetText() for important limitations.
|
||||
/// Convenience method for setting text inside an element. See SetText() for important limitations.
|
||||
void SetText( double value );
|
||||
/// Convenience method for setting text inside and element. See SetText() for important limitations.
|
||||
/// Convenience method for setting text inside an element. See SetText() for important limitations.
|
||||
void SetText( float value );
|
||||
|
||||
/**
|
||||
@@ -1448,6 +1525,8 @@ public:
|
||||
/// See QueryIntText()
|
||||
XMLError QueryUnsignedText( unsigned* uval ) const;
|
||||
/// See QueryIntText()
|
||||
XMLError QueryInt64Text(int64_t* uval) const;
|
||||
/// See QueryIntText()
|
||||
XMLError QueryBoolText( bool* bval ) const;
|
||||
/// See QueryIntText()
|
||||
XMLError QueryDoubleText( double* dval ) const;
|
||||
@@ -1463,20 +1542,25 @@ public:
|
||||
int ClosingType() const {
|
||||
return _closingType;
|
||||
}
|
||||
char* ParseDeep( char* p, StrPair* endTag );
|
||||
virtual XMLNode* ShallowClone( XMLDocument* document ) const;
|
||||
virtual bool ShallowEqual( const XMLNode* compare ) const;
|
||||
|
||||
protected:
|
||||
char* ParseDeep( char* p, StrPair* endTag );
|
||||
|
||||
private:
|
||||
XMLElement( XMLDocument* doc );
|
||||
virtual ~XMLElement();
|
||||
XMLElement( const XMLElement& ); // not supported
|
||||
void operator=( const XMLElement& ); // not supported
|
||||
|
||||
XMLAttribute* FindAttribute( const char* name );
|
||||
XMLAttribute* FindAttribute( const char* name ) {
|
||||
return const_cast<XMLAttribute*>(const_cast<const XMLElement*>(this)->FindAttribute( name ));
|
||||
}
|
||||
XMLAttribute* FindOrCreateAttribute( const char* name );
|
||||
//void LinkAttribute( XMLAttribute* attrib );
|
||||
char* ParseAttributes( char* p );
|
||||
static void DeleteAttribute( XMLAttribute* attribute );
|
||||
|
||||
enum { BUF_SIZE = 200 };
|
||||
int _closingType;
|
||||
@@ -1507,9 +1591,11 @@ public:
|
||||
~XMLDocument();
|
||||
|
||||
virtual XMLDocument* ToDocument() {
|
||||
TIXMLASSERT( this == _document );
|
||||
return this;
|
||||
}
|
||||
virtual const XMLDocument* ToDocument() const {
|
||||
TIXMLASSERT( this == _document );
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1536,6 +1622,10 @@ public:
|
||||
Load an XML file from disk. You are responsible
|
||||
for providing and closing the FILE*.
|
||||
|
||||
NOTE: The file should be opened as binary ("rb")
|
||||
not text in order for TinyXML-2 to correctly
|
||||
do newline normalization.
|
||||
|
||||
Returns XML_NO_ERROR (0) on success, or
|
||||
an errorID.
|
||||
*/
|
||||
@@ -1644,20 +1734,20 @@ public:
|
||||
Delete a node associated with this document.
|
||||
It will be unlinked from the DOM.
|
||||
*/
|
||||
void DeleteNode( XMLNode* node ) {
|
||||
node->_parent->DeleteChild( node );
|
||||
}
|
||||
void DeleteNode( XMLNode* node );
|
||||
|
||||
void SetError( XMLError error, const char* str1, const char* str2 );
|
||||
|
||||
/// Return true if there was an error parsing the document.
|
||||
bool Error() const {
|
||||
return _errorID != XML_NO_ERROR;
|
||||
return _errorID != XML_SUCCESS;
|
||||
}
|
||||
/// Return the errorID.
|
||||
XMLError ErrorID() const {
|
||||
return _errorID;
|
||||
}
|
||||
const char* ErrorName() const;
|
||||
|
||||
/// Return a possibly helpful diagnostic location or string.
|
||||
const char* GetErrorStr1() const {
|
||||
return _errorStr1;
|
||||
@@ -1698,6 +1788,10 @@ private:
|
||||
MemPoolT< sizeof(XMLAttribute) > _attributePool;
|
||||
MemPoolT< sizeof(XMLText) > _textPool;
|
||||
MemPoolT< sizeof(XMLComment) > _commentPool;
|
||||
|
||||
static const char* _errorNames[XML_ERROR_COUNT];
|
||||
|
||||
void Parse();
|
||||
};
|
||||
|
||||
|
||||
@@ -1741,7 +1835,7 @@ private:
|
||||
|
||||
@verbatim
|
||||
XMLHandle docHandle( &document );
|
||||
XMLElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild().NextSibling().ToElement();
|
||||
XMLElement* child2 = docHandle.FirstChildElement( "Document" ).FirstChildElement( "Element" ).FirstChildElement().NextSiblingElement();
|
||||
if ( child2 )
|
||||
{
|
||||
// do something useful
|
||||
@@ -1782,32 +1876,32 @@ public:
|
||||
return XMLHandle( _node ? _node->FirstChild() : 0 );
|
||||
}
|
||||
/// Get the first child element of this handle.
|
||||
XMLHandle FirstChildElement( const char* value=0 ) {
|
||||
return XMLHandle( _node ? _node->FirstChildElement( value ) : 0 );
|
||||
XMLHandle FirstChildElement( const char* name = 0 ) {
|
||||
return XMLHandle( _node ? _node->FirstChildElement( name ) : 0 );
|
||||
}
|
||||
/// Get the last child of this handle.
|
||||
XMLHandle LastChild() {
|
||||
return XMLHandle( _node ? _node->LastChild() : 0 );
|
||||
}
|
||||
/// Get the last child element of this handle.
|
||||
XMLHandle LastChildElement( const char* _value=0 ) {
|
||||
return XMLHandle( _node ? _node->LastChildElement( _value ) : 0 );
|
||||
XMLHandle LastChildElement( const char* name = 0 ) {
|
||||
return XMLHandle( _node ? _node->LastChildElement( name ) : 0 );
|
||||
}
|
||||
/// Get the previous sibling of this handle.
|
||||
XMLHandle PreviousSibling() {
|
||||
return XMLHandle( _node ? _node->PreviousSibling() : 0 );
|
||||
}
|
||||
/// Get the previous sibling element of this handle.
|
||||
XMLHandle PreviousSiblingElement( const char* _value=0 ) {
|
||||
return XMLHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
|
||||
XMLHandle PreviousSiblingElement( const char* name = 0 ) {
|
||||
return XMLHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
|
||||
}
|
||||
/// Get the next sibling of this handle.
|
||||
XMLHandle NextSibling() {
|
||||
return XMLHandle( _node ? _node->NextSibling() : 0 );
|
||||
}
|
||||
/// Get the next sibling element of this handle.
|
||||
XMLHandle NextSiblingElement( const char* _value=0 ) {
|
||||
return XMLHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
|
||||
XMLHandle NextSiblingElement( const char* name = 0 ) {
|
||||
return XMLHandle( _node ? _node->NextSiblingElement( name ) : 0 );
|
||||
}
|
||||
|
||||
/// Safe cast to XMLNode. This can return null.
|
||||
@@ -1816,19 +1910,19 @@ public:
|
||||
}
|
||||
/// Safe cast to XMLElement. This can return null.
|
||||
XMLElement* ToElement() {
|
||||
return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToElement() );
|
||||
}
|
||||
/// Safe cast to XMLText. This can return null.
|
||||
XMLText* ToText() {
|
||||
return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToText() );
|
||||
}
|
||||
/// Safe cast to XMLUnknown. This can return null.
|
||||
XMLUnknown* ToUnknown() {
|
||||
return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
|
||||
}
|
||||
/// Safe cast to XMLDeclaration. This can return null.
|
||||
XMLDeclaration* ToDeclaration() {
|
||||
return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -1861,26 +1955,26 @@ public:
|
||||
const XMLConstHandle FirstChild() const {
|
||||
return XMLConstHandle( _node ? _node->FirstChild() : 0 );
|
||||
}
|
||||
const XMLConstHandle FirstChildElement( const char* value=0 ) const {
|
||||
return XMLConstHandle( _node ? _node->FirstChildElement( value ) : 0 );
|
||||
const XMLConstHandle FirstChildElement( const char* name = 0 ) const {
|
||||
return XMLConstHandle( _node ? _node->FirstChildElement( name ) : 0 );
|
||||
}
|
||||
const XMLConstHandle LastChild() const {
|
||||
return XMLConstHandle( _node ? _node->LastChild() : 0 );
|
||||
}
|
||||
const XMLConstHandle LastChildElement( const char* _value=0 ) const {
|
||||
return XMLConstHandle( _node ? _node->LastChildElement( _value ) : 0 );
|
||||
const XMLConstHandle LastChildElement( const char* name = 0 ) const {
|
||||
return XMLConstHandle( _node ? _node->LastChildElement( name ) : 0 );
|
||||
}
|
||||
const XMLConstHandle PreviousSibling() const {
|
||||
return XMLConstHandle( _node ? _node->PreviousSibling() : 0 );
|
||||
}
|
||||
const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const {
|
||||
return XMLConstHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 );
|
||||
const XMLConstHandle PreviousSiblingElement( const char* name = 0 ) const {
|
||||
return XMLConstHandle( _node ? _node->PreviousSiblingElement( name ) : 0 );
|
||||
}
|
||||
const XMLConstHandle NextSibling() const {
|
||||
return XMLConstHandle( _node ? _node->NextSibling() : 0 );
|
||||
}
|
||||
const XMLConstHandle NextSiblingElement( const char* _value=0 ) const {
|
||||
return XMLConstHandle( _node ? _node->NextSiblingElement( _value ) : 0 );
|
||||
const XMLConstHandle NextSiblingElement( const char* name = 0 ) const {
|
||||
return XMLConstHandle( _node ? _node->NextSiblingElement( name ) : 0 );
|
||||
}
|
||||
|
||||
|
||||
@@ -1888,16 +1982,16 @@ public:
|
||||
return _node;
|
||||
}
|
||||
const XMLElement* ToElement() const {
|
||||
return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToElement() );
|
||||
}
|
||||
const XMLText* ToText() const {
|
||||
return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToText() );
|
||||
}
|
||||
const XMLUnknown* ToUnknown() const {
|
||||
return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToUnknown() );
|
||||
}
|
||||
const XMLDeclaration* ToDeclaration() const {
|
||||
return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 );
|
||||
return ( ( _node == 0 ) ? 0 : _node->ToDeclaration() );
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -1969,6 +2063,7 @@ public:
|
||||
void PushAttribute( const char* name, const char* value );
|
||||
void PushAttribute( const char* name, int value );
|
||||
void PushAttribute( const char* name, unsigned value );
|
||||
void PushAttribute(const char* name, int64_t value);
|
||||
void PushAttribute( const char* name, bool value );
|
||||
void PushAttribute( const char* name, double value );
|
||||
/// If streaming, close the Element.
|
||||
@@ -1980,6 +2075,8 @@ public:
|
||||
void PushText( int value );
|
||||
/// Add a text node from an unsigned.
|
||||
void PushText( unsigned value );
|
||||
/// Add a text node from an unsigned.
|
||||
void PushText(int64_t value);
|
||||
/// Add a text node from a bool.
|
||||
void PushText( bool value );
|
||||
/// Add a text node from a float.
|
||||
@@ -2031,7 +2128,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool CompactMode( const XMLElement& ) { return _compactMode; };
|
||||
virtual bool CompactMode( const XMLElement& ) { return _compactMode; }
|
||||
|
||||
/** Prints out the space before an element. You may override to change
|
||||
the space and tabs used. A PrintSpace() override should call Print().
|
||||
@@ -2039,7 +2136,7 @@ protected:
|
||||
virtual void PrintSpace( int depth );
|
||||
void Print( const char* format, ... );
|
||||
|
||||
void SealElement();
|
||||
void SealElementIfJustOpened();
|
||||
bool _elementJustOpened;
|
||||
DynArray< const char*, 10 > _stack;
|
||||
|
||||
@@ -2061,9 +2158,6 @@ private:
|
||||
bool _restrictedEntityFlag[ENTITY_RANGE];
|
||||
|
||||
DynArray< char, 20 > _buffer;
|
||||
#ifdef _MSC_VER
|
||||
DynArray< char, 20 > _accumulator;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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,29 +134,25 @@
|
||||
<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)$(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)$(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)$(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)$(Configuration)\</IntDir>
|
||||
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|x64'">
|
||||
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
|
||||
|
||||
@@ -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,13 +141,9 @@
|
||||
<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>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Dll|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)temp\$(Platform)-$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Lib|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
@@ -152,13 +157,9 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)temp\$(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>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release-Lib|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
|
||||
@@ -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;
|
||||
|
||||
293
xmltest.cpp
293
xmltest.cpp
@@ -1,5 +1,7 @@
|
||||
#if defined( _MSC_VER )
|
||||
#if !defined( _CRT_SECURE_NO_WARNINGS )
|
||||
#define _CRT_SECURE_NO_WARNINGS // This test file is not intended to be secure.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "tinyxml2.h"
|
||||
@@ -21,13 +23,20 @@
|
||||
#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
|
||||
@@ -277,6 +286,8 @@ 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);
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) || defined(MINGW32) || defined(__MINGW32__)
|
||||
@@ -290,6 +301,10 @@ int main( int argc, const char ** argv )
|
||||
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();
|
||||
@@ -401,6 +416,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!" ));
|
||||
@@ -410,6 +426,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", 2, (int)comment->GetUserData());
|
||||
|
||||
// And now deletion:
|
||||
element->DeleteChild( sub[2] );
|
||||
@@ -498,13 +515,13 @@ 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 );
|
||||
result = ele->QueryDoubleAttribute( "attr1", &dVal );
|
||||
XMLTest( "Query attribute: double as double", result, (int)XML_NO_ERROR );
|
||||
XMLTest( "Query attribute: double as double", result, (int)XML_SUCCESS);
|
||||
XMLTest( "Query attribute: double as double", (int)dVal, 2 );
|
||||
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 );
|
||||
@@ -671,6 +688,107 @@ 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);
|
||||
}
|
||||
{
|
||||
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);
|
||||
}
|
||||
{
|
||||
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);
|
||||
}
|
||||
{
|
||||
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);
|
||||
}
|
||||
{
|
||||
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);
|
||||
}
|
||||
{
|
||||
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);
|
||||
}
|
||||
{
|
||||
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 ---------------
|
||||
{
|
||||
@@ -858,12 +976,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,7 +1106,7 @@ int main( int argc, const char ** argv )
|
||||
{
|
||||
// This shouldn't crash.
|
||||
XMLDocument doc;
|
||||
if(XML_NO_ERROR != doc.LoadFile( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
|
||||
if(XML_SUCCESS != doc.LoadFile( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
|
||||
{
|
||||
doc.PrintError();
|
||||
}
|
||||
@@ -1150,7 +1276,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 );
|
||||
}
|
||||
@@ -1220,6 +1350,8 @@ int main( int argc, const char ** argv )
|
||||
XMLDocument doc;
|
||||
XMLError error = doc.LoadFile( "resources/empty.xml" );
|
||||
XMLTest( "Loading an empty file", XML_ERROR_EMPTY_DOCUMENT, error );
|
||||
XMLTest( "Loading an empty file and ErrorName as string", "XML_ERROR_EMPTY_DOCUMENT", doc.ErrorName() );
|
||||
doc.PrintError();
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1227,7 +1359,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 );
|
||||
|
||||
@@ -1325,6 +1457,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
|
||||
@@ -1360,42 +1500,149 @@ 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);
|
||||
}
|
||||
|
||||
{
|
||||
// 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 parsed only as the FirstChild
|
||||
const char* xml0 = "<?xml version=\"1.0\" ?>"
|
||||
" <!-- xml version=\"1.1\" -->"
|
||||
"<first />";
|
||||
const char* xml1 = "<?xml version=\"1.0\" ?>"
|
||||
" <?xml version=\"1.1\" ?>"
|
||||
"<first />";
|
||||
const char* xml2 = "<first />"
|
||||
"<?xml version=\"1.0\" ?>";
|
||||
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 throws an error", doc.ErrorID(), XML_ERROR_PARSING_DECLARATION);
|
||||
doc.Parse(xml2);
|
||||
XMLTest("Test that declaration after a child throws an error", 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 );
|
||||
doc.ErrorName();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------- 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(fp);
|
||||
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
|
||||
@@ -1405,20 +1652,18 @@ 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 );
|
||||
#endif
|
||||
|
||||
printf ("\nPass %d, Fail %d\n", gPass, gFail);
|
||||
|
||||
Reference in New Issue
Block a user