From fb4c5708b798e74f5acead4966fdb6a0cc12033d Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Wed, 24 Jun 2020 17:38:41 +0200 Subject: [PATCH] Made pugixml an external dependency and fixed the cmake/cpack installation and package creation. As pugixml seems to be well supported nowadays and seems to ship with most distributions it's pretty pointless to keep bundling it with EmulationStation. --- .gitignore | 6 + CMake/Packages/FindPugixml.cmake | 42 + CMake/Packages/FindRapidJSON.cmake | 85 +- CMake/Packages/FindVLC.cmake | 8 +- CMake/Packages/MacroEnsureVersion.cmake | 2 - CMakeLists.txt | 87 +- INSTALL.md | 96 +- LICENSES/EmulationStation | 19 + LICENSES/pugixml | 24 - es-app/CMakeLists.txt | 53 +- es-app/src/CollectionSystemManager.cpp | 2 +- es-app/src/Gamelist.cpp | 2 +- es-app/src/MetaData.cpp | 2 +- es-app/src/SystemData.cpp | 2 +- es-app/src/scrapers/GamesDBJSONScraper.cpp | 2 +- es-app/src/scrapers/ScreenScraper.cpp | 2 +- es-core/src/InputConfig.cpp | 2 +- es-core/src/InputManager.cpp | 4 +- es-core/src/MameNames.cpp | 2 +- es-core/src/Settings.cpp | 2 +- es-core/src/ThemeData.cpp | 2 +- es-core/src/utils/FileSystemUtil.cpp | 30 +- external/CMakeLists.txt | 1 - external/pugixml/.codecov.yml | 2 - external/pugixml/.gitattributes | 1 - external/pugixml/.gitignore | 11 - external/pugixml/.travis.yml | 27 - external/pugixml/CMakeLists.txt | 217 - external/pugixml/LICENSE.md | 24 - external/pugixml/README.md | 72 - external/pugixml/appveyor.yml | 22 - external/pugixml/docs/config.adoc | 7 - external/pugixml/docs/images/dom_tree.png | Bin 24570 -> 0 bytes external/pugixml/docs/images/vs2005_link1.png | Bin 25698 -> 0 bytes external/pugixml/docs/images/vs2005_link2.png | Bin 18063 -> 0 bytes external/pugixml/docs/images/vs2005_pch1.png | Bin 27693 -> 0 bytes external/pugixml/docs/images/vs2005_pch2.png | Bin 14895 -> 0 bytes external/pugixml/docs/images/vs2005_pch3.png | Bin 15931 -> 0 bytes external/pugixml/docs/images/vs2005_pch4.png | Bin 15117 -> 0 bytes external/pugixml/docs/images/vs2010_link1.png | Bin 19609 -> 0 bytes external/pugixml/docs/images/vs2010_link2.png | Bin 17206 -> 0 bytes external/pugixml/docs/manual.adoc | 3087 ---- external/pugixml/docs/manual.html | 5869 ------- external/pugixml/docs/quickstart.adoc | 287 - external/pugixml/docs/quickstart.html | 1102 -- external/pugixml/docs/samples/character.xml | 8 - .../docs/samples/custom_memory_management.cpp | 27 - external/pugixml/docs/samples/include.cpp | 64 - .../docs/samples/load_error_handling.cpp | 33 - external/pugixml/docs/samples/load_file.cpp | 16 - external/pugixml/docs/samples/load_memory.cpp | 66 - .../pugixml/docs/samples/load_options.cpp | 30 - external/pugixml/docs/samples/load_stream.cpp | 97 - external/pugixml/docs/samples/modify_add.cpp | 29 - external/pugixml/docs/samples/modify_base.cpp | 43 - .../pugixml/docs/samples/modify_remove.cpp | 27 - .../docs/samples/save_custom_writer.cpp | 116 - .../pugixml/docs/samples/save_declaration.cpp | 27 - external/pugixml/docs/samples/save_file.cpp | 17 - .../pugixml/docs/samples/save_options.cpp | 48 - external/pugixml/docs/samples/save_stream.cpp | 18 - .../pugixml/docs/samples/save_subtree.cpp | 26 - external/pugixml/docs/samples/text.cpp | 35 - external/pugixml/docs/samples/transitions.xml | 7 - .../pugixml/docs/samples/traverse_base.cpp | 51 - .../pugixml/docs/samples/traverse_iter.cpp | 27 - .../docs/samples/traverse_predicate.cpp | 48 - .../docs/samples/traverse_rangefor.cpp | 32 - .../pugixml/docs/samples/traverse_walker.cpp | 35 - external/pugixml/docs/samples/tree.xml | 12 - .../pugixml/docs/samples/weekly-shift_jis.xml | 78 - .../pugixml/docs/samples/weekly-utf-16.xml | Bin 3186 -> 0 bytes .../pugixml/docs/samples/weekly-utf-8.xml | 78 - external/pugixml/docs/samples/xgconsole.xml | 12 - external/pugixml/docs/samples/xpath_error.cpp | 43 - external/pugixml/docs/samples/xpath_query.cpp | 36 - .../pugixml/docs/samples/xpath_select.cpp | 28 - .../pugixml/docs/samples/xpath_variables.cpp | 38 - external/pugixml/readme.txt | 50 - external/pugixml/scripts/archive.py | 54 - external/pugixml/scripts/cocoapods_push.sh | 4 - .../pugixml/scripts/natvis/pugixml.natvis | 77 - .../scripts/natvis/pugixml_compact.natvis | 506 - .../build/native/pugixml-propertiesui.xml | 17 - .../nuget/build/native/pugixml.targets | 28 - external/pugixml/scripts/nuget/pugixml.nuspec | 21 - external/pugixml/scripts/nuget_build.ps1 | 66 - external/pugixml/scripts/premake4.lua | 92 - .../pugixml/scripts/pugixml-config.cmake.in | 3 - external/pugixml/scripts/pugixml.pc.in | 11 - external/pugixml/scripts/pugixml.podspec | 14 - .../scripts/pugixml.xcodeproj/project.pbxproj | 212 - external/pugixml/scripts/pugixml_airplay.mkf | 13 - .../pugixml/scripts/pugixml_codeblocks.cbp | 44 - .../pugixml/scripts/pugixml_codelite.project | 56 - external/pugixml/scripts/pugixml_dll.rc | 45 - .../pugixml/scripts/pugixml_vs2005.vcproj | 343 - .../scripts/pugixml_vs2005_static.vcproj | 343 - .../pugixml/scripts/pugixml_vs2008.vcproj | 339 - .../scripts/pugixml_vs2008_static.vcproj | 339 - .../pugixml/scripts/pugixml_vs2010.vcxproj | 191 - .../scripts/pugixml_vs2010_static.vcxproj | 191 - .../pugixml/scripts/pugixml_vs2013.vcxproj | 199 - .../scripts/pugixml_vs2013_static.vcxproj | 199 - .../pugixml/scripts/pugixml_vs2015.vcxproj | 172 - .../scripts/pugixml_vs2015_static.vcxproj | 176 - .../pugixml/scripts/pugixml_vs2017.vcxproj | 172 - .../scripts/pugixml_vs2017_static.vcxproj | 176 - .../pugixml/scripts/pugixml_vs2019.vcxproj | 172 - .../scripts/pugixml_vs2019_static.vcxproj | 176 - external/pugixml/src/pugiconfig.hpp | 74 - external/pugixml/src/pugixml.cpp | 12948 ---------------- external/pugixml/src/pugixml.hpp | 1499 -- external/pugixml/tests/allocator.cpp | 175 - external/pugixml/tests/allocator.hpp | 10 - external/pugixml/tests/autotest-appveyor.ps1 | 84 - external/pugixml/tests/data/empty.xml | 0 external/pugixml/tests/data/large.xml | 1 - .../pugixml/tests/data/latintest_latin1.xml | 1 - .../pugixml/tests/data/latintest_utf8.xml | 1 - external/pugixml/tests/data/multiline.xml | 3 - external/pugixml/tests/data/small.xml | 1 - external/pugixml/tests/data/truncation.xml | 19 - .../pugixml/tests/data/utftest_utf16_be.xml | Bin 4176 -> 0 bytes .../tests/data/utftest_utf16_be_bom.xml | Bin 4178 -> 0 bytes .../tests/data/utftest_utf16_be_clean.xml | Bin 3932 -> 0 bytes .../tests/data/utftest_utf16_be_nodecl.xml | Bin 4130 -> 0 bytes .../pugixml/tests/data/utftest_utf16_le.xml | Bin 4176 -> 0 bytes .../tests/data/utftest_utf16_le_bom.xml | Bin 4178 -> 0 bytes .../tests/data/utftest_utf16_le_clean.xml | Bin 3932 -> 0 bytes .../tests/data/utftest_utf16_le_nodecl.xml | Bin 4130 -> 0 bytes .../pugixml/tests/data/utftest_utf32_be.xml | Bin 8348 -> 0 bytes .../tests/data/utftest_utf32_be_bom.xml | Bin 8352 -> 0 bytes .../tests/data/utftest_utf32_be_clean.xml | Bin 7860 -> 0 bytes .../tests/data/utftest_utf32_be_nodecl.xml | Bin 8256 -> 0 bytes .../pugixml/tests/data/utftest_utf32_le.xml | Bin 8348 -> 0 bytes .../tests/data/utftest_utf32_le_bom.xml | Bin 8352 -> 0 bytes .../tests/data/utftest_utf32_le_clean.xml | Bin 7860 -> 0 bytes .../tests/data/utftest_utf32_le_nodecl.xml | Bin 8256 -> 0 bytes external/pugixml/tests/data/utftest_utf8.xml | 87 - .../pugixml/tests/data/utftest_utf8_bom.xml | 87 - .../pugixml/tests/data/utftest_utf8_clean.xml | 84 - .../tests/data/utftest_utf8_nodecl.xml | 86 - external/pugixml/tests/data/тест.xml | 1 - .../pugixml/tests/data_fuzz_parse/basic.xml | 1 - .../pugixml/tests/data_fuzz_parse/doctype.xml | 1 - .../pugixml/tests/data_fuzz_parse/refs.xml | 1 - .../pugixml/tests/data_fuzz_parse/types.xml | 1 - .../pugixml/tests/data_fuzz_parse/utf16.xml | Bin 700 -> 0 bytes .../pugixml/tests/data_fuzz_parse/utf32.xml | Bin 652 -> 0 bytes .../pugixml/tests/data_fuzz_xpath/basic.xpath | 1 - .../tests/data_fuzz_xpath/functions.xpath | 1 - .../pugixml/tests/data_fuzz_xpath/math.xpath | 1 - .../pugixml/tests/data_fuzz_xpath/path.xpath | 1 - .../tests/data_fuzz_xpath/predicate.xpath | 1 - external/pugixml/tests/fuzz_parse.cpp | 14 - external/pugixml/tests/fuzz_parse.dict | 72 - external/pugixml/tests/fuzz_setup.sh | 11 - external/pugixml/tests/fuzz_xpath.cpp | 26 - external/pugixml/tests/fuzz_xpath.dict | 72 - external/pugixml/tests/helpers.hpp | 114 - external/pugixml/tests/main.cpp | 218 - external/pugixml/tests/test.cpp | 220 - external/pugixml/tests/test.hpp | 175 - external/pugixml/tests/test_compact.cpp | 150 - external/pugixml/tests/test_deprecated.cpp | 25 - external/pugixml/tests/test_document.cpp | 1809 --- external/pugixml/tests/test_dom_modify.cpp | 1845 --- external/pugixml/tests/test_dom_text.cpp | 447 - external/pugixml/tests/test_dom_traverse.cpp | 1299 -- external/pugixml/tests/test_header_guard.cpp | 3 - .../pugixml/tests/test_header_iosfwd_1.cpp | 3 - .../pugixml/tests/test_header_iosfwd_2.cpp | 3 - .../pugixml/tests/test_header_iostream_1.cpp | 3 - .../pugixml/tests/test_header_iostream_2.cpp | 3 - external/pugixml/tests/test_header_only_1.cpp | 21 - external/pugixml/tests/test_header_only_2.cpp | 21 - .../pugixml/tests/test_header_string_1.cpp | 3 - .../pugixml/tests/test_header_string_2.cpp | 3 - .../tests/test_header_string_iostream.cpp | 5 - external/pugixml/tests/test_memory.cpp | 303 - external/pugixml/tests/test_parse.cpp | 1357 -- external/pugixml/tests/test_parse_doctype.cpp | 366 - external/pugixml/tests/test_unicode.cpp | 153 - external/pugixml/tests/test_version.cpp | 5 - external/pugixml/tests/test_write.cpp | 733 - external/pugixml/tests/test_xpath.cpp | 807 - external/pugixml/tests/test_xpath_api.cpp | 644 - .../pugixml/tests/test_xpath_functions.cpp | 844 - .../pugixml/tests/test_xpath_operators.cpp | 566 - external/pugixml/tests/test_xpath_parse.cpp | 392 - external/pugixml/tests/test_xpath_paths.cpp | 783 - .../tests/test_xpath_paths_abbrev_w3c.cpp | 219 - .../pugixml/tests/test_xpath_paths_w3c.cpp | 312 - .../pugixml/tests/test_xpath_variables.cpp | 671 - external/pugixml/tests/test_xpath_xalan_1.cpp | 411 - external/pugixml/tests/test_xpath_xalan_2.cpp | 417 - external/pugixml/tests/test_xpath_xalan_3.cpp | 321 - external/pugixml/tests/test_xpath_xalan_4.cpp | 300 - external/pugixml/tests/test_xpath_xalan_5.cpp | 295 - external/pugixml/tests/writer_string.cpp | 79 - external/pugixml/tests/writer_string.hpp | 27 - 202 files changed, 278 insertions(+), 48420 deletions(-) create mode 100644 CMake/Packages/FindPugixml.cmake create mode 100644 LICENSES/EmulationStation delete mode 100644 LICENSES/pugixml delete mode 100644 external/pugixml/.codecov.yml delete mode 100644 external/pugixml/.gitattributes delete mode 100644 external/pugixml/.gitignore delete mode 100644 external/pugixml/.travis.yml delete mode 100644 external/pugixml/CMakeLists.txt delete mode 100644 external/pugixml/LICENSE.md delete mode 100644 external/pugixml/README.md delete mode 100644 external/pugixml/appveyor.yml delete mode 100644 external/pugixml/docs/config.adoc delete mode 100644 external/pugixml/docs/images/dom_tree.png delete mode 100644 external/pugixml/docs/images/vs2005_link1.png delete mode 100644 external/pugixml/docs/images/vs2005_link2.png delete mode 100644 external/pugixml/docs/images/vs2005_pch1.png delete mode 100644 external/pugixml/docs/images/vs2005_pch2.png delete mode 100644 external/pugixml/docs/images/vs2005_pch3.png delete mode 100644 external/pugixml/docs/images/vs2005_pch4.png delete mode 100644 external/pugixml/docs/images/vs2010_link1.png delete mode 100644 external/pugixml/docs/images/vs2010_link2.png delete mode 100644 external/pugixml/docs/manual.adoc delete mode 100644 external/pugixml/docs/manual.html delete mode 100644 external/pugixml/docs/quickstart.adoc delete mode 100644 external/pugixml/docs/quickstart.html delete mode 100644 external/pugixml/docs/samples/character.xml delete mode 100644 external/pugixml/docs/samples/custom_memory_management.cpp delete mode 100644 external/pugixml/docs/samples/include.cpp delete mode 100644 external/pugixml/docs/samples/load_error_handling.cpp delete mode 100644 external/pugixml/docs/samples/load_file.cpp delete mode 100644 external/pugixml/docs/samples/load_memory.cpp delete mode 100644 external/pugixml/docs/samples/load_options.cpp delete mode 100644 external/pugixml/docs/samples/load_stream.cpp delete mode 100644 external/pugixml/docs/samples/modify_add.cpp delete mode 100644 external/pugixml/docs/samples/modify_base.cpp delete mode 100644 external/pugixml/docs/samples/modify_remove.cpp delete mode 100644 external/pugixml/docs/samples/save_custom_writer.cpp delete mode 100644 external/pugixml/docs/samples/save_declaration.cpp delete mode 100644 external/pugixml/docs/samples/save_file.cpp delete mode 100644 external/pugixml/docs/samples/save_options.cpp delete mode 100644 external/pugixml/docs/samples/save_stream.cpp delete mode 100644 external/pugixml/docs/samples/save_subtree.cpp delete mode 100644 external/pugixml/docs/samples/text.cpp delete mode 100644 external/pugixml/docs/samples/transitions.xml delete mode 100644 external/pugixml/docs/samples/traverse_base.cpp delete mode 100644 external/pugixml/docs/samples/traverse_iter.cpp delete mode 100644 external/pugixml/docs/samples/traverse_predicate.cpp delete mode 100644 external/pugixml/docs/samples/traverse_rangefor.cpp delete mode 100644 external/pugixml/docs/samples/traverse_walker.cpp delete mode 100644 external/pugixml/docs/samples/tree.xml delete mode 100644 external/pugixml/docs/samples/weekly-shift_jis.xml delete mode 100644 external/pugixml/docs/samples/weekly-utf-16.xml delete mode 100644 external/pugixml/docs/samples/weekly-utf-8.xml delete mode 100644 external/pugixml/docs/samples/xgconsole.xml delete mode 100644 external/pugixml/docs/samples/xpath_error.cpp delete mode 100644 external/pugixml/docs/samples/xpath_query.cpp delete mode 100644 external/pugixml/docs/samples/xpath_select.cpp delete mode 100644 external/pugixml/docs/samples/xpath_variables.cpp delete mode 100644 external/pugixml/readme.txt delete mode 100644 external/pugixml/scripts/archive.py delete mode 100755 external/pugixml/scripts/cocoapods_push.sh delete mode 100644 external/pugixml/scripts/natvis/pugixml.natvis delete mode 100644 external/pugixml/scripts/natvis/pugixml_compact.natvis delete mode 100644 external/pugixml/scripts/nuget/build/native/pugixml-propertiesui.xml delete mode 100644 external/pugixml/scripts/nuget/build/native/pugixml.targets delete mode 100644 external/pugixml/scripts/nuget/pugixml.nuspec delete mode 100644 external/pugixml/scripts/nuget_build.ps1 delete mode 100644 external/pugixml/scripts/premake4.lua delete mode 100644 external/pugixml/scripts/pugixml-config.cmake.in delete mode 100644 external/pugixml/scripts/pugixml.pc.in delete mode 100644 external/pugixml/scripts/pugixml.podspec delete mode 100644 external/pugixml/scripts/pugixml.xcodeproj/project.pbxproj delete mode 100644 external/pugixml/scripts/pugixml_airplay.mkf delete mode 100644 external/pugixml/scripts/pugixml_codeblocks.cbp delete mode 100644 external/pugixml/scripts/pugixml_codelite.project delete mode 100644 external/pugixml/scripts/pugixml_dll.rc delete mode 100644 external/pugixml/scripts/pugixml_vs2005.vcproj delete mode 100644 external/pugixml/scripts/pugixml_vs2005_static.vcproj delete mode 100644 external/pugixml/scripts/pugixml_vs2008.vcproj delete mode 100644 external/pugixml/scripts/pugixml_vs2008_static.vcproj delete mode 100644 external/pugixml/scripts/pugixml_vs2010.vcxproj delete mode 100644 external/pugixml/scripts/pugixml_vs2010_static.vcxproj delete mode 100644 external/pugixml/scripts/pugixml_vs2013.vcxproj delete mode 100644 external/pugixml/scripts/pugixml_vs2013_static.vcxproj delete mode 100644 external/pugixml/scripts/pugixml_vs2015.vcxproj delete mode 100644 external/pugixml/scripts/pugixml_vs2015_static.vcxproj delete mode 100644 external/pugixml/scripts/pugixml_vs2017.vcxproj delete mode 100644 external/pugixml/scripts/pugixml_vs2017_static.vcxproj delete mode 100644 external/pugixml/scripts/pugixml_vs2019.vcxproj delete mode 100644 external/pugixml/scripts/pugixml_vs2019_static.vcxproj delete mode 100644 external/pugixml/src/pugiconfig.hpp delete mode 100644 external/pugixml/src/pugixml.cpp delete mode 100644 external/pugixml/src/pugixml.hpp delete mode 100644 external/pugixml/tests/allocator.cpp delete mode 100644 external/pugixml/tests/allocator.hpp delete mode 100644 external/pugixml/tests/autotest-appveyor.ps1 delete mode 100644 external/pugixml/tests/data/empty.xml delete mode 100644 external/pugixml/tests/data/large.xml delete mode 100644 external/pugixml/tests/data/latintest_latin1.xml delete mode 100644 external/pugixml/tests/data/latintest_utf8.xml delete mode 100644 external/pugixml/tests/data/multiline.xml delete mode 100644 external/pugixml/tests/data/small.xml delete mode 100644 external/pugixml/tests/data/truncation.xml delete mode 100644 external/pugixml/tests/data/utftest_utf16_be.xml delete mode 100644 external/pugixml/tests/data/utftest_utf16_be_bom.xml delete mode 100644 external/pugixml/tests/data/utftest_utf16_be_clean.xml delete mode 100644 external/pugixml/tests/data/utftest_utf16_be_nodecl.xml delete mode 100644 external/pugixml/tests/data/utftest_utf16_le.xml delete mode 100644 external/pugixml/tests/data/utftest_utf16_le_bom.xml delete mode 100644 external/pugixml/tests/data/utftest_utf16_le_clean.xml delete mode 100644 external/pugixml/tests/data/utftest_utf16_le_nodecl.xml delete mode 100644 external/pugixml/tests/data/utftest_utf32_be.xml delete mode 100644 external/pugixml/tests/data/utftest_utf32_be_bom.xml delete mode 100644 external/pugixml/tests/data/utftest_utf32_be_clean.xml delete mode 100644 external/pugixml/tests/data/utftest_utf32_be_nodecl.xml delete mode 100644 external/pugixml/tests/data/utftest_utf32_le.xml delete mode 100644 external/pugixml/tests/data/utftest_utf32_le_bom.xml delete mode 100644 external/pugixml/tests/data/utftest_utf32_le_clean.xml delete mode 100644 external/pugixml/tests/data/utftest_utf32_le_nodecl.xml delete mode 100644 external/pugixml/tests/data/utftest_utf8.xml delete mode 100644 external/pugixml/tests/data/utftest_utf8_bom.xml delete mode 100644 external/pugixml/tests/data/utftest_utf8_clean.xml delete mode 100644 external/pugixml/tests/data/utftest_utf8_nodecl.xml delete mode 100644 external/pugixml/tests/data/тест.xml delete mode 100644 external/pugixml/tests/data_fuzz_parse/basic.xml delete mode 100644 external/pugixml/tests/data_fuzz_parse/doctype.xml delete mode 100644 external/pugixml/tests/data_fuzz_parse/refs.xml delete mode 100644 external/pugixml/tests/data_fuzz_parse/types.xml delete mode 100644 external/pugixml/tests/data_fuzz_parse/utf16.xml delete mode 100644 external/pugixml/tests/data_fuzz_parse/utf32.xml delete mode 100644 external/pugixml/tests/data_fuzz_xpath/basic.xpath delete mode 100644 external/pugixml/tests/data_fuzz_xpath/functions.xpath delete mode 100644 external/pugixml/tests/data_fuzz_xpath/math.xpath delete mode 100644 external/pugixml/tests/data_fuzz_xpath/path.xpath delete mode 100644 external/pugixml/tests/data_fuzz_xpath/predicate.xpath delete mode 100644 external/pugixml/tests/fuzz_parse.cpp delete mode 100644 external/pugixml/tests/fuzz_parse.dict delete mode 100755 external/pugixml/tests/fuzz_setup.sh delete mode 100644 external/pugixml/tests/fuzz_xpath.cpp delete mode 100644 external/pugixml/tests/fuzz_xpath.dict delete mode 100644 external/pugixml/tests/helpers.hpp delete mode 100644 external/pugixml/tests/main.cpp delete mode 100644 external/pugixml/tests/test.cpp delete mode 100644 external/pugixml/tests/test.hpp delete mode 100644 external/pugixml/tests/test_compact.cpp delete mode 100644 external/pugixml/tests/test_deprecated.cpp delete mode 100644 external/pugixml/tests/test_document.cpp delete mode 100644 external/pugixml/tests/test_dom_modify.cpp delete mode 100644 external/pugixml/tests/test_dom_text.cpp delete mode 100644 external/pugixml/tests/test_dom_traverse.cpp delete mode 100644 external/pugixml/tests/test_header_guard.cpp delete mode 100644 external/pugixml/tests/test_header_iosfwd_1.cpp delete mode 100644 external/pugixml/tests/test_header_iosfwd_2.cpp delete mode 100644 external/pugixml/tests/test_header_iostream_1.cpp delete mode 100644 external/pugixml/tests/test_header_iostream_2.cpp delete mode 100644 external/pugixml/tests/test_header_only_1.cpp delete mode 100644 external/pugixml/tests/test_header_only_2.cpp delete mode 100644 external/pugixml/tests/test_header_string_1.cpp delete mode 100644 external/pugixml/tests/test_header_string_2.cpp delete mode 100644 external/pugixml/tests/test_header_string_iostream.cpp delete mode 100644 external/pugixml/tests/test_memory.cpp delete mode 100644 external/pugixml/tests/test_parse.cpp delete mode 100644 external/pugixml/tests/test_parse_doctype.cpp delete mode 100644 external/pugixml/tests/test_unicode.cpp delete mode 100644 external/pugixml/tests/test_version.cpp delete mode 100644 external/pugixml/tests/test_write.cpp delete mode 100644 external/pugixml/tests/test_xpath.cpp delete mode 100644 external/pugixml/tests/test_xpath_api.cpp delete mode 100644 external/pugixml/tests/test_xpath_functions.cpp delete mode 100644 external/pugixml/tests/test_xpath_operators.cpp delete mode 100644 external/pugixml/tests/test_xpath_parse.cpp delete mode 100644 external/pugixml/tests/test_xpath_paths.cpp delete mode 100644 external/pugixml/tests/test_xpath_paths_abbrev_w3c.cpp delete mode 100644 external/pugixml/tests/test_xpath_paths_w3c.cpp delete mode 100644 external/pugixml/tests/test_xpath_variables.cpp delete mode 100644 external/pugixml/tests/test_xpath_xalan_1.cpp delete mode 100644 external/pugixml/tests/test_xpath_xalan_2.cpp delete mode 100644 external/pugixml/tests/test_xpath_xalan_3.cpp delete mode 100644 external/pugixml/tests/test_xpath_xalan_4.cpp delete mode 100644 external/pugixml/tests/test_xpath_xalan_5.cpp delete mode 100644 external/pugixml/tests/writer_string.cpp delete mode 100644 external/pugixml/tests/writer_string.hpp diff --git a/.gitignore b/.gitignore index 5927985ca..7a8415be9 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,12 @@ CMakeCache.txt CMakeFiles cmake_install.cmake Makefile +install_manifest.txt + +# CPack +_CPack_Packages +emulationstation-de*.deb +emulationstation-de*.rpm # TODO TODO.md diff --git a/CMake/Packages/FindPugixml.cmake b/CMake/Packages/FindPugixml.cmake new file mode 100644 index 000000000..e0dfc9726 --- /dev/null +++ b/CMake/Packages/FindPugixml.cmake @@ -0,0 +1,42 @@ + +# Find the pugixml XML parsing library. +# +# Sets the usual variables expected for find_package scripts: +# +# Looks for both the include files (via pkgconfig) and the shared library. +# +# PUGIXML_INCLUDE_DIR - header location +# PUGIXML_LIBRARIES - library to link against +# PUGIXML_FOUND - true if pugixml was found. + +include(FindPkgMacros) + +if (NOT WIN32) + find_package(PkgConfig) + pkg_check_modules(PUGIXML REQUIRED pugixml>=1.09) +endif (NOT WIN32) + +if (WIN32) +find_path(PUGIXML_INCLUDE_DIR pugixml.hpp) + +# Support the REQUIRED and QUIET arguments, and set PUGIXML_FOUND if found. +include (FindPackageHandleStandardArgs) + +find_package_handle_standard_args(PUGIXML DEFAULT_MSG PUGIXML_INCLUDE_DIR) + +if (NOT PUGIXML_INCLUDE_DIR) + message(FATAL_ERROR "PUGIXML include files not found!") +endif() + +endif (WIN32) + +find_library(PUGIXML_LIBRARY pugixml) + +if (NOT PUGIXML_LIBRARY) + message(FATAL_ERROR "libpugixml library not found!") +endif() + +# Support the REQUIRED and QUIET arguments, and set PUGIXML_FOUND if found. +include (FindPackageHandleStandardArgs) + +find_package_handle_standard_args(pugixml DEFAULT_MSG PUGIXML_LIBRARY) diff --git a/CMake/Packages/FindRapidJSON.cmake b/CMake/Packages/FindRapidJSON.cmake index 731461a34..376566519 100644 --- a/CMake/Packages/FindRapidJSON.cmake +++ b/CMake/Packages/FindRapidJSON.cmake @@ -1,71 +1,28 @@ -#.rst: -# FindRapidjson -# -------- -# -# Find the native rapidjson includes and library. -# -# IMPORTED Targets -# ^^^^^^^^^^^^^^^^ -# -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following variables: -# -# :: -# -# RAPIDJSON_INCLUDE_DIRS - where to find rapidjson/document.h, etc. -# RAPIDJSON_LIBRARIES - List of libraries when using rapidjson. -# RAPIDJSON_FOUND - True if rapidjson found. -# -# :: -# -# -# Hints -# ^^^^^ -# -# A user may set ``RAPIDJSON_ROOT`` to a rapidjson installation root to tell this -# module where to look. -#============================================================================= -# Copyright 2018 OWenT. +# Find the RapidJSON parsing library. # -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. +# Sets the usual variables expected for find_package scripts: # -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) +# RAPIDJSON_INCLUDE_DIR - header location +# RAPIDJSON_FOUND - true if RAPIDJSON was found. -unset(_RAPIDJSON_SEARCH_ROOT_INC) -unset(_RAPIDJSON_SEARCH_ROOT_LIB) +include(FindPkgMacros) -# Search RAPIDJSON_ROOT first if it is set. -if (Rapidjson_ROOT) - set(RAPIDJSON_ROOT ${Rapidjson_ROOT}) +if (NOT WIN32) + find_package(PkgConfig) + pkg_check_modules(RAPIDJSON REQUIRED RapidJSON>=1.0.0) +endif (NOT WIN32) + +if (WIN32) +find_path(RAPIDJSON_INCLUDE_DIR rapidjson/rapidjson.h) + +# Support the REQUIRED and QUIET arguments, and set RAPIDJSON_FOUND if found. +include (FindPackageHandleStandardArgs) + +find_package_handle_standard_args(RAPIDJSON DEFAULT_MSG RAPIDJSON_INCLUDE_DIR) + +if (NOT RAPIDJSON_INCLUDE_DIR) + message(FATAL_ERROR "RapidJSON include files not found!") endif() -if(RAPIDJSON_ROOT) - set(_RAPIDJSON_SEARCH_ROOT_INC PATHS ${RAPIDJSON_ROOT} ${RAPIDJSON_ROOT}/include NO_DEFAULT_PATH) -endif() - -# Try each search configuration. -find_path(RAPIDJSON_INCLUDE_DIRS NAMES rapidjson/document.h ${_RAPIDJSON_SEARCH_ROOT_INC}) - -mark_as_advanced(RAPIDJSON_INCLUDE_DIRS) - -# handle the QUIETLY and REQUIRED arguments and set RAPIDJSON_FOUND to TRUE if -# all listed variables are TRUE -include("FindPackageHandleStandardArgs") -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Rapidjson - REQUIRED_VARS RAPIDJSON_INCLUDE_DIRS - FOUND_VAR Rapidjson_FOUND -) - -if(Rapidjson_FOUND) - set(RAPIDJSON_FOUND ${Rapidjson_FOUND}) -endif() +endif (WIN32) diff --git a/CMake/Packages/FindVLC.cmake b/CMake/Packages/FindVLC.cmake index eec5c5709..ec5d1d16e 100644 --- a/CMake/Packages/FindVLC.cmake +++ b/CMake/Packages/FindVLC.cmake @@ -23,14 +23,16 @@ endif(VLC_INCLUDE_DIR AND VLC_LIBRARIES) # in the FIND_PATH() and FIND_LIBRARY() calls if(NOT WIN32) find_package(PkgConfig) - pkg_check_modules(VLC libvlc>=1.0.0) + pkg_check_modules(VLC REQUIRED libvlc>=3.0.0) set(VLC_DEFINITIONS ${VLC_CFLAGS}) set(VLC_LIBRARIES ${VLC_LDFLAGS}) endif(NOT WIN32) +if (WIN32) + # TODO add argument support to pass version on find_package include(MacroEnsureVersion) -macro_ensure_version(1.0.0 ${VLC_VERSION} VLC_VERSION_OK) +macro_ensure_version(3.0.0 ${VLC_VERSION} VLC_VERSION_OK) if(VLC_VERSION_OK) set(VLC_FOUND TRUE) message(STATUS "VLC library found") @@ -53,3 +55,5 @@ find_package_handle_standard_args(VLC DEFAULT_MSG VLC_INCLUDE_DIR VLC_LIBRARIES) # show the VLC_INCLUDE_DIR and VLC_LIBRARIES variables only in the advanced view mark_as_advanced(VLC_INCLUDE_DIR VLC_LIBRARIES) + +endif (WIN32) diff --git a/CMake/Packages/MacroEnsureVersion.cmake b/CMake/Packages/MacroEnsureVersion.cmake index 6797e5b7d..bb1fac488 100644 --- a/CMake/Packages/MacroEnsureVersion.cmake +++ b/CMake/Packages/MacroEnsureVersion.cmake @@ -113,5 +113,3 @@ MACRO(MACRO_ENSURE_VERSION_RANGE min_version found_version max_version var_ok) MACRO_CHECK_RANGE_INCLUSIVE_LOWER( ${req_vers_num} ${found_vers_num} ${max_vers_num} ${var_ok}) ENDMACRO(MACRO_ENSURE_VERSION_RANGE) - - diff --git a/CMakeLists.txt b/CMakeLists.txt index aa60d995c..3bf8f3770 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,35 +5,35 @@ option(GL "Set to ON if targeting Desktop OpenGL" ${GL}) option(RPI "Set to ON to enable the Raspberry PI video player (omxplayer)" ${RPI}) option(CEC "Set to ON to enable CEC" ${CEC}) -project(emulationstation-all) +project(emulationstation-de) #------------------------------------------------------------------------------- -#add local find scripts to CMAKE path +# Add local find scripts to CMAKE path. LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake/Utils ${CMAKE_CURRENT_SOURCE_DIR}/CMake/Packages ) #------------------------------------------------------------------------------- -#set up OpenGL system variable +# Set up OpenGL system variable. if(GLES) set(GLSystem "Embedded OpenGL" CACHE STRING "The OpenGL system to be used") elseif(GL) set(GLSystem "Desktop OpenGL" CACHE STRING "The OpenGL system to be used") #------------------------------------------------------------------------------- -#check if we're running on Raspberry Pi +# Check if we're running on a Raspberry Pi. elseif(EXISTS "${CMAKE_FIND_ROOT_PATH}/opt/vc/include/bcm_host.h") MESSAGE("bcm_host.h found") set(BCMHOST found) set(GLSystem "Embedded OpenGL" CACHE STRING "The OpenGL system to be used") #------------------------------------------------------------------------------- -#check if we're running on OSMC Vero4K +# Check if we're running on OSMC Vero4K. elseif(EXISTS "${CMAKE_FIND_ROOT_PATH}/opt/vero3/lib/libMali.so") MESSAGE("libMali.so found") set(VERO4K found) set(GLSystem "Embedded OpenGL" CACHE STRING "The OpenGL system to be used") #------------------------------------------------------------------------------- -#check if we're running on olinuxino / odroid / etc +# Check if we're running on olinuxino / odroid / etc. elseif(EXISTS "${CMAKE_FIND_ROOT_PATH}/usr/lib/libMali.so" OR EXISTS "${CMAKE_FIND_ROOT_PATH}/usr/lib/arm-linux-gnueabihf/libMali.so" OR EXISTS "${CMAKE_FIND_ROOT_PATH}/usr/lib/aarch64-linux-gnu/libMali.so" OR @@ -47,32 +47,34 @@ endif(GLES) set_property(CACHE GLSystem PROPERTY STRINGS "Desktop OpenGL" "Embedded OpenGL") -#finding necessary packages +# Package dependencies. #------------------------------------------------------------------------------- if(${GLSystem} MATCHES "Desktop OpenGL") + set(OpenGL_GL_PREFERENCE "GLVND") find_package(OpenGL REQUIRED) else() find_package(OpenGLES REQUIRED) endif() -find_package(Freetype REQUIRED) -find_package(FreeImage REQUIRED) -find_package(SDL2 REQUIRED) find_package(CURL REQUIRED) -find_package(VLC REQUIRED) +find_package(FreeImage REQUIRED) +find_package(Freetype REQUIRED) +find_package(Pugixml REQUIRED) find_package(RapidJSON REQUIRED) +find_package(SDL2 REQUIRED) +find_package(VLC REQUIRED) -#add libCEC support +# Add libCEC support. if(CEC) find_package(libCEC REQUIRED) endif() -#add ALSA for Linux +# Add ALSA for Linux. if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") find_package(ALSA REQUIRED) endif() #------------------------------------------------------------------------------- -#set up compiler flags and excutable names +# Set up compiler flags and excutable names. if(DEFINED BCMHOST OR RPI) add_definitions(-D_RPI_) endif() @@ -92,23 +94,26 @@ if(MSVC) add_definitions(-D_CRT_SECURE_NO_DEPRECATE) add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) add_definitions(-DNOMINMAX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") #multi-processor compilation - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") #multi-processor compilation + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # Multi-processor compilation. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") # Multi-processor compilation. endif() +# Check for a GCC/G++ version higher than 4.8. if(CMAKE_COMPILER_IS_GNUCXX) - #check for G++ 4.7+ execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE G++_VERSION) - if (G++_VERSION VERSION_LESS 4.7) - message(SEND_ERROR "You need at least G++ 4.7 to compile EmulationStation!") + if (G++_VERSION VERSION_LESS 4.8) + message(SEND_ERROR "You need at least GCC 4.8 to compile EmulationStation!") endif() - #set up compiler flags for GCC +# Set up compiler flags for GCC. if (CMAKE_BUILD_TYPE MATCHES Debug) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -O0") #support C++11 for std::, optimize + # Enable the C++11 standard and disable optimizations as it's a debug build. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -O0") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O0") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -O2 -DNDEBUG") #support C++11 for std::, optimize + # Enable the C++11 standard and enable optimizations as it's a release build. + # Also disable the assert() macros. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -O2 -DNDEBUG") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2") #-s = strip binary endif() endif() @@ -119,35 +124,35 @@ else() add_definitions(-DUSE_OPENGLES_10) endif() -#add installation prefix and datarootdir +# Add the installation prefix. add_definitions(-DES_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}") -add_definitions(-DES_DATAROOTDIR="${CMAKE_INSTALL_DATAROOTDIR}") -# Enable additional defines for the Debug build configuration +# Enable additional defines for the Debug build configuration. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") #------------------------------------------------------------------------------- -#add include directories +# Add include directories. set(COMMON_INCLUDE_DIRS - ${FREETYPE_INCLUDE_DIRS} - ${FreeImage_INCLUDE_DIRS} - ${SDL2_INCLUDE_DIR} ${CURL_INCLUDE_DIR} - ${VLC_INCLUDE_DIR} + ${FreeImage_INCLUDE_DIRS} + ${FREETYPE_INCLUDE_DIRS} + ${PUGIXML_INCLUDE_DIRS} ${RAPIDJSON_INCLUDE_DIRS} + ${SDL2_INCLUDE_DIR} + ${VLC_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/es-core/src ) -#add libCEC_INCLUDE_DIR +# Add libCEC_INCLUDE_DIR. if(DEFINED libCEC_FOUND) LIST(APPEND COMMON_INCLUDE_DIRS ${libCEC_INCLUDE_DIR} ) endif() -#add ALSA for Linux +# Add ALSA for Linux. if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") LIST(APPEND COMMON_INCLUDE_DIRS ${ALSA_INCLUDE_DIRS} @@ -179,7 +184,7 @@ else() endif() #------------------------------------------------------------------------------- -#define libraries and directories +# Define libraries and directories. if(DEFINED BCMHOST) link_directories( "${CMAKE_FIND_ROOT_PATH}/opt/vc/lib" @@ -191,16 +196,16 @@ elseif(DEFINED VERO4K) endif() set(COMMON_LIBRARIES - ${FREETYPE_LIBRARIES} - ${FreeImage_LIBRARIES} - ${SDL2_LIBRARY} ${CURL_LIBRARIES} + ${FreeImage_LIBRARIES} + ${FREETYPE_LIBRARIES} + ${PUGIXML_LIBRARIES} + ${SDL2_LIBRARY} ${VLC_LIBRARIES} - pugixml nanosvg ) -#add libCEC_LIBRARIES +# Add libCEC_LIBRARIES. if(DEFINED libCEC_FOUND) if(DEFINED BCMHOST) LIST(APPEND COMMON_LIBRARIES @@ -213,7 +218,7 @@ endif() ) endif() -#add ALSA for Linux +# Add ALSA for Linux. if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") LIST(APPEND COMMON_LIBRARIES ${ALSA_LIBRARY} @@ -250,13 +255,13 @@ else() endif() #------------------------------------------------------------------------------- -# set up build directories +# Set up build directories. set(dir ${CMAKE_CURRENT_SOURCE_DIR}) set(EXECUTABLE_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE) set(LIBRARY_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE) #------------------------------------------------------------------------------- -# add each component +# Add each component. add_subdirectory("external") add_subdirectory("es-core") diff --git a/INSTALL.md b/INSTALL.md index b3b718a26..53edbb462 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -4,44 +4,118 @@ Building EmulationStation-DE uses some C++11 code, which means you'll need to use a compiler that supports that. \ GCC is recommended although other compilers should hopefully work fine as well. -The code has a few dependencies. For building, you'll need CMake and development packages for SDL2, FreeImage, FreeType, libVLC, cURL and RapidJSON. +The code has a few dependencies. For building, you'll need CMake and development packages for cURL, FreeImage, FreeType, libVLC, pugixml, SDL2 and RapidJSON. **On Debian/Ubuntu:** All of the required packages can be easily installed with `apt-get`: ``` -sudo apt-get install libsdl2-dev libfreeimage-dev libfreetype6-dev libcurl4-openssl-dev rapidjson-dev - libasound2-dev libgl1-mesa-dev build-essential cmake fonts-droid-fallback libvlc-dev - libvlccore-dev vlc-bin +sudo apt-get install build-essential cmake libsdl2-dev libfreeimage-dev libfreetype6-dev libcurl4-openssl-dev libpugixml-dev rapidjson-dev libasound2-dev libvlc-dev libgl1-mesa-dev ``` **On Fedora:** For this operating system, use `dnf` (with rpmfusion activated) : ``` -sudo dnf install SDL2-devel freeimage-devel freetype-devel curl-devel - alsa-lib-devel mesa-libGL-devel cmake - vlc-devel rapidjson-devel +sudo dnf install cmake SDL2-devel freeimage-devel freetype-devel curl-devel rapidjson-devel alsa-lib-devel vlc-devel mesa-libGL-devel ``` -To checkout the source, run the following: +To clone the source repository, run the following: ``` git clone https://gitlab.com/leonstyhre/emulationstation-de ``` -Then generate the Makefile and build the software like this: +Then generate the Makefile and build the software: ``` cd emulationstation-de -cmake -DOpenGL_GL_PREFERENCE=GLVND . +cmake . make ``` NOTE: to generate a `Debug` build on Unix/Linux, run this instead: ``` -cmake -DOpenGL_GL_PREFERENCE=GLVND -DCMAKE_BUILD_TYPE=Debug . +cmake -DCMAKE_BUILD_TYPE=Debug . make ``` Keep in mind though that a debug version will be much slower due to all compiler optimizations being disabled. +By default EmulationStation will install under `/usr/local` but this can be changed by setting the `CMAKE_INSTALL_PREFIX` variable.\ +The following example will build the application for installtion under `/opt`: + +``` +cmake -DCMAKE_INSTALL_PREFIX=/opt . +``` + +Note that this is not only the directory used by the install script, the CMAKE_INSTALL_PREFIX variable also modifies code modified inside ES to find the program resources. So it's very important that the install prefix corresponds to the location where the application will actually be located. + +**Installing:** + +Installing the software requires root permissions, the following command will install all the required application files: + +``` +sudo make install +``` + +Assuming the default installation prefix `/usr/local` has been used, this is the directory structure for the installation: + +``` +/usr/local/bin/emulationstation +/usr/local/share/emulationstation/LICENSES +/usr/local/share/emulationstation/resources +/usr/local/share/emulationstation/themes +``` + +*Note: The `resources` directory is critical, without it the application won't start.* \ +ES will look in the following two locations for the resources: + +* `[HOME]/.emulationstation/resources/` +* `[INSTALLATION PATH]/share/emulationstation/resources/` + +The home directory will always take precedence so any resources located there will override the ones in the installation path. It's not recommended to override any resources since they are by nature static. But combining this ability with the command line `--home` flag, a fully portable version of EmulationStation could be created on a USB memory stick or similar. + +Anyway, after compiling the application, either run `make install` or copy or symlink the resources directory to `~/.emulationstation/resources`: +`cp -R resources ~/.emulationstation/` \ +or +`ln -s $(pwd)/resources ~/.emulationstation/` + +The same goes for the `themes` directory. Although ES can start without a theme, it would be pretty pointless as the application would barely be usable. + +**Making .deb and .rpm packages:** + +Creation of Debian .deb packages are enabled by default, simply run `cpack` to generate the package: + +``` +user@computer:~/emulationstation-de$ cpack +CPack: Create package using DEB +CPack: Install projects +CPack: - Run preinstall target for: emulationstation-de +CPack: - Install project: emulationstation-de [] +CPack: Create package +CPackDeb: - Generating dependency list +CPack: - package: /home/user/emulationstation-de/emulationstation-de-1.0.0.deb generated. +``` + +The package can now be installed using a package manager, for example `dpkg'. + +For RPM packages, change the comments in the `CMakeLists.txt` accordingly. \ +From: +``` +#SET(CPACK_GENERATOR "RPM") +SET(CPACK_GENERATOR "DEB") +``` +To: +``` +SET(CPACK_GENERATOR "RPM") +#SET(CPACK_GENERATOR "DEB") +``` + +Then simply run `cpack`. + +To be able to generate RPM packages on a Debian system such as Ubuntu, install the `rpm` package first: + +``` +sudo apt-get install rpm +``` + **On Windows:** [CMake](http://www.cmake.org/cmake/resources/software.html) diff --git a/LICENSES/EmulationStation b/LICENSES/EmulationStation new file mode 100644 index 000000000..125abdaa0 --- /dev/null +++ b/LICENSES/EmulationStation @@ -0,0 +1,19 @@ +Copyright (c) 2014 Alec Lofquist + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/LICENSES/pugixml b/LICENSES/pugixml deleted file mode 100644 index 7cd2f3d08..000000000 --- a/LICENSES/pugixml +++ /dev/null @@ -1,24 +0,0 @@ -MIT License - -Copyright (c) 2006-2019 Arseny Kapoulkine - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/es-app/CMakeLists.txt b/es-app/CMakeLists.txt index f91a817a3..4e0b0f17b 100644 --- a/es-app/CMakeLists.txt +++ b/es-app/CMakeLists.txt @@ -1,4 +1,4 @@ -project("emulationstation") +project("emulationstation-de") set(ES_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/EmulationStation.h @@ -101,7 +101,7 @@ set(ES_SOURCES ) #------------------------------------------------------------------------------- -# define OS specific sources and headers +# Define OS specific sources and headers. if(MSVC) LIST(APPEND ES_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/EmulationStation.rc @@ -109,12 +109,12 @@ if(MSVC) endif() #------------------------------------------------------------------------------- -# define target +# Define target. include_directories(${COMMON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src) add_executable(emulationstation ${ES_SOURCES} ${ES_HEADERS}) target_link_libraries(emulationstation ${COMMON_LIBRARIES} es-core) -# special properties for Windows builds +# Special properties for Windows builds. if(MSVC) # Always compile with the "WINDOWS" subsystem to avoid console window flashing at startup # when --debug is not set (see es-core/src/main.cpp for explanation). @@ -126,36 +126,51 @@ if(MSVC) set_target_properties(emulationstation PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS") endif() - #------------------------------------------------------------------------------- -# set up CPack install stuff so `make install` does something useful +# Set up CPack install for `make install`. install(TARGETS emulationstation RUNTIME - DESTINATION bin) + DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) +install(DIRECTORY ${CMAKE_SOURCE_DIR}/LICENSES + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/emulationstation) +install(DIRECTORY ${CMAKE_SOURCE_DIR}/themes + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/emulationstation) +install(DIRECTORY ${CMAKE_SOURCE_DIR}/resources + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/emulationstation) INCLUDE(InstallRequiredSystemLibraries) -SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A flexible graphical emulator front-end") -SET(CPACK_PACKAGE_DESCRIPTION "EmulationStation is a flexible, graphical front-end designed for keyboardless navigation of your multi-platform retro game collection.") +SET(CPACK_PACKAGE_NAME "emulationstation-de") +SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An emulator front-end with controller navigation and theming support.") +SET(CPACK_PACKAGE_DESCRIPTION "EmulationStation Desktop Edition is a fast, feature rich front-end for browsing and launching games from your multi-platform retro game collection. It's intended to be used in conjunction with emulators such as the RetroArch cores.") -SET(CPACK_RESOURCE_FILE LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md") -SET(CPACK_RESOURCE_FILE README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") +SET(CPACK_RESOURCE_FILE LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +#SET(CPACK_RESOURCE_FILE README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") -SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Alec Lofquist ") +SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Leon Styhre ") +SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://gitlab.com/leonstyhre/emulationstation-de") SET(CPACK_DEBIAN_PACKAGE_SECTION "misc") -SET(CPACK_DEBIAN_PACKAGE_PRIORITY "extra") -SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libsdl2-2.0-0, libfreeimage3, libfreetype6, libcurl3, libasound2") -SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS "debhelper (>= 8.0.0), cmake, g++ (>= 4.8), libsdl2-dev, libfreeimage-dev, libfreetype6-dev, libcurl4-openssl-dev, libasound2-dev, libgl1-mesa-dev, rapidjson-dev") +SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") +SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) +#SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libsdl2-2.0-0, libfreeimage3, libfreetype6, libvlc5, libcurl4, libpugixml1v5, libasound2") +SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS "debhelper (>= 8.0.0), cmake, g++ (>= 4.8), libsdl2-dev, libfreeimage-dev, libfreetype6-dev, libcurl4-openssl-dev, libpugixml-dev, rapidjson-dev, libasound2-dev, libvlc-dev, libgl1-mesa-dev") -SET(CPACK_PACKAGE_VENDOR "emulationstation.org") -SET(CPACK_PACKAGE_VERSION "2.0.0~rc1") -SET(CPACK_PACKAGE_VERSION_MAJOR "2") +SET(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION}) +SET(CPACK_RPM_PACKAGE_REQUIRES "libc6, libsdl2-2.0-0, libfreeimage3, libfreetype6, libvlc5, libcurl4, libpugixml1v5, libasound2") +SET(CPACK_RPM_PACKAGE_LICENSE "MIT") + +SET(CPACK_PACKAGE_VENDOR "https://gitlab.com/leonstyhre/emulationstation-de") +SET(CPACK_PACKAGE_VERSION "1.0.0") +SET(CPACK_PACKAGE_VERSION_MAJOR "1") SET(CPACK_PACKAGE_VERSION_MINOR "0") SET(CPACK_PACKAGE_VERSION_PATCH "0") SET(CPACK_PACKAGE_INSTALL_DIRECTORY "emulationstation_${CMAKE_PACKAGE_VERSION}") SET(CPACK_PACKAGE_EXECUTABLES "emulationstation" "emulationstation") -SET(CPACK_GENERATOR "TGZ;DEB") +SET(CPACK_RPM_FILE_NAME "emulationstation-de-${CPACK_PACKAGE_VERSION}.rpm") +SET(CPACK_DEBIAN_FILE_NAME "emulationstation-de-${CPACK_PACKAGE_VERSION}.deb") +#SET(CPACK_GENERATOR "RPM") +SET(CPACK_GENERATOR "DEB") INCLUDE(CPack) diff --git a/es-app/src/CollectionSystemManager.cpp b/es-app/src/CollectionSystemManager.cpp index c0fcc2cb1..c4c7fa62d 100644 --- a/es-app/src/CollectionSystemManager.cpp +++ b/es-app/src/CollectionSystemManager.cpp @@ -30,7 +30,7 @@ #include "Settings.h" #include "SystemData.h" #include "ThemeData.h" -#include +#include #include std::string myCollectionsName = "collections"; diff --git a/es-app/src/Gamelist.cpp b/es-app/src/Gamelist.cpp index 60371c031..6e5359638 100644 --- a/es-app/src/Gamelist.cpp +++ b/es-app/src/Gamelist.cpp @@ -14,7 +14,7 @@ #include "Log.h" #include "Settings.h" #include "SystemData.h" -#include +#include FileData* findOrCreateFile(SystemData* system, const std::string& path, FileType type) { diff --git a/es-app/src/MetaData.cpp b/es-app/src/MetaData.cpp index 11eb7e217..d2bddc2d6 100644 --- a/es-app/src/MetaData.cpp +++ b/es-app/src/MetaData.cpp @@ -9,7 +9,7 @@ #include "utils/FileSystemUtil.h" #include "Log.h" -#include +#include MetaDataDecl gameDecls[] = { // key, type, default, statistic, name in GuiMetaDataEd, prompt in GuiMetaDataEd, shouldScrape diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index 977529d35..e0adf3d7c 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -20,7 +20,7 @@ #include "Settings.h" #include "ThemeData.h" #include "views/UIModeController.h" -#include +#include #include #ifdef WIN32 #include diff --git a/es-app/src/scrapers/GamesDBJSONScraper.cpp b/es-app/src/scrapers/GamesDBJSONScraper.cpp index c53e7bef2..f2dc8c992 100644 --- a/es-app/src/scrapers/GamesDBJSONScraper.cpp +++ b/es-app/src/scrapers/GamesDBJSONScraper.cpp @@ -18,7 +18,7 @@ #include "SystemData.h" #include "MameNames.h" #include "utils/TimeUtil.h" -#include +#include // When raspbian will get an up to date version of rapidjson we'll be // able to have it throw in case of error with the following: diff --git a/es-app/src/scrapers/ScreenScraper.cpp b/es-app/src/scrapers/ScreenScraper.cpp index c9952376b..fb80e561a 100644 --- a/es-app/src/scrapers/ScreenScraper.cpp +++ b/es-app/src/scrapers/ScreenScraper.cpp @@ -15,7 +15,7 @@ #include "Settings.h" #include "SystemData.h" #include "math/Misc.h" -#include +#include #include using namespace PlatformIds; diff --git a/es-core/src/InputConfig.cpp b/es-core/src/InputConfig.cpp index 69a783705..38ef3c374 100644 --- a/es-core/src/InputConfig.cpp +++ b/es-core/src/InputConfig.cpp @@ -7,7 +7,7 @@ #include "InputConfig.h" #include "Log.h" -#include +#include // Some utility functions. std::string inputTypeToString(InputType type) diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp index 8d1ea42b8..16c8b4d86 100644 --- a/es-core/src/InputManager.cpp +++ b/es-core/src/InputManager.cpp @@ -13,10 +13,10 @@ #include "Platform.h" #include "Scripting.h" #include "Window.h" -#include +#include #include -#include #include +#include #define KEYBOARD_GUID_STRING "-1" #define CEC_GUID_STRING "-2" diff --git a/es-core/src/MameNames.cpp b/es-core/src/MameNames.cpp index 63bd8ccfe..d36d97bbc 100644 --- a/es-core/src/MameNames.cpp +++ b/es-core/src/MameNames.cpp @@ -13,7 +13,7 @@ #include "utils/FileSystemUtil.h" #include "utils/StringUtil.h" #include "Log.h" -#include +#include #include MameNames* MameNames::sInstance = nullptr; diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index d7f850d54..86f0fa972 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -11,7 +11,7 @@ #include "Log.h" #include "Scripting.h" #include "Platform.h" -#include +#include #include #include diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index e957cbc18..e60b14dff 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -15,7 +15,7 @@ #include "Log.h" #include "Platform.h" #include "Settings.h" -#include +#include #include std::vector ThemeData::sSupportedViews { diff --git a/es-core/src/utils/FileSystemUtil.cpp b/es-core/src/utils/FileSystemUtil.cpp index 0e0ad2aed..6b38f0aae 100644 --- a/es-core/src/utils/FileSystemUtil.cpp +++ b/es-core/src/utils/FileSystemUtil.cpp @@ -30,21 +30,14 @@ #endif // Try to get the install prefix as defined when CMake was run. -// The installPrefix directory is the value set for CMAKE_INSTALL_DIRECTORY during build. -// The datarootdir directory is the value set for CMAKE_INSTALL_DATAROOTDIR during build. -// If not defined, the default prefix path '/usr/local' and the default datarootdir -// directory 'share' will be used, i.e. combining to '/usr/local/share'. +// The installPrefix directory is the value set for CMAKE_INSTALL_PREFIX during build. +// If not defined, the default prefix path '/usr/local' will be used. #ifdef __unix__ #ifdef ES_INSTALL_PREFIX std::string installPrefix = ES_INSTALL_PREFIX; #else std::string installPrefix = "/usr/local"; #endif -#ifdef ES_DATAROOTDIR -std::string dataRootDir = ES_DATAROOTDIR; -#else -std::string dataRootDir = "share"; -#endif #endif namespace Utils @@ -216,22 +209,13 @@ namespace Utils std::string getInstallPrefixPath() { - // There seems to be a bug in CMake that when deleting the CMakeCache.txt - // file and running cmake, the ES_DATAROOTDIR is not populated, i.e. this fails: - // add_definitions(-DES_DATAROOTDIR="${CMAKE_INSTALL_DATAROOTDIR}") - // Re-running cmake a second time populates it correctly. But ES_INSTALL_PREFIX - // is always populated correctly on my machine which is very strange. - // Anyway, as an extra precaution, let's set datarootdir to 'share' if it's blank, - // as that's what most people would want anyway. When this bug has been fixed in - // CMake this code can be removed. - // Just in case, let's set installPrefix to '/usr/local' if blank as well as a - // fallback precaution as maybe some make environments won't handle this - // correctly either. + // installPrefix should be populated by CMAKE from $CMAKE_INSTALL_PREFIX. + // But just as a precaution, let's check if this variable is blank, and if so + // set it to '/usr/local'. Just in case some make environments won't handle this + // correctly. if (!installPrefix.length()) installPrefix = "/usr/local"; - if (!dataRootDir.length()) - dataRootDir = "share"; - return installPrefix + "/" + dataRootDir; + return installPrefix + "/share"; } std::string getPreferredPath(const std::string& _path) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 9b09143ad..d817d9dfb 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -2,4 +2,3 @@ # package managers are included with the project (in the 'external' folder) add_subdirectory("nanosvg") -add_subdirectory("pugixml") diff --git a/external/pugixml/.codecov.yml b/external/pugixml/.codecov.yml deleted file mode 100644 index 230b4ed78..000000000 --- a/external/pugixml/.codecov.yml +++ /dev/null @@ -1,2 +0,0 @@ -comment: false - diff --git a/external/pugixml/.gitattributes b/external/pugixml/.gitattributes deleted file mode 100644 index 07b051b5c..000000000 --- a/external/pugixml/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -tests/data/* -text diff --git a/external/pugixml/.gitignore b/external/pugixml/.gitignore deleted file mode 100644 index 6e8271004..000000000 --- a/external/pugixml/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -# CMake -Makefile -CTestTestfile.cmake -DartConfiguration.tcl -pugixml-config-version.cmake -pugixml-config.cmake -pugixml-targets.cmake -pugixml.pc - -/build/ -/.vscode/ diff --git a/external/pugixml/.travis.yml b/external/pugixml/.travis.yml deleted file mode 100644 index 01bd59f93..000000000 --- a/external/pugixml/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: cpp -os: - - linux - - osx -compiler: - - clang - - gcc - -matrix: - exclude: - - os: osx - compiler: gcc - -env: - - DEFINES=standard - - DEFINES=PUGIXML_WCHAR_MODE - - DEFINES=PUGIXML_COMPACT - - DEFINES=PUGIXML_NO_EXCEPTIONS - -script: - - if [[ ! ( "$CXX" == "clang++" && "$TRAVIS_OS_NAME" == "linux" ) ]]; then make test cxxstd=c++11 defines=$DEFINES config=coverage -j2; fi - - if [[ "$CXX" == "clang++" ]]; then make test cxxstd=c++11 defines=$DEFINES config=sanitize -j2; fi - - make test cxxstd=c++11 defines=$DEFINES config=release -j2 - - make test cxxstd=c++98 defines=$DEFINES config=debug -j2 - -after_success: - - bash <(curl -s https://codecov.io/bash) -f pugixml.cpp.gcov diff --git a/external/pugixml/CMakeLists.txt b/external/pugixml/CMakeLists.txt deleted file mode 100644 index a0254d8ad..000000000 --- a/external/pugixml/CMakeLists.txt +++ /dev/null @@ -1,217 +0,0 @@ -cmake_minimum_required(VERSION 3.4) -project(pugixml VERSION 1.10 LANGUAGES CXX) - -include(CMakePackageConfigHelpers) -include(CMakeDependentOption) -include(GNUInstallDirs) -include(CTest) - - -cmake_dependent_option(USE_VERSIONED_LIBDIR - "Use a private subdirectory to install the headers and libraries" OFF - "CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF) - -cmake_dependent_option(USE_POSTFIX - "Use separate postfix for each configuration to make sure you can install multiple build outputs" OFF - "CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF) - -cmake_dependent_option(STATIC_CRT - "Use static MSVC RT libraries" OFF - "MSVC" OFF) - -cmake_dependent_option(BUILD_TESTS - "Build pugixml tests" OFF - "BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF) - -option(BUILD_SHARED_AND_STATIC_LIBS "Build both shared and static libraries" OFF) - # Technically not needed for this file. This is builtin. -option(BUILD_SHARED_LIBS "Build shared instead of static library" OFF) - -set(BUILD_DEFINES CACHE STRING "Build defines") - -# This is used to backport a CMake 3.15 feature, but is also forwards compatible -if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) - set(CMAKE_MSVC_RUNTIME_LIBRARY - MultiThreaded$<$:Debug>$<$>:DLL>) -endif() - -if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) - set(CMAKE_CXX_STANDARD_REQUIRED ON) -endif() - -if (NOT DEFINED CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 11) -endif() - -if (USE_POSTFIX) - set(CMAKE_RELWITHDEBINFO_POSTFIX _r) - set(CMAKE_MINSIZEREL_POSTFIX _m) - set(CMAKE_DEBUG_POSTFIX _d) -endif() - -if (CMAKE_VERSION VERSION_LESS 3.15) - set(msvc-rt $) - - set(msvc-rt-mtd-shared $) - set(msvc-rt-mtd-static $) - set(msvc-rt-mt-shared $) - set(msvc-rt-mt-static $) - unset(msvc-rt) - - set(msvc-rt-mtd-shared $<${msvc-rt-mtd-shared}:-MDd>) - set(msvc-rt-mtd-static $<${msvc-rt-mtd-static}:-MTd>) - set(msvc-rt-mt-shared $<${msvc-rt-mt-shared}:-MD>) - set(msvc-rt-mt-static $<${msvc-rt-mt-static}:-MT>) -endif() - -set(versioned-dir $<$:/pugixml-${PROJECT_VERSION}>) - -set(libs) - -if (BUILD_SHARED_LIBS OR BUILD_SHARED_AND_STATIC_LIBS) - add_library(pugixml-shared SHARED - ${PROJECT_SOURCE_DIR}/scripts/pugixml_dll.rc - ${PROJECT_SOURCE_DIR}/src/pugixml.cpp) - add_library(pugixml::shared ALIAS pugixml-shared) - list(APPEND libs pugixml-shared) - - set_property(TARGET pugixml-shared PROPERTY EXPORT_NAME shared) - target_include_directories(pugixml-shared - PUBLIC - $) - target_compile_definitions(pugixml-shared - PRIVATE - $<$:PUGIXML_API=__declspec\(dllexport\)>) - target_compile_options(pugixml-shared - PRIVATE - ${msvc-rt-mtd-shared} - ${msvc-rt-mtd-static} - ${msvc-rt-mt-shared} - ${msvc-rt-mt-static}) -endif() - -if (NOT BUILD_SHARED_LIBS OR BUILD_SHARED_AND_STATIC_LIBS) - add_library(pugixml-static STATIC - ${PROJECT_SOURCE_DIR}/src/pugixml.cpp) - add_library(pugixml::static ALIAS pugixml-static) - list(APPEND libs pugixml-static) - - set_property(TARGET pugixml-static PROPERTY EXPORT_NAME static) - target_include_directories(pugixml-static - PUBLIC - $) - target_compile_definitions(pugixml-static - PRIVATE - $<$:PUGIXML_API=__declspec\(dllexport\)>) - target_compile_options(pugixml-static - PRIVATE - ${msvc-rt-mtd-shared} - ${msvc-rt-mtd-static} - ${msvc-rt-mt-shared} - ${msvc-rt-mt-static}) -endif() - -if (BUILD_SHARED_LIBS) - set(pugixml-alias pugixml-shared) -else() - set(pugixml-alias pugixml-static) -endif() -add_library(pugixml INTERFACE) -target_link_libraries(pugixml INTERFACE ${pugixml-alias}) -add_library(pugixml::pugixml ALIAS pugixml) - -set_target_properties(${libs} - PROPERTIES - MSVC_RUNTIME_LIBRARY ${CMAKE_MSVC_RUNTIME_LIBRARY} - EXCLUDE_FROM_ALL ON - POSITION_INDEPENDENT_CODE ON - SOVERSION ${PROJECT_VERSION_MAJOR} - VERSION ${PROJECT_VERSION} - OUTPUT_NAME pugixml) - -set_target_properties(${libs} - PROPERTIES - EXCLUDE_FROM_ALL OFF) -set(install-targets pugixml ${libs}) - -configure_package_config_file( - "${PROJECT_SOURCE_DIR}/scripts/pugixml-config.cmake.in" - "${PROJECT_BINARY_DIR}/pugixml-config.cmake" - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR} - NO_CHECK_REQUIRED_COMPONENTS_MACRO - NO_SET_AND_CHECK_MACRO) - -write_basic_package_version_file( - "${PROJECT_BINARY_DIR}/pugixml-config-version.cmake" - COMPATIBILITY SameMajorVersion) - -configure_file(scripts/pugixml.pc.in pugixml.pc @ONLY) - -if (NOT DEFINED PUGIXML_RUNTIME_COMPONENT) - set(PUGIXML_RUNTIME_COMPONENT Runtime) -endif() - -if (NOT DEFINED PUGIXML_LIBRARY_COMPONENT) - set(PUGIXML_LIBRARY_COMPONENT Library) -endif() - -if (NOT DEFINED PUGIXML_DEVELOPMENT_COMPONENT) - set(PUGIXML_DEVELOPMENT_COMPONENT Development) -endif() - -set(namelink-component) -if (NOT CMAKE_VERSION VERSION_LESS 3.12) - set(namelink-component NAMELINK_COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT}) -endif() -install(TARGETS ${install-targets} - EXPORT pugixml-targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${PUGIXML_RUNTIME_COMPONENT} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${PUGIXML_LIBRARY_COMPONENT} ${namelink-component} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT} - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}${versioned-dir}) - -install(EXPORT pugixml-targets - NAMESPACE pugixml:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pugixml COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT}) - -export(EXPORT pugixml-targets - NAMESPACE pugixml::) - -install(FILES - "${PROJECT_BINARY_DIR}/pugixml-config-version.cmake" - "${PROJECT_BINARY_DIR}/pugixml-config.cmake" - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pugixml COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT}) - -install(FILES ${PROJECT_BINARY_DIR}/pugixml.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT}) - -install( - FILES - "${PROJECT_SOURCE_DIR}/src/pugiconfig.hpp" - "${PROJECT_SOURCE_DIR}/src/pugixml.hpp" - DESTINATION - ${CMAKE_INSTALL_INCLUDEDIR}${versioned-dir} COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT}) - -if (BUILD_TESTS) - set(fuzz-pattern "tests/fuzz_*.cpp") - set(test-pattern "tests/*.cpp") - if (CMAKE_VERSION VERSION_GREATER 3.11) - list(INSERT fuzz-pattern 0 CONFIGURE_DEPENDS) - list(INSERT test-pattern 0 CONFIGURE_DEPENDS) - endif() - file(GLOB test-sources ${test-pattern}) - file(GLOB fuzz-sources ${fuzz-pattern}) - list(REMOVE_ITEM test-sources ${fuzz-sources}) - - add_custom_target(check - COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure) - - add_executable(pugixml-check ${test-sources}) - add_test(NAME pugixml::test - COMMAND pugixml-check - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) - add_dependencies(check pugixml-check) - target_link_libraries(pugixml-check - PRIVATE - pugixml::pugixml) -endif() diff --git a/external/pugixml/LICENSE.md b/external/pugixml/LICENSE.md deleted file mode 100644 index 7cd2f3d08..000000000 --- a/external/pugixml/LICENSE.md +++ /dev/null @@ -1,24 +0,0 @@ -MIT License - -Copyright (c) 2006-2019 Arseny Kapoulkine - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/external/pugixml/README.md b/external/pugixml/README.md deleted file mode 100644 index 2982ec2c3..000000000 --- a/external/pugixml/README.md +++ /dev/null @@ -1,72 +0,0 @@ -pugixml [![Build Status](https://travis-ci.org/zeux/pugixml.svg?branch=master)](https://travis-ci.org/zeux/pugixml) [![Build status](https://ci.appveyor.com/api/projects/status/9hdks1doqvq8pwe7/branch/master?svg=true)](https://ci.appveyor.com/project/zeux/pugixml) [![codecov.io](https://codecov.io/github/zeux/pugixml/coverage.svg?branch=master)](https://codecov.io/github/zeux/pugixml?branch=master) ![MIT](https://img.shields.io/badge/license-MIT-blue.svg) -======= - -pugixml is a C++ XML processing library, which consists of a DOM-like interface with rich traversal/modification -capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an XPath 1.0 -implementation for complex data-driven tree queries. Full Unicode support is also available, with Unicode interface -variants and conversions between different Unicode encodings (which happen automatically during parsing/saving). - -pugixml is used by a lot of projects, both open-source and proprietary, for performance and easy-to-use interface. - -## Documentation - -Documentation for the current release of pugixml is available on-line as two separate documents: - -* [Quick-start guide](https://pugixml.org/docs/quickstart.html), that aims to provide enough information to start using the library; -* [Complete reference manual](https://pugixml.org/docs/manual.html), that describes all features of the library in detail. - -You’re advised to start with the quick-start guide; however, many important library features are either not described in it at all or only mentioned briefly; if you require more information you should read the complete manual. - -## Example - -Here's an example of how code using pugixml looks; it opens an XML file, goes over all Tool nodes and prints tools that have a Timeout attribute greater than 0: - -```c++ -#include "pugixml.hpp" -#include - -int main() -{ - pugi::xml_document doc; - pugi::xml_parse_result result = doc.load_file("xgconsole.xml"); - if (!result) - return -1; - - for (pugi::xml_node tool: doc.child("Profile").child("Tools").children("Tool")) - { - int timeout = tool.attribute("Timeout").as_int(); - - if (timeout > 0) - std::cout << "Tool " << tool.attribute("Filename").value() << " has timeout " << timeout << "\n"; - } -} -``` - -And the same example using XPath: - -```c++ -#include "pugixml.hpp" -#include - -int main() -{ - pugi::xml_document doc; - pugi::xml_parse_result result = doc.load_file("xgconsole.xml"); - if (!result) - return -1; - - pugi::xpath_node_set tools_with_timeout = doc.select_nodes("/Profile/Tools/Tool[@Timeout > 0]"); - - for (pugi::xpath_node node: tools_with_timeout) - { - pugi::xml_node tool = node.node(); - std::cout << "Tool " << tool.attribute("Filename").value() << - " has timeout " << tool.attribute("Timeout").as_int() << "\n"; - } -} -``` - - -## License - -This library is available to anybody free of charge, under the terms of MIT License (see LICENSE.md). diff --git a/external/pugixml/appveyor.yml b/external/pugixml/appveyor.yml deleted file mode 100644 index 4c636a028..000000000 --- a/external/pugixml/appveyor.yml +++ /dev/null @@ -1,22 +0,0 @@ -image: - - Visual Studio 2019 - - Visual Studio 2017 - - Visual Studio 2015 - -version: "{branch}-{build}" - -build_script: - - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2013") { .\scripts\nuget_build.ps1 2013} - - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { .\scripts\nuget_build.ps1 2015} - - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2017") { .\scripts\nuget_build.ps1 2017} - - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2019") { .\scripts\nuget_build.ps1 2019} - -test_script: - - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { .\tests\autotest-appveyor.ps1 9 10 11 12 14 } - - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2017") { .\tests\autotest-appveyor.ps1 15 } - - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2019") { .\tests\autotest-appveyor.ps1 19 } - - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { & C:\cygwin\bin\bash.exe -c "PATH=/usr/bin:/usr/local/bin:$PATH; make config=coverage test && bash <(curl -s https://codecov.io/bash) -f pugixml.cpp.gcov" } - - ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2015") { & C:\cygwin\bin\bash.exe -c "PATH=/usr/bin:/usr/local/bin:$PATH; make config=coverage defines=PUGIXML_WCHAR_MODE test && bash <(curl -s https://codecov.io/bash) -f pugixml.cpp.gcov" } - -artifacts: - - path: .\scripts\*.nupkg diff --git a/external/pugixml/docs/config.adoc b/external/pugixml/docs/config.adoc deleted file mode 100644 index 504606458..000000000 --- a/external/pugixml/docs/config.adoc +++ /dev/null @@ -1,7 +0,0 @@ -website ; repository -:toc: right -:source-highlighter: pygments -:source-language: c++ -:sectanchors: -:sectlinks: -:imagesdir: images diff --git a/external/pugixml/docs/images/dom_tree.png b/external/pugixml/docs/images/dom_tree.png deleted file mode 100644 index 30467e73628dfca1f4cb337f974e867b6c73672d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24570 zcmbTe1yo#Jvo_d30t62PcS0b+A-EF=F2N;eaCd9m-2()74^D6kjT4;UE@>KC)fgEJ_~V(mn1UDxR2zqWXY?HS`-OwFwlfGs9{Ti+pqGyq00J4r$w-K) zdFUTzDcO(>BtKI6c@5e2=`m4>qeL*`HemJ0vNL;loKSj%TuAqX22k7LBI)oUn{9?5 zBq0ZTAPr(LQz_<#gdt$?iucxhp>m*tu;FRF*PjplLMc%#E`{b|7@j8&%atyf;DOF| zU6xmXt-!5bU^B2;t9d77UfUx7-|Rj>uw0P2>s$CQ>BQn zG+J;!7_chlQ|G=DNOEyX!gp18q8|T=9-yW&WxzSjjrI z*+}|06V@BUH$a$Ov_->MlW_8y!GUamaz(t_N3Ce-<`bTgXK?b6r-31>$j4N0G_dF(Dq`KfFTU3*DxJk7AlToWrYz5GKy|Ag6!r6I;FyT67mo( z{#G}dH%v}Y7@0;oCeX^v;Dh274b?#L9DfxBrKfrPN<=Q&r8Mnu$+PAwNp40jMidM_ zNZ;*T+{6zY9`5G};pchwGS%}Pdo`@|)0Z7S)fZYXeIfdx0ZL}UN9`mozzjje6%v*@ z&i;kR#Va*?|H8yBg0T5#^%lSU5vF4u28|+xTbdYF=7nJM(U$Hd`FUyq$r%03aO##6YVpSI{5#2{R#n3C9GCscj_nIHCBv*krzon407z2 zfehLHS@aX}MJUVYAY`Oak*9?okIKgIKP#^aU-<_UQBsyvcizYz2Z+^K&#^2nSQ;zi zf<$Qm(V({vcTkb(W4}kQo9!f}-5_k?T%X&&lU)z{T~m*DK*g_I>)dnT>*&cxp zhieZC_sLuT*)lJ8Ry(|g!>`sJ?+q?4N!PBBg>H5W;DfK@-WG_h{(b&FVP@^&FOR8B zc>5jKS^r?X52)MXX|KKfN%Xv!{zIr$v@(?+1WeImR>CPn+CNx>`Ly3H-+{W{A^@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{)j zcoj3v7Vw5tJe&L-Xsq5%B$t>)qHiJitZ~3%YnGi=;rFPmibWYF&6ih*k+m|NlYn3E z{$QF}{+Y|%>ut5p!0(kI75B>tUD&n+N&QaePIB04o_x(Wrxh7x>Z665LnH*Ww<1N) zhTQ{ZvV4cCO0ayC<^#>B_mC{SlX&RAE8)vnncBGkA5Z=awekoF{)R8c*zlYM?izrm0GArhvl)gD z!g*tC$BA`*<*DRzkt7r04yn!h-w%8=Tu3)K2FRoTC!Fj5;KLjH)%2X4JoY&ndkH1= zhkSA0$<4@MXhP{{1DR#tEmQhz_++mB#Wkf3pw|DloO%C^-#EJgydf^hKO(R6mclbt KnX;!Qf&T-D5uywL diff --git a/external/pugixml/docs/images/vs2005_link1.png b/external/pugixml/docs/images/vs2005_link1.png deleted file mode 100644 index 6da6366afa49d26758d5217497fa273078c1188d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25698 zcmZr$XEfZ;_x|k1VwJF1y{%p%h-gt__1;MkWkrqXEh5UU9z?G}vU(x}QKH)*N<@zu zgh=$>yZ`t1{(t7h%-nP5&YXLmd(S-g+*byA>bFRlNC5!2rKzD}1ONme0Dw>!!GDrG zou^#?ZLSP-OjH5Le?uC8JS7KB?tlOSU*etsTOp%6eEBOt0Ib(hCfkV8^Jypb9K$Y(i-Kt9ka3Ew_^a6jP_t1qCN zqpd9AAd~2&pdhLJ^0l;#v_^)$&K+a5KubeKG8d01nWKUS!Bh_Q{V0wX2L3t98SN^P z%mIQ$`gf@?5P6&L&QGM6J@Vab3?ABi8CUY440Td=skCs$#X3qS+goS2!M->EkAkGu zjrbffz?hYi5O%TH-IFUNA?dlBUF6e#5B}Io_zp964bZ+k%-(!sVW( zqkLlu+@r>|5|@AYJBCHK*<~h4XWv96WJE?>HHW*`g@-?So7NbXW1T&an3SEJ6#gag ze)d}+J6qxqt27ci=ulz(DRKNqHq&CVtj}lp;h2LDxMY#GiN##joWf5jMeTNV^~g>YWiMLs{4Br z2U>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docs/images/vs2005_link2.png b/external/pugixml/docs/images/vs2005_link2.png deleted file mode 100644 index 9f75a4f773a17a8eb052a33aa677fbfc0fc4c942..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18063 zcmcG$cT^Km)GwM01B9MPmtp`xRH_sa1VTqZ1*Jh~MNTl~72-1u6E=Vs?iU>%R z-lg|09bWvtch~#gee1sO{&UyLS;@?tIcLv4yUlO!lMvNs3S`7Li6IaO*%L+C7Z3;@ z0D%A?3=elERpkvE?hESlLO~i*+RM0xy9!ZNQI~^2ai>Kf5Kl7b>qijCE#SE*MD!8V z)C>aAfbhMBJaUIZUPH_vv^CEuNtuz%$lJmYK?4F&HeOyXPb3^78mY;}F2>`T&L%7_ z5(!cH=q|`duFyuPsU9isajur*@08+%`$F{%^*F6R+L>@!m`cl<7Cv`? z7@EHRs1I0}>7;5ZhL~{azD{{)(`)hO^>h38oUUJxzK)S5`p(V}JA2z-hSHMguaJZ& z7dPidJE|=co?JKnQg6a{zTVAn)++(Ltx_PN{Pn)vh2{YRE?nW;K2ONto$^?%Cn68vYh;!sn7R) z%cffkZIeoVhE$gomK2s2mk;MVS5^3EeP8#f8_g)X{+*Y+@;R~KYlq;_d1FmNW7XHM zHB~1W$2Cor>*W~@P4#|VTVu`dQU=_vt4**it$!P3u-{v1TL(s)zT|WqTvtb(w%siI zl~eg+dax}cd8n%K$8c{)OGjt>&mZ02ehxPOswxUw8y`|sb1t^L1Od%b%HyG!TC zN5_Yw*Vorql~)(tCuheOS2Jf9r&re(ZlT@h{}jVSSwR*OjL)QqJ0N!~sIAwqkIzM?TM>s(UBc)^Z*bv9{LqeX&N~ya~Y^9PJsSkfTCX^zJ8y)*H5Na!I z8UArg*orzQ?1=3PS5Bs)QbS<1eZ}8t`Sn+N-$w%DH1d80S_!j~RTW1FH`psu$`rJJ zmyO}MB}FCpT~Yd%pde)q)0-D2Nd&Hm9_cG7=Z~CL1Oz^OTD%TAt##X0i52VHk?3>k z_2{iA;eK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zXsC(!1Ekwf+*1G797K*RyLsC4(YZB78ef$d-uN)IIzC~sko@+m(Lp5dz~e^&9TEu~ zTBnmQ%h-J_UbBx^@{Ax|{a% zZMn2OZYvW*U(*~JHlV*(NPh5Oi{fNjq+lk>$*04%+F@llGvfs<&JQXx8w%SPmNJWQ z3$pky77H|Y{k$R`T`L`sbu>P9bu+^PjgGUz97j$xv@~ca@FfKr&j0!7f&LOvuZ=%e zXHREX($Mg+xgo{DiYa`$@d^foMbkdrjF(9$r8a}o+ za5=tN_2jjG>IUy`PRUC{7!2eDCrBJQ=cxMs@6>~FlG7~AuD$o3y0OQf<kFPw<8_6S&z1YPuog3ocF!y^D}Vkl7bnTps*q Y-WPrGna9oxn;3w=)78&qol`;+0RC#k<^TWy diff --git a/external/pugixml/docs/images/vs2005_pch1.png b/external/pugixml/docs/images/vs2005_pch1.png deleted file mode 100644 index ddbb93cb7c51f2027693d35590148a639af48f5c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 27693 zcmXtf2Rt0l`~TfKtbQj5q8uVogNPFKbRnWdi(W(Y-o>3x^e#k~=tOVfBoV!a5TXmB z_g?-!-{0%Muie+YW_D)hnce5vXXgF9CqnIo0tq24Ap`;;d8R0<0fFEE5C{MRac)aK zJb%M-n?PMP6r>>)gLMCH??Tj`Ysx_Y2n>o3gHS*K0T>Pw42oj9tp?R%g+L+D*CJ2| zKU5L{zas$=kOSxhA!Zg32qhII1W|4V5$1&4m_jUAn1mlb5NGFL(`KY*=XlJ;fg*Zr z4S5o#!a>Q;D`&_F;o%n*5)jIvlq$JP`BeBhL?*kPQcgkwg+jd)e0&3cmM9_-?#Py|PW^d^K4eHr3W0_)cyUB%SpfdlrY24S#+ak6|xFQg0F?eO{-=MMb3~#ai`+@LLwXe4hmgNi2^~j7xhjj7>luVx-fP z(vp&MMgj(Ha@+sJ3eQFQRm4rXRg3!-Rc7aW7)&$I&aUTa`<0hlI30enn8}cy->{b~ zV^&*Vl%J5BUuINw6I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hBd diff --git a/external/pugixml/docs/images/vs2005_pch2.png b/external/pugixml/docs/images/vs2005_pch2.png deleted file mode 100644 index 7f15ebc1813de5d4b97c964a36eab69fd643b4c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14895 zcmb_@XH-)`*Y3$7fh4rh5kW$gUZn~edX)~+gn&qs5)c7JFrjx4l#T?HBBCJDn?aBw zpfnK>=^`LisnTwI-}~Kl@Bh2<<78&f?DOnr?|Ej{$w{1vkq#}A0|@{Ct)8x?830g# z002Va6y%V@K>Qw*D`chQAtn)oE73UH15D`Yyhk5SVg5q8J?H&7gH2n z0k`WWX1;*S+gv@s%skB8%0=R4f{pF{7ka7=ws&vXhCAO>%C-RvS`hi5a+@oYH;U;Z+D%JI+J; z(f3S(d34kRd`wDWl9P6Jr$YAG%ka$Pq|&|^Im_J1uIO-=g4VCG;Q`raD&?omsfkl5 zirLv!1$hWQPxbmpiZ$XLZgg{i_)R{cSC0xY48Vp{4g-JwH40yLv`m4DOEiKg<6%@nrI(X)1H$bM)ZQ zw}y#{cVB0}j^}w1mC~&rJ-_NoxBkq{ z{pemk7+OC#ojLoo_2LI^ z?{4od{NCBx+50noc6N69_ULrt@A2X3*>T&umiopzb~f>X!lyns@6s0~Ny!Nb$&aF< zBMP6DynIz|Y-)5r0$c}TwejXg~ z@r-^}l<9vbB>nNDp;!06PK>!Y$NBiAWMn;wj7kQ8o0;WxP(TX+tpU&x2Ka@B=Ia{< zkt?s^*Y`O9kYCl)RI>kc~C%d@uhNuYtMLL#E0TbShTgLM^%vq zLy?erE6W1bqmY$L|I_`SDScNvu-d5ick^$3^$_CuX%_~OC#dT_8{0`=IDiHlyXc$T z*znKA{DHa@3%#;>Sj)+KfVfB#{8@Z436_;YYU>v7D!Q~07)z!1?5*)uGlV`GFBPA& zE`3k9OaCvz;I?>;`?s22BYOX}f_e{h;z9#YC4mr*3MY`5ZS&dVqp-WZRo#y2OU2aKGv>P1r{C7EguwSV+iz?Tmfmbxd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@g+1Cwf3G-cDu=gJ|BOUXp04iOPASc z6ofU@Tgsb`D2+7NUV)Ln$8o4^^GYpH_-xY{2=F~X&|YnMNbYDr$A|c%8SAx#d{ub4 zfA_ZZ*)HqspWDBM_UzqrcP8j#&&QmtzFYfU>cv19`ltm^{+r5H;vDPQHb&94sW4ss z8pSJE*JtL=Z`_U6y#Mx(RNYz{_HLlHRNKGF5dD!w2;=7LEW0VK>67c3^ah8!i#x$0 zW@FBS;nvmruX_$Co@A?;;k+SJyzTnrj}bwChpoF)k8dh#DCE)|<%1^7@s`1Vt}@Bb z?svQ1)z$};VC&g*alkEv)vOu=)|HN7-AD)N_jzI0Lpk5hAxO@B*=U4udfX9Yoiy^yK)Tskc!ZmtNfN(ufVOI<54{BYU026{t-F96Wo3Ivhpg~N|Zo9+lj9Wh@=VApAydHzByOJamwP@EnsTF zW6T&6(O0lQmF*s7A|Ls}S?~;YOcO_%5Rx()EH+!xPHyPwk^K3f#Ey~DH_NQ~asV@W z!G??~miS+6IDCKDFXj~8WvcaQ6JB@sgCx)?MgvTzPne56pf7MQd(aeXP;$5i3yAM) z?E1^%@!?kp&bj#snfhhOpSkB?@<&KI?B@WGqeusgoDwd^&+E_gCmT#`j5m6C9Q%z5`N*NRSzW~|2 B1iAnK diff --git a/external/pugixml/docs/images/vs2005_pch4.png b/external/pugixml/docs/images/vs2005_pch4.png deleted file mode 100644 index c9fe63da7d453f9155ec3d8df997b7949a772634..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15117 zcmYj%1yoc~*Y=&u3=9Lp&`8LDbayHY9ny_-H&OzEzzm&&0a6NxlF}(T(n?4v-HL#e zs7UjV@B4mh{cFv-bMDz^Kj)mipR@N}ci%*PUG-}S1_S^A*EBU$3;}=u1ON~UC&2f- z(00Fxzxk`LZLA7F@GT+;APxYsAYcdqEC>L50CWR@WGMiU0{~J|R%t+*5Gg1D*q8wj zyi5*sHUmWQBkTYv3*fFRAe;D4!R7i5K~P!-kg($yk_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(^bLrLcE#4C0XF_~ag&RW+QvImB2&u2iGC**vRTF({GL0<1y=9?y*) z5=o`^y7Ek@q2H9SN(otKdo12x8)>Z21;i{Hpz(mr|Gt0W{^9`Z*%y{AD=2t)2_6eR zxXJy>T0e!wjq|dkk_Pu;M5LH**lw5bQS@b{F{{j*lf|gY3H;^y?4on46_lLrTqODd z;&RypZ@{v1Ih;<0Hq{Z=(JA*kUfk-}Z_i&tWrY@>nqHc9>sFbMPZFPyHAH_w1nbP| z*E|z(7Wl%AlDmHgN_F*WE6$Ai7`}7!S*^j+t{);Tm~R^^GHrnBjaH$QDYegW?SWzy zbAJ^{?s`x+NBUi>1y%>Lr9?soBYp+KYpFP3UVC$b1umv(k>rH*H(QHvcY6b8*;+9x z68j2Gi*E?0|1E zaGs_sP)FQfmWv2J`8Z~i_qK;_J^tvP(eAK5Ii4t- zqD9UYJEvHf!V}q#nw#0Vkvux8?aEyGy JvV=qp{~z3Tqv!wt diff --git a/external/pugixml/docs/images/vs2010_link2.png b/external/pugixml/docs/images/vs2010_link2.png deleted file mode 100644 index b6446a29a68eb2b2adb9221347fdf0a4dbbe339f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17206 zcmc(`cRbbM`#*lp%L_029Arg~5h61y#IZ+02w4f4Wt3Ur9D7q_%igk*Jr1%d>#>(;;W(8y10&z^nC`ISZgtH5d|{|1*0G_n7*v!9cAs?$|eD#B1ULAMHMw$ z@mN*46csh)Yuc}6H7xFFig0P?21;4M%<{DFYpd!xp!MCg^$e&Ul^Ym72-OAjjIC-F z1^X3vtt=%Y^tH?_%uFmD3@tqh3}J!hw<>hd<$B^)whn&A$?guU^3T$2?4Iy?d!xLn zpE*CZat*hA9uV#5Fz|#x+OK-xk%F7Yi~6Uu65)|?&tIfF1qp`_+XV*t_`R<3A@sz) z(F^}H=wcKQi1iDJY4eAr_!T{VQ`Yb85E5;R2`g{*@yrRkU*qo}k$h1U7+m6?7!mny z(AOd|IwCkGy+2sYF!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kIf-?`g=wPeX>U%C3_3L7FCN3~Hfh@f0ZyhMuD2aw34R zMLLr1y)=NvP11d$@7bGVv0up*G~rYQ;-MenFal%9dP?@9B3J*hue%?2I@u`+U<(XL}h>x}*gg%LhHeUGv z5@fx7>kGl)(RcAiQRcfOI_&cmu>`XJGH_U@F!o5EhpW3kzYqcJ(RZ6D-3YjpGjGP9 zFmT>teqUsu&&c<0YOYG>@8bts+2!@B_n(xCsKSCY`0&>q|M##7E#3^u!h_BKJK;6F zgZCQh|LhkmP>4U7qR<)3C?`RpuY_WL%KcI-xlVNRUK3?=@ex<0wqq^<61}KbdvR)5 zzEJk)?9{_GfTHP|_B_MfRRmmL-tEt~M@K@Q&D%RBofHD!m%T;XXSqXR#W3h~Y@

*`(7nj*Z_BX(JMzXpQVnH4o#->|!w z%oC5{5$C5wNl)=!S6(n~Ec~m`9nr@ygwdzjfTu{jmtd*yhIbfsK-?h-^rB%V`T4<< z?qLZSh_g+Wd4)LhO(ZeX^y7p7iyHE$bO79m1ehPUiG9i(P%&5h-}@USB% z;-`Qy$+3&#@wHrl^E2W`KX1!<6AaEou4(<#E+Ujw!HtHPe0{9KerXOb^@G>QrM??w z{--NVpICm=Zh;`Sw&iUgb^#h>%dovBYusk`@`!SyEfeox3M17FZyWCB)%ob0eL{DN&F}9uGk5@xhGY^Co}~Pwjsw|GPDph!qhAP7L%t zGFj2dbnrg(UOQzeQc_w4 Ohp8)TDU~T$`2TOT9Us{M diff --git a/external/pugixml/docs/manual.adoc b/external/pugixml/docs/manual.adoc deleted file mode 100644 index c56667397..000000000 --- a/external/pugixml/docs/manual.adoc +++ /dev/null @@ -1,3087 +0,0 @@ -= pugixml {version} manual -include::config.adoc[] -:numbered: - -[[overview]] -== Overview - -[[overview.introduction]] -=== Introduction - -https://pugixml.org/[pugixml] is a light-weight C{plus}{plus} XML processing library. It consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an <> for complex data-driven tree queries. Full Unicode support is also available, with <> and conversions between different Unicode encodings (which happen automatically during parsing/saving). The library is <> and easy to integrate and use. pugixml is developed and maintained since 2006 and has many users. All code is distributed under the <>, making it completely free to use in both open-source and proprietary applications. - -pugixml enables very fast, convenient and memory-efficient XML document processing. However, since pugixml has a DOM parser, it can't process XML documents that do not fit in memory; also the parser is a non-validating one, so if you need DTD or XML Schema validation, the library is not for you. - -This is the complete manual for pugixml, which describes all features of the library in detail. If you want to start writing code as quickly as possible, you are advised to link:quickstart.html[read the quick start guide first]. - -NOTE: No documentation is perfect; neither is this one. If you find errors or omissions, please don’t hesitate to https://github.com/zeux/pugixml/issues/new[submit an issue or open a pull request] with a fix. - -[[overview.feedback]] -=== Feedback - -If you believe you've found a bug in pugixml (bugs include compilation problems (errors/warnings), crashes, performance degradation and incorrect behavior), please file an issue via https://github.com/zeux/pugixml/issues/new[issue submission form]. Be sure to include the relevant information so that the bug can be reproduced: the version of pugixml, compiler version and target architecture, the code that uses pugixml and exhibits the bug, etc. - -Feature requests can be reported the same way as bugs, so if you're missing some functionality in pugixml or if the API is rough in some places and you can suggest an improvement, https://github.com/zeux/pugixml/issues/new[file an issue]. However please note that there are many factors when considering API changes (compatibility with previous versions, API redundancy, etc.), so generally features that can be implemented via a small function without pugixml modification are not accepted. However, all rules have exceptions. - -If you have a contribution to pugixml, such as build script for some build system/IDE, or a well-designed set of helper functions, or a binding to some language other than C{plus}{plus}, please https://github.com/zeux/pugixml/issues/new[file an issue or open a pull request]. Your contribution has to be distributed under the terms of a license that's compatible with pugixml license; i.e. GPL/LGPL licensed code is not accepted. - -If filing an issue is not possible due to privacy or other concerns, you can contact pugixml author by e-mail directly: arseny.kapoulkine@gmail.com. - -[[overview.thanks]] -=== Acknowledgments - -pugixml could not be developed without the help from many people; some of them are listed in this section. If you've played a part in pugixml development and you can not find yourself on this list, I'm truly sorry; please <> so I can fix this. - -Thanks to *Kristen Wegner* for pugxml parser, which was used as a basis for pugixml. - -Thanks to *Neville Franks* for contributions to pugxml parser. - -Thanks to *Artyom Palvelev* for suggesting a lazy gap contraction approach. - -Thanks to *Vyacheslav Egorov* for documentation proofreading and fuzz testing. - -[[overview.license]] -=== License - -The pugixml library is distributed under the MIT license: - -.... -Copyright (c) 2006-2019 Arseny Kapoulkine - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. -.... - -This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution: - -.... -This software is based on pugixml library (https://pugixml.org). -pugixml is Copyright (C) 2006-2019 Arseny Kapoulkine. -.... - -[[install]] -== Installation - -[[install.getting]] -=== Getting pugixml - -pugixml is distributed in source form. You can either download a source distribution or clone the Git repository. - -[[install.getting.source]] -==== Source distributions - -You can download the latest source distribution as an archive: - -https://github.com/zeux/pugixml/releases/download/v{version}/pugixml-{version}.zip[pugixml-{version}.zip] (Windows line endings) -/ -https://github.com/zeux/pugixml/releases/download/v{version}/pugixml-{version}.tar.gz[pugixml-{version}.tar.gz] (Unix line endings) - -The distribution contains library source, documentation (the manual you're reading now and the quick start guide) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive. - -If you need an older version, you can download it from the https://github.com/zeux/pugixml/releases[version archive]. - -[[install.getting.git]] -==== Git repository - -The Git repository is located at https://github.com/zeux/pugixml/. There is a Git tag "v\{version\}" for each version; also there is the "latest" tag, which always points to the latest stable release. - -For example, to checkout the current version, you can use this command: - -[source,bash,subs="attributes"] ----- -git clone https://github.com/zeux/pugixml -cd pugixml -git checkout v{version} ----- - -The repository contains library source, documentation, code examples and full unit test suite. - -Use `latest` tag if you want to automatically get new versions. Use other tags if you want to switch to new versions only explicitly. Also please note that the master branch contains the work-in-progress version of the code; while this means that you can get new features and bug fixes from master without waiting for a new release, this also means that occasionally the code can be broken in some configurations. - -[[install.getting.subversion]] -==== Subversion repository - -You can access the Git repository via Subversion using https://github.com/zeux/pugixml URL. For example, to checkout the current version, you can use this command: - -[source,bash,subs="attributes"] ----- -svn checkout https://github.com/zeux/pugixml/tags/v{version} pugixml ----- - -[[install.getting.packages]] -==== Packages - -pugixml is available as a package via various package managers. Note that most packages are maintained separately from the main repository so they do not necessarily contain the latest version. - -Here's an incomplete list of pugixml packages in various systems: - -* Linux (http://packages.ubuntu.com/search?keywords=pugixml[Ubuntu], https://tracker.debian.org/pkg/pugixml[Debian], https://apps.fedoraproject.org/packages/pugixml[Fedora], https://aur.archlinux.org/packages/pugixml/[Arch Linux], other http://pkgs.org/search/pugixml[distributions]) -* http://fbsdmon.org/ports/textproc/pugixml[FreeBSD] -* OSX, via http://brewformulas.org/Pugixml[Homebrew] -* Windows, via https://www.nuget.org/packages/pugixml/[NuGet] - -[[install.building]] -=== Building pugixml - -pugixml is distributed in source form without any pre-built binaries; you have to build them yourself. - -The complete pugixml source consists of three files - one source file, `pugixml.cpp`, and two header files, `pugixml.hpp` and `pugiconfig.hpp`. `pugixml.hpp` is the primary header which you need to include in order to use pugixml classes/functions; `pugiconfig.hpp` is a supplementary configuration file (see <>). The rest of this guide assumes that `pugixml.hpp` is either in the current directory or in one of include directories of your projects, so that `#include "pugixml.hpp"` can find the header; however you can also use relative path (i.e. `#include "../libs/pugixml/src/pugixml.hpp"`) or include directory-relative path (i.e. `#include `). - -[[install.building.embed]] -==== Building pugixml as a part of another static library/executable - -The easiest way to build pugixml is to compile the source file, `pugixml.cpp`, along with the existing library/executable. This process depends on the method of building your application; for example, if you're using Microsoft Visual Studio footnote:[All trademarks used are properties of their respective owners.], Apple Xcode, Code::Blocks or any other IDE, just *add `pugixml.cpp` to one of your projects*. - -If you're using Microsoft Visual Studio and the project has precompiled headers turned on, you'll see the following error messages: - ----- -pugixml.cpp(3477) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? ----- - -The correct way to resolve this is to disable precompiled headers for `pugixml.cpp`; you have to set "Create/Use Precompiled Header" option (Properties dialog -> C/C{plus}{plus} -> Precompiled Headers -> Create/Use Precompiled Header) to "Not Using Precompiled Headers". You'll have to do it for all project configurations/platforms (you can select Configuration "All Configurations" and Platform "All Platforms" before editing the option): - -[cols="4*a",frame=none] -|=== -| image::vs2005_pch1.png[link="images/vs2005_pch1.png"] -| image::vs2005_pch2.png[link="images/vs2005_pch2.png"] -| image::vs2005_pch3.png[link="images/vs2005_pch3.png"] -| image::vs2005_pch4.png[link="images/vs2005_pch4.png"] -|=== - -[[install.building.static]] -==== Building pugixml as a standalone static library - -It's possible to compile pugixml as a standalone static library. This process depends on the method of building your application; pugixml distribution comes with project files for several popular IDEs/build systems. There are project files for Apple XCode, Code::Blocks, Codelite, Microsoft Visual Studio 2005, 2008, 2010+, and configuration scripts for CMake and premake4. You're welcome to submit project files/build scripts for other software; see <>. - -There are two projects for each version of Microsoft Visual Studio: one for dynamically linked CRT, which has a name like `pugixml_vs2008.vcproj`, and another one for statically linked CRT, which has a name like `pugixml_vs2008_static.vcproj`. You should select the version that matches the CRT used in your application; the default option for new projects created by Microsoft Visual Studio is dynamically linked CRT, so unless you changed the defaults, you should use the version with dynamic CRT (i.e. `pugixml_vs2008.vcproj` for Microsoft Visual Studio 2008). - -In addition to adding pugixml project to your workspace, you'll have to make sure that your application links with pugixml library. If you're using Microsoft Visual Studio 2005/2008, you can add a dependency from your application project to pugixml one. If you're using Microsoft Visual Studio 2010+, you'll have to add a reference to your application project instead. For other IDEs/systems, consult the relevant documentation. - -[cols="4*a",frame=none,options=header] -|=== -2+| Microsoft Visual Studio 2005/2008 -2+| Microsoft Visual Studio 2010+ -| image::vs2005_link1.png[link="images/vs2005_link1.png"] -| image::vs2005_link2.png[link="images/vs2005_link2.png"] -| image::vs2010_link1.png[link="images/vs2010_link1.png"] -| image::vs2010_link2.png[link="images/vs2010_link2.png"] -|=== - -[[install.building.shared]] -==== Building pugixml as a standalone shared library - -It's possible to compile pugixml as a standalone shared library. The process is usually similar to the static library approach; however, no preconfigured projects/scripts are included into pugixml distribution, so you'll have to do it yourself. Generally, if you're using GCC-based toolchain, the process does not differ from building any other library as DLL (adding -shared to compilation flags should suffice); if you're using MSVC-based toolchain, you'll have to explicitly mark exported symbols with a declspec attribute. You can do it by defining <> macro, i.e. via `pugiconfig.hpp`: - -[source] ----- -#ifdef _DLL - #define PUGIXML_API __declspec(dllexport) -#else - #define PUGIXML_API __declspec(dllimport) -#endif ----- - -CAUTION: If you're using STL-related functions, you should use the shared runtime library to ensure that a single heap is used for STL allocations in your application and in pugixml; in MSVC, this means selecting the 'Multithreaded DLL' or 'Multithreaded Debug DLL' to 'Runtime library' property (`/MD` or `/MDd` linker switch). You should also make sure that your runtime library choice is consistent between different projects. - -[[install.building.header]] -==== Using pugixml in header-only mode - -[[PUGIXML_HEADER_ONLY]] -It's possible to use pugixml in header-only mode. This means that all source code for pugixml will be included in every translation unit that includes `pugixml.hpp`. This is how most of Boost and STL libraries work. - -Note that there are advantages and drawbacks of this approach. Header mode may improve tree traversal/modification performance (because many simple functions will be inlined), if your compiler toolchain does not support link-time optimization, or if you have it turned off (with link-time optimization the performance should be similar to non-header mode). However, since compiler now has to compile pugixml source once for each translation unit that includes it, compilation times may increase noticeably. If you want to use pugixml in header mode but do not need XPath support, you can consider disabling it by using <> define to improve compilation time. - -To enable header-only mode, you have to define `PUGIXML_HEADER_ONLY`. You can either do it in `pugiconfig.hpp`, or provide them via compiler command-line. - -Note that it is safe to compile `pugixml.cpp` if `PUGIXML_HEADER_ONLY` is defined - so if you want to i.e. use header-only mode only in Release configuration, you -can include pugixml.cpp in your project (see <>), and conditionally enable header-only mode in `pugiconfig.hpp` like this: - -[source] ----- -#ifndef _DEBUG - #define PUGIXML_HEADER_ONLY -#endif ----- - -[[install.building.config]] -==== Additional configuration options - -pugixml uses several defines to control the compilation process. There are two ways to define them: either put the needed definitions to `pugiconfig.hpp` (it has some examples that are commented out) or provide them via compiler command-line. Consistency is important: the definitions should match in all source files that include `pugixml.hpp` (including pugixml sources) throughout the application. Adding defines to `pugiconfig.hpp` lets you guarantee this, unless your macro definition is wrapped in preprocessor `#if`/`#ifdef` directive and this directive is not consistent. `pugiconfig.hpp` will never contain anything but comments, which means that when upgrading to a new version, you can safely leave your modified version intact. - -[[PUGIXML_WCHAR_MODE]]`PUGIXML_WCHAR_MODE` define toggles between UTF-8 style interface (the in-memory text encoding is assumed to be UTF-8, most functions use `char` as character type) and UTF-16/32 style interface (the in-memory text encoding is assumed to be UTF-16/32, depending on `wchar_t` size, most functions use `wchar_t` as character type). See <> for more details. - -[[PUGIXML_COMPACT]]`PUGIXML_COMPACT` define activates a different internal representation of document storage that is much more memory efficient for documents with a lot of markup (i.e. nodes and attributes), but is slightly slower to parse and access. For details see <>. - -[[PUGIXML_NO_XPATH]]`PUGIXML_NO_XPATH` define disables XPath. Both XPath interfaces and XPath implementation are excluded from compilation. This option is provided in case you do not need XPath functionality and need to save code space. - -[[PUGIXML_NO_STL]]`PUGIXML_NO_STL` define disables use of STL in pugixml. The functions that operate on STL types are no longer present (i.e. load/save via iostream) if this macro is defined. This option is provided in case your target platform does not have a standard-compliant STL implementation. - -[[PUGIXML_NO_EXCEPTIONS]]`PUGIXML_NO_EXCEPTIONS` define disables use of exceptions in pugixml. This option is provided in case your target platform does not have exception handling capabilities. - -[[PUGIXML_API]]`PUGIXML_API`, [[PUGIXML_CLASS]]`PUGIXML_CLASS` and [[PUGIXML_FUNCTION]]`PUGIXML_FUNCTION` defines let you specify custom attributes (i.e. declspec or calling conventions) for pugixml classes and non-member functions. In absence of `PUGIXML_CLASS` or `PUGIXML_FUNCTION` definitions, `PUGIXML_API` definition is used instead. For example, to specify fixed calling convention, you can define `PUGIXML_FUNCTION` to i.e. `__fastcall`. Another example is DLL import/export attributes in MSVC (see <>). - -NOTE: In that example `PUGIXML_API` is inconsistent between several source files; this is an exception to the consistency rule. - -[[PUGIXML_MEMORY_PAGE_SIZE]]`PUGIXML_MEMORY_PAGE_SIZE`, [[PUGIXML_MEMORY_OUTPUT_STACK]]`PUGIXML_MEMORY_OUTPUT_STACK` and [[PUGIXML_MEMORY_XPATH_PAGE_SIZE]]`PUGIXML_MEMORY_XPATH_PAGE_SIZE` can be used to customize certain important sizes to optimize memory usage for the application-specific patterns. For details see <>. - -[[PUGIXML_HAS_LONG_LONG]]`PUGIXML_HAS_LONG_LONG` define enables support for `long long` type in pugixml. This define is automatically enabled if your platform is known to have `long long` support (i.e. has C{plus}{plus}11 support or uses a reasonably modern version of a known compiler); if pugixml does not recognize that your platform supports `long long` but in fact it does, you can enable the define manually. - -[[install.portability]] -=== Portability - -pugixml is written in standard-compliant C{plus}{plus} with some compiler-specific workarounds where appropriate. pugixml is compatible with the C{plus}{plus}11 standard, but does not require C{plus}{plus}11 support. Each version is tested with a unit test suite with code coverage exceeding 99%. - -pugixml runs on a variety of desktop platforms (including Microsoft Windows, Linux, FreeBSD, Apple MacOSX and Sun Solaris), game consoles (inclusing Microsoft Xbox 360, Microsoft Xbox One, Nintendo Wii, Sony Playstation Portable and Sony Playstation 3) and mobile platforms (including Android, iOS, BlackBerry, Samsung bada and Microsoft Windows CE). - -pugixml supports various architectures, such as x86/x86-64, PowerPC, ARM, MIPS and SPARC. In general it should run on any architecture since it does not use architecture-specific code and does not rely on features such as unaligned memory access. - -pugixml can be compiled using any C++ compiler; it was tested with all versions of Microsoft Visual C{plus}{plus} from 6.0 up to 2015, GCC from 3.4 up to 5.2, Clang from 3.2 up to 3.7, as well as a variety of other compilers (e.g. Borland C{plus}{plus}, Digital Mars C{plus}{plus}, Intel C{plus}{plus}, Metrowerks CodeWarrior and PathScale). The code is written to avoid compilation warnings even on reasonably high warning levels. - -Note that some platforms may have very bare-bones support of C++; in some cases you'll have to use `PUGIXML_NO_STL` and/or `PUGIXML_NO_EXCEPTIONS` to compile without issues. This mostly applies to old game consoles and embedded systems. - -[[dom]] -== Document object model - -pugixml stores XML data in DOM-like way: the entire XML document (both document structure and element data) is stored in memory as a tree. The tree can be loaded from a character stream (file, string, C{plus}{plus} I/O stream), then traversed with the special API or XPath expressions. The whole tree is mutable: both node structure and node/attribute data can be changed at any time. Finally, the result of document transformations can be saved to a character stream (file, C{plus}{plus} I/O stream or custom transport). - -[[dom.tree]] -=== Tree structure - -The XML document is represented with a tree data structure. The root of the tree is the document itself, which corresponds to C{plus}{plus} type <>. Document has one or more child nodes, which correspond to C{plus}{plus} type <>. Nodes have different types; depending on a type, a node can have a collection of child nodes, a collection of attributes, which correspond to C{plus}{plus} type <>, and some additional data (i.e. name). - -[[xml_node_type]] -The tree nodes can be of one of the following types (which together form the enumeration `xml_node_type`): - -* Document node ([[node_document]]`node_document`) - this is the root of the tree, which consists of several child nodes. This node corresponds to <> class; note that <> is a sub-class of <>, so the entire node interface is also available. However, document node is special in several ways, which are covered below. There can be only one document node in the tree; document node does not have any XML representation. Document generally has one child element node (see [[xml_document::document_element]]`document_element()`), although documents parsed from XML fragments (see [[parse_fragment]]`parse_fragment`) can have more than one. - -* Element/tag node ([[node_element]]`node_element`) - this is the most common type of node, which represents XML elements. Element nodes have a name, a collection of attributes and a collection of child nodes (both of which may be empty). The attribute is a simple name/value pair. The example XML representation of element nodes is as follows: -+ ----- - ----- -+ -There are two element nodes here: one has name `"node"`, single attribute `"attr"` and single child `"child"`, another has name `"child"` and does not have any attributes or child nodes. - -* Plain character data nodes ([[node_pcdata]]`node_pcdata`) represent plain text in XML. PCDATA nodes have a value, but do not have a name or children/attributes. Note that *plain character data is not a part of the element node but instead has its own node*; an element node can have several child PCDATA nodes. The example XML representation of text nodes is as follows: -+ ----- - text1 text2 ----- -+ -Here `"node"` element has three children, two of which are PCDATA nodes with values `" text1 "` and `" text2 "`. - -* Character data nodes ([[node_cdata]]`node_cdata`) represent text in XML that is quoted in a special way. CDATA nodes do not differ from PCDATA nodes except in XML representation - the above text example looks like this with CDATA: -+ ----- - ----- -+ -CDATA nodes make it easy to include non-escaped `<`, `&` and `>` characters in plain text. CDATA value can not contain the character sequence `]]>`, since it is used to determine the end of node contents. - -* Comment nodes ([[node_comment]]`node_comment`) represent comments in XML. Comment nodes have a value, but do not have a name or children/attributes. The example XML representation of a comment node is as follows: -+ ----- - ----- -+ -Here the comment node has value `"comment text"`. By default comment nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <> flag. - -* Processing instruction node ([[node_pi]]`node_pi`) represent processing instructions (PI) in XML. PI nodes have a name and an optional value, but do not have children/attributes. The example XML representation of a PI node is as follows: -+ ----- - ----- -+ -Here the name (also called PI target) is `"name"`, and the value is `"value"`. By default PI nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <> flag. - -* Declaration node ([[node_declaration]]`node_declaration`) represents document declarations in XML. Declaration nodes have a name (`"xml"`) and an optional collection of attributes, but do not have value or children. There can be only one declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a declaration node is as follows: -+ ----- - ----- -+ -Here the node has name `"xml"` and a single attribute with name `"version"` and value `"1.0"`. By default declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <> flag. Also, by default a dummy declaration is output when XML document is saved unless there is already a declaration in the document; you can disable this with <> flag. - -* Document type declaration node ([[node_doctype]]`node_doctype`) represents document type declarations in XML. Document type declaration nodes have a value, which corresponds to the entire document type contents; no additional nodes are created for inner elements like ``. There can be only one document type declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a document type declaration node is as follows: -+ ----- - ]> ----- -+ -Here the node has value `"greeting [ ]"`. By default document type declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with <> flag. - -Finally, here is a complete example of XML document and the corresponding tree representation (link:samples/tree.xml[]): - -[cols="2*a",frame=none] -|=== -| -[source,xml] ----- - - - - some text - - some more text - - - - - - ----- -| -image::dom_tree.png[link="images/dom_tree.png"] -|=== - -[[dom.cpp]] -=== C{plus}{plus} interface - -NOTE: All pugixml classes and functions are located in the `pugi` namespace; you have to either use explicit name qualification (i.e. `pugi::xml_node`), or to gain access to relevant symbols via `using` directive (i.e. `using pugi::xml_node;` or `using namespace pugi;`). The namespace will be omitted from all declarations in this documentation hereafter; all code examples will use fully qualified names. - -Despite the fact that there are several node types, there are only three C{plus}{plus} classes representing the tree (`xml_document`, `xml_node`, `xml_attribute`); some operations on `xml_node` are only valid for certain node types. The classes are described below. - -[[xml_document]][[xml_document::document_element]] -`xml_document` is the owner of the entire document structure; it is a non-copyable class. The interface of `xml_document` consists of loading functions (see <>), saving functions (see <>) and the entire interface of `xml_node`, which allows for document inspection and/or modification. Note that while `xml_document` is a sub-class of `xml_node`, `xml_node` is not a polymorphic type; the inheritance is present only to simplify usage. Alternatively you can use the `document_element` function to get the element node that's the immediate child of the document. - -[[xml_document::ctor]][[xml_document::dtor]][[xml_document::reset]] -Default constructor of `xml_document` initializes the document to the tree with only a root node (document node). You can then populate it with data using either tree modification functions or loading functions; all loading functions destroy the previous tree with all occupied memory, which puts existing node/attribute handles for this document to invalid state. If you want to destroy the previous tree, you can use the `xml_document::reset` function; it destroys the tree and replaces it with either an empty one or a copy of the specified document. Destructor of `xml_document` also destroys the tree, thus the lifetime of the document object should exceed the lifetimes of any node/attribute handles that point to the tree. - -CAUTION: While technically node/attribute handles can be alive when the tree they're referring to is destroyed, calling any member function for these handles results in undefined behavior. Thus it is recommended to make sure that the document is destroyed only after all references to its nodes/attributes are destroyed. - -[[xml_node]][[xml_node::type]] -`xml_node` is the handle to document node; it can point to any node in the document, including the document node itself. There is a common interface for nodes of all types; the actual <> can be queried via the `xml_node::type()` method. Note that `xml_node` is only a handle to the actual node, not the node itself - you can have several `xml_node` handles pointing to the same underlying object. Destroying `xml_node` handle does not destroy the node and does not remove it from the tree. The size of `xml_node` is equal to that of a pointer, so it is nothing more than a lightweight wrapper around a pointer; you can safely pass or return `xml_node` objects by value without additional overhead. - -[[node_null]] -There is a special value of `xml_node` type, known as null node or empty node (such nodes have type `node_null`). It does not correspond to any node in any document, and thus resembles null pointer. However, all operations are defined on empty nodes; generally the operations don't do anything and return empty nodes/attributes or empty strings as their result (see documentation for specific functions for more detailed information). This is useful for chaining calls; i.e. you can get the grandparent of a node like so: `node.parent().parent()`; if a node is a null node or it does not have a parent, the first `parent()` call returns null node; the second `parent()` call then also returns null node, which makes error handling easier. - -[[xml_attribute]] -`xml_attribute` is the handle to an XML attribute; it has the same semantics as `xml_node`, i.e. there can be several `xml_attribute` handles pointing to the same underlying object and there is a special null attribute value, which propagates to function results. - -[[xml_attribute::ctor]][[xml_node::ctor]] -Both `xml_node` and `xml_attribute` have the default constructor which initializes them to null objects. - -[[xml_attribute::comparison]][[xml_node::comparison]] -`xml_node` and `xml_attribute` try to behave like pointers, that is, they can be compared with other objects of the same type, making it possible to use them as keys in associative containers. All handles to the same underlying object are equal, and any two handles to different underlying objects are not equal. Null handles only compare as equal to null handles. The result of relational comparison can not be reliably determined from the order of nodes in file or in any other way. Do not use relational comparison operators except for search optimization (i.e. associative container keys). - -[[xml_attribute::hash_value]][[xml_node::hash_value]] -If you want to use `xml_node` or `xml_attribute` objects as keys in hash-based associative containers, you can use the `hash_value` member functions. They return the hash values that are guaranteed to be the same for all handles to the same underlying object. The hash value for null handles is 0. Note that hash value does not depend on the content of the node, only on the location of the underlying structure in memory - this means that loading the same document twice will likely produce different hash values, and copying the node will not preserve the hash. - -[[xml_attribute::unspecified_bool_type]][[xml_node::unspecified_bool_type]][[xml_attribute::empty]][[xml_node::empty]] -Finally handles can be implicitly cast to boolean-like objects, so that you can test if the node/attribute is empty with the following code: `if (node) { ... }` or `if (!node) { ... } else { ... }`. Alternatively you can check if a given `xml_node`/`xml_attribute` handle is null by calling the following methods: - -[source] ----- -bool xml_attribute::empty() const; -bool xml_node::empty() const; ----- - -Nodes and attributes do not exist without a document tree, so you can't create them without adding them to some document. Once underlying node/attribute objects are destroyed, the handles to those objects become invalid. While this means that destruction of the entire tree invalidates all node/attribute handles, it also means that destroying a subtree (by calling <>) or removing an attribute invalidates the corresponding handles. There is no way to check handle validity; you have to ensure correctness through external mechanisms. - -[[dom.unicode]] -=== Unicode interface - -There are two choices of interface and internal representation when configuring pugixml: you can either choose the UTF-8 (also called char) interface or UTF-16/32 (also called wchar_t) one. The choice is controlled via <> define; you can set it via `pugiconfig.hpp` or via preprocessor options, as discussed in <>. If this define is set, the wchar_t interface is used; otherwise (by default) the char interface is used. The exact wide character encoding is assumed to be either UTF-16 or UTF-32 and is determined based on the size of `wchar_t` type. - -NOTE: If the size of `wchar_t` is 2, pugixml assumes UTF-16 encoding instead of UCS-2, which means that some characters are represented as two code points. - -All tree functions that work with strings work with either C-style null terminated strings or STL strings of the selected character type. For example, node name accessors look like this in char mode: - -[source] ----- -const char* xml_node::name() const; -bool xml_node::set_name(const char* value); ----- - -and like this in wchar_t mode: - -[source] ----- -const wchar_t* xml_node::name() const; -bool xml_node::set_name(const wchar_t* value); ----- - -[[char_t]][[string_t]] -There is a special type, `pugi::char_t`, that is defined as the character type and depends on the library configuration; it will be also used in the documentation hereafter. There is also a type `pugi::string_t`, which is defined as the STL string of the character type; it corresponds to `std::string` in char mode and to `std::wstring` in wchar_t mode. - -In addition to the interface, the internal implementation changes to store XML data as `pugi::char_t`; this means that these two modes have different memory usage characteristics - generally UTF-8 mode is more memory and performance efficient, especially if `sizeof(wchar_t)` is 4. The conversion to `pugi::char_t` upon document loading and from `pugi::char_t` upon document saving happen automatically, which also carries minor performance penalty. The general advice however is to select the character mode based on usage scenario, i.e. if UTF-8 is inconvenient to process and most of your XML data is non-ASCII, wchar_t mode is probably a better choice. - -[[as_utf8]][[as_wide]] -There are cases when you'll have to convert string data between UTF-8 and wchar_t encodings; the following helper functions are provided for such purposes: - -[source] ----- -std::string as_utf8(const wchar_t* str); -std::wstring as_wide(const char* str); ----- - -Both functions accept a null-terminated string as an argument `str`, and return the converted string. `as_utf8` performs conversion from UTF-16/32 to UTF-8; `as_wide` performs conversion from UTF-8 to UTF-16/32. Invalid UTF sequences are silently discarded upon conversion. `str` has to be a valid string; passing null pointer results in undefined behavior. There are also two overloads with the same semantics which accept a string as an argument: - -[source] ----- -std::string as_utf8(const std::wstring& str); -std::wstring as_wide(const std::string& str); ----- - -[NOTE] -==== -Most examples in this documentation assume char interface and therefore will not compile with <>. This is done to simplify the documentation; usually the only changes you'll have to make is to pass `wchar_t` string literals, i.e. instead of - -`xml_node node = doc.child("bookstore").find_child_by_attribute("book", "id", "12345");` - -you'll have to use - -`xml_node node = doc.child(L"bookstore").find_child_by_attribute(L"book", L"id", L"12345");` -==== - -[[dom.thread]] -=== Thread-safety guarantees - -Almost all functions in pugixml have the following thread-safety guarantees: - -* it is safe to call free (non-member) functions from multiple threads -* it is safe to perform concurrent read-only accesses to the same tree (all constant member functions do not modify the tree) -* it is safe to perform concurrent read/write accesses, if there is only one read or write access to the single tree at a time - -Concurrent modification and traversing of a single tree requires synchronization, for example via reader-writer lock. Modification includes altering document structure and altering individual node/attribute data, i.e. changing names/values. - -The only exception is <>; it modifies global variables and as such is not thread-safe. Its usage policy has more restrictions, see <>. - -[[dom.exception]] -=== Exception guarantees - -With the exception of XPath, pugixml itself does not throw any exceptions. Additionally, most pugixml functions have a no-throw exception guarantee. - -This is not applicable to functions that operate on STL strings or IOstreams; such functions have either strong guarantee (functions that operate on strings) or basic guarantee (functions that operate on streams). Also functions that call user-defined callbacks (i.e. <> or <>) do not provide any exception guarantees beyond the ones provided by the callback. - -If exception handling is not disabled with <> define, XPath functions may throw <> on parsing errors; also, XPath functions may throw `std::bad_alloc` in low memory conditions. Still, XPath functions provide strong exception guarantee. - -[[dom.memory]] -=== Memory management - -pugixml requests the memory needed for document storage in big chunks, and allocates document data inside those chunks. This section discusses replacing functions used for chunk allocation and internal memory management implementation. - -[[dom.memory.custom]] -==== Custom memory allocation/deallocation functions - -[[allocation_function]][[deallocation_function]] -All memory for tree structure, tree data and XPath objects is allocated via globally specified functions, which default to malloc/free. You can set your own allocation functions with set_memory_management function. The function interfaces are the same as that of malloc/free: - -[source] ----- -typedef void* (*allocation_function)(size_t size); -typedef void (*deallocation_function)(void* ptr); ----- - -[[set_memory_management_functions]][[get_memory_allocation_function]][[get_memory_deallocation_function]] -You can use the following accessor functions to change or get current memory management functions: - -[source] ----- -void set_memory_management_functions(allocation_function allocate, deallocation_function deallocate); -allocation_function get_memory_allocation_function(); -deallocation_function get_memory_deallocation_function(); ----- - -Allocation function is called with the size (in bytes) as an argument and should return a pointer to a memory block with alignment that is suitable for storage of primitive types (usually a maximum of `void*` and `double` types alignment is sufficient) and size that is greater than or equal to the requested one. If the allocation fails, the function has to either return null pointer or to throw an exception. - -Deallocation function is called with the pointer that was returned by some call to allocation function; it is never called with a null pointer. If memory management functions are not thread-safe, library thread safety is not guaranteed. - -This is a simple example of custom memory management (link:samples/custom_memory_management.cpp[]): - -[source,indent=0] ----- -include::samples/custom_memory_management.cpp[tags=decl] ----- -[source,indent=0] ----- -include::samples/custom_memory_management.cpp[tags=call] ----- - -When setting new memory management functions, care must be taken to make sure that there are no live pugixml objects. Otherwise when the objects are destroyed, the new deallocation function will be called with the memory obtained by the old allocation function, resulting in undefined behavior. - -[[dom.memory.tuning]] -==== Memory consumption tuning - -There are several important buffering optimizations in pugixml that rely on predefined constants. These constants have default values that were tuned for common usage patterns; for some applications, changing these constants might improve memory consumption or increase performance. Changing these constants is not recommended unless their default values result in visible problems. - -These constants can be tuned via configuration defines, as discussed in <>; it is recommended to set them in `pugiconfig.hpp`. - -* `PUGIXML_MEMORY_PAGE_SIZE` controls the page size for document memory allocation. Memory for node/attribute objects is allocated in pages of the specified size. The default size is 32 Kb; for some applications the size is too large (i.e. embedded systems with little heap space or applications that keep lots of XML documents in memory). A minimum size of 1 Kb is recommended. - -* `PUGIXML_MEMORY_OUTPUT_STACK` controls the cumulative stack space required to output the node. Any output operation (i.e. saving a subtree to file) uses an internal buffering scheme for performance reasons. The default size is 10 Kb; if you're using node output from threads with little stack space, decreasing this value can prevent stack overflows. A minimum size of 1 Kb is recommended. - -* `PUGIXML_MEMORY_XPATH_PAGE_SIZE` controls the page size for XPath memory allocation. Memory for XPath query objects as well as internal memory for XPath evaluation is allocated in pages of the specified size. The default size is 4 Kb; if you have a lot of resident XPath query objects, you might need to decrease the size to improve memory consumption. A minimum size of 256 bytes is recommended. - -[[dom.memory.internals]] -==== Document memory management internals - -Constructing a document object using the default constructor does not result in any allocations; document node is stored inside the <> object. - -When the document is loaded from file/buffer, unless an inplace loading function is used (see <>), a complete copy of character stream is made; all names/values of nodes and attributes are allocated in this buffer. This buffer is allocated via a single large allocation and is only freed when document memory is reclaimed (i.e. if the <> object is destroyed or if another document is loaded in the same object). Also when loading from file or stream, an additional large allocation may be performed if encoding conversion is required; a temporary buffer is allocated, and it is freed before load function returns. - -All additional memory, such as memory for document structure (node/attribute objects) and memory for node/attribute names/values is allocated in pages on the order of 32 Kb; actual objects are allocated inside the pages using a memory management scheme optimized for fast allocation/deallocation of many small objects. Because of the scheme specifics, the pages are only destroyed if all objects inside them are destroyed; also, generally destroying an object does not mean that subsequent object creation will reuse the same memory. This means that it is possible to devise a usage scheme which will lead to higher memory usage than expected; one example is adding a lot of nodes, and them removing all even numbered ones; not a single page is reclaimed in the process. However this is an example specifically crafted to produce unsatisfying behavior; in all practical usage scenarios the memory consumption is less than that of a general-purpose allocator because allocation meta-data is very small in size. - -[[dom.memory.compact]] -==== Compact mode - -By default nodes and attributes are optimized for efficiency of access. This can cause them to take a significant amount of memory - for documents with a lot of nodes and not a lot of contents (short attribute values/node text), and depending on the pointer size, the document structure can take noticeably more memory than the document itself (e.g. on a 64-bit platform in UTF-8 mode a markup-heavy document with the file size of 2.1 Mb can use 2.1 Mb for document buffer and 8.3 Mb for document structure). - -If you are processing big documents or your platform is memory constrained and you're willing to sacrifice a bit of performance for memory, you can compile pugixml with `PUGIXML_COMPACT` define which will activate compact mode. Compact mode uses a different representation of the document structure that assumes locality of reference between nodes and attributes to optimize memory usage. As a result you get significantly smaller node/attribute objects; usually most objects in most documents don't require additional storage, but in the worst case - if assumptions about locality of reference don't hold - additional memory will be allocated to store the extra data required. - -The compact storage supports all existing operations - including tree modification - with the same amortized complexity (that is, all basic document manipulations are still O(1) on average). The operations are slightly slower; you can usually expect 10-50% slowdown in terms of processing time unless your processing was memory-bound. - -On 32-bit architectures document structure in compact mode is typically reduced by around 2.5x; on 64-bit architectures the ratio is around 5x. Thus for big markup-heavy documents compact mode can make the difference between the processing of a multi-gigabyte document running completely from RAM vs requiring swapping to disk. Even if the document fits into memory, compact storage can use CPU caches more efficiently by taking less space and causing less cache/TLB misses. - -[[loading]] -== Loading document - -pugixml provides several functions for loading XML data from various places - files, C{plus}{plus} iostreams, memory buffers. All functions use an extremely fast non-validating parser. This parser is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed for performance reasons. Also some XML transformations (i.e. EOL handling or attribute value normalization) can impact parsing speed and thus can be disabled. However for vast majority of XML documents there is no performance difference between different parsing options. Parsing options also control whether certain XML nodes are parsed; see <> for more information. - -XML data is always converted to internal character format (see <>) before parsing. pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it's a strict subset of UTF-16) as well as some non-Unicode encodings (Latin-1) and handles all encoding conversions automatically. Unless explicit encoding is specified, loading functions perform automatic encoding detection based on source XML data, so in most cases you do not have to specify document encoding. Encoding conversion is described in more detail in <>. - -[[loading.file]] -=== Loading document from file - -[[xml_document::load_file]][[xml_document::load_file_wide]] -The most common source of XML data is files; pugixml provides dedicated functions for loading an XML document from file: - -[source] ----- -xml_parse_result xml_document::load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); -xml_parse_result xml_document::load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); ----- - -These functions accept the file path as its first argument, and also two optional arguments, which specify parsing options (see <>) and input data encoding (see <>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc. - -File path is passed to the system file opening function as is in case of the first function (which accepts `const char* path`); the second function either uses a special file opening function if it is provided by the runtime library or converts the path to UTF-8 and uses the system file opening function. - -`load_file` destroys the existing document tree and then tries to load the new tree from the specified file. The result of the operation is returned in an <> object; this object contains the operation status and the related information (i.e. last successfully parsed position in the input file, if parsing fails). See <> for error handling details. - -This is an example of loading XML document from file (link:samples/load_file.cpp[]): - -[source,indent=0] ----- -include::samples/load_file.cpp[tags=code] ----- - -[[loading.memory]] -=== Loading document from memory - -[[xml_document::load_buffer]][[xml_document::load_buffer_inplace]][[xml_document::load_buffer_inplace_own]] -Sometimes XML data should be loaded from some other source than a file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from GZip-compressed files. All these scenarios require loading document from memory. First you should prepare a contiguous memory block with all XML data; then you have to invoke one of buffer loading functions. These functions will handle the necessary encoding conversions, if any, and then will parse the data into the corresponding XML tree. There are several buffer loading functions, which differ in the behavior and thus in performance/memory usage: - -[source] ----- -xml_parse_result xml_document::load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); -xml_parse_result xml_document::load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); -xml_parse_result xml_document::load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); ----- - -All functions accept the buffer which is represented by a pointer to XML data, `contents`, and data size in bytes. Also there are two optional arguments, which specify parsing options (see <>) and input data encoding (see <>). The buffer does not have to be zero-terminated. - -`load_buffer` function works with immutable buffer - it does not ever modify the buffer. Because of this restriction it has to create a private buffer and copy XML data to it before parsing (applying encoding conversions if necessary). This copy operation carries a performance penalty, so inplace functions are provided - `load_buffer_inplace` and `load_buffer_inplace_own` store the document data in the buffer, modifying it in the process. In order for the document to stay valid, you have to make sure that the buffer's lifetime exceeds that of the tree if you're using inplace functions. In addition to that, `load_buffer_inplace` does not assume ownership of the buffer, so you'll have to destroy it yourself; `load_buffer_inplace_own` assumes ownership of the buffer and destroys it once it is not needed. This means that if you're using `load_buffer_inplace_own`, you have to allocate memory with pugixml allocation function (you can get it via <>). - -The best way from the performance/memory point of view is to load document using `load_buffer_inplace_own`; this function has maximum control of the buffer with XML data so it is able to avoid redundant copies and reduce peak memory usage while parsing. This is the recommended function if you have to load the document from memory and performance is critical. - -[[xml_document::load_string]] -There is also a simple helper function for cases when you want to load the XML document from null-terminated character string: - -[source] ----- -xml_parse_result xml_document::load_string(const char_t* contents, unsigned int options = parse_default); ----- - -It is equivalent to calling `load_buffer` with `size` being either `strlen(contents)` or `wcslen(contents) * sizeof(wchar_t)`, depending on the character type. This function assumes native encoding for input data, so it does not do any encoding conversion. In general, this function is fine for loading small documents from string literals, but has more overhead and less functionality than the buffer loading functions. - -This is an example of loading XML document from memory using different functions (link:samples/load_memory.cpp[]): - -[source,indent=0] ----- -include::samples/load_memory.cpp[tags=decl] ----- -[source,indent=0] ----- -include::samples/load_memory.cpp[tags=load_buffer] ----- -[source,indent=0] ----- -include::samples/load_memory.cpp[tags=load_buffer_inplace_begin] - -include::samples/load_memory.cpp[tags=load_buffer_inplace_end] ----- -[source,indent=0] ----- -include::samples/load_memory.cpp[tags=load_buffer_inplace_own] ----- -[source,indent=0] ----- -include::samples/load_memory.cpp[tags=load_string] ----- - -[[loading.stream]] -=== Loading document from C{plus}{plus} IOstreams - -[[xml_document::load_stream]] -To enhance interoperability, pugixml provides functions for loading document from any object which implements C{plus}{plus} `std::istream` interface. This allows you to load documents from any standard C{plus}{plus} stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). There are two functions, one works with narrow character streams, another handles wide character ones: - -[source] ----- -xml_parse_result xml_document::load(std::istream& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); -xml_parse_result xml_document::load(std::wistream& stream, unsigned int options = parse_default); ----- - -`load` with `std::istream` argument loads the document from stream from the current read position to the end, treating the stream contents as a byte stream of the specified encoding (with encoding autodetection as necessary). Thus calling `xml_document::load` on an opened `std::ifstream` object is equivalent to calling `xml_document::load_file`. - -`load` with `std::wstream` argument treats the stream contents as a wide character stream (encoding is always <>). Because of this, using `load` with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the `imbue` function). Generally use of wide streams is discouraged, however it provides you the ability to load documents from non-Unicode encodings, i.e. you can load Shift-JIS encoded data if you set the correct locale. - -This is a simple example of loading XML document from file using streams (link:samples/load_stream.cpp[]); read the sample code for more complex examples involving wide streams and locales: - -[source,indent=0] ----- -include::samples/load_stream.cpp[tags=code] ----- - -[[loading.errors]] -=== Handling parsing errors - -[[xml_parse_result]] -All document loading functions return the parsing result via `xml_parse_result` object. It contains parsing status, the offset of last successfully parsed character from the beginning of the source stream, and the encoding of the source stream: - -[source] ----- -struct xml_parse_result -{ - xml_parse_status status; - ptrdiff_t offset; - xml_encoding encoding; - - operator bool() const; - const char* description() const; -}; ----- - -[[xml_parse_status]][[xml_parse_result::status]] -Parsing status is represented as the `xml_parse_status` enumeration and can be one of the following: - -* [[status_ok]]`status_ok` means that no error was encountered during parsing; the source stream represents the valid XML document which was fully parsed and converted to a tree. - -* [[status_file_not_found]]`status_file_not_found` is only returned by `load_file` function and means that file could not be opened. -* [[status_io_error]]`status_io_error` is returned by `load_file` function and by `load` functions with `std::istream`/`std::wstream` arguments; it means that some I/O error has occurred during reading the file/stream. -* [[status_out_of_memory]]`status_out_of_memory` means that there was not enough memory during some allocation; any allocation failure during parsing results in this error. -* [[status_internal_error]]`status_internal_error` means that something went horribly wrong; currently this error does not occur - -* [[status_unrecognized_tag]]`status_unrecognized_tag` means that parsing stopped due to a tag with either an empty name or a name which starts with incorrect character, such as `#`. -* [[status_bad_pi]]`status_bad_pi` means that parsing stopped due to incorrect document declaration/processing instruction -* [[status_bad_comment]]`status_bad_comment`, [[status_bad_cdata]]`status_bad_cdata`, [[status_bad_doctype]]`status_bad_doctype` and [[status_bad_pcdata]]`status_bad_pcdata` mean that parsing stopped due to the invalid construct of the respective type -* [[status_bad_start_element]]`status_bad_start_element` means that parsing stopped because starting tag either had no closing `>` symbol or contained some incorrect symbol -* [[status_bad_attribute]]`status_bad_attribute` means that parsing stopped because there was an incorrect attribute, such as an attribute without value or with value that is not quoted (note that `` is incorrect in XML) -* [[status_bad_end_element]]`status_bad_end_element` means that parsing stopped because ending tag had incorrect syntax (i.e. extra non-whitespace symbols between tag name and `>`) -* [[status_end_element_mismatch]]`status_end_element_mismatch` means that parsing stopped because the closing tag did not match the opening one (i.e. ``) or because some tag was not closed at all -* [[status_no_document_element]]`status_no_document_element` means that no element nodes were discovered during parsing; this usually indicates an empty or invalid document - -[[xml_parse_result::description]] -`description()` member function can be used to convert parsing status to a string; the returned message is always in English, so you'll have to write your own function if you need a localized string. However please note that the exact messages returned by `description()` function may change from version to version, so any complex status handling should be based on `status` value. Note that `description()` returns a `char` string even in `PUGIXML_WCHAR_MODE`; you'll have to call <> to get the `wchar_t` string. - -If parsing failed because the source data was not a valid XML, the resulting tree is not destroyed - despite the fact that load function returns error, you can use the part of the tree that was successfully parsed. Obviously, the last element may have an unexpected name/value; for example, if the attribute value does not end with the necessary quotation mark, like in `>) is to be put in DOM tree. If this flag is off, it is not put in the tree, but is still parsed and checked for correctness. This flag is *off* by default. - -* [[parse_doctype]]`parse_doctype` determines if XML document type declaration (node with type <>) is to be put in DOM tree. If this flag is off, it is not put in the tree, but is still parsed and checked for correctness. This flag is *off* by default. - -* [[parse_pi]]`parse_pi` determines if processing instructions (nodes with type <>) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. Note that `` (document declaration) is not considered to be a PI. This flag is *off* by default. - -* [[parse_comments]]`parse_comments` determines if comments (nodes with type <>) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. This flag is *off* by default. - -* [[parse_cdata]]`parse_cdata` determines if CDATA sections (nodes with type <>) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. This flag is *on* by default. - -* [[parse_trim_pcdata]]`parse_trim_pcdata` determines if leading and trailing whitespace characters are to be removed from PCDATA nodes. While for some applications leading/trailing whitespace is significant, often the application only cares about the non-whitespace contents so it's easier to trim whitespace from text during parsing. This flag is *off* by default. - -* [[parse_ws_pcdata]]`parse_ws_pcdata` determines if PCDATA nodes (nodes with type <>) that consist only of whitespace characters are to be put in DOM tree. Often whitespace-only data is not significant for the application, and the cost of allocating and storing such nodes (both memory and speed-wise) can be significant. For example, after parsing XML string ` `, `` element will have three children when `parse_ws_pcdata` is set (child with type <> and value `" "`, child with type <> and name `"a"`, and another child with type <> and value `" "`), and only one child when `parse_ws_pcdata` is not set. This flag is *off* by default. - -* [[parse_ws_pcdata_single]]`parse_ws_pcdata_single` determines if whitespace-only PCDATA nodes that have no sibling nodes are to be put in DOM tree. In some cases application needs to parse the whitespace-only contents of nodes, i.e. ` `, but is not interested in whitespace markup elsewhere. It is possible to use <> flag in this case, but it results in excessive allocations and complicates document processing; this flag can be used to avoid that. As an example, after parsing XML string ` ` with `parse_ws_pcdata_single` flag set, `` element will have one child ``, and `` element will have one child with type <> and value `" "`. This flag has no effect if <> is enabled. This flag is *off* by default. - -* [[parse_embed_pcdata]]`parse_embed_pcdata` determines if PCDATA contents is to be saved as element values. Normally element nodes have names but not values; this flag forces the parser to store the contents as a value if PCDATA is the first child of the element node (otherwise PCDATA node is created as usual). This can significantly reduce the memory required for documents with many PCDATA nodes. To retrieve the data you can use `xml_node::value()` on the element nodes or any of the higher-level functions like `child_value` or `text`. This flag is *off* by default. -Since this flag significantly changes the DOM structure it is only recommended for parsing documents with many PCDATA nodes in memory-constrained environments. This flag is *off* by default. - -* [[parse_fragment]]`parse_fragment` determines if document should be treated as a fragment of a valid XML. Parsing document as a fragment leads to top-level PCDATA content (i.e. text that is not located inside a node) to be added to a tree, and additionally treats documents without element nodes as valid and permits multiple top-level element nodes. This flag is *off* by default. - -CAUTION: Using in-place parsing (<>) with `parse_fragment` flag may result in the loss of the last character of the buffer if it is a part of PCDATA. Since PCDATA values are null-terminated strings, the only way to resolve this is to provide a null-terminated buffer as an input to `load_buffer_inplace` - i.e. `doc.load_buffer_inplace("test\0", 5, pugi::parse_default | pugi::parse_fragment)`. - -These flags control the transformation of tree element contents: - -* [[parse_escapes]]`parse_escapes` determines if character and entity references are to be expanded during the parsing process. Character references have the form `&#...;` or `&#x...;` (`...` is Unicode numeric representation of character in either decimal (`&#...;`) or hexadecimal (`&#x...;`) form), entity references are `&lt;`, `&gt;`, `&amp;`, `&apos;` and `&quot;` (note that as pugixml does not handle DTD, the only allowed entities are predefined ones). If character/entity reference can not be expanded, it is left as is, so you can do additional processing later. Reference expansion is performed on attribute values and PCDATA content. This flag is *on* by default. - -* [[parse_eol]]`parse_eol` determines if EOL handling (that is, replacing sequences `\r\n` by a single `\n` character, and replacing all standalone `\r` characters by `\n`) is to be performed on input data (that is, comment contents, PCDATA/CDATA contents and attribute values). This flag is *on* by default. - -* [[parse_wconv_attribute]]`parse_wconv_attribute` determines if attribute value normalization should be performed for all attributes. This means, that whitespace characters (new line, tab and space) are replaced with space (`' '`). New line characters are always treated as if <> is set, i.e. `\r\n` is converted to a single space. This flag is *on* by default. - -* [[parse_wnorm_attribute]]`parse_wnorm_attribute` determines if extended attribute value normalization should be performed for all attributes. This means, that after attribute values are normalized as if <> was set, leading and trailing space characters are removed, and all sequences of space characters are replaced by a single space character. <> has no effect if this flag is on. This flag is *off* by default. - -NOTE: `parse_wconv_attribute` option performs transformations that are required by W3C specification for attributes that are declared as CDATA; <> performs transformations required for NMTOKENS attributes. In the absence of document type declaration all attributes should behave as if they are declared as CDATA, thus <> is the default option. - -Additionally there are three predefined option masks: - -* [[parse_minimal]]`parse_minimal` has all options turned off. This option mask means that pugixml does not add declaration nodes, document type declaration nodes, PI nodes, CDATA sections and comments to the resulting tree and does not perform any conversion for input data, so theoretically it is the fastest mode. However, as mentioned above, in practice <> is usually equally fast. - -* [[parse_default]]`parse_default` is the default set of flags, i.e. it has all options set to their default values. It includes parsing CDATA sections (comments/PIs are not parsed), performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed (by default) for performance reasons. - -* [[parse_full]]`parse_full` is the set of flags which adds nodes of all types to the resulting tree and performs default conversions for input data. It includes parsing CDATA sections, comments, PI nodes, document declaration node and document type declaration node, performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed in this mode. - -This is an example of using different parsing options (link:samples/load_options.cpp[]): - -[source,indent=0] ----- -include::samples/load_options.cpp[tags=code] ----- - -[[loading.encoding]] -=== Encodings - -[[xml_encoding]] -pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it's a strict subset of UTF-16) as well as some non-Unicode encodings (Latin-1) and handles all encoding conversions. Most loading functions accept the optional parameter `encoding`. This is a value of enumeration type `xml_encoding`, that can have the following values: - -* [[encoding_auto]]`encoding_auto` means that pugixml will try to guess the encoding based on source XML data. The algorithm is a modified version of the one presented in http://www.w3.org/TR/REC-xml/#sec-guessing[Appendix F of XML recommendation]. It tries to find a Byte Order Mark of one of the supported encodings first; if that fails, it checks if the first few bytes of the input data look like a representation of `<` or `> for XPath reference. As discussed in <>, there are two types of handles to tree data - <> and <>. The handles have special null (empty) values which propagate through various functions and thus are useful for writing more concise code; see <> for details. The documentation in this section will explicitly state the results of all function in case of null inputs. - -[import samples/traverse_base.cpp] - -[[access.basic]] -=== Basic traversal functions - -[[xml_node::parent]][[xml_node::first_child]][[xml_node::last_child]][[xml_node::next_sibling]][[xml_node::previous_sibling]][[xml_node::first_attribute]][[xml_node::last_attribute]][[xml_attribute::next_attribute]][[xml_attribute::previous_attribute]] -The internal representation of the document is a tree, where each node has a list of child nodes (the order of children corresponds to their order in the XML representation), and additionally element nodes have a list of attributes, which is also ordered. Several functions are provided in order to let you get from one node in the tree to the other. These functions roughly correspond to the internal representation, and thus are usually building blocks for other methods of traversing (i.e. XPath traversals are based on these functions). - -[source] ----- -xml_node xml_node::parent() const; -xml_node xml_node::first_child() const; -xml_node xml_node::last_child() const; -xml_node xml_node::next_sibling() const; -xml_node xml_node::previous_sibling() const; - -xml_attribute xml_node::first_attribute() const; -xml_attribute xml_node::last_attribute() const; -xml_attribute xml_attribute::next_attribute() const; -xml_attribute xml_attribute::previous_attribute() const; ----- - -`parent` function returns the node's parent; all non-null nodes except the document have non-null parent. `first_child` and `last_child` return the first and last child of the node, respectively; note that only document nodes and element nodes can have non-empty child node list. If node has no children, both functions return null nodes. `next_sibling` and `previous_sibling` return the node that's immediately to the right/left of this node in the children list, respectively - for example, in ``, calling `next_sibling` for a handle that points to `` results in a handle pointing to ``, and calling `previous_sibling` results in handle pointing to ``. If node does not have next/previous sibling (this happens if it is the last/first node in the list, respectively), the functions return null nodes. `first_attribute`, `last_attribute`, `next_attribute` and `previous_attribute` functions behave similarly to the corresponding child node functions and allow to iterate through attribute list in the same way. - -NOTE: Because of memory consumption reasons, attributes do not have a link to their parent nodes. Thus there is no `xml_attribute::parent()` function. - -Calling any of the functions above on the null handle results in a null handle - i.e. `node.first_child().next_sibling()` returns the second child of `node`, and null handle if `node` is null, has no children at all or if it has only one child node. - -With these functions, you can iterate through all child nodes and display all attributes like this (link:samples/traverse_base.cpp[]): - -[source,indent=0] ----- -include::samples/traverse_base.cpp[tags=basic] ----- - -[[access.nodedata]] -=== Getting node data - -[[xml_node::name]][[xml_node::value]] -Apart from structural information (parent, child nodes, attributes), nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. <> nodes do not have a name or value, <> and <> nodes always have a name but never have a value, <>, <>, <> and <> nodes never have a name but always have a value (it may be empty though), <> nodes always have a name and a value (again, value may be empty). In order to get node's name or value, you can use the following functions: - -[source] ----- -const char_t* xml_node::name() const; -const char_t* xml_node::value() const; ----- - -In case node does not have a name or value or if the node handle is null, both functions return empty strings - they never return null pointers. - -[[xml_node::child_value]] -It is common to store data as text contents of some node - i.e. `This is a node`. In this case, `` node does not have a value, but instead has a child of type <> with value `"This is a node"`. pugixml provides several helper functions to parse such data: - -[source] ----- -const char_t* xml_node::child_value() const; -const char_t* xml_node::child_value(const char_t* name) const; -xml_text xml_node::text() const; ----- - -`child_value()` returns the value of the first child with type <> or <>; `child_value(name)` is a simple wrapper for `child(name).child_value()`. For the above example, calling `node.child_value("description")` and `description.child_value()` will both produce string `"This is a node"`. If there is no child with relevant type, or if the handle is null, `child_value` functions return empty string. - -`text()` returns a special object that can be used for working with PCDATA contents in more complex cases than just retrieving the value; it is described in <> sections. - -There is an example of using some of these functions <>. - -[[access.attrdata]] -=== Getting attribute data - -[[xml_attribute::name]][[xml_attribute::value]] -All attributes have name and value, both of which are strings (value may be empty). There are two corresponding accessors, like for `xml_node`: - -[source] ----- -const char_t* xml_attribute::name() const; -const char_t* xml_attribute::value() const; ----- - -In case the attribute handle is null, both functions return empty strings - they never return null pointers. - -[[xml_attribute::as_string]] -If you need a non-empty string if the attribute handle is null (for example, you need to get the option value from XML attribute, but if it is not specified, you need it to default to `"sorted"` instead of `""`), you can use `as_string` accessor: - -[source] ----- -const char_t* xml_attribute::as_string(const char_t* def = "") const; ----- - -It returns `def` argument if the attribute handle is null. If you do not specify the argument, the function is equivalent to `value()`. - -[[xml_attribute::as_int]][[xml_attribute::as_uint]][[xml_attribute::as_double]][[xml_attribute::as_float]][[xml_attribute::as_bool]][[xml_attribute::as_llong]][[xml_attribute::as_ullong]] -In many cases attribute values have types that are not strings - i.e. an attribute may always contain values that should be treated as integers, despite the fact that they are represented as strings in XML. pugixml provides several accessors that convert attribute value to some other type: - -[source] ----- -int xml_attribute::as_int(int def = 0) const; -unsigned int xml_attribute::as_uint(unsigned int def = 0) const; -double xml_attribute::as_double(double def = 0) const; -float xml_attribute::as_float(float def = 0) const; -bool xml_attribute::as_bool(bool def = false) const; -long long xml_attribute::as_llong(long long def = 0) const; -unsigned long long xml_attribute::as_ullong(unsigned long long def = 0) const; ----- - -`as_int`, `as_uint`, `as_llong`, `as_ullong`, `as_double` and `as_float` convert attribute values to numbers. If attribute handle is null `def` argument is returned (which is 0 by default). Otherwise, all leading whitespace characters are truncated, and the remaining string is parsed as an integer number in either decimal or hexadecimal form (applicable to `as_int`, `as_uint`, `as_llong` and `as_ullong`; hexadecimal format is used if the number has `0x` or `0X` prefix) or as a floating point number in either decimal or scientific form (`as_double` or `as_float`). - -In case the input string contains a non-numeric character sequence or a number that is out of the target numeric range, the result is undefined. - -CAUTION: Number conversion functions depend on current C locale as set with `setlocale`, so may return unexpected results if the locale is different from `"C"`. - -`as_bool` converts attribute value to boolean as follows: if attribute handle is null, `def` argument is returned (which is `false` by default). If attribute value is empty, `false` is returned. Otherwise, `true` is returned if the first character is one of `'1', 't', 'T', 'y', 'Y'`. This means that strings like `"true"` and `"yes"` are recognized as `true`, while strings like `"false"` and `"no"` are recognized as `false`. For more complex matching you'll have to write your own function. - -NOTE: `as_llong` and `as_ullong` are only available if your platform has reliable support for the `long long` type, including string conversions. - -[[code_traverse_base_data]] -This is an example of using these functions, along with node data retrieval ones (link:samples/traverse_base.cpp[]): - -[source,indent=0] ----- -include::samples/traverse_base.cpp[tags=data] ----- - -[[access.contents]] -=== Contents-based traversal functions - -[[xml_node::child]][[xml_node::attribute]][[xml_node::next_sibling_name]][[xml_node::previous_sibling_name]] -Since a lot of document traversal consists of finding the node/attribute with the correct name, there are special functions for that purpose: - -[source] ----- -xml_node xml_node::child(const char_t* name) const; -xml_attribute xml_node::attribute(const char_t* name) const; -xml_node xml_node::next_sibling(const char_t* name) const; -xml_node xml_node::previous_sibling(const char_t* name) const; ----- - -`child` and `attribute` return the first child/attribute with the specified name; `next_sibling` and `previous_sibling` return the first sibling in the corresponding direction with the specified name. All string comparisons are case-sensitive. In case the node handle is null or there is no node/attribute with the specified name, null handle is returned. - -`child` and `next_sibling` functions can be used together to loop through all child nodes with the desired name like this: - -[source] ----- -for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool")) ----- - -[[xml_node::find_child_by_attribute]] -Occasionally the needed node is specified not by the unique name but instead by the value of some attribute; for example, it is common to have node collections with each node having a unique id: ` `. There are two functions for finding child nodes based on the attribute values: - -[source] ----- -xml_node xml_node::find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const; -xml_node xml_node::find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const; ----- - -The three-argument function returns the first child node with the specified name which has an attribute with the specified name/value; the two-argument function skips the name test for the node, which can be useful for searching in heterogeneous collections. If the node handle is null or if no node is found, null handle is returned. All string comparisons are case-sensitive. - -In all of the above functions, all arguments have to be valid strings; passing null pointers results in undefined behavior. - -This is an example of using these functions (link:samples/traverse_base.cpp[]): - -[source,indent=0] ----- -include::samples/traverse_base.cpp[tags=contents] ----- - -[[access.rangefor]] -=== Range-based for-loop support - -[[xml_node::children]][[xml_node::attributes]] -If your C{plus}{plus} compiler supports range-based for-loop (this is a C{plus}{plus}11 feature, at the time of writing it's supported by Microsoft Visual Studio 2012+, GCC 4.6+ and Clang 3.0+), you can use it to enumerate nodes/attributes. Additional helpers are provided to support this; note that they are also compatible with http://www.boost.org/libs/foreach/[Boost Foreach], and possibly other pre-C{plus}{plus}11 foreach facilities. - -[source,subs="+quotes"] ----- -_implementation_-_defined_-_type_ xml_node::children() const; -_implementation_-_defined_-_type_ xml_node::children(const char_t* name) const; -_implementation_-_defined_-_type_ xml_node::attributes() const; ----- - -`children` function allows you to enumerate all child nodes; `children` function with `name` argument allows you to enumerate all child nodes with a specific name; `attributes` function allows you to enumerate all attributes of the node. Note that you can also use node object itself in a range-based for construct, which is equivalent to using `children()`. - -This is an example of using these functions (link:samples/traverse_rangefor.cpp[]): - -[source,indent=0] ----- -include::samples/traverse_rangefor.cpp[tags=code] ----- - -While using `children()` makes the intent of the code clear, note that each node can be treated as a container of child nodes, since it provides `begin()`/`end()` member functions described in the next section. Because of this, you can iterate through node's children simply by using the node itself: - -[source] ----- -for (pugi::xml_node child: tool) ----- - -[[access.iterators]] -=== Traversing node/attribute lists via iterators - -[[xml_node_iterator]][[xml_attribute_iterator]][[xml_node::begin]][[xml_node::end]][[xml_node::attributes_begin]][[xml_node::attributes_end]] -Child node lists and attribute lists are simply double-linked lists; while you can use `previous_sibling`/`next_sibling` and other such functions for iteration, pugixml additionally provides node and attribute iterators, so that you can treat nodes as containers of other nodes or attributes: - -[source] ----- -class xml_node_iterator; -class xml_attribute_iterator; - -typedef xml_node_iterator xml_node::iterator; -iterator xml_node::begin() const; -iterator xml_node::end() const; - -typedef xml_attribute_iterator xml_node::attribute_iterator; -attribute_iterator xml_node::attributes_begin() const; -attribute_iterator xml_node::attributes_end() const; ----- - -`begin` and `attributes_begin` return iterators that point to the first node/attribute, respectively; `end` and `attributes_end` return past-the-end iterator for node/attribute list, respectively - this iterator can't be dereferenced, but decrementing it results in an iterator pointing to the last element in the list (except for empty lists, where decrementing past-the-end iterator results in undefined behavior). Past-the-end iterator is commonly used as a termination value for iteration loops (see sample below). If you want to get an iterator that points to an existing handle, you can construct the iterator with the handle as a single constructor argument, like so: `xml_node_iterator(node)`. For `xml_attribute_iterator`, you'll have to provide both an attribute and its parent node. - -`begin` and `end` return equal iterators if called on null node; such iterators can't be dereferenced. `attributes_begin` and `attributes_end` behave the same way. For correct iterator usage this means that child node/attribute collections of null nodes appear to be empty. - -Both types of iterators have bidirectional iterator semantics (i.e. they can be incremented and decremented, but efficient random access is not supported) and support all usual iterator operations - comparison, dereference, etc. The iterators are invalidated if the node/attribute objects they're pointing to are removed from the tree; adding nodes/attributes does not invalidate any iterators. - -Here is an example of using iterators for document traversal (link:samples/traverse_iter.cpp[]): - -[source,indent=0] ----- -include::samples/traverse_iter.cpp[tags=code] ----- - -CAUTION: Node and attribute iterators are somewhere in the middle between const and non-const iterators. While dereference operation yields a non-constant reference to the object, so that you can use it for tree modification operations, modifying this reference using assignment - i.e. passing iterators to a function like `std::sort` - will not give expected results, as assignment modifies local handle that's stored in the iterator. - -[[access.walker]] -=== Recursive traversal with xml_tree_walker - -[[xml_tree_walker]] -The methods described above allow traversal of immediate children of some node; if you want to do a deep tree traversal, you'll have to do it via a recursive function or some equivalent method. However, pugixml provides a helper for depth-first traversal of a subtree. In order to use it, you have to implement `xml_tree_walker` interface and to call `traverse` function: - -[source] ----- -class xml_tree_walker -{ -public: - virtual bool begin(xml_node& node); - virtual bool for_each(xml_node& node) = 0; - virtual bool end(xml_node& node); - - int depth() const; -}; - -bool xml_node::traverse(xml_tree_walker& walker); ----- - -[[xml_tree_walker::begin]][[xml_tree_walker::for_each]][[xml_tree_walker::end]][[xml_node::traverse]] -The traversal is launched by calling `traverse` function on traversal root and proceeds as follows: - -* First, `begin` function is called with traversal root as its argument. -* Then, `for_each` function is called for all nodes in the traversal subtree in depth first order, excluding the traversal root. Node is passed as an argument. -* Finally, `end` function is called with traversal root as its argument. - -If `begin`, `end` or any of the `for_each` calls return `false`, the traversal is terminated and `false` is returned as the traversal result; otherwise, the traversal results in `true`. Note that you don't have to override `begin` or `end` functions; their default implementations return `true`. - -[[xml_tree_walker::depth]] -You can get the node's depth relative to the traversal root at any point by calling `depth` function. It returns `-1` if called from `begin`/`end`, and returns 0-based depth if called from `for_each` - depth is 0 for all children of the traversal root, 1 for all grandchildren and so on. - -This is an example of traversing tree hierarchy with xml_tree_walker (link:samples/traverse_walker.cpp[]): - -[source,indent=0] ----- -include::samples/traverse_walker.cpp[tags=impl] ----- -[source,indent=0] ----- -include::samples/traverse_walker.cpp[tags=traverse] ----- - -[[access.predicate]] -=== Searching for nodes/attributes with predicates - -[[xml_node::find_attribute]][[xml_node::find_child]][[xml_node::find_node]] -While there are existing functions for getting a node/attribute with known contents, they are often not sufficient for simple queries. As an alternative for manual iteration through nodes/attributes until the needed one is found, you can make a predicate and call one of `find_` functions: - -[source] ----- -template xml_attribute xml_node::find_attribute(Predicate pred) const; -template xml_node xml_node::find_child(Predicate pred) const; -template xml_node xml_node::find_node(Predicate pred) const; ----- - -The predicate should be either a plain function or a function object which accepts one argument of type `xml_attribute` (for `find_attribute`) or `xml_node` (for `find_child` and `find_node`), and returns `bool`. The predicate is never called with null handle as an argument. - -`find_attribute` function iterates through all attributes of the specified node, and returns the first attribute for which the predicate returned `true`. If the predicate returned `false` for all attributes or if there were no attributes (including the case where the node is null), null attribute is returned. - -`find_child` function iterates through all child nodes of the specified node, and returns the first node for which the predicate returned `true`. If the predicate returned `false` for all nodes or if there were no child nodes (including the case where the node is null), null node is returned. - -`find_node` function performs a depth-first traversal through the subtree of the specified node (excluding the node itself), and returns the first node for which the predicate returned `true`. If the predicate returned `false` for all nodes or if subtree was empty, null node is returned. - -This is an example of using predicate-based functions (link:samples/traverse_predicate.cpp[]): - -[source,indent=0] ----- -include::samples/traverse_predicate.cpp[tags=decl] ----- -[source,indent=0] ----- -include::samples/traverse_predicate.cpp[tags=find] ----- - -[[access.text]] -=== Working with text contents - -[[xml_text]] -It is common to store data as text contents of some node - i.e. `This is a node`. In this case, `` node does not have a value, but instead has a child of type <> with value `"This is a node"`. pugixml provides a special class, `xml_text`, to work with such data. Working with text objects to modify data is described in <>; this section describes the access interface of `xml_text`. - -[[xml_node::text]] -You can get the text object from a node by using `text()` method: - -[source] ----- -xml_text xml_node::text() const; ----- - -If the node has a type `node_pcdata` or `node_cdata`, then the node itself is used to return data; otherwise, a first child node of type `node_pcdata` or `node_cdata` is used. - -[[xml_text::empty]][[xml_text::unspecified_bool_type]] -You can check if the text object is bound to a valid PCDATA/CDATA node by using it as a boolean value, i.e. `if (text) { ... }` or `if (!text) { ... }`. Alternatively you can check it by using the `empty()` method: - -[source] ----- -bool xml_text::empty() const; ----- - -[[xml_text::get]] -Given a text object, you can get the contents (i.e. the value of PCDATA/CDATA node) by using the following function: - -[source] ----- -const char_t* xml_text::get() const; ----- - -In case text object is empty, the function returns an empty string - it never returns a null pointer. - -[[xml_text::as_string]][[xml_text::as_int]][[xml_text::as_uint]][[xml_text::as_double]][[xml_text::as_float]][[xml_text::as_bool]][[xml_text::as_llong]][[xml_text::as_ullong]] -If you need a non-empty string if the text object is empty, or if the text contents is actually a number or a boolean that is stored as a string, you can use the following accessors: - -[source] ----- -const char_t* xml_text::as_string(const char_t* def = "") const; -int xml_text::as_int(int def = 0) const; -unsigned int xml_text::as_uint(unsigned int def = 0) const; -double xml_text::as_double(double def = 0) const; -float xml_text::as_float(float def = 0) const; -bool xml_text::as_bool(bool def = false) const; -long long xml_text::as_llong(long long def = 0) const; -unsigned long long xml_text::as_ullong(unsigned long long def = 0) const; ----- - -All of the above functions have the same semantics as similar `xml_attribute` members: they return the default argument if the text object is empty, they convert the text contents to a target type using the same rules and restrictions. You can <> for details. - -[[xml_text::data]] -`xml_text` is essentially a helper class that operates on `xml_node` values. It is bound to a node of type <> or <>. You can use the following function to retrieve this node: - -[source] ----- -xml_node xml_text::data() const; ----- - -Essentially, assuming `text` is an `xml_text` object, calling `text.get()` is equivalent to calling `text.data().value()`. - -This is an example of using `xml_text` object (link:samples/text.cpp[]): - -[source,indent=0] ----- -include::samples/text.cpp[tags=access] ----- - -[[access.misc]] -=== Miscellaneous functions - -[[xml_node::root]] -If you need to get the document root of some node, you can use the following function: - -[source] ----- -xml_node xml_node::root() const; ----- - -This function returns the node with type <>, which is the root node of the document the node belongs to (unless the node is null, in which case null node is returned). - -[[xml_node::path]][[xml_node::first_element_by_path]] -While pugixml supports complex XPath expressions, sometimes a simple path handling facility is needed. There are two functions, for getting node path and for converting path to a node: - -[source] ----- -string_t xml_node::path(char_t delimiter = '/') const; -xml_node xml_node::first_element_by_path(const char_t* path, char_t delimiter = '/') const; ----- - -Node paths consist of node names, separated with a delimiter (which is `/` by default); also paths can contain self (`.`) and parent (`..`) pseudo-names, so that this is a valid path: `"../../foo/./bar"`. `path` returns the path to the node from the document root, `first_element_by_path` looks for a node represented by a given path; a path can be an absolute one (absolute paths start with the delimiter), in which case the rest of the path is treated as document root relative, and relative to the given node. For example, in the following document: ``, node `` has path `"a/b/c"`; calling `first_element_by_path` for document with path `"a/b"` results in node ``; calling `first_element_by_path` for node `` with path `"../a/./b/../."` results in node ``; calling `first_element_by_path` with path `"/a"` results in node `` for any node. - -In case path component is ambiguous (if there are two nodes with given name), the first one is selected; paths are not guaranteed to uniquely identify nodes in a document. If any component of a path is not found, the result of `first_element_by_path` is null node; also `first_element_by_path` returns null node for null nodes, in which case the path does not matter. `path` returns an empty string for null nodes. - -NOTE: `path` function returns the result as STL string, and thus is not available if <> is defined. - -[[xml_node::offset_debug]] -pugixml does not record row/column information for nodes upon parsing for efficiency reasons. However, if the node has not changed in a significant way since parsing (the name/value are not changed, and the node itself is the original one, i.e. it was not deleted from the tree and re-added later), it is possible to get the offset from the beginning of XML buffer: - -[source] ----- -ptrdiff_t xml_node::offset_debug() const; ----- - -If the offset is not available (this happens if the node is null, was not originally parsed from a stream, or has changed in a significant way), the function returns -1. Otherwise it returns the offset to node's data from the beginning of XML buffer in <> units. For more information on parsing offsets, see <>. - -[[modify]] -== Modifying document data - -The document in pugixml is fully mutable: you can completely change the document structure and modify the data of nodes/attributes. This section provides documentation for the relevant functions. All functions take care of memory management and structural integrity themselves, so they always result in structurally valid tree - however, it is possible to create an invalid XML tree (for example, by adding two attributes with the same name or by setting attribute/node name to empty/invalid string). Tree modification is optimized for performance and for memory consumption, so if you have enough memory you can create documents from scratch with pugixml and later save them to file/stream instead of relying on error-prone manual text writing and without too much overhead. - -All member functions that change node/attribute data or structure are non-constant and thus can not be called on constant handles. However, you can easily convert constant handle to non-constant one by simple assignment: `void foo(const pugi::xml_node& n) { pugi::xml_node nc = n; }`, so const-correctness here mainly provides additional documentation. - -[import samples/modify_base.cpp] - -[[modify.nodedata]] -=== Setting node data - -[[xml_node::set_name]][[xml_node::set_value]] -As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. <> nodes do not have a name or value, <> and <> nodes always have a name but never have a value, <>, <>, <> and <> nodes never have a name but always have a value (it may be empty though), <> nodes always have a name and a value (again, value may be empty). In order to set node's name or value, you can use the following functions: - -[source] ----- -bool xml_node::set_name(const char_t* rhs); -bool xml_node::set_value(const char_t* rhs); ----- - -Both functions try to set the name/value to the specified string, and return the operation result. The operation fails if the node can not have name or value (for instance, when trying to call `set_name` on a <> node), if the node handle is null, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to these functions). The name/value content is not verified, so take care to use only valid XML names, or the document may become malformed. - -This is an example of setting node name and value (link:samples/modify_base.cpp[]): - -[source,indent=0] ----- -include::samples/modify_base.cpp[tags=node] ----- - -[[modify.attrdata]] -=== Setting attribute data - -[[xml_attribute::set_name]][[xml_attribute::set_value]] -All attributes have name and value, both of which are strings (value may be empty). You can set them with the following functions: - -[source] ----- -bool xml_attribute::set_name(const char_t* rhs); -bool xml_attribute::set_value(const char_t* rhs); ----- - -Both functions try to set the name/value to the specified string, and return the operation result. The operation fails if the attribute handle is null, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to these functions). The name/value content is not verified, so take care to use only valid XML names, or the document may become malformed. - -In addition to string functions, several functions are provided for handling attributes with numbers and booleans as values: - -[source] ----- -bool xml_attribute::set_value(int rhs); -bool xml_attribute::set_value(unsigned int rhs); -bool xml_attribute::set_value(long rhs); -bool xml_attribute::set_value(unsigned long rhs); -bool xml_attribute::set_value(double rhs); -bool xml_attribute::set_value(double rhs, int precision); -bool xml_attribute::set_value(float rhs); -bool xml_attribute::set_value(float rhs, int precision); -bool xml_attribute::set_value(bool rhs); -bool xml_attribute::set_value(long long rhs); -bool xml_attribute::set_value(unsigned long long rhs); ----- - -The above functions convert the argument to string and then call the base `set_value` function. Integers are converted to a decimal form, floating-point numbers are converted to either decimal or scientific form, depending on the number magnitude, boolean values are converted to either `"true"` or `"false"`. - -CAUTION: Number conversion functions depend on current C locale as set with `setlocale`, so may generate unexpected results if the locale is different from `"C"`. - -NOTE: `set_value` overloads with `long long` type are only available if your platform has reliable support for the type, including string conversions. - -[[xml_attribute::assign]] - -For convenience, all `set_value` functions have the corresponding assignment operators: - -[source] ----- -xml_attribute& xml_attribute::operator=(const char_t* rhs); -xml_attribute& xml_attribute::operator=(int rhs); -xml_attribute& xml_attribute::operator=(unsigned int rhs); -xml_attribute& xml_attribute::operator=(long rhs); -xml_attribute& xml_attribute::operator=(unsigned long rhs); -xml_attribute& xml_attribute::operator=(double rhs); -xml_attribute& xml_attribute::operator=(float rhs); -xml_attribute& xml_attribute::operator=(bool rhs); -xml_attribute& xml_attribute::operator=(long long rhs); -xml_attribute& xml_attribute::operator=(unsigned long long rhs); ----- - -These operators simply call the right `set_value` function and return the attribute they're called on; the return value of `set_value` is ignored, so errors are ignored. - -This is an example of setting attribute name and value (link:samples/modify_base.cpp[]): - -[source,indent=0] ----- -include::samples/modify_base.cpp[tags=attr] ----- - -[[modify.add]] -=== Adding nodes/attributes - -[[xml_node::prepend_attribute]][[xml_node::append_attribute]][[xml_node::insert_attribute_after]][[xml_node::insert_attribute_before]][[xml_node::prepend_child]][[xml_node::append_child]][[xml_node::insert_child_after]][[xml_node::insert_child_before]] -Nodes and attributes do not exist without a document tree, so you can't create them without adding them to some document. A node or attribute can be created at the end of node/attribute list or before/after some other node: - -[source] ----- -xml_attribute xml_node::append_attribute(const char_t* name); -xml_attribute xml_node::prepend_attribute(const char_t* name); -xml_attribute xml_node::insert_attribute_after(const char_t* name, const xml_attribute& attr); -xml_attribute xml_node::insert_attribute_before(const char_t* name, const xml_attribute& attr); - -xml_node xml_node::append_child(xml_node_type type = node_element); -xml_node xml_node::prepend_child(xml_node_type type = node_element); -xml_node xml_node::insert_child_after(xml_node_type type, const xml_node& node); -xml_node xml_node::insert_child_before(xml_node_type type, const xml_node& node); - -xml_node xml_node::append_child(const char_t* name); -xml_node xml_node::prepend_child(const char_t* name); -xml_node xml_node::insert_child_after(const char_t* name, const xml_node& node); -xml_node xml_node::insert_child_before(const char_t* name, const xml_node& node); ----- - -`append_attribute` and `append_child` create a new node/attribute at the end of the corresponding list of the node the method is called on; `prepend_attribute` and `prepend_child` create a new node/attribute at the beginning of the list; `insert_attribute_after`, `insert_attribute_before`, `insert_child_after` and `insert_attribute_before` add the node/attribute before or after the specified node/attribute. - -Attribute functions create an attribute with the specified name; you can specify the empty name and change the name later if you want to. Node functions with the `type` argument create the node with the specified type; since node type can't be changed, you have to know the desired type beforehand. Also note that not all types can be added as children; see below for clarification. Node functions with the `name` argument create the element node (<>) with the specified name. - -All functions return the handle to the created object on success, and null handle on failure. There are several reasons for failure: - -* Adding fails if the target node is null; -* Only <> nodes can contain attributes, so attribute adding fails if node is not an element; -* Only <> and <> nodes can contain children, so child node adding fails if the target node is not an element or a document; -* <> and <> nodes can not be inserted as children, so passing <> or <> value as `type` results in operation failure; -* <> nodes can only be added as children of the document node; attempt to insert declaration node as a child of an element node fails; -* Adding node/attribute results in memory allocation, which may fail; -* Insertion functions fail if the specified node or attribute is null or is not in the target node's children/attribute list. - -Even if the operation fails, the document remains in consistent state, but the requested node/attribute is not added. - -CAUTION: `attribute()` and `child()` functions do not add attributes or nodes to the tree, so code like `node.attribute("id") = 123;` will not do anything if `node` does not have an attribute with name `"id"`. Make sure you're operating with existing attributes/nodes by adding them if necessary. - -This is an example of adding new attributes/nodes to the document (link:samples/modify_add.cpp[]): - -[source,indent=0] ----- -include::samples/modify_add.cpp[tags=code] ----- - -[[modify.remove]] -=== Removing nodes/attributes - -[[xml_node::remove_attribute]][[xml_node::remove_attributes]][[xml_node::remove_child]][[xml_node::remove_children]] -If you do not want your document to contain some node or attribute, you can remove it with one of the following functions: - -[source] ----- -bool xml_node::remove_attribute(const xml_attribute& a); -bool xml_node::remove_attributes(); -bool xml_node::remove_child(const xml_node& n); -bool xml_node::remove_children(); ----- - -`remove_attribute` removes the attribute from the attribute list of the node, and returns the operation result. `remove_child` removes the child node with the entire subtree (including all descendant nodes and attributes) from the document, and returns the operation result. `remove_attributes` removes all the attributes of the node, and returns the operation result. `remove_children` removes all the child nodes of the node, and returns the operation result. Removing fails if one of the following is true: - -* The node the function is called on is null; -* The attribute/node to be removed is null; -* The attribute/node to be removed is not in the node's attribute/child list. - -Removing the attribute or node invalidates all handles to the same underlying object, and also invalidates all iterators pointing to the same object. Removing node also invalidates all past-the-end iterators to its attribute or child node list. Be careful to ensure that all such handles and iterators either do not exist or are not used after the attribute/node is removed. - -If you want to remove the attribute or child node by its name, two additional helper functions are available: - -[source] ----- -bool xml_node::remove_attribute(const char_t* name); -bool xml_node::remove_child(const char_t* name); ----- - -These functions look for the first attribute or child with the specified name, and then remove it, returning the result. If there is no attribute or child with such name, the function returns `false`; if there are two nodes with the given name, only the first node is deleted. If you want to delete all nodes with the specified name, you can use code like this: `while (node.remove_child("tool")) ;`. - -This is an example of removing attributes/nodes from the document (link:samples/modify_remove.cpp[]): - -[source,indent=0] ----- -include::samples/modify_remove.cpp[tags=code] ----- - -[[modify.text]] -=== Working with text contents - -pugixml provides a special class, `xml_text`, to work with text contents stored as a value of some node, i.e. `This is a node`. Working with text objects to retrieve data is described in <>; this section describes the modification interface of `xml_text`. - -[[xml_text::set]] -Once you have an `xml_text` object, you can set the text contents using the following function: - -[source] ----- -bool xml_text::set(const char_t* rhs); ----- - -This function tries to set the contents to the specified string, and returns the operation result. The operation fails if the text object was retrieved from a node that can not have a value and is not an element node (i.e. it is a <> node), if the text object is empty, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to this function). Note that if the text object was retrieved from an element node, this function creates the PCDATA child node if necessary (i.e. if the element node does not have a PCDATA/CDATA child already). - -[[xml_text::set_value]] -In addition to a string function, several functions are provided for handling text with numbers and booleans as contents: - -[source] ----- -bool xml_text::set(int rhs); -bool xml_text::set(unsigned int rhs); -bool xml_text::set(long rhs); -bool xml_text::set(unsigned long rhs); -bool xml_text::set(double rhs); -bool xml_text::set(double rhs, int precision); -bool xml_text::set(float rhs); -bool xml_text::set(float rhs, int precision); -bool xml_text::set(bool rhs); -bool xml_text::set(long long rhs); -bool xml_text::set(unsigned long long rhs); ----- - -The above functions convert the argument to string and then call the base `set` function. These functions have the same semantics as similar `xml_attribute` functions. You can <> for details. - -[[xml_text::assign]] - -For convenience, all `set` functions have the corresponding assignment operators: - -[source] ----- -xml_text& xml_text::operator=(const char_t* rhs); -xml_text& xml_text::operator=(int rhs); -xml_text& xml_text::operator=(unsigned int rhs); -xml_text& xml_text::operator=(long rhs); -xml_text& xml_text::operator=(unsigned long rhs); -xml_text& xml_text::operator=(double rhs); -xml_text& xml_text::operator=(float rhs); -xml_text& xml_text::operator=(bool rhs); -xml_text& xml_text::operator=(long long rhs); -xml_text& xml_text::operator=(unsigned long long rhs); ----- - -These operators simply call the right `set` function and return the attribute they're called on; the return value of `set` is ignored, so errors are ignored. - -This is an example of using `xml_text` object to modify text contents (link:samples/text.cpp[]): - -[source,indent=0] ----- -include::samples/text.cpp[tags=modify] ----- - -[[modify.clone]] -=== Cloning nodes/attributes - -[[xml_node::prepend_copy]][[xml_node::append_copy]][[xml_node::insert_copy_after]][[xml_node::insert_copy_before]] -With the help of previously described functions, it is possible to create trees with any contents and structure, including cloning the existing data. However since this is an often needed operation, pugixml provides built-in node/attribute cloning facilities. Since nodes and attributes do not exist without a document tree, you can't create a standalone copy - you have to immediately insert it somewhere in the tree. For this, you can use one of the following functions: - -[source] ----- -xml_attribute xml_node::append_copy(const xml_attribute& proto); -xml_attribute xml_node::prepend_copy(const xml_attribute& proto); -xml_attribute xml_node::insert_copy_after(const xml_attribute& proto, const xml_attribute& attr); -xml_attribute xml_node::insert_copy_before(const xml_attribute& proto, const xml_attribute& attr); - -xml_node xml_node::append_copy(const xml_node& proto); -xml_node xml_node::prepend_copy(const xml_node& proto); -xml_node xml_node::insert_copy_after(const xml_node& proto, const xml_node& node); -xml_node xml_node::insert_copy_before(const xml_node& proto, const xml_node& node); ----- - -These functions mirror the structure of `append_child`, `prepend_child`, `insert_child_before` and related functions - they take the handle to the prototype object, which is to be cloned, insert a new attribute/node at the appropriate place, and then copy the attribute data or the whole node subtree to the new object. The functions return the handle to the resulting duplicate object, or null handle on failure. - -The attribute is copied along with the name and value; the node is copied along with its type, name and value; additionally attribute list and all children are recursively cloned, resulting in the deep subtree clone. The prototype object can be a part of the same document, or a part of any other document. - -The failure conditions resemble those of `append_child`, `insert_child_before` and related functions, <>. There are additional caveats specific to cloning functions: - -* Cloning null handles results in operation failure; -* Node cloning starts with insertion of the node of the same type as that of the prototype; for this reason, cloning functions can not be directly used to clone entire documents, since <> is not a valid insertion type. The example below provides a workaround. -* It is possible to copy a subtree as a child of some node inside this subtree, i.e. `node.append_copy(node.parent().parent());`. This is a valid operation, and it results in a clone of the subtree in the state before cloning started, i.e. no infinite recursion takes place. - -This is an example with one possible implementation of include tags in XML (link:samples/include.cpp[]). It illustrates node cloning and usage of other document modification functions: - -[source,indent=0] ----- -include::samples/include.cpp[tags=code] ----- - -[[modify.move]] -=== Moving nodes - -[[xml_node::prepend_move]][[xml_node::append_move]][[xml_node::insert_move_after]][[xml_node::insert_move_before]] -Sometimes instead of cloning a node you need to move an existing node to a different position in a tree. This can be accomplished by copying the node and removing the original; however, this is expensive since it results in a lot of extra operations. For moving nodes within the same document tree, you can use of the following functions instead: - -[source] ----- -xml_node xml_node::append_move(const xml_node& moved); -xml_node xml_node::prepend_move(const xml_node& moved); -xml_node xml_node::insert_move_after(const xml_node& moved, const xml_node& node); -xml_node xml_node::insert_move_before(const xml_node& moved, const xml_node& node); ----- - -These functions mirror the structure of `append_copy`, `prepend_copy`, `insert_copy_before` and `insert_copy_after` - they take the handle to the moved object and move it to the appropriate place with all attributes and/or child nodes. The functions return the handle to the resulting object (which is the same as the moved object), or null handle on failure. - -The failure conditions resemble those of `append_child`, `insert_child_before` and related functions, <>. There are additional caveats specific to moving functions: - -* Moving null handles results in operation failure; -* Moving is only possible for nodes that belong to the same document; attempting to move nodes between documents will fail. -* `insert_move_after` and `insert_move_before` functions fail if the moved node is the same as the `node` argument (this operation would be a no-op otherwise). -* It is impossible to move a subtree to a child of some node inside this subtree, i.e. `node.append_move(node.parent().parent());` will fail. - -[[modify.fragments]] -=== Assembling document from fragments - -[[xml_node::append_buffer]] -pugixml provides several ways to assemble an XML document from other XML documents. Assuming there is a set of document fragments, represented as in-memory buffers, the implementation choices are as follows: - -* Use a temporary document to parse the data from a string, then clone the nodes to a destination node. For example: -+ -[source] ----- -bool append_fragment(pugi::xml_node target, const char* buffer, size_t size) -{ - pugi::xml_document doc; - if (!doc.load_buffer(buffer, size)) return false; - - for (pugi::xml_node child = doc.first_child(); child; child = child.next_sibling()) - target.append_copy(child); -} ----- - -* Cache the parsing step - instead of keeping in-memory buffers, keep document objects that already contain the parsed fragment: -+ -[source] ----- -bool append_fragment(pugi::xml_node target, const pugi::xml_document& cached_fragment) -{ - for (pugi::xml_node child = cached_fragment.first_child(); child; child = child.next_sibling()) - target.append_copy(child); -} ----- - -* Use `xml_node::append_buffer` directly: -+ -[source] ----- -xml_parse_result xml_node::append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); ----- - -The first method is more convenient, but slower than the other two. The relative performance of `append_copy` and `append_buffer` depends on the buffer format - usually `append_buffer` is faster if the buffer is in native encoding (UTF-8 or wchar_t, depending on `PUGIXML_WCHAR_MODE`). At the same time it might be less efficient in terms of memory usage - the implementation makes a copy of the provided buffer, and the copy has the same lifetime as the document - the memory used by that copy will be reclaimed after the document is destroyed, but no sooner. Even deleting all nodes in the document, including the appended ones, won't reclaim the memory. - -`append_buffer` behaves in the same way as <> - the input buffer is a byte buffer, with size in bytes; the buffer is not modified and can be freed after the function returns. - -[[status_append_invalid_root]] -Since `append_buffer` needs to append child nodes to the current node, it only works if the current node is either document or element node. Calling `append_buffer` on a node with any other type results in an error with `status_append_invalid_root` status. - -[[saving]] -== Saving document - -Often after creating a new document or loading the existing one and processing it, it is necessary to save the result back to file. Also it is occasionally useful to output the whole document or a subtree to some stream; use cases include debug printing, serialization via network or other text-oriented medium, etc. pugixml provides several functions to output any subtree of the document to a file, stream or another generic transport interface; these functions allow to customize the output format (see <>), and also perform necessary encoding conversions (see <>). This section documents the relevant functionality. - -Before writing to the destination the node/attribute data is properly formatted according to the node type; all special XML symbols, such as `<` and `&`, are properly escaped (unless <> flag is set). In order to guard against forgotten node/attribute names, empty node/attribute names are printed as `":anonymous"`. For well-formed output, make sure all node and attribute names are set to meaningful values. - -CDATA sections with values that contain `"]]>"` are split into several sections as follows: section with value `"pre]]>post"` is written as `post]]>`. While this alters the structure of the document (if you load the document after saving it, there will be two CDATA sections instead of one), this is the only way to escape CDATA contents. - -[[saving.file]] -=== Saving document to a file - -[[xml_document::save_file]][[xml_document::save_file_wide]] -If you want to save the whole document to a file, you can use one of the following functions: - -[source] ----- -bool xml_document::save_file(const char* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; -bool xml_document::save_file(const wchar_t* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; ----- - -These functions accept file path as its first argument, and also three optional arguments, which specify indentation and other output options (see <>) and output data encoding (see <>). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc. - -File path is passed to the system file opening function as is in case of the first function (which accepts `const char* path`); the second function either uses a special file opening function if it is provided by the runtime library or converts the path to UTF-8 and uses the system file opening function. - -[[xml_writer_file]] -`save_file` opens the target file for writing, outputs the requested header (by default a document declaration is output, unless the document already has one), and then saves the document contents. If the file could not be opened, the function returns `false`. Calling `save_file` is equivalent to creating an `xml_writer_file` object with `FILE*` handle as the only constructor argument and then calling `save`; see <> for writer interface details. - -This is a simple example of saving XML document to file (link:samples/save_file.cpp[]): - -[source,indent=0] ----- -include::samples/save_file.cpp[tags=code] ----- - -[[saving.stream]] -=== Saving document to C{plus}{plus} IOstreams - -[[xml_document::save_stream]] -To enhance interoperability pugixml provides functions for saving document to any object which implements C{plus}{plus} `std::ostream` interface. This allows you to save documents to any standard C{plus}{plus} stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). Most notably, this allows for easy debug output, since you can use `std::cout` stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones: - -[source] ----- -void xml_document::save(std::ostream& stream, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; -void xml_document::save(std::wostream& stream, const char_t* indent = "\t", unsigned int flags = format_default) const; ----- - -`save` with `std::ostream` argument saves the document to the stream in the same way as `save_file` (i.e. with requested header and with encoding conversions). On the other hand, `save` with `std::wstream` argument saves the document to the wide stream with <> encoding. Because of this, using `save` with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the `imbue` function). Generally use of wide streams is discouraged, however it provides you with the ability to save documents to non-Unicode encodings, i.e. you can save Shift-JIS encoded data if you set the correct locale. - -[[xml_writer_stream]] -Calling `save` with stream target is equivalent to creating an `xml_writer_stream` object with stream as the only constructor argument and then calling `save`; see <> for writer interface details. - -This is a simple example of saving XML document to standard output (link:samples/save_stream.cpp[]): - -[source,indent=0] ----- -include::samples/save_stream.cpp[tags=code] ----- - -[[saving.writer]] -=== Saving document via writer interface - -[[xml_document::save]][[xml_writer]][[xml_writer::write]] -All of the above saving functions are implemented in terms of writer interface. This is a simple interface with a single function, which is called several times during output process with chunks of document data as input: - -[source] ----- -class xml_writer -{ -public: - virtual void write(const void* data, size_t size) = 0; -}; - -void xml_document::save(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; ----- - -In order to output the document via some custom transport, for example sockets, you should create an object which implements `xml_writer` interface and pass it to `save` function. `xml_writer::write` function is called with a buffer as an input, where `data` points to buffer start, and `size` is equal to the buffer size in bytes. `write` implementation must write the buffer to the transport; it can not save the passed buffer pointer, as the buffer contents will change after `write` returns. The buffer contains the chunk of document data in the desired encoding. - -`write` function is called with relatively large blocks (size is usually several kilobytes, except for the last block that may be small), so there is often no need for additional buffering in the implementation. - -This is a simple example of custom writer for saving document data to STL string (link:samples/save_custom_writer.cpp[]); read the sample code for more complex examples: - -[source,indent=0] ----- -include::samples/save_custom_writer.cpp[tags=code] ----- - -[[saving.subtree]] -=== Saving a single subtree - -[[xml_node::print]][[xml_node::print_stream]] -While the previously described functions save the whole document to the destination, it is easy to save a single subtree. The following functions are provided: - -[source] ----- -void xml_node::print(std::ostream& os, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; -void xml_node::print(std::wostream& os, const char_t* indent = "\t", unsigned int flags = format_default, unsigned int depth = 0) const; -void xml_node::print(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; ----- - -These functions have the same arguments with the same meaning as the corresponding `xml_document::save` functions, and allow you to save the subtree to either a C{plus}{plus} IOstream or to any object that implements `xml_writer` interface. - -Saving a subtree differs from saving the whole document: the process behaves as if <> is off, and <> is on, even if actual values of the flags are different. This means that BOM is not written to the destination, and document declaration is only written if it is the node itself or is one of node's children. Note that this also holds if you're saving a document; this example (link:samples/save_subtree.cpp[]) illustrates the difference: - -[source,indent=0] ----- -include::samples/save_subtree.cpp[tags=code] ----- - -[[saving.options]] -=== Output options - -All saving functions accept the optional parameter `flags`. This is a bitmask that customizes the output format; you can select the way the document nodes are printed and select the needed additional information that is output before the document contents. - -NOTE: You should use the usual bitwise arithmetics to manipulate the bitmask: to enable a flag, use `mask | flag`; to disable a flag, use `mask & ~flag`. - -These flags control the resulting tree contents: - -* [[format_indent]]`format_indent` determines if all nodes should be indented with the indentation string (this is an additional parameter for all saving functions, and is `"\t"` by default). If this flag is on, the indentation string is printed several times before every node, where the amount of indentation depends on the node's depth relative to the output subtree. This flag has no effect if <> is enabled. This flag is *on* by default. - -* [[format_indent_attributes]]`format_indent_attributes` determines if all attributes should be printed on a new line, indented with the indentation string according to the attribute's depth. This flag implies <>. This flag has no effect if <> is enabled. This flag is *off* by default. - -* [[format_raw]]`format_raw` switches between formatted and raw output. If this flag is on, the nodes are not indented in any way, and also no newlines that are not part of document text are printed. Raw mode can be used for serialization where the result is not intended to be read by humans; also it can be useful if the document was parsed with <> flag, to preserve the original document formatting as much as possible. This flag is *off* by default. - -* [[format_no_escapes]]`format_no_escapes` disables output escaping for attribute values and PCDATA contents. If this flag is off, special symbols (`"`, `&`, `<`, `>`) and all non-printable characters (those with codepoint values less than 32) are converted to XML escape sequences (i.e. `&amp;`) during output. If this flag is on, no text processing is performed; therefore, output XML can be malformed if output contents contains invalid symbols (i.e. having a stray `<` in the PCDATA will make the output malformed). This flag is *off* by default. - -* [[format_no_empty_element_tags]]`format_no_empty_element_tags` determines if start/end tags should be output instead of empty element tags for empty elements (that is, elements with no children). This flag is *off* by default. - -* [[format_skip_control_chars]]`format_skip_control_chars` enables skipping characters belonging to range [0; 32) instead of "&#xNN;" encoding. This flag is *off* by default. - -* [[format_attribute_single_quote]]`format_attribute_single_quote` enables using single quotes `'` instead of double quotes `"` for enclosing attribute values. This flag is *off* by default. - -These flags control the additional output information: - -* [[format_no_declaration]]`format_no_declaration` disables default node declaration output. By default, if the document is saved via `save` or `save_file` function, and it does not have any document declaration, a default declaration is output before the document contents. Enabling this flag disables this declaration. This flag has no effect in `xml_node::print` functions: they never output the default declaration. This flag is *off* by default. - -* [[format_write_bom]]`format_write_bom` enables Byte Order Mark (BOM) output. By default, no BOM is output, so in case of non UTF-8 encodings the resulting document's encoding may not be recognized by some parsers and text editors, if they do not implement sophisticated encoding detection. Enabling this flag adds an encoding-specific BOM to the output. This flag has no effect in `xml_node::print` functions: they never output the BOM. This flag is *off* by default. - -* [[format_save_file_text]]`format_save_file_text` changes the file mode when using `save_file` function. By default, file is opened in binary mode, which means that the output file will -contain platform-independent newline `\n` (ASCII 10). If this flag is on, file is opened in text mode, which on some systems changes the newline format (i.e. on Windows you can use this flag to output XML documents with `\r\n` (ASCII 13 10) newlines. This flag is *off* by default. - -Additionally, there is one predefined option mask: - -* [[format_default]]`format_default` is the default set of flags, i.e. it has all options set to their default values. It sets formatted output with indentation, without BOM and with default node declaration, if necessary. - -This is an example that shows the outputs of different output options (link:samples/save_options.cpp[]): - -[source,indent=0] ----- -include::samples/save_options.cpp[tags=code] ----- - -[[saving.encoding]] -=== Encodings - -pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it's a strict subset of UTF-16) and handles all encoding conversions during output. The output encoding is set via the `encoding` parameter of saving functions, which is of type `xml_encoding`. The possible values for the encoding are documented in <>; the only flag that has a different meaning is `encoding_auto`. - -While all other flags set the exact encoding, `encoding_auto` is meant for automatic encoding detection. The automatic detection does not make sense for output encoding, since there is usually nothing to infer the actual encoding from, so here `encoding_auto` means UTF-8 encoding, which is the most popular encoding for XML data storage. This is also the default value of output encoding; specify another value if you do not want UTF-8 encoded output. - -Also note that wide stream saving functions do not have `encoding` argument and always assume <> encoding. - -NOTE: The current behavior for Unicode conversion is to skip all invalid UTF sequences during conversion. This behavior should not be relied upon; if your node/attribute names do not contain any valid UTF sequences, they may be output as if they are empty, which will result in malformed XML document. - -[[saving.declaration]] -=== Customizing document declaration - -When you are saving the document using `xml_document::save()` or `xml_document::save_file()`, a default XML document declaration is output, if `format_no_declaration` is not specified and if the document does not have a declaration node. However, the default declaration is not customizable. If you want to customize the declaration output, you need to create the declaration node yourself. - -NOTE: By default the declaration node is not added to the document during parsing. If you just need to preserve the original declaration node, you have to add the flag <> to the parsing flags; the resulting document will contain the original declaration node, which will be output during saving. - -Declaration node is a node with type <>; it behaves like an element node in that it has attributes with values (but it does not have child nodes). Therefore setting custom version, encoding or standalone declaration involves adding attributes and setting attribute values. - -This is an example that shows how to create a custom declaration node (link:samples/save_declaration.cpp[]): - -[source,indent=0] ----- -include::samples/save_declaration.cpp[tags=code] ----- - -[[xpath]] -== XPath - -If the task at hand is to select a subset of document nodes that match some criteria, it is possible to code a function using the existing traversal functionality for any practical criteria. However, often either a data-driven approach is desirable, in case the criteria are not predefined and come from a file, or it is inconvenient to use traversal interfaces and a higher-level DSL is required. There is a standard language for XML processing, XPath, that can be useful for these cases. pugixml implements an almost complete subset of XPath 1.0. Because of differences in document object model and some performance implications, there are minor violations of the official specifications, which can be found in <>. The rest of this section describes the interface for XPath functionality. Please note that if you wish to learn to use XPath language, you have to look for other tutorials or manuals; for example, you can read http://www.w3schools.com/xpath/[W3Schools XPath tutorial], http://www.tizag.com/xmlTutorial/xpathtutorial.php[XPath tutorial at tizag.com], and http://www.w3.org/TR/xpath/[the XPath 1.0 specification]. - -[[xpath.types]] -=== XPath types - -[[xpath_value_type]][[xpath_type_number]][[xpath_type_string]][[xpath_type_boolean]][[xpath_type_node_set]][[xpath_type_none]] -Each XPath expression can have one of the following types: boolean, number, string or node set. Boolean type corresponds to `bool` type, number type corresponds to `double` type, string type corresponds to either `std::string` or `std::wstring`, depending on whether <>, and node set corresponds to <> type. There is an enumeration, `xpath_value_type`, which can take the values `xpath_type_boolean`, `xpath_type_number`, `xpath_type_string` or `xpath_type_node_set`, accordingly. - -[[xpath_node]][[xpath_node::node]][[xpath_node::attribute]][[xpath_node::parent]] -Because an XPath node can be either a node or an attribute, there is a special type, `xpath_node`, which is a discriminated union of these types. A value of this type contains two node handles, one of `xml_node` type, and another one of `xml_attribute` type; at most one of them can be non-null. The accessors to get these handles are available: - -[source] ----- -xml_node xpath_node::node() const; -xml_attribute xpath_node::attribute() const; ----- - -XPath nodes can be null, in which case both accessors return null handles. - -Note that as per XPath specification, each XPath node has a parent, which can be retrieved via this function: - -[source] ----- -xml_node xpath_node::parent() const; ----- - -`parent` function returns the node's parent if the XPath node corresponds to `xml_node` handle (equivalent to `node().parent()`), or the node to which the attribute belongs to, if the XPath node corresponds to `xml_attribute` handle. For null nodes, `parent` returns null handle. - -[[xpath_node::unspecified_bool_type]][[xpath_node::comparison]] -Like node and attribute handles, XPath node handles can be implicitly cast to boolean-like object to check if it is a null node, and also can be compared for equality with each other. - -[[xpath_node::ctor]] -You can also create XPath nodes with one of the three constructors: the default constructor, the constructor that takes node argument, and the constructor that takes attribute and node arguments (in which case the attribute must belong to the attribute list of the node). The constructor from `xml_node` is implicit, so you can usually pass `xml_node` to functions that expect `xpath_node`. Apart from that you usually don't need to create your own XPath node objects, since they are returned to you via selection functions. - -[[xpath_node_set]] -XPath expressions operate not on single nodes, but instead on node sets. A node set is a collection of nodes, which can be optionally ordered in either a forward document order or a reverse one. Document order is defined in XPath specification; an XPath node is before another node in document order if it appears before it in XML representation of the corresponding document. - -[[xpath_node_set::const_iterator]][[xpath_node_set::begin]][[xpath_node_set::end]] -Node sets are represented by `xpath_node_set` object, which has an interface that resembles one of sequential random-access containers. It has an iterator type along with usual begin/past-the-end iterator accessors: - -[source] ----- -typedef const xpath_node* xpath_node_set::const_iterator; -const_iterator xpath_node_set::begin() const; -const_iterator xpath_node_set::end() const; ----- - -[[xpath_node_set::index]][[xpath_node_set::size]][[xpath_node_set::empty]] -And it also can be iterated via indices, just like `std::vector`: - -[source] ----- -const xpath_node& xpath_node_set::operator[](size_t index) const; -size_t xpath_node_set::size() const; -bool xpath_node_set::empty() const; ----- - -All of the above operations have the same semantics as that of `std::vector`: the iterators are random-access, all of the above operations are constant time, and accessing the element at index that is greater or equal than the set size results in undefined behavior. You can use both iterator-based and index-based access for iteration, however the iterator-based one can be faster. - -[[xpath_node_set::type]][[xpath_node_set::type_unsorted]][[xpath_node_set::type_sorted]][[xpath_node_set::type_sorted_reverse]][[xpath_node_set::sort]] -The order of iteration depends on the order of nodes inside the set; the order can be queried via the following function: - -[source] ----- -enum xpath_node_set::type_t {type_unsorted, type_sorted, type_sorted_reverse}; -type_t xpath_node_set::type() const; ----- - -`type` function returns the current order of nodes; `type_sorted` means that the nodes are in forward document order, `type_sorted_reverse` means that the nodes are in reverse document order, and `type_unsorted` means that neither order is guaranteed (nodes can accidentally be in a sorted order even if `type()` returns `type_unsorted`). If you require a specific order of iteration, you can change it via `sort` function: - -[source] ----- -void xpath_node_set::sort(bool reverse = false); ----- - -Calling `sort` sorts the nodes in either forward or reverse document order, depending on the argument; after this call `type()` will return `type_sorted` or `type_sorted_reverse`. - -[[xpath_node_set::first]] -Often the actual iteration is not needed; instead, only the first element in document order is required. For this, a special accessor is provided: - -[source] ----- -xpath_node xpath_node_set::first() const; ----- - -This function returns the first node in forward document order from the set, or null node if the set is empty. Note that while the result of the node does not depend on the order of nodes in the set (i.e. on the result of `type()`), the complexity does - if the set is sorted, the complexity is constant, otherwise it is linear in the number of elements or worse. - -[[xpath_node_set::ctor]] -While in the majority of cases the node set is returned by XPath functions, sometimes there is a need to manually construct a node set. For such cases, a constructor is provided which takes an iterator range (`const_iterator` is a typedef for `const xpath_node*`), and an optional type: - -[source] ----- -xpath_node_set::xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted); ----- - -The constructor copies the specified range and sets the specified type. The objects in the range are not checked in any way; you'll have to ensure that the range contains no duplicates, and that the objects are sorted according to the `type` parameter. Otherwise XPath operations with this set may produce unexpected results. - -[[xpath.select]] -=== Selecting nodes via XPath expression - -[[xml_node::select_node]][[xml_node::select_nodes]] -If you want to select nodes that match some XPath expression, you can do it with the following functions: - -[source] ----- -xpath_node xml_node::select_node(const char_t* query, xpath_variable_set* variables = 0) const; -xpath_node_set xml_node::select_nodes(const char_t* query, xpath_variable_set* variables = 0) const; ----- - -`select_nodes` function compiles the expression and then executes it with the node as a context node, and returns the resulting node set. `select_node` returns only the first node in document order from the result, and is equivalent to calling `select_nodes(query).first()`. If the XPath expression does not match anything, or the node handle is null, `select_nodes` returns an empty set, and `select_node` returns null XPath node. - -If exception handling is not disabled, both functions throw <> if the query can not be compiled or if it returns a value with type other than node set; see <> for details. - -[[xml_node::select_node_precomp]][[xml_node::select_nodes_precomp]] -While compiling expressions is fast, the compilation time can introduce a significant overhead if the same expression is used many times on small subtrees. If you're doing many similar queries, consider compiling them into query objects (see <> for further reference). Once you get a compiled query object, you can pass it to select functions instead of an expression string: - -[source] ----- -xpath_node xml_node::select_node(const xpath_query& query) const; -xpath_node_set xml_node::select_nodes(const xpath_query& query) const; ----- - -If exception handling is not disabled, both functions throw <> if the query returns a value with type other than node set. - -This is an example of selecting nodes using XPath expressions (link:samples/xpath_select.cpp[]): - -[source,indent=0] ----- -include::samples/xpath_select.cpp[tags=code] ----- - -[[xpath.query]] -=== Using query objects - -[[xpath_query]] -When you call `select_nodes` with an expression string as an argument, a query object is created behind the scenes. A query object represents a compiled XPath expression. Query objects can be needed in the following circumstances: - -* You can precompile expressions to query objects to save compilation time if it becomes an issue; -* You can use query objects to evaluate XPath expressions which result in booleans, numbers or strings; -* You can get the type of expression value via query object. - -Query objects correspond to `xpath_query` type. They are immutable and non-copyable: they are bound to the expression at creation time and can not be cloned. If you want to put query objects in a container, either allocate them on heap via `new` operator and store pointers to `xpath_query` in the container, or use a C++11 compiler (query objects are movable in C++11). - -[[xpath_query::ctor]] -You can create a query object with the constructor that takes XPath expression as an argument: - -[source] ----- -explicit xpath_query::xpath_query(const char_t* query, xpath_variable_set* variables = 0); ----- - -[[xpath_query::return_type]] -The expression is compiled and the compiled representation is stored in the new query object. If compilation fails, <> is thrown if exception handling is not disabled (see <> for details). After the query is created, you can query the type of the evaluation result using the following function: - -[source] ----- -xpath_value_type xpath_query::return_type() const; ----- - -[[xpath_query::evaluate_boolean]][[xpath_query::evaluate_number]][[xpath_query::evaluate_string]][[xpath_query::evaluate_node_set]][[xpath_query::evaluate_node]] -You can evaluate the query using one of the following functions: - -[source] ----- -bool xpath_query::evaluate_boolean(const xpath_node& n) const; -double xpath_query::evaluate_number(const xpath_node& n) const; -string_t xpath_query::evaluate_string(const xpath_node& n) const; -xpath_node_set xpath_query::evaluate_node_set(const xpath_node& n) const; -xpath_node xpath_query::evaluate_node(const xpath_node& n) const; ----- - -All functions take the context node as an argument, compute the expression and return the result, converted to the requested type. According to XPath specification, value of any type can be converted to boolean, number or string value, but no type other than node set can be converted to node set. Because of this, `evaluate_boolean`, `evaluate_number` and `evaluate_string` always return a result, but `evaluate_node_set` and `evaluate_node` result in an error if the return type is not node set (see <>). - -NOTE: Calling `node.select_nodes("query")` is equivalent to calling `xpath_query("query").evaluate_node_set(node)`. Calling `node.select_node("query")` is equivalent to calling `xpath_query("query").evaluate_node(node)`. - -[[xpath_query::evaluate_string_buffer]] -Note that `evaluate_string` function returns the STL string; as such, it's not available in <> mode and also usually allocates memory. There is another string evaluation function: - -[source] ----- -size_t xpath_query::evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const; ----- - -This function evaluates the string, and then writes the result to `buffer` (but at most `capacity` characters); then it returns the full size of the result in characters, including the terminating zero. If `capacity` is not 0, the resulting buffer is always zero-terminated. You can use this function as follows: - -* First call the function with `buffer = 0` and `capacity = 0`; then allocate the returned amount of characters, and call the function again, passing the allocated storage and the amount of characters; -* First call the function with small buffer and buffer capacity; then, if the result is larger than the capacity, the output has been trimmed, so allocate a larger buffer and call the function again. - -This is an example of using query objects (link:samples/xpath_query.cpp[]): - -[source,indent=0] ----- -include::samples/xpath_query.cpp[tags=code] ----- - -[[xpath.variables]] -=== Using variables - -XPath queries may contain references to variables; this is useful if you want to use queries that depend on some dynamic parameter without manually preparing the complete query string, or if you want to reuse the same query object for similar queries. - -Variable references have the form `$name`; in order to use them, you have to provide a variable set, which includes all variables present in the query with correct types. This set is passed to `xpath_query` constructor or to `select_nodes`/`select_node` functions: - -[source] ----- -explicit xpath_query::xpath_query(const char_t* query, xpath_variable_set* variables = 0); -xpath_node xml_node::select_node(const char_t* query, xpath_variable_set* variables = 0) const; -xpath_node_set xml_node::select_nodes(const char_t* query, xpath_variable_set* variables = 0) const; ----- - -If you're using query objects, you can change the variable values before `evaluate`/`select` calls to change the query behavior. - -NOTE: The variable set pointer is stored in the query object; you have to ensure that the lifetime of the set exceeds that of query object. - -[[xpath_variable_set]] -Variable sets correspond to `xpath_variable_set` type, which is essentially a variable container. - -[[xpath_variable_set::add]] -You can add new variables with the following function: - -[source] ----- -xpath_variable* xpath_variable_set::add(const char_t* name, xpath_value_type type); ----- - -The function tries to add a new variable with the specified name and type; if the variable with such name does not exist in the set, the function adds a new variable and returns the variable handle; if there is already a variable with the specified name, the function returns the variable handle if variable has the specified type. Otherwise the function returns null pointer; it also returns null pointer on allocation failure. - -New variables are assigned the default value which depends on the type: `0` for numbers, `false` for booleans, empty string for strings and empty set for node sets. - -[[xpath_variable_set::get]] -You can get the existing variables with the following functions: - -[source] ----- -xpath_variable* xpath_variable_set::get(const char_t* name); -const xpath_variable* xpath_variable_set::get(const char_t* name) const; ----- - -The functions return the variable handle, or null pointer if the variable with the specified name is not found. - -[[xpath_variable_set::set]] -Additionally, there are the helper functions for setting the variable value by name; they try to add the variable with the corresponding type, if it does not exist, and to set the value. If the variable with the same name but with different type is already present, they return `false`; they also return `false` on allocation failure. Note that these functions do not perform any type conversions. - -[source] ----- -bool xpath_variable_set::set(const char_t* name, bool value); -bool xpath_variable_set::set(const char_t* name, double value); -bool xpath_variable_set::set(const char_t* name, const char_t* value); -bool xpath_variable_set::set(const char_t* name, const xpath_node_set& value); ----- - -The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return. - -[[xpath_variable]] -If setting variables by name is not efficient enough, or if you have to inspect variable information or get variable values, you can use variable handles. A variable corresponds to the `xpath_variable` type, and a variable handle is simply a pointer to `xpath_variable`. - -[[xpath_variable::type]][[xpath_variable::name]] -In order to get variable information, you can use one of the following functions: - -[source] ----- -const char_t* xpath_variable::name() const; -xpath_value_type xpath_variable::type() const; ----- - -Note that each variable has a distinct type which is specified upon variable creation and can not be changed later. - -[[xpath_variable::get_boolean]][[xpath_variable::get_number]][[xpath_variable::get_string]][[xpath_variable::get_node_set]] -In order to get variable value, you should use one of the following functions, depending on the variable type: - -[source] ----- -bool xpath_variable::get_boolean() const; -double xpath_variable::get_number() const; -const char_t* xpath_variable::get_string() const; -const xpath_node_set& xpath_variable::get_node_set() const; ----- - -These functions return the value of the variable. Note that no type conversions are performed; if the type mismatch occurs, a dummy value is returned (`false` for booleans, `NaN` for numbers, empty string for strings and empty set for node sets). - -[[xpath_variable::set]] -In order to set variable value, you should use one of the following functions, depending on the variable type: - -[source] ----- -bool xpath_variable::set(bool value); -bool xpath_variable::set(double value); -bool xpath_variable::set(const char_t* value); -bool xpath_variable::set(const xpath_node_set& value); ----- - -These functions modify the variable value. Note that no type conversions are performed; if the type mismatch occurs, the functions return `false`; they also return `false` on allocation failure. The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return. - -This is an example of using variables in XPath queries (link:samples/xpath_variables.cpp[]): - -[source,indent=0] ----- -include::samples/xpath_variables.cpp[tags=code] ----- - -[[xpath.errors]] -=== Error handling - -There are two different mechanisms for error handling in XPath implementation; the mechanism used depends on whether exception support is disabled (this is controlled with <> define). - -[[xpath_exception]][[xpath_exception::result]][[xpath_exception::what]] -By default, XPath functions throw `xpath_exception` object in case of errors; additionally, in the event any memory allocation fails, an `std::bad_alloc` exception is thrown. Also `xpath_exception` is thrown if the query is evaluated to a node set, but the return type is not node set. If the query constructor succeeds (i.e. no exception is thrown), the query object is valid. Otherwise you can get the error details via one of the following functions: - -[source] ----- -virtual const char* xpath_exception::what() const throw(); -const xpath_parse_result& xpath_exception::result() const; ----- - -[[xpath_query::unspecified_bool_type]][[xpath_query::result]] -If exceptions are disabled, then in the event of parsing failure the query is initialized to invalid state; you can test if the query object is valid by using it in a boolean expression: `if (query) { ... }`. Additionally, you can get parsing result via the result() accessor: - -[source] ----- -const xpath_parse_result& xpath_query::result() const; ----- - -Without exceptions, evaluating invalid query results in `false`, empty string, `NaN` or an empty node set, depending on the type; evaluating a query as a node set results in an empty node set if the return type is not node set. - -[[xpath_parse_result]] -The information about parsing result is returned via `xpath_parse_result` object. It contains parsing status and the offset of last successfully parsed character from the beginning of the source stream: - -[source] ----- -struct xpath_parse_result -{ - const char* error; - ptrdiff_t offset; - - operator bool() const; - const char* description() const; -}; ----- - -[[xpath_parse_result::error]] -Parsing result is represented as the error message; it is either a null pointer, in case there is no error, or the error message in the form of ASCII zero-terminated string. - -[[xpath_parse_result::description]] -`description()` member function can be used to get the error message; it never returns the null pointer, so you can safely use `description()` even if query parsing succeeded. Note that `description()` returns a `char` string even in `PUGIXML_WCHAR_MODE`; you'll have to call <> to get the `wchar_t` string. - -[[xpath_parse_result::offset]] -In addition to the error message, parsing result has an `offset` member, which contains the offset of last successfully parsed character. This offset is in units of <> (bytes for character mode, wide characters for wide character mode). - -[[xpath_parse_result::bool]] -Parsing result object can be implicitly converted to `bool` like this: `if (result) { ... } else { ... }`. - -This is an example of XPath error handling (link:samples/xpath_error.cpp[]): - -[source,indent=0] ----- -include::samples/xpath_error.cpp[tags=code] ----- - -[[xpath.w3c]] -=== Conformance to W3C specification - -Because of the differences in document object models, performance considerations and implementation complexity, pugixml does not provide a fully conformant XPath 1.0 implementation. This is the current list of incompatibilities: - -* Consecutive text nodes sharing the same parent are not merged, i.e. in `text1 text2` node should have one text node child, but instead has three. -* Since the document type declaration is not used for parsing, `id()` function always returns an empty node set. -* Namespace nodes are not supported (affects `namespace::` axis). -* Name tests are performed on QNames in XML document instead of expanded names; for ``, query `foo/ns1:*` will return only the first child, not both of them. Compliant XPath implementations can return both nodes if the user provides appropriate namespace declarations. -* String functions consider a character to be either a single `char` value or a single `wchar_t` value, depending on the library configuration; this means that some string functions are not fully Unicode-aware. This affects `substring()`, `string-length()` and `translate()` functions. - -[[changes]] -== Changelog - -:!numbered: - -[[v1.10]] -=== v1.10 ^2019-09-15^ - -Maintenance release. Changes: - -* Behavior changes: - . Tab characters (ASCII 9) in attribute values are now encoded as ' ' to survive roundtripping - . `>` characters are no longer escaped in attribute values - -* New features: - . Add Visual Studio .natvis files to improve debugging experience - . CMake improvements (USE_POSTFIX and BUILD_SHARED_AND_STATIC_LIBS options for building multiple versions and pkg-config tweaks) - . Add format_skip_control_chars formatting flag to skip non-printable ASCII characters that are invalid to use in well-formed XML files - . Add format_attribute_single_quote formatting flag to use single quotes for attribute values instead of default double quotes. - -* XPath improvements: - . XPath union now results in a stable order that doesn't depend on memory allocations; crucially, this may require sorting the output of XPath query operation if you rely on the document-ordered traversal - . Improve performance of XPath union operation, making it ~2x faster - -* Compatibility improvements: - . Fix Visual Studio warnings when built in a DLL configuration - . Fix static analysis false positives in Coverity and clang - . Fix Wdouble-promotion warnings in gcc - . Add Visual Studio 2019 support for NuGet packages - -[[v1.9]] -=== v1.9 ^2018-04-04^ - -Maintenance release. Changes: - -* Specification changes: - . `xml_document::load(const char*)` (deprecated in 1.5) now has `deprecated` attribute; use `xml_document::load_string` instead - . `xml_node::select_single_node` (deprecated in 1.5) now has `deprecated` attribute; use `xml_node::select_node` instead - -* New features: - . Add move semantics support for xml_document and improve move semantics support for other objects - . CMake build now exports include directories - . CMake build with BUILD_SHARED_LIBS=ON now uses dllexport attribute for MSVC - -* XPath improvements: - . Rework parser/evaluator to not rely on exceptional control flow; longjmp is no longer used when exceptions are disabled - . Improve error messages for certain invalid expressions such as `.[1]` or `(1` - . Minor performance improvements - -* Compatibility improvements: - . Fix Texas Instruments compiler warnings - . Fix compilation issues with limits.h for some versions of gcc - . Fix compilation issues with Clang/C2 - . Fix implicit fallthrough warnings in gcc 7 - . Fix unknown attribute directive warnings in gcc 8 - . Fix cray++ compiler errors - . Fix unsigned integer overflow errors with -fsanitize=integer - . Fix undefined behavior sanitizer issues in compact mode - -[[v1.8]] -=== v1.8 ^2016-11-24^ - -Maintenance release. Changes: - -* Specification changes: - . When printing empty elements, a space is no longer added before / in format_raw mode - -* New features: - . Added parse_embed_pcdata parsing mode in which PCDATA value is stored in the element node if possible (significantly reducing memory consumption for some documents) - . Added auto-detection support for Latin-1 (ISO-8859-1) encoding during parsing - . Added format_no_empty_element_tags formatting flag that outputs start/end tags instead of empty element tags for empty elements - -* Performance improvements: - . Minor memory allocation improvements (yielding up to 1% memory savings in some cases) - -* Compatibility improvements: - . Fixed compilation issues for Borland C++ 5.4 - . Fixed compilation issues for some distributions of MinGW 3.8 - . Fixed various Clang/GCC warnings - . Enabled move semantics support for XPath objects for MSVC 2010 and above - -[[v1.7]] -=== v1.7 ^2015-10-19^ - -Major release, featuring performance and memory improvements along with some new features. Changes: - -* Compact mode: - . Introduced a new tree storage mode that takes significantly less memory (2-5x smaller DOM) at some performance cost. - . The mode can be enabled using `PUGIXML_COMPACT` define. - -* New integer parsing/formatting implementation: - . Functions that convert from and to integers (e.g. `as_int`/`set_value`) do not rely on CRT any more. - . New implementation is 3-5x faster and is always correct wrt overflow or underflow. This is a behavior change - where previously `as_uint()` would return UINT_MAX on a value "-1", it now returns 0. - -* New features: - . XPath objects (`xpath_query`, `xpath_node_set`, `xpath_variable_set`) are now movable if your compiler supports C++11. Additionally, `xpath_variable_set` is copyable. - . Added `format_indent_attributes` that makes the resulting XML friendlier to line diff/merge tools. - . Added a variant of `xml_node::attribute` function with a hint that can improve lookup performance. - . Custom allocation functions are now allowed (but not required) to throw instead of returning a null pointer. - -* Bug fixes: - . Fix Clang 3.7 crashes in out-of-memory cases (C++ DR 1748) - . Fix XPath crashes on SPARC64 (and other 32-bit architectures where doubles have to be aligned to 8 bytes) - . Fix xpath_node_set assignment to provide strong exception guarantee - . Fix saving for custom xml_writer implementations that can throw from write() - -[[v1.6]] -=== v1.6 ^2015-04-10^ - -Maintenance release. Changes: - -* Specification changes: - . Attribute/text values now use more digits when printing floating point numbers to guarantee round-tripping. - . Text nodes no longer get extra surrounding whitespace when pretty-printing nodes with mixed contents - -* Bug fixes: - . Fixed translate and normalize-space XPath functions to no longer return internal NUL characters - . Fixed buffer overrun on malformed comments inside DOCTYPE sections - . DOCTYPE parsing can no longer run out of stack space on malformed inputs (XML parsing is now using bounded stack space) - . Adjusted processing instruction output to avoid malformed documents if the PI value contains `?>` - -[[v1.5]] -=== v1.5 ^2014-11-27^ - -Major release, featuring a lot of performance improvements and some new features. - -* Specification changes: - . `xml_document::load(const char_t*)` was renamed to `load_string`; the old method is still available and will be deprecated in a future release - . `xml_node::select_single_node` was renamed to `select_node`; the old method is still available and will be deprecated in a future release. - -* New features: - . Added `xml_node::append_move` and other functions for moving nodes within a document - . Added `xpath_query::evaluate_node` for evaluating queries with a single node as a result - -* Performance improvements: - . Optimized XML parsing (10-40% faster with clang/gcc, up to 10% faster with MSVC) - . Optimized memory consumption when copying nodes in the same document (string contents is now shared) - . Optimized node copying (10% faster for cross-document copies, 3x faster for inter-document copies; also it now consumes a constant amount of stack space) - . Optimized node output (60% faster; also it now consumes a constant amount of stack space) - . Optimized XPath allocation (query evaluation now results in fewer temporary allocations) - . Optimized XPath sorting (node set sorting is 2-3x faster in some cases) - . Optimized XPath evaluation (XPathMark suite is 100x faster; some commonly used queries are 3-4x faster) - -* Compatibility improvements: - . Fixed `xml_node::offset_debug` for corner cases - . Fixed undefined behavior while calling memcpy in some cases - . Fixed MSVC 2015 compilation warnings - . Fixed `contrib/foreach.hpp` for Boost 1.56.0 - -* Bug fixes - . Adjusted comment output to avoid malformed documents if the comment value contains `--` - . Fix XPath sorting for documents that were constructed using append_buffer - . Fix `load_file` for wide-character paths with non-ASCII characters in MinGW with C{plus}{plus}11 mode enabled - -[[v1.4]] -=== v1.4 ^2014-02-27^ - -Major release, featuring various new features, bug fixes and compatibility improvements. - -* Specification changes: - . Documents without element nodes are now rejected with `status_no_document_element` error, unless `parse_fragment` option is used - -* New features: - . Added XML fragment parsing (`parse_fragment` flag) - . Added PCDATA whitespace trimming (`parse_trim_pcdata` flag) - . Added long long support for `xml_attribute` and `xml_text` (`as_llong`, `as_ullong` and `set_value`/`set` overloads) - . Added hexadecimal integer parsing support for `as_int`/`as_uint`/`as_llong`/`as_ullong` - . Added `xml_node::append_buffer` to improve performance of assembling documents from fragments - . `xml_named_node_iterator` is now bidirectional - . Reduced XPath stack consumption during compilation and evaluation (useful for embedded systems) - -* Compatibility improvements: - . Improved support for platforms without wchar_t support - . Fixed several false positives in clang static analysis - . Fixed several compilation warnings for various GCC versions - -* Bug fixes: - . Fixed undefined pointer arithmetic in XPath implementation - . Fixed non-seekable iostream support for certain stream types, i.e. Boost `file_source` with pipe input - . Fixed `xpath_query::return_type` for some expressions - . Fixed dllexport issues with `xml_named_node_iterator` - . Fixed `find_child_by_attribute` assertion for attributes with null name/value - -[[v1.2]] -=== v1.2 ^2012-05-01^ - -Major release, featuring header-only mode, various interface enhancements (i.e. PCDATA manipulation and C{plus}{plus}11 iteration), many other features and compatibility improvements. - -* New features: - . Added `xml_text` helper class for working with PCDATA/CDATA contents of an element node - . Added optional header-only mode (controlled by `PUGIXML_HEADER_ONLY` define) - . Added `xml_node::children()` and `xml_node::attributes()` for C{plus}{plus}11 ranged for loop or `BOOST_FOREACH` - . Added support for Latin-1 (ISO-8859-1) encoding conversion during loading and saving - . Added custom default values for `xml_attribute::as_*` (they are returned if the attribute does not exist) - . Added `parse_ws_pcdata_single` flag for preserving whitespace-only PCDATA in case it's the only child - . Added `format_save_file_text` for `xml_document::save_file` to open files as text instead of binary (changes newlines on Windows) - . Added `format_no_escapes` flag to disable special symbol escaping (complements `~parse_escapes`) - . Added support for loading document from streams that do not support seeking - . Added `PUGIXML_MEMORY_*` constants for tweaking allocation behavior (useful for embedded systems) - . Added `PUGIXML_VERSION` preprocessor define - -* Compatibility improvements: - . Parser does not require setjmp support (improves compatibility with some embedded platforms, enables `/clr:pure` compilation) - . STL forward declarations are no longer used (fixes SunCC/RWSTL compilation, fixes clang compilation in C{plus}{plus}11 mode) - . Fixed AirPlay SDK, Android, Windows Mobile (WinCE) and C{plus}{plus}/CLI compilation - . Fixed several compilation warnings for various GCC versions, Intel C{plus}{plus} compiler and Clang - -* Bug fixes: - . Fixed unsafe bool conversion to avoid problems on C{plus}{plus}/CLI - . Iterator dereference operator is const now (fixes Boost `filter_iterator` support) - . `xml_document::save_file` now checks for file I/O errors during saving - -[[v1.0]] -=== v1.0 ^2010-11-01^ - -Major release, featuring many XPath enhancements, wide character filename support, miscellaneous performance improvements, bug fixes and more. - -* XPath: - . XPath implementation is moved to `pugixml.cpp` (which is the only source file now); use `PUGIXML_NO_XPATH` if you want to disable XPath to reduce code size - . XPath is now supported without exceptions (`PUGIXML_NO_EXCEPTIONS`); the error handling mechanism depends on the presence of exception support - . XPath is now supported without STL (`PUGIXML_NO_STL`) - . Introduced variable support - . Introduced new `xpath_query::evaluate_string`, which works without STL - . Introduced new `xpath_node_set` constructor (from an iterator range) - . Evaluation function now accept attribute context nodes - . All internal allocations use custom allocation functions - . Improved error reporting; now a last parsed offset is returned together with the parsing error - -* Bug fixes: - . Fixed memory leak for loading from streams with stream exceptions turned on - . Fixed custom deallocation function calling with null pointer in one case - . Fixed missing attributes for iterator category functions; all functions/classes can now be DLL-exported - . Worked around Digital Mars compiler bug, which lead to minor read overfetches in several functions - . `load_file` now works with 2+ Gb files in MSVC/MinGW - . XPath: fixed memory leaks for incorrect queries - . XPath: fixed `xpath_node()` attribute constructor with empty attribute argument - . XPath: fixed `lang()` function for non-ASCII arguments - -* Specification changes: - . CDATA nodes containing `]]>` are printed as several nodes; while this changes the internal structure, this is the only way to escape CDATA contents - . Memory allocation errors during parsing now preserve last parsed offset (to give an idea about parsing progress) - . If an element node has the only child, and it is of CDATA type, then the extra indentation is omitted (previously this behavior only held for PCDATA children) - -* Additional functionality: - . Added `xml_parse_result` default constructor - . Added `xml_document::load_file` and `xml_document::save_file` with wide character paths - . Added `as_utf8` and `as_wide` overloads for `std::wstring`/`std::string` arguments - . Added DOCTYPE node type (`node_doctype`) and a special parse flag, `parse_doctype`, to add such nodes to the document during parsing - . Added `parse_full` parse flag mask, which extends `parse_default` with all node type parsing flags except `parse_ws_pcdata` - . Added `xml_node::hash_value()` and `xml_attribute::hash_value()` functions for use in hash-based containers - . Added `internal_object()` and additional constructor for both `xml_node` and `xml_attribute` for easier marshalling (useful for language bindings) - . Added `xml_document::document_element()` function - . Added `xml_node::prepend_attribute`, `xml_node::prepend_child` and `xml_node::prepend_copy` functions - . Added `xml_node::append_child`, `xml_node::prepend_child`, `xml_node::insert_child_before` and `xml_node::insert_child_after` overloads for element nodes (with name instead of type) - . Added `xml_document::reset()` function - -* Performance improvements: - . `xml_node::root()` and `xml_node::offset_debug()` are now O(1) instead of O(logN) - . Minor parsing optimizations - . Minor memory optimization for strings in DOM tree (`set_name`/`set_value`) - . Memory optimization for string memory reclaiming in DOM tree (`set_name`/`set_value` now reallocate the buffer if memory waste is too big) - . XPath: optimized document order sorting - . XPath: optimized child/attribute axis step - . XPath: optimized number-to-string conversions in MSVC - . XPath: optimized concat for many arguments - . XPath: optimized evaluation allocation mechanism: constant and document strings are not heap-allocated - . XPath: optimized evaluation allocation mechanism: all temporaries' allocations use fast stack-like allocator - -* Compatibility: - . Removed wildcard functions (`xml_node::child_w`, `xml_node::attribute_w`, etc.) - . Removed `xml_node::all_elements_by_name` - . Removed `xpath_type_t` enumeration; use `xpath_value_type` instead - . Removed `format_write_bom_utf8` enumeration; use `format_write_bom` instead - . Removed `xml_document::precompute_document_order`, `xml_attribute::document_order` and `xml_node::document_order` functions; document order sort optimization is now automatic - . Removed `xml_document::parse` functions and `transfer_ownership` struct; use `xml_document::load_buffer_inplace` and `xml_document::load_buffer_inplace_own` instead - . Removed `as_utf16` function; use `as_wide` instead - -[[v0.9]] -=== v0.9 ^2010-07-01^ - -Major release, featuring extended and improved Unicode support, miscellaneous performance improvements, bug fixes and more. - -* Major Unicode improvements: - . Introduced encoding support (automatic/manual encoding detection on load, manual encoding selection on save, conversion from/to UTF8, UTF16 LE/BE, UTF32 LE/BE) - . Introduced `wchar_t` mode (you can set `PUGIXML_WCHAR_MODE` define to switch pugixml internal encoding from UTF8 to `wchar_t`; all functions are switched to their Unicode variants) - . Load/save functions now support wide streams - -* Bug fixes: - . Fixed document corruption on failed parsing bug - . XPath string/number conversion improvements (increased precision, fixed crash for huge numbers) - . Improved DOCTYPE parsing: now parser recognizes all well-formed DOCTYPE declarations - . Fixed `xml_attribute::as_uint()` for large numbers (i.e. 2^32^-1) - . Fixed `xml_node::first_element_by_path` for path components that are prefixes of node names, but are not exactly equal to them. - -* Specification changes: - . `parse()` API changed to `load_buffer`/`load_buffer_inplace`/`load_buffer_inplace_own`; `load_buffer` APIs do not require zero-terminated strings. - . Renamed `as_utf16` to `as_wide` - . Changed `xml_node::offset_debug` return type and `xml_parse_result::offset` type to `ptrdiff_t` - . Nodes/attributes with empty names are now printed as `:anonymous` - -* Performance improvements: - . Optimized document parsing and saving - . Changed internal memory management: internal allocator is used for both metadata and name/value data; allocated pages are deleted if all allocations from them are deleted - . Optimized memory consumption: `sizeof(xml_node_struct)` reduced from 40 bytes to 32 bytes on x86 - . Optimized debug mode parsing/saving by order of magnitude - -* Miscellaneous: - . All STL includes except `` in `pugixml.hpp` are replaced with forward declarations - . `xml_node::remove_child` and `xml_node::remove_attribute` now return the operation result - -* Compatibility: - . `parse()` and `as_utf16` are left for compatibility (these functions are deprecated and will be removed in version 1.0) - . Wildcard functions, `document_order`/`precompute_document_order` functions, `all_elements_by_name` function and `format_write_bom_utf8` flag are deprecated and will be removed in version 1.0 - . `xpath_type_t` enumeration was renamed to `xpath_value_type`; `xpath_type_t` is deprecated and will be removed in version 1.0 - -[[v0.5]] -=== v0.5 ^2009-11-08^ - -Major bugfix release. Changes: - -* XPath bugfixes: - . Fixed `translate()`, `lang()` and `concat()` functions (infinite loops/crashes) - . Fixed compilation of queries with empty literal strings (`""`) - . Fixed axis tests: they never add empty nodes/attributes to the resulting node set now - . Fixed string-value evaluation for node-set (the result excluded some text descendants) - . Fixed `self::` axis (it behaved like `ancestor-or-self::`) - . Fixed `following::` and `preceding::` axes (they included descendent and ancestor nodes, respectively) - . Minor fix for `namespace-uri()` function (namespace declaration scope includes the parent element of namespace declaration attribute) - . Some incorrect queries are no longer parsed now (i.e. `foo: *`) - . Fixed `text()`/etc. node test parsing bug (i.e. `foo[text()]` failed to compile) - . Fixed root step (`/`) - it now selects empty node set if query is evaluated on empty node - . Fixed string to number conversion (`"123 "` converted to NaN, `"123 .456"` converted to 123.456 - now the results are 123 and NaN, respectively) - . Node set copying now preserves sorted type; leads to better performance on some queries - -* Miscellaneous bugfixes: - . Fixed `xml_node::offset_debug` for PI nodes - . Added empty attribute checks to `xml_node::remove_attribute` - . Fixed `node_pi` and `node_declaration` copying - . Const-correctness fixes - -* Specification changes: - . `xpath_node::select_nodes()` and related functions now throw exception if expression return type is not node set (instead of assertion) - . `xml_node::traverse()` now sets depth to -1 for both `begin()` and `end()` callbacks (was 0 at `begin()` and -1 at `end()`) - . In case of non-raw node printing a newline is output after PCDATA inside nodes if the PCDATA has siblings - . UTF8 -> `wchar_t` conversion now considers 5-byte UTF8-like sequences as invalid - -* New features: - . Added `xpath_node_set::operator[]` for index-based iteration - . Added `xpath_query::return_type()` - . Added getter accessors for memory-management functions - -[[v0.42]] -=== v0.42 ^2009-09-17^ - -Maintenance release. Changes: - -* Bug fixes: - . Fixed deallocation in case of custom allocation functions or if `delete[]` / `free` are incompatible - . XPath parser fixed for incorrect queries (i.e. incorrect XPath queries should now always fail to compile) - . Const-correctness fixes for `find_child_by_attribute` - . Improved compatibility (miscellaneous warning fixes, fixed `` include dependency for GCC) - . Fixed iterator begin/end and print function to work correctly for empty nodes - -* New features: - . Added `PUGIXML_API`/`PUGIXML_CLASS`/`PUGIXML_FUNCTION` configuration macros to control class/function attributes - . Added `xml_attribute::set_value` overloads for different types - -[[v0.41]] -=== v0.41 ^2009-02-08^ - -Maintenance release. Changes: - -* Bug fixes: - . Fixed bug with node printing (occasionally some content was not written to output stream) - -[[v0.4]] -=== v0.4 ^2009-01-18^ - -Changes: - -* Bug fixes: - . Documentation fix in samples for `parse()` with manual lifetime control - . Fixed document order sorting in XPath (it caused wrong order of nodes after `xpath_node_set::sort` and wrong results of some XPath queries) - -* Node printing changes: - . Single quotes are no longer escaped when printing nodes - . Symbols in second half of ASCII table are no longer escaped when printing nodes; because of this, `format_utf8` flag is deleted as it's no longer needed and `format_write_bom` is renamed to `format_write_bom_utf8`. - . Reworked node printing - now it works via `xml_writer` interface; implementations for `FILE*` and `std::ostream` are available. As a side-effect, `xml_document::save_file` now works without STL. - -* New features: - . Added unsigned integer support for attributes (`xml_attribute::as_uint`, `xml_attribute::operator=`) - . Now document declaration (``) is parsed as node with type `node_declaration` when `parse_declaration` flag is specified (access to encoding/version is performed as if they were attributes, i.e. `doc.child("xml").attribute("version").as_float()`); corresponding flags for node printing were also added - . Added support for custom memory management (see `set_memory_management_functions` for details) - . Implemented node/attribute copying (see `xml_node::insert_copy_*` and `xml_node::append_copy` for details) - . Added `find_child_by_attribute` and `find_child_by_attribute_w` to simplify parsing code in some cases (i.e. COLLADA files) - . Added file offset information querying for debugging purposes (now you're able to determine exact location of any `xml_node` in parsed file, see `xml_node::offset_debug` for details) - . Improved error handling for parsing - now `load()`, `load_file()` and `parse()` return `xml_parse_result`, which contains error code and last parsed offset; this does not break old interface as `xml_parse_result` can be implicitly casted to `bool`. - -[[v0.34]] -=== v0.34 ^2007-10-31^ - -Maintenance release. Changes: - -* Bug fixes: - . Fixed bug with loading from text-mode iostreams - . Fixed leak when `transfer_ownership` is true and parsing is failing - . Fixed bug in saving (`\r` and `\n` are now escaped in attribute values) - . Renamed `free()` to `destroy()` - some macro conflicts were reported - -* New features: - . Improved compatibility (supported Digital Mars C{plus}{plus}, MSVC 6, CodeWarrior 8, PGI C{plus}{plus}, Comeau, supported PS3 and XBox360) - . `PUGIXML_NO_EXCEPTION` flag for platforms without exception handling - -[[v0.3]] -=== v0.3 ^2007-02-21^ - -Refactored, reworked and improved version. Changes: - -* Interface: - . Added XPath - . Added tree modification functions - . Added no STL compilation mode - . Added saving document to file - . Refactored parsing flags - . Removed `xml_parser` class in favor of `xml_document` - . Added transfer ownership parsing mode - . Modified the way `xml_tree_walker` works - . Iterators are now non-constant - -* Implementation: - . Support of several compilers and platforms - . Refactored and sped up parsing core - . Improved standard compliancy - . Added XPath implementation - . Fixed several bugs - -[[v0.2]] -=== v0.2 ^2006-11-06^ - -First public release. Changes: - -* Bug fixes: - . Fixed `child_value()` (for empty nodes) - . Fixed `xml_parser_impl` warning at W4 - -* New features: - . Introduced `child_value(name)` and `child_value_w(name)` - . `parse_eol_pcdata` and `parse_eol_attribute` flags + `parse_minimal` optimizations - . Optimizations of `strconv_t` - -[[v0.1]] -=== v0.1 ^2006-07-15^ - -First private release for testing purposes - -:numbered: - -[[apiref]] -== API Reference - -This is the reference for all macros, types, enumerations, classes and functions in pugixml. Each symbol is a link that leads to the relevant section of the manual. - -[[apiref.macros]] -=== Macros - -[source,subs="+macros"] ----- -#define +++PUGIXML_WCHAR_MODE+++ -#define +++PUGIXML_COMPACT+++ -#define +++PUGIXML_NO_XPATH+++ -#define +++PUGIXML_NO_STL+++ -#define +++PUGIXML_NO_EXCEPTIONS+++ -#define +++PUGIXML_API+++ -#define +++PUGIXML_CLASS+++ -#define +++PUGIXML_FUNCTION+++ -#define +++PUGIXML_MEMORY_PAGE_SIZE+++ -#define +++PUGIXML_MEMORY_OUTPUT_STACK+++ -#define +++PUGIXML_MEMORY_XPATH_PAGE_SIZE+++ -#define +++PUGIXML_HEADER_ONLY+++ -#define +++PUGIXML_HAS_LONG_LONG+++ ----- - -[[apiref.types]] -=== Types - -[source,subs="+macros"] ----- -typedef configuration-defined-type +++char_t+++; -typedef configuration-defined-type +++string_t+++; -typedef void* (*+++allocation_function+++)(size_t size); -typedef void (*+++deallocation_function+++)(void* ptr); ----- - -[[apiref.enums]] -=== Enumerations - -[source,subs="+macros"] ----- -enum +++xml_node_type+++ - +++node_null+++ - +++node_document+++ - +++node_element+++ - +++node_pcdata+++ - +++node_cdata+++ - +++node_comment+++ - +++node_pi+++ - +++node_declaration+++ - +++node_doctype+++ - -enum +++xml_parse_status+++ - +++status_ok+++ - +++status_file_not_found+++ - +++status_io_error+++ - +++status_out_of_memory+++ - +++status_internal_error+++ - +++status_unrecognized_tag+++ - +++status_bad_pi+++ - +++status_bad_comment+++ - +++status_bad_cdata+++ - +++status_bad_doctype+++ - +++status_bad_pcdata+++ - +++status_bad_start_element+++ - +++status_bad_attribute+++ - +++status_bad_end_element+++ - +++status_end_element_mismatch+++ - +++status_append_invalid_root+++ - +++status_no_document_element+++ - -enum +++xml_encoding+++ - +++encoding_auto+++ - +++encoding_utf8+++ - +++encoding_utf16_le+++ - +++encoding_utf16_be+++ - +++encoding_utf16+++ - +++encoding_utf32_le+++ - +++encoding_utf32_be+++ - +++encoding_utf32+++ - +++encoding_wchar+++ - +++encoding_latin1+++ - -enum +++xpath_value_type+++ - +++xpath_type_none+++ - +++xpath_type_node_set+++ - +++xpath_type_number+++ - +++xpath_type_string+++ - +++xpath_type_boolean+++ ----- - -[[apiref.constants]] -=== Constants - -[source,subs="+macros"] ----- -// Formatting options bit flags: -const unsigned int +++format_attribute_single_quote+++ -const unsigned int +++format_default+++ -const unsigned int +++format_indent+++ -const unsigned int +++format_indent_attributes+++ -const unsigned int +++format_no_declaration+++ -const unsigned int +++format_no_empty_element_tags+++ -const unsigned int +++format_no_escapes+++ -const unsigned int +++format_raw+++ -const unsigned int +++format_save_file_text+++ -const unsigned int +++format_skip_control_chars+++ -const unsigned int +++format_write_bom+++ - -// Parsing options bit flags: -const unsigned int +++parse_cdata+++ -const unsigned int +++parse_comments+++ -const unsigned int +++parse_declaration+++ -const unsigned int +++parse_default+++ -const unsigned int +++parse_doctype+++ -const unsigned int +++parse_eol+++ -const unsigned int +++parse_escapes+++ -const unsigned int +++parse_fragment+++ -const unsigned int +++parse_full+++ -const unsigned int +++parse_minimal+++ -const unsigned int +++parse_pi+++ -const unsigned int +++parse_trim_pcdata+++ -const unsigned int +++parse_ws_pcdata+++ -const unsigned int +++parse_ws_pcdata_single+++ -const unsigned int +++parse_embed_pcdata+++ -const unsigned int +++parse_wconv_attribute+++ -const unsigned int +++parse_wnorm_attribute+++ ----- - -[[apiref.classes]] -=== Classes - -[source,subs="+macros"] ----- -+++class xml_attribute+++ - +++xml_attribute+++(); - - bool +++empty+++() const; - operator +++unspecified_bool_type+++() const; - - bool +++operator==+++(const xml_attribute& r) const; - bool +++operator!=+++(const xml_attribute& r) const; - bool +++operator<+++(const xml_attribute& r) const; - bool +++operator>+++(const xml_attribute& r) const; - bool +++operator<=+++(const xml_attribute& r) const; - bool +++operator>=+++(const xml_attribute& r) const; - - size_t +++hash_value+++() const; - - xml_attribute +++next_attribute+++() const; - xml_attribute +++previous_attribute+++() const; - - const char_t* +++name+++() const; - const char_t* +++value+++() const; - - const char_t* +++as_string+++(const char_t* def = "") const; - int +++as_int+++(int def = 0) const; - unsigned int +++as_uint+++(unsigned int def = 0) const; - double +++as_double+++(double def = 0) const; - float +++as_float+++(float def = 0) const; - bool +++as_bool+++(bool def = false) const; - long long +++as_llong+++(long long def = 0) const; - unsigned long long +++as_ullong+++(unsigned long long def = 0) const; - - bool +++set_name+++(const char_t* rhs); - bool +++set_value+++(const char_t* rhs); - bool +++set_value+++(int rhs); - bool +++set_value+++(unsigned int rhs); - bool +++set_value+++(long rhs); - bool +++set_value+++(unsigned long rhs); - bool +++set_value+++(double rhs); - bool +++set_value+++(float rhs); - bool +++set_value+++(bool rhs); - bool +++set_value+++(long long rhs); - bool +++set_value+++(unsigned long long rhs); - - xml_attribute& +++operator=+++(const char_t* rhs); - xml_attribute& +++operator=+++(int rhs); - xml_attribute& +++operator=+++(unsigned int rhs); - xml_attribute& +++operator=+++(long rhs); - xml_attribute& +++operator=+++(unsigned long rhs); - xml_attribute& +++operator=+++(double rhs); - xml_attribute& +++operator=+++(float rhs); - xml_attribute& +++operator=+++(bool rhs); - xml_attribute& +++operator=+++(long long rhs); - xml_attribute& +++operator=+++(unsnigned long long rhs); - -+++class xml_node+++ - +++xml_node+++(); - - bool +++empty+++() const; - operator +++unspecified_bool_type+++() const; - - bool +++operator==+++(const xml_node& r) const; - bool +++operator!=+++(const xml_node& r) const; - bool +++operator<+++(const xml_node& r) const; - bool +++operator>+++(const xml_node& r) const; - bool +++operator<=+++(const xml_node& r) const; - bool +++operator>=+++(const xml_node& r) const; - - size_t +++hash_value+++() const; - - xml_node_type +++type+++() const; - - const char_t* +++name+++() const; - const char_t* +++value+++() const; - - xml_node +++parent+++() const; - xml_node +++first_child+++() const; - xml_node +++last_child+++() const; - xml_node +++next_sibling+++() const; - xml_node +++previous_sibling+++() const; - - xml_attribute +++first_attribute+++() const; - xml_attribute +++last_attribute+++() const; - - implementation-defined-type +++children+++() const; - implementation-defined-type +++children+++(const char_t* name) const; - implementation-defined-type +++attributes+++() const; - - xml_node +++child+++(const char_t* name) const; - xml_attribute +++attribute+++(const char_t* name) const; - xml_node +++next_sibling+++(const char_t* name) const; - xml_node +++previous_sibling+++(const char_t* name) const; - xml_node +++find_child_by_attribute+++(const char_t* name, const char_t* attr_name, const char_t* attr_value) const; - xml_node +++find_child_by_attribute+++(const char_t* attr_name, const char_t* attr_value) const; - - const char_t* +++child_value+++() const; - const char_t* +++child_value+++(const char_t* name) const; - xml_text +++text+++() const; - - typedef xml_node_iterator +++iterator+++; - iterator +++begin+++() const; - iterator +++end+++() const; - - typedef xml_attribute_iterator +++attribute_iterator+++; - attribute_iterator +++attributes_begin+++() const; - attribute_iterator +++attributes_end+++() const; - - bool +++traverse+++(xml_tree_walker& walker); - - template xml_attribute +++find_attribute+++(Predicate pred) const; - template xml_node +++find_child+++(Predicate pred) const; - template xml_node +++find_node+++(Predicate pred) const; - - string_t +++path+++(char_t delimiter = '/') const; - xml_node +++xml_node::first_element_by_path+++(const char_t* path, char_t delimiter = '/') const; - xml_node +++root+++() const; - ptrdiff_t +++offset_debug+++() const; - - bool +++set_name+++(const char_t* rhs); - bool +++set_value+++(const char_t* rhs); - - xml_attribute +++append_attribute+++(const char_t* name); - xml_attribute +++prepend_attribute+++(const char_t* name); - xml_attribute +++insert_attribute_after+++(const char_t* name, const xml_attribute& attr); - xml_attribute +++insert_attribute_before+++(const char_t* name, const xml_attribute& attr); - - xml_node +++append_child+++(xml_node_type type = node_element); - xml_node +++prepend_child+++(xml_node_type type = node_element); - xml_node +++insert_child_after+++(xml_node_type type, const xml_node& node); - xml_node +++insert_child_before+++(xml_node_type type, const xml_node& node); - - xml_node +++append_child+++(const char_t* name); - xml_node +++prepend_child+++(const char_t* name); - xml_node +++insert_child_after+++(const char_t* name, const xml_node& node); - xml_node +++insert_child_before+++(const char_t* name, const xml_node& node); - - xml_attribute +++append_copy+++(const xml_attribute& proto); - xml_attribute +++prepend_copy+++(const xml_attribute& proto); - xml_attribute +++insert_copy_after+++(const xml_attribute& proto, const xml_attribute& attr); - xml_attribute +++insert_copy_before+++(const xml_attribute& proto, const xml_attribute& attr); - - xml_node +++append_copy+++(const xml_node& proto); - xml_node +++prepend_copy+++(const xml_node& proto); - xml_node +++insert_copy_after+++(const xml_node& proto, const xml_node& node); - xml_node +++insert_copy_before+++(const xml_node& proto, const xml_node& node); - - xml_node +++append_move+++(const xml_node& moved); - xml_node +++prepend_move+++(const xml_node& moved); - xml_node +++insert_move_after+++(const xml_node& moved, const xml_node& node); - xml_node +++insert_move_before+++(const xml_node& moved, const xml_node& node); - - bool +++remove_attribute+++(const xml_attribute& a); - bool +++remove_attribute+++(const char_t* name); - bool +++remove_attributes+++(); - bool +++remove_child+++(const xml_node& n); - bool +++remove_child+++(const char_t* name); - bool +++remove_children+++(); - - xml_parse_result +++append_buffer+++(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - void +++print+++(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; - void +++print+++(std::ostream& os, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; - void +++print+++(std::wostream& os, const char_t* indent = "\t", unsigned int flags = format_default, unsigned int depth = 0) const; - - xpath_node +++select_node+++(const char_t* query, xpath_variable_set* variables = 0) const; - xpath_node +++select_node+++(const xpath_query& query) const; - xpath_node_set +++select_nodes+++(const char_t* query, xpath_variable_set* variables = 0) const; - xpath_node_set +++select_nodes+++(const xpath_query& query) const; - -+++class xml_document+++ - +++xml_document+++(); - ~+++xml_document+++(); - - void +++reset+++(); - void +++reset+++(const xml_document& proto); - - xml_parse_result +++load+++(std::istream& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - xml_parse_result +++load+++(std::wistream& stream, unsigned int options = parse_default); - - xml_parse_result +++load_string+++(const char_t* contents, unsigned int options = parse_default); - - xml_parse_result +++load_file+++(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - xml_parse_result +++load_file+++(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - xml_parse_result +++load_buffer+++(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - xml_parse_result +++load_buffer_inplace+++(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - xml_parse_result +++load_buffer_inplace_own+++(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - bool +++save_file+++(const char* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - bool +++save_file+++(const wchar_t* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - - void +++save+++(std::ostream& stream, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - void +++save+++(std::wostream& stream, const char_t* indent = "\t", unsigned int flags = format_default) const; - - void +++save+++(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - - xml_node +++document_element+++() const; - -+++struct xml_parse_result+++ - xml_parse_status +++status+++; - ptrdiff_t +++offset+++; - xml_encoding +++encoding+++; - - operator +++bool+++() const; - const char* +++description+++() const; - -+++class xml_node_iterator+++ -+++class xml_attribute_iterator+++ - -+++class xml_tree_walker+++ - virtual bool +++begin+++(xml_node& node); - virtual bool +++for_each+++(xml_node& node) = 0; - virtual bool +++end+++(xml_node& node); - - int +++depth+++() const; - -+++class xml_text+++ - bool +++empty+++() const; - operator +++xml_text::unspecified_bool_type+++() const; - - const char_t* +++xml_text::get+++() const; - - const char_t* +++as_string+++(const char_t* def = "") const; - int +++as_int+++(int def = 0) const; - unsigned int +++as_uint+++(unsigned int def = 0) const; - double +++as_double+++(double def = 0) const; - float +++as_float+++(float def = 0) const; - bool +++as_bool+++(bool def = false) const; - long long +++as_llong+++(long long def = 0) const; - unsigned long long +++as_ullong+++(unsigned long long def = 0) const; - - bool +++set+++(const char_t* rhs); - - bool +++set+++(int rhs); - bool +++set+++(unsigned int rhs); - bool +++set+++(long rhs); - bool +++set+++(unsigned long rhs); - bool +++set+++(double rhs); - bool +++set+++(float rhs); - bool +++set+++(bool rhs); - bool +++set+++(long long rhs); - bool +++set+++(unsigned long long rhs); - - xml_text& +++operator=+++(const char_t* rhs); - xml_text& +++operator=+++(int rhs); - xml_text& +++operator=+++(unsigned int rhs); - xml_text& +++operator=+++(long rhs); - xml_text& +++operator=+++(unsigned long rhs); - xml_text& +++operator=+++(double rhs); - xml_text& +++operator=+++(float rhs); - xml_text& +++operator=+++(bool rhs); - xml_text& +++operator=+++(long long rhs); - xml_text& +++operator=+++(unsigned long long rhs); - - xml_node +++data+++() const; - -+++class xml_writer+++ - virtual void +++write+++(const void* data, size_t size) = 0; - -+++class xml_writer_file+++: public xml_writer - +++xml_writer_file+++(void* file); - -+++class xml_writer_stream+++: public xml_writer - +++xml_writer_stream+++(std::ostream& stream); - +++xml_writer_stream+++(std::wostream& stream); - -+++struct xpath_parse_result+++ - const char* +++error+++; - ptrdiff_t +++offset+++; - - operator +++bool+++() const; - const char* +++description+++() const; - -+++class xpath_query+++ - explicit +++xpath_query+++(const char_t* query, xpath_variable_set* variables = 0); - - bool +++evaluate_boolean+++(const xpath_node& n) const; - double +++evaluate_number+++(const xpath_node& n) const; - string_t +++evaluate_string+++(const xpath_node& n) const; - size_t +++evaluate_string+++(char_t* buffer, size_t capacity, const xpath_node& n) const; - xpath_node_set +++evaluate_node_set+++(const xpath_node& n) const; - xpath_node +++evaluate_node+++(const xpath_node& n) const; - - xpath_value_type +++return_type+++() const; - - const xpath_parse_result& +++result+++() const; - operator +++unspecified_bool_type+++() const; - -+++class xpath_exception+++: public std::exception - virtual const char* +++what+++() const throw(); - - const xpath_parse_result& +++result+++() const; - -+++class xpath_node+++ - +++xpath_node+++(); - +++xpath_node+++(const xml_node& node); - +++xpath_node+++(const xml_attribute& attribute, const xml_node& parent); - - xml_node +++node+++() const; - xml_attribute +++attribute+++() const; - xml_node +++parent+++() const; - - operator +++unspecified_bool_type+++() const; - bool +++operator==+++(const xpath_node& n) const; - bool +++operator!=+++(const xpath_node& n) const; - -+++class xpath_node_set+++ - +++xpath_node_set+++(); - +++xpath_node_set+++(const_iterator begin, const_iterator end, type_t type = type_unsorted); - - typedef const xpath_node* +++const_iterator+++; - const_iterator +++begin+++() const; - const_iterator +++end+++() const; - - const xpath_node& +++operator[+++](size_t index) const; - size_t +++size+++() const; - bool +++empty+++() const; - - xpath_node +++first+++() const; - - enum type_t {+++type_unsorted+++, +++type_sorted+++, +++type_sorted_reverse+++}; - type_t +++type+++() const; - void +++sort+++(bool reverse = false); - -+++class xpath_variable+++ - const char_t* +++name+++() const; - xpath_value_type +++type+++() const; - - bool +++get_boolean+++() const; - double +++get_number+++() const; - const char_t* +++get_string+++() const; - const xpath_node_set& +++get_node_set+++() const; - - bool +++set+++(bool value); - bool +++set+++(double value); - bool +++set+++(const char_t* value); - bool +++set+++(const xpath_node_set& value); - -+++class xpath_variable_set+++ - xpath_variable* +++add+++(const char_t* name, xpath_value_type type); - - bool +++set+++(const char_t* name, bool value); - bool +++set+++(const char_t* name, double value); - bool +++set+++(const char_t* name, const char_t* value); - bool +++set+++(const char_t* name, const xpath_node_set& value); - - xpath_variable* +++get+++(const char_t* name); - const xpath_variable* +++get+++(const char_t* name) const; ----- - -[[apiref.functions]] -=== Functions - -[source,subs="+macros"] ----- -std::string +++as_utf8+++(const wchar_t* str); -std::string +++as_utf8+++(const std::wstring& str); -std::wstring +++as_wide+++(const char* str); -std::wstring +++as_wide+++(const std::string& str); -void +++set_memory_management_functions+++(allocation_function allocate, deallocation_function deallocate); -allocation_function +++get_memory_allocation_function+++(); -deallocation_function +++get_memory_deallocation_function+++(); ----- diff --git a/external/pugixml/docs/manual.html b/external/pugixml/docs/manual.html deleted file mode 100644 index 4a1d50151..000000000 --- a/external/pugixml/docs/manual.html +++ /dev/null @@ -1,5869 +0,0 @@ - - - - - - - - -pugixml 1.10 manual - - - - - - -
-
-

1. Overview

-
-
-

1.1. Introduction

-
-

pugixml is a light-weight C++ XML processing library. It consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an XPath 1.0 implementation for complex data-driven tree queries. Full Unicode support is also available, with two Unicode interface variants and conversions between different Unicode encodings (which happen automatically during parsing/saving). The library is extremely portable and easy to integrate and use. pugixml is developed and maintained since 2006 and has many users. All code is distributed under the MIT license, making it completely free to use in both open-source and proprietary applications.

-
-
-

pugixml enables very fast, convenient and memory-efficient XML document processing. However, since pugixml has a DOM parser, it can’t process XML documents that do not fit in memory; also the parser is a non-validating one, so if you need DTD or XML Schema validation, the library is not for you.

-
-
-

This is the complete manual for pugixml, which describes all features of the library in detail. If you want to start writing code as quickly as possible, you are advised to read the quick start guide first.

-
-
- - - - - -
-
Note
-
-No documentation is perfect; neither is this one. If you find errors or omissions, please don’t hesitate to submit an issue or open a pull request with a fix. -
-
-
-
-

1.2. Feedback

-
-

If you believe you’ve found a bug in pugixml (bugs include compilation problems (errors/warnings), crashes, performance degradation and incorrect behavior), please file an issue via issue submission form. Be sure to include the relevant information so that the bug can be reproduced: the version of pugixml, compiler version and target architecture, the code that uses pugixml and exhibits the bug, etc.

-
-
-

Feature requests can be reported the same way as bugs, so if you’re missing some functionality in pugixml or if the API is rough in some places and you can suggest an improvement, file an issue. However please note that there are many factors when considering API changes (compatibility with previous versions, API redundancy, etc.), so generally features that can be implemented via a small function without pugixml modification are not accepted. However, all rules have exceptions.

-
-
-

If you have a contribution to pugixml, such as build script for some build system/IDE, or a well-designed set of helper functions, or a binding to some language other than C++, please file an issue or open a pull request. Your contribution has to be distributed under the terms of a license that’s compatible with pugixml license; i.e. GPL/LGPL licensed code is not accepted.

-
-
-

If filing an issue is not possible due to privacy or other concerns, you can contact pugixml author by e-mail directly: arseny.kapoulkine@gmail.com.

-
-
-
-

1.3. Acknowledgments

-
-

pugixml could not be developed without the help from many people; some of them are listed in this section. If you’ve played a part in pugixml development and you can not find yourself on this list, I’m truly sorry; please send me an e-mail so I can fix this.

-
-
-

Thanks to Kristen Wegner for pugxml parser, which was used as a basis for pugixml.

-
-
-

Thanks to Neville Franks for contributions to pugxml parser.

-
-
-

Thanks to Artyom Palvelev for suggesting a lazy gap contraction approach.

-
-
-

Thanks to Vyacheslav Egorov for documentation proofreading and fuzz testing.

-
-
-
-

1.4. License

-
-

The pugixml library is distributed under the MIT license:

-
-
-
-
Copyright (c) 2006-2019 Arseny Kapoulkine
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-
-
-

This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution:

-
-
-
-
This software is based on pugixml library (https://pugixml.org).
-pugixml is Copyright (C) 2006-2019 Arseny Kapoulkine.
-
-
-
-
-
-
-

2. Installation

-
-
-

2.1. Getting pugixml

-
-

pugixml is distributed in source form. You can either download a source distribution or clone the Git repository.

-
-
-

2.1.1. Source distributions

-
-

You can download the latest source distribution as an archive:

-
-
-

pugixml-1.10.zip (Windows line endings) -/ -pugixml-1.10.tar.gz (Unix line endings)

-
-
-

The distribution contains library source, documentation (the manual you’re reading now and the quick start guide) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive.

-
-
-

If you need an older version, you can download it from the version archive.

-
-
-
-

2.1.2. Git repository

-
-

The Git repository is located at https://github.com/zeux/pugixml/. There is a Git tag "v{version}" for each version; also there is the "latest" tag, which always points to the latest stable release.

-
-
-

For example, to checkout the current version, you can use this command:

-
-
-
-
git clone https://github.com/zeux/pugixml
-cd pugixml
-git checkout v1.10
-
-
-
-

The repository contains library source, documentation, code examples and full unit test suite.

-
-
-

Use latest tag if you want to automatically get new versions. Use other tags if you want to switch to new versions only explicitly. Also please note that the master branch contains the work-in-progress version of the code; while this means that you can get new features and bug fixes from master without waiting for a new release, this also means that occasionally the code can be broken in some configurations.

-
-
-
-

2.1.3. Subversion repository

-
-

You can access the Git repository via Subversion using https://github.com/zeux/pugixml URL. For example, to checkout the current version, you can use this command:

-
-
-
-
svn checkout https://github.com/zeux/pugixml/tags/v1.10 pugixml
-
-
-
-
-

2.1.4. Packages

-
-

pugixml is available as a package via various package managers. Note that most packages are maintained separately from the main repository so they do not necessarily contain the latest version.

-
-
-

Here’s an incomplete list of pugixml packages in various systems:

-
-
- -
-
-
-
-

2.2. Building pugixml

-
-

pugixml is distributed in source form without any pre-built binaries; you have to build them yourself.

-
-
-

The complete pugixml source consists of three files - one source file, pugixml.cpp, and two header files, pugixml.hpp and pugiconfig.hpp. pugixml.hpp is the primary header which you need to include in order to use pugixml classes/functions; pugiconfig.hpp is a supplementary configuration file (see Additional configuration options). The rest of this guide assumes that pugixml.hpp is either in the current directory or in one of include directories of your projects, so that #include "pugixml.hpp" can find the header; however you can also use relative path (i.e. #include "../libs/pugixml/src/pugixml.hpp") or include directory-relative path (i.e. #include <xml/thirdparty/pugixml/src/pugixml.hpp>).

-
-
-

2.2.1. Building pugixml as a part of another static library/executable

-
-

The easiest way to build pugixml is to compile the source file, pugixml.cpp, along with the existing library/executable. This process depends on the method of building your application; for example, if you’re using Microsoft Visual Studio [1], Apple Xcode, Code::Blocks or any other IDE, just add pugixml.cpp to one of your projects.

-
-
-

If you’re using Microsoft Visual Studio and the project has precompiled headers turned on, you’ll see the following error messages:

-
-
-
-
pugixml.cpp(3477) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
-
-
-
-

The correct way to resolve this is to disable precompiled headers for pugixml.cpp; you have to set "Create/Use Precompiled Header" option (Properties dialog → C/C++ → Precompiled Headers → Create/Use Precompiled Header) to "Not Using Precompiled Headers". You’ll have to do it for all project configurations/platforms (you can select Configuration "All Configurations" and Platform "All Platforms" before editing the option):

-
- ------ - - - - - - - - -
-
-vs2005 pch1 -
-
-
-vs2005 pch2 -
-
-
-vs2005 pch3 -
-
-
-vs2005 pch4 -
-
-
-
-

2.2.2. Building pugixml as a standalone static library

-
-

It’s possible to compile pugixml as a standalone static library. This process depends on the method of building your application; pugixml distribution comes with project files for several popular IDEs/build systems. There are project files for Apple XCode, Code::Blocks, Codelite, Microsoft Visual Studio 2005, 2008, 2010+, and configuration scripts for CMake and premake4. You’re welcome to submit project files/build scripts for other software; see Feedback.

-
-
-

There are two projects for each version of Microsoft Visual Studio: one for dynamically linked CRT, which has a name like pugixml_vs2008.vcproj, and another one for statically linked CRT, which has a name like pugixml_vs2008_static.vcproj. You should select the version that matches the CRT used in your application; the default option for new projects created by Microsoft Visual Studio is dynamically linked CRT, so unless you changed the defaults, you should use the version with dynamic CRT (i.e. pugixml_vs2008.vcproj for Microsoft Visual Studio 2008).

-
-
-

In addition to adding pugixml project to your workspace, you’ll have to make sure that your application links with pugixml library. If you’re using Microsoft Visual Studio 2005/2008, you can add a dependency from your application project to pugixml one. If you’re using Microsoft Visual Studio 2010+, you’ll have to add a reference to your application project instead. For other IDEs/systems, consult the relevant documentation.

-
- ------ - - - - - - - - - - - - - - -
Microsoft Visual Studio 2005/2008Microsoft Visual Studio 2010+
-
-vs2005 link1 -
-
-
-vs2005 link2 -
-
-
-vs2010 link1 -
-
-
-vs2010 link2 -
-
-
-
-

2.2.3. Building pugixml as a standalone shared library

-
-

It’s possible to compile pugixml as a standalone shared library. The process is usually similar to the static library approach; however, no preconfigured projects/scripts are included into pugixml distribution, so you’ll have to do it yourself. Generally, if you’re using GCC-based toolchain, the process does not differ from building any other library as DLL (adding -shared to compilation flags should suffice); if you’re using MSVC-based toolchain, you’ll have to explicitly mark exported symbols with a declspec attribute. You can do it by defining PUGIXML_API macro, i.e. via pugiconfig.hpp:

-
-
-
-
#ifdef _DLL
-    #define PUGIXML_API __declspec(dllexport)
-#else
-    #define PUGIXML_API __declspec(dllimport)
-#endif
-
-
-
- - - - - -
-
Caution
-
-If you’re using STL-related functions, you should use the shared runtime library to ensure that a single heap is used for STL allocations in your application and in pugixml; in MSVC, this means selecting the 'Multithreaded DLL' or 'Multithreaded Debug DLL' to 'Runtime library' property (/MD or /MDd linker switch). You should also make sure that your runtime library choice is consistent between different projects. -
-
-
-
-

2.2.4. Using pugixml in header-only mode

-
-

It’s possible to use pugixml in header-only mode. This means that all source code for pugixml will be included in every translation unit that includes pugixml.hpp. This is how most of Boost and STL libraries work.

-
-
-

Note that there are advantages and drawbacks of this approach. Header mode may improve tree traversal/modification performance (because many simple functions will be inlined), if your compiler toolchain does not support link-time optimization, or if you have it turned off (with link-time optimization the performance should be similar to non-header mode). However, since compiler now has to compile pugixml source once for each translation unit that includes it, compilation times may increase noticeably. If you want to use pugixml in header mode but do not need XPath support, you can consider disabling it by using PUGIXML_NO_XPATH define to improve compilation time.

-
-
-

To enable header-only mode, you have to define PUGIXML_HEADER_ONLY. You can either do it in pugiconfig.hpp, or provide them via compiler command-line.

-
-
-

Note that it is safe to compile pugixml.cpp if PUGIXML_HEADER_ONLY is defined - so if you want to i.e. use header-only mode only in Release configuration, you -can include pugixml.cpp in your project (see Building pugixml as a part of another static library/executable), and conditionally enable header-only mode in pugiconfig.hpp like this:

-
-
-
-
#ifndef _DEBUG
-    #define PUGIXML_HEADER_ONLY
-#endif
-
-
-
-
-

2.2.5. Additional configuration options

-
-

pugixml uses several defines to control the compilation process. There are two ways to define them: either put the needed definitions to pugiconfig.hpp (it has some examples that are commented out) or provide them via compiler command-line. Consistency is important: the definitions should match in all source files that include pugixml.hpp (including pugixml sources) throughout the application. Adding defines to pugiconfig.hpp lets you guarantee this, unless your macro definition is wrapped in preprocessor #if/#ifdef directive and this directive is not consistent. pugiconfig.hpp will never contain anything but comments, which means that when upgrading to a new version, you can safely leave your modified version intact.

-
-
-

PUGIXML_WCHAR_MODE define toggles between UTF-8 style interface (the in-memory text encoding is assumed to be UTF-8, most functions use char as character type) and UTF-16/32 style interface (the in-memory text encoding is assumed to be UTF-16/32, depending on wchar_t size, most functions use wchar_t as character type). See Unicode interface for more details.

-
-
-

PUGIXML_COMPACT define activates a different internal representation of document storage that is much more memory efficient for documents with a lot of markup (i.e. nodes and attributes), but is slightly slower to parse and access. For details see Compact mode.

-
-
-

PUGIXML_NO_XPATH define disables XPath. Both XPath interfaces and XPath implementation are excluded from compilation. This option is provided in case you do not need XPath functionality and need to save code space.

-
-
-

PUGIXML_NO_STL define disables use of STL in pugixml. The functions that operate on STL types are no longer present (i.e. load/save via iostream) if this macro is defined. This option is provided in case your target platform does not have a standard-compliant STL implementation.

-
-
-

PUGIXML_NO_EXCEPTIONS define disables use of exceptions in pugixml. This option is provided in case your target platform does not have exception handling capabilities.

-
-
-

PUGIXML_API, PUGIXML_CLASS and PUGIXML_FUNCTION defines let you specify custom attributes (i.e. declspec or calling conventions) for pugixml classes and non-member functions. In absence of PUGIXML_CLASS or PUGIXML_FUNCTION definitions, PUGIXML_API definition is used instead. For example, to specify fixed calling convention, you can define PUGIXML_FUNCTION to i.e. __fastcall. Another example is DLL import/export attributes in MSVC (see Building pugixml as a standalone shared library).

-
-
- - - - - -
-
Note
-
-In that example PUGIXML_API is inconsistent between several source files; this is an exception to the consistency rule. -
-
-
-

PUGIXML_MEMORY_PAGE_SIZE, PUGIXML_MEMORY_OUTPUT_STACK and PUGIXML_MEMORY_XPATH_PAGE_SIZE can be used to customize certain important sizes to optimize memory usage for the application-specific patterns. For details see Memory consumption tuning.

-
-
-

PUGIXML_HAS_LONG_LONG define enables support for long long type in pugixml. This define is automatically enabled if your platform is known to have long long support (i.e. has C++11 support or uses a reasonably modern version of a known compiler); if pugixml does not recognize that your platform supports long long but in fact it does, you can enable the define manually.

-
-
-
-
-

2.3. Portability

-
-

pugixml is written in standard-compliant C++ with some compiler-specific workarounds where appropriate. pugixml is compatible with the C++11 standard, but does not require C++11 support. Each version is tested with a unit test suite with code coverage exceeding 99%.

-
-
-

pugixml runs on a variety of desktop platforms (including Microsoft Windows, Linux, FreeBSD, Apple MacOSX and Sun Solaris), game consoles (inclusing Microsoft Xbox 360, Microsoft Xbox One, Nintendo Wii, Sony Playstation Portable and Sony Playstation 3) and mobile platforms (including Android, iOS, BlackBerry, Samsung bada and Microsoft Windows CE).

-
-
-

pugixml supports various architectures, such as x86/x86-64, PowerPC, ARM, MIPS and SPARC. In general it should run on any architecture since it does not use architecture-specific code and does not rely on features such as unaligned memory access.

-
-
-

pugixml can be compiled using any C++ compiler; it was tested with all versions of Microsoft Visual C++ from 6.0 up to 2015, GCC from 3.4 up to 5.2, Clang from 3.2 up to 3.7, as well as a variety of other compilers (e.g. Borland C++, Digital Mars C++, Intel C++, Metrowerks CodeWarrior and PathScale). The code is written to avoid compilation warnings even on reasonably high warning levels.

-
-
-

Note that some platforms may have very bare-bones support of C++; in some cases you’ll have to use PUGIXML_NO_STL and/or PUGIXML_NO_EXCEPTIONS to compile without issues. This mostly applies to old game consoles and embedded systems.

-
-
-
-
-
-

3. Document object model

-
-
-

pugixml stores XML data in DOM-like way: the entire XML document (both document structure and element data) is stored in memory as a tree. The tree can be loaded from a character stream (file, string, C++ I/O stream), then traversed with the special API or XPath expressions. The whole tree is mutable: both node structure and node/attribute data can be changed at any time. Finally, the result of document transformations can be saved to a character stream (file, C++ I/O stream or custom transport).

-
-
-

3.1. Tree structure

-
-

The XML document is represented with a tree data structure. The root of the tree is the document itself, which corresponds to C++ type xml_document. Document has one or more child nodes, which correspond to C++ type xml_node. Nodes have different types; depending on a type, a node can have a collection of child nodes, a collection of attributes, which correspond to C++ type xml_attribute, and some additional data (i.e. name).

-
-
-

The tree nodes can be of one of the following types (which together form the enumeration xml_node_type):

-
-
-
    -
  • -

    Document node (node_document) - this is the root of the tree, which consists of several child nodes. This node corresponds to xml_document class; note that xml_document is a sub-class of xml_node, so the entire node interface is also available. However, document node is special in several ways, which are covered below. There can be only one document node in the tree; document node does not have any XML representation.

    -
  • -
  • -

    Element/tag node (node_element) - this is the most common type of node, which represents XML elements. Element nodes have a name, a collection of attributes and a collection of child nodes (both of which may be empty). The attribute is a simple name/value pair. The example XML representation of element nodes is as follows:

    -
    -
    -
    <node attr="value"><child/></node>
    -
    -
    -
    -

    There are two element nodes here: one has name "node", single attribute "attr" and single child "child", another has name "child" and does not have any attributes or child nodes.

    -
    -
  • -
  • -

    Plain character data nodes (node_pcdata) represent plain text in XML. PCDATA nodes have a value, but do not have a name or children/attributes. Note that plain character data is not a part of the element node but instead has its own node; an element node can have several child PCDATA nodes. The example XML representation of text nodes is as follows:

    -
    -
    -
    <node> text1 <child/> text2 </node>
    -
    -
    -
    -

    Here "node" element has three children, two of which are PCDATA nodes with values " text1 " and " text2 ".

    -
    -
  • -
  • -

    Character data nodes (node_cdata) represent text in XML that is quoted in a special way. CDATA nodes do not differ from PCDATA nodes except in XML representation - the above text example looks like this with CDATA:

    -
    -
    -
    <node> <![CDATA[text1]]> <child/> <![CDATA[text2]]> </node>
    -
    -
    -
    -

    CDATA nodes make it easy to include non-escaped <, & and > characters in plain text. CDATA value can not contain the character sequence ]]>, since it is used to determine the end of node contents.

    -
    -
  • -
  • -

    Comment nodes (node_comment) represent comments in XML. Comment nodes have a value, but do not have a name or children/attributes. The example XML representation of a comment node is as follows:

    -
    -
    -
    <!-- comment text -->
    -
    -
    -
    -

    Here the comment node has value "comment text". By default comment nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with parse_comments flag.

    -
    -
  • -
  • -

    Processing instruction node (node_pi) represent processing instructions (PI) in XML. PI nodes have a name and an optional value, but do not have children/attributes. The example XML representation of a PI node is as follows:

    -
    -
    -
    <?name value?>
    -
    -
    -
    -

    Here the name (also called PI target) is "name", and the value is "value". By default PI nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with parse_pi flag.

    -
    -
  • -
  • -

    Declaration node (node_declaration) represents document declarations in XML. Declaration nodes have a name ("xml") and an optional collection of attributes, but do not have value or children. There can be only one declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a declaration node is as follows:

    -
    -
    -
    <?xml version="1.0"?>
    -
    -
    -
    -

    Here the node has name "xml" and a single attribute with name "version" and value "1.0". By default declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with parse_declaration flag. Also, by default a dummy declaration is output when XML document is saved unless there is already a declaration in the document; you can disable this with format_no_declaration flag.

    -
    -
  • -
  • -

    Document type declaration node (node_doctype) represents document type declarations in XML. Document type declaration nodes have a value, which corresponds to the entire document type contents; no additional nodes are created for inner elements like <!ENTITY>. There can be only one document type declaration node in a document; moreover, it should be the topmost node (its parent should be the document). The example XML representation of a document type declaration node is as follows:

    -
    -
    -
    <!DOCTYPE greeting [ <!ELEMENT greeting (#PCDATA)> ]>
    -
    -
    -
    -

    Here the node has value "greeting [ <!ELEMENT greeting (#PCDATA)> ]". By default document type declaration nodes are treated as non-essential part of XML markup and are not loaded during XML parsing. You can override this behavior with parse_doctype flag.

    -
    -
  • -
-
-
-

Finally, here is a complete example of XML document and the corresponding tree representation (samples/tree.xml):

-
- ---- - - - - - - -
-
-
<?xml version="1.0"?>
-<mesh name="mesh_root">
-    <!-- here is a mesh node -->
-    some text
-    <![CDATA[someothertext]]>
-    some more text
-    <node attr1="value1" attr2="value2" />
-    <node attr1="value2">
-        <innernode/>
-    </node>
-</mesh>
-<?include somedata?>
-
-
-
-dom tree -
-
-
-
-

3.2. C++ interface

-
- - - - - -
-
Note
-
-All pugixml classes and functions are located in the pugi namespace; you have to either use explicit name qualification (i.e. pugi::xml_node), or to gain access to relevant symbols via using directive (i.e. using pugi::xml_node; or using namespace pugi;). The namespace will be omitted from all declarations in this documentation hereafter; all code examples will use fully qualified names. -
-
-
-

Despite the fact that there are several node types, there are only three C++ classes representing the tree (xml_document, xml_node, xml_attribute); some operations on xml_node are only valid for certain node types. The classes are described below.

-
-
-

-xml_document is the owner of the entire document structure; it is a non-copyable class. The interface of xml_document consists of loading functions (see Loading document), saving functions (see Saving document) and the entire interface of xml_node, which allows for document inspection and/or modification. Note that while xml_document is a sub-class of xml_node, xml_node is not a polymorphic type; the inheritance is present only to simplify usage. Alternatively you can use the document_element function to get the element node that’s the immediate child of the document.

-
-
-

-Default constructor of xml_document initializes the document to the tree with only a root node (document node). You can then populate it with data using either tree modification functions or loading functions; all loading functions destroy the previous tree with all occupied memory, which puts existing node/attribute handles for this document to invalid state. If you want to destroy the previous tree, you can use the xml_document::reset function; it destroys the tree and replaces it with either an empty one or a copy of the specified document. Destructor of xml_document also destroys the tree, thus the lifetime of the document object should exceed the lifetimes of any node/attribute handles that point to the tree.

-
-
- - - - - -
-
Caution
-
-While technically node/attribute handles can be alive when the tree they’re referring to is destroyed, calling any member function for these handles results in undefined behavior. Thus it is recommended to make sure that the document is destroyed only after all references to its nodes/attributes are destroyed. -
-
-
-

-xml_node is the handle to document node; it can point to any node in the document, including the document node itself. There is a common interface for nodes of all types; the actual node type can be queried via the xml_node::type() method. Note that xml_node is only a handle to the actual node, not the node itself - you can have several xml_node handles pointing to the same underlying object. Destroying xml_node handle does not destroy the node and does not remove it from the tree. The size of xml_node is equal to that of a pointer, so it is nothing more than a lightweight wrapper around a pointer; you can safely pass or return xml_node objects by value without additional overhead.

-
-
-

There is a special value of xml_node type, known as null node or empty node (such nodes have type node_null). It does not correspond to any node in any document, and thus resembles null pointer. However, all operations are defined on empty nodes; generally the operations don’t do anything and return empty nodes/attributes or empty strings as their result (see documentation for specific functions for more detailed information). This is useful for chaining calls; i.e. you can get the grandparent of a node like so: node.parent().parent(); if a node is a null node or it does not have a parent, the first parent() call returns null node; the second parent() call then also returns null node, which makes error handling easier.

-
-
-

xml_attribute is the handle to an XML attribute; it has the same semantics as xml_node, i.e. there can be several xml_attribute handles pointing to the same underlying object and there is a special null attribute value, which propagates to function results.

-
-
-

-Both xml_node and xml_attribute have the default constructor which initializes them to null objects.

-
-
-

-xml_node and xml_attribute try to behave like pointers, that is, they can be compared with other objects of the same type, making it possible to use them as keys in associative containers. All handles to the same underlying object are equal, and any two handles to different underlying objects are not equal. Null handles only compare as equal to null handles. The result of relational comparison can not be reliably determined from the order of nodes in file or in any other way. Do not use relational comparison operators except for search optimization (i.e. associative container keys).

-
-
-

-If you want to use xml_node or xml_attribute objects as keys in hash-based associative containers, you can use the hash_value member functions. They return the hash values that are guaranteed to be the same for all handles to the same underlying object. The hash value for null handles is 0. Note that hash value does not depend on the content of the node, only on the location of the underlying structure in memory - this means that loading the same document twice will likely produce different hash values, and copying the node will not preserve the hash.

-
-
-

-Finally handles can be implicitly cast to boolean-like objects, so that you can test if the node/attribute is empty with the following code: if (node) { …​ } or if (!node) { …​ } else { …​ }. Alternatively you can check if a given xml_node/xml_attribute handle is null by calling the following methods:

-
-
-
-
bool xml_attribute::empty() const;
-bool xml_node::empty() const;
-
-
-
-

Nodes and attributes do not exist without a document tree, so you can’t create them without adding them to some document. Once underlying node/attribute objects are destroyed, the handles to those objects become invalid. While this means that destruction of the entire tree invalidates all node/attribute handles, it also means that destroying a subtree (by calling xml_node::remove_child) or removing an attribute invalidates the corresponding handles. There is no way to check handle validity; you have to ensure correctness through external mechanisms.

-
-
-
-

3.3. Unicode interface

-
-

There are two choices of interface and internal representation when configuring pugixml: you can either choose the UTF-8 (also called char) interface or UTF-16/32 (also called wchar_t) one. The choice is controlled via PUGIXML_WCHAR_MODE define; you can set it via pugiconfig.hpp or via preprocessor options, as discussed in Additional configuration options. If this define is set, the wchar_t interface is used; otherwise (by default) the char interface is used. The exact wide character encoding is assumed to be either UTF-16 or UTF-32 and is determined based on the size of wchar_t type.

-
-
- - - - - -
-
Note
-
-If the size of wchar_t is 2, pugixml assumes UTF-16 encoding instead of UCS-2, which means that some characters are represented as two code points. -
-
-
-

All tree functions that work with strings work with either C-style null terminated strings or STL strings of the selected character type. For example, node name accessors look like this in char mode:

-
-
-
-
const char* xml_node::name() const;
-bool xml_node::set_name(const char* value);
-
-
-
-

and like this in wchar_t mode:

-
-
-
-
const wchar_t* xml_node::name() const;
-bool xml_node::set_name(const wchar_t* value);
-
-
-
-

-There is a special type, pugi::char_t, that is defined as the character type and depends on the library configuration; it will be also used in the documentation hereafter. There is also a type pugi::string_t, which is defined as the STL string of the character type; it corresponds to std::string in char mode and to std::wstring in wchar_t mode.

-
-
-

In addition to the interface, the internal implementation changes to store XML data as pugi::char_t; this means that these two modes have different memory usage characteristics - generally UTF-8 mode is more memory and performance efficient, especially if sizeof(wchar_t) is 4. The conversion to pugi::char_t upon document loading and from pugi::char_t upon document saving happen automatically, which also carries minor performance penalty. The general advice however is to select the character mode based on usage scenario, i.e. if UTF-8 is inconvenient to process and most of your XML data is non-ASCII, wchar_t mode is probably a better choice.

-
-
-

-There are cases when you’ll have to convert string data between UTF-8 and wchar_t encodings; the following helper functions are provided for such purposes:

-
-
-
-
std::string as_utf8(const wchar_t* str);
-std::wstring as_wide(const char* str);
-
-
-
-

Both functions accept a null-terminated string as an argument str, and return the converted string. as_utf8 performs conversion from UTF-16/32 to UTF-8; as_wide performs conversion from UTF-8 to UTF-16/32. Invalid UTF sequences are silently discarded upon conversion. str has to be a valid string; passing null pointer results in undefined behavior. There are also two overloads with the same semantics which accept a string as an argument:

-
-
-
-
std::string as_utf8(const std::wstring& str);
-std::wstring as_wide(const std::string& str);
-
-
-
- - - - - -
-
Note
-
-
-

Most examples in this documentation assume char interface and therefore will not compile with PUGIXML_WCHAR_MODE. This is done to simplify the documentation; usually the only changes you’ll have to make is to pass wchar_t string literals, i.e. instead of

-
-
-

xml_node node = doc.child("bookstore").find_child_by_attribute("book", "id", "12345");

-
-
-

you’ll have to use

-
-
-

xml_node node = doc.child(L"bookstore").find_child_by_attribute(L"book", L"id", L"12345");

-
-
-
-
-
-

3.4. Thread-safety guarantees

-
-

Almost all functions in pugixml have the following thread-safety guarantees:

-
-
-
    -
  • -

    it is safe to call free (non-member) functions from multiple threads

    -
  • -
  • -

    it is safe to perform concurrent read-only accesses to the same tree (all constant member functions do not modify the tree)

    -
  • -
  • -

    it is safe to perform concurrent read/write accesses, if there is only one read or write access to the single tree at a time

    -
  • -
-
-
-

Concurrent modification and traversing of a single tree requires synchronization, for example via reader-writer lock. Modification includes altering document structure and altering individual node/attribute data, i.e. changing names/values.

-
-
-

The only exception is set_memory_management_functions; it modifies global variables and as such is not thread-safe. Its usage policy has more restrictions, see Custom memory allocation/deallocation functions.

-
-
-
-

3.5. Exception guarantees

-
-

With the exception of XPath, pugixml itself does not throw any exceptions. Additionally, most pugixml functions have a no-throw exception guarantee.

-
-
-

This is not applicable to functions that operate on STL strings or IOstreams; such functions have either strong guarantee (functions that operate on strings) or basic guarantee (functions that operate on streams). Also functions that call user-defined callbacks (i.e. xml_node::traverse or xml_node::find_node) do not provide any exception guarantees beyond the ones provided by the callback.

-
-
-

If exception handling is not disabled with PUGIXML_NO_EXCEPTIONS define, XPath functions may throw xpath_exception on parsing errors; also, XPath functions may throw std::bad_alloc in low memory conditions. Still, XPath functions provide strong exception guarantee.

-
-
-
-

3.6. Memory management

-
-

pugixml requests the memory needed for document storage in big chunks, and allocates document data inside those chunks. This section discusses replacing functions used for chunk allocation and internal memory management implementation.

-
-
-

3.6.1. Custom memory allocation/deallocation functions

-
-

-All memory for tree structure, tree data and XPath objects is allocated via globally specified functions, which default to malloc/free. You can set your own allocation functions with set_memory_management function. The function interfaces are the same as that of malloc/free:

-
-
-
-
typedef void* (*allocation_function)(size_t size);
-typedef void (*deallocation_function)(void* ptr);
-
-
-
-

-You can use the following accessor functions to change or get current memory management functions:

-
-
-
-
void set_memory_management_functions(allocation_function allocate, deallocation_function deallocate);
-allocation_function get_memory_allocation_function();
-deallocation_function get_memory_deallocation_function();
-
-
-
-

Allocation function is called with the size (in bytes) as an argument and should return a pointer to a memory block with alignment that is suitable for storage of primitive types (usually a maximum of void* and double types alignment is sufficient) and size that is greater than or equal to the requested one. If the allocation fails, the function has to either return null pointer or to throw an exception.

-
-
-

Deallocation function is called with the pointer that was returned by some call to allocation function; it is never called with a null pointer. If memory management functions are not thread-safe, library thread safety is not guaranteed.

-
-
-

This is a simple example of custom memory management (samples/custom_memory_management.cpp):

-
-
-
-
void* custom_allocate(size_t size)
-{
-    return new (std::nothrow) char[size];
-}
-
-void custom_deallocate(void* ptr)
-{
-    delete[] static_cast<char*>(ptr);
-}
-
-
-
-
-
pugi::set_memory_management_functions(custom_allocate, custom_deallocate);
-
-
-
-

When setting new memory management functions, care must be taken to make sure that there are no live pugixml objects. Otherwise when the objects are destroyed, the new deallocation function will be called with the memory obtained by the old allocation function, resulting in undefined behavior.

-
-
-
-

3.6.2. Memory consumption tuning

-
-

There are several important buffering optimizations in pugixml that rely on predefined constants. These constants have default values that were tuned for common usage patterns; for some applications, changing these constants might improve memory consumption or increase performance. Changing these constants is not recommended unless their default values result in visible problems.

-
-
-

These constants can be tuned via configuration defines, as discussed in Additional configuration options; it is recommended to set them in pugiconfig.hpp.

-
-
-
    -
  • -

    PUGIXML_MEMORY_PAGE_SIZE controls the page size for document memory allocation. Memory for node/attribute objects is allocated in pages of the specified size. The default size is 32 Kb; for some applications the size is too large (i.e. embedded systems with little heap space or applications that keep lots of XML documents in memory). A minimum size of 1 Kb is recommended.

    -
  • -
  • -

    PUGIXML_MEMORY_OUTPUT_STACK controls the cumulative stack space required to output the node. Any output operation (i.e. saving a subtree to file) uses an internal buffering scheme for performance reasons. The default size is 10 Kb; if you’re using node output from threads with little stack space, decreasing this value can prevent stack overflows. A minimum size of 1 Kb is recommended.

    -
  • -
  • -

    PUGIXML_MEMORY_XPATH_PAGE_SIZE controls the page size for XPath memory allocation. Memory for XPath query objects as well as internal memory for XPath evaluation is allocated in pages of the specified size. The default size is 4 Kb; if you have a lot of resident XPath query objects, you might need to decrease the size to improve memory consumption. A minimum size of 256 bytes is recommended.

    -
  • -
-
-
-
-

3.6.3. Document memory management internals

-
-

Constructing a document object using the default constructor does not result in any allocations; document node is stored inside the xml_document object.

-
-
-

When the document is loaded from file/buffer, unless an inplace loading function is used (see Loading document from memory), a complete copy of character stream is made; all names/values of nodes and attributes are allocated in this buffer. This buffer is allocated via a single large allocation and is only freed when document memory is reclaimed (i.e. if the xml_document object is destroyed or if another document is loaded in the same object). Also when loading from file or stream, an additional large allocation may be performed if encoding conversion is required; a temporary buffer is allocated, and it is freed before load function returns.

-
-
-

All additional memory, such as memory for document structure (node/attribute objects) and memory for node/attribute names/values is allocated in pages on the order of 32 Kb; actual objects are allocated inside the pages using a memory management scheme optimized for fast allocation/deallocation of many small objects. Because of the scheme specifics, the pages are only destroyed if all objects inside them are destroyed; also, generally destroying an object does not mean that subsequent object creation will reuse the same memory. This means that it is possible to devise a usage scheme which will lead to higher memory usage than expected; one example is adding a lot of nodes, and them removing all even numbered ones; not a single page is reclaimed in the process. However this is an example specifically crafted to produce unsatisfying behavior; in all practical usage scenarios the memory consumption is less than that of a general-purpose allocator because allocation meta-data is very small in size.

-
-
-
-

3.6.4. Compact mode

-
-

By default nodes and attributes are optimized for efficiency of access. This can cause them to take a significant amount of memory - for documents with a lot of nodes and not a lot of contents (short attribute values/node text), and depending on the pointer size, the document structure can take noticeably more memory than the document itself (e.g. on a 64-bit platform in UTF-8 mode a markup-heavy document with the file size of 2.1 Mb can use 2.1 Mb for document buffer and 8.3 Mb for document structure).

-
-
-

If you are processing big documents or your platform is memory constrained and you’re willing to sacrifice a bit of performance for memory, you can compile pugixml with PUGIXML_COMPACT define which will activate compact mode. Compact mode uses a different representation of the document structure that assumes locality of reference between nodes and attributes to optimize memory usage. As a result you get significantly smaller node/attribute objects; usually most objects in most documents don’t require additional storage, but in the worst case - if assumptions about locality of reference don’t hold - additional memory will be allocated to store the extra data required.

-
-
-

The compact storage supports all existing operations - including tree modification - with the same amortized complexity (that is, all basic document manipulations are still O(1) on average). The operations are slightly slower; you can usually expect 10-50% slowdown in terms of processing time unless your processing was memory-bound.

-
-
-

On 32-bit architectures document structure in compact mode is typically reduced by around 2.5x; on 64-bit architectures the ratio is around 5x. Thus for big markup-heavy documents compact mode can make the difference between the processing of a multi-gigabyte document running completely from RAM vs requiring swapping to disk. Even if the document fits into memory, compact storage can use CPU caches more efficiently by taking less space and causing less cache/TLB misses.

-
-
-
-
-
-
-

4. Loading document

-
-
-

pugixml provides several functions for loading XML data from various places - files, C++ iostreams, memory buffers. All functions use an extremely fast non-validating parser. This parser is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed for performance reasons. Also some XML transformations (i.e. EOL handling or attribute value normalization) can impact parsing speed and thus can be disabled. However for vast majority of XML documents there is no performance difference between different parsing options. Parsing options also control whether certain XML nodes are parsed; see Parsing options for more information.

-
-
-

XML data is always converted to internal character format (see Unicode interface) before parsing. pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it’s a strict subset of UTF-16) as well as some non-Unicode encodings (Latin-1) and handles all encoding conversions automatically. Unless explicit encoding is specified, loading functions perform automatic encoding detection based on source XML data, so in most cases you do not have to specify document encoding. Encoding conversion is described in more detail in Encodings.

-
-
-

4.1. Loading document from file

-
-

-The most common source of XML data is files; pugixml provides dedicated functions for loading an XML document from file:

-
-
-
-
xml_parse_result xml_document::load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-xml_parse_result xml_document::load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-
-
-
-

These functions accept the file path as its first argument, and also two optional arguments, which specify parsing options (see Parsing options) and input data encoding (see Encodings). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc.

-
-
-

File path is passed to the system file opening function as is in case of the first function (which accepts const char* path); the second function either uses a special file opening function if it is provided by the runtime library or converts the path to UTF-8 and uses the system file opening function.

-
-
-

load_file destroys the existing document tree and then tries to load the new tree from the specified file. The result of the operation is returned in an xml_parse_result object; this object contains the operation status and the related information (i.e. last successfully parsed position in the input file, if parsing fails). See Handling parsing errors for error handling details.

-
-
-

This is an example of loading XML document from file (samples/load_file.cpp):

-
-
-
-
pugi::xml_document doc;
-
-pugi::xml_parse_result result = doc.load_file("tree.xml");
-
-std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl;
-
-
-
-
-

4.2. Loading document from memory

-
-

-Sometimes XML data should be loaded from some other source than a file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from GZip-compressed files. All these scenarios require loading document from memory. First you should prepare a contiguous memory block with all XML data; then you have to invoke one of buffer loading functions. These functions will handle the necessary encoding conversions, if any, and then will parse the data into the corresponding XML tree. There are several buffer loading functions, which differ in the behavior and thus in performance/memory usage:

-
-
-
-
xml_parse_result xml_document::load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-xml_parse_result xml_document::load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-xml_parse_result xml_document::load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-
-
-
-

All functions accept the buffer which is represented by a pointer to XML data, contents, and data size in bytes. Also there are two optional arguments, which specify parsing options (see Parsing options) and input data encoding (see Encodings). The buffer does not have to be zero-terminated.

-
-
-

load_buffer function works with immutable buffer - it does not ever modify the buffer. Because of this restriction it has to create a private buffer and copy XML data to it before parsing (applying encoding conversions if necessary). This copy operation carries a performance penalty, so inplace functions are provided - load_buffer_inplace and load_buffer_inplace_own store the document data in the buffer, modifying it in the process. In order for the document to stay valid, you have to make sure that the buffer’s lifetime exceeds that of the tree if you’re using inplace functions. In addition to that, load_buffer_inplace does not assume ownership of the buffer, so you’ll have to destroy it yourself; load_buffer_inplace_own assumes ownership of the buffer and destroys it once it is not needed. This means that if you’re using load_buffer_inplace_own, you have to allocate memory with pugixml allocation function (you can get it via get_memory_allocation_function).

-
-
-

The best way from the performance/memory point of view is to load document using load_buffer_inplace_own; this function has maximum control of the buffer with XML data so it is able to avoid redundant copies and reduce peak memory usage while parsing. This is the recommended function if you have to load the document from memory and performance is critical.

-
-
-

There is also a simple helper function for cases when you want to load the XML document from null-terminated character string:

-
-
-
-
xml_parse_result xml_document::load_string(const char_t* contents, unsigned int options = parse_default);
-
-
-
-

It is equivalent to calling load_buffer with size being either strlen(contents) or wcslen(contents) * sizeof(wchar_t), depending on the character type. This function assumes native encoding for input data, so it does not do any encoding conversion. In general, this function is fine for loading small documents from string literals, but has more overhead and less functionality than the buffer loading functions.

-
-
-

This is an example of loading XML document from memory using different functions (samples/load_memory.cpp):

-
-
-
-
const char source[] = "<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>";
-size_t size = sizeof(source);
-
-
-
-
-
// You can use load_buffer to load document from immutable memory block:
-pugi::xml_parse_result result = doc.load_buffer(source, size);
-
-
-
-
-
// You can use load_buffer_inplace to load document from mutable memory block; the block's lifetime must exceed that of document
-char* buffer = new char[size];
-memcpy(buffer, source, size);
-
-// The block can be allocated by any method; the block is modified during parsing
-pugi::xml_parse_result result = doc.load_buffer_inplace(buffer, size);
-
-// You have to destroy the block yourself after the document is no longer used
-delete[] buffer;
-
-
-
-
-
// You can use load_buffer_inplace_own to load document from mutable memory block and to pass the ownership of this block
-// The block has to be allocated via pugixml allocation function - using i.e. operator new here is incorrect
-char* buffer = static_cast<char*>(pugi::get_memory_allocation_function()(size));
-memcpy(buffer, source, size);
-
-// The block will be deleted by the document
-pugi::xml_parse_result result = doc.load_buffer_inplace_own(buffer, size);
-
-
-
-
-
// You can use load to load document from null-terminated strings, for example literals:
-pugi::xml_parse_result result = doc.load_string("<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>");
-
-
-
-
-

4.3. Loading document from C++ IOstreams

-
-

To enhance interoperability, pugixml provides functions for loading document from any object which implements C++ std::istream interface. This allows you to load documents from any standard C++ stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). There are two functions, one works with narrow character streams, another handles wide character ones:

-
-
-
-
xml_parse_result xml_document::load(std::istream& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-xml_parse_result xml_document::load(std::wistream& stream, unsigned int options = parse_default);
-
-
-
-

load with std::istream argument loads the document from stream from the current read position to the end, treating the stream contents as a byte stream of the specified encoding (with encoding autodetection as necessary). Thus calling xml_document::load on an opened std::ifstream object is equivalent to calling xml_document::load_file.

-
-
-

load with std::wstream argument treats the stream contents as a wide character stream (encoding is always encoding_wchar). Because of this, using load with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the imbue function). Generally use of wide streams is discouraged, however it provides you the ability to load documents from non-Unicode encodings, i.e. you can load Shift-JIS encoded data if you set the correct locale.

-
-
-

This is a simple example of loading XML document from file using streams (samples/load_stream.cpp); read the sample code for more complex examples involving wide streams and locales:

-
-
-
-
std::ifstream stream("weekly-utf-8.xml");
-pugi::xml_parse_result result = doc.load(stream);
-
-
-
-
-

4.4. Handling parsing errors

-
-

All document loading functions return the parsing result via xml_parse_result object. It contains parsing status, the offset of last successfully parsed character from the beginning of the source stream, and the encoding of the source stream:

-
-
-
-
struct xml_parse_result
-{
-    xml_parse_status status;
-    ptrdiff_t offset;
-    xml_encoding encoding;
-
-    operator bool() const;
-    const char* description() const;
-};
-
-
-
-

-Parsing status is represented as the xml_parse_status enumeration and can be one of the following:

-
-
-
    -
  • -

    status_ok means that no error was encountered during parsing; the source stream represents the valid XML document which was fully parsed and converted to a tree.

    -
  • -
  • -

    status_file_not_found is only returned by load_file function and means that file could not be opened.

    -
  • -
  • -

    status_io_error is returned by load_file function and by load functions with std::istream/std::wstream arguments; it means that some I/O error has occurred during reading the file/stream.

    -
  • -
  • -

    status_out_of_memory means that there was not enough memory during some allocation; any allocation failure during parsing results in this error.

    -
  • -
  • -

    status_internal_error means that something went horribly wrong; currently this error does not occur

    -
  • -
  • -

    status_unrecognized_tag means that parsing stopped due to a tag with either an empty name or a name which starts with incorrect character, such as #.

    -
  • -
  • -

    status_bad_pi means that parsing stopped due to incorrect document declaration/processing instruction

    -
  • -
  • -

    status_bad_comment, status_bad_cdata, status_bad_doctype and status_bad_pcdata mean that parsing stopped due to the invalid construct of the respective type

    -
  • -
  • -

    status_bad_start_element means that parsing stopped because starting tag either had no closing > symbol or contained some incorrect symbol

    -
  • -
  • -

    status_bad_attribute means that parsing stopped because there was an incorrect attribute, such as an attribute without value or with value that is not quoted (note that <node attr=1> is incorrect in XML)

    -
  • -
  • -

    status_bad_end_element means that parsing stopped because ending tag had incorrect syntax (i.e. extra non-whitespace symbols between tag name and >)

    -
  • -
  • -

    status_end_element_mismatch means that parsing stopped because the closing tag did not match the opening one (i.e. <node></nedo>) or because some tag was not closed at all

    -
  • -
  • -

    status_no_document_element means that no element nodes were discovered during parsing; this usually indicates an empty or invalid document

    -
  • -
-
-
-

description() member function can be used to convert parsing status to a string; the returned message is always in English, so you’ll have to write your own function if you need a localized string. However please note that the exact messages returned by description() function may change from version to version, so any complex status handling should be based on status value. Note that description() returns a char string even in PUGIXML_WCHAR_MODE; you’ll have to call as_wide to get the wchar_t string.

-
-
-

If parsing failed because the source data was not a valid XML, the resulting tree is not destroyed - despite the fact that load function returns error, you can use the part of the tree that was successfully parsed. Obviously, the last element may have an unexpected name/value; for example, if the attribute value does not end with the necessary quotation mark, like in <node attr="value>some data</node> example, the value of attribute attr will contain the string value>some data</node>.

-
-
-

In addition to the status code, parsing result has an offset member, which contains the offset of last successfully parsed character if parsing failed because of an error in source data; otherwise offset is 0. For parsing efficiency reasons, pugixml does not track the current line during parsing; this offset is in units of pugi::char_t (bytes for character mode, wide characters for wide character mode). Many text editors support 'Go To Position' feature - you can use it to locate the exact error position. Alternatively, if you’re loading the document from memory, you can display the error chunk along with the error description (see the example code below).

-
-
- - - - - -
-
Caution
-
-Offset is calculated in the XML buffer in native encoding; if encoding conversion is performed during parsing, offset can not be used to reliably track the error position. -
-
-
-

Parsing result also has an encoding member, which can be used to check that the source data encoding was correctly guessed. It is equal to the exact encoding used during parsing (i.e. with the exact endianness); see Encodings for more information.

-
-
-

Parsing result object can be implicitly converted to bool; if you do not want to handle parsing errors thoroughly, you can just check the return value of load functions as if it was a bool: if (doc.load_file("file.xml")) { …​ } else { …​ }.

-
-
-

This is an example of handling loading errors (samples/load_error_handling.cpp):

-
-
-
-
pugi::xml_document doc;
-pugi::xml_parse_result result = doc.load_string(source);
-
-if (result)
-{
-    std::cout << "XML [" << source << "] parsed without errors, attr value: [" << doc.child("node").attribute("attr").value() << "]\n\n";
-}
-else
-{
-    std::cout << "XML [" << source << "] parsed with errors, attr value: [" << doc.child("node").attribute("attr").value() << "]\n";
-    std::cout << "Error description: " << result.description() << "\n";
-    std::cout << "Error offset: " << result.offset << " (error at [..." << (source + result.offset) << "]\n\n";
-}
-
-
-
-
-

4.5. Parsing options

-
-

All document loading functions accept the optional parameter options. This is a bitmask that customizes the parsing process: you can select the node types that are parsed and various transformations that are performed with the XML text. Disabling certain transformations can improve parsing performance for some documents; however, the code for all transformations is very well optimized, and thus the majority of documents won’t get any performance benefit. As a rule of thumb, only modify parsing flags if you want to get some nodes in the document that are excluded by default (i.e. declaration or comment nodes).

-
-
- - - - - -
-
Note
-
-You should use the usual bitwise arithmetics to manipulate the bitmask: to enable a flag, use mask | flag; to disable a flag, use mask & ~flag. -
-
-
-

These flags control the resulting tree contents:

-
-
-
    -
  • -

    parse_declaration determines if XML document declaration (node with type node_declaration) is to be put in DOM tree. If this flag is off, it is not put in the tree, but is still parsed and checked for correctness. This flag is off by default.

    -
  • -
  • -

    parse_doctype determines if XML document type declaration (node with type node_doctype) is to be put in DOM tree. If this flag is off, it is not put in the tree, but is still parsed and checked for correctness. This flag is off by default.

    -
  • -
  • -

    parse_pi determines if processing instructions (nodes with type node_pi) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. Note that <?xml …​?> (document declaration) is not considered to be a PI. This flag is off by default.

    -
  • -
  • -

    parse_comments determines if comments (nodes with type node_comment) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. This flag is off by default.

    -
  • -
  • -

    parse_cdata determines if CDATA sections (nodes with type node_cdata) are to be put in DOM tree. If this flag is off, they are not put in the tree, but are still parsed and checked for correctness. This flag is on by default.

    -
  • -
  • -

    parse_trim_pcdata determines if leading and trailing whitespace characters are to be removed from PCDATA nodes. While for some applications leading/trailing whitespace is significant, often the application only cares about the non-whitespace contents so it’s easier to trim whitespace from text during parsing. This flag is off by default.

    -
  • -
  • -

    parse_ws_pcdata determines if PCDATA nodes (nodes with type node_pcdata) that consist only of whitespace characters are to be put in DOM tree. Often whitespace-only data is not significant for the application, and the cost of allocating and storing such nodes (both memory and speed-wise) can be significant. For example, after parsing XML string <node> <a/> </node>, <node> element will have three children when parse_ws_pcdata is set (child with type node_pcdata and value " ", child with type node_element and name "a", and another child with type node_pcdata and value " "), and only one child when parse_ws_pcdata is not set. This flag is off by default.

    -
  • -
  • -

    parse_ws_pcdata_single determines if whitespace-only PCDATA nodes that have no sibling nodes are to be put in DOM tree. In some cases application needs to parse the whitespace-only contents of nodes, i.e. <node> </node>, but is not interested in whitespace markup elsewhere. It is possible to use parse_ws_pcdata flag in this case, but it results in excessive allocations and complicates document processing; this flag can be used to avoid that. As an example, after parsing XML string <node> <a> </a> </node> with parse_ws_pcdata_single flag set, <node> element will have one child <a>, and <a> element will have one child with type node_pcdata and value " ". This flag has no effect if parse_ws_pcdata is enabled. This flag is off by default.

    -
  • -
  • -

    parse_embed_pcdata determines if PCDATA contents is to be saved as element values. Normally element nodes have names but not values; this flag forces the parser to store the contents as a value if PCDATA is the first child of the element node (otherwise PCDATA node is created as usual). This can significantly reduce the memory required for documents with many PCDATA nodes. To retrieve the data you can use xml_node::value() on the element nodes or any of the higher-level functions like child_value or text. This flag is off by default. -Since this flag significantly changes the DOM structure it is only recommended for parsing documents with many PCDATA nodes in memory-constrained environments. This flag is off by default.

    -
  • -
  • -

    parse_fragment determines if document should be treated as a fragment of a valid XML. Parsing document as a fragment leads to top-level PCDATA content (i.e. text that is not located inside a node) to be added to a tree, and additionally treats documents without element nodes as valid. This flag is off by default.

    -
  • -
-
-
- - - - - -
-
Caution
-
-Using in-place parsing (load_buffer_inplace) with parse_fragment flag may result in the loss of the last character of the buffer if it is a part of PCDATA. Since PCDATA values are null-terminated strings, the only way to resolve this is to provide a null-terminated buffer as an input to load_buffer_inplace - i.e. doc.load_buffer_inplace("test\0", 5, pugi::parse_default | pugi::parse_fragment). -
-
-
-

These flags control the transformation of tree element contents:

-
-
-
    -
  • -

    parse_escapes determines if character and entity references are to be expanded during the parsing process. Character references have the form &#…​; or &#x…​; (…​ is Unicode numeric representation of character in either decimal (&#…​;) or hexadecimal (&#x…​;) form), entity references are &lt;, &gt;, &amp;, &apos; and &quot; (note that as pugixml does not handle DTD, the only allowed entities are predefined ones). If character/entity reference can not be expanded, it is left as is, so you can do additional processing later. Reference expansion is performed on attribute values and PCDATA content. This flag is on by default.

    -
  • -
  • -

    parse_eol determines if EOL handling (that is, replacing sequences \r\n by a single \n character, and replacing all standalone \r characters by \n) is to be performed on input data (that is, comment contents, PCDATA/CDATA contents and attribute values). This flag is on by default.

    -
  • -
  • -

    parse_wconv_attribute determines if attribute value normalization should be performed for all attributes. This means, that whitespace characters (new line, tab and space) are replaced with space (' '). New line characters are always treated as if parse_eol is set, i.e. \r\n is converted to a single space. This flag is on by default.

    -
  • -
  • -

    parse_wnorm_attribute determines if extended attribute value normalization should be performed for all attributes. This means, that after attribute values are normalized as if parse_wconv_attribute was set, leading and trailing space characters are removed, and all sequences of space characters are replaced by a single space character. parse_wconv_attribute has no effect if this flag is on. This flag is off by default.

    -
  • -
-
-
- - - - - -
-
Note
-
-parse_wconv_attribute option performs transformations that are required by W3C specification for attributes that are declared as CDATA; parse_wnorm_attribute performs transformations required for NMTOKENS attributes. In the absence of document type declaration all attributes should behave as if they are declared as CDATA, thus parse_wconv_attribute is the default option. -
-
-
-

Additionally there are three predefined option masks:

-
-
-
    -
  • -

    parse_minimal has all options turned off. This option mask means that pugixml does not add declaration nodes, document type declaration nodes, PI nodes, CDATA sections and comments to the resulting tree and does not perform any conversion for input data, so theoretically it is the fastest mode. However, as mentioned above, in practice parse_default is usually equally fast.

    -
  • -
  • -

    parse_default is the default set of flags, i.e. it has all options set to their default values. It includes parsing CDATA sections (comments/PIs are not parsed), performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed (by default) for performance reasons.

    -
  • -
  • -

    parse_full is the set of flags which adds nodes of all types to the resulting tree and performs default conversions for input data. It includes parsing CDATA sections, comments, PI nodes, document declaration node and document type declaration node, performing character and entity reference expansion, replacing whitespace characters with spaces in attribute values and performing EOL handling. Note, that PCDATA sections consisting only of whitespace characters are not parsed in this mode.

    -
  • -
-
-
-

This is an example of using different parsing options (samples/load_options.cpp):

-
-
-
-
const char* source = "<!--comment--><node>&lt;</node>";
-
-// Parsing with default options; note that comment node is not added to the tree, and entity reference &lt; is expanded
-doc.load_string(source);
-std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
-
-// Parsing with additional parse_comments option; comment node is now added to the tree
-doc.load_string(source, pugi::parse_default | pugi::parse_comments);
-std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
-
-// Parsing with additional parse_comments option and without the (default) parse_escapes option; &lt; is not expanded
-doc.load_string(source, (pugi::parse_default | pugi::parse_comments) & ~pugi::parse_escapes);
-std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
-
-// Parsing with minimal option mask; comment node is not added to the tree, and &lt; is not expanded
-doc.load_string(source, pugi::parse_minimal);
-std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n";
-
-
-
-
-

4.6. Encodings

-
-

pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it’s a strict subset of UTF-16) as well as some non-Unicode encodings (Latin-1) and handles all encoding conversions. Most loading functions accept the optional parameter encoding. This is a value of enumeration type xml_encoding, that can have the following values:

-
-
-
    -
  • -

    encoding_auto means that pugixml will try to guess the encoding based on source XML data. The algorithm is a modified version of the one presented in Appendix F of XML recommendation. It tries to find a Byte Order Mark of one of the supported encodings first; if that fails, it checks if the first few bytes of the input data look like a representation of < or <? in one of UTF-16 or UTF-32 variants; if that fails as well, encoding is assumed to be either UTF-8 or one of the non-Unicode encodings - to make the final decision the algorithm tries to parse the encoding attribute of the XML document declaration, ultimately falling back to UTF-8 if document declaration is not present or does not specify a supported encoding.

    -
  • -
  • -

    encoding_utf8 corresponds to UTF-8 encoding as defined in the Unicode standard; UTF-8 sequences with length equal to 5 or 6 are not standard and are rejected.

    -
  • -
  • -

    encoding_utf16_le corresponds to little-endian UTF-16 encoding as defined in the Unicode standard; surrogate pairs are supported.

    -
  • -
  • -

    encoding_utf16_be corresponds to big-endian UTF-16 encoding as defined in the Unicode standard; surrogate pairs are supported.

    -
  • -
  • -

    encoding_utf16 corresponds to UTF-16 encoding as defined in the Unicode standard; the endianness is assumed to be that of the target platform.

    -
  • -
  • -

    encoding_utf32_le corresponds to little-endian UTF-32 encoding as defined in the Unicode standard.

    -
  • -
  • -

    encoding_utf32_be corresponds to big-endian UTF-32 encoding as defined in the Unicode standard.

    -
  • -
  • -

    encoding_utf32 corresponds to UTF-32 encoding as defined in the Unicode standard; the endianness is assumed to be that of the target platform.

    -
  • -
  • -

    encoding_wchar corresponds to the encoding of wchar_t type; it has the same meaning as either encoding_utf16 or encoding_utf32, depending on wchar_t size.

    -
  • -
  • -

    encoding_latin1 corresponds to ISO-8859-1 encoding (also known as Latin-1).

    -
  • -
-
-
-

The algorithm used for encoding_auto correctly detects any supported Unicode encoding for all well-formed XML documents (since they start with document declaration) and for all other XML documents that start with <; if your XML document does not start with < and has encoding that is different from UTF-8, use the specific encoding.

-
-
- - - - - -
-
Note
-
-The current behavior for Unicode conversion is to skip all invalid UTF sequences during conversion. This behavior should not be relied upon; moreover, in case no encoding conversion is performed, the invalid sequences are not removed, so you’ll get them as is in node/attribute contents. -
-
-
-
-

4.7. Conformance to W3C specification

-
-

pugixml is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed because of performance reasons.

-
-
-

There is only one non-conformant behavior when dealing with valid XML documents: pugixml does not use information supplied in document type declaration for parsing. This means that entities declared in DOCTYPE are not expanded, and all attribute/PCDATA values are always processed in a uniform way that depends only on parsing options.

-
-
-

As for rejecting invalid XML documents, there are a number of incompatibilities with W3C specification, including:

-
-
-
    -
  • -

    Multiple attributes of the same node can have equal names.

    -
  • -
  • -

    Tag and attribute names are not fully validated for consisting of allowed characters, so some invalid tags are not rejected

    -
  • -
  • -

    Attribute values which contain < are not rejected.

    -
  • -
  • -

    Invalid entity/character references are not rejected and are instead left as is.

    -
  • -
  • -

    Comment values can contain --.

    -
  • -
  • -

    XML data is not required to begin with document declaration; additionally, document declaration can appear after comments and other nodes.

    -
  • -
  • -

    Invalid document type declarations are silently ignored in some cases.

    -
  • -
  • -

    Unicode validation is not performed so invalid UTF sequences are not rejected.

    -
  • -
-
-
-
-
-
-

5. Accessing document data

-
-
-

pugixml features an extensive interface for getting various types of data from the document and for traversing the document. This section provides documentation for all such functions that do not modify the tree except for XPath-related functions; see XPath for XPath reference. As discussed in C++ interface, there are two types of handles to tree data - xml_node and xml_attribute. The handles have special null (empty) values which propagate through various functions and thus are useful for writing more concise code; see this description for details. The documentation in this section will explicitly state the results of all function in case of null inputs.

-
-
-

Basic traversal functions

-
-

-The internal representation of the document is a tree, where each node has a list of child nodes (the order of children corresponds to their order in the XML representation), and additionally element nodes have a list of attributes, which is also ordered. Several functions are provided in order to let you get from one node in the tree to the other. These functions roughly correspond to the internal representation, and thus are usually building blocks for other methods of traversing (i.e. XPath traversals are based on these functions).

-
-
-
-
xml_node xml_node::parent() const;
-xml_node xml_node::first_child() const;
-xml_node xml_node::last_child() const;
-xml_node xml_node::next_sibling() const;
-xml_node xml_node::previous_sibling() const;
-
-xml_attribute xml_node::first_attribute() const;
-xml_attribute xml_node::last_attribute() const;
-xml_attribute xml_attribute::next_attribute() const;
-xml_attribute xml_attribute::previous_attribute() const;
-
-
-
-

parent function returns the node’s parent; all non-null nodes except the document have non-null parent. first_child and last_child return the first and last child of the node, respectively; note that only document nodes and element nodes can have non-empty child node list. If node has no children, both functions return null nodes. next_sibling and previous_sibling return the node that’s immediately to the right/left of this node in the children list, respectively - for example, in <a/><b/><c/>, calling next_sibling for a handle that points to <b/> results in a handle pointing to <c/>, and calling previous_sibling results in handle pointing to <a/>. If node does not have next/previous sibling (this happens if it is the last/first node in the list, respectively), the functions return null nodes. first_attribute, last_attribute, next_attribute and previous_attribute functions behave similarly to the corresponding child node functions and allow to iterate through attribute list in the same way.

-
-
- - - - - -
-
Note
-
-Because of memory consumption reasons, attributes do not have a link to their parent nodes. Thus there is no xml_attribute::parent() function. -
-
-
-

Calling any of the functions above on the null handle results in a null handle - i.e. node.first_child().next_sibling() returns the second child of node, and null handle if node is null, has no children at all or if it has only one child node.

-
-
-

With these functions, you can iterate through all child nodes and display all attributes like this (samples/traverse_base.cpp):

-
-
-
-
for (pugi::xml_node tool = tools.first_child(); tool; tool = tool.next_sibling())
-{
-    std::cout << "Tool:";
-
-    for (pugi::xml_attribute attr = tool.first_attribute(); attr; attr = attr.next_attribute())
-    {
-        std::cout << " " << attr.name() << "=" << attr.value();
-    }
-
-    std::cout << std::endl;
-}
-
-
-
-
-

5.1. Getting node data

-
-

-Apart from structural information (parent, child nodes, attributes), nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. node_document nodes do not have a name or value, node_element and node_declaration nodes always have a name but never have a value, node_pcdata, node_cdata, node_comment and node_doctype nodes never have a name but always have a value (it may be empty though), node_pi nodes always have a name and a value (again, value may be empty). In order to get node’s name or value, you can use the following functions:

-
-
-
-
const char_t* xml_node::name() const;
-const char_t* xml_node::value() const;
-
-
-
-

In case node does not have a name or value or if the node handle is null, both functions return empty strings - they never return null pointers.

-
-
-

It is common to store data as text contents of some node - i.e. <node><description>This is a node</description></node>. In this case, <description> node does not have a value, but instead has a child of type node_pcdata with value "This is a node". pugixml provides several helper functions to parse such data:

-
-
-
-
const char_t* xml_node::child_value() const;
-const char_t* xml_node::child_value(const char_t* name) const;
-xml_text xml_node::text() const;
-
-
-
-

child_value() returns the value of the first child with type node_pcdata or node_cdata; child_value(name) is a simple wrapper for child(name).child_value(). For the above example, calling node.child_value("description") and description.child_value() will both produce string "This is a node". If there is no child with relevant type, or if the handle is null, child_value functions return empty string.

-
-
-

text() returns a special object that can be used for working with PCDATA contents in more complex cases than just retrieving the value; it is described in Working with text contents sections.

-
-
-

There is an example of using some of these functions at the end of the next section.

-
-
-
-

5.2. Getting attribute data

-
-

-All attributes have name and value, both of which are strings (value may be empty). There are two corresponding accessors, like for xml_node:

-
-
-
-
const char_t* xml_attribute::name() const;
-const char_t* xml_attribute::value() const;
-
-
-
-

In case the attribute handle is null, both functions return empty strings - they never return null pointers.

-
-
-

If you need a non-empty string if the attribute handle is null (for example, you need to get the option value from XML attribute, but if it is not specified, you need it to default to "sorted" instead of ""), you can use as_string accessor:

-
-
-
-
const char_t* xml_attribute::as_string(const char_t* def = "") const;
-
-
-
-

It returns def argument if the attribute handle is null. If you do not specify the argument, the function is equivalent to value().

-
-
-

-In many cases attribute values have types that are not strings - i.e. an attribute may always contain values that should be treated as integers, despite the fact that they are represented as strings in XML. pugixml provides several accessors that convert attribute value to some other type:

-
-
-
-
int xml_attribute::as_int(int def = 0) const;
-unsigned int xml_attribute::as_uint(unsigned int def = 0) const;
-double xml_attribute::as_double(double def = 0) const;
-float xml_attribute::as_float(float def = 0) const;
-bool xml_attribute::as_bool(bool def = false) const;
-long long xml_attribute::as_llong(long long def = 0) const;
-unsigned long long xml_attribute::as_ullong(unsigned long long def = 0) const;
-
-
-
-

as_int, as_uint, as_llong, as_ullong, as_double and as_float convert attribute values to numbers. If attribute handle is null def argument is returned (which is 0 by default). Otherwise, all leading whitespace characters are truncated, and the remaining string is parsed as an integer number in either decimal or hexadecimal form (applicable to as_int, as_uint, as_llong and as_ullong; hexadecimal format is used if the number has 0x or 0X prefix) or as a floating point number in either decimal or scientific form (as_double or as_float).

-
-
-

In case the input string contains a non-numeric character sequence or a number that is out of the target numeric range, the result is undefined.

-
-
- - - - - -
-
Caution
-
-Number conversion functions depend on current C locale as set with setlocale, so may return unexpected results if the locale is different from "C". -
-
-
-

as_bool converts attribute value to boolean as follows: if attribute handle is null, def argument is returned (which is false by default). If attribute value is empty, false is returned. Otherwise, true is returned if the first character is one of '1', 't', 'T', 'y', 'Y'. This means that strings like "true" and "yes" are recognized as true, while strings like "false" and "no" are recognized as false. For more complex matching you’ll have to write your own function.

-
-
- - - - - -
-
Note
-
-as_llong and as_ullong are only available if your platform has reliable support for the long long type, including string conversions. -
-
-
-

This is an example of using these functions, along with node data retrieval ones (samples/traverse_base.cpp):

-
-
-
-
for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool"))
-{
-    std::cout << "Tool " << tool.attribute("Filename").value();
-    std::cout << ": AllowRemote " << tool.attribute("AllowRemote").as_bool();
-    std::cout << ", Timeout " << tool.attribute("Timeout").as_int();
-    std::cout << ", Description '" << tool.child_value("Description") << "'\n";
-}
-
-
-
-
-

5.3. Contents-based traversal functions

-
-

-Since a lot of document traversal consists of finding the node/attribute with the correct name, there are special functions for that purpose:

-
-
-
-
xml_node xml_node::child(const char_t* name) const;
-xml_attribute xml_node::attribute(const char_t* name) const;
-xml_node xml_node::next_sibling(const char_t* name) const;
-xml_node xml_node::previous_sibling(const char_t* name) const;
-
-
-
-

child and attribute return the first child/attribute with the specified name; next_sibling and previous_sibling return the first sibling in the corresponding direction with the specified name. All string comparisons are case-sensitive. In case the node handle is null or there is no node/attribute with the specified name, null handle is returned.

-
-
-

child and next_sibling functions can be used together to loop through all child nodes with the desired name like this:

-
-
-
-
for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool"))
-
-
-
-

Occasionally the needed node is specified not by the unique name but instead by the value of some attribute; for example, it is common to have node collections with each node having a unique id: <group><item id="1"/> <item id="2"/></group>. There are two functions for finding child nodes based on the attribute values:

-
-
-
-
xml_node xml_node::find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
-xml_node xml_node::find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const;
-
-
-
-

The three-argument function returns the first child node with the specified name which has an attribute with the specified name/value; the two-argument function skips the name test for the node, which can be useful for searching in heterogeneous collections. If the node handle is null or if no node is found, null handle is returned. All string comparisons are case-sensitive.

-
-
-

In all of the above functions, all arguments have to be valid strings; passing null pointers results in undefined behavior.

-
-
-

This is an example of using these functions (samples/traverse_base.cpp):

-
-
-
-
std::cout << "Tool for *.dae generation: " << tools.find_child_by_attribute("Tool", "OutputFileMasks", "*.dae").attribute("Filename").value() << "\n";
-
-for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool"))
-{
-    std::cout << "Tool " << tool.attribute("Filename").value() << "\n";
-}
-
-
-
-
-

5.4. Range-based for-loop support

-
-

-If your C++ compiler supports range-based for-loop (this is a C++11 feature, at the time of writing it’s supported by Microsoft Visual Studio 2012+, GCC 4.6+ and Clang 3.0+), you can use it to enumerate nodes/attributes. Additional helpers are provided to support this; note that they are also compatible with Boost Foreach, and possibly other pre-C++11 foreach facilities.

-
-
-
-
implementation-defined-type xml_node::children() const;
-implementation-defined-type xml_node::children(const char_t* name) const;
-implementation-defined-type xml_node::attributes() const;
-
-
-
-

children function allows you to enumerate all child nodes; children function with name argument allows you to enumerate all child nodes with a specific name; attributes function allows you to enumerate all attributes of the node. Note that you can also use node object itself in a range-based for construct, which is equivalent to using children().

-
-
-

This is an example of using these functions (samples/traverse_rangefor.cpp):

-
-
-
-
for (pugi::xml_node tool: tools.children("Tool"))
-{
-    std::cout << "Tool:";
-
-    for (pugi::xml_attribute attr: tool.attributes())
-    {
-        std::cout << " " << attr.name() << "=" << attr.value();
-    }
-
-    for (pugi::xml_node child: tool.children())
-    {
-        std::cout << ", child " << child.name();
-    }
-
-    std::cout << std::endl;
-}
-
-
-
-

While using children() makes the intent of the code clear, note that each node can be treated as a container of child nodes, since it provides begin()/end() member functions described in the next section. Because of this, you can iterate through node’s children simply by using the node itself:

-
-
-
-
for (pugi::xml_node child: tool)
-
-
-
-
-

5.5. Traversing node/attribute lists via iterators

-
-

-Child node lists and attribute lists are simply double-linked lists; while you can use previous_sibling/next_sibling and other such functions for iteration, pugixml additionally provides node and attribute iterators, so that you can treat nodes as containers of other nodes or attributes:

-
-
-
-
class xml_node_iterator;
-class xml_attribute_iterator;
-
-typedef xml_node_iterator xml_node::iterator;
-iterator xml_node::begin() const;
-iterator xml_node::end() const;
-
-typedef xml_attribute_iterator xml_node::attribute_iterator;
-attribute_iterator xml_node::attributes_begin() const;
-attribute_iterator xml_node::attributes_end() const;
-
-
-
-

begin and attributes_begin return iterators that point to the first node/attribute, respectively; end and attributes_end return past-the-end iterator for node/attribute list, respectively - this iterator can’t be dereferenced, but decrementing it results in an iterator pointing to the last element in the list (except for empty lists, where decrementing past-the-end iterator results in undefined behavior). Past-the-end iterator is commonly used as a termination value for iteration loops (see sample below). If you want to get an iterator that points to an existing handle, you can construct the iterator with the handle as a single constructor argument, like so: xml_node_iterator(node). For xml_attribute_iterator, you’ll have to provide both an attribute and its parent node.

-
-
-

begin and end return equal iterators if called on null node; such iterators can’t be dereferenced. attributes_begin and attributes_end behave the same way. For correct iterator usage this means that child node/attribute collections of null nodes appear to be empty.

-
-
-

Both types of iterators have bidirectional iterator semantics (i.e. they can be incremented and decremented, but efficient random access is not supported) and support all usual iterator operations - comparison, dereference, etc. The iterators are invalidated if the node/attribute objects they’re pointing to are removed from the tree; adding nodes/attributes does not invalidate any iterators.

-
-
-

Here is an example of using iterators for document traversal (samples/traverse_iter.cpp):

-
-
-
-
for (pugi::xml_node_iterator it = tools.begin(); it != tools.end(); ++it)
-{
-    std::cout << "Tool:";
-
-    for (pugi::xml_attribute_iterator ait = it->attributes_begin(); ait != it->attributes_end(); ++ait)
-    {
-        std::cout << " " << ait->name() << "=" << ait->value();
-    }
-
-    std::cout << std::endl;
-}
-
-
-
- - - - - -
-
Caution
-
-Node and attribute iterators are somewhere in the middle between const and non-const iterators. While dereference operation yields a non-constant reference to the object, so that you can use it for tree modification operations, modifying this reference using assignment - i.e. passing iterators to a function like std::sort - will not give expected results, as assignment modifies local handle that’s stored in the iterator. -
-
-
-
-

5.6. Recursive traversal with xml_tree_walker

-
-

The methods described above allow traversal of immediate children of some node; if you want to do a deep tree traversal, you’ll have to do it via a recursive function or some equivalent method. However, pugixml provides a helper for depth-first traversal of a subtree. In order to use it, you have to implement xml_tree_walker interface and to call traverse function:

-
-
-
-
class xml_tree_walker
-{
-public:
-    virtual bool begin(xml_node& node);
-    virtual bool for_each(xml_node& node) = 0;
-    virtual bool end(xml_node& node);
-
-    int depth() const;
-};
-
-bool xml_node::traverse(xml_tree_walker& walker);
-
-
-
-

-The traversal is launched by calling traverse function on traversal root and proceeds as follows:

-
-
-
    -
  • -

    First, begin function is called with traversal root as its argument.

    -
  • -
  • -

    Then, for_each function is called for all nodes in the traversal subtree in depth first order, excluding the traversal root. Node is passed as an argument.

    -
  • -
  • -

    Finally, end function is called with traversal root as its argument.

    -
  • -
-
-
-

If begin, end or any of the for_each calls return false, the traversal is terminated and false is returned as the traversal result; otherwise, the traversal results in true. Note that you don’t have to override begin or end functions; their default implementations return true.

-
-
-

You can get the node’s depth relative to the traversal root at any point by calling depth function. It returns -1 if called from begin/end, and returns 0-based depth if called from for_each - depth is 0 for all children of the traversal root, 1 for all grandchildren and so on.

-
-
-

This is an example of traversing tree hierarchy with xml_tree_walker (samples/traverse_walker.cpp):

-
-
-
-
struct simple_walker: pugi::xml_tree_walker
-{
-    virtual bool for_each(pugi::xml_node& node)
-    {
-        for (int i = 0; i < depth(); ++i) std::cout << "  "; // indentation
-
-        std::cout << node_types[node.type()] << ": name='" << node.name() << "', value='" << node.value() << "'\n";
-
-        return true; // continue traversal
-    }
-};
-
-
-
-
-
simple_walker walker;
-doc.traverse(walker);
-
-
-
-
-

5.7. Searching for nodes/attributes with predicates

-
-

-While there are existing functions for getting a node/attribute with known contents, they are often not sufficient for simple queries. As an alternative for manual iteration through nodes/attributes until the needed one is found, you can make a predicate and call one of find_ functions:

-
-
-
-
template <typename Predicate> xml_attribute xml_node::find_attribute(Predicate pred) const;
-template <typename Predicate> xml_node xml_node::find_child(Predicate pred) const;
-template <typename Predicate> xml_node xml_node::find_node(Predicate pred) const;
-
-
-
-

The predicate should be either a plain function or a function object which accepts one argument of type xml_attribute (for find_attribute) or xml_node (for find_child and find_node), and returns bool. The predicate is never called with null handle as an argument.

-
-
-

find_attribute function iterates through all attributes of the specified node, and returns the first attribute for which the predicate returned true. If the predicate returned false for all attributes or if there were no attributes (including the case where the node is null), null attribute is returned.

-
-
-

find_child function iterates through all child nodes of the specified node, and returns the first node for which the predicate returned true. If the predicate returned false for all nodes or if there were no child nodes (including the case where the node is null), null node is returned.

-
-
-

find_node function performs a depth-first traversal through the subtree of the specified node (excluding the node itself), and returns the first node for which the predicate returned true. If the predicate returned false for all nodes or if subtree was empty, null node is returned.

-
-
-

This is an example of using predicate-based functions (samples/traverse_predicate.cpp):

-
-
-
-
bool small_timeout(pugi::xml_node node)
-{
-    return node.attribute("Timeout").as_int() < 20;
-}
-
-struct allow_remote_predicate
-{
-    bool operator()(pugi::xml_attribute attr) const
-    {
-        return strcmp(attr.name(), "AllowRemote") == 0;
-    }
-
-    bool operator()(pugi::xml_node node) const
-    {
-        return node.attribute("AllowRemote").as_bool();
-    }
-};
-
-
-
-
-
// Find child via predicate (looks for direct children only)
-std::cout << tools.find_child(allow_remote_predicate()).attribute("Filename").value() << std::endl;
-
-// Find node via predicate (looks for all descendants in depth-first order)
-std::cout << doc.find_node(allow_remote_predicate()).attribute("Filename").value() << std::endl;
-
-// Find attribute via predicate
-std::cout << tools.last_child().find_attribute(allow_remote_predicate()).value() << std::endl;
-
-// We can use simple functions instead of function objects
-std::cout << tools.find_child(small_timeout).attribute("Filename").value() << std::endl;
-
-
-
-
-

5.8. Working with text contents

-
-

It is common to store data as text contents of some node - i.e. <node><description>This is a node</description></node>. In this case, <description> node does not have a value, but instead has a child of type node_pcdata with value "This is a node". pugixml provides a special class, xml_text, to work with such data. Working with text objects to modify data is described in the documentation for modifying document data; this section describes the access interface of xml_text.

-
-
-

You can get the text object from a node by using text() method:

-
-
-
-
xml_text xml_node::text() const;
-
-
-
-

If the node has a type node_pcdata or node_cdata, then the node itself is used to return data; otherwise, a first child node of type node_pcdata or node_cdata is used.

-
-
-

-You can check if the text object is bound to a valid PCDATA/CDATA node by using it as a boolean value, i.e. if (text) { …​ } or if (!text) { …​ }. Alternatively you can check it by using the empty() method:

-
-
-
-
bool xml_text::empty() const;
-
-
-
-

Given a text object, you can get the contents (i.e. the value of PCDATA/CDATA node) by using the following function:

-
-
-
-
const char_t* xml_text::get() const;
-
-
-
-

In case text object is empty, the function returns an empty string - it never returns a null pointer.

-
-
-

-If you need a non-empty string if the text object is empty, or if the text contents is actually a number or a boolean that is stored as a string, you can use the following accessors:

-
-
-
-
const char_t* xml_text::as_string(const char_t* def = "") const;
-int xml_text::as_int(int def = 0) const;
-unsigned int xml_text::as_uint(unsigned int def = 0) const;
-double xml_text::as_double(double def = 0) const;
-float xml_text::as_float(float def = 0) const;
-bool xml_text::as_bool(bool def = false) const;
-long long xml_text::as_llong(long long def = 0) const;
-unsigned long long xml_text::as_ullong(unsigned long long def = 0) const;
-
-
-
-

All of the above functions have the same semantics as similar xml_attribute members: they return the default argument if the text object is empty, they convert the text contents to a target type using the same rules and restrictions. You can refer to documentation for the attribute functions for details.

-
-
-

xml_text is essentially a helper class that operates on xml_node values. It is bound to a node of type node_pcdata or node_cdata. You can use the following function to retrieve this node:

-
-
-
-
xml_node xml_text::data() const;
-
-
-
-

Essentially, assuming text is an xml_text object, calling text.get() is equivalent to calling text.data().value().

-
-
-

This is an example of using xml_text object (samples/text.cpp):

-
-
-
-
std::cout << "Project name: " << project.child("name").text().get() << std::endl;
-std::cout << "Project version: " << project.child("version").text().as_double() << std::endl;
-std::cout << "Project visibility: " << (project.child("public").text().as_bool(/* def= */ true) ? "public" : "private") << std::endl;
-std::cout << "Project description: " << project.child("description").text().get() << std::endl;
-
-
-
-
-

5.9. Miscellaneous functions

-
-

If you need to get the document root of some node, you can use the following function:

-
-
-
-
xml_node xml_node::root() const;
-
-
-
-

This function returns the node with type node_document, which is the root node of the document the node belongs to (unless the node is null, in which case null node is returned).

-
-
-

-While pugixml supports complex XPath expressions, sometimes a simple path handling facility is needed. There are two functions, for getting node path and for converting path to a node:

-
-
-
-
string_t xml_node::path(char_t delimiter = '/') const;
-xml_node xml_node::first_element_by_path(const char_t* path, char_t delimiter = '/') const;
-
-
-
-

Node paths consist of node names, separated with a delimiter (which is / by default); also paths can contain self (.) and parent (..) pseudo-names, so that this is a valid path: "../../foo/./bar". path returns the path to the node from the document root, first_element_by_path looks for a node represented by a given path; a path can be an absolute one (absolute paths start with the delimiter), in which case the rest of the path is treated as document root relative, and relative to the given node. For example, in the following document: <a><b><c/></b></a>, node <c/> has path "a/b/c"; calling first_element_by_path for document with path "a/b" results in node <b/>; calling first_element_by_path for node <a/> with path "../a/./b/../." results in node <a/>; calling first_element_by_path with path "/a" results in node <a/> for any node.

-
-
-

In case path component is ambiguous (if there are two nodes with given name), the first one is selected; paths are not guaranteed to uniquely identify nodes in a document. If any component of a path is not found, the result of first_element_by_path is null node; also first_element_by_path returns null node for null nodes, in which case the path does not matter. path returns an empty string for null nodes.

-
-
- - - - - -
-
Note
-
-path function returns the result as STL string, and thus is not available if PUGIXML_NO_STL is defined. -
-
-
-

pugixml does not record row/column information for nodes upon parsing for efficiency reasons. However, if the node has not changed in a significant way since parsing (the name/value are not changed, and the node itself is the original one, i.e. it was not deleted from the tree and re-added later), it is possible to get the offset from the beginning of XML buffer:

-
-
-
-
ptrdiff_t xml_node::offset_debug() const;
-
-
-
-

If the offset is not available (this happens if the node is null, was not originally parsed from a stream, or has changed in a significant way), the function returns -1. Otherwise it returns the offset to node’s data from the beginning of XML buffer in pugi::char_t units. For more information on parsing offsets, see parsing error handling documentation.

-
-
-
-
-
-

6. Modifying document data

-
-
-

The document in pugixml is fully mutable: you can completely change the document structure and modify the data of nodes/attributes. This section provides documentation for the relevant functions. All functions take care of memory management and structural integrity themselves, so they always result in structurally valid tree - however, it is possible to create an invalid XML tree (for example, by adding two attributes with the same name or by setting attribute/node name to empty/invalid string). Tree modification is optimized for performance and for memory consumption, so if you have enough memory you can create documents from scratch with pugixml and later save them to file/stream instead of relying on error-prone manual text writing and without too much overhead.

-
-
-

All member functions that change node/attribute data or structure are non-constant and thus can not be called on constant handles. However, you can easily convert constant handle to non-constant one by simple assignment: void foo(const pugi::xml_node& n) { pugi::xml_node nc = n; }, so const-correctness here mainly provides additional documentation.

-
-
-

Setting node data

-
-

-As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. node_document nodes do not have a name or value, node_element and node_declaration nodes always have a name but never have a value, node_pcdata, node_cdata, node_comment and node_doctype nodes never have a name but always have a value (it may be empty though), node_pi nodes always have a name and a value (again, value may be empty). In order to set node’s name or value, you can use the following functions:

-
-
-
-
bool xml_node::set_name(const char_t* rhs);
-bool xml_node::set_value(const char_t* rhs);
-
-
-
-

Both functions try to set the name/value to the specified string, and return the operation result. The operation fails if the node can not have name or value (for instance, when trying to call set_name on a node_pcdata node), if the node handle is null, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to these functions). The name/value content is not verified, so take care to use only valid XML names, or the document may become malformed.

-
-
-

This is an example of setting node name and value (samples/modify_base.cpp):

-
-
-
-
pugi::xml_node node = doc.child("node");
-
-// change node name
-std::cout << node.set_name("notnode");
-std::cout << ", new node name: " << node.name() << std::endl;
-
-// change comment text
-std::cout << doc.last_child().set_value("useless comment");
-std::cout << ", new comment text: " << doc.last_child().value() << std::endl;
-
-// we can't change value of the element or name of the comment
-std::cout << node.set_value("1") << ", " << doc.last_child().set_name("2") << std::endl;
-
-
-
-
-

6.1. Setting attribute data

-
-

-All attributes have name and value, both of which are strings (value may be empty). You can set them with the following functions:

-
-
-
-
bool xml_attribute::set_name(const char_t* rhs);
-bool xml_attribute::set_value(const char_t* rhs);
-
-
-
-

Both functions try to set the name/value to the specified string, and return the operation result. The operation fails if the attribute handle is null, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to these functions). The name/value content is not verified, so take care to use only valid XML names, or the document may become malformed.

-
-
-

In addition to string functions, several functions are provided for handling attributes with numbers and booleans as values:

-
-
-
-
bool xml_attribute::set_value(int rhs);
-bool xml_attribute::set_value(unsigned int rhs);
-bool xml_attribute::set_value(long rhs);
-bool xml_attribute::set_value(unsigned long rhs);
-bool xml_attribute::set_value(double rhs);
-bool xml_attribute::set_value(float rhs);
-bool xml_attribute::set_value(bool rhs);
-bool xml_attribute::set_value(long long rhs);
-bool xml_attribute::set_value(unsigned long long rhs);
-
-
-
-

The above functions convert the argument to string and then call the base set_value function. Integers are converted to a decimal form, floating-point numbers are converted to either decimal or scientific form, depending on the number magnitude, boolean values are converted to either "true" or "false".

-
-
- - - - - -
-
Caution
-
-Number conversion functions depend on current C locale as set with setlocale, so may generate unexpected results if the locale is different from "C". -
-
-
- - - - - -
-
Note
-
-set_value overloads with long long type are only available if your platform has reliable support for the type, including string conversions. -
-
-
-

For convenience, all set_value functions have the corresponding assignment operators:

-
-
-
-
xml_attribute& xml_attribute::operator=(const char_t* rhs);
-xml_attribute& xml_attribute::operator=(int rhs);
-xml_attribute& xml_attribute::operator=(unsigned int rhs);
-xml_attribute& xml_attribute::operator=(long rhs);
-xml_attribute& xml_attribute::operator=(unsigned long rhs);
-xml_attribute& xml_attribute::operator=(double rhs);
-xml_attribute& xml_attribute::operator=(float rhs);
-xml_attribute& xml_attribute::operator=(bool rhs);
-xml_attribute& xml_attribute::operator=(long long rhs);
-xml_attribute& xml_attribute::operator=(unsigned long long rhs);
-
-
-
-

These operators simply call the right set_value function and return the attribute they’re called on; the return value of set_value is ignored, so errors are ignored.

-
-
-

This is an example of setting attribute name and value (samples/modify_base.cpp):

-
-
-
-
pugi::xml_attribute attr = node.attribute("id");
-
-// change attribute name/value
-std::cout << attr.set_name("key") << ", " << attr.set_value("345");
-std::cout << ", new attribute: " << attr.name() << "=" << attr.value() << std::endl;
-
-// we can use numbers or booleans
-attr.set_value(1.234);
-std::cout << "new attribute value: " << attr.value() << std::endl;
-
-// we can also use assignment operators for more concise code
-attr = true;
-std::cout << "final attribute value: " << attr.value() << std::endl;
-
-
-
-
-

6.2. Adding nodes/attributes

-
-

-Nodes and attributes do not exist without a document tree, so you can’t create them without adding them to some document. A node or attribute can be created at the end of node/attribute list or before/after some other node:

-
-
-
-
xml_attribute xml_node::append_attribute(const char_t* name);
-xml_attribute xml_node::prepend_attribute(const char_t* name);
-xml_attribute xml_node::insert_attribute_after(const char_t* name, const xml_attribute& attr);
-xml_attribute xml_node::insert_attribute_before(const char_t* name, const xml_attribute& attr);
-
-xml_node xml_node::append_child(xml_node_type type = node_element);
-xml_node xml_node::prepend_child(xml_node_type type = node_element);
-xml_node xml_node::insert_child_after(xml_node_type type, const xml_node& node);
-xml_node xml_node::insert_child_before(xml_node_type type, const xml_node& node);
-
-xml_node xml_node::append_child(const char_t* name);
-xml_node xml_node::prepend_child(const char_t* name);
-xml_node xml_node::insert_child_after(const char_t* name, const xml_node& node);
-xml_node xml_node::insert_child_before(const char_t* name, const xml_node& node);
-
-
-
-

append_attribute and append_child create a new node/attribute at the end of the corresponding list of the node the method is called on; prepend_attribute and prepend_child create a new node/attribute at the beginning of the list; insert_attribute_after, insert_attribute_before, insert_child_after and insert_attribute_before add the node/attribute before or after the specified node/attribute.

-
-
-

Attribute functions create an attribute with the specified name; you can specify the empty name and change the name later if you want to. Node functions with the type argument create the node with the specified type; since node type can’t be changed, you have to know the desired type beforehand. Also note that not all types can be added as children; see below for clarification. Node functions with the name argument create the element node (node_element) with the specified name.

-
-
-

All functions return the handle to the created object on success, and null handle on failure. There are several reasons for failure:

-
-
-
    -
  • -

    Adding fails if the target node is null;

    -
  • -
  • -

    Only node_element nodes can contain attributes, so attribute adding fails if node is not an element;

    -
  • -
  • -

    Only node_document and node_element nodes can contain children, so child node adding fails if the target node is not an element or a document;

    -
  • -
  • -

    node_document and node_null nodes can not be inserted as children, so passing node_document or node_null value as type results in operation failure;

    -
  • -
  • -

    node_declaration nodes can only be added as children of the document node; attempt to insert declaration node as a child of an element node fails;

    -
  • -
  • -

    Adding node/attribute results in memory allocation, which may fail;

    -
  • -
  • -

    Insertion functions fail if the specified node or attribute is null or is not in the target node’s children/attribute list.

    -
  • -
-
-
-

Even if the operation fails, the document remains in consistent state, but the requested node/attribute is not added.

-
-
- - - - - -
-
Caution
-
-attribute() and child() functions do not add attributes or nodes to the tree, so code like node.attribute("id") = 123; will not do anything if node does not have an attribute with name "id". Make sure you’re operating with existing attributes/nodes by adding them if necessary. -
-
-
-

This is an example of adding new attributes/nodes to the document (samples/modify_add.cpp):

-
-
-
-
// add node with some name
-pugi::xml_node node = doc.append_child("node");
-
-// add description node with text child
-pugi::xml_node descr = node.append_child("description");
-descr.append_child(pugi::node_pcdata).set_value("Simple node");
-
-// add param node before the description
-pugi::xml_node param = node.insert_child_before("param", descr);
-
-// add attributes to param node
-param.append_attribute("name") = "version";
-param.append_attribute("value") = 1.1;
-param.insert_attribute_after("type", param.attribute("name")) = "float";
-
-
-
-
-

6.3. Removing nodes/attributes

-
-

-If you do not want your document to contain some node or attribute, you can remove it with one of the following functions:

-
-
-
-
bool xml_node::remove_attribute(const xml_attribute& a);
-bool xml_node::remove_child(const xml_node& n);
-
-
-
-

remove_attribute removes the attribute from the attribute list of the node, and returns the operation result. remove_child removes the child node with the entire subtree (including all descendant nodes and attributes) from the document, and returns the operation result. Removing fails if one of the following is true:

-
-
-
    -
  • -

    The node the function is called on is null;

    -
  • -
  • -

    The attribute/node to be removed is null;

    -
  • -
  • -

    The attribute/node to be removed is not in the node’s attribute/child list.

    -
  • -
-
-
-

Removing the attribute or node invalidates all handles to the same underlying object, and also invalidates all iterators pointing to the same object. Removing node also invalidates all past-the-end iterators to its attribute or child node list. Be careful to ensure that all such handles and iterators either do not exist or are not used after the attribute/node is removed.

-
-
-

If you want to remove the attribute or child node by its name, two additional helper functions are available:

-
-
-
-
bool xml_node::remove_attribute(const char_t* name);
-bool xml_node::remove_child(const char_t* name);
-
-
-
-

These functions look for the first attribute or child with the specified name, and then remove it, returning the result. If there is no attribute or child with such name, the function returns false; if there are two nodes with the given name, only the first node is deleted. If you want to delete all nodes with the specified name, you can use code like this: while (node.remove_child("tool")) ;.

-
-
-

This is an example of removing attributes/nodes from the document (samples/modify_remove.cpp):

-
-
-
-
// remove description node with the whole subtree
-pugi::xml_node node = doc.child("node");
-node.remove_child("description");
-
-// remove id attribute
-pugi::xml_node param = node.child("param");
-param.remove_attribute("value");
-
-// we can also remove nodes/attributes by handles
-pugi::xml_attribute id = param.attribute("name");
-param.remove_attribute(id);
-
-
-
-
-

6.4. Working with text contents

-
-

pugixml provides a special class, xml_text, to work with text contents stored as a value of some node, i.e. <node><description>This is a node</description></node>. Working with text objects to retrieve data is described in the documentation for accessing document data; this section describes the modification interface of xml_text.

-
-
-

Once you have an xml_text object, you can set the text contents using the following function:

-
-
-
-
bool xml_text::set(const char_t* rhs);
-
-
-
-

This function tries to set the contents to the specified string, and returns the operation result. The operation fails if the text object was retrieved from a node that can not have a value and is not an element node (i.e. it is a node_declaration node), if the text object is empty, or if there is insufficient memory to handle the request. The provided string is copied into document managed memory and can be destroyed after the function returns (for example, you can safely pass stack-allocated buffers to this function). Note that if the text object was retrieved from an element node, this function creates the PCDATA child node if necessary (i.e. if the element node does not have a PCDATA/CDATA child already).

-
-
-

In addition to a string function, several functions are provided for handling text with numbers and booleans as contents:

-
-
-
-
bool xml_text::set(int rhs);
-bool xml_text::set(unsigned int rhs);
-bool xml_text::set(long rhs);
-bool xml_text::set(unsigned long rhs);
-bool xml_text::set(double rhs);
-bool xml_text::set(float rhs);
-bool xml_text::set(bool rhs);
-bool xml_text::set(long long rhs);
-bool xml_text::set(unsigned long long rhs);
-
-
-
-

The above functions convert the argument to string and then call the base set function. These functions have the same semantics as similar xml_attribute functions. You can refer to documentation for the attribute functions for details.

-
-
-

For convenience, all set functions have the corresponding assignment operators:

-
-
-
-
xml_text& xml_text::operator=(const char_t* rhs);
-xml_text& xml_text::operator=(int rhs);
-xml_text& xml_text::operator=(unsigned int rhs);
-xml_text& xml_text::operator=(long rhs);
-xml_text& xml_text::operator=(unsigned long rhs);
-xml_text& xml_text::operator=(double rhs);
-xml_text& xml_text::operator=(float rhs);
-xml_text& xml_text::operator=(bool rhs);
-xml_text& xml_text::operator=(long long rhs);
-xml_text& xml_text::operator=(unsigned long long rhs);
-
-
-
-

These operators simply call the right set function and return the attribute they’re called on; the return value of set is ignored, so errors are ignored.

-
-
-

This is an example of using xml_text object to modify text contents (samples/text.cpp):

-
-
-
-
// change project version
-project.child("version").text() = 1.2;
-
-// add description element and set the contents
-// note that we do not have to explicitly add the node_pcdata child
-project.append_child("description").text().set("a test project");
-
-
-
-
-

6.5. Cloning nodes/attributes

-
-

-With the help of previously described functions, it is possible to create trees with any contents and structure, including cloning the existing data. However since this is an often needed operation, pugixml provides built-in node/attribute cloning facilities. Since nodes and attributes do not exist without a document tree, you can’t create a standalone copy - you have to immediately insert it somewhere in the tree. For this, you can use one of the following functions:

-
-
-
-
xml_attribute xml_node::append_copy(const xml_attribute& proto);
-xml_attribute xml_node::prepend_copy(const xml_attribute& proto);
-xml_attribute xml_node::insert_copy_after(const xml_attribute& proto, const xml_attribute& attr);
-xml_attribute xml_node::insert_copy_before(const xml_attribute& proto, const xml_attribute& attr);
-
-xml_node xml_node::append_copy(const xml_node& proto);
-xml_node xml_node::prepend_copy(const xml_node& proto);
-xml_node xml_node::insert_copy_after(const xml_node& proto, const xml_node& node);
-xml_node xml_node::insert_copy_before(const xml_node& proto, const xml_node& node);
-
-
-
-

These functions mirror the structure of append_child, prepend_child, insert_child_before and related functions - they take the handle to the prototype object, which is to be cloned, insert a new attribute/node at the appropriate place, and then copy the attribute data or the whole node subtree to the new object. The functions return the handle to the resulting duplicate object, or null handle on failure.

-
-
-

The attribute is copied along with the name and value; the node is copied along with its type, name and value; additionally attribute list and all children are recursively cloned, resulting in the deep subtree clone. The prototype object can be a part of the same document, or a part of any other document.

-
-
-

The failure conditions resemble those of append_child, insert_child_before and related functions, consult their documentation for more information. There are additional caveats specific to cloning functions:

-
-
-
    -
  • -

    Cloning null handles results in operation failure;

    -
  • -
  • -

    Node cloning starts with insertion of the node of the same type as that of the prototype; for this reason, cloning functions can not be directly used to clone entire documents, since node_document is not a valid insertion type. The example below provides a workaround.

    -
  • -
  • -

    It is possible to copy a subtree as a child of some node inside this subtree, i.e. node.append_copy(node.parent().parent());. This is a valid operation, and it results in a clone of the subtree in the state before cloning started, i.e. no infinite recursion takes place.

    -
  • -
-
-
-

This is an example with one possible implementation of include tags in XML (samples/include.cpp). It illustrates node cloning and usage of other document modification functions:

-
-
-
-
bool load_preprocess(pugi::xml_document& doc, const char* path);
-
-bool preprocess(pugi::xml_node node)
-{
-    for (pugi::xml_node child = node.first_child(); child; )
-    {
-        if (child.type() == pugi::node_pi && strcmp(child.name(), "include") == 0)
-        {
-            pugi::xml_node include = child;
-
-            // load new preprocessed document (note: ideally this should handle relative paths)
-            const char* path = include.value();
-
-            pugi::xml_document doc;
-            if (!load_preprocess(doc, path)) return false;
-
-            // insert the comment marker above include directive
-            node.insert_child_before(pugi::node_comment, include).set_value(path);
-
-            // copy the document above the include directive (this retains the original order!)
-            for (pugi::xml_node ic = doc.first_child(); ic; ic = ic.next_sibling())
-            {
-                node.insert_copy_before(ic, include);
-            }
-
-            // remove the include node and move to the next child
-            child = child.next_sibling();
-
-            node.remove_child(include);
-        }
-        else
-        {
-            if (!preprocess(child)) return false;
-
-            child = child.next_sibling();
-        }
-    }
-
-    return true;
-}
-
-bool load_preprocess(pugi::xml_document& doc, const char* path)
-{
-    pugi::xml_parse_result result = doc.load_file(path, pugi::parse_default | pugi::parse_pi); // for <?include?>
-
-    return result ? preprocess(doc) : false;
-}
-
-
-
-
-

6.6. Moving nodes

-
-

-Sometimes instead of cloning a node you need to move an existing node to a different position in a tree. This can be accomplished by copying the node and removing the original; however, this is expensive since it results in a lot of extra operations. For moving nodes within the same document tree, you can use of the following functions instead:

-
-
-
-
xml_node xml_node::append_move(const xml_node& moved);
-xml_node xml_node::prepend_move(const xml_node& moved);
-xml_node xml_node::insert_move_after(const xml_node& moved, const xml_node& node);
-xml_node xml_node::insert_move_before(const xml_node& moved, const xml_node& node);
-
-
-
-

These functions mirror the structure of append_copy, prepend_copy, insert_copy_before and insert_copy_after - they take the handle to the moved object and move it to the appropriate place with all attributes and/or child nodes. The functions return the handle to the resulting object (which is the same as the moved object), or null handle on failure.

-
-
-

The failure conditions resemble those of append_child, insert_child_before and related functions, consult their documentation for more information. There are additional caveats specific to moving functions:

-
-
-
    -
  • -

    Moving null handles results in operation failure;

    -
  • -
  • -

    Moving is only possible for nodes that belong to the same document; attempting to move nodes between documents will fail.

    -
  • -
  • -

    insert_move_after and insert_move_before functions fail if the moved node is the same as the node argument (this operation would be a no-op otherwise).

    -
  • -
  • -

    It is impossible to move a subtree to a child of some node inside this subtree, i.e. node.append_move(node.parent().parent()); will fail.

    -
  • -
-
-
-
-

6.7. Assembling document from fragments

-
-

pugixml provides several ways to assemble an XML document from other XML documents. Assuming there is a set of document fragments, represented as in-memory buffers, the implementation choices are as follows:

-
-
-
    -
  • -

    Use a temporary document to parse the data from a string, then clone the nodes to a destination node. For example:

    -
    -
    -
    bool append_fragment(pugi::xml_node target, const char* buffer, size_t size)
    -{
    -    pugi::xml_document doc;
    -    if (!doc.load_buffer(buffer, size)) return false;
    -
    -    for (pugi::xml_node child = doc.first_child(); child; child = child.next_sibling())
    -        target.append_copy(child);
    -}
    -
    -
    -
  • -
  • -

    Cache the parsing step - instead of keeping in-memory buffers, keep document objects that already contain the parsed fragment:

    -
    -
    -
    bool append_fragment(pugi::xml_node target, const pugi::xml_document& cached_fragment)
    -{
    -    for (pugi::xml_node child = cached_fragment.first_child(); child; child = child.next_sibling())
    -        target.append_copy(child);
    -}
    -
    -
    -
  • -
  • -

    Use xml_node::append_buffer directly:

    -
    -
    -
    xml_parse_result xml_node::append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
    -
    -
    -
  • -
-
-
-

The first method is more convenient, but slower than the other two. The relative performance of append_copy and append_buffer depends on the buffer format - usually append_buffer is faster if the buffer is in native encoding (UTF-8 or wchar_t, depending on PUGIXML_WCHAR_MODE). At the same time it might be less efficient in terms of memory usage - the implementation makes a copy of the provided buffer, and the copy has the same lifetime as the document - the memory used by that copy will be reclaimed after the document is destroyed, but no sooner. Even deleting all nodes in the document, including the appended ones, won’t reclaim the memory.

-
-
-

append_buffer behaves in the same way as xml_document::load_buffer - the input buffer is a byte buffer, with size in bytes; the buffer is not modified and can be freed after the function returns.

-
-
-

Since append_buffer needs to append child nodes to the current node, it only works if the current node is either document or element node. Calling append_buffer on a node with any other type results in an error with status_append_invalid_root status.

-
-
-
-
-
-

7. Saving document

-
-
-

Often after creating a new document or loading the existing one and processing it, it is necessary to save the result back to file. Also it is occasionally useful to output the whole document or a subtree to some stream; use cases include debug printing, serialization via network or other text-oriented medium, etc. pugixml provides several functions to output any subtree of the document to a file, stream or another generic transport interface; these functions allow to customize the output format (see Output options), and also perform necessary encoding conversions (see Encodings). This section documents the relevant functionality.

-
-
-

Before writing to the destination the node/attribute data is properly formatted according to the node type; all special XML symbols, such as < and &, are properly escaped (unless format_no_escapes flag is set). In order to guard against forgotten node/attribute names, empty node/attribute names are printed as ":anonymous". For well-formed output, make sure all node and attribute names are set to meaningful values.

-
-
-

CDATA sections with values that contain "]]>" are split into several sections as follows: section with value "pre]]>post" is written as <![CDATA[pre]]]]><![CDATA[>post]]>. While this alters the structure of the document (if you load the document after saving it, there will be two CDATA sections instead of one), this is the only way to escape CDATA contents.

-
-
-

7.1. Saving document to a file

-
-

-If you want to save the whole document to a file, you can use one of the following functions:

-
-
-
-
bool xml_document::save_file(const char* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
-bool xml_document::save_file(const wchar_t* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
-
-
-
-

These functions accept file path as its first argument, and also three optional arguments, which specify indentation and other output options (see Output options) and output data encoding (see Encodings). The path has the target operating system format, so it can be a relative or absolute one, it should have the delimiters of the target system, it should have the exact case if the target file system is case-sensitive, etc.

-
-
-

File path is passed to the system file opening function as is in case of the first function (which accepts const char* path); the second function either uses a special file opening function if it is provided by the runtime library or converts the path to UTF-8 and uses the system file opening function.

-
-
-

save_file opens the target file for writing, outputs the requested header (by default a document declaration is output, unless the document already has one), and then saves the document contents. If the file could not be opened, the function returns false. Calling save_file is equivalent to creating an xml_writer_file object with FILE* handle as the only constructor argument and then calling save; see Saving document via writer interface for writer interface details.

-
-
-

This is a simple example of saving XML document to file (samples/save_file.cpp):

-
-
-
-
// save document to file
-std::cout << "Saving result: " << doc.save_file("save_file_output.xml") << std::endl;
-
-
-
-
-

7.2. Saving document to C++ IOstreams

-
-

To enhance interoperability pugixml provides functions for saving document to any object which implements C++ std::ostream interface. This allows you to save documents to any standard C++ stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). Most notably, this allows for easy debug output, since you can use std::cout stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones:

-
-
-
-
void xml_document::save(std::ostream& stream, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
-void xml_document::save(std::wostream& stream, const char_t* indent = "\t", unsigned int flags = format_default) const;
-
-
-
-

save with std::ostream argument saves the document to the stream in the same way as save_file (i.e. with requested header and with encoding conversions). On the other hand, save with std::wstream argument saves the document to the wide stream with encoding_wchar encoding. Because of this, using save with wide character streams requires careful (usually platform-specific) stream setup (i.e. using the imbue function). Generally use of wide streams is discouraged, however it provides you with the ability to save documents to non-Unicode encodings, i.e. you can save Shift-JIS encoded data if you set the correct locale.

-
-
-

Calling save with stream target is equivalent to creating an xml_writer_stream object with stream as the only constructor argument and then calling save; see Saving document via writer interface for writer interface details.

-
-
-

This is a simple example of saving XML document to standard output (samples/save_stream.cpp):

-
-
-
-
// save document to standard output
-std::cout << "Document:\n";
-doc.save(std::cout);
-
-
-
-
-

7.3. Saving document via writer interface

-
-

-All of the above saving functions are implemented in terms of writer interface. This is a simple interface with a single function, which is called several times during output process with chunks of document data as input:

-
-
-
-
class xml_writer
-{
-public:
-    virtual void write(const void* data, size_t size) = 0;
-};
-
-void xml_document::save(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
-
-
-
-

In order to output the document via some custom transport, for example sockets, you should create an object which implements xml_writer interface and pass it to save function. xml_writer::write function is called with a buffer as an input, where data points to buffer start, and size is equal to the buffer size in bytes. write implementation must write the buffer to the transport; it can not save the passed buffer pointer, as the buffer contents will change after write returns. The buffer contains the chunk of document data in the desired encoding.

-
-
-

write function is called with relatively large blocks (size is usually several kilobytes, except for the last block that may be small), so there is often no need for additional buffering in the implementation.

-
-
-

This is a simple example of custom writer for saving document data to STL string (samples/save_custom_writer.cpp); read the sample code for more complex examples:

-
-
-
-
struct xml_string_writer: pugi::xml_writer
-{
-    std::string result;
-
-    virtual void write(const void* data, size_t size)
-    {
-        result.append(static_cast<const char*>(data), size);
-    }
-};
-
-
-
-
-

7.4. Saving a single subtree

-
-

-While the previously described functions save the whole document to the destination, it is easy to save a single subtree. The following functions are provided:

-
-
-
-
void xml_node::print(std::ostream& os, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
-void xml_node::print(std::wostream& os, const char_t* indent = "\t", unsigned int flags = format_default, unsigned int depth = 0) const;
-void xml_node::print(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
-
-
-
-

These functions have the same arguments with the same meaning as the corresponding xml_document::save functions, and allow you to save the subtree to either a C++ IOstream or to any object that implements xml_writer interface.

-
-
-

Saving a subtree differs from saving the whole document: the process behaves as if format_write_bom is off, and format_no_declaration is on, even if actual values of the flags are different. This means that BOM is not written to the destination, and document declaration is only written if it is the node itself or is one of node’s children. Note that this also holds if you’re saving a document; this example (samples/save_subtree.cpp) illustrates the difference:

-
-
-
-
// get a test document
-pugi::xml_document doc;
-doc.load_string("<foo bar='baz'><call>hey</call></foo>");
-
-// print document to standard output (prints <?xml version="1.0"?><foo bar="baz"><call>hey</call></foo>)
-doc.save(std::cout, "", pugi::format_raw);
-std::cout << std::endl;
-
-// print document to standard output as a regular node (prints <foo bar="baz"><call>hey</call></foo>)
-doc.print(std::cout, "", pugi::format_raw);
-std::cout << std::endl;
-
-// print a subtree to standard output (prints <call>hey</call>)
-doc.child("foo").child("call").print(std::cout, "", pugi::format_raw);
-std::cout << std::endl;
-
-
-
-
-

7.5. Output options

-
-

All saving functions accept the optional parameter flags. This is a bitmask that customizes the output format; you can select the way the document nodes are printed and select the needed additional information that is output before the document contents.

-
-
- - - - - -
-
Note
-
-You should use the usual bitwise arithmetics to manipulate the bitmask: to enable a flag, use mask | flag; to disable a flag, use mask & ~flag. -
-
-
-

These flags control the resulting tree contents:

-
-
-
    -
  • -

    format_indent determines if all nodes should be indented with the indentation string (this is an additional parameter for all saving functions, and is "\t" by default). If this flag is on, the indentation string is printed several times before every node, where the amount of indentation depends on the node’s depth relative to the output subtree. This flag has no effect if format_raw is enabled. This flag is on by default.

    -
  • -
  • -

    format_indent_attributes determines if all attributes should be printed on a new line, indented with the indentation string according to the attribute’s depth. This flag implies format_indent. This flag has no effect if format_raw is enabled. This flag is off by default.

    -
  • -
  • -

    format_raw switches between formatted and raw output. If this flag is on, the nodes are not indented in any way, and also no newlines that are not part of document text are printed. Raw mode can be used for serialization where the result is not intended to be read by humans; also it can be useful if the document was parsed with parse_ws_pcdata flag, to preserve the original document formatting as much as possible. This flag is off by default.

    -
  • -
  • -

    format_no_escapes disables output escaping for attribute values and PCDATA contents. If this flag is off, special symbols (", &, <, >) and all non-printable characters (those with codepoint values less than 32) are converted to XML escape sequences (i.e. &amp;) during output. If this flag is on, no text processing is performed; therefore, output XML can be malformed if output contents contains invalid symbols (i.e. having a stray < in the PCDATA will make the output malformed). This flag is off by default.

    -
  • -
  • -

    format_no_empty_element_tags determines if start/end tags should be output instead of empty element tags for empty elements (that is, elements with no children). This flag is off by default.

    -
  • -
  • -

    format_skip_control_chars enables skipping characters belonging to range [0; 32) instead of "&#xNN;" encoding. This flag is off by default.

    -
  • -
  • -

    format_attribute_single_quote enables using single quotes ' instead of double quotes " for enclosing attribute values. This flag is off by default.

    -
  • -
-
-
-

These flags control the additional output information:

-
-
-
    -
  • -

    format_no_declaration disables default node declaration output. By default, if the document is saved via save or save_file function, and it does not have any document declaration, a default declaration is output before the document contents. Enabling this flag disables this declaration. This flag has no effect in xml_node::print functions: they never output the default declaration. This flag is off by default.

    -
  • -
  • -

    format_write_bom enables Byte Order Mark (BOM) output. By default, no BOM is output, so in case of non UTF-8 encodings the resulting document’s encoding may not be recognized by some parsers and text editors, if they do not implement sophisticated encoding detection. Enabling this flag adds an encoding-specific BOM to the output. This flag has no effect in xml_node::print functions: they never output the BOM. This flag is off by default.

    -
  • -
  • -

    format_save_file_text changes the file mode when using save_file function. By default, file is opened in binary mode, which means that the output file will -contain platform-independent newline \n (ASCII 10). If this flag is on, file is opened in text mode, which on some systems changes the newline format (i.e. on Windows you can use this flag to output XML documents with \r\n (ASCII 13 10) newlines. This flag is off by default.

    -
  • -
-
-
-

Additionally, there is one predefined option mask:

-
-
-
    -
  • -

    format_default is the default set of flags, i.e. it has all options set to their default values. It sets formatted output with indentation, without BOM and with default node declaration, if necessary.

    -
  • -
-
-
-

This is an example that shows the outputs of different output options (samples/save_options.cpp):

-
-
-
-
// get a test document
-pugi::xml_document doc;
-doc.load_string("<foo bar='baz'><call>hey</call></foo>");
-
-// default options; prints
-// <?xml version="1.0"?>
-// <foo bar="baz">
-//         <call>hey</call>
-// </foo>
-doc.save(std::cout);
-std::cout << std::endl;
-
-// default options with custom indentation string; prints
-// <?xml version="1.0"?>
-// <foo bar="baz">
-// --<call>hey</call>
-// </foo>
-doc.save(std::cout, "--");
-std::cout << std::endl;
-
-// default options without indentation; prints
-// <?xml version="1.0"?>
-// <foo bar="baz">
-// <call>hey</call>
-// </foo>
-doc.save(std::cout, "\t", pugi::format_default & ~pugi::format_indent); // can also pass "" instead of indentation string for the same effect
-std::cout << std::endl;
-
-// raw output; prints
-// <?xml version="1.0"?><foo bar="baz"><call>hey</call></foo>
-doc.save(std::cout, "\t", pugi::format_raw);
-std::cout << std::endl << std::endl;
-
-// raw output without declaration; prints
-// <foo bar="baz"><call>hey</call></foo>
-doc.save(std::cout, "\t", pugi::format_raw | pugi::format_no_declaration);
-std::cout << std::endl;
-
-
-
-
-

7.6. Encodings

-
-

pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it’s a strict subset of UTF-16) and handles all encoding conversions during output. The output encoding is set via the encoding parameter of saving functions, which is of type xml_encoding. The possible values for the encoding are documented in Encodings; the only flag that has a different meaning is encoding_auto.

-
-
-

While all other flags set the exact encoding, encoding_auto is meant for automatic encoding detection. The automatic detection does not make sense for output encoding, since there is usually nothing to infer the actual encoding from, so here encoding_auto means UTF-8 encoding, which is the most popular encoding for XML data storage. This is also the default value of output encoding; specify another value if you do not want UTF-8 encoded output.

-
-
-

Also note that wide stream saving functions do not have encoding argument and always assume encoding_wchar encoding.

-
-
- - - - - -
-
Note
-
-The current behavior for Unicode conversion is to skip all invalid UTF sequences during conversion. This behavior should not be relied upon; if your node/attribute names do not contain any valid UTF sequences, they may be output as if they are empty, which will result in malformed XML document. -
-
-
-
-

7.7. Customizing document declaration

-
-

When you are saving the document using xml_document::save() or xml_document::save_file(), a default XML document declaration is output, if format_no_declaration is not specified and if the document does not have a declaration node. However, the default declaration is not customizable. If you want to customize the declaration output, you need to create the declaration node yourself.

-
-
- - - - - -
-
Note
-
-By default the declaration node is not added to the document during parsing. If you just need to preserve the original declaration node, you have to add the flag parse_declaration to the parsing flags; the resulting document will contain the original declaration node, which will be output during saving. -
-
-
-

Declaration node is a node with type node_declaration; it behaves like an element node in that it has attributes with values (but it does not have child nodes). Therefore setting custom version, encoding or standalone declaration involves adding attributes and setting attribute values.

-
-
-

This is an example that shows how to create a custom declaration node (samples/save_declaration.cpp):

-
-
-
-
// get a test document
-pugi::xml_document doc;
-doc.load_string("<foo bar='baz'><call>hey</call></foo>");
-
-// add a custom declaration node
-pugi::xml_node decl = doc.prepend_child(pugi::node_declaration);
-decl.append_attribute("version") = "1.0";
-decl.append_attribute("encoding") = "UTF-8";
-decl.append_attribute("standalone") = "no";
-
-// <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-// <foo bar="baz">
-//         <call>hey</call>
-// </foo>
-doc.save(std::cout);
-std::cout << std::endl;
-
-
-
-
-
-
-

8. XPath

-
-
-

If the task at hand is to select a subset of document nodes that match some criteria, it is possible to code a function using the existing traversal functionality for any practical criteria. However, often either a data-driven approach is desirable, in case the criteria are not predefined and come from a file, or it is inconvenient to use traversal interfaces and a higher-level DSL is required. There is a standard language for XML processing, XPath, that can be useful for these cases. pugixml implements an almost complete subset of XPath 1.0. Because of differences in document object model and some performance implications, there are minor violations of the official specifications, which can be found in Conformance to W3C specification. The rest of this section describes the interface for XPath functionality. Please note that if you wish to learn to use XPath language, you have to look for other tutorials or manuals; for example, you can read W3Schools XPath tutorial, XPath tutorial at tizag.com, and the XPath 1.0 specification.

-
-
-

8.1. XPath types

-
-

-Each XPath expression can have one of the following types: boolean, number, string or node set. Boolean type corresponds to bool type, number type corresponds to double type, string type corresponds to either std::string or std::wstring, depending on whether wide character interface is enabled, and node set corresponds to xpath_node_set type. There is an enumeration, xpath_value_type, which can take the values xpath_type_boolean, xpath_type_number, xpath_type_string or xpath_type_node_set, accordingly.

-
-
-

-Because an XPath node can be either a node or an attribute, there is a special type, xpath_node, which is a discriminated union of these types. A value of this type contains two node handles, one of xml_node type, and another one of xml_attribute type; at most one of them can be non-null. The accessors to get these handles are available:

-
-
-
-
xml_node xpath_node::node() const;
-xml_attribute xpath_node::attribute() const;
-
-
-
-

XPath nodes can be null, in which case both accessors return null handles.

-
-
-

Note that as per XPath specification, each XPath node has a parent, which can be retrieved via this function:

-
-
-
-
xml_node xpath_node::parent() const;
-
-
-
-

parent function returns the node’s parent if the XPath node corresponds to xml_node handle (equivalent to node().parent()), or the node to which the attribute belongs to, if the XPath node corresponds to xml_attribute handle. For null nodes, parent returns null handle.

-
-
-

-Like node and attribute handles, XPath node handles can be implicitly cast to boolean-like object to check if it is a null node, and also can be compared for equality with each other.

-
-
-

You can also create XPath nodes with one of the three constructors: the default constructor, the constructor that takes node argument, and the constructor that takes attribute and node arguments (in which case the attribute must belong to the attribute list of the node). The constructor from xml_node is implicit, so you can usually pass xml_node to functions that expect xpath_node. Apart from that you usually don’t need to create your own XPath node objects, since they are returned to you via selection functions.

-
-
-

XPath expressions operate not on single nodes, but instead on node sets. A node set is a collection of nodes, which can be optionally ordered in either a forward document order or a reverse one. Document order is defined in XPath specification; an XPath node is before another node in document order if it appears before it in XML representation of the corresponding document.

-
-
-

-Node sets are represented by xpath_node_set object, which has an interface that resembles one of sequential random-access containers. It has an iterator type along with usual begin/past-the-end iterator accessors:

-
-
-
-
typedef const xpath_node* xpath_node_set::const_iterator;
-const_iterator xpath_node_set::begin() const;
-const_iterator xpath_node_set::end() const;
-
-
-
-

-And it also can be iterated via indices, just like std::vector:

-
-
-
-
const xpath_node& xpath_node_set::operator[](size_t index) const;
-size_t xpath_node_set::size() const;
-bool xpath_node_set::empty() const;
-
-
-
-

All of the above operations have the same semantics as that of std::vector: the iterators are random-access, all of the above operations are constant time, and accessing the element at index that is greater or equal than the set size results in undefined behavior. You can use both iterator-based and index-based access for iteration, however the iterator-based one can be faster.

-
-
-

-The order of iteration depends on the order of nodes inside the set; the order can be queried via the following function:

-
-
-
-
enum xpath_node_set::type_t {type_unsorted, type_sorted, type_sorted_reverse};
-type_t xpath_node_set::type() const;
-
-
-
-

type function returns the current order of nodes; type_sorted means that the nodes are in forward document order, type_sorted_reverse means that the nodes are in reverse document order, and type_unsorted means that neither order is guaranteed (nodes can accidentally be in a sorted order even if type() returns type_unsorted). If you require a specific order of iteration, you can change it via sort function:

-
-
-
-
void xpath_node_set::sort(bool reverse = false);
-
-
-
-

Calling sort sorts the nodes in either forward or reverse document order, depending on the argument; after this call type() will return type_sorted or type_sorted_reverse.

-
-
-

Often the actual iteration is not needed; instead, only the first element in document order is required. For this, a special accessor is provided:

-
-
-
-
xpath_node xpath_node_set::first() const;
-
-
-
-

This function returns the first node in forward document order from the set, or null node if the set is empty. Note that while the result of the node does not depend on the order of nodes in the set (i.e. on the result of type()), the complexity does - if the set is sorted, the complexity is constant, otherwise it is linear in the number of elements or worse.

-
-
-

While in the majority of cases the node set is returned by XPath functions, sometimes there is a need to manually construct a node set. For such cases, a constructor is provided which takes an iterator range (const_iterator is a typedef for const xpath_node*), and an optional type:

-
-
-
-
xpath_node_set::xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted);
-
-
-
-

The constructor copies the specified range and sets the specified type. The objects in the range are not checked in any way; you’ll have to ensure that the range contains no duplicates, and that the objects are sorted according to the type parameter. Otherwise XPath operations with this set may produce unexpected results.

-
-
-
-

8.2. Selecting nodes via XPath expression

-
-

-If you want to select nodes that match some XPath expression, you can do it with the following functions:

-
-
-
-
xpath_node xml_node::select_node(const char_t* query, xpath_variable_set* variables = 0) const;
-xpath_node_set xml_node::select_nodes(const char_t* query, xpath_variable_set* variables = 0) const;
-
-
-
-

select_nodes function compiles the expression and then executes it with the node as a context node, and returns the resulting node set. select_node returns only the first node in document order from the result, and is equivalent to calling select_nodes(query).first(). If the XPath expression does not match anything, or the node handle is null, select_nodes returns an empty set, and select_node returns null XPath node.

-
-
-

If exception handling is not disabled, both functions throw xpath_exception if the query can not be compiled or if it returns a value with type other than node set; see Error handling for details.

-
-
-

-While compiling expressions is fast, the compilation time can introduce a significant overhead if the same expression is used many times on small subtrees. If you’re doing many similar queries, consider compiling them into query objects (see Using query objects for further reference). Once you get a compiled query object, you can pass it to select functions instead of an expression string:

-
-
-
-
xpath_node xml_node::select_node(const xpath_query& query) const;
-xpath_node_set xml_node::select_nodes(const xpath_query& query) const;
-
-
-
-

If exception handling is not disabled, both functions throw xpath_exception if the query returns a value with type other than node set.

-
-
-

This is an example of selecting nodes using XPath expressions (samples/xpath_select.cpp):

-
-
-
-
pugi::xpath_node_set tools = doc.select_nodes("/Profile/Tools/Tool[@AllowRemote='true' and @DeriveCaptionFrom='lastparam']");
-
-std::cout << "Tools:\n";
-
-for (pugi::xpath_node_set::const_iterator it = tools.begin(); it != tools.end(); ++it)
-{
-    pugi::xpath_node node = *it;
-    std::cout << node.node().attribute("Filename").value() << "\n";
-}
-
-pugi::xpath_node build_tool = doc.select_node("//Tool[contains(Description, 'build system')]");
-
-if (build_tool)
-    std::cout << "Build tool: " << build_tool.node().attribute("Filename").value() << "\n";
-
-
-
-
-

8.3. Using query objects

-
-

When you call select_nodes with an expression string as an argument, a query object is created behind the scenes. A query object represents a compiled XPath expression. Query objects can be needed in the following circumstances:

-
-
-
    -
  • -

    You can precompile expressions to query objects to save compilation time if it becomes an issue;

    -
  • -
  • -

    You can use query objects to evaluate XPath expressions which result in booleans, numbers or strings;

    -
  • -
  • -

    You can get the type of expression value via query object.

    -
  • -
-
-
-

Query objects correspond to xpath_query type. They are immutable and non-copyable: they are bound to the expression at creation time and can not be cloned. If you want to put query objects in a container, either allocate them on heap via new operator and store pointers to xpath_query in the container, or use a C11 compiler (query objects are movable in C11).

-
-
-

You can create a query object with the constructor that takes XPath expression as an argument:

-
-
-
-
explicit xpath_query::xpath_query(const char_t* query, xpath_variable_set* variables = 0);
-
-
-
-

The expression is compiled and the compiled representation is stored in the new query object. If compilation fails, xpath_exception is thrown if exception handling is not disabled (see Error handling for details). After the query is created, you can query the type of the evaluation result using the following function:

-
-
-
-
xpath_value_type xpath_query::return_type() const;
-
-
-
-

-You can evaluate the query using one of the following functions:

-
-
-
-
bool xpath_query::evaluate_boolean(const xpath_node& n) const;
-double xpath_query::evaluate_number(const xpath_node& n) const;
-string_t xpath_query::evaluate_string(const xpath_node& n) const;
-xpath_node_set xpath_query::evaluate_node_set(const xpath_node& n) const;
-xpath_node xpath_query::evaluate_node(const xpath_node& n) const;
-
-
-
-

All functions take the context node as an argument, compute the expression and return the result, converted to the requested type. According to XPath specification, value of any type can be converted to boolean, number or string value, but no type other than node set can be converted to node set. Because of this, evaluate_boolean, evaluate_number and evaluate_string always return a result, but evaluate_node_set and evaluate_node result in an error if the return type is not node set (see Error handling).

-
-
- - - - - -
-
Note
-
-Calling node.select_nodes("query") is equivalent to calling xpath_query("query").evaluate_node_set(node). Calling node.select_node("query") is equivalent to calling xpath_query("query").evaluate_node(node). -
-
-
-

Note that evaluate_string function returns the STL string; as such, it’s not available in PUGIXML_NO_STL mode and also usually allocates memory. There is another string evaluation function:

-
-
-
-
size_t xpath_query::evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const;
-
-
-
-

This function evaluates the string, and then writes the result to buffer (but at most capacity characters); then it returns the full size of the result in characters, including the terminating zero. If capacity is not 0, the resulting buffer is always zero-terminated. You can use this function as follows:

-
-
-
    -
  • -

    First call the function with buffer = 0 and capacity = 0; then allocate the returned amount of characters, and call the function again, passing the allocated storage and the amount of characters;

    -
  • -
  • -

    First call the function with small buffer and buffer capacity; then, if the result is larger than the capacity, the output has been trimmed, so allocate a larger buffer and call the function again.

    -
  • -
-
-
-

This is an example of using query objects (samples/xpath_query.cpp):

-
-
-
-
// Select nodes via compiled query
-pugi::xpath_query query_remote_tools("/Profile/Tools/Tool[@AllowRemote='true']");
-
-pugi::xpath_node_set tools = query_remote_tools.evaluate_node_set(doc);
-std::cout << "Remote tool: ";
-tools[2].node().print(std::cout);
-
-// Evaluate numbers via compiled query
-pugi::xpath_query query_timeouts("sum(//Tool/@Timeout)");
-std::cout << query_timeouts.evaluate_number(doc) << std::endl;
-
-// Evaluate strings via compiled query for different context nodes
-pugi::xpath_query query_name_valid("string-length(substring-before(@Filename, '_')) > 0 and @OutputFileMasks");
-pugi::xpath_query query_name("concat(substring-before(@Filename, '_'), ' produces ', @OutputFileMasks)");
-
-for (pugi::xml_node tool = doc.first_element_by_path("Profile/Tools/Tool"); tool; tool = tool.next_sibling())
-{
-    std::string s = query_name.evaluate_string(tool);
-
-    if (query_name_valid.evaluate_boolean(tool)) std::cout << s << std::endl;
-}
-
-
-
-
-

8.4. Using variables

-
-

XPath queries may contain references to variables; this is useful if you want to use queries that depend on some dynamic parameter without manually preparing the complete query string, or if you want to reuse the same query object for similar queries.

-
-
-

Variable references have the form $name; in order to use them, you have to provide a variable set, which includes all variables present in the query with correct types. This set is passed to xpath_query constructor or to select_nodes/select_node functions:

-
-
-
-
explicit xpath_query::xpath_query(const char_t* query, xpath_variable_set* variables = 0);
-xpath_node xml_node::select_node(const char_t* query, xpath_variable_set* variables = 0) const;
-xpath_node_set xml_node::select_nodes(const char_t* query, xpath_variable_set* variables = 0) const;
-
-
-
-

If you’re using query objects, you can change the variable values before evaluate/select calls to change the query behavior.

-
-
- - - - - -
-
Note
-
-The variable set pointer is stored in the query object; you have to ensure that the lifetime of the set exceeds that of query object. -
-
-
-

Variable sets correspond to xpath_variable_set type, which is essentially a variable container.

-
-
-

You can add new variables with the following function:

-
-
-
-
xpath_variable* xpath_variable_set::add(const char_t* name, xpath_value_type type);
-
-
-
-

The function tries to add a new variable with the specified name and type; if the variable with such name does not exist in the set, the function adds a new variable and returns the variable handle; if there is already a variable with the specified name, the function returns the variable handle if variable has the specified type. Otherwise the function returns null pointer; it also returns null pointer on allocation failure.

-
-
-

New variables are assigned the default value which depends on the type: 0 for numbers, false for booleans, empty string for strings and empty set for node sets.

-
-
-

You can get the existing variables with the following functions:

-
-
-
-
xpath_variable* xpath_variable_set::get(const char_t* name);
-const xpath_variable* xpath_variable_set::get(const char_t* name) const;
-
-
-
-

The functions return the variable handle, or null pointer if the variable with the specified name is not found.

-
-
-

Additionally, there are the helper functions for setting the variable value by name; they try to add the variable with the corresponding type, if it does not exist, and to set the value. If the variable with the same name but with different type is already present, they return false; they also return false on allocation failure. Note that these functions do not perform any type conversions.

-
-
-
-
bool xpath_variable_set::set(const char_t* name, bool value);
-bool xpath_variable_set::set(const char_t* name, double value);
-bool xpath_variable_set::set(const char_t* name, const char_t* value);
-bool xpath_variable_set::set(const char_t* name, const xpath_node_set& value);
-
-
-
-

The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return.

-
-
-

If setting variables by name is not efficient enough, or if you have to inspect variable information or get variable values, you can use variable handles. A variable corresponds to the xpath_variable type, and a variable handle is simply a pointer to xpath_variable.

-
-
-

-In order to get variable information, you can use one of the following functions:

-
-
-
-
const char_t* xpath_variable::name() const;
-xpath_value_type xpath_variable::type() const;
-
-
-
-

Note that each variable has a distinct type which is specified upon variable creation and can not be changed later.

-
-
-

-In order to get variable value, you should use one of the following functions, depending on the variable type:

-
-
-
-
bool xpath_variable::get_boolean() const;
-double xpath_variable::get_number() const;
-const char_t* xpath_variable::get_string() const;
-const xpath_node_set& xpath_variable::get_node_set() const;
-
-
-
-

These functions return the value of the variable. Note that no type conversions are performed; if the type mismatch occurs, a dummy value is returned (false for booleans, NaN for numbers, empty string for strings and empty set for node sets).

-
-
-

In order to set variable value, you should use one of the following functions, depending on the variable type:

-
-
-
-
bool xpath_variable::set(bool value);
-bool xpath_variable::set(double value);
-bool xpath_variable::set(const char_t* value);
-bool xpath_variable::set(const xpath_node_set& value);
-
-
-
-

These functions modify the variable value. Note that no type conversions are performed; if the type mismatch occurs, the functions return false; they also return false on allocation failure. The variable values are copied to the internal variable storage, so you can modify or destroy them after the functions return.

-
-
-

This is an example of using variables in XPath queries (samples/xpath_variables.cpp):

-
-
-
-
// Select nodes via compiled query
-pugi::xpath_variable_set vars;
-vars.add("remote", pugi::xpath_type_boolean);
-
-pugi::xpath_query query_remote_tools("/Profile/Tools/Tool[@AllowRemote = string($remote)]", &vars);
-
-vars.set("remote", true);
-pugi::xpath_node_set tools_remote = query_remote_tools.evaluate_node_set(doc);
-
-vars.set("remote", false);
-pugi::xpath_node_set tools_local = query_remote_tools.evaluate_node_set(doc);
-
-std::cout << "Remote tool: ";
-tools_remote[2].node().print(std::cout);
-
-std::cout << "Local tool: ";
-tools_local[0].node().print(std::cout);
-
-// You can pass the context directly to select_nodes/select_node
-pugi::xpath_node_set tools_local_imm = doc.select_nodes("/Profile/Tools/Tool[@AllowRemote = string($remote)]", &vars);
-
-std::cout << "Local tool imm: ";
-tools_local_imm[0].node().print(std::cout);
-
-
-
-
-

8.5. Error handling

-
-

There are two different mechanisms for error handling in XPath implementation; the mechanism used depends on whether exception support is disabled (this is controlled with PUGIXML_NO_EXCEPTIONS define).

-
-
-

-By default, XPath functions throw xpath_exception object in case of errors; additionally, in the event any memory allocation fails, an std::bad_alloc exception is thrown. Also xpath_exception is thrown if the query is evaluated to a node set, but the return type is not node set. If the query constructor succeeds (i.e. no exception is thrown), the query object is valid. Otherwise you can get the error details via one of the following functions:

-
-
-
-
virtual const char* xpath_exception::what() const throw();
-const xpath_parse_result& xpath_exception::result() const;
-
-
-
-

-If exceptions are disabled, then in the event of parsing failure the query is initialized to invalid state; you can test if the query object is valid by using it in a boolean expression: if (query) { …​ }. Additionally, you can get parsing result via the result() accessor:

-
-
-
-
const xpath_parse_result& xpath_query::result() const;
-
-
-
-

Without exceptions, evaluating invalid query results in false, empty string, NaN or an empty node set, depending on the type; evaluating a query as a node set results in an empty node set if the return type is not node set.

-
-
-

The information about parsing result is returned via xpath_parse_result object. It contains parsing status and the offset of last successfully parsed character from the beginning of the source stream:

-
-
-
-
struct xpath_parse_result
-{
-    const char* error;
-    ptrdiff_t offset;
-
-    operator bool() const;
-    const char* description() const;
-};
-
-
-
-

Parsing result is represented as the error message; it is either a null pointer, in case there is no error, or the error message in the form of ASCII zero-terminated string.

-
-
-

description() member function can be used to get the error message; it never returns the null pointer, so you can safely use description() even if query parsing succeeded. Note that description() returns a char string even in PUGIXML_WCHAR_MODE; you’ll have to call as_wide to get the wchar_t string.

-
-
-

In addition to the error message, parsing result has an offset member, which contains the offset of last successfully parsed character. This offset is in units of pugi::char_t (bytes for character mode, wide characters for wide character mode).

-
-
-

Parsing result object can be implicitly converted to bool like this: if (result) { …​ } else { …​ }.

-
-
-

This is an example of XPath error handling (samples/xpath_error.cpp):

-
-
-
-
// Exception is thrown for incorrect query syntax
-try
-{
-    doc.select_nodes("//nodes[#true()]");
-}
-catch (const pugi::xpath_exception& e)
-{
-    std::cout << "Select failed: " << e.what() << std::endl;
-}
-
-// Exception is thrown for incorrect query semantics
-try
-{
-    doc.select_nodes("(123)/next");
-}
-catch (const pugi::xpath_exception& e)
-{
-    std::cout << "Select failed: " << e.what() << std::endl;
-}
-
-// Exception is thrown for query with incorrect return type
-try
-{
-    doc.select_nodes("123");
-}
-catch (const pugi::xpath_exception& e)
-{
-    std::cout << "Select failed: " << e.what() << std::endl;
-}
-
-
-
-
-

8.6. Conformance to W3C specification

-
-

Because of the differences in document object models, performance considerations and implementation complexity, pugixml does not provide a fully conformant XPath 1.0 implementation. This is the current list of incompatibilities:

-
-
-
    -
  • -

    Consecutive text nodes sharing the same parent are not merged, i.e. in <node>text1 <![CDATA[data]]> text2</node> node should have one text node child, but instead has three.

    -
  • -
  • -

    Since the document type declaration is not used for parsing, id() function always returns an empty node set.

    -
  • -
  • -

    Namespace nodes are not supported (affects namespace:: axis).

    -
  • -
  • -

    Name tests are performed on QNames in XML document instead of expanded names; for <foo xmlns:ns1='uri' xmlns:ns2='uri'><ns1:child/><ns2:child/></foo>, query foo/ns1:* will return only the first child, not both of them. Compliant XPath implementations can return both nodes if the user provides appropriate namespace declarations.

    -
  • -
  • -

    String functions consider a character to be either a single char value or a single wchar_t value, depending on the library configuration; this means that some string functions are not fully Unicode-aware. This affects substring(), string-length() and translate() functions.

    -
  • -
-
-
-
-
-
-

9. Changelog

-
-
-

v1.10 2019-09-15

-
-

Maintenance release. Changes:

-
-
-
    -
  • -

    Behavior changes:

    -
    -
      -
    1. -

      Tab characters (ASCII 9) in attribute values are now encoded as '&#9;' to survive roundtripping

      -
    2. -
    3. -

      > characters are no longer escaped in attribute values

      -
    4. -
    -
    -
  • -
  • -

    New features:

    -
    -
      -
    1. -

      Add Visual Studio .natvis files to improve debugging experience

      -
    2. -
    3. -

      CMake improvements (USE_POSTFIX and BUILD_SHARED_AND_STATIC_LIBS options for building multiple versions and pkg-config tweaks)

      -
    4. -
    5. -

      Add format_skip_control_chars formatting flag to skip non-printable ASCII characters that are invalid to use in well-formed XML files

      -
    6. -
    7. -

      Add format_attribute_single_quote formatting flag to use single quotes for attribute values instead of default double quotes.

      -
    8. -
    -
    -
  • -
  • -

    XPath improvements:

    -
    -
      -
    1. -

      XPath union now results in a stable order that doesn’t depend on memory allocations; crucially, this may require sorting the output of XPath query operation if you rely on the document-ordered traversal

      -
    2. -
    3. -

      Improve performance of XPath union operation, making it ~2x faster

      -
    4. -
    -
    -
  • -
  • -

    Compatibility improvements:

    -
    -
      -
    1. -

      Fix Visual Studio warnings when built in a DLL configuration

      -
    2. -
    3. -

      Fix static analysis false positives in Coverity and clang

      -
    4. -
    5. -

      Fix Wdouble-promotion warnings in gcc

      -
    6. -
    7. -

      Add Visual Studio 2019 support for NuGet packages

      -
    8. -
    -
    -
  • -
-
-
-
-

v1.9 2018-04-04

-
-

Maintenance release. Changes:

-
-
-
    -
  • -

    Specification changes:

    -
    -
      -
    1. -

      xml_document::load(const char*) (deprecated in 1.5) now has deprecated attribute; use xml_document::load_string instead

      -
    2. -
    3. -

      xml_node::select_single_node (deprecated in 1.5) now has deprecated attribute; use xml_node::select_node instead

      -
    4. -
    -
    -
  • -
  • -

    New features:

    -
    -
      -
    1. -

      Add move semantics support for xml_document and improve move semantics support for other objects

      -
    2. -
    3. -

      CMake build now exports include directories

      -
    4. -
    5. -

      CMake build with BUILD_SHARED_LIBS=ON now uses dllexport attribute for MSVC

      -
    6. -
    -
    -
  • -
  • -

    XPath improvements:

    -
    -
      -
    1. -

      Rework parser/evaluator to not rely on exceptional control flow; longjmp is no longer used when exceptions are disabled

      -
    2. -
    3. -

      Improve error messages for certain invalid expressions such as .[1] or (1

      -
    4. -
    5. -

      Minor performance improvements

      -
    6. -
    -
    -
  • -
  • -

    Compatibility improvements:

    -
    -
      -
    1. -

      Fix Texas Instruments compiler warnings

      -
    2. -
    3. -

      Fix compilation issues with limits.h for some versions of gcc

      -
    4. -
    5. -

      Fix compilation issues with Clang/C2

      -
    6. -
    7. -

      Fix implicit fallthrough warnings in gcc 7

      -
    8. -
    9. -

      Fix unknown attribute directive warnings in gcc 8

      -
    10. -
    11. -

      Fix cray++ compiler errors

      -
    12. -
    13. -

      Fix unsigned integer overflow errors with -fsanitize=integer

      -
    14. -
    15. -

      Fix undefined behavior sanitizer issues in compact mode

      -
    16. -
    -
    -
  • -
-
-
-
-

v1.8 2016-11-24

-
-

Maintenance release. Changes:

-
-
-
    -
  • -

    Specification changes:

    -
    -
      -
    1. -

      When printing empty elements, a space is no longer added before / in format_raw mode

      -
    2. -
    -
    -
  • -
  • -

    New features:

    -
    -
      -
    1. -

      Added parse_embed_pcdata parsing mode in which PCDATA value is stored in the element node if possible (significantly reducing memory consumption for some documents)

      -
    2. -
    3. -

      Added auto-detection support for Latin-1 (ISO-8859-1) encoding during parsing

      -
    4. -
    5. -

      Added format_no_empty_element_tags formatting flag that outputs start/end tags instead of empty element tags for empty elements

      -
    6. -
    -
    -
  • -
  • -

    Performance improvements:

    -
    -
      -
    1. -

      Minor memory allocation improvements (yielding up to 1% memory savings in some cases)

      -
    2. -
    -
    -
  • -
  • -

    Compatibility improvements:

    -
    -
      -
    1. -

      Fixed compilation issues for Borland C++ 5.4

      -
    2. -
    3. -

      Fixed compilation issues for some distributions of MinGW 3.8

      -
    4. -
    5. -

      Fixed various Clang/GCC warnings

      -
    6. -
    7. -

      Enabled move semantics support for XPath objects for MSVC 2010 and above

      -
    8. -
    -
    -
  • -
-
-
-
-

v1.7 2015-10-19

-
-

Major release, featuring performance and memory improvements along with some new features. Changes:

-
-
-
    -
  • -

    Compact mode:

    -
    -
      -
    1. -

      Introduced a new tree storage mode that takes significantly less memory (2-5x smaller DOM) at some performance cost.

      -
    2. -
    3. -

      The mode can be enabled using PUGIXML_COMPACT define.

      -
    4. -
    -
    -
  • -
  • -

    New integer parsing/formatting implementation:

    -
    -
      -
    1. -

      Functions that convert from and to integers (e.g. as_int/set_value) do not rely on CRT any more.

      -
    2. -
    3. -

      New implementation is 3-5x faster and is always correct wrt overflow or underflow. This is a behavior change - where previously as_uint() would return UINT_MAX on a value "-1", it now returns 0.

      -
    4. -
    -
    -
  • -
  • -

    New features:

    -
    -
      -
    1. -

      XPath objects (xpath_query, xpath_node_set, xpath_variable_set) are now movable if your compiler supports C++11. Additionally, xpath_variable_set is copyable.

      -
    2. -
    3. -

      Added format_indent_attributes that makes the resulting XML friendlier to line diff/merge tools.

      -
    4. -
    5. -

      Added a variant of xml_node::attribute function with a hint that can improve lookup performance.

      -
    6. -
    7. -

      Custom allocation functions are now allowed (but not required) to throw instead of returning a null pointer.

      -
    8. -
    -
    -
  • -
  • -

    Bug fixes:

    -
    -
      -
    1. -

      Fix Clang 3.7 crashes in out-of-memory cases (C++ DR 1748)

      -
    2. -
    3. -

      Fix XPath crashes on SPARC64 (and other 32-bit architectures where doubles have to be aligned to 8 bytes)

      -
    4. -
    5. -

      Fix xpath_node_set assignment to provide strong exception guarantee

      -
    6. -
    7. -

      Fix saving for custom xml_writer implementations that can throw from write()

      -
    8. -
    -
    -
  • -
-
-
-
-

v1.6 2015-04-10

-
-

Maintenance release. Changes:

-
-
-
    -
  • -

    Specification changes:

    -
    -
      -
    1. -

      Attribute/text values now use more digits when printing floating point numbers to guarantee round-tripping.

      -
    2. -
    3. -

      Text nodes no longer get extra surrounding whitespace when pretty-printing nodes with mixed contents

      -
    4. -
    -
    -
  • -
  • -

    Bug fixes:

    -
    -
      -
    1. -

      Fixed translate and normalize-space XPath functions to no longer return internal NUL characters

      -
    2. -
    3. -

      Fixed buffer overrun on malformed comments inside DOCTYPE sections

      -
    4. -
    5. -

      DOCTYPE parsing can no longer run out of stack space on malformed inputs (XML parsing is now using bounded stack space)

      -
    6. -
    7. -

      Adjusted processing instruction output to avoid malformed documents if the PI value contains ?>

      -
    8. -
    -
    -
  • -
-
-
-
-

v1.5 2014-11-27

-
-

Major release, featuring a lot of performance improvements and some new features.

-
-
-
    -
  • -

    Specification changes:

    -
    -
      -
    1. -

      xml_document::load(const char_t*) was renamed to load_string; the old method is still available and will be deprecated in a future release

      -
    2. -
    3. -

      xml_node::select_single_node was renamed to select_node; the old method is still available and will be deprecated in a future release.

      -
    4. -
    -
    -
  • -
  • -

    New features:

    -
    -
      -
    1. -

      Added xml_node::append_move and other functions for moving nodes within a document

      -
    2. -
    3. -

      Added xpath_query::evaluate_node for evaluating queries with a single node as a result

      -
    4. -
    -
    -
  • -
  • -

    Performance improvements:

    -
    -
      -
    1. -

      Optimized XML parsing (10-40% faster with clang/gcc, up to 10% faster with MSVC)

      -
    2. -
    3. -

      Optimized memory consumption when copying nodes in the same document (string contents is now shared)

      -
    4. -
    5. -

      Optimized node copying (10% faster for cross-document copies, 3x faster for inter-document copies; also it now consumes a constant amount of stack space)

      -
    6. -
    7. -

      Optimized node output (60% faster; also it now consumes a constant amount of stack space)

      -
    8. -
    9. -

      Optimized XPath allocation (query evaluation now results in fewer temporary allocations)

      -
    10. -
    11. -

      Optimized XPath sorting (node set sorting is 2-3x faster in some cases)

      -
    12. -
    13. -

      Optimized XPath evaluation (XPathMark suite is 100x faster; some commonly used queries are 3-4x faster)

      -
    14. -
    -
    -
  • -
  • -

    Compatibility improvements:

    -
    -
      -
    1. -

      Fixed xml_node::offset_debug for corner cases

      -
    2. -
    3. -

      Fixed undefined behavior while calling memcpy in some cases

      -
    4. -
    5. -

      Fixed MSVC 2015 compilation warnings

      -
    6. -
    7. -

      Fixed contrib/foreach.hpp for Boost 1.56.0

      -
    8. -
    -
    -
  • -
  • -

    Bug fixes

    -
    -
      -
    1. -

      Adjusted comment output to avoid malformed documents if the comment value contains --

      -
    2. -
    3. -

      Fix XPath sorting for documents that were constructed using append_buffer

      -
    4. -
    5. -

      Fix load_file for wide-character paths with non-ASCII characters in MinGW with C++11 mode enabled

      -
    6. -
    -
    -
  • -
-
-
-
-

v1.4 2014-02-27

-
-

Major release, featuring various new features, bug fixes and compatibility improvements.

-
-
-
    -
  • -

    Specification changes:

    -
    -
      -
    1. -

      Documents without element nodes are now rejected with status_no_document_element error, unless parse_fragment option is used

      -
    2. -
    -
    -
  • -
  • -

    New features:

    -
    -
      -
    1. -

      Added XML fragment parsing (parse_fragment flag)

      -
    2. -
    3. -

      Added PCDATA whitespace trimming (parse_trim_pcdata flag)

      -
    4. -
    5. -

      Added long long support for xml_attribute and xml_text (as_llong, as_ullong and set_value/set overloads)

      -
    6. -
    7. -

      Added hexadecimal integer parsing support for as_int/as_uint/as_llong/as_ullong

      -
    8. -
    9. -

      Added xml_node::append_buffer to improve performance of assembling documents from fragments

      -
    10. -
    11. -

      xml_named_node_iterator is now bidirectional

      -
    12. -
    13. -

      Reduced XPath stack consumption during compilation and evaluation (useful for embedded systems)

      -
    14. -
    -
    -
  • -
  • -

    Compatibility improvements:

    -
    -
      -
    1. -

      Improved support for platforms without wchar_t support

      -
    2. -
    3. -

      Fixed several false positives in clang static analysis

      -
    4. -
    5. -

      Fixed several compilation warnings for various GCC versions

      -
    6. -
    -
    -
  • -
  • -

    Bug fixes:

    -
    -
      -
    1. -

      Fixed undefined pointer arithmetic in XPath implementation

      -
    2. -
    3. -

      Fixed non-seekable iostream support for certain stream types, i.e. Boost file_source with pipe input

      -
    4. -
    5. -

      Fixed xpath_query::return_type for some expressions

      -
    6. -
    7. -

      Fixed dllexport issues with xml_named_node_iterator

      -
    8. -
    9. -

      Fixed find_child_by_attribute assertion for attributes with null name/value

      -
    10. -
    -
    -
  • -
-
-
-
-

v1.2 2012-05-01

-
-

Major release, featuring header-only mode, various interface enhancements (i.e. PCDATA manipulation and C++11 iteration), many other features and compatibility improvements.

-
-
-
    -
  • -

    New features:

    -
    -
      -
    1. -

      Added xml_text helper class for working with PCDATA/CDATA contents of an element node

      -
    2. -
    3. -

      Added optional header-only mode (controlled by PUGIXML_HEADER_ONLY define)

      -
    4. -
    5. -

      Added xml_node::children() and xml_node::attributes() for C++11 ranged for loop or BOOST_FOREACH

      -
    6. -
    7. -

      Added support for Latin-1 (ISO-8859-1) encoding conversion during loading and saving

      -
    8. -
    9. -

      Added custom default values for xml_attribute::as_* (they are returned if the attribute does not exist)

      -
    10. -
    11. -

      Added parse_ws_pcdata_single flag for preserving whitespace-only PCDATA in case it’s the only child

      -
    12. -
    13. -

      Added format_save_file_text for xml_document::save_file to open files as text instead of binary (changes newlines on Windows)

      -
    14. -
    15. -

      Added format_no_escapes flag to disable special symbol escaping (complements ~parse_escapes)

      -
    16. -
    17. -

      Added support for loading document from streams that do not support seeking

      -
    18. -
    19. -

      Added PUGIXML_MEMORY_* constants for tweaking allocation behavior (useful for embedded systems)

      -
    20. -
    21. -

      Added PUGIXML_VERSION preprocessor define

      -
    22. -
    -
    -
  • -
  • -

    Compatibility improvements:

    -
    -
      -
    1. -

      Parser does not require setjmp support (improves compatibility with some embedded platforms, enables /clr:pure compilation)

      -
    2. -
    3. -

      STL forward declarations are no longer used (fixes SunCC/RWSTL compilation, fixes clang compilation in C++11 mode)

      -
    4. -
    5. -

      Fixed AirPlay SDK, Android, Windows Mobile (WinCE) and C++/CLI compilation

      -
    6. -
    7. -

      Fixed several compilation warnings for various GCC versions, Intel C++ compiler and Clang

      -
    8. -
    -
    -
  • -
  • -

    Bug fixes:

    -
    -
      -
    1. -

      Fixed unsafe bool conversion to avoid problems on C++/CLI

      -
    2. -
    3. -

      Iterator dereference operator is const now (fixes Boost filter_iterator support)

      -
    4. -
    5. -

      xml_document::save_file now checks for file I/O errors during saving

      -
    6. -
    -
    -
  • -
-
-
-
-

v1.0 2010-11-01

-
-

Major release, featuring many XPath enhancements, wide character filename support, miscellaneous performance improvements, bug fixes and more.

-
-
-
    -
  • -

    XPath:

    -
    -
      -
    1. -

      XPath implementation is moved to pugixml.cpp (which is the only source file now); use PUGIXML_NO_XPATH if you want to disable XPath to reduce code size

      -
    2. -
    3. -

      XPath is now supported without exceptions (PUGIXML_NO_EXCEPTIONS); the error handling mechanism depends on the presence of exception support

      -
    4. -
    5. -

      XPath is now supported without STL (PUGIXML_NO_STL)

      -
    6. -
    7. -

      Introduced variable support

      -
    8. -
    9. -

      Introduced new xpath_query::evaluate_string, which works without STL

      -
    10. -
    11. -

      Introduced new xpath_node_set constructor (from an iterator range)

      -
    12. -
    13. -

      Evaluation function now accept attribute context nodes

      -
    14. -
    15. -

      All internal allocations use custom allocation functions

      -
    16. -
    17. -

      Improved error reporting; now a last parsed offset is returned together with the parsing error

      -
    18. -
    -
    -
  • -
  • -

    Bug fixes:

    -
    -
      -
    1. -

      Fixed memory leak for loading from streams with stream exceptions turned on

      -
    2. -
    3. -

      Fixed custom deallocation function calling with null pointer in one case

      -
    4. -
    5. -

      Fixed missing attributes for iterator category functions; all functions/classes can now be DLL-exported

      -
    6. -
    7. -

      Worked around Digital Mars compiler bug, which lead to minor read overfetches in several functions

      -
    8. -
    9. -

      load_file now works with 2+ Gb files in MSVC/MinGW

      -
    10. -
    11. -

      XPath: fixed memory leaks for incorrect queries

      -
    12. -
    13. -

      XPath: fixed xpath_node() attribute constructor with empty attribute argument

      -
    14. -
    15. -

      XPath: fixed lang() function for non-ASCII arguments

      -
    16. -
    -
    -
  • -
  • -

    Specification changes:

    -
    -
      -
    1. -

      CDATA nodes containing ]]> are printed as several nodes; while this changes the internal structure, this is the only way to escape CDATA contents

      -
    2. -
    3. -

      Memory allocation errors during parsing now preserve last parsed offset (to give an idea about parsing progress)

      -
    4. -
    5. -

      If an element node has the only child, and it is of CDATA type, then the extra indentation is omitted (previously this behavior only held for PCDATA children)

      -
    6. -
    -
    -
  • -
  • -

    Additional functionality:

    -
    -
      -
    1. -

      Added xml_parse_result default constructor

      -
    2. -
    3. -

      Added xml_document::load_file and xml_document::save_file with wide character paths

      -
    4. -
    5. -

      Added as_utf8 and as_wide overloads for std::wstring/std::string arguments

      -
    6. -
    7. -

      Added DOCTYPE node type (node_doctype) and a special parse flag, parse_doctype, to add such nodes to the document during parsing

      -
    8. -
    9. -

      Added parse_full parse flag mask, which extends parse_default with all node type parsing flags except parse_ws_pcdata

      -
    10. -
    11. -

      Added xml_node::hash_value() and xml_attribute::hash_value() functions for use in hash-based containers

      -
    12. -
    13. -

      Added internal_object() and additional constructor for both xml_node and xml_attribute for easier marshalling (useful for language bindings)

      -
    14. -
    15. -

      Added xml_document::document_element() function

      -
    16. -
    17. -

      Added xml_node::prepend_attribute, xml_node::prepend_child and xml_node::prepend_copy functions

      -
    18. -
    19. -

      Added xml_node::append_child, xml_node::prepend_child, xml_node::insert_child_before and xml_node::insert_child_after overloads for element nodes (with name instead of type)

      -
    20. -
    21. -

      Added xml_document::reset() function

      -
    22. -
    -
    -
  • -
  • -

    Performance improvements:

    -
    -
      -
    1. -

      xml_node::root() and xml_node::offset_debug() are now O(1) instead of O(logN)

      -
    2. -
    3. -

      Minor parsing optimizations

      -
    4. -
    5. -

      Minor memory optimization for strings in DOM tree (set_name/set_value)

      -
    6. -
    7. -

      Memory optimization for string memory reclaiming in DOM tree (set_name/set_value now reallocate the buffer if memory waste is too big)

      -
    8. -
    9. -

      XPath: optimized document order sorting

      -
    10. -
    11. -

      XPath: optimized child/attribute axis step

      -
    12. -
    13. -

      XPath: optimized number-to-string conversions in MSVC

      -
    14. -
    15. -

      XPath: optimized concat for many arguments

      -
    16. -
    17. -

      XPath: optimized evaluation allocation mechanism: constant and document strings are not heap-allocated

      -
    18. -
    19. -

      XPath: optimized evaluation allocation mechanism: all temporaries' allocations use fast stack-like allocator

      -
    20. -
    -
    -
  • -
  • -

    Compatibility:

    -
    -
      -
    1. -

      Removed wildcard functions (xml_node::child_w, xml_node::attribute_w, etc.)

      -
    2. -
    3. -

      Removed xml_node::all_elements_by_name

      -
    4. -
    5. -

      Removed xpath_type_t enumeration; use xpath_value_type instead

      -
    6. -
    7. -

      Removed format_write_bom_utf8 enumeration; use format_write_bom instead

      -
    8. -
    9. -

      Removed xml_document::precompute_document_order, xml_attribute::document_order and xml_node::document_order functions; document order sort optimization is now automatic

      -
    10. -
    11. -

      Removed xml_document::parse functions and transfer_ownership struct; use xml_document::load_buffer_inplace and xml_document::load_buffer_inplace_own instead

      -
    12. -
    13. -

      Removed as_utf16 function; use as_wide instead

      -
    14. -
    -
    -
  • -
-
-
-
-

v0.9 2010-07-01

-
-

Major release, featuring extended and improved Unicode support, miscellaneous performance improvements, bug fixes and more.

-
-
-
    -
  • -

    Major Unicode improvements:

    -
    -
      -
    1. -

      Introduced encoding support (automatic/manual encoding detection on load, manual encoding selection on save, conversion from/to UTF8, UTF16 LE/BE, UTF32 LE/BE)

      -
    2. -
    3. -

      Introduced wchar_t mode (you can set PUGIXML_WCHAR_MODE define to switch pugixml internal encoding from UTF8 to wchar_t; all functions are switched to their Unicode variants)

      -
    4. -
    5. -

      Load/save functions now support wide streams

      -
    6. -
    -
    -
  • -
  • -

    Bug fixes:

    -
    -
      -
    1. -

      Fixed document corruption on failed parsing bug

      -
    2. -
    3. -

      XPath string/number conversion improvements (increased precision, fixed crash for huge numbers)

      -
    4. -
    5. -

      Improved DOCTYPE parsing: now parser recognizes all well-formed DOCTYPE declarations

      -
    6. -
    7. -

      Fixed xml_attribute::as_uint() for large numbers (i.e. 232-1)

      -
    8. -
    9. -

      Fixed xml_node::first_element_by_path for path components that are prefixes of node names, but are not exactly equal to them.

      -
    10. -
    -
    -
  • -
  • -

    Specification changes:

    -
    -
      -
    1. -

      parse() API changed to load_buffer/load_buffer_inplace/load_buffer_inplace_own; load_buffer APIs do not require zero-terminated strings.

      -
    2. -
    3. -

      Renamed as_utf16 to as_wide

      -
    4. -
    5. -

      Changed xml_node::offset_debug return type and xml_parse_result::offset type to ptrdiff_t

      -
    6. -
    7. -

      Nodes/attributes with empty names are now printed as :anonymous

      -
    8. -
    -
    -
  • -
  • -

    Performance improvements:

    -
    -
      -
    1. -

      Optimized document parsing and saving

      -
    2. -
    3. -

      Changed internal memory management: internal allocator is used for both metadata and name/value data; allocated pages are deleted if all allocations from them are deleted

      -
    4. -
    5. -

      Optimized memory consumption: sizeof(xml_node_struct) reduced from 40 bytes to 32 bytes on x86

      -
    6. -
    7. -

      Optimized debug mode parsing/saving by order of magnitude

      -
    8. -
    -
    -
  • -
  • -

    Miscellaneous:

    -
    -
      -
    1. -

      All STL includes except <exception> in pugixml.hpp are replaced with forward declarations

      -
    2. -
    3. -

      xml_node::remove_child and xml_node::remove_attribute now return the operation result

      -
    4. -
    -
    -
  • -
  • -

    Compatibility:

    -
    -
      -
    1. -

      parse() and as_utf16 are left for compatibility (these functions are deprecated and will be removed in version 1.0)

      -
    2. -
    3. -

      Wildcard functions, document_order/precompute_document_order functions, all_elements_by_name function and format_write_bom_utf8 flag are deprecated and will be removed in version 1.0

      -
    4. -
    5. -

      xpath_type_t enumeration was renamed to xpath_value_type; xpath_type_t is deprecated and will be removed in version 1.0

      -
    6. -
    -
    -
  • -
-
-
-
-

v0.5 2009-11-08

-
-

Major bugfix release. Changes:

-
-
-
    -
  • -

    XPath bugfixes:

    -
    -
      -
    1. -

      Fixed translate(), lang() and concat() functions (infinite loops/crashes)

      -
    2. -
    3. -

      Fixed compilation of queries with empty literal strings ("")

      -
    4. -
    5. -

      Fixed axis tests: they never add empty nodes/attributes to the resulting node set now

      -
    6. -
    7. -

      Fixed string-value evaluation for node-set (the result excluded some text descendants)

      -
    8. -
    9. -

      Fixed self:: axis (it behaved like ancestor-or-self::)

      -
    10. -
    11. -

      Fixed following:: and preceding:: axes (they included descendent and ancestor nodes, respectively)

      -
    12. -
    13. -

      Minor fix for namespace-uri() function (namespace declaration scope includes the parent element of namespace declaration attribute)

      -
    14. -
    15. -

      Some incorrect queries are no longer parsed now (i.e. foo: *)

      -
    16. -
    17. -

      Fixed text()/etc. node test parsing bug (i.e. foo[text()] failed to compile)

      -
    18. -
    19. -

      Fixed root step (/) - it now selects empty node set if query is evaluated on empty node

      -
    20. -
    21. -

      Fixed string to number conversion ("123 " converted to NaN, "123 .456" converted to 123.456 - now the results are 123 and NaN, respectively)

      -
    22. -
    23. -

      Node set copying now preserves sorted type; leads to better performance on some queries

      -
    24. -
    -
    -
  • -
  • -

    Miscellaneous bugfixes:

    -
    -
      -
    1. -

      Fixed xml_node::offset_debug for PI nodes

      -
    2. -
    3. -

      Added empty attribute checks to xml_node::remove_attribute

      -
    4. -
    5. -

      Fixed node_pi and node_declaration copying

      -
    6. -
    7. -

      Const-correctness fixes

      -
    8. -
    -
    -
  • -
  • -

    Specification changes:

    -
    -
      -
    1. -

      xpath_node::select_nodes() and related functions now throw exception if expression return type is not node set (instead of assertion)

      -
    2. -
    3. -

      xml_node::traverse() now sets depth to -1 for both begin() and end() callbacks (was 0 at begin() and -1 at end())

      -
    4. -
    5. -

      In case of non-raw node printing a newline is output after PCDATA inside nodes if the PCDATA has siblings

      -
    6. -
    7. -

      UTF8 → wchar_t conversion now considers 5-byte UTF8-like sequences as invalid

      -
    8. -
    -
    -
  • -
  • -

    New features:

    -
    -
      -
    1. -

      Added xpath_node_set::operator[] for index-based iteration

      -
    2. -
    3. -

      Added xpath_query::return_type()

      -
    4. -
    5. -

      Added getter accessors for memory-management functions

      -
    6. -
    -
    -
  • -
-
-
-
-

v0.42 2009-09-17

-
-

Maintenance release. Changes:

-
-
-
    -
  • -

    Bug fixes:

    -
    -
      -
    1. -

      Fixed deallocation in case of custom allocation functions or if delete[] / free are incompatible

      -
    2. -
    3. -

      XPath parser fixed for incorrect queries (i.e. incorrect XPath queries should now always fail to compile)

      -
    4. -
    5. -

      Const-correctness fixes for find_child_by_attribute

      -
    6. -
    7. -

      Improved compatibility (miscellaneous warning fixes, fixed <cstring> include dependency for GCC)

      -
    8. -
    9. -

      Fixed iterator begin/end and print function to work correctly for empty nodes

      -
    10. -
    -
    -
  • -
  • -

    New features:

    -
    -
      -
    1. -

      Added PUGIXML_API/PUGIXML_CLASS/PUGIXML_FUNCTION configuration macros to control class/function attributes

      -
    2. -
    3. -

      Added xml_attribute::set_value overloads for different types

      -
    4. -
    -
    -
  • -
-
-
-
-

v0.41 2009-02-08

-
-

Maintenance release. Changes:

-
-
-
    -
  • -

    Bug fixes:

    -
    -
      -
    1. -

      Fixed bug with node printing (occasionally some content was not written to output stream)

      -
    2. -
    -
    -
  • -
-
-
-
-

v0.4 2009-01-18

-
-

Changes:

-
-
-
    -
  • -

    Bug fixes:

    -
    -
      -
    1. -

      Documentation fix in samples for parse() with manual lifetime control

      -
    2. -
    3. -

      Fixed document order sorting in XPath (it caused wrong order of nodes after xpath_node_set::sort and wrong results of some XPath queries)

      -
    4. -
    -
    -
  • -
  • -

    Node printing changes:

    -
    -
      -
    1. -

      Single quotes are no longer escaped when printing nodes

      -
    2. -
    3. -

      Symbols in second half of ASCII table are no longer escaped when printing nodes; because of this, format_utf8 flag is deleted as it’s no longer needed and format_write_bom is renamed to format_write_bom_utf8.

      -
    4. -
    5. -

      Reworked node printing - now it works via xml_writer interface; implementations for FILE* and std::ostream are available. As a side-effect, xml_document::save_file now works without STL.

      -
    6. -
    -
    -
  • -
  • -

    New features:

    -
    -
      -
    1. -

      Added unsigned integer support for attributes (xml_attribute::as_uint, xml_attribute::operator=)

      -
    2. -
    3. -

      Now document declaration (<?xml …​?>) is parsed as node with type node_declaration when parse_declaration flag is specified (access to encoding/version is performed as if they were attributes, i.e. doc.child("xml").attribute("version").as_float()); corresponding flags for node printing were also added

      -
    4. -
    5. -

      Added support for custom memory management (see set_memory_management_functions for details)

      -
    6. -
    7. -

      Implemented node/attribute copying (see xml_node::insert_copy_* and xml_node::append_copy for details)

      -
    8. -
    9. -

      Added find_child_by_attribute and find_child_by_attribute_w to simplify parsing code in some cases (i.e. COLLADA files)

      -
    10. -
    11. -

      Added file offset information querying for debugging purposes (now you’re able to determine exact location of any xml_node in parsed file, see xml_node::offset_debug for details)

      -
    12. -
    13. -

      Improved error handling for parsing - now load(), load_file() and parse() return xml_parse_result, which contains error code and last parsed offset; this does not break old interface as xml_parse_result can be implicitly casted to bool.

      -
    14. -
    -
    -
  • -
-
-
-
-

v0.34 2007-10-31

-
-

Maintenance release. Changes:

-
-
-
    -
  • -

    Bug fixes:

    -
    -
      -
    1. -

      Fixed bug with loading from text-mode iostreams

      -
    2. -
    3. -

      Fixed leak when transfer_ownership is true and parsing is failing

      -
    4. -
    5. -

      Fixed bug in saving (\r and \n are now escaped in attribute values)

      -
    6. -
    7. -

      Renamed free() to destroy() - some macro conflicts were reported

      -
    8. -
    -
    -
  • -
  • -

    New features:

    -
    -
      -
    1. -

      Improved compatibility (supported Digital Mars C++, MSVC 6, CodeWarrior 8, PGI C++, Comeau, supported PS3 and XBox360)

      -
    2. -
    3. -

      PUGIXML_NO_EXCEPTION flag for platforms without exception handling

      -
    4. -
    -
    -
  • -
-
-
-
-

v0.3 2007-02-21

-
-

Refactored, reworked and improved version. Changes:

-
-
-
    -
  • -

    Interface:

    -
    -
      -
    1. -

      Added XPath

      -
    2. -
    3. -

      Added tree modification functions

      -
    4. -
    5. -

      Added no STL compilation mode

      -
    6. -
    7. -

      Added saving document to file

      -
    8. -
    9. -

      Refactored parsing flags

      -
    10. -
    11. -

      Removed xml_parser class in favor of xml_document

      -
    12. -
    13. -

      Added transfer ownership parsing mode

      -
    14. -
    15. -

      Modified the way xml_tree_walker works

      -
    16. -
    17. -

      Iterators are now non-constant

      -
    18. -
    -
    -
  • -
  • -

    Implementation:

    -
    -
      -
    1. -

      Support of several compilers and platforms

      -
    2. -
    3. -

      Refactored and sped up parsing core

      -
    4. -
    5. -

      Improved standard compliancy

      -
    6. -
    7. -

      Added XPath implementation

      -
    8. -
    9. -

      Fixed several bugs

      -
    10. -
    -
    -
  • -
-
-
-
-

v0.2 2006-11-06

-
-

First public release. Changes:

-
-
-
    -
  • -

    Bug fixes:

    -
    -
      -
    1. -

      Fixed child_value() (for empty nodes)

      -
    2. -
    3. -

      Fixed xml_parser_impl warning at W4

      -
    4. -
    -
    -
  • -
  • -

    New features:

    -
    -
      -
    1. -

      Introduced child_value(name) and child_value_w(name)

      -
    2. -
    3. -

      parse_eol_pcdata and parse_eol_attribute flags + parse_minimal optimizations

      -
    4. -
    5. -

      Optimizations of strconv_t

      -
    6. -
    -
    -
  • -
-
-
-
-

v0.1 2006-07-15

-
-

First private release for testing purposes

-
-
-
-
-
-

10. API Reference

-
-
-

This is the reference for all macros, types, enumerations, classes and functions in pugixml. Each symbol is a link that leads to the relevant section of the manual.

-
- -
-

10.2. Types

-
-
-
typedef configuration-defined-type char_t;
-typedef configuration-defined-type string_t;
-typedef void* (*allocation_function)(size_t size);
-typedef void (*deallocation_function)(void* ptr);
-
-
-
- -
-

10.4. Constants

-
-
-
// Formatting options bit flags:
-const unsigned int format_attribute_single_quote
-const unsigned int format_default
-const unsigned int format_indent
-const unsigned int format_indent_attributes
-const unsigned int format_no_declaration
-const unsigned int format_no_empty_element_tags
-const unsigned int format_no_escapes
-const unsigned int format_raw
-const unsigned int format_save_file_text
-const unsigned int format_skip_control_chars
-const unsigned int format_write_bom
-
-// Parsing options bit flags:
-const unsigned int parse_cdata
-const unsigned int parse_comments
-const unsigned int parse_declaration
-const unsigned int parse_default
-const unsigned int parse_doctype
-const unsigned int parse_eol
-const unsigned int parse_escapes
-const unsigned int parse_fragment
-const unsigned int parse_full
-const unsigned int parse_minimal
-const unsigned int parse_pi
-const unsigned int parse_trim_pcdata
-const unsigned int parse_ws_pcdata
-const unsigned int parse_ws_pcdata_single
-const unsigned int parse_embed_pcdata
-const unsigned int parse_wconv_attribute
-const unsigned int parse_wnorm_attribute
-
-
-
-
-

10.5. Classes

-
-
-
class xml_attribute
-    xml_attribute();
-
-    bool empty() const;
-    operator unspecified_bool_type() const;
-
-    bool operator==(const xml_attribute& r) const;
-    bool operator!=(const xml_attribute& r) const;
-    bool operator<(const xml_attribute& r) const;
-    bool operator>(const xml_attribute& r) const;
-    bool operator<=(const xml_attribute& r) const;
-    bool operator>=(const xml_attribute& r) const;
-
-    size_t hash_value() const;
-
-    xml_attribute next_attribute() const;
-    xml_attribute previous_attribute() const;
-
-    const char_t* name() const;
-    const char_t* value() const;
-
-    const char_t* as_string(const char_t* def = "") const;
-    int as_int(int def = 0) const;
-    unsigned int as_uint(unsigned int def = 0) const;
-    double as_double(double def = 0) const;
-    float as_float(float def = 0) const;
-    bool as_bool(bool def = false) const;
-    long long as_llong(long long def = 0) const;
-    unsigned long long as_ullong(unsigned long long def = 0) const;
-
-    bool set_name(const char_t* rhs);
-    bool set_value(const char_t* rhs);
-    bool set_value(int rhs);
-    bool set_value(unsigned int rhs);
-    bool set_value(long rhs);
-    bool set_value(unsigned long rhs);
-    bool set_value(double rhs);
-    bool set_value(float rhs);
-    bool set_value(bool rhs);
-    bool set_value(long long rhs);
-    bool set_value(unsigned long long rhs);
-
-    xml_attribute& operator=(const char_t* rhs);
-    xml_attribute& operator=(int rhs);
-    xml_attribute& operator=(unsigned int rhs);
-    xml_attribute& operator=(long rhs);
-    xml_attribute& operator=(unsigned long rhs);
-    xml_attribute& operator=(double rhs);
-    xml_attribute& operator=(float rhs);
-    xml_attribute& operator=(bool rhs);
-    xml_attribute& operator=(long long rhs);
-    xml_attribute& operator=(unsnigned long long rhs);
-
-class xml_node
-    xml_node();
-
-    bool empty() const;
-    operator unspecified_bool_type() const;
-
-    bool operator==(const xml_node& r) const;
-    bool operator!=(const xml_node& r) const;
-    bool operator<(const xml_node& r) const;
-    bool operator>(const xml_node& r) const;
-    bool operator<=(const xml_node& r) const;
-    bool operator>=(const xml_node& r) const;
-
-    size_t hash_value() const;
-
-    xml_node_type type() const;
-
-    const char_t* name() const;
-    const char_t* value() const;
-
-    xml_node parent() const;
-    xml_node first_child() const;
-    xml_node last_child() const;
-    xml_node next_sibling() const;
-    xml_node previous_sibling() const;
-
-    xml_attribute first_attribute() const;
-    xml_attribute last_attribute() const;
-
-    implementation-defined-type children() const;
-    implementation-defined-type children(const char_t* name) const;
-    implementation-defined-type attributes() const;
-
-    xml_node child(const char_t* name) const;
-    xml_attribute attribute(const char_t* name) const;
-    xml_node next_sibling(const char_t* name) const;
-    xml_node previous_sibling(const char_t* name) const;
-    xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
-    xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const;
-
-    const char_t* child_value() const;
-    const char_t* child_value(const char_t* name) const;
-    xml_text text() const;
-
-    typedef xml_node_iterator iterator;
-    iterator begin() const;
-    iterator end() const;
-
-    typedef xml_attribute_iterator attribute_iterator;
-    attribute_iterator attributes_begin() const;
-    attribute_iterator attributes_end() const;
-
-    bool traverse(xml_tree_walker& walker);
-
-    template <typename Predicate> xml_attribute find_attribute(Predicate pred) const;
-    template <typename Predicate> xml_node find_child(Predicate pred) const;
-    template <typename Predicate> xml_node find_node(Predicate pred) const;
-
-    string_t path(char_t delimiter = '/') const;
-    xml_node xml_node::first_element_by_path(const char_t* path, char_t delimiter = '/') const;
-    xml_node root() const;
-    ptrdiff_t offset_debug() const;
-
-    bool set_name(const char_t* rhs);
-    bool set_value(const char_t* rhs);
-
-    xml_attribute append_attribute(const char_t* name);
-    xml_attribute prepend_attribute(const char_t* name);
-    xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr);
-    xml_attribute insert_attribute_before(const char_t* name, const xml_attribute& attr);
-
-    xml_node append_child(xml_node_type type = node_element);
-    xml_node prepend_child(xml_node_type type = node_element);
-    xml_node insert_child_after(xml_node_type type, const xml_node& node);
-    xml_node insert_child_before(xml_node_type type, const xml_node& node);
-
-    xml_node append_child(const char_t* name);
-    xml_node prepend_child(const char_t* name);
-    xml_node insert_child_after(const char_t* name, const xml_node& node);
-    xml_node insert_child_before(const char_t* name, const xml_node& node);
-
-    xml_attribute append_copy(const xml_attribute& proto);
-    xml_attribute prepend_copy(const xml_attribute& proto);
-    xml_attribute insert_copy_after(const xml_attribute& proto, const xml_attribute& attr);
-    xml_attribute insert_copy_before(const xml_attribute& proto, const xml_attribute& attr);
-
-    xml_node append_copy(const xml_node& proto);
-    xml_node prepend_copy(const xml_node& proto);
-    xml_node insert_copy_after(const xml_node& proto, const xml_node& node);
-    xml_node insert_copy_before(const xml_node& proto, const xml_node& node);
-
-    xml_node append_move(const xml_node& moved);
-    xml_node prepend_move(const xml_node& moved);
-    xml_node insert_move_after(const xml_node& moved, const xml_node& node);
-    xml_node insert_move_before(const xml_node& moved, const xml_node& node);
-
-    bool remove_attribute(const xml_attribute& a);
-    bool remove_attribute(const char_t* name);
-    bool remove_child(const xml_node& n);
-    bool remove_child(const char_t* name);
-
-    xml_parse_result append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-
-    void print(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
-    void print(std::ostream& os, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const;
-    void print(std::wostream& os, const char_t* indent = "\t", unsigned int flags = format_default, unsigned int depth = 0) const;
-
-    xpath_node select_node(const char_t* query, xpath_variable_set* variables = 0) const;
-    xpath_node select_node(const xpath_query& query) const;
-    xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = 0) const;
-    xpath_node_set select_nodes(const xpath_query& query) const;
-
-class xml_document
-    xml_document();
-    ~xml_document();
-
-    void reset();
-    void reset(const xml_document& proto);
-
-    xml_parse_result load(std::istream& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-    xml_parse_result load(std::wistream& stream, unsigned int options = parse_default);
-
-    xml_parse_result load_string(const char_t* contents, unsigned int options = parse_default);
-
-    xml_parse_result load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-    xml_parse_result load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-
-    xml_parse_result load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-    xml_parse_result load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-    xml_parse_result load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
-
-    bool save_file(const char* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
-    bool save_file(const wchar_t* path, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
-
-    void save(std::ostream& stream, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
-    void save(std::wostream& stream, const char_t* indent = "\t", unsigned int flags = format_default) const;
-
-    void save(xml_writer& writer, const char_t* indent = "\t", unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
-
-    xml_node document_element() const;
-
-struct xml_parse_result
-    xml_parse_status status;
-    ptrdiff_t offset;
-    xml_encoding encoding;
-
-    operator bool() const;
-    const char* description() const;
-
-class xml_node_iterator
-class xml_attribute_iterator
-
-class xml_tree_walker
-    virtual bool begin(xml_node& node);
-    virtual bool for_each(xml_node& node) = 0;
-    virtual bool end(xml_node& node);
-
-    int depth() const;
-
-class xml_text
-    bool empty() const;
-    operator xml_text::unspecified_bool_type() const;
-
-    const char_t* xml_text::get() const;
-
-    const char_t* as_string(const char_t* def = "") const;
-    int as_int(int def = 0) const;
-    unsigned int as_uint(unsigned int def = 0) const;
-    double as_double(double def = 0) const;
-    float as_float(float def = 0) const;
-    bool as_bool(bool def = false) const;
-    long long as_llong(long long def = 0) const;
-    unsigned long long as_ullong(unsigned long long def = 0) const;
-
-    bool set(const char_t* rhs);
-
-    bool set(int rhs);
-    bool set(unsigned int rhs);
-    bool set(long rhs);
-    bool set(unsigned long rhs);
-    bool set(double rhs);
-    bool set(float rhs);
-    bool set(bool rhs);
-    bool set(long long rhs);
-    bool set(unsigned long long rhs);
-
-    xml_text& operator=(const char_t* rhs);
-    xml_text& operator=(int rhs);
-    xml_text& operator=(unsigned int rhs);
-    xml_text& operator=(long rhs);
-    xml_text& operator=(unsigned long rhs);
-    xml_text& operator=(double rhs);
-    xml_text& operator=(float rhs);
-    xml_text& operator=(bool rhs);
-    xml_text& operator=(long long rhs);
-    xml_text& operator=(unsigned long long rhs);
-
-    xml_node data() const;
-
-class xml_writer
-    virtual void write(const void* data, size_t size) = 0;
-
-class xml_writer_file: public xml_writer
-    xml_writer_file(void* file);
-
-class xml_writer_stream: public xml_writer
-    xml_writer_stream(std::ostream& stream);
-    xml_writer_stream(std::wostream& stream);
-
-struct xpath_parse_result
-    const char* error;
-    ptrdiff_t offset;
-
-    operator bool() const;
-    const char* description() const;
-
-class xpath_query
-    explicit xpath_query(const char_t* query, xpath_variable_set* variables = 0);
-
-    bool evaluate_boolean(const xpath_node& n) const;
-    double evaluate_number(const xpath_node& n) const;
-    string_t evaluate_string(const xpath_node& n) const;
-    size_t evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const;
-    xpath_node_set evaluate_node_set(const xpath_node& n) const;
-    xpath_node evaluate_node(const xpath_node& n) const;
-
-    xpath_value_type return_type() const;
-
-    const xpath_parse_result& result() const;
-    operator unspecified_bool_type() const;
-
-class xpath_exception: public std::exception
-    virtual const char* what() const throw();
-
-    const xpath_parse_result& result() const;
-
-class xpath_node
-    xpath_node();
-    xpath_node(const xml_node& node);
-    xpath_node(const xml_attribute& attribute, const xml_node& parent);
-
-    xml_node node() const;
-    xml_attribute attribute() const;
-    xml_node parent() const;
-
-    operator unspecified_bool_type() const;
-    bool operator==(const xpath_node& n) const;
-    bool operator!=(const xpath_node& n) const;
-
-class xpath_node_set
-    xpath_node_set();
-    xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted);
-
-    typedef const xpath_node* const_iterator;
-    const_iterator begin() const;
-    const_iterator end() const;
-
-    const xpath_node& operator[](size_t index) const;
-    size_t size() const;
-    bool empty() const;
-
-    xpath_node first() const;
-
-    enum type_t {type_unsorted, type_sorted, type_sorted_reverse};
-    type_t type() const;
-    void sort(bool reverse = false);
-
-class xpath_variable
-    const char_t* name() const;
-    xpath_value_type type() const;
-
-    bool get_boolean() const;
-    double get_number() const;
-    const char_t* get_string() const;
-    const xpath_node_set& get_node_set() const;
-
-    bool set(bool value);
-    bool set(double value);
-    bool set(const char_t* value);
-    bool set(const xpath_node_set& value);
-
-class xpath_variable_set
-    xpath_variable* add(const char_t* name, xpath_value_type type);
-
-    bool set(const char_t* name, bool value);
-    bool set(const char_t* name, double value);
-    bool set(const char_t* name, const char_t* value);
-    bool set(const char_t* name, const xpath_node_set& value);
-
-    xpath_variable* get(const char_t* name);
-    const xpath_variable* get(const char_t* name) const;
-
-
-
-
-

10.6. Functions

-
-
-
std::string as_utf8(const wchar_t* str);
-std::string as_utf8(const std::wstring& str);
-std::wstring as_wide(const char* str);
-std::wstring as_wide(const std::string& str);
-void set_memory_management_functions(allocation_function allocate, deallocation_function deallocate);
-allocation_function get_memory_allocation_function();
-deallocation_function get_memory_deallocation_function();
-
-
-
-
-
-
-
-
-
-1. All trademarks used are properties of their respective owners. -
-
- - - \ No newline at end of file diff --git a/external/pugixml/docs/quickstart.adoc b/external/pugixml/docs/quickstart.adoc deleted file mode 100644 index b4d621d39..000000000 --- a/external/pugixml/docs/quickstart.adoc +++ /dev/null @@ -1,287 +0,0 @@ -= pugixml {version} quick start guide -include::config.adoc[] - -[[introduction]] -== Introduction - -https://pugixml.org/[pugixml] is a light-weight C{plus}{plus} XML processing library. It consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an XPath 1.0 implementation for complex data-driven tree queries. Full Unicode support is also available, with two Unicode interface variants and conversions between different Unicode encodings (which happen automatically during parsing/saving). The library is extremely portable and easy to integrate and use. pugixml is developed and maintained since 2006 and has many users. All code is distributed under the <>, making it completely free to use in both open-source and proprietary applications. - -pugixml enables very fast, convenient and memory-efficient XML document processing. However, since pugixml has a DOM parser, it can't process XML documents that do not fit in memory; also the parser is a non-validating one, so if you need DTD/Schema validation, the library is not for you. - -This is the quick start guide for pugixml, which purpose is to enable you to start using the library quickly. Many important library features are either not described at all or only mentioned briefly; for more complete information you link:manual.html[should read the complete manual]. - -NOTE: No documentation is perfect; neither is this one. If you find errors or omissions, please don’t hesitate to https://github.com/zeux/pugixml/issues/new[submit an issue or open a pull request] with a fix. - -[[install]] -== Installation - -You can download the latest source distribution as an archive: - -https://github.com/zeux/pugixml/releases/download/v{version}/pugixml-{version}.zip[pugixml-{version}.zip] (Windows line endings) -/ -https://github.com/zeux/pugixml/releases/download/v{version}/pugixml-{version}.tar.gz[pugixml-{version}.tar.gz] (Unix line endings) - -The distribution contains library source, documentation (the guide you're reading now and the manual) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive. - -The complete pugixml source consists of three files - one source file, `pugixml.cpp`, and two header files, `pugixml.hpp` and `pugiconfig.hpp`. `pugixml.hpp` is the primary header which you need to include in order to use pugixml classes/functions. The rest of this guide assumes that `pugixml.hpp` is either in the current directory or in one of include directories of your projects, so that `#include "pugixml.hpp"` can find the header; however you can also use relative path (i.e. `#include "../libs/pugixml/src/pugixml.hpp"`) or include directory-relative path (i.e. `#include `). - -The easiest way to build pugixml is to compile the source file, `pugixml.cpp`, along with the existing library/executable. This process depends on the method of building your application; for example, if you're using Microsoft Visual Studio footnote:[All trademarks used are properties of their respective owners.], Apple Xcode, Code::Blocks or any other IDE, just *add `pugixml.cpp` to one of your projects*. There are other building methods available, including building pugixml as a standalone static/shared library; link:manual.html#install.building[read the manual] for further information. - -[[dom]] -== Document object model - -pugixml stores XML data in DOM-like way: the entire XML document (both document structure and element data) is stored in memory as a tree. The tree can be loaded from character stream (file, string, C{plus}{plus} I/O stream), then traversed via special API or XPath expressions. The whole tree is mutable: both node structure and node/attribute data can be changed at any time. Finally, the result of document transformations can be saved to a character stream (file, C{plus}{plus} I/O stream or custom transport). - -The root of the tree is the document itself, which corresponds to C{plus}{plus} type `xml_document`. Document has one or more child nodes, which correspond to C{plus}{plus} type `xml_node`. Nodes have different types; depending on a type, a node can have a collection of child nodes, a collection of attributes, which correspond to C{plus}{plus} type `xml_attribute`, and some additional data (i.e. name). - -The most common node types are: - -* Document node (`node_document`) - this is the root of the tree, which consists of several child nodes. This node corresponds to `xml_document` class; note that `xml_document` is a sub-class of `xml_node`, so the entire node interface is also available. - -* Element/tag node (`node_element`) - this is the most common type of node, which represents XML elements. Element nodes have a name, a collection of attributes and a collection of child nodes (both of which may be empty). The attribute is a simple name/value pair. - -* Plain character data nodes (`node_pcdata`) represent plain text in XML. PCDATA nodes have a value, but do not have name or children/attributes. Note that *plain character data is not a part of the element node but instead has its own node*; for example, an element node can have several child PCDATA nodes. - -Despite the fact that there are several node types, there are only three C{plus}{plus} types representing the tree (`xml_document`, `xml_node`, `xml_attribute`); some operations on `xml_node` are only valid for certain node types. They are described below. - -NOTE: All pugixml classes and functions are located in `pugi` namespace; you have to either use explicit name qualification (i.e. `pugi::xml_node`), or to gain access to relevant symbols via `using` directive (i.e. `using pugi::xml_node;` or `using namespace pugi;`). - -`xml_document` is the owner of the entire document structure; destroying the document destroys the whole tree. The interface of `xml_document` consists of loading functions, saving functions and the entire interface of `xml_node`, which allows for document inspection and/or modification. Note that while `xml_document` is a sub-class of `xml_node`, `xml_node` is not a polymorphic type; the inheritance is present only to simplify usage. - -`xml_node` is the handle to document node; it can point to any node in the document, including document itself. There is a common interface for nodes of all types. Note that `xml_node` is only a handle to the actual node, not the node itself - you can have several `xml_node` handles pointing to the same underlying object. Destroying `xml_node` handle does not destroy the node and does not remove it from the tree. - -There is a special value of `xml_node` type, known as null node or empty node. It does not correspond to any node in any document, and thus resembles null pointer. However, all operations are defined on empty nodes; generally the operations don't do anything and return empty nodes/attributes or empty strings as their result. This is useful for chaining calls; i.e. you can get the grandparent of a node like so: `node.parent().parent()`; if a node is a null node or it does not have a parent, the first `parent()` call returns null node; the second `parent()` call then also returns null node, so you don't have to check for errors twice. You can test if a handle is null via implicit boolean cast: `if (node) { ... }` or `if (!node) { ... }`. - -`xml_attribute` is the handle to an XML attribute; it has the same semantics as `xml_node`, i.e. there can be several `xml_attribute` handles pointing to the same underlying object and there is a special null attribute value, which propagates to function results. - -There are two choices of interface and internal representation when configuring pugixml: you can either choose the UTF-8 (also called char) interface or UTF-16/32 (also called wchar_t) one. The choice is controlled via `PUGIXML_WCHAR_MODE` define; you can set it via `pugiconfig.hpp` or via preprocessor options. All tree functions that work with strings work with either C-style null terminated strings or STL strings of the selected character type. link:manual.html#dom.unicode[Read the manual] for additional information on Unicode interface. - -[[loading]] -== Loading document - -pugixml provides several functions for loading XML data from various places - files, C{plus}{plus} iostreams, memory buffers. All functions use an extremely fast non-validating parser. This parser is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed because of performance reasons. XML data is always converted to internal character format before parsing. pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it's a strict subset of UTF-16) and handles all encoding conversions automatically. - -The most common source of XML data is files; pugixml provides a separate function for loading XML document from file. This function accepts file path as its first argument, and also two optional arguments, which specify parsing options and input data encoding, which are described in the manual. - -This is an example of loading XML document from file (link:samples/load_file.cpp[]): - -[source,indent=0] ----- -include::samples/load_file.cpp[tags=code] ----- - -`load_file`, as well as other loading functions, destroys the existing document tree and then tries to load the new tree from the specified file. The result of the operation is returned in an `xml_parse_result` object; this object contains the operation status, and the related information (i.e. last successfully parsed position in the input file, if parsing fails). - -Parsing result object can be implicitly converted to `bool`; if you do not want to handle parsing errors thoroughly, you can just check the return value of load functions as if it was a `bool`: `if (doc.load_file("file.xml")) { ... } else { ... }`. Otherwise you can use the `status` member to get parsing status, or the `description()` member function to get the status in a string form. - -This is an example of handling loading errors (link:samples/load_error_handling.cpp[]): - -[source,indent=0] ----- -include::samples/load_error_handling.cpp[tags=code] ----- - -Sometimes XML data should be loaded from some other source than file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from gzip-compressed files. These scenarios either require loading document from memory, in which case you should prepare a contiguous memory block with all XML data and to pass it to one of buffer loading functions, or loading document from C{plus}{plus} IOstream, in which case you should provide an object which implements `std::istream` or `std::wistream` interface. - -There are different functions for loading document from memory; they treat the passed buffer as either an immutable one (`load_buffer`), a mutable buffer which is owned by the caller (`load_buffer_inplace`), or a mutable buffer which ownership belongs to pugixml (`load_buffer_inplace_own`). There is also a simple helper function, `xml_document::load`, for cases when you want to load the XML document from null-terminated character string. - -This is an example of loading XML document from memory using one of these functions (link:samples/load_memory.cpp[]); read the sample code for more examples: - -[source,indent=0] ----- -include::samples/load_memory.cpp[tags=decl] ----- -[source,indent=0] ----- -include::samples/load_memory.cpp[tags=load_buffer_inplace_begin] - -include::samples/load_memory.cpp[tags=load_buffer_inplace_end] ----- - -This is a simple example of loading XML document from file using streams (link:samples/load_stream.cpp[]); read the sample code for more complex examples involving wide streams and locales: - -[source,indent=0] ----- -include::samples/load_stream.cpp[tags=code] ----- - -[[access]] -== Accessing document data - -pugixml features an extensive interface for getting various types of data from the document and for traversing the document. You can use various accessors to get node/attribute data, you can traverse the child node/attribute lists via accessors or iterators, you can do depth-first traversals with `xml_tree_walker` objects, and you can use XPath for complex data-driven queries. - -You can get node or attribute name via `name()` accessor, and value via `value()` accessor. Note that both functions never return null pointers - they either return a string with the relevant content, or an empty string if name/value is absent or if the handle is null. Also there are two notable things for reading values: - -* It is common to store data as text contents of some node - i.e. `This is a node`. In this case, `` node does not have a value, but instead has a child of type `node_pcdata` with value `"This is a node"`. pugixml provides `child_value()` and `text()` helper functions to parse such data. - -* In many cases attribute values have types that are not strings - i.e. an attribute may always contain values that should be treated as integers, despite the fact that they are represented as strings in XML. pugixml provides several accessors that convert attribute value to some other type. - -This is an example of using these functions (link:samples/traverse_base.cpp[]): - -[source,indent=0] ----- -include::samples/traverse_base.cpp[tags=data] ----- - -Since a lot of document traversal consists of finding the node/attribute with the correct name, there are special functions for that purpose. For example, `child("Tool")` returns the first node which has the name `"Tool"`, or null handle if there is no such node. This is an example of using such functions (link:samples/traverse_base.cpp[]): - -[source,indent=0] ----- -include::samples/traverse_base.cpp[tags=contents] ----- - -Child node lists and attribute lists are simply double-linked lists; while you can use `previous_sibling`/`next_sibling` and other such functions for iteration, pugixml additionally provides node and attribute iterators, so that you can treat nodes as containers of other nodes or attributes. All iterators are bidirectional and support all usual iterator operations. The iterators are invalidated if the node/attribute objects they're pointing to are removed from the tree; adding nodes/attributes does not invalidate any iterators. - -Here is an example of using iterators for document traversal (link:samples/traverse_iter.cpp[]): - -[source,indent=0] ----- -include::samples/traverse_iter.cpp[tags=code] ----- - -If your C{plus}{plus} compiler supports range-based for-loop (this is a C{plus}{plus}11 feature, at the time of writing it's supported by Microsoft Visual Studio 11 Beta, GCC 4.6 and Clang 3.0), you can use it to enumerate nodes/attributes. Additional helpers are provided to support this; note that they are also compatible with http://www.boost.org/libs/foreach/[Boost Foreach], and possibly other pre-C{plus}{plus}11 foreach facilities. - -Here is an example of using C{plus}{plus}11 range-based for loop for document traversal (link:samples/traverse_rangefor.cpp[]): - -[source,indent=0] ----- -include::samples/traverse_rangefor.cpp[tags=code] ----- - -The methods described above allow traversal of immediate children of some node; if you want to do a deep tree traversal, you'll have to do it via a recursive function or some equivalent method. However, pugixml provides a helper for depth-first traversal of a subtree. In order to use it, you have to implement `xml_tree_walker` interface and to call `traverse` function. - -This is an example of traversing tree hierarchy with xml_tree_walker (link:samples/traverse_walker.cpp[]): - -[source,indent=0] ----- -include::samples/traverse_walker.cpp[tags=impl] ----- -[source,indent=0] ----- -include::samples/traverse_walker.cpp[tags=traverse] ----- - -Finally, for complex queries often a higher-level DSL is needed. pugixml provides an implementation of XPath 1.0 language for such queries. The complete description of XPath usage can be found in the manual, but here are some examples: - -[source,indent=0] ----- -include::samples/xpath_select.cpp[tags=code] ----- - -CAUTION: XPath functions throw `xpath_exception` objects on error; the sample above does not catch these exceptions. - -[[modify]] -== Modifying document data - -The document in pugixml is fully mutable: you can completely change the document structure and modify the data of nodes/attributes. All functions take care of memory management and structural integrity themselves, so they always result in structurally valid tree - however, it is possible to create an invalid XML tree (for example, by adding two attributes with the same name or by setting attribute/node name to empty/invalid string). Tree modification is optimized for performance and for memory consumption, so if you have enough memory you can create documents from scratch with pugixml and later save them to file/stream instead of relying on error-prone manual text writing and without too much overhead. - -All member functions that change node/attribute data or structure are non-constant and thus can not be called on constant handles. However, you can easily convert constant handle to non-constant one by simple assignment: `void foo(const pugi::xml_node& n) { pugi::xml_node nc = n; }`, so const-correctness here mainly provides additional documentation. - -As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. You can use `set_name` and `set_value` member functions to set them. Similar functions are available for attributes; however, the `set_value` function is overloaded for some other types except strings, like floating-point numbers. Also, attribute value can be set using an assignment operator. This is an example of setting node/attribute name and value (link:samples/modify_base.cpp[]): - -[source,indent=0] ----- -include::samples/modify_base.cpp[tags=node] ----- -[source,indent=0] ----- -include::samples/modify_base.cpp[tags=attr] ----- - -Nodes and attributes do not exist without a document tree, so you can't create them without adding them to some document. A node or attribute can be created at the end of node/attribute list or before/after some other node. All insertion functions return the handle to newly created object on success, and null handle on failure. Even if the operation fails (for example, if you're trying to add a child node to PCDATA node), the document remains in consistent state, but the requested node/attribute is not added. - -CAUTION: `attribute()` and `child()` functions do not add attributes or nodes to the tree, so code like `node.attribute("id") = 123;` will not do anything if `node` does not have an attribute with name `"id"`. Make sure you're operating with existing attributes/nodes by adding them if necessary. - -This is an example of adding new attributes/nodes to the document (link:samples/modify_add.cpp[]): - -[source,indent=0] ----- -include::samples/modify_add.cpp[tags=code] ----- - -If you do not want your document to contain some node or attribute, you can remove it with `remove_attribute` and `remove_child` functions. Removing the attribute or node invalidates all handles to the same underlying object, and also invalidates all iterators pointing to the same object. Removing node also invalidates all past-the-end iterators to its attribute or child node list. Be careful to ensure that all such handles and iterators either do not exist or are not used after the attribute/node is removed. - -This is an example of removing attributes/nodes from the document (link:samples/modify_remove.cpp[]): - -[source,indent=0] ----- -include::samples/modify_remove.cpp[tags=code] ----- - -[[saving]] -== Saving document - -Often after creating a new document or loading the existing one and processing it, it is necessary to save the result back to file. Also it is occasionally useful to output the whole document or a subtree to some stream; use cases include debug printing, serialization via network or other text-oriented medium, etc. pugixml provides several functions to output any subtree of the document to a file, stream or another generic transport interface; these functions allow to customize the output format, and also perform necessary encoding conversions. - -Before writing to the destination the node/attribute data is properly formatted according to the node type; all special XML symbols, such as < and &, are properly escaped. In order to guard against forgotten node/attribute names, empty node/attribute names are printed as `":anonymous"`. For well-formed output, make sure all node and attribute names are set to meaningful values. - -If you want to save the whole document to a file, you can use the `save_file` function, which returns `true` on success. This is a simple example of saving XML document to file (link:samples/save_file.cpp[]): - -[source,indent=0] ----- -include::samples/save_file.cpp[tags=code] ----- - -To enhance interoperability pugixml provides functions for saving document to any object which implements C{plus}{plus} `std::ostream` interface. This allows you to save documents to any standard C{plus}{plus} stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). Most notably, this allows for easy debug output, since you can use `std::cout` stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones. - -This is a simple example of saving XML document to standard output (link:samples/save_stream.cpp[]): - -[source,indent=0] ----- -include::samples/save_stream.cpp[tags=code] ----- - -All of the above saving functions are implemented in terms of writer interface. This is a simple interface with a single function, which is called several times during output process with chunks of document data as input. In order to output the document via some custom transport, for example sockets, you should create an object which implements `xml_writer_file` interface and pass it to `xml_document::save` function. - -This is a simple example of custom writer for saving document data to STL string (link:samples/save_custom_writer.cpp[]); read the sample code for more complex examples: - -[source,indent=0] ----- -include::samples/save_custom_writer.cpp[tags=code] ----- - -While the previously described functions save the whole document to the destination, it is easy to save a single subtree. Instead of calling `xml_document::save`, just call `xml_node::print` function on the target node. You can save node contents to C{plus}{plus} IOstream object or custom writer in this way. Saving a subtree slightly differs from saving the whole document; link:manual.html#saving.subtree[read the manual] for more information. - -[[feedback]] -== Feedback - -If you believe you've found a bug in pugixml, please file an issue via https://github.com/zeux/pugixml/issues/new[issue submission form]. Be sure to include the relevant information so that the bug can be reproduced: the version of pugixml, compiler version and target architecture, the code that uses pugixml and exhibits the bug, etc. Feature requests and contributions can be filed as issues, too. - -If filing an issue is not possible due to privacy or other concerns, you can contact pugixml author by e-mail directly: arseny.kapoulkine@gmail.com. - -[[license]] -== License - -The pugixml library is distributed under the MIT license: - -.... -Copyright (c) 2006-2019 Arseny Kapoulkine - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. -.... - -This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution: - -.... -This software is based on pugixml library (https://pugixml.org). -pugixml is Copyright (C) 2006-2019 Arseny Kapoulkine. -.... diff --git a/external/pugixml/docs/quickstart.html b/external/pugixml/docs/quickstart.html deleted file mode 100644 index 26173aa52..000000000 --- a/external/pugixml/docs/quickstart.html +++ /dev/null @@ -1,1102 +0,0 @@ - - - - - - - - -pugixml 1.10 quick start guide - - - - - - -
-
-

Introduction

-
-
-

pugixml is a light-weight C++ XML processing library. It consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an XPath 1.0 implementation for complex data-driven tree queries. Full Unicode support is also available, with two Unicode interface variants and conversions between different Unicode encodings (which happen automatically during parsing/saving). The library is extremely portable and easy to integrate and use. pugixml is developed and maintained since 2006 and has many users. All code is distributed under the MIT license, making it completely free to use in both open-source and proprietary applications.

-
-
-

pugixml enables very fast, convenient and memory-efficient XML document processing. However, since pugixml has a DOM parser, it can’t process XML documents that do not fit in memory; also the parser is a non-validating one, so if you need DTD/Schema validation, the library is not for you.

-
-
-

This is the quick start guide for pugixml, which purpose is to enable you to start using the library quickly. Many important library features are either not described at all or only mentioned briefly; for more complete information you should read the complete manual.

-
-
- - - - - -
-
Note
-
-No documentation is perfect; neither is this one. If you find errors or omissions, please don’t hesitate to submit an issue or open a pull request with a fix. -
-
-
-
-
-

Installation

-
-
-

You can download the latest source distribution as an archive:

-
-
-

pugixml-1.10.zip (Windows line endings) -/ -pugixml-1.10.tar.gz (Unix line endings)

-
-
-

The distribution contains library source, documentation (the guide you’re reading now and the manual) and some code examples. After downloading the distribution, install pugixml by extracting all files from the compressed archive.

-
-
-

The complete pugixml source consists of three files - one source file, pugixml.cpp, and two header files, pugixml.hpp and pugiconfig.hpp. pugixml.hpp is the primary header which you need to include in order to use pugixml classes/functions. The rest of this guide assumes that pugixml.hpp is either in the current directory or in one of include directories of your projects, so that #include "pugixml.hpp" can find the header; however you can also use relative path (i.e. #include "../libs/pugixml/src/pugixml.hpp") or include directory-relative path (i.e. #include <xml/thirdparty/pugixml/src/pugixml.hpp>).

-
-
-

The easiest way to build pugixml is to compile the source file, pugixml.cpp, along with the existing library/executable. This process depends on the method of building your application; for example, if you’re using Microsoft Visual Studio [1], Apple Xcode, Code::Blocks or any other IDE, just add pugixml.cpp to one of your projects. There are other building methods available, including building pugixml as a standalone static/shared library; read the manual for further information.

-
-
-
-
-

Document object model

-
-
-

pugixml stores XML data in DOM-like way: the entire XML document (both document structure and element data) is stored in memory as a tree. The tree can be loaded from character stream (file, string, C++ I/O stream), then traversed via special API or XPath expressions. The whole tree is mutable: both node structure and node/attribute data can be changed at any time. Finally, the result of document transformations can be saved to a character stream (file, C++ I/O stream or custom transport).

-
-
-

The root of the tree is the document itself, which corresponds to C++ type xml_document. Document has one or more child nodes, which correspond to C++ type xml_node. Nodes have different types; depending on a type, a node can have a collection of child nodes, a collection of attributes, which correspond to C++ type xml_attribute, and some additional data (i.e. name).

-
-
-

The most common node types are:

-
-
-
    -
  • -

    Document node (node_document) - this is the root of the tree, which consists of several child nodes. This node corresponds to xml_document class; note that xml_document is a sub-class of xml_node, so the entire node interface is also available.

    -
  • -
  • -

    Element/tag node (node_element) - this is the most common type of node, which represents XML elements. Element nodes have a name, a collection of attributes and a collection of child nodes (both of which may be empty). The attribute is a simple name/value pair.

    -
  • -
  • -

    Plain character data nodes (node_pcdata) represent plain text in XML. PCDATA nodes have a value, but do not have name or children/attributes. Note that plain character data is not a part of the element node but instead has its own node; for example, an element node can have several child PCDATA nodes.

    -
  • -
-
-
-

Despite the fact that there are several node types, there are only three C++ types representing the tree (xml_document, xml_node, xml_attribute); some operations on xml_node are only valid for certain node types. They are described below.

-
-
- - - - - -
-
Note
-
-All pugixml classes and functions are located in pugi namespace; you have to either use explicit name qualification (i.e. pugi::xml_node), or to gain access to relevant symbols via using directive (i.e. using pugi::xml_node; or using namespace pugi;). -
-
-
-

xml_document is the owner of the entire document structure; destroying the document destroys the whole tree. The interface of xml_document consists of loading functions, saving functions and the entire interface of xml_node, which allows for document inspection and/or modification. Note that while xml_document is a sub-class of xml_node, xml_node is not a polymorphic type; the inheritance is present only to simplify usage.

-
-
-

xml_node is the handle to document node; it can point to any node in the document, including document itself. There is a common interface for nodes of all types. Note that xml_node is only a handle to the actual node, not the node itself - you can have several xml_node handles pointing to the same underlying object. Destroying xml_node handle does not destroy the node and does not remove it from the tree.

-
-
-

There is a special value of xml_node type, known as null node or empty node. It does not correspond to any node in any document, and thus resembles null pointer. However, all operations are defined on empty nodes; generally the operations don’t do anything and return empty nodes/attributes or empty strings as their result. This is useful for chaining calls; i.e. you can get the grandparent of a node like so: node.parent().parent(); if a node is a null node or it does not have a parent, the first parent() call returns null node; the second parent() call then also returns null node, so you don’t have to check for errors twice. You can test if a handle is null via implicit boolean cast: if (node) { …​ } or if (!node) { …​ }.

-
-
-

xml_attribute is the handle to an XML attribute; it has the same semantics as xml_node, i.e. there can be several xml_attribute handles pointing to the same underlying object and there is a special null attribute value, which propagates to function results.

-
-
-

There are two choices of interface and internal representation when configuring pugixml: you can either choose the UTF-8 (also called char) interface or UTF-16/32 (also called wchar_t) one. The choice is controlled via PUGIXML_WCHAR_MODE define; you can set it via pugiconfig.hpp or via preprocessor options. All tree functions that work with strings work with either C-style null terminated strings or STL strings of the selected character type. Read the manual for additional information on Unicode interface.

-
-
-
-
-

Loading document

-
-
-

pugixml provides several functions for loading XML data from various places - files, C++ iostreams, memory buffers. All functions use an extremely fast non-validating parser. This parser is not fully W3C conformant - it can load any valid XML document, but does not perform some well-formedness checks. While considerable effort is made to reject invalid XML documents, some validation is not performed because of performance reasons. XML data is always converted to internal character format before parsing. pugixml supports all popular Unicode encodings (UTF-8, UTF-16 (big and little endian), UTF-32 (big and little endian); UCS-2 is naturally supported since it’s a strict subset of UTF-16) and handles all encoding conversions automatically.

-
-
-

The most common source of XML data is files; pugixml provides a separate function for loading XML document from file. This function accepts file path as its first argument, and also two optional arguments, which specify parsing options and input data encoding, which are described in the manual.

-
-
-

This is an example of loading XML document from file (samples/load_file.cpp):

-
-
-
-
pugi::xml_document doc;
-
-pugi::xml_parse_result result = doc.load_file("tree.xml");
-
-std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl;
-
-
-
-

load_file, as well as other loading functions, destroys the existing document tree and then tries to load the new tree from the specified file. The result of the operation is returned in an xml_parse_result object; this object contains the operation status, and the related information (i.e. last successfully parsed position in the input file, if parsing fails).

-
-
-

Parsing result object can be implicitly converted to bool; if you do not want to handle parsing errors thoroughly, you can just check the return value of load functions as if it was a bool: if (doc.load_file("file.xml")) { …​ } else { …​ }. Otherwise you can use the status member to get parsing status, or the description() member function to get the status in a string form.

-
-
-

This is an example of handling loading errors (samples/load_error_handling.cpp):

-
-
-
-
pugi::xml_document doc;
-pugi::xml_parse_result result = doc.load_string(source);
-
-if (result)
-{
-    std::cout << "XML [" << source << "] parsed without errors, attr value: [" << doc.child("node").attribute("attr").value() << "]\n\n";
-}
-else
-{
-    std::cout << "XML [" << source << "] parsed with errors, attr value: [" << doc.child("node").attribute("attr").value() << "]\n";
-    std::cout << "Error description: " << result.description() << "\n";
-    std::cout << "Error offset: " << result.offset << " (error at [..." << (source + result.offset) << "]\n\n";
-}
-
-
-
-

Sometimes XML data should be loaded from some other source than file, i.e. HTTP URL; also you may want to load XML data from file using non-standard functions, i.e. to use your virtual file system facilities or to load XML from gzip-compressed files. These scenarios either require loading document from memory, in which case you should prepare a contiguous memory block with all XML data and to pass it to one of buffer loading functions, or loading document from C++ IOstream, in which case you should provide an object which implements std::istream or std::wistream interface.

-
-
-

There are different functions for loading document from memory; they treat the passed buffer as either an immutable one (load_buffer), a mutable buffer which is owned by the caller (load_buffer_inplace), or a mutable buffer which ownership belongs to pugixml (load_buffer_inplace_own). There is also a simple helper function, xml_document::load, for cases when you want to load the XML document from null-terminated character string.

-
-
-

This is an example of loading XML document from memory using one of these functions (samples/load_memory.cpp); read the sample code for more examples:

-
-
-
-
const char source[] = "<mesh name='sphere'><bounds>0 0 1 1</bounds></mesh>";
-size_t size = sizeof(source);
-
-
-
-
-
// You can use load_buffer_inplace to load document from mutable memory block; the block's lifetime must exceed that of document
-char* buffer = new char[size];
-memcpy(buffer, source, size);
-
-// The block can be allocated by any method; the block is modified during parsing
-pugi::xml_parse_result result = doc.load_buffer_inplace(buffer, size);
-
-// You have to destroy the block yourself after the document is no longer used
-delete[] buffer;
-
-
-
-

This is a simple example of loading XML document from file using streams (samples/load_stream.cpp); read the sample code for more complex examples involving wide streams and locales:

-
-
-
-
std::ifstream stream("weekly-utf-8.xml");
-pugi::xml_parse_result result = doc.load(stream);
-
-
-
-
-
-

Accessing document data

-
-
-

pugixml features an extensive interface for getting various types of data from the document and for traversing the document. You can use various accessors to get node/attribute data, you can traverse the child node/attribute lists via accessors or iterators, you can do depth-first traversals with xml_tree_walker objects, and you can use XPath for complex data-driven queries.

-
-
-

You can get node or attribute name via name() accessor, and value via value() accessor. Note that both functions never return null pointers - they either return a string with the relevant content, or an empty string if name/value is absent or if the handle is null. Also there are two notable things for reading values:

-
-
-
    -
  • -

    It is common to store data as text contents of some node - i.e. <node><description>This is a node</description></node>. In this case, <description> node does not have a value, but instead has a child of type node_pcdata with value "This is a node". pugixml provides child_value() and text() helper functions to parse such data.

    -
  • -
  • -

    In many cases attribute values have types that are not strings - i.e. an attribute may always contain values that should be treated as integers, despite the fact that they are represented as strings in XML. pugixml provides several accessors that convert attribute value to some other type.

    -
  • -
-
-
-

This is an example of using these functions (samples/traverse_base.cpp):

-
-
-
-
for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool"))
-{
-    std::cout << "Tool " << tool.attribute("Filename").value();
-    std::cout << ": AllowRemote " << tool.attribute("AllowRemote").as_bool();
-    std::cout << ", Timeout " << tool.attribute("Timeout").as_int();
-    std::cout << ", Description '" << tool.child_value("Description") << "'\n";
-}
-
-
-
-

Since a lot of document traversal consists of finding the node/attribute with the correct name, there are special functions for that purpose. For example, child("Tool") returns the first node which has the name "Tool", or null handle if there is no such node. This is an example of using such functions (samples/traverse_base.cpp):

-
-
-
-
std::cout << "Tool for *.dae generation: " << tools.find_child_by_attribute("Tool", "OutputFileMasks", "*.dae").attribute("Filename").value() << "\n";
-
-for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool"))
-{
-    std::cout << "Tool " << tool.attribute("Filename").value() << "\n";
-}
-
-
-
-

Child node lists and attribute lists are simply double-linked lists; while you can use previous_sibling/next_sibling and other such functions for iteration, pugixml additionally provides node and attribute iterators, so that you can treat nodes as containers of other nodes or attributes. All iterators are bidirectional and support all usual iterator operations. The iterators are invalidated if the node/attribute objects they’re pointing to are removed from the tree; adding nodes/attributes does not invalidate any iterators.

-
-
-

Here is an example of using iterators for document traversal (samples/traverse_iter.cpp):

-
-
-
-
for (pugi::xml_node_iterator it = tools.begin(); it != tools.end(); ++it)
-{
-    std::cout << "Tool:";
-
-    for (pugi::xml_attribute_iterator ait = it->attributes_begin(); ait != it->attributes_end(); ++ait)
-    {
-        std::cout << " " << ait->name() << "=" << ait->value();
-    }
-
-    std::cout << std::endl;
-}
-
-
-
-

If your C++ compiler supports range-based for-loop (this is a C++11 feature, at the time of writing it’s supported by Microsoft Visual Studio 11 Beta, GCC 4.6 and Clang 3.0), you can use it to enumerate nodes/attributes. Additional helpers are provided to support this; note that they are also compatible with Boost Foreach, and possibly other pre-C++11 foreach facilities.

-
-
-

Here is an example of using C++11 range-based for loop for document traversal (samples/traverse_rangefor.cpp):

-
-
-
-
for (pugi::xml_node tool: tools.children("Tool"))
-{
-    std::cout << "Tool:";
-
-    for (pugi::xml_attribute attr: tool.attributes())
-    {
-        std::cout << " " << attr.name() << "=" << attr.value();
-    }
-
-    for (pugi::xml_node child: tool.children())
-    {
-        std::cout << ", child " << child.name();
-    }
-
-    std::cout << std::endl;
-}
-
-
-
-

The methods described above allow traversal of immediate children of some node; if you want to do a deep tree traversal, you’ll have to do it via a recursive function or some equivalent method. However, pugixml provides a helper for depth-first traversal of a subtree. In order to use it, you have to implement xml_tree_walker interface and to call traverse function.

-
-
-

This is an example of traversing tree hierarchy with xml_tree_walker (samples/traverse_walker.cpp):

-
-
-
-
struct simple_walker: pugi::xml_tree_walker
-{
-    virtual bool for_each(pugi::xml_node& node)
-    {
-        for (int i = 0; i < depth(); ++i) std::cout << "  "; // indentation
-
-        std::cout << node_types[node.type()] << ": name='" << node.name() << "', value='" << node.value() << "'\n";
-
-        return true; // continue traversal
-    }
-};
-
-
-
-
-
simple_walker walker;
-doc.traverse(walker);
-
-
-
-

Finally, for complex queries often a higher-level DSL is needed. pugixml provides an implementation of XPath 1.0 language for such queries. The complete description of XPath usage can be found in the manual, but here are some examples:

-
-
-
-
pugi::xpath_node_set tools = doc.select_nodes("/Profile/Tools/Tool[@AllowRemote='true' and @DeriveCaptionFrom='lastparam']");
-
-std::cout << "Tools:\n";
-
-for (pugi::xpath_node_set::const_iterator it = tools.begin(); it != tools.end(); ++it)
-{
-    pugi::xpath_node node = *it;
-    std::cout << node.node().attribute("Filename").value() << "\n";
-}
-
-pugi::xpath_node build_tool = doc.select_node("//Tool[contains(Description, 'build system')]");
-
-if (build_tool)
-    std::cout << "Build tool: " << build_tool.node().attribute("Filename").value() << "\n";
-
-
-
- - - - - -
-
Caution
-
-XPath functions throw xpath_exception objects on error; the sample above does not catch these exceptions. -
-
-
-
-
-

Modifying document data

-
-
-

The document in pugixml is fully mutable: you can completely change the document structure and modify the data of nodes/attributes. All functions take care of memory management and structural integrity themselves, so they always result in structurally valid tree - however, it is possible to create an invalid XML tree (for example, by adding two attributes with the same name or by setting attribute/node name to empty/invalid string). Tree modification is optimized for performance and for memory consumption, so if you have enough memory you can create documents from scratch with pugixml and later save them to file/stream instead of relying on error-prone manual text writing and without too much overhead.

-
-
-

All member functions that change node/attribute data or structure are non-constant and thus can not be called on constant handles. However, you can easily convert constant handle to non-constant one by simple assignment: void foo(const pugi::xml_node& n) { pugi::xml_node nc = n; }, so const-correctness here mainly provides additional documentation.

-
-
-

As discussed before, nodes can have name and value, both of which are strings. Depending on node type, name or value may be absent. You can use set_name and set_value member functions to set them. Similar functions are available for attributes; however, the set_value function is overloaded for some other types except strings, like floating-point numbers. Also, attribute value can be set using an assignment operator. This is an example of setting node/attribute name and value (samples/modify_base.cpp):

-
-
-
-
pugi::xml_node node = doc.child("node");
-
-// change node name
-std::cout << node.set_name("notnode");
-std::cout << ", new node name: " << node.name() << std::endl;
-
-// change comment text
-std::cout << doc.last_child().set_value("useless comment");
-std::cout << ", new comment text: " << doc.last_child().value() << std::endl;
-
-// we can't change value of the element or name of the comment
-std::cout << node.set_value("1") << ", " << doc.last_child().set_name("2") << std::endl;
-
-
-
-
-
pugi::xml_attribute attr = node.attribute("id");
-
-// change attribute name/value
-std::cout << attr.set_name("key") << ", " << attr.set_value("345");
-std::cout << ", new attribute: " << attr.name() << "=" << attr.value() << std::endl;
-
-// we can use numbers or booleans
-attr.set_value(1.234);
-std::cout << "new attribute value: " << attr.value() << std::endl;
-
-// we can also use assignment operators for more concise code
-attr = true;
-std::cout << "final attribute value: " << attr.value() << std::endl;
-
-
-
-

Nodes and attributes do not exist without a document tree, so you can’t create them without adding them to some document. A node or attribute can be created at the end of node/attribute list or before/after some other node. All insertion functions return the handle to newly created object on success, and null handle on failure. Even if the operation fails (for example, if you’re trying to add a child node to PCDATA node), the document remains in consistent state, but the requested node/attribute is not added.

-
-
- - - - - -
-
Caution
-
-attribute() and child() functions do not add attributes or nodes to the tree, so code like node.attribute("id") = 123; will not do anything if node does not have an attribute with name "id". Make sure you’re operating with existing attributes/nodes by adding them if necessary. -
-
-
-

This is an example of adding new attributes/nodes to the document (samples/modify_add.cpp):

-
-
-
-
// add node with some name
-pugi::xml_node node = doc.append_child("node");
-
-// add description node with text child
-pugi::xml_node descr = node.append_child("description");
-descr.append_child(pugi::node_pcdata).set_value("Simple node");
-
-// add param node before the description
-pugi::xml_node param = node.insert_child_before("param", descr);
-
-// add attributes to param node
-param.append_attribute("name") = "version";
-param.append_attribute("value") = 1.1;
-param.insert_attribute_after("type", param.attribute("name")) = "float";
-
-
-
-

If you do not want your document to contain some node or attribute, you can remove it with remove_attribute and remove_child functions. Removing the attribute or node invalidates all handles to the same underlying object, and also invalidates all iterators pointing to the same object. Removing node also invalidates all past-the-end iterators to its attribute or child node list. Be careful to ensure that all such handles and iterators either do not exist or are not used after the attribute/node is removed.

-
-
-

This is an example of removing attributes/nodes from the document (samples/modify_remove.cpp):

-
-
-
-
// remove description node with the whole subtree
-pugi::xml_node node = doc.child("node");
-node.remove_child("description");
-
-// remove id attribute
-pugi::xml_node param = node.child("param");
-param.remove_attribute("value");
-
-// we can also remove nodes/attributes by handles
-pugi::xml_attribute id = param.attribute("name");
-param.remove_attribute(id);
-
-
-
-
-
-

Saving document

-
-
-

Often after creating a new document or loading the existing one and processing it, it is necessary to save the result back to file. Also it is occasionally useful to output the whole document or a subtree to some stream; use cases include debug printing, serialization via network or other text-oriented medium, etc. pugixml provides several functions to output any subtree of the document to a file, stream or another generic transport interface; these functions allow to customize the output format, and also perform necessary encoding conversions.

-
-
-

Before writing to the destination the node/attribute data is properly formatted according to the node type; all special XML symbols, such as < and &, are properly escaped. In order to guard against forgotten node/attribute names, empty node/attribute names are printed as ":anonymous". For well-formed output, make sure all node and attribute names are set to meaningful values.

-
-
-

If you want to save the whole document to a file, you can use the save_file function, which returns true on success. This is a simple example of saving XML document to file (samples/save_file.cpp):

-
-
-
-
// save document to file
-std::cout << "Saving result: " << doc.save_file("save_file_output.xml") << std::endl;
-
-
-
-

To enhance interoperability pugixml provides functions for saving document to any object which implements C++ std::ostream interface. This allows you to save documents to any standard C++ stream (i.e. file stream) or any third-party compliant implementation (i.e. Boost Iostreams). Most notably, this allows for easy debug output, since you can use std::cout stream as saving target. There are two functions, one works with narrow character streams, another handles wide character ones.

-
-
-

This is a simple example of saving XML document to standard output (samples/save_stream.cpp):

-
-
-
-
// save document to standard output
-std::cout << "Document:\n";
-doc.save(std::cout);
-
-
-
-

All of the above saving functions are implemented in terms of writer interface. This is a simple interface with a single function, which is called several times during output process with chunks of document data as input. In order to output the document via some custom transport, for example sockets, you should create an object which implements xml_writer_file interface and pass it to xml_document::save function.

-
-
-

This is a simple example of custom writer for saving document data to STL string (samples/save_custom_writer.cpp); read the sample code for more complex examples:

-
-
-
-
struct xml_string_writer: pugi::xml_writer
-{
-    std::string result;
-
-    virtual void write(const void* data, size_t size)
-    {
-        result.append(static_cast<const char*>(data), size);
-    }
-};
-
-
-
-

While the previously described functions save the whole document to the destination, it is easy to save a single subtree. Instead of calling xml_document::save, just call xml_node::print function on the target node. You can save node contents to C++ IOstream object or custom writer in this way. Saving a subtree slightly differs from saving the whole document; read the manual for more information.

-
-
-
-
-

Feedback

-
-
-

If you believe you’ve found a bug in pugixml, please file an issue via issue submission form. Be sure to include the relevant information so that the bug can be reproduced: the version of pugixml, compiler version and target architecture, the code that uses pugixml and exhibits the bug, etc. Feature requests and contributions can be filed as issues, too.

-
-
-

If filing an issue is not possible due to privacy or other concerns, you can contact pugixml author by e-mail directly: arseny.kapoulkine@gmail.com.

-
-
-
-
-

License

-
-
-

The pugixml library is distributed under the MIT license:

-
-
-
-
Copyright (c) 2006-2019 Arseny Kapoulkine
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-
-
-

This means that you can freely use pugixml in your applications, both open-source and proprietary. If you use pugixml in a product, it is sufficient to add an acknowledgment like this to the product distribution:

-
-
-
-
This software is based on pugixml library (https://pugixml.org).
-pugixml is Copyright (C) 2006-2019 Arseny Kapoulkine.
-
-
-
-
-
-
-
-
-1. All trademarks used are properties of their respective owners. -
-
- - - \ No newline at end of file diff --git a/external/pugixml/docs/samples/character.xml b/external/pugixml/docs/samples/character.xml deleted file mode 100644 index 078e0bf80..000000000 --- a/external/pugixml/docs/samples/character.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/external/pugixml/docs/samples/custom_memory_management.cpp b/external/pugixml/docs/samples/custom_memory_management.cpp deleted file mode 100644 index 2cb5520ea..000000000 --- a/external/pugixml/docs/samples/custom_memory_management.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "pugixml.hpp" - -#include - -// tag::decl[] -void* custom_allocate(size_t size) -{ - return new (std::nothrow) char[size]; -} - -void custom_deallocate(void* ptr) -{ - delete[] static_cast(ptr); -} -// end::decl[] - -int main() -{ -// tag::call[] - pugi::set_memory_management_functions(custom_allocate, custom_deallocate); -// end::call[] - - pugi::xml_document doc; - doc.load_string(""); -} - -// vim:et diff --git a/external/pugixml/docs/samples/include.cpp b/external/pugixml/docs/samples/include.cpp deleted file mode 100644 index 84f9dd0e1..000000000 --- a/external/pugixml/docs/samples/include.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "pugixml.hpp" - -#include -#include - -// tag::code[] -bool load_preprocess(pugi::xml_document& doc, const char* path); - -bool preprocess(pugi::xml_node node) -{ - for (pugi::xml_node child = node.first_child(); child; ) - { - if (child.type() == pugi::node_pi && strcmp(child.name(), "include") == 0) - { - pugi::xml_node include = child; - - // load new preprocessed document (note: ideally this should handle relative paths) - const char* path = include.value(); - - pugi::xml_document doc; - if (!load_preprocess(doc, path)) return false; - - // insert the comment marker above include directive - node.insert_child_before(pugi::node_comment, include).set_value(path); - - // copy the document above the include directive (this retains the original order!) - for (pugi::xml_node ic = doc.first_child(); ic; ic = ic.next_sibling()) - { - node.insert_copy_before(ic, include); - } - - // remove the include node and move to the next child - child = child.next_sibling(); - - node.remove_child(include); - } - else - { - if (!preprocess(child)) return false; - - child = child.next_sibling(); - } - } - - return true; -} - -bool load_preprocess(pugi::xml_document& doc, const char* path) -{ - pugi::xml_parse_result result = doc.load_file(path, pugi::parse_default | pugi::parse_pi); // for - - return result ? preprocess(doc) : false; -} -// end::code[] - -int main() -{ - pugi::xml_document doc; - if (!load_preprocess(doc, "character.xml")) return -1; - - doc.print(std::cout); -} - -// vim:et diff --git a/external/pugixml/docs/samples/load_error_handling.cpp b/external/pugixml/docs/samples/load_error_handling.cpp deleted file mode 100644 index d1e5a4933..000000000 --- a/external/pugixml/docs/samples/load_error_handling.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "pugixml.hpp" - -#include - -void check_xml(const char* source) -{ -// tag::code[] - pugi::xml_document doc; - pugi::xml_parse_result result = doc.load_string(source); - - if (result) - { - std::cout << "XML [" << source << "] parsed without errors, attr value: [" << doc.child("node").attribute("attr").value() << "]\n\n"; - } - else - { - std::cout << "XML [" << source << "] parsed with errors, attr value: [" << doc.child("node").attribute("attr").value() << "]\n"; - std::cout << "Error description: " << result.description() << "\n"; - std::cout << "Error offset: " << result.offset << " (error at [..." << (source + result.offset) << "]\n\n"; - } -// end::code[] -} - -int main() -{ - check_xml("text"); - check_xml("text"); - check_xml("text"); - check_xml("<#tag />"); -} - -// vim:et diff --git a/external/pugixml/docs/samples/load_file.cpp b/external/pugixml/docs/samples/load_file.cpp deleted file mode 100644 index 8b2191bf1..000000000 --- a/external/pugixml/docs/samples/load_file.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ -// tag::code[] - pugi::xml_document doc; - - pugi::xml_parse_result result = doc.load_file("tree.xml"); - - std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl; -// end::code[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/load_memory.cpp b/external/pugixml/docs/samples/load_memory.cpp deleted file mode 100644 index 80bba3cdb..000000000 --- a/external/pugixml/docs/samples/load_memory.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "pugixml.hpp" - -#include -#include - -int main() -{ -// tag::decl[] - const char source[] = "0 0 1 1"; - size_t size = sizeof(source); -// end::decl[] - - pugi::xml_document doc; - - { - // tag::load_buffer[] - // You can use load_buffer to load document from immutable memory block: - pugi::xml_parse_result result = doc.load_buffer(source, size); - // end::load_buffer[] - - std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl; - } - - { - // tag::load_buffer_inplace_begin[] - // You can use load_buffer_inplace to load document from mutable memory block; the block's lifetime must exceed that of document - char* buffer = new char[size]; - memcpy(buffer, source, size); - - // The block can be allocated by any method; the block is modified during parsing - pugi::xml_parse_result result = doc.load_buffer_inplace(buffer, size); - // end::load_buffer_inplace_begin[] - - std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl; - - // tag::load_buffer_inplace_end[] - // You have to destroy the block yourself after the document is no longer used - delete[] buffer; - // end::load_buffer_inplace_end[] - } - - { - // tag::load_buffer_inplace_own[] - // You can use load_buffer_inplace_own to load document from mutable memory block and to pass the ownership of this block - // The block has to be allocated via pugixml allocation function - using i.e. operator new here is incorrect - char* buffer = static_cast(pugi::get_memory_allocation_function()(size)); - memcpy(buffer, source, size); - - // The block will be deleted by the document - pugi::xml_parse_result result = doc.load_buffer_inplace_own(buffer, size); - // end::load_buffer_inplace_own[] - - std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl; - } - - { - // tag::load_string[] - // You can use load to load document from null-terminated strings, for example literals: - pugi::xml_parse_result result = doc.load_string("0 0 1 1"); - // end::load_string[] - - std::cout << "Load result: " << result.description() << ", mesh name: " << doc.child("mesh").attribute("name").value() << std::endl; - } -} - -// vim:et diff --git a/external/pugixml/docs/samples/load_options.cpp b/external/pugixml/docs/samples/load_options.cpp deleted file mode 100644 index b7b0a6b60..000000000 --- a/external/pugixml/docs/samples/load_options.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ - pugi::xml_document doc; - -// tag::code[] - const char* source = "<"; - - // Parsing with default options; note that comment node is not added to the tree, and entity reference < is expanded - doc.load_string(source); - std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n"; - - // Parsing with additional parse_comments option; comment node is now added to the tree - doc.load_string(source, pugi::parse_default | pugi::parse_comments); - std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n"; - - // Parsing with additional parse_comments option and without the (default) parse_escapes option; < is not expanded - doc.load_string(source, (pugi::parse_default | pugi::parse_comments) & ~pugi::parse_escapes); - std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n"; - - // Parsing with minimal option mask; comment node is not added to the tree, and < is not expanded - doc.load_string(source, pugi::parse_minimal); - std::cout << "First node value: [" << doc.first_child().value() << "], node child value: [" << doc.child_value("node") << "]\n"; -// end::code[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/load_stream.cpp b/external/pugixml/docs/samples/load_stream.cpp deleted file mode 100644 index f982a8317..000000000 --- a/external/pugixml/docs/samples/load_stream.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "pugixml.hpp" - -#include -#include -#include - -void print_doc(const char* message, const pugi::xml_document& doc, const pugi::xml_parse_result& result) -{ - std::cout - << message - << "\t: load result '" << result.description() << "'" - << ", first character of root name: U+" << std::hex << std::uppercase << std::setw(4) << std::setfill('0') << pugi::as_wide(doc.first_child().name())[0] - << ", year: " << doc.first_child().first_child().first_child().child_value() - << std::endl; -} - -bool try_imbue(std::wistream& stream, const char* name) -{ - try - { - stream.imbue(std::locale(name)); - - return true; - } - catch (const std::exception&) - { - return false; - } -} - -int main() -{ - pugi::xml_document doc; - - { - // tag::code[] - std::ifstream stream("weekly-utf-8.xml"); - pugi::xml_parse_result result = doc.load(stream); - // end::code[] - - // first character of root name: U+9031, year: 1997 - print_doc("UTF8 file from narrow stream", doc, result); - } - - { - std::ifstream stream("weekly-utf-16.xml"); - pugi::xml_parse_result result = doc.load(stream); - - // first character of root name: U+9031, year: 1997 - print_doc("UTF16 file from narrow stream", doc, result); - } - - { - // Since wide streams are treated as UTF-16/32 ones, you can't load the UTF-8 file from a wide stream - // directly if you have localized characters; you'll have to provide a UTF8 locale (there is no - // standard one; you can use utf8_codecvt_facet from Boost or codecvt_utf8 from C++0x) - std::wifstream stream("weekly-utf-8.xml"); - - if (try_imbue(stream, "en_US.UTF-8")) // try Linux encoding - { - pugi::xml_parse_result result = doc.load(stream); - - // first character of root name: U+00E9, year: 1997 - print_doc("UTF8 file from wide stream", doc, result); - } - else - { - std::cout << "UTF-8 locale is not available\n"; - } - } - - { - // Since wide streams are treated as UTF-16/32 ones, you can't load the UTF-16 file from a wide stream without - // using custom codecvt; you can use codecvt_utf16 from C++0x - } - - { - // Since encoding names are non-standard, you can't load the Shift-JIS (or any other non-ASCII) file - // from a wide stream portably - std::wifstream stream("weekly-shift_jis.xml"); - - if (try_imbue(stream, ".932") || // try Microsoft encoding - try_imbue(stream, "ja_JP.SJIS")) // try Linux encoding; run "localedef -i ja_JP -c -f SHIFT_JIS /usr/lib/locale/ja_JP.SJIS" to get it - { - pugi::xml_parse_result result = doc.load(stream); - - // first character of root name: U+9031, year: 1997 - print_doc("Shift-JIS file from wide stream", doc, result); - } - else - { - std::cout << "Shift-JIS locale is not available\n"; - } - } -} - -// vim:et diff --git a/external/pugixml/docs/samples/modify_add.cpp b/external/pugixml/docs/samples/modify_add.cpp deleted file mode 100644 index a2ddd31b7..000000000 --- a/external/pugixml/docs/samples/modify_add.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ - pugi::xml_document doc; - - // tag::code[] - // add node with some name - pugi::xml_node node = doc.append_child("node"); - - // add description node with text child - pugi::xml_node descr = node.append_child("description"); - descr.append_child(pugi::node_pcdata).set_value("Simple node"); - - // add param node before the description - pugi::xml_node param = node.insert_child_before("param", descr); - - // add attributes to param node - param.append_attribute("name") = "version"; - param.append_attribute("value") = 1.1; - param.insert_attribute_after("type", param.attribute("name")) = "float"; - // end::code[] - - doc.print(std::cout); -} - -// vim:et diff --git a/external/pugixml/docs/samples/modify_base.cpp b/external/pugixml/docs/samples/modify_base.cpp deleted file mode 100644 index 7c4819b32..000000000 --- a/external/pugixml/docs/samples/modify_base.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "pugixml.hpp" - -#include -#include - -int main() -{ - pugi::xml_document doc; - if (!doc.load_string("text", pugi::parse_default | pugi::parse_comments)) return -1; - - // tag::node[] - pugi::xml_node node = doc.child("node"); - - // change node name - std::cout << node.set_name("notnode"); - std::cout << ", new node name: " << node.name() << std::endl; - - // change comment text - std::cout << doc.last_child().set_value("useless comment"); - std::cout << ", new comment text: " << doc.last_child().value() << std::endl; - - // we can't change value of the element or name of the comment - std::cout << node.set_value("1") << ", " << doc.last_child().set_name("2") << std::endl; - // end::node[] - - // tag::attr[] - pugi::xml_attribute attr = node.attribute("id"); - - // change attribute name/value - std::cout << attr.set_name("key") << ", " << attr.set_value("345"); - std::cout << ", new attribute: " << attr.name() << "=" << attr.value() << std::endl; - - // we can use numbers or booleans - attr.set_value(1.234); - std::cout << "new attribute value: " << attr.value() << std::endl; - - // we can also use assignment operators for more concise code - attr = true; - std::cout << "final attribute value: " << attr.value() << std::endl; - // end::attr[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/modify_remove.cpp b/external/pugixml/docs/samples/modify_remove.cpp deleted file mode 100644 index d54c0d8d0..000000000 --- a/external/pugixml/docs/samples/modify_remove.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ - pugi::xml_document doc; - if (!doc.load_string("Simple node")) return -1; - - // tag::code[] - // remove description node with the whole subtree - pugi::xml_node node = doc.child("node"); - node.remove_child("description"); - - // remove id attribute - pugi::xml_node param = node.child("param"); - param.remove_attribute("value"); - - // we can also remove nodes/attributes by handles - pugi::xml_attribute id = param.attribute("name"); - param.remove_attribute(id); - // end::code[] - - doc.print(std::cout); -} - -// vim:et diff --git a/external/pugixml/docs/samples/save_custom_writer.cpp b/external/pugixml/docs/samples/save_custom_writer.cpp deleted file mode 100644 index e777a32da..000000000 --- a/external/pugixml/docs/samples/save_custom_writer.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "pugixml.hpp" - -#include -#include -#include - -// tag::code[] -struct xml_string_writer: pugi::xml_writer -{ - std::string result; - - virtual void write(const void* data, size_t size) - { - result.append(static_cast(data), size); - } -}; -// end::code[] - -struct xml_memory_writer: pugi::xml_writer -{ - char* buffer; - size_t capacity; - - size_t result; - - xml_memory_writer(): buffer(0), capacity(0), result(0) - { - } - - xml_memory_writer(char* buffer, size_t capacity): buffer(buffer), capacity(capacity), result(0) - { - } - - size_t written_size() const - { - return result < capacity ? result : capacity; - } - - virtual void write(const void* data, size_t size) - { - if (result < capacity) - { - size_t chunk = (capacity - result < size) ? capacity - result : size; - - memcpy(buffer + result, data, chunk); - } - - result += size; - } -}; - -std::string node_to_string(pugi::xml_node node) -{ - xml_string_writer writer; - node.print(writer); - - return writer.result; -} - -char* node_to_buffer(pugi::xml_node node, char* buffer, size_t size) -{ - if (size == 0) return buffer; - - // leave one character for null terminator - xml_memory_writer writer(buffer, size - 1); - node.print(writer); - - // null terminate - buffer[writer.written_size()] = 0; - - return buffer; -} - -char* node_to_buffer_heap(pugi::xml_node node) -{ - // first pass: get required memory size - xml_memory_writer counter; - node.print(counter); - - // allocate necessary size (+1 for null termination) - char* buffer = new char[counter.result + 1]; - - // second pass: actual printing - xml_memory_writer writer(buffer, counter.result); - node.print(writer); - - // null terminate - buffer[writer.written_size()] = 0; - - return buffer; -} - -int main() -{ - // get a test document - pugi::xml_document doc; - doc.load_string("hey"); - - // get contents as std::string (single pass) - std::cout << "contents: [" << node_to_string(doc) << "]\n"; - - // get contents into fixed-size buffer (single pass) - char large_buf[128]; - std::cout << "contents: [" << node_to_buffer(doc, large_buf, sizeof(large_buf)) << "]\n"; - - // get contents into fixed-size buffer (single pass, shows truncating behavior) - char small_buf[22]; - std::cout << "contents: [" << node_to_buffer(doc, small_buf, sizeof(small_buf)) << "]\n"; - - // get contents into heap-allocated buffer (two passes) - char* heap_buf = node_to_buffer_heap(doc); - std::cout << "contents: [" << heap_buf << "]\n"; - delete[] heap_buf; -} - -// vim:et diff --git a/external/pugixml/docs/samples/save_declaration.cpp b/external/pugixml/docs/samples/save_declaration.cpp deleted file mode 100644 index ca98dcbb2..000000000 --- a/external/pugixml/docs/samples/save_declaration.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ - // tag::code[] - // get a test document - pugi::xml_document doc; - doc.load_string("hey"); - - // add a custom declaration node - pugi::xml_node decl = doc.prepend_child(pugi::node_declaration); - decl.append_attribute("version") = "1.0"; - decl.append_attribute("encoding") = "UTF-8"; - decl.append_attribute("standalone") = "no"; - - // - // - // hey - // - doc.save(std::cout); - std::cout << std::endl; - // end::code[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/save_file.cpp b/external/pugixml/docs/samples/save_file.cpp deleted file mode 100644 index 10c610407..000000000 --- a/external/pugixml/docs/samples/save_file.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ - // get a test document - pugi::xml_document doc; - doc.load_string("hey"); - - // tag::code[] - // save document to file - std::cout << "Saving result: " << doc.save_file("save_file_output.xml") << std::endl; - // end::code[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/save_options.cpp b/external/pugixml/docs/samples/save_options.cpp deleted file mode 100644 index e19694699..000000000 --- a/external/pugixml/docs/samples/save_options.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ - // tag::code[] - // get a test document - pugi::xml_document doc; - doc.load_string("hey"); - - // default options; prints - // - // - // hey - // - doc.save(std::cout); - std::cout << std::endl; - - // default options with custom indentation string; prints - // - // - // --hey - // - doc.save(std::cout, "--"); - std::cout << std::endl; - - // default options without indentation; prints - // - // - // hey - // - doc.save(std::cout, "\t", pugi::format_default & ~pugi::format_indent); // can also pass "" instead of indentation string for the same effect - std::cout << std::endl; - - // raw output; prints - // hey - doc.save(std::cout, "\t", pugi::format_raw); - std::cout << std::endl << std::endl; - - // raw output without declaration; prints - // hey - doc.save(std::cout, "\t", pugi::format_raw | pugi::format_no_declaration); - std::cout << std::endl; - // end::code[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/save_stream.cpp b/external/pugixml/docs/samples/save_stream.cpp deleted file mode 100644 index 84a33bf0f..000000000 --- a/external/pugixml/docs/samples/save_stream.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ - // get a test document - pugi::xml_document doc; - doc.load_string("hey"); - - // tag::code[] - // save document to standard output - std::cout << "Document:\n"; - doc.save(std::cout); - // end::code[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/save_subtree.cpp b/external/pugixml/docs/samples/save_subtree.cpp deleted file mode 100644 index 5ae4830aa..000000000 --- a/external/pugixml/docs/samples/save_subtree.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ - // tag::code[] - // get a test document - pugi::xml_document doc; - doc.load_string("hey"); - - // print document to standard output (prints hey) - doc.save(std::cout, "", pugi::format_raw); - std::cout << std::endl; - - // print document to standard output as a regular node (prints hey) - doc.print(std::cout, "", pugi::format_raw); - std::cout << std::endl; - - // print a subtree to standard output (prints hey) - doc.child("foo").child("call").print(std::cout, "", pugi::format_raw); - std::cout << std::endl; - // end::code[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/text.cpp b/external/pugixml/docs/samples/text.cpp deleted file mode 100644 index 0b4bae66a..000000000 --- a/external/pugixml/docs/samples/text.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ - pugi::xml_document doc; - - // get a test document - doc.load_string("test1.1yes"); - - pugi::xml_node project = doc.child("project"); - - // tag::access[] - std::cout << "Project name: " << project.child("name").text().get() << std::endl; - std::cout << "Project version: " << project.child("version").text().as_double() << std::endl; - std::cout << "Project visibility: " << (project.child("public").text().as_bool(/* def= */ true) ? "public" : "private") << std::endl; - std::cout << "Project description: " << project.child("description").text().get() << std::endl; - // end::access[] - - std::cout << std::endl; - - // tag::modify[] - // change project version - project.child("version").text() = 1.2; - - // add description element and set the contents - // note that we do not have to explicitly add the node_pcdata child - project.append_child("description").text().set("a test project"); - // end::modify[] - - doc.save(std::cout); -} - -// vim:et diff --git a/external/pugixml/docs/samples/transitions.xml b/external/pugixml/docs/samples/transitions.xml deleted file mode 100644 index a195ef8e5..000000000 --- a/external/pugixml/docs/samples/transitions.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/external/pugixml/docs/samples/traverse_base.cpp b/external/pugixml/docs/samples/traverse_base.cpp deleted file mode 100644 index 3ee7fe4aa..000000000 --- a/external/pugixml/docs/samples/traverse_base.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "pugixml.hpp" - -#include -#include - -int main() -{ - pugi::xml_document doc; - if (!doc.load_file("xgconsole.xml")) return -1; - - pugi::xml_node tools = doc.child("Profile").child("Tools"); - - // tag::basic[] - for (pugi::xml_node tool = tools.first_child(); tool; tool = tool.next_sibling()) - { - std::cout << "Tool:"; - - for (pugi::xml_attribute attr = tool.first_attribute(); attr; attr = attr.next_attribute()) - { - std::cout << " " << attr.name() << "=" << attr.value(); - } - - std::cout << std::endl; - } - // end::basic[] - - std::cout << std::endl; - - // tag::data[] - for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool")) - { - std::cout << "Tool " << tool.attribute("Filename").value(); - std::cout << ": AllowRemote " << tool.attribute("AllowRemote").as_bool(); - std::cout << ", Timeout " << tool.attribute("Timeout").as_int(); - std::cout << ", Description '" << tool.child_value("Description") << "'\n"; - } - // end::data[] - - std::cout << std::endl; - - // tag::contents[] - std::cout << "Tool for *.dae generation: " << tools.find_child_by_attribute("Tool", "OutputFileMasks", "*.dae").attribute("Filename").value() << "\n"; - - for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool")) - { - std::cout << "Tool " << tool.attribute("Filename").value() << "\n"; - } - // end::contents[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/traverse_iter.cpp b/external/pugixml/docs/samples/traverse_iter.cpp deleted file mode 100644 index 77bcf351c..000000000 --- a/external/pugixml/docs/samples/traverse_iter.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ - pugi::xml_document doc; - if (!doc.load_file("xgconsole.xml")) return -1; - - pugi::xml_node tools = doc.child("Profile").child("Tools"); - - // tag::code[] - for (pugi::xml_node_iterator it = tools.begin(); it != tools.end(); ++it) - { - std::cout << "Tool:"; - - for (pugi::xml_attribute_iterator ait = it->attributes_begin(); ait != it->attributes_end(); ++ait) - { - std::cout << " " << ait->name() << "=" << ait->value(); - } - - std::cout << std::endl; - } - // end::code[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/traverse_predicate.cpp b/external/pugixml/docs/samples/traverse_predicate.cpp deleted file mode 100644 index 40e171807..000000000 --- a/external/pugixml/docs/samples/traverse_predicate.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "pugixml.hpp" - -#include -#include - -// tag::decl[] -bool small_timeout(pugi::xml_node node) -{ - return node.attribute("Timeout").as_int() < 20; -} - -struct allow_remote_predicate -{ - bool operator()(pugi::xml_attribute attr) const - { - return strcmp(attr.name(), "AllowRemote") == 0; - } - - bool operator()(pugi::xml_node node) const - { - return node.attribute("AllowRemote").as_bool(); - } -}; -// end::decl[] - -int main() -{ - pugi::xml_document doc; - if (!doc.load_file("xgconsole.xml")) return -1; - - pugi::xml_node tools = doc.child("Profile").child("Tools"); - - // tag::find[] - // Find child via predicate (looks for direct children only) - std::cout << tools.find_child(allow_remote_predicate()).attribute("Filename").value() << std::endl; - - // Find node via predicate (looks for all descendants in depth-first order) - std::cout << doc.find_node(allow_remote_predicate()).attribute("Filename").value() << std::endl; - - // Find attribute via predicate - std::cout << tools.last_child().find_attribute(allow_remote_predicate()).value() << std::endl; - - // We can use simple functions instead of function objects - std::cout << tools.find_child(small_timeout).attribute("Filename").value() << std::endl; - // end::find[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/traverse_rangefor.cpp b/external/pugixml/docs/samples/traverse_rangefor.cpp deleted file mode 100644 index 8d9d7d50b..000000000 --- a/external/pugixml/docs/samples/traverse_rangefor.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ - pugi::xml_document doc; - if (!doc.load_file("xgconsole.xml")) return -1; - - pugi::xml_node tools = doc.child("Profile").child("Tools"); - - // tag::code[] - for (pugi::xml_node tool: tools.children("Tool")) - { - std::cout << "Tool:"; - - for (pugi::xml_attribute attr: tool.attributes()) - { - std::cout << " " << attr.name() << "=" << attr.value(); - } - - for (pugi::xml_node child: tool.children()) - { - std::cout << ", child " << child.name(); - } - - std::cout << std::endl; - } - // end::code[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/traverse_walker.cpp b/external/pugixml/docs/samples/traverse_walker.cpp deleted file mode 100644 index 2f4b11bbe..000000000 --- a/external/pugixml/docs/samples/traverse_walker.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "pugixml.hpp" - -#include - -const char* node_types[] = -{ - "null", "document", "element", "pcdata", "cdata", "comment", "pi", "declaration" -}; - -// tag::impl[] -struct simple_walker: pugi::xml_tree_walker -{ - virtual bool for_each(pugi::xml_node& node) - { - for (int i = 0; i < depth(); ++i) std::cout << " "; // indentation - - std::cout << node_types[node.type()] << ": name='" << node.name() << "', value='" << node.value() << "'\n"; - - return true; // continue traversal - } -}; -// end::impl[] - -int main() -{ - pugi::xml_document doc; - if (!doc.load_file("tree.xml")) return -1; - - // tag::traverse[] - simple_walker walker; - doc.traverse(walker); - // end::traverse[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/tree.xml b/external/pugixml/docs/samples/tree.xml deleted file mode 100644 index b33267afa..000000000 --- a/external/pugixml/docs/samples/tree.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - some text - - some more text - - - - - - diff --git a/external/pugixml/docs/samples/weekly-shift_jis.xml b/external/pugixml/docs/samples/weekly-shift_jis.xml deleted file mode 100644 index 097e37421..000000000 --- a/external/pugixml/docs/samples/weekly-shift_jis.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - 1997 - 1 - 1 - - - <> - <>Rc - <>Y - - - <Ɩ񍐃Xg> - <Ɩ> - <Ɩ>XMLGfB^[̍쐬 - <ƖR[h>X3355-23 - - <ςH>1600 - <эH>320 - <ςH>160 - <эH>24 - - <\荀ڃXg> - <\荀> -

XMLGfB^[̊{dl̍쐬

- - - <{Xg> - <{> -

XMLGfB^[̊{dl̍쐬

- - <{> -

Аi̋@\

- - - <㒷ւ̗vXg> - <㒷ւ̗v> -

ɂȂ

- - - <_΍> -

XMLƂ͉킩ȂB

- - - - <Ɩ> - <Ɩ>GW̊J - <ƖR[h>S8821-76 - - <ςH>120 - <эH>6 - <ςH>32 - <эH>2 - - <\荀ڃXg> - <\荀> -

goő@\𒲂ׂĂ݂

- - - <{Xg> - <{> -

XɁAǂGW邩

- - - <㒷ւ̗vXg> - <㒷ւ̗v> -

Ĵ͂߂ǂȂ̂ŁAYahoo!𔃎ĉB

- - - <_΍> -

GWŎԂ𑖂点邱ƂłȂBivj

- - - -
diff --git a/external/pugixml/docs/samples/weekly-utf-16.xml b/external/pugixml/docs/samples/weekly-utf-16.xml deleted file mode 100644 index 6c8622aa4311bb434668336a57dbdd253eb25a3d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3186 zcmcguOHUI~6h4?>Du&<>Z~-ihg;P*`WGqpEg+MX32&4$nP)d2Uh~*t0xB}{fU`U7? zVoZ#CW0ZvCqA+LqWEVgqMBw)#S+_%ko_OEsFMRphcGLMP+3 zVk!;%kYDh9Ug2LHZ)(4=N94CHtZX()q2WiceTB%aREc#E%S#n_Gd*qnAKvFaMFuDD zC3m`@lE`LK6ODYGXN4VX#J*rG#8otEWa%AVy5cuID}hJ)Ib^Orox!L_iJi`hoGv{Iv@}WZ--R%ghiHa7=h{V-NpQouddUzr(s!X`YF4D^C%{zOuFSqbbsJ&?8DZ~ zrJag09ico+9@JrJwOEbtQsh}6wV1E9Fz1)H`q$N1Xf%0jv>LtL)rs#RPvG6Se|kOi zoa4Qn*VboOqCds#v-L7dc6eG^ZKsSt!NMqyaeQWK_D$}ds@Az`8XD(5?&X$TRcs@! z*csc!YBV=3HViI@Hzv<&5E_ns+{1~cX0GSk_{{)q4e!w61qy9!=oFrG?teqkiMd-# z>I8?z_FgUpgRb#Y{Nf9#kqLohoBSE1!&nvIIWPX1sw~gH$e$()Dh%hW(yqwCRT7Eg z+tuEM9R=&6dKZm0f+LIV>yW8_i2fg0)1c#+cn@wr5!_S6&8G)J%rK z=S3YH=LApj9a(cPzM`Cm+w6Jl0Ws|op1<)VxXLZu9oWsySvkm>sKSOWSj1!%D}5)l zyp}P!j9Eo*z2^CwgJ8`tDhzTDH=wS@G>2|_@SlPyZtl|VP2kgJh0cXB9ny?SAm6&b F{{~s7f^`4@ diff --git a/external/pugixml/docs/samples/weekly-utf-8.xml b/external/pugixml/docs/samples/weekly-utf-8.xml deleted file mode 100644 index d55474e5e..000000000 --- a/external/pugixml/docs/samples/weekly-utf-8.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - -<週報> - <年月週> - <年度>1997 - <月度>1 - <週>1 - - - <氏名> - <氏>山田 - <名>太郎 - - - <業務報告リスト> - <業務報告> - <業務名>XMLエディターの作成 - <業務コード>X3355-23 - <工数管理> - <見積もり工数>1600 - <実績工数>320 - <当月見積もり工数>160 - <当月実績工数>24 - - <予定項目リスト> - <予定項目> -

XMLエディターの基本仕様の作成

- - - <実施事項リスト> - <実施事項> -

XMLエディターの基本仕様の作成

- - <実施事項> -

競合他社製品の機能調査

- - - <上長への要請事項リスト> - <上長への要請事項> -

特になし

- - - <問題点対策> -

XMLとは何かわからない。

- - - - <業務報告> - <業務名>検索エンジンの開発 - <業務コード>S8821-76 - <工数管理> - <見積もり工数>120 - <実績工数>6 - <当月見積もり工数>32 - <当月実績工数>2 - - <予定項目リスト> - <予定項目> -

gooの機能を調べてみる

- - - <実施事項リスト> - <実施事項> -

更に、どういう検索エンジンがあるか調査する

- - - <上長への要請事項リスト> - <上長への要請事項> -

開発をするのはめんどうなので、Yahoo!を買収して下さい。

- - - <問題点対策> -

検索エンジンで車を走らせることができない。(要調査)

- - - - diff --git a/external/pugixml/docs/samples/xgconsole.xml b/external/pugixml/docs/samples/xgconsole.xml deleted file mode 100644 index b2bf5a2de..000000000 --- a/external/pugixml/docs/samples/xgconsole.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - Jamplus build system - - - - - - - diff --git a/external/pugixml/docs/samples/xpath_error.cpp b/external/pugixml/docs/samples/xpath_error.cpp deleted file mode 100644 index b6dc424cc..000000000 --- a/external/pugixml/docs/samples/xpath_error.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ - pugi::xml_document doc; - if (!doc.load_file("xgconsole.xml")) return -1; - -// tag::code[] - // Exception is thrown for incorrect query syntax - try - { - doc.select_nodes("//nodes[#true()]"); - } - catch (const pugi::xpath_exception& e) - { - std::cout << "Select failed: " << e.what() << std::endl; - } - - // Exception is thrown for incorrect query semantics - try - { - doc.select_nodes("(123)/next"); - } - catch (const pugi::xpath_exception& e) - { - std::cout << "Select failed: " << e.what() << std::endl; - } - - // Exception is thrown for query with incorrect return type - try - { - doc.select_nodes("123"); - } - catch (const pugi::xpath_exception& e) - { - std::cout << "Select failed: " << e.what() << std::endl; - } -// end::code[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/xpath_query.cpp b/external/pugixml/docs/samples/xpath_query.cpp deleted file mode 100644 index 857c04c39..000000000 --- a/external/pugixml/docs/samples/xpath_query.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "pugixml.hpp" - -#include -#include - -int main() -{ - pugi::xml_document doc; - if (!doc.load_file("xgconsole.xml")) return -1; - -// tag::code[] - // Select nodes via compiled query - pugi::xpath_query query_remote_tools("/Profile/Tools/Tool[@AllowRemote='true']"); - - pugi::xpath_node_set tools = query_remote_tools.evaluate_node_set(doc); - std::cout << "Remote tool: "; - tools[2].node().print(std::cout); - - // Evaluate numbers via compiled query - pugi::xpath_query query_timeouts("sum(//Tool/@Timeout)"); - std::cout << query_timeouts.evaluate_number(doc) << std::endl; - - // Evaluate strings via compiled query for different context nodes - pugi::xpath_query query_name_valid("string-length(substring-before(@Filename, '_')) > 0 and @OutputFileMasks"); - pugi::xpath_query query_name("concat(substring-before(@Filename, '_'), ' produces ', @OutputFileMasks)"); - - for (pugi::xml_node tool = doc.first_element_by_path("Profile/Tools/Tool"); tool; tool = tool.next_sibling()) - { - std::string s = query_name.evaluate_string(tool); - - if (query_name_valid.evaluate_boolean(tool)) std::cout << s << std::endl; - } -// end::code[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/xpath_select.cpp b/external/pugixml/docs/samples/xpath_select.cpp deleted file mode 100644 index f6067a310..000000000 --- a/external/pugixml/docs/samples/xpath_select.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "pugixml.hpp" - -#include - -int main() -{ - pugi::xml_document doc; - if (!doc.load_file("xgconsole.xml")) return -1; - -// tag::code[] - pugi::xpath_node_set tools = doc.select_nodes("/Profile/Tools/Tool[@AllowRemote='true' and @DeriveCaptionFrom='lastparam']"); - - std::cout << "Tools:\n"; - - for (pugi::xpath_node_set::const_iterator it = tools.begin(); it != tools.end(); ++it) - { - pugi::xpath_node node = *it; - std::cout << node.node().attribute("Filename").value() << "\n"; - } - - pugi::xpath_node build_tool = doc.select_node("//Tool[contains(Description, 'build system')]"); - - if (build_tool) - std::cout << "Build tool: " << build_tool.node().attribute("Filename").value() << "\n"; -// end::code[] -} - -// vim:et diff --git a/external/pugixml/docs/samples/xpath_variables.cpp b/external/pugixml/docs/samples/xpath_variables.cpp deleted file mode 100644 index 5affaefd0..000000000 --- a/external/pugixml/docs/samples/xpath_variables.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "pugixml.hpp" - -#include -#include - -int main() -{ - pugi::xml_document doc; - if (!doc.load_file("xgconsole.xml")) return -1; - -// tag::code[] - // Select nodes via compiled query - pugi::xpath_variable_set vars; - vars.add("remote", pugi::xpath_type_boolean); - - pugi::xpath_query query_remote_tools("/Profile/Tools/Tool[@AllowRemote = string($remote)]", &vars); - - vars.set("remote", true); - pugi::xpath_node_set tools_remote = query_remote_tools.evaluate_node_set(doc); - - vars.set("remote", false); - pugi::xpath_node_set tools_local = query_remote_tools.evaluate_node_set(doc); - - std::cout << "Remote tool: "; - tools_remote[2].node().print(std::cout); - - std::cout << "Local tool: "; - tools_local[0].node().print(std::cout); - - // You can pass the context directly to select_nodes/select_node - pugi::xpath_node_set tools_local_imm = doc.select_nodes("/Profile/Tools/Tool[@AllowRemote = string($remote)]", &vars); - - std::cout << "Local tool imm: "; - tools_local_imm[0].node().print(std::cout); -// end::code[] -} - -// vim:et diff --git a/external/pugixml/readme.txt b/external/pugixml/readme.txt deleted file mode 100644 index 3af59b178..000000000 --- a/external/pugixml/readme.txt +++ /dev/null @@ -1,50 +0,0 @@ -pugixml 1.10 - an XML processing library - -Copyright (C) 2006-2019, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) -Report bugs and download new versions at https://pugixml.org/ - -This is the distribution of pugixml, which is a C++ XML processing library, -which consists of a DOM-like interface with rich traversal/modification -capabilities, an extremely fast XML parser which constructs the DOM tree from -an XML file/buffer, and an XPath 1.0 implementation for complex data-driven -tree queries. Full Unicode support is also available, with Unicode interface -variants and conversions between different Unicode encodings (which happen -automatically during parsing/saving). - -The distribution contains the following folders: - - docs/ - documentation - docs/samples - pugixml usage examples - docs/quickstart.html - quick start guide - docs/manual.html - complete manual - - scripts/ - project files for IDE/build systems - - src/ - header and source files - - readme.txt - this file. - -This library is distributed under the MIT License: - -Copyright (c) 2006-2019 Arseny Kapoulkine - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/external/pugixml/scripts/archive.py b/external/pugixml/scripts/archive.py deleted file mode 100644 index d102d0596..000000000 --- a/external/pugixml/scripts/archive.py +++ /dev/null @@ -1,54 +0,0 @@ -import os.path -import sys -import tarfile -import time -import zipfile -import StringIO - -def read_file(path, use_crlf): - with open(path, 'rb') as file: - data = file.read() - - if '\0' not in data: - data = data.replace('\r', '') - if use_crlf: - data = data.replace('\n', '\r\n') - - return data - -def write_zip(target, arcprefix, timestamp, sources): - with zipfile.ZipFile(target, 'w') as archive: - for source in sorted(sources): - data = read_file(source, use_crlf = True) - path = os.path.join(arcprefix, source) - info = zipfile.ZipInfo(path) - info.date_time = time.localtime(timestamp) - info.compress_type = zipfile.ZIP_DEFLATED - info.external_attr = 0644 << 16L - archive.writestr(info, data) - -def write_tar(target, arcprefix, timestamp, sources, compression): - with tarfile.open(target, 'w:' + compression) as archive: - for source in sorted(sources): - data = read_file(source, use_crlf = False) - path = os.path.join(arcprefix, source) - info = tarfile.TarInfo(path) - info.size = len(data) - info.mtime = timestamp - archive.addfile(info, StringIO.StringIO(data)) - -if len(sys.argv) < 5: - raise RuntimeError('Usage: python archive.py ') - -target, arcprefix, timestamp = sys.argv[1:4] -sources = sys.argv[4:] - -# tarfile._Stream._init_write_gz always writes current time to gzip header -time.time = lambda: timestamp - -if target.endswith('.zip'): - write_zip(target, arcprefix, int(timestamp), sources) -elif target.endswith('.tar.gz') or target.endswith('.tar.bz2'): - write_tar(target, arcprefix, int(timestamp), sources, compression = os.path.splitext(target)[1][1:]) -else: - raise NotImplementedError('File type not supported: ' + target) diff --git a/external/pugixml/scripts/cocoapods_push.sh b/external/pugixml/scripts/cocoapods_push.sh deleted file mode 100755 index d582ea4bf..000000000 --- a/external/pugixml/scripts/cocoapods_push.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -#Push to igagis repo for now -pod repo push igagis pugixml.podspec --use-libraries --verbose diff --git a/external/pugixml/scripts/natvis/pugixml.natvis b/external/pugixml/scripts/natvis/pugixml.natvis deleted file mode 100644 index b756763b7..000000000 --- a/external/pugixml/scripts/natvis/pugixml.natvis +++ /dev/null @@ -1,77 +0,0 @@ - - - - {_root} - none - - _root - - - - - {(pugi::xml_node_type)(header & 0xf),en} name={name,na} value={value,na} - {(pugi::xml_node_type)(header & 0xf),en} name={name,na} - {(pugi::xml_node_type)(header & 0xf),en} value={value,na} - {(pugi::xml_node_type)(header & 0xf),en} - - value,na - - - - - - - curr,view(child)na - curr = curr->next_attribute - - - - - - first_child - next_sibling - this,na - - - - - - {_attr} - none - - _attr - - - - - {name,na} = {value,na} - {value,na} - - name,na - value,na - - - - - {_node,na} "{_attribute._attr->name,na}"="{_attribute._attr->value,na}" - {_node,na} - {_attribute} - empty - - _node - _attribute - _node,na - _attribute,na - - - - - - _type - - _end - _begin - _begin - - - - \ No newline at end of file diff --git a/external/pugixml/scripts/natvis/pugixml_compact.natvis b/external/pugixml/scripts/natvis/pugixml_compact.natvis deleted file mode 100644 index bf44d0216..000000000 --- a/external/pugixml/scripts/natvis/pugixml_compact.natvis +++ /dev/null @@ -1,506 +0,0 @@ - - - - {_root} - none - - _root - - - - - {_attr} - none - - _attr - - - - - - (pugi::xml_node_type)(header._flags & 15) - name,na - value,na - - - ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - h = h ^ (h >> 16) - h = h * (0x85ebca6bu) - h = h ^ (h >> 13) - h = h * (0xc2b2ae35u) - h = h ^ (h >> 16) - - bucket = h & hashmod - - - - probe_item = (size_t*)_items + bucket * 2 - - - attribute_real = *(pugi::xml_attribute_struct**)(probe_item + 1) - - - - bucket = (bucket + probe + 1) & hashmod - probe++ - - - attribute_data_copy = attribute_data - - - *attribute_real,view(child) - attribute_this = (size_t)&(*attribute_real).next_attribute - attribute_data = (*attribute_real).next_attribute._data - - - *attribute_short,view(child) - attribute_this = (size_t)&(*attribute_short).next_attribute - attribute_data = (*attribute_short).next_attribute._data - - - - attribute_T1 = 7 - attribute_T2 = 0 - - - h = (unsigned)attribute_this - bucket = 0 - - probe = 0 - probe_item = (size_t*)0 - - attribute_real = (pugi::xml_attribute_struct*)0 - attribute_short = (pugi::xml_attribute_struct*)(((size_t)attribute_this & ~(compact_alignment - 1)) + (attribute_data - 1 + attribute_T2) * compact_alignment) - - number++ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - h = h ^ (h >> 16) - h = h * (0x85ebca6bu) - h = h ^ (h >> 13) - h = h * (0xc2b2ae35u) - h = h ^ (h >> 16) - - bucket = h & hashmod - - - - probe_item = (size_t*)_items + bucket * 2 - - - child_real = *(pugi::xml_node_struct**)(probe_item + 1) - - - - bucket = (bucket + probe + 1) & hashmod - probe++ - - - child_data_copy = child_data - - - *child_real,view(child) - child_this = (size_t)&(*child_real).next_sibling - child_data = (*child_real).next_sibling._data - - - *child_short,view(child) - child_this = (size_t)&(*child_short).next_sibling - child_data = (*child_short).next_sibling._data - - - - child_T1 = 10 - child_T2 = 0 - - - h = (unsigned)child_this - bucket = 0 - - probe = 0 - probe_item = (size_t*)0 - - child_real = (pugi::xml_node_struct*)0 - child_short = (pugi::xml_node_struct*)(((size_t)child_this & ~(compact_alignment - 1)) + (child_data - 1 + child_T2) * compact_alignment) - - number++ - - - - next_sibling - - - - - - name,na - value,na - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - h = h ^ (h >> 16) - h = h * (0x85ebca6bu) - h = h ^ (h >> 13) - h = h * (0xc2b2ae35u) - h = h ^ (h >> 16) - - bucket = h & hashmod - - - - probe_item = (size_t*)_items + bucket * 2 - - - attribute_real = *(pugi::xml_attribute_struct**)(probe_item + 1) - - - - bucket = (bucket + probe + 1) & hashmod - probe++ - - - - *attribute_real - - - *attribute_short - - - - - - - - - - - - - - - - - - - - (pugi::char_t*)(compact_string_base + offset * sizeof(pugi::char_t)),na - - - - - - - - - - - - - - - - - - - - - - - - - - - - h = h ^ (h >> 16) - h = h * (0x85ebca6bu) - h = h ^ (h >> 13) - h = h * (0xc2b2ae35u) - h = h ^ (h >> 16) - - bucket = h & hashmod - - - - probe_item = (size_t*)_items + bucket * 2 - - - *(pugi::char_t**)(probe_item + 1) - - - - bucket = (bucket + probe + 1) & hashmod - probe++ - - - - - - - nullptr - ... - - - - - - - *(pugi::xml_node_struct*)(((size_t)this & ~(compact_alignment - 1)) + (_data - 1 + $T2) * compact_alignment) - - - - - - - - - - - - - - - - - - - - - - - - - - - - h = h ^ (h >> 16) - h = h * (0x85ebca6bu) - h = h ^ (h >> 13) - h = h * (0xc2b2ae35u) - h = h ^ (h >> 16) - - bucket = h & hashmod - - - - probe_item = (size_t*)_items + bucket * 2 - - - **(pugi::xml_node_struct**)(probe_item + 1) - - - - bucket = (bucket + probe + 1) & hashmod - probe++ - - - - - - - nullptr - ... - - - - - - - *(pugi::xml_attribute_struct*)(((size_t)this & ~(compact_alignment - 1)) + (_data - 1 + $T2) * compact_alignment) - - - - - - - - - - - - - - - - - - - - - - - - - - - - h = h ^ (h >> 16) - h = h * (0x85ebca6bu) - h = h ^ (h >> 13) - h = h * (0xc2b2ae35u) - h = h ^ (h >> 16) - - bucket = h & hashmod - - - - probe_item = (size_t*)_items + bucket * 2 - - - **(pugi::xml_attribute_struct**)(probe_item + 1) - - - - bucket = (bucket + probe + 1) & hashmod - probe++ - - - - - - - {_node,na} {_attribute,na} - {_node,na} - {_attribute} - empty - - - _node - _attribute - - _node,na - _attribute,na - - - - - - _type - - _end - _begin - _begin - - - - \ No newline at end of file diff --git a/external/pugixml/scripts/nuget/build/native/pugixml-propertiesui.xml b/external/pugixml/scripts/nuget/build/native/pugixml-propertiesui.xml deleted file mode 100644 index bfbd2194e..000000000 --- a/external/pugixml/scripts/nuget/build/native/pugixml-propertiesui.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/nuget/build/native/pugixml.targets b/external/pugixml/scripts/nuget/build/native/pugixml.targets deleted file mode 100644 index 7a6e3182e..000000000 --- a/external/pugixml/scripts/nuget/build/native/pugixml.targets +++ /dev/null @@ -1,28 +0,0 @@ - - - - dynamic - Debug - Release - - - - - - - PUGIXML_HEADER_ONLY;%(PreprocessorDefinitions) - $(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories) - - - $(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories) - - - - - - - - $(MSBuildThisFileDirectory)lib/$(Platform)\$(PlatformToolset.Split('_')[0])\$(Linkage-pugixml)\$(Configuration-pugixml)\pugixml.lib;%(AdditionalDependencies) - - - diff --git a/external/pugixml/scripts/nuget/pugixml.nuspec b/external/pugixml/scripts/nuget/pugixml.nuspec deleted file mode 100644 index 74c7b9423..000000000 --- a/external/pugixml/scripts/nuget/pugixml.nuspec +++ /dev/null @@ -1,21 +0,0 @@ - - - - pugixml - 1.10.0-appveyor - pugixml - Arseny Kapoulkine - Arseny Kapoulkine - false - MIT - https://pugixml.org/ - https://github.com/zeux/pugixml/logo.svg - pugixml is a C++ XML processing library, which consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an XPath 1.0 implementation for complex data-driven tree queries. Full Unicode support is also available, with Unicode interface variants and conversions between different Unicode encodings (which happen automatically during parsing/saving). -pugixml is used by a lot of projects, both open-source and proprietary, for performance and easy-to-use interface. -This package contains builds for VS2013, VS2015, VS2017 and VS2019, for both statically linked and DLL CRT; you can switch the CRT linkage in Project -> Properties -> Referenced Packages -> pugixml. - Light-weight, simple and fast XML parser for C++ with XPath support - https://pugixml.org/docs/manual.html#changes - Copyright (c) 2006-2019 Arseny Kapoulkine - native nativepackage - - diff --git a/external/pugixml/scripts/nuget_build.ps1 b/external/pugixml/scripts/nuget_build.ps1 deleted file mode 100644 index 7368f3ba0..000000000 --- a/external/pugixml/scripts/nuget_build.ps1 +++ /dev/null @@ -1,66 +0,0 @@ -function Run-Command([string]$cmd) -{ - Invoke-Expression $cmd - if ($LastExitCode) { exit $LastExitCode } -} - -function Force-Copy([string]$from, [string]$to) -{ - Write-Host $from "->" $to - New-Item -Force $to | Out-Null - Copy-Item -Force $from $to - if (! $?) { exit 1 } -} - -function Build-Version([string]$vs, [string]$toolset, [string]$linkage) -{ - $prjsuffix = if ($linkage -eq "static") { "_static" } else { "" } - $cfgsuffix = if ($linkage -eq "static") { "Static" } else { "" } - - foreach ($configuration in "Debug","Release") - { - Run-Command "msbuild pugixml_$vs$prjsuffix.vcxproj /t:Rebuild /p:Configuration=$configuration /p:Platform=x86 /v:minimal /nologo" - Run-Command "msbuild pugixml_$vs$prjsuffix.vcxproj /t:Rebuild /p:Configuration=$configuration /p:Platform=x64 /v:minimal /nologo" - - Force-Copy "$vs/Win32_$configuration$cfgsuffix/pugixml.lib" "nuget/build/native/lib/Win32/$toolset/$linkage/$configuration/pugixml.lib" - Force-Copy "$vs/x64_$configuration$cfgsuffix/pugixml.lib" "nuget/build/native/lib/x64/$toolset/$linkage/$configuration/pugixml.lib" - } -} - -Push-Location -$scriptdir = Split-Path $MyInvocation.MyCommand.Path -cd $scriptdir - -Force-Copy "../src/pugiconfig.hpp" "nuget/build/native/include/pugiconfig.hpp" -Force-Copy "../src/pugixml.hpp" "nuget/build/native/include/pugixml.hpp" -Force-Copy "../src/pugixml.cpp" "nuget/build/native/include/pugixml.cpp" - -if ($args[0] -eq 2019){ - Build-Version "vs2019" "v142" "dynamic" - Build-Version "vs2019" "v142" "static" - -} elseif ($args[0] -eq 2017){ - Build-Version "vs2017" "v141" "dynamic" - Build-Version "vs2017" "v141" "static" - - Build-Version "vs2015" "v140" "dynamic" - Build-Version "vs2015" "v140" "static" - - Build-Version "vs2013" "v120" "dynamic" - Build-Version "vs2013" "v120" "static" - -} elseif($args[0] -eq 2015){ - Build-Version "vs2015" "v140" "dynamic" - Build-Version "vs2015" "v140" "static" - - Build-Version "vs2013" "v120" "dynamic" - Build-Version "vs2013" "v120" "static" - -} elseif($args[0] -eq 2013){ - Build-Version "vs2013" "v120" "dynamic" - Build-Version "vs2013" "v120" "static" -} - -Run-Command "nuget pack nuget" - -Pop-Location diff --git a/external/pugixml/scripts/premake4.lua b/external/pugixml/scripts/premake4.lua deleted file mode 100644 index f1b89a0a2..000000000 --- a/external/pugixml/scripts/premake4.lua +++ /dev/null @@ -1,92 +0,0 @@ --- Reset RNG seed to get consistent results across runs (i.e. XCode) -math.randomseed(12345) - -local static = _ARGS[1] == 'static' -local action = premake.action.current() - -if string.startswith(_ACTION, "vs") then - if action then - -- Disable solution generation - function action.onsolution(sln) - sln.vstudio_configs = premake.vstudio_buildconfigs(sln) - end - - -- Rename output file - function action.onproject(prj) - local name = "%%_" .. _ACTION .. (static and "_static" or "") - - if static then - for k, v in pairs(prj.project.__configs) do - v.objectsdir = v.objectsdir .. "Static" - end - end - - if _ACTION == "vs2010" then - premake.generate(prj, name .. ".vcxproj", premake.vs2010_vcxproj) - else - premake.generate(prj, name .. ".vcproj", premake.vs200x_vcproj) - end - end - end -elseif _ACTION == "codeblocks" then - action.onsolution = nil - - function action.onproject(prj) - premake.generate(prj, "%%_" .. _ACTION .. ".cbp", premake.codeblocks_cbp) - end -elseif _ACTION == "codelite" then - action.onsolution = nil - - function action.onproject(prj) - premake.generate(prj, "%%_" .. _ACTION .. ".project", premake.codelite_project) - end -end - -solution "pugixml" - objdir(_ACTION) - targetdir(_ACTION) - -if string.startswith(_ACTION, "vs") then - if _ACTION ~= "vs2002" and _ACTION ~= "vs2003" then - platforms { "x32", "x64" } - - configuration "x32" targetdir(_ACTION .. "/x32") - configuration "x64" targetdir(_ACTION .. "/x64") - end - - configurations { "Debug", "Release" } - - if static then - configuration "Debug" targetsuffix "sd" - configuration "Release" targetsuffix "s" - else - configuration "Debug" targetsuffix "d" - end -else - if _ACTION == "xcode3" then - platforms "universal" - end - - configurations { "Debug", "Release" } - - configuration "Debug" targetsuffix "d" -end - -project "pugixml" - kind "StaticLib" - language "C++" - files { "../src/pugixml.hpp", "../src/pugiconfig.hpp", "../src/pugixml.cpp" } - flags { "NoPCH", "NoMinimalRebuild", "NoEditAndContinue", "Symbols" } - uuid "89A1E353-E2DC-495C-B403-742BE206ACED" - -configuration "Debug" - defines { "_DEBUG" } - -configuration "Release" - defines { "NDEBUG" } - flags { "Optimize" } - -if static then - configuration "*" - flags { "StaticRuntime" } -end diff --git a/external/pugixml/scripts/pugixml-config.cmake.in b/external/pugixml/scripts/pugixml-config.cmake.in deleted file mode 100644 index 91e349354..000000000 --- a/external/pugixml/scripts/pugixml-config.cmake.in +++ /dev/null @@ -1,3 +0,0 @@ -@PACKAGE_INIT@ - -include("${CMAKE_CURRENT_LIST_DIR}/pugixml-targets.cmake") diff --git a/external/pugixml/scripts/pugixml.pc.in b/external/pugixml/scripts/pugixml.pc.in deleted file mode 100644 index f9c3fd456..000000000 --- a/external/pugixml/scripts/pugixml.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@@INSTALL_SUFFIX@ -libdir=@CMAKE_INSTALL_FULL_LIBDIR@@INSTALL_SUFFIX@ - -Name: pugixml -Description: Light-weight, simple and fast XML parser for C++ with XPath support. -URL: https://pugixml.org/ -Version: @pugixml_VERSION@ -Cflags: -I${includedir} -Libs: -L${libdir} -lpugixml diff --git a/external/pugixml/scripts/pugixml.podspec b/external/pugixml/scripts/pugixml.podspec deleted file mode 100644 index f9a72ed32..000000000 --- a/external/pugixml/scripts/pugixml.podspec +++ /dev/null @@ -1,14 +0,0 @@ -Pod::Spec.new do |s| - s.name = "pugixml" - s.version = "1.10" - s.summary = "C++ XML parser library." - s.homepage = "https://pugixml.org" - s.license = "MIT" - s.author = { "Arseny Kapoulkine" => "arseny.kapoulkine@gmail.com" } - s.platform = :ios, "7.0" - - s.source = { :git => "https://github.com/zeux/pugixml.git", :tag => "v" + s.version.to_s } - - s.source_files = "src/**/*.{hpp,cpp}" - s.header_mappings_dir = "src" -end diff --git a/external/pugixml/scripts/pugixml.xcodeproj/project.pbxproj b/external/pugixml/scripts/pugixml.xcodeproj/project.pbxproj deleted file mode 100644 index 7d56bafd2..000000000 --- a/external/pugixml/scripts/pugixml.xcodeproj/project.pbxproj +++ /dev/null @@ -1,212 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 45; - objects = { - -/* Begin PBXBuildFile section */ - 0424128F67AB5C730232235E /* pugixml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 47481C4F0E03673E0E780637 /* pugixml.cpp */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 0B66463C5F896E6449051D38 /* pugiconfig.hpp */ = {isa = PBXFileReference; lastKnownFileType = text; name = "pugiconfig.hpp"; path = "pugiconfig.hpp"; sourceTree = ""; }; - 47481C4F0E03673E0E780637 /* pugixml.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "pugixml.cpp"; path = "pugixml.cpp"; sourceTree = ""; }; - 6C911F0460FC44CD3B1B5624 /* pugixml.hpp */ = {isa = PBXFileReference; lastKnownFileType = text; name = "pugixml.hpp"; path = "pugixml.hpp"; sourceTree = ""; }; - 1DA04ADC64C3566D16C45B6D /* libpugixmld.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = "libpugixmld.a"; path = "libpugixmld.a"; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 2BA00212518037166623673F /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 19E0517F3CF26ED63AE23641 /* pugixml */ = { - isa = PBXGroup; - children = ( - 578963B4309E714F05E01D71 /* src */, - 219F66186DDF392149043810 /* Products */, - ); - name = "pugixml"; - sourceTree = ""; - }; - 578963B4309E714F05E01D71 /* src */ = { - isa = PBXGroup; - children = ( - 0B66463C5F896E6449051D38 /* pugiconfig.hpp */, - 47481C4F0E03673E0E780637 /* pugixml.cpp */, - 6C911F0460FC44CD3B1B5624 /* pugixml.hpp */, - ); - name = "src"; - path = ../src; - sourceTree = ""; - }; - 219F66186DDF392149043810 /* Products */ = { - isa = PBXGroup; - children = ( - 1DA04ADC64C3566D16C45B6D /* libpugixmld.a */, - ); - name = "Products"; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 6B55152571905B6C3A6F39D0 /* pugixml */ = { - isa = PBXNativeTarget; - buildConfigurationList = 73BF376C14AA1ECC0AC517ED /* Build configuration list for PBXNativeTarget "pugixml" */; - buildPhases = ( - 6CA66B9B6252229A36E8733C /* Resources */, - 287808486FBF545206A47CC1 /* Sources */, - 2BA00212518037166623673F /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "pugixml"; - productName = "pugixml"; - productReference = 1DA04ADC64C3566D16C45B6D /* libpugixmld.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 08FB7793FE84155DC02AAC07 /* Project object */ = { - isa = PBXProject; - buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "pugixml" */; - compatibilityVersion = "Xcode 3.1"; - hasScannedForEncodings = 1; - mainGroup = 19E0517F3CF26ED63AE23641 /* pugixml */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 6B55152571905B6C3A6F39D0 /* libpugixmld.a */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 6CA66B9B6252229A36E8733C /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 287808486FBF545206A47CC1 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 0424128F67AB5C730232235E /* pugixml.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 4FDB54E4253E36FC55CE27E8 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CONFIGURATION_BUILD_DIR = xcode3; - GCC_DYNAMIC_NO_PIC = NO; - GCC_MODEL_TUNING = G5; - INSTALL_PATH = /usr/local/lib; - PRODUCT_NAME = "pugixmld"; - }; - name = "Debug"; - }; - 0A4C28F553990E0405306C15 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CONFIGURATION_BUILD_DIR = xcode3; - GCC_DYNAMIC_NO_PIC = NO; - GCC_MODEL_TUNING = G5; - INSTALL_PATH = /usr/local/lib; - PRODUCT_NAME = "pugixml"; - }; - name = "Release"; - }; - 65DB0F6D27EA20852B6E3BB4 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; - CONFIGURATION_TEMP_DIR = "$(OBJROOT)"; - COPY_PHASE_STRIP = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "_DEBUG", - ); - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - OBJROOT = "xcode3/Universal/Debug"; - ONLY_ACTIVE_ARCH = NO; - PREBINDING = NO; - SYMROOT = "xcode3"; - }; - name = "Debug"; - }; - 5314084032B57C1A11945858 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; - CONFIGURATION_TEMP_DIR = "$(OBJROOT)"; - COPY_PHASE_STRIP = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_OPTIMIZATION_LEVEL = s; - GCC_PREPROCESSOR_DEFINITIONS = ( - "NDEBUG", - ); - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - OBJROOT = "xcode3/Universal/Release"; - ONLY_ACTIVE_ARCH = NO; - PREBINDING = NO; - SYMROOT = "xcode3"; - }; - name = "Release"; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 73BF376C14AA1ECC0AC517ED /* Build configuration list for PBXNativeTarget "libpugixmld.a" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4FDB54E4253E36FC55CE27E8 /* Debug */, - 0A4C28F553990E0405306C15 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Debug"; - }; - 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "pugixml" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 65DB0F6D27EA20852B6E3BB4 /* Debug */, - 5314084032B57C1A11945858 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Debug"; - }; -/* End XCConfigurationList section */ - - }; - rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; -} diff --git a/external/pugixml/scripts/pugixml_airplay.mkf b/external/pugixml/scripts/pugixml_airplay.mkf deleted file mode 100644 index 0ca5c2387..000000000 --- a/external/pugixml/scripts/pugixml_airplay.mkf +++ /dev/null @@ -1,13 +0,0 @@ -includepaths -{ -"../src" -} - -files -{ -("../src") -pugiconfig.hpp -pugixml.cpp -pugixml.hpp -} - diff --git a/external/pugixml/scripts/pugixml_codeblocks.cbp b/external/pugixml/scripts/pugixml_codeblocks.cbp deleted file mode 100644 index e18ccfca5..000000000 --- a/external/pugixml/scripts/pugixml_codeblocks.cbp +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - diff --git a/external/pugixml/scripts/pugixml_codelite.project b/external/pugixml/scripts/pugixml_codelite.project deleted file mode 100644 index 637a81da5..000000000 --- a/external/pugixml/scripts/pugixml_codelite.project +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - None - - - - - - - - - - - - - - - - - - - - - None - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/pugixml_dll.rc b/external/pugixml/scripts/pugixml_dll.rc deleted file mode 100644 index d71a65db6..000000000 --- a/external/pugixml/scripts/pugixml_dll.rc +++ /dev/null @@ -1,45 +0,0 @@ -#include - -#define PUGIXML_VERSION_MAJOR 1 -#define PUGIXML_VERSION_MINOR 10 -#define PUGIXML_VERSION_PATCH 0 -#define PUGIXML_VERSION_NUMBER "1.10.0\0" - -#ifdef GCC_WINDRES -VS_VERSION_INFO VERSIONINFO -#else -VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE -#endif - FILEVERSION PUGIXML_VERSION_MAJOR,PUGIXML_VERSION_MINOR,PUGIXML_VERSION_PATCH,0 - PRODUCTVERSION PUGIXML_VERSION_MAJOR,PUGIXML_VERSION_MINOR,PUGIXML_VERSION_PATCH,0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS 1 -#else - FILEFLAGS 0 -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0 // not used -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - //language ID = U.S. English, char set = Windows, Multilingual - BEGIN - VALUE "CompanyName", "zeux/pugixml\0" - VALUE "FileDescription", "pugixml library\0" - VALUE "FileVersion", PUGIXML_VERSION_NUMBER - VALUE "InternalName", "pugixml.dll\0" - VALUE "LegalCopyright", "Copyright (C) 2006-2019, by Arseny Kapoulkine\0" - VALUE "OriginalFilename", "pugixml.dll\0" - VALUE "ProductName", "pugixml\0" - VALUE "ProductVersion", PUGIXML_VERSION_NUMBER - VALUE "Comments", "For more information visit https://github.com/zeux/pugixml/\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1252 - END -END diff --git a/external/pugixml/scripts/pugixml_vs2005.vcproj b/external/pugixml/scripts/pugixml_vs2005.vcproj deleted file mode 100644 index b60f5af8f..000000000 --- a/external/pugixml/scripts/pugixml_vs2005.vcproj +++ /dev/null @@ -1,343 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/pugixml_vs2005_static.vcproj b/external/pugixml/scripts/pugixml_vs2005_static.vcproj deleted file mode 100644 index 065e0eb4f..000000000 --- a/external/pugixml/scripts/pugixml_vs2005_static.vcproj +++ /dev/null @@ -1,343 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/pugixml_vs2008.vcproj b/external/pugixml/scripts/pugixml_vs2008.vcproj deleted file mode 100644 index 72186182d..000000000 --- a/external/pugixml/scripts/pugixml_vs2008.vcproj +++ /dev/null @@ -1,339 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/pugixml_vs2008_static.vcproj b/external/pugixml/scripts/pugixml_vs2008_static.vcproj deleted file mode 100644 index a00e9d1f6..000000000 --- a/external/pugixml/scripts/pugixml_vs2008_static.vcproj +++ /dev/null @@ -1,339 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/pugixml_vs2010.vcxproj b/external/pugixml/scripts/pugixml_vs2010.vcxproj deleted file mode 100644 index d29c463d2..000000000 --- a/external/pugixml/scripts/pugixml_vs2010.vcxproj +++ /dev/null @@ -1,191 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {89A1E353-E2DC-495C-B403-742BE206ACED} - pugixml - Win32Proj - - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - true - false - - - StaticLibrary - MultiByte - true - false - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - vs2010\Win32_Debug\ - vs2010\Win32_Debug\ - pugixml - vs2010\x64_Debug\ - vs2010\x64_Debug\ - pugixml - vs2010\Win32_Release\ - vs2010\Win32_Release\ - pugixml - vs2010\x64_Release\ - vs2010\x64_Release\ - pugixml - - - - Disabled - _DEBUG;%(PreprocessorDefinitions) - false - EnableFastChecks - MultiThreadedDebugDLL - true - - Level3 - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - $(OutDir)pugixml.pdb - - - - - Disabled - _DEBUG;%(PreprocessorDefinitions) - false - EnableFastChecks - MultiThreadedDebugDLL - true - - Level3 - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - $(OutDir)pugixml.pdb - - - - - Full - NDEBUG;%(PreprocessorDefinitions) - false - true - MultiThreadedDLL - true - - Level3 - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - true - true - $(OutDir)pugixml.pdb - - - - - Full - NDEBUG;%(PreprocessorDefinitions) - false - true - MultiThreadedDLL - true - - Level3 - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - true - true - $(OutDir)pugixml.pdb - - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/pugixml_vs2010_static.vcxproj b/external/pugixml/scripts/pugixml_vs2010_static.vcxproj deleted file mode 100644 index e770d170e..000000000 --- a/external/pugixml/scripts/pugixml_vs2010_static.vcxproj +++ /dev/null @@ -1,191 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {89A1E353-E2DC-495C-B403-742BE206ACED} - pugixml - Win32Proj - - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - true - - - StaticLibrary - MultiByte - true - false - - - StaticLibrary - MultiByte - true - false - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - vs2010\Win32_DebugStatic\ - vs2010\Win32_DebugStatic\ - pugixml - vs2010\x64_DebugStatic\ - vs2010\x64_DebugStatic\ - pugixml - vs2010\Win32_ReleaseStatic\ - vs2010\Win32_ReleaseStatic\ - pugixml - vs2010\x64_ReleaseStatic\ - vs2010\x64_ReleaseStatic\ - pugixml - - - - Disabled - _DEBUG;%(PreprocessorDefinitions) - false - EnableFastChecks - MultiThreadedDebug - true - - Level3 - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - $(OutDir)pugixml.pdb - - - - - Disabled - _DEBUG;%(PreprocessorDefinitions) - false - EnableFastChecks - MultiThreadedDebug - true - - Level3 - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - $(OutDir)pugixml.pdb - - - - - Full - NDEBUG;%(PreprocessorDefinitions) - false - true - MultiThreaded - true - - Level3 - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - true - true - $(OutDir)pugixml.pdb - - - - - Full - NDEBUG;%(PreprocessorDefinitions) - false - true - MultiThreaded - true - - Level3 - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - true - true - $(OutDir)pugixml.pdb - - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/pugixml_vs2013.vcxproj b/external/pugixml/scripts/pugixml_vs2013.vcxproj deleted file mode 100644 index eae27c9a2..000000000 --- a/external/pugixml/scripts/pugixml_vs2013.vcxproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {89A1E353-E2DC-495C-B403-742BE206ACED} - pugixml - Win32Proj - - - - StaticLibrary - MultiByte - true - v120 - - - StaticLibrary - MultiByte - true - v120 - - - StaticLibrary - MultiByte - true - false - v120 - - - StaticLibrary - MultiByte - true - false - v120 - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - vs2013\Win32_Debug\ - vs2013\Win32_Debug\ - pugixml - vs2013\x64_Debug\ - vs2013\x64_Debug\ - pugixml - vs2013\Win32_Release\ - vs2013\Win32_Release\ - pugixml - vs2013\x64_Release\ - vs2013\x64_Release\ - pugixml - - - - Disabled - _DEBUG;%(PreprocessorDefinitions) - false - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - OldStyle - - - _DEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - $(OutDir)pugixml.pdb - - - - - Disabled - _DEBUG;%(PreprocessorDefinitions) - false - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - OldStyle - - - _DEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - $(OutDir)pugixml.pdb - - - - - Full - NDEBUG;%(PreprocessorDefinitions) - false - true - MultiThreadedDLL - true - - - Level3 - OldStyle - - - NDEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - true - true - $(OutDir)pugixml.pdb - - - - - Full - NDEBUG;%(PreprocessorDefinitions) - false - true - MultiThreadedDLL - true - - - Level3 - OldStyle - - - NDEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - true - true - $(OutDir)pugixml.pdb - - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/pugixml_vs2013_static.vcxproj b/external/pugixml/scripts/pugixml_vs2013_static.vcxproj deleted file mode 100644 index 0ad4fe230..000000000 --- a/external/pugixml/scripts/pugixml_vs2013_static.vcxproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {89A1E353-E2DC-495C-B403-742BE206ACED} - pugixml - Win32Proj - - - - StaticLibrary - MultiByte - true - v120 - - - StaticLibrary - MultiByte - true - v120 - - - StaticLibrary - MultiByte - true - false - v120 - - - StaticLibrary - MultiByte - true - false - v120 - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - vs2013\Win32_DebugStatic\ - vs2013\Win32_DebugStatic\ - pugixml - vs2013\x64_DebugStatic\ - vs2013\x64_DebugStatic\ - pugixml - vs2013\Win32_ReleaseStatic\ - vs2013\Win32_ReleaseStatic\ - pugixml - vs2013\x64_ReleaseStatic\ - vs2013\x64_ReleaseStatic\ - pugixml - - - - Disabled - _DEBUG;%(PreprocessorDefinitions) - false - EnableFastChecks - MultiThreadedDebug - true - - - Level3 - OldStyle - - - _DEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - $(OutDir)pugixml.pdb - - - - - Disabled - _DEBUG;%(PreprocessorDefinitions) - false - EnableFastChecks - MultiThreadedDebug - true - - - Level3 - OldStyle - - - _DEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - $(OutDir)pugixml.pdb - - - - - Full - NDEBUG;%(PreprocessorDefinitions) - false - true - MultiThreaded - true - - - Level3 - OldStyle - - - NDEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - true - true - $(OutDir)pugixml.pdb - - - - - Full - NDEBUG;%(PreprocessorDefinitions) - false - true - MultiThreaded - true - - - Level3 - OldStyle - - - NDEBUG;%(PreprocessorDefinitions) - - - $(OutDir)pugixml.lib - - - Windows - true - true - true - $(OutDir)pugixml.pdb - - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/pugixml_vs2015.vcxproj b/external/pugixml/scripts/pugixml_vs2015.vcxproj deleted file mode 100644 index e9b48f4b0..000000000 --- a/external/pugixml/scripts/pugixml_vs2015.vcxproj +++ /dev/null @@ -1,172 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {07CF01C0-B887-499D-AD9C-799CB6A9FE64} - Win32Proj - pugixml - 8.1 - - - - StaticLibrary - true - v140 - Unicode - - - StaticLibrary - false - v140 - true - Unicode - - - StaticLibrary - true - v140 - Unicode - - - StaticLibrary - false - v140 - true - Unicode - - - - - - - - - - - - - - - - - - - - - vs2015\$(Platform)_$(Configuration)\ - vs2015\$(Platform)_$(Configuration)\ - pugixml - - - vs2015\$(Platform)_$(Configuration)\ - vs2015\$(Platform)_$(Configuration)\ - pugixml - - - vs2015\$(Platform)_$(Configuration)\ - vs2015\$(Platform)_$(Configuration)\ - pugixml - - - vs2015\$(Platform)_$(Configuration)\ - vs2015\$(Platform)_$(Configuration)\ - pugixml - - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - false - - - Windows - true - - - - - - - Level3 - Disabled - _DEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - false - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - - - Windows - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - - - Windows - true - true - true - - - - - - - - - - - - - \ No newline at end of file diff --git a/external/pugixml/scripts/pugixml_vs2015_static.vcxproj b/external/pugixml/scripts/pugixml_vs2015_static.vcxproj deleted file mode 100644 index 0ce5082bc..000000000 --- a/external/pugixml/scripts/pugixml_vs2015_static.vcxproj +++ /dev/null @@ -1,176 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {07CF01C0-B887-499D-AD9C-799CB6A9FE64} - Win32Proj - pugixml - 8.1 - - - - StaticLibrary - true - v140 - Unicode - - - StaticLibrary - false - v140 - true - Unicode - - - StaticLibrary - true - v140 - Unicode - - - StaticLibrary - false - v140 - true - Unicode - - - - - - - - - - - - - - - - - - - - - vs2015\$(Platform)_$(Configuration)Static\ - vs2015\$(Platform)_$(Configuration)Static\ - pugixml - - - vs2015\$(Platform)_$(Configuration)Static\ - vs2015\$(Platform)_$(Configuration)Static\ - pugixml - - - vs2015\$(Platform)_$(Configuration)Static\ - vs2015\$(Platform)_$(Configuration)Static\ - pugixml - - - vs2015\$(Platform)_$(Configuration)Static\ - vs2015\$(Platform)_$(Configuration)Static\ - pugixml - - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - false - MultiThreadedDebug - - - Windows - true - - - - - - - Level3 - Disabled - _DEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - false - MultiThreadedDebug - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - MultiThreaded - - - Windows - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - MultiThreaded - - - Windows - true - true - true - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/pugixml_vs2017.vcxproj b/external/pugixml/scripts/pugixml_vs2017.vcxproj deleted file mode 100644 index 8a54db7a8..000000000 --- a/external/pugixml/scripts/pugixml_vs2017.vcxproj +++ /dev/null @@ -1,172 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {07CF01C0-B887-499D-AD9C-799CB6A9FE64} - Win32Proj - pugixml - 8.1 - - - - StaticLibrary - true - v141 - Unicode - - - StaticLibrary - false - v141 - false - Unicode - - - StaticLibrary - true - v141 - Unicode - - - StaticLibrary - false - v141 - false - Unicode - - - - - - - - - - - - - - - - - - - - - vs2017\$(Platform)_$(Configuration)\ - vs2017\$(Platform)_$(Configuration)\ - pugixml - - - vs2017\$(Platform)_$(Configuration)\ - vs2017\$(Platform)_$(Configuration)\ - pugixml - - - vs2017\$(Platform)_$(Configuration)\ - vs2017\$(Platform)_$(Configuration)\ - pugixml - - - vs2017\$(Platform)_$(Configuration)\ - vs2017\$(Platform)_$(Configuration)\ - pugixml - - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - false - - - Windows - true - - - - - - - Level3 - Disabled - _DEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - false - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - - - Windows - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - - - Windows - true - true - true - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/pugixml_vs2017_static.vcxproj b/external/pugixml/scripts/pugixml_vs2017_static.vcxproj deleted file mode 100644 index 327ee6954..000000000 --- a/external/pugixml/scripts/pugixml_vs2017_static.vcxproj +++ /dev/null @@ -1,176 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {07CF01C0-B887-499D-AD9C-799CB6A9FE64} - Win32Proj - pugixml - 8.1 - - - - StaticLibrary - true - v141 - Unicode - - - StaticLibrary - false - v141 - false - Unicode - - - StaticLibrary - true - v141 - Unicode - - - StaticLibrary - false - v141 - false - Unicode - - - - - - - - - - - - - - - - - - - - - vs2017\$(Platform)_$(Configuration)Static\ - vs2017\$(Platform)_$(Configuration)Static\ - pugixml - - - vs2017\$(Platform)_$(Configuration)Static\ - vs2017\$(Platform)_$(Configuration)Static\ - pugixml - - - vs2017\$(Platform)_$(Configuration)Static\ - vs2017\$(Platform)_$(Configuration)Static\ - pugixml - - - vs2017\$(Platform)_$(Configuration)Static\ - vs2017\$(Platform)_$(Configuration)Static\ - pugixml - - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - false - MultiThreadedDebug - - - Windows - true - - - - - - - Level3 - Disabled - _DEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - false - MultiThreadedDebug - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - MultiThreaded - - - Windows - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - MultiThreaded - - - Windows - true - true - true - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/pugixml_vs2019.vcxproj b/external/pugixml/scripts/pugixml_vs2019.vcxproj deleted file mode 100644 index 690a790db..000000000 --- a/external/pugixml/scripts/pugixml_vs2019.vcxproj +++ /dev/null @@ -1,172 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {07CF01C0-B887-499D-AD9C-799CB6A9FE64} - Win32Proj - pugixml - 10.0 - - - - StaticLibrary - true - v142 - Unicode - - - StaticLibrary - false - v142 - false - Unicode - - - StaticLibrary - true - v142 - Unicode - - - StaticLibrary - false - v142 - false - Unicode - - - - - - - - - - - - - - - - - - - - - vs2019\$(Platform)_$(Configuration)\ - vs2019\$(Platform)_$(Configuration)\ - pugixml - - - vs2019\$(Platform)_$(Configuration)\ - vs2019\$(Platform)_$(Configuration)\ - pugixml - - - vs2019\$(Platform)_$(Configuration)\ - vs2019\$(Platform)_$(Configuration)\ - pugixml - - - vs2019\$(Platform)_$(Configuration)\ - vs2019\$(Platform)_$(Configuration)\ - pugixml - - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - false - - - Windows - true - - - - - - - Level3 - Disabled - _DEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - false - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - - - Windows - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - - - Windows - true - true - true - - - - - - - - - - - - - diff --git a/external/pugixml/scripts/pugixml_vs2019_static.vcxproj b/external/pugixml/scripts/pugixml_vs2019_static.vcxproj deleted file mode 100644 index 1747e37cc..000000000 --- a/external/pugixml/scripts/pugixml_vs2019_static.vcxproj +++ /dev/null @@ -1,176 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {07CF01C0-B887-499D-AD9C-799CB6A9FE64} - Win32Proj - pugixml - 10.0 - - - - StaticLibrary - true - v142 - Unicode - - - StaticLibrary - false - v142 - false - Unicode - - - StaticLibrary - true - v142 - Unicode - - - StaticLibrary - false - v142 - false - Unicode - - - - - - - - - - - - - - - - - - - - - vs2019\$(Platform)_$(Configuration)Static\ - vs2019\$(Platform)_$(Configuration)Static\ - pugixml - - - vs2019\$(Platform)_$(Configuration)Static\ - vs2019\$(Platform)_$(Configuration)Static\ - pugixml - - - vs2019\$(Platform)_$(Configuration)Static\ - vs2019\$(Platform)_$(Configuration)Static\ - pugixml - - - vs2019\$(Platform)_$(Configuration)Static\ - vs2019\$(Platform)_$(Configuration)Static\ - pugixml - - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - false - MultiThreadedDebug - - - Windows - true - - - - - - - Level3 - Disabled - _DEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - false - MultiThreadedDebug - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - MultiThreaded - - - Windows - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions) - $(IntDir)$(TargetName).pdb - OldStyle - MultiThreaded - - - Windows - true - true - true - - - - - - - - - - - - - diff --git a/external/pugixml/src/pugiconfig.hpp b/external/pugixml/src/pugiconfig.hpp deleted file mode 100644 index 2fb691802..000000000 --- a/external/pugixml/src/pugiconfig.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/** - * pugixml parser - version 1.10 - * -------------------------------------------------------- - * Copyright (C) 2006-2019, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) - * Report bugs and download new versions at https://pugixml.org/ - * - * This library is distributed under the MIT License. See notice at the end - * of this file. - * - * This work is based on the pugxml parser, which is: - * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) - */ - -#ifndef HEADER_PUGICONFIG_HPP -#define HEADER_PUGICONFIG_HPP - -// Uncomment this to enable wchar_t mode -// #define PUGIXML_WCHAR_MODE - -// Uncomment this to enable compact mode -// #define PUGIXML_COMPACT - -// Uncomment this to disable XPath -// #define PUGIXML_NO_XPATH - -// Uncomment this to disable STL -// #define PUGIXML_NO_STL - -// Uncomment this to disable exceptions -// #define PUGIXML_NO_EXCEPTIONS - -// Set this to control attributes for public classes/functions, i.e.: -// #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL -// #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL -// #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall -// In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead - -// Tune these constants to adjust memory-related behavior -// #define PUGIXML_MEMORY_PAGE_SIZE 32768 -// #define PUGIXML_MEMORY_OUTPUT_STACK 10240 -// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 - -// Uncomment this to switch to header-only version -// #define PUGIXML_HEADER_ONLY - -// Uncomment this to enable long long support -// #define PUGIXML_HAS_LONG_LONG - -#endif - -/** - * Copyright (c) 2006-2019 Arseny Kapoulkine - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ diff --git a/external/pugixml/src/pugixml.cpp b/external/pugixml/src/pugixml.cpp deleted file mode 100644 index c3df93b12..000000000 --- a/external/pugixml/src/pugixml.cpp +++ /dev/null @@ -1,12948 +0,0 @@ -/** - * pugixml parser - version 1.10 - * -------------------------------------------------------- - * Copyright (C) 2006-2019, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) - * Report bugs and download new versions at https://pugixml.org/ - * - * This library is distributed under the MIT License. See notice at the end - * of this file. - * - * This work is based on the pugxml parser, which is: - * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) - */ - -#ifndef SOURCE_PUGIXML_CPP -#define SOURCE_PUGIXML_CPP - -#include "pugixml.hpp" - -#include -#include -#include -#include -#include - -#ifdef PUGIXML_WCHAR_MODE -# include -#endif - -#ifndef PUGIXML_NO_XPATH -# include -# include -#endif - -#ifndef PUGIXML_NO_STL -# include -# include -# include -#endif - -// For placement new -#include - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4127) // conditional expression is constant -# pragma warning(disable: 4324) // structure was padded due to __declspec(align()) -# pragma warning(disable: 4702) // unreachable code -# pragma warning(disable: 4996) // this function or variable may be unsafe -#endif - -#if defined(_MSC_VER) && defined(__c2__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wdeprecated" // this function or variable may be unsafe -#endif - -#ifdef __INTEL_COMPILER -# pragma warning(disable: 177) // function was declared but never referenced -# pragma warning(disable: 279) // controlling expression is constant -# pragma warning(disable: 1478 1786) // function was declared "deprecated" -# pragma warning(disable: 1684) // conversion from pointer to same-sized integral type -#endif - -#if defined(__BORLANDC__) && defined(PUGIXML_HEADER_ONLY) -# pragma warn -8080 // symbol is declared but never used; disabling this inside push/pop bracket does not make the warning go away -#endif - -#ifdef __BORLANDC__ -# pragma option push -# pragma warn -8008 // condition is always false -# pragma warn -8066 // unreachable code -#endif - -#ifdef __SNC__ -// Using diag_push/diag_pop does not disable the warnings inside templates due to a compiler bug -# pragma diag_suppress=178 // function was declared but never referenced -# pragma diag_suppress=237 // controlling expression is constant -#endif - -#ifdef __TI_COMPILER_VERSION__ -# pragma diag_suppress 179 // function was declared but never referenced -#endif - -// Inlining controls -#if defined(_MSC_VER) && _MSC_VER >= 1300 -# define PUGI__NO_INLINE __declspec(noinline) -#elif defined(__GNUC__) -# define PUGI__NO_INLINE __attribute__((noinline)) -#else -# define PUGI__NO_INLINE -#endif - -// Branch weight controls -#if defined(__GNUC__) && !defined(__c2__) -# define PUGI__UNLIKELY(cond) __builtin_expect(cond, 0) -#else -# define PUGI__UNLIKELY(cond) (cond) -#endif - -// Simple static assertion -#define PUGI__STATIC_ASSERT(cond) { static const char condition_failed[(cond) ? 1 : -1] = {0}; (void)condition_failed[0]; } - -// Digital Mars C++ bug workaround for passing char loaded from memory via stack -#ifdef __DMC__ -# define PUGI__DMC_VOLATILE volatile -#else -# define PUGI__DMC_VOLATILE -#endif - -// Integer sanitizer workaround; we only apply this for clang since gcc8 has no_sanitize but not unsigned-integer-overflow and produces "attribute directive ignored" warnings -#if defined(__clang__) && defined(__has_attribute) -# if __has_attribute(no_sanitize) -# define PUGI__UNSIGNED_OVERFLOW __attribute__((no_sanitize("unsigned-integer-overflow"))) -# else -# define PUGI__UNSIGNED_OVERFLOW -# endif -#else -# define PUGI__UNSIGNED_OVERFLOW -#endif - -// Borland C++ bug workaround for not defining ::memcpy depending on header include order (can't always use std::memcpy because some compilers don't have it at all) -#if defined(__BORLANDC__) && !defined(__MEM_H_USING_LIST) -using std::memcpy; -using std::memmove; -using std::memset; -#endif - -// Some MinGW/GCC versions have headers that erroneously omit LLONG_MIN/LLONG_MAX/ULLONG_MAX definitions from limits.h in some configurations -#if defined(PUGIXML_HAS_LONG_LONG) && defined(__GNUC__) && !defined(LLONG_MAX) && !defined(LLONG_MIN) && !defined(ULLONG_MAX) -# define LLONG_MIN (-LLONG_MAX - 1LL) -# define LLONG_MAX __LONG_LONG_MAX__ -# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) -#endif - -// In some environments MSVC is a compiler but the CRT lacks certain MSVC-specific features -#if defined(_MSC_VER) && !defined(__S3E__) -# define PUGI__MSVC_CRT_VERSION _MSC_VER -#endif - -// Not all platforms have snprintf; we define a wrapper that uses snprintf if possible. This only works with buffers with a known size. -#if __cplusplus >= 201103 -# define PUGI__SNPRINTF(buf, ...) snprintf(buf, sizeof(buf), __VA_ARGS__) -#elif defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 -# define PUGI__SNPRINTF(buf, ...) _snprintf_s(buf, _countof(buf), _TRUNCATE, __VA_ARGS__) -#else -# define PUGI__SNPRINTF sprintf -#endif - -// We put implementation details into an anonymous namespace in source mode, but have to keep it in non-anonymous namespace in header-only mode to prevent binary bloat. -#ifdef PUGIXML_HEADER_ONLY -# define PUGI__NS_BEGIN namespace pugi { namespace impl { -# define PUGI__NS_END } } -# define PUGI__FN inline -# define PUGI__FN_NO_INLINE inline -#else -# if defined(_MSC_VER) && _MSC_VER < 1300 // MSVC6 seems to have an amusing bug with anonymous namespaces inside namespaces -# define PUGI__NS_BEGIN namespace pugi { namespace impl { -# define PUGI__NS_END } } -# else -# define PUGI__NS_BEGIN namespace pugi { namespace impl { namespace { -# define PUGI__NS_END } } } -# endif -# define PUGI__FN -# define PUGI__FN_NO_INLINE PUGI__NO_INLINE -#endif - -// uintptr_t -#if (defined(_MSC_VER) && _MSC_VER < 1600) || (defined(__BORLANDC__) && __BORLANDC__ < 0x561) -namespace pugi -{ -# ifndef _UINTPTR_T_DEFINED - typedef size_t uintptr_t; -# endif - - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; -} -#else -# include -#endif - -// Memory allocation -PUGI__NS_BEGIN - PUGI__FN void* default_allocate(size_t size) - { - return malloc(size); - } - - PUGI__FN void default_deallocate(void* ptr) - { - free(ptr); - } - - template - struct xml_memory_management_function_storage - { - static allocation_function allocate; - static deallocation_function deallocate; - }; - - // Global allocation functions are stored in class statics so that in header mode linker deduplicates them - // Without a template<> we'll get multiple definitions of the same static - template allocation_function xml_memory_management_function_storage::allocate = default_allocate; - template deallocation_function xml_memory_management_function_storage::deallocate = default_deallocate; - - typedef xml_memory_management_function_storage xml_memory; -PUGI__NS_END - -// String utilities -PUGI__NS_BEGIN - // Get string length - PUGI__FN size_t strlength(const char_t* s) - { - assert(s); - - #ifdef PUGIXML_WCHAR_MODE - return wcslen(s); - #else - return strlen(s); - #endif - } - - // Compare two strings - PUGI__FN bool strequal(const char_t* src, const char_t* dst) - { - assert(src && dst); - - #ifdef PUGIXML_WCHAR_MODE - return wcscmp(src, dst) == 0; - #else - return strcmp(src, dst) == 0; - #endif - } - - // Compare lhs with [rhs_begin, rhs_end) - PUGI__FN bool strequalrange(const char_t* lhs, const char_t* rhs, size_t count) - { - for (size_t i = 0; i < count; ++i) - if (lhs[i] != rhs[i]) - return false; - - return lhs[count] == 0; - } - - // Get length of wide string, even if CRT lacks wide character support - PUGI__FN size_t strlength_wide(const wchar_t* s) - { - assert(s); - - #ifdef PUGIXML_WCHAR_MODE - return wcslen(s); - #else - const wchar_t* end = s; - while (*end) end++; - return static_cast(end - s); - #endif - } -PUGI__NS_END - -// auto_ptr-like object for exception recovery -PUGI__NS_BEGIN - template struct auto_deleter - { - typedef void (*D)(T*); - - T* data; - D deleter; - - auto_deleter(T* data_, D deleter_): data(data_), deleter(deleter_) - { - } - - ~auto_deleter() - { - if (data) deleter(data); - } - - T* release() - { - T* result = data; - data = 0; - return result; - } - }; -PUGI__NS_END - -#ifdef PUGIXML_COMPACT -PUGI__NS_BEGIN - class compact_hash_table - { - public: - compact_hash_table(): _items(0), _capacity(0), _count(0) - { - } - - void clear() - { - if (_items) - { - xml_memory::deallocate(_items); - _items = 0; - _capacity = 0; - _count = 0; - } - } - - void* find(const void* key) - { - if (_capacity == 0) return 0; - - item_t* item = get_item(key); - assert(item); - assert(item->key == key || (item->key == 0 && item->value == 0)); - - return item->value; - } - - void insert(const void* key, void* value) - { - assert(_capacity != 0 && _count < _capacity - _capacity / 4); - - item_t* item = get_item(key); - assert(item); - - if (item->key == 0) - { - _count++; - item->key = key; - } - - item->value = value; - } - - bool reserve(size_t extra = 16) - { - if (_count + extra >= _capacity - _capacity / 4) - return rehash(_count + extra); - - return true; - } - - private: - struct item_t - { - const void* key; - void* value; - }; - - item_t* _items; - size_t _capacity; - - size_t _count; - - bool rehash(size_t count); - - item_t* get_item(const void* key) - { - assert(key); - assert(_capacity > 0); - - size_t hashmod = _capacity - 1; - size_t bucket = hash(key) & hashmod; - - for (size_t probe = 0; probe <= hashmod; ++probe) - { - item_t& probe_item = _items[bucket]; - - if (probe_item.key == key || probe_item.key == 0) - return &probe_item; - - // hash collision, quadratic probing - bucket = (bucket + probe + 1) & hashmod; - } - - assert(false && "Hash table is full"); // unreachable - return 0; - } - - static PUGI__UNSIGNED_OVERFLOW unsigned int hash(const void* key) - { - unsigned int h = static_cast(reinterpret_cast(key)); - - // MurmurHash3 32-bit finalizer - h ^= h >> 16; - h *= 0x85ebca6bu; - h ^= h >> 13; - h *= 0xc2b2ae35u; - h ^= h >> 16; - - return h; - } - }; - - PUGI__FN_NO_INLINE bool compact_hash_table::rehash(size_t count) - { - size_t capacity = 32; - while (count >= capacity - capacity / 4) - capacity *= 2; - - compact_hash_table rt; - rt._capacity = capacity; - rt._items = static_cast(xml_memory::allocate(sizeof(item_t) * capacity)); - - if (!rt._items) - return false; - - memset(rt._items, 0, sizeof(item_t) * capacity); - - for (size_t i = 0; i < _capacity; ++i) - if (_items[i].key) - rt.insert(_items[i].key, _items[i].value); - - if (_items) - xml_memory::deallocate(_items); - - _capacity = capacity; - _items = rt._items; - - assert(_count == rt._count); - - return true; - } - -PUGI__NS_END -#endif - -PUGI__NS_BEGIN -#ifdef PUGIXML_COMPACT - static const uintptr_t xml_memory_block_alignment = 4; -#else - static const uintptr_t xml_memory_block_alignment = sizeof(void*); -#endif - - // extra metadata bits - static const uintptr_t xml_memory_page_contents_shared_mask = 64; - static const uintptr_t xml_memory_page_name_allocated_mask = 32; - static const uintptr_t xml_memory_page_value_allocated_mask = 16; - static const uintptr_t xml_memory_page_type_mask = 15; - - // combined masks for string uniqueness - static const uintptr_t xml_memory_page_name_allocated_or_shared_mask = xml_memory_page_name_allocated_mask | xml_memory_page_contents_shared_mask; - static const uintptr_t xml_memory_page_value_allocated_or_shared_mask = xml_memory_page_value_allocated_mask | xml_memory_page_contents_shared_mask; - -#ifdef PUGIXML_COMPACT - #define PUGI__GETHEADER_IMPL(object, page, flags) // unused - #define PUGI__GETPAGE_IMPL(header) (header).get_page() -#else - #define PUGI__GETHEADER_IMPL(object, page, flags) (((reinterpret_cast(object) - reinterpret_cast(page)) << 8) | (flags)) - // this macro casts pointers through void* to avoid 'cast increases required alignment of target type' warnings - #define PUGI__GETPAGE_IMPL(header) static_cast(const_cast(static_cast(reinterpret_cast(&header) - (header >> 8)))) -#endif - - #define PUGI__GETPAGE(n) PUGI__GETPAGE_IMPL((n)->header) - #define PUGI__NODETYPE(n) static_cast((n)->header & impl::xml_memory_page_type_mask) - - struct xml_allocator; - - struct xml_memory_page - { - static xml_memory_page* construct(void* memory) - { - xml_memory_page* result = static_cast(memory); - - result->allocator = 0; - result->prev = 0; - result->next = 0; - result->busy_size = 0; - result->freed_size = 0; - - #ifdef PUGIXML_COMPACT - result->compact_string_base = 0; - result->compact_shared_parent = 0; - result->compact_page_marker = 0; - #endif - - return result; - } - - xml_allocator* allocator; - - xml_memory_page* prev; - xml_memory_page* next; - - size_t busy_size; - size_t freed_size; - - #ifdef PUGIXML_COMPACT - char_t* compact_string_base; - void* compact_shared_parent; - uint32_t* compact_page_marker; - #endif - }; - - static const size_t xml_memory_page_size = - #ifdef PUGIXML_MEMORY_PAGE_SIZE - (PUGIXML_MEMORY_PAGE_SIZE) - #else - 32768 - #endif - - sizeof(xml_memory_page); - - struct xml_memory_string_header - { - uint16_t page_offset; // offset from page->data - uint16_t full_size; // 0 if string occupies whole page - }; - - struct xml_allocator - { - xml_allocator(xml_memory_page* root): _root(root), _busy_size(root->busy_size) - { - #ifdef PUGIXML_COMPACT - _hash = 0; - #endif - } - - xml_memory_page* allocate_page(size_t data_size) - { - size_t size = sizeof(xml_memory_page) + data_size; - - // allocate block with some alignment, leaving memory for worst-case padding - void* memory = xml_memory::allocate(size); - if (!memory) return 0; - - // prepare page structure - xml_memory_page* page = xml_memory_page::construct(memory); - assert(page); - - page->allocator = _root->allocator; - - return page; - } - - static void deallocate_page(xml_memory_page* page) - { - xml_memory::deallocate(page); - } - - void* allocate_memory_oob(size_t size, xml_memory_page*& out_page); - - void* allocate_memory(size_t size, xml_memory_page*& out_page) - { - if (PUGI__UNLIKELY(_busy_size + size > xml_memory_page_size)) - return allocate_memory_oob(size, out_page); - - void* buf = reinterpret_cast(_root) + sizeof(xml_memory_page) + _busy_size; - - _busy_size += size; - - out_page = _root; - - return buf; - } - - #ifdef PUGIXML_COMPACT - void* allocate_object(size_t size, xml_memory_page*& out_page) - { - void* result = allocate_memory(size + sizeof(uint32_t), out_page); - if (!result) return 0; - - // adjust for marker - ptrdiff_t offset = static_cast(result) - reinterpret_cast(out_page->compact_page_marker); - - if (PUGI__UNLIKELY(static_cast(offset) >= 256 * xml_memory_block_alignment)) - { - // insert new marker - uint32_t* marker = static_cast(result); - - *marker = static_cast(reinterpret_cast(marker) - reinterpret_cast(out_page)); - out_page->compact_page_marker = marker; - - // since we don't reuse the page space until we reallocate it, we can just pretend that we freed the marker block - // this will make sure deallocate_memory correctly tracks the size - out_page->freed_size += sizeof(uint32_t); - - return marker + 1; - } - else - { - // roll back uint32_t part - _busy_size -= sizeof(uint32_t); - - return result; - } - } - #else - void* allocate_object(size_t size, xml_memory_page*& out_page) - { - return allocate_memory(size, out_page); - } - #endif - - void deallocate_memory(void* ptr, size_t size, xml_memory_page* page) - { - if (page == _root) page->busy_size = _busy_size; - - assert(ptr >= reinterpret_cast(page) + sizeof(xml_memory_page) && ptr < reinterpret_cast(page) + sizeof(xml_memory_page) + page->busy_size); - (void)!ptr; - - page->freed_size += size; - assert(page->freed_size <= page->busy_size); - - if (page->freed_size == page->busy_size) - { - if (page->next == 0) - { - assert(_root == page); - - // top page freed, just reset sizes - page->busy_size = 0; - page->freed_size = 0; - - #ifdef PUGIXML_COMPACT - // reset compact state to maximize efficiency - page->compact_string_base = 0; - page->compact_shared_parent = 0; - page->compact_page_marker = 0; - #endif - - _busy_size = 0; - } - else - { - assert(_root != page); - assert(page->prev); - - // remove from the list - page->prev->next = page->next; - page->next->prev = page->prev; - - // deallocate - deallocate_page(page); - } - } - } - - char_t* allocate_string(size_t length) - { - static const size_t max_encoded_offset = (1 << 16) * xml_memory_block_alignment; - - PUGI__STATIC_ASSERT(xml_memory_page_size <= max_encoded_offset); - - // allocate memory for string and header block - size_t size = sizeof(xml_memory_string_header) + length * sizeof(char_t); - - // round size up to block alignment boundary - size_t full_size = (size + (xml_memory_block_alignment - 1)) & ~(xml_memory_block_alignment - 1); - - xml_memory_page* page; - xml_memory_string_header* header = static_cast(allocate_memory(full_size, page)); - - if (!header) return 0; - - // setup header - ptrdiff_t page_offset = reinterpret_cast(header) - reinterpret_cast(page) - sizeof(xml_memory_page); - - assert(page_offset % xml_memory_block_alignment == 0); - assert(page_offset >= 0 && static_cast(page_offset) < max_encoded_offset); - header->page_offset = static_cast(static_cast(page_offset) / xml_memory_block_alignment); - - // full_size == 0 for large strings that occupy the whole page - assert(full_size % xml_memory_block_alignment == 0); - assert(full_size < max_encoded_offset || (page->busy_size == full_size && page_offset == 0)); - header->full_size = static_cast(full_size < max_encoded_offset ? full_size / xml_memory_block_alignment : 0); - - // round-trip through void* to avoid 'cast increases required alignment of target type' warning - // header is guaranteed a pointer-sized alignment, which should be enough for char_t - return static_cast(static_cast(header + 1)); - } - - void deallocate_string(char_t* string) - { - // this function casts pointers through void* to avoid 'cast increases required alignment of target type' warnings - // we're guaranteed the proper (pointer-sized) alignment on the input string if it was allocated via allocate_string - - // get header - xml_memory_string_header* header = static_cast(static_cast(string)) - 1; - assert(header); - - // deallocate - size_t page_offset = sizeof(xml_memory_page) + header->page_offset * xml_memory_block_alignment; - xml_memory_page* page = reinterpret_cast(static_cast(reinterpret_cast(header) - page_offset)); - - // if full_size == 0 then this string occupies the whole page - size_t full_size = header->full_size == 0 ? page->busy_size : header->full_size * xml_memory_block_alignment; - - deallocate_memory(header, full_size, page); - } - - bool reserve() - { - #ifdef PUGIXML_COMPACT - return _hash->reserve(); - #else - return true; - #endif - } - - xml_memory_page* _root; - size_t _busy_size; - - #ifdef PUGIXML_COMPACT - compact_hash_table* _hash; - #endif - }; - - PUGI__FN_NO_INLINE void* xml_allocator::allocate_memory_oob(size_t size, xml_memory_page*& out_page) - { - const size_t large_allocation_threshold = xml_memory_page_size / 4; - - xml_memory_page* page = allocate_page(size <= large_allocation_threshold ? xml_memory_page_size : size); - out_page = page; - - if (!page) return 0; - - if (size <= large_allocation_threshold) - { - _root->busy_size = _busy_size; - - // insert page at the end of linked list - page->prev = _root; - _root->next = page; - _root = page; - - _busy_size = size; - } - else - { - // insert page before the end of linked list, so that it is deleted as soon as possible - // the last page is not deleted even if it's empty (see deallocate_memory) - assert(_root->prev); - - page->prev = _root->prev; - page->next = _root; - - _root->prev->next = page; - _root->prev = page; - - page->busy_size = size; - } - - return reinterpret_cast(page) + sizeof(xml_memory_page); - } -PUGI__NS_END - -#ifdef PUGIXML_COMPACT -PUGI__NS_BEGIN - static const uintptr_t compact_alignment_log2 = 2; - static const uintptr_t compact_alignment = 1 << compact_alignment_log2; - - class compact_header - { - public: - compact_header(xml_memory_page* page, unsigned int flags) - { - PUGI__STATIC_ASSERT(xml_memory_block_alignment == compact_alignment); - - ptrdiff_t offset = (reinterpret_cast(this) - reinterpret_cast(page->compact_page_marker)); - assert(offset % compact_alignment == 0 && static_cast(offset) < 256 * compact_alignment); - - _page = static_cast(offset >> compact_alignment_log2); - _flags = static_cast(flags); - } - - void operator&=(uintptr_t mod) - { - _flags &= static_cast(mod); - } - - void operator|=(uintptr_t mod) - { - _flags |= static_cast(mod); - } - - uintptr_t operator&(uintptr_t mod) const - { - return _flags & mod; - } - - xml_memory_page* get_page() const - { - // round-trip through void* to silence 'cast increases required alignment of target type' warnings - const char* page_marker = reinterpret_cast(this) - (_page << compact_alignment_log2); - const char* page = page_marker - *reinterpret_cast(static_cast(page_marker)); - - return const_cast(reinterpret_cast(static_cast(page))); - } - - private: - unsigned char _page; - unsigned char _flags; - }; - - PUGI__FN xml_memory_page* compact_get_page(const void* object, int header_offset) - { - const compact_header* header = reinterpret_cast(static_cast(object) - header_offset); - - return header->get_page(); - } - - template PUGI__FN_NO_INLINE T* compact_get_value(const void* object) - { - return static_cast(compact_get_page(object, header_offset)->allocator->_hash->find(object)); - } - - template PUGI__FN_NO_INLINE void compact_set_value(const void* object, T* value) - { - compact_get_page(object, header_offset)->allocator->_hash->insert(object, value); - } - - template class compact_pointer - { - public: - compact_pointer(): _data(0) - { - } - - void operator=(const compact_pointer& rhs) - { - *this = rhs + 0; - } - - void operator=(T* value) - { - if (value) - { - // value is guaranteed to be compact-aligned; 'this' is not - // our decoding is based on 'this' aligned to compact alignment downwards (see operator T*) - // so for negative offsets (e.g. -3) we need to adjust the diff by compact_alignment - 1 to - // compensate for arithmetic shift rounding for negative values - ptrdiff_t diff = reinterpret_cast(value) - reinterpret_cast(this); - ptrdiff_t offset = ((diff + int(compact_alignment - 1)) >> compact_alignment_log2) - start; - - if (static_cast(offset) <= 253) - _data = static_cast(offset + 1); - else - { - compact_set_value(this, value); - - _data = 255; - } - } - else - _data = 0; - } - - operator T*() const - { - if (_data) - { - if (_data < 255) - { - uintptr_t base = reinterpret_cast(this) & ~(compact_alignment - 1); - - return reinterpret_cast(base + (_data - 1 + start) * compact_alignment); - } - else - return compact_get_value(this); - } - else - return 0; - } - - T* operator->() const - { - return *this; - } - - private: - unsigned char _data; - }; - - template class compact_pointer_parent - { - public: - compact_pointer_parent(): _data(0) - { - } - - void operator=(const compact_pointer_parent& rhs) - { - *this = rhs + 0; - } - - void operator=(T* value) - { - if (value) - { - // value is guaranteed to be compact-aligned; 'this' is not - // our decoding is based on 'this' aligned to compact alignment downwards (see operator T*) - // so for negative offsets (e.g. -3) we need to adjust the diff by compact_alignment - 1 to - // compensate for arithmetic shift behavior for negative values - ptrdiff_t diff = reinterpret_cast(value) - reinterpret_cast(this); - ptrdiff_t offset = ((diff + int(compact_alignment - 1)) >> compact_alignment_log2) + 65533; - - if (static_cast(offset) <= 65533) - { - _data = static_cast(offset + 1); - } - else - { - xml_memory_page* page = compact_get_page(this, header_offset); - - if (PUGI__UNLIKELY(page->compact_shared_parent == 0)) - page->compact_shared_parent = value; - - if (page->compact_shared_parent == value) - { - _data = 65534; - } - else - { - compact_set_value(this, value); - - _data = 65535; - } - } - } - else - { - _data = 0; - } - } - - operator T*() const - { - if (_data) - { - if (_data < 65534) - { - uintptr_t base = reinterpret_cast(this) & ~(compact_alignment - 1); - - return reinterpret_cast(base + (_data - 1 - 65533) * compact_alignment); - } - else if (_data == 65534) - return static_cast(compact_get_page(this, header_offset)->compact_shared_parent); - else - return compact_get_value(this); - } - else - return 0; - } - - T* operator->() const - { - return *this; - } - - private: - uint16_t _data; - }; - - template class compact_string - { - public: - compact_string(): _data(0) - { - } - - void operator=(const compact_string& rhs) - { - *this = rhs + 0; - } - - void operator=(char_t* value) - { - if (value) - { - xml_memory_page* page = compact_get_page(this, header_offset); - - if (PUGI__UNLIKELY(page->compact_string_base == 0)) - page->compact_string_base = value; - - ptrdiff_t offset = value - page->compact_string_base; - - if (static_cast(offset) < (65535 << 7)) - { - // round-trip through void* to silence 'cast increases required alignment of target type' warnings - uint16_t* base = reinterpret_cast(static_cast(reinterpret_cast(this) - base_offset)); - - if (*base == 0) - { - *base = static_cast((offset >> 7) + 1); - _data = static_cast((offset & 127) + 1); - } - else - { - ptrdiff_t remainder = offset - ((*base - 1) << 7); - - if (static_cast(remainder) <= 253) - { - _data = static_cast(remainder + 1); - } - else - { - compact_set_value(this, value); - - _data = 255; - } - } - } - else - { - compact_set_value(this, value); - - _data = 255; - } - } - else - { - _data = 0; - } - } - - operator char_t*() const - { - if (_data) - { - if (_data < 255) - { - xml_memory_page* page = compact_get_page(this, header_offset); - - // round-trip through void* to silence 'cast increases required alignment of target type' warnings - const uint16_t* base = reinterpret_cast(static_cast(reinterpret_cast(this) - base_offset)); - assert(*base); - - ptrdiff_t offset = ((*base - 1) << 7) + (_data - 1); - - return page->compact_string_base + offset; - } - else - { - return compact_get_value(this); - } - } - else - return 0; - } - - private: - unsigned char _data; - }; -PUGI__NS_END -#endif - -#ifdef PUGIXML_COMPACT -namespace pugi -{ - struct xml_attribute_struct - { - xml_attribute_struct(impl::xml_memory_page* page): header(page, 0), namevalue_base(0) - { - PUGI__STATIC_ASSERT(sizeof(xml_attribute_struct) == 8); - } - - impl::compact_header header; - - uint16_t namevalue_base; - - impl::compact_string<4, 2> name; - impl::compact_string<5, 3> value; - - impl::compact_pointer prev_attribute_c; - impl::compact_pointer next_attribute; - }; - - struct xml_node_struct - { - xml_node_struct(impl::xml_memory_page* page, xml_node_type type): header(page, type), namevalue_base(0) - { - PUGI__STATIC_ASSERT(sizeof(xml_node_struct) == 12); - } - - impl::compact_header header; - - uint16_t namevalue_base; - - impl::compact_string<4, 2> name; - impl::compact_string<5, 3> value; - - impl::compact_pointer_parent parent; - - impl::compact_pointer first_child; - - impl::compact_pointer prev_sibling_c; - impl::compact_pointer next_sibling; - - impl::compact_pointer first_attribute; - }; -} -#else -namespace pugi -{ - struct xml_attribute_struct - { - xml_attribute_struct(impl::xml_memory_page* page): name(0), value(0), prev_attribute_c(0), next_attribute(0) - { - header = PUGI__GETHEADER_IMPL(this, page, 0); - } - - uintptr_t header; - - char_t* name; - char_t* value; - - xml_attribute_struct* prev_attribute_c; - xml_attribute_struct* next_attribute; - }; - - struct xml_node_struct - { - xml_node_struct(impl::xml_memory_page* page, xml_node_type type): name(0), value(0), parent(0), first_child(0), prev_sibling_c(0), next_sibling(0), first_attribute(0) - { - header = PUGI__GETHEADER_IMPL(this, page, type); - } - - uintptr_t header; - - char_t* name; - char_t* value; - - xml_node_struct* parent; - - xml_node_struct* first_child; - - xml_node_struct* prev_sibling_c; - xml_node_struct* next_sibling; - - xml_attribute_struct* first_attribute; - }; -} -#endif - -PUGI__NS_BEGIN - struct xml_extra_buffer - { - char_t* buffer; - xml_extra_buffer* next; - }; - - struct xml_document_struct: public xml_node_struct, public xml_allocator - { - xml_document_struct(xml_memory_page* page): xml_node_struct(page, node_document), xml_allocator(page), buffer(0), extra_buffers(0) - { - } - - const char_t* buffer; - - xml_extra_buffer* extra_buffers; - - #ifdef PUGIXML_COMPACT - compact_hash_table hash; - #endif - }; - - template inline xml_allocator& get_allocator(const Object* object) - { - assert(object); - - return *PUGI__GETPAGE(object)->allocator; - } - - template inline xml_document_struct& get_document(const Object* object) - { - assert(object); - - return *static_cast(PUGI__GETPAGE(object)->allocator); - } -PUGI__NS_END - -// Low-level DOM operations -PUGI__NS_BEGIN - inline xml_attribute_struct* allocate_attribute(xml_allocator& alloc) - { - xml_memory_page* page; - void* memory = alloc.allocate_object(sizeof(xml_attribute_struct), page); - if (!memory) return 0; - - return new (memory) xml_attribute_struct(page); - } - - inline xml_node_struct* allocate_node(xml_allocator& alloc, xml_node_type type) - { - xml_memory_page* page; - void* memory = alloc.allocate_object(sizeof(xml_node_struct), page); - if (!memory) return 0; - - return new (memory) xml_node_struct(page, type); - } - - inline void destroy_attribute(xml_attribute_struct* a, xml_allocator& alloc) - { - if (a->header & impl::xml_memory_page_name_allocated_mask) - alloc.deallocate_string(a->name); - - if (a->header & impl::xml_memory_page_value_allocated_mask) - alloc.deallocate_string(a->value); - - alloc.deallocate_memory(a, sizeof(xml_attribute_struct), PUGI__GETPAGE(a)); - } - - inline void destroy_node(xml_node_struct* n, xml_allocator& alloc) - { - if (n->header & impl::xml_memory_page_name_allocated_mask) - alloc.deallocate_string(n->name); - - if (n->header & impl::xml_memory_page_value_allocated_mask) - alloc.deallocate_string(n->value); - - for (xml_attribute_struct* attr = n->first_attribute; attr; ) - { - xml_attribute_struct* next = attr->next_attribute; - - destroy_attribute(attr, alloc); - - attr = next; - } - - for (xml_node_struct* child = n->first_child; child; ) - { - xml_node_struct* next = child->next_sibling; - - destroy_node(child, alloc); - - child = next; - } - - alloc.deallocate_memory(n, sizeof(xml_node_struct), PUGI__GETPAGE(n)); - } - - inline void append_node(xml_node_struct* child, xml_node_struct* node) - { - child->parent = node; - - xml_node_struct* head = node->first_child; - - if (head) - { - xml_node_struct* tail = head->prev_sibling_c; - - tail->next_sibling = child; - child->prev_sibling_c = tail; - head->prev_sibling_c = child; - } - else - { - node->first_child = child; - child->prev_sibling_c = child; - } - } - - inline void prepend_node(xml_node_struct* child, xml_node_struct* node) - { - child->parent = node; - - xml_node_struct* head = node->first_child; - - if (head) - { - child->prev_sibling_c = head->prev_sibling_c; - head->prev_sibling_c = child; - } - else - child->prev_sibling_c = child; - - child->next_sibling = head; - node->first_child = child; - } - - inline void insert_node_after(xml_node_struct* child, xml_node_struct* node) - { - xml_node_struct* parent = node->parent; - - child->parent = parent; - - if (node->next_sibling) - node->next_sibling->prev_sibling_c = child; - else - parent->first_child->prev_sibling_c = child; - - child->next_sibling = node->next_sibling; - child->prev_sibling_c = node; - - node->next_sibling = child; - } - - inline void insert_node_before(xml_node_struct* child, xml_node_struct* node) - { - xml_node_struct* parent = node->parent; - - child->parent = parent; - - if (node->prev_sibling_c->next_sibling) - node->prev_sibling_c->next_sibling = child; - else - parent->first_child = child; - - child->prev_sibling_c = node->prev_sibling_c; - child->next_sibling = node; - - node->prev_sibling_c = child; - } - - inline void remove_node(xml_node_struct* node) - { - xml_node_struct* parent = node->parent; - - if (node->next_sibling) - node->next_sibling->prev_sibling_c = node->prev_sibling_c; - else - parent->first_child->prev_sibling_c = node->prev_sibling_c; - - if (node->prev_sibling_c->next_sibling) - node->prev_sibling_c->next_sibling = node->next_sibling; - else - parent->first_child = node->next_sibling; - - node->parent = 0; - node->prev_sibling_c = 0; - node->next_sibling = 0; - } - - inline void append_attribute(xml_attribute_struct* attr, xml_node_struct* node) - { - xml_attribute_struct* head = node->first_attribute; - - if (head) - { - xml_attribute_struct* tail = head->prev_attribute_c; - - tail->next_attribute = attr; - attr->prev_attribute_c = tail; - head->prev_attribute_c = attr; - } - else - { - node->first_attribute = attr; - attr->prev_attribute_c = attr; - } - } - - inline void prepend_attribute(xml_attribute_struct* attr, xml_node_struct* node) - { - xml_attribute_struct* head = node->first_attribute; - - if (head) - { - attr->prev_attribute_c = head->prev_attribute_c; - head->prev_attribute_c = attr; - } - else - attr->prev_attribute_c = attr; - - attr->next_attribute = head; - node->first_attribute = attr; - } - - inline void insert_attribute_after(xml_attribute_struct* attr, xml_attribute_struct* place, xml_node_struct* node) - { - if (place->next_attribute) - place->next_attribute->prev_attribute_c = attr; - else - node->first_attribute->prev_attribute_c = attr; - - attr->next_attribute = place->next_attribute; - attr->prev_attribute_c = place; - place->next_attribute = attr; - } - - inline void insert_attribute_before(xml_attribute_struct* attr, xml_attribute_struct* place, xml_node_struct* node) - { - if (place->prev_attribute_c->next_attribute) - place->prev_attribute_c->next_attribute = attr; - else - node->first_attribute = attr; - - attr->prev_attribute_c = place->prev_attribute_c; - attr->next_attribute = place; - place->prev_attribute_c = attr; - } - - inline void remove_attribute(xml_attribute_struct* attr, xml_node_struct* node) - { - if (attr->next_attribute) - attr->next_attribute->prev_attribute_c = attr->prev_attribute_c; - else - node->first_attribute->prev_attribute_c = attr->prev_attribute_c; - - if (attr->prev_attribute_c->next_attribute) - attr->prev_attribute_c->next_attribute = attr->next_attribute; - else - node->first_attribute = attr->next_attribute; - - attr->prev_attribute_c = 0; - attr->next_attribute = 0; - } - - PUGI__FN_NO_INLINE xml_node_struct* append_new_node(xml_node_struct* node, xml_allocator& alloc, xml_node_type type = node_element) - { - if (!alloc.reserve()) return 0; - - xml_node_struct* child = allocate_node(alloc, type); - if (!child) return 0; - - append_node(child, node); - - return child; - } - - PUGI__FN_NO_INLINE xml_attribute_struct* append_new_attribute(xml_node_struct* node, xml_allocator& alloc) - { - if (!alloc.reserve()) return 0; - - xml_attribute_struct* attr = allocate_attribute(alloc); - if (!attr) return 0; - - append_attribute(attr, node); - - return attr; - } -PUGI__NS_END - -// Helper classes for code generation -PUGI__NS_BEGIN - struct opt_false - { - enum { value = 0 }; - }; - - struct opt_true - { - enum { value = 1 }; - }; -PUGI__NS_END - -// Unicode utilities -PUGI__NS_BEGIN - inline uint16_t endian_swap(uint16_t value) - { - return static_cast(((value & 0xff) << 8) | (value >> 8)); - } - - inline uint32_t endian_swap(uint32_t value) - { - return ((value & 0xff) << 24) | ((value & 0xff00) << 8) | ((value & 0xff0000) >> 8) | (value >> 24); - } - - struct utf8_counter - { - typedef size_t value_type; - - static value_type low(value_type result, uint32_t ch) - { - // U+0000..U+007F - if (ch < 0x80) return result + 1; - // U+0080..U+07FF - else if (ch < 0x800) return result + 2; - // U+0800..U+FFFF - else return result + 3; - } - - static value_type high(value_type result, uint32_t) - { - // U+10000..U+10FFFF - return result + 4; - } - }; - - struct utf8_writer - { - typedef uint8_t* value_type; - - static value_type low(value_type result, uint32_t ch) - { - // U+0000..U+007F - if (ch < 0x80) - { - *result = static_cast(ch); - return result + 1; - } - // U+0080..U+07FF - else if (ch < 0x800) - { - result[0] = static_cast(0xC0 | (ch >> 6)); - result[1] = static_cast(0x80 | (ch & 0x3F)); - return result + 2; - } - // U+0800..U+FFFF - else - { - result[0] = static_cast(0xE0 | (ch >> 12)); - result[1] = static_cast(0x80 | ((ch >> 6) & 0x3F)); - result[2] = static_cast(0x80 | (ch & 0x3F)); - return result + 3; - } - } - - static value_type high(value_type result, uint32_t ch) - { - // U+10000..U+10FFFF - result[0] = static_cast(0xF0 | (ch >> 18)); - result[1] = static_cast(0x80 | ((ch >> 12) & 0x3F)); - result[2] = static_cast(0x80 | ((ch >> 6) & 0x3F)); - result[3] = static_cast(0x80 | (ch & 0x3F)); - return result + 4; - } - - static value_type any(value_type result, uint32_t ch) - { - return (ch < 0x10000) ? low(result, ch) : high(result, ch); - } - }; - - struct utf16_counter - { - typedef size_t value_type; - - static value_type low(value_type result, uint32_t) - { - return result + 1; - } - - static value_type high(value_type result, uint32_t) - { - return result + 2; - } - }; - - struct utf16_writer - { - typedef uint16_t* value_type; - - static value_type low(value_type result, uint32_t ch) - { - *result = static_cast(ch); - - return result + 1; - } - - static value_type high(value_type result, uint32_t ch) - { - uint32_t msh = static_cast(ch - 0x10000) >> 10; - uint32_t lsh = static_cast(ch - 0x10000) & 0x3ff; - - result[0] = static_cast(0xD800 + msh); - result[1] = static_cast(0xDC00 + lsh); - - return result + 2; - } - - static value_type any(value_type result, uint32_t ch) - { - return (ch < 0x10000) ? low(result, ch) : high(result, ch); - } - }; - - struct utf32_counter - { - typedef size_t value_type; - - static value_type low(value_type result, uint32_t) - { - return result + 1; - } - - static value_type high(value_type result, uint32_t) - { - return result + 1; - } - }; - - struct utf32_writer - { - typedef uint32_t* value_type; - - static value_type low(value_type result, uint32_t ch) - { - *result = ch; - - return result + 1; - } - - static value_type high(value_type result, uint32_t ch) - { - *result = ch; - - return result + 1; - } - - static value_type any(value_type result, uint32_t ch) - { - *result = ch; - - return result + 1; - } - }; - - struct latin1_writer - { - typedef uint8_t* value_type; - - static value_type low(value_type result, uint32_t ch) - { - *result = static_cast(ch > 255 ? '?' : ch); - - return result + 1; - } - - static value_type high(value_type result, uint32_t ch) - { - (void)ch; - - *result = '?'; - - return result + 1; - } - }; - - struct utf8_decoder - { - typedef uint8_t type; - - template static inline typename Traits::value_type process(const uint8_t* data, size_t size, typename Traits::value_type result, Traits) - { - const uint8_t utf8_byte_mask = 0x3f; - - while (size) - { - uint8_t lead = *data; - - // 0xxxxxxx -> U+0000..U+007F - if (lead < 0x80) - { - result = Traits::low(result, lead); - data += 1; - size -= 1; - - // process aligned single-byte (ascii) blocks - if ((reinterpret_cast(data) & 3) == 0) - { - // round-trip through void* to silence 'cast increases required alignment of target type' warnings - while (size >= 4 && (*static_cast(static_cast(data)) & 0x80808080) == 0) - { - result = Traits::low(result, data[0]); - result = Traits::low(result, data[1]); - result = Traits::low(result, data[2]); - result = Traits::low(result, data[3]); - data += 4; - size -= 4; - } - } - } - // 110xxxxx -> U+0080..U+07FF - else if (static_cast(lead - 0xC0) < 0x20 && size >= 2 && (data[1] & 0xc0) == 0x80) - { - result = Traits::low(result, ((lead & ~0xC0) << 6) | (data[1] & utf8_byte_mask)); - data += 2; - size -= 2; - } - // 1110xxxx -> U+0800-U+FFFF - else if (static_cast(lead - 0xE0) < 0x10 && size >= 3 && (data[1] & 0xc0) == 0x80 && (data[2] & 0xc0) == 0x80) - { - result = Traits::low(result, ((lead & ~0xE0) << 12) | ((data[1] & utf8_byte_mask) << 6) | (data[2] & utf8_byte_mask)); - data += 3; - size -= 3; - } - // 11110xxx -> U+10000..U+10FFFF - else if (static_cast(lead - 0xF0) < 0x08 && size >= 4 && (data[1] & 0xc0) == 0x80 && (data[2] & 0xc0) == 0x80 && (data[3] & 0xc0) == 0x80) - { - result = Traits::high(result, ((lead & ~0xF0) << 18) | ((data[1] & utf8_byte_mask) << 12) | ((data[2] & utf8_byte_mask) << 6) | (data[3] & utf8_byte_mask)); - data += 4; - size -= 4; - } - // 10xxxxxx or 11111xxx -> invalid - else - { - data += 1; - size -= 1; - } - } - - return result; - } - }; - - template struct utf16_decoder - { - typedef uint16_t type; - - template static inline typename Traits::value_type process(const uint16_t* data, size_t size, typename Traits::value_type result, Traits) - { - while (size) - { - uint16_t lead = opt_swap::value ? endian_swap(*data) : *data; - - // U+0000..U+D7FF - if (lead < 0xD800) - { - result = Traits::low(result, lead); - data += 1; - size -= 1; - } - // U+E000..U+FFFF - else if (static_cast(lead - 0xE000) < 0x2000) - { - result = Traits::low(result, lead); - data += 1; - size -= 1; - } - // surrogate pair lead - else if (static_cast(lead - 0xD800) < 0x400 && size >= 2) - { - uint16_t next = opt_swap::value ? endian_swap(data[1]) : data[1]; - - if (static_cast(next - 0xDC00) < 0x400) - { - result = Traits::high(result, 0x10000 + ((lead & 0x3ff) << 10) + (next & 0x3ff)); - data += 2; - size -= 2; - } - else - { - data += 1; - size -= 1; - } - } - else - { - data += 1; - size -= 1; - } - } - - return result; - } - }; - - template struct utf32_decoder - { - typedef uint32_t type; - - template static inline typename Traits::value_type process(const uint32_t* data, size_t size, typename Traits::value_type result, Traits) - { - while (size) - { - uint32_t lead = opt_swap::value ? endian_swap(*data) : *data; - - // U+0000..U+FFFF - if (lead < 0x10000) - { - result = Traits::low(result, lead); - data += 1; - size -= 1; - } - // U+10000..U+10FFFF - else - { - result = Traits::high(result, lead); - data += 1; - size -= 1; - } - } - - return result; - } - }; - - struct latin1_decoder - { - typedef uint8_t type; - - template static inline typename Traits::value_type process(const uint8_t* data, size_t size, typename Traits::value_type result, Traits) - { - while (size) - { - result = Traits::low(result, *data); - data += 1; - size -= 1; - } - - return result; - } - }; - - template struct wchar_selector; - - template <> struct wchar_selector<2> - { - typedef uint16_t type; - typedef utf16_counter counter; - typedef utf16_writer writer; - typedef utf16_decoder decoder; - }; - - template <> struct wchar_selector<4> - { - typedef uint32_t type; - typedef utf32_counter counter; - typedef utf32_writer writer; - typedef utf32_decoder decoder; - }; - - typedef wchar_selector::counter wchar_counter; - typedef wchar_selector::writer wchar_writer; - - struct wchar_decoder - { - typedef wchar_t type; - - template static inline typename Traits::value_type process(const wchar_t* data, size_t size, typename Traits::value_type result, Traits traits) - { - typedef wchar_selector::decoder decoder; - - return decoder::process(reinterpret_cast(data), size, result, traits); - } - }; - -#ifdef PUGIXML_WCHAR_MODE - PUGI__FN void convert_wchar_endian_swap(wchar_t* result, const wchar_t* data, size_t length) - { - for (size_t i = 0; i < length; ++i) - result[i] = static_cast(endian_swap(static_cast::type>(data[i]))); - } -#endif -PUGI__NS_END - -PUGI__NS_BEGIN - enum chartype_t - { - ct_parse_pcdata = 1, // \0, &, \r, < - ct_parse_attr = 2, // \0, &, \r, ', " - ct_parse_attr_ws = 4, // \0, &, \r, ', ", \n, tab - ct_space = 8, // \r, \n, space, tab - ct_parse_cdata = 16, // \0, ], >, \r - ct_parse_comment = 32, // \0, -, >, \r - ct_symbol = 64, // Any symbol > 127, a-z, A-Z, 0-9, _, :, -, . - ct_start_symbol = 128 // Any symbol > 127, a-z, A-Z, _, : - }; - - static const unsigned char chartype_table[256] = - { - 55, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 0, 0, 63, 0, 0, // 0-15 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31 - 8, 0, 6, 0, 0, 0, 7, 6, 0, 0, 0, 0, 0, 96, 64, 0, // 32-47 - 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 192, 0, 1, 0, 48, 0, // 48-63 - 0, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, // 64-79 - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 16, 0, 192, // 80-95 - 0, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, // 96-111 - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 0, 0, 0, 0, 0, // 112-127 - - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, // 128+ - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192 - }; - - enum chartypex_t - { - ctx_special_pcdata = 1, // Any symbol >= 0 and < 32 (except \t, \r, \n), &, <, > - ctx_special_attr = 2, // Any symbol >= 0 and < 32, &, <, ", ' - ctx_start_symbol = 4, // Any symbol > 127, a-z, A-Z, _ - ctx_digit = 8, // 0-9 - ctx_symbol = 16 // Any symbol > 127, a-z, A-Z, 0-9, _, -, . - }; - - static const unsigned char chartypex_table[256] = - { - 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 2, 3, 3, // 0-15 - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 16-31 - 0, 0, 2, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 16, 16, 0, // 32-47 - 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 3, 0, 1, 0, // 48-63 - - 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 64-79 - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 20, // 80-95 - 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 96-111 - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, // 112-127 - - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, // 128+ - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 - }; - -#ifdef PUGIXML_WCHAR_MODE - #define PUGI__IS_CHARTYPE_IMPL(c, ct, table) ((static_cast(c) < 128 ? table[static_cast(c)] : table[128]) & (ct)) -#else - #define PUGI__IS_CHARTYPE_IMPL(c, ct, table) (table[static_cast(c)] & (ct)) -#endif - - #define PUGI__IS_CHARTYPE(c, ct) PUGI__IS_CHARTYPE_IMPL(c, ct, chartype_table) - #define PUGI__IS_CHARTYPEX(c, ct) PUGI__IS_CHARTYPE_IMPL(c, ct, chartypex_table) - - PUGI__FN bool is_little_endian() - { - unsigned int ui = 1; - - return *reinterpret_cast(&ui) == 1; - } - - PUGI__FN xml_encoding get_wchar_encoding() - { - PUGI__STATIC_ASSERT(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4); - - if (sizeof(wchar_t) == 2) - return is_little_endian() ? encoding_utf16_le : encoding_utf16_be; - else - return is_little_endian() ? encoding_utf32_le : encoding_utf32_be; - } - - PUGI__FN bool parse_declaration_encoding(const uint8_t* data, size_t size, const uint8_t*& out_encoding, size_t& out_length) - { - #define PUGI__SCANCHAR(ch) { if (offset >= size || data[offset] != ch) return false; offset++; } - #define PUGI__SCANCHARTYPE(ct) { while (offset < size && PUGI__IS_CHARTYPE(data[offset], ct)) offset++; } - - // check if we have a non-empty XML declaration - if (size < 6 || !((data[0] == '<') & (data[1] == '?') & (data[2] == 'x') & (data[3] == 'm') & (data[4] == 'l') && PUGI__IS_CHARTYPE(data[5], ct_space))) - return false; - - // scan XML declaration until the encoding field - for (size_t i = 6; i + 1 < size; ++i) - { - // declaration can not contain ? in quoted values - if (data[i] == '?') - return false; - - if (data[i] == 'e' && data[i + 1] == 'n') - { - size_t offset = i; - - // encoding follows the version field which can't contain 'en' so this has to be the encoding if XML is well formed - PUGI__SCANCHAR('e'); PUGI__SCANCHAR('n'); PUGI__SCANCHAR('c'); PUGI__SCANCHAR('o'); - PUGI__SCANCHAR('d'); PUGI__SCANCHAR('i'); PUGI__SCANCHAR('n'); PUGI__SCANCHAR('g'); - - // S? = S? - PUGI__SCANCHARTYPE(ct_space); - PUGI__SCANCHAR('='); - PUGI__SCANCHARTYPE(ct_space); - - // the only two valid delimiters are ' and " - uint8_t delimiter = (offset < size && data[offset] == '"') ? '"' : '\''; - - PUGI__SCANCHAR(delimiter); - - size_t start = offset; - - out_encoding = data + offset; - - PUGI__SCANCHARTYPE(ct_symbol); - - out_length = offset - start; - - PUGI__SCANCHAR(delimiter); - - return true; - } - } - - return false; - - #undef PUGI__SCANCHAR - #undef PUGI__SCANCHARTYPE - } - - PUGI__FN xml_encoding guess_buffer_encoding(const uint8_t* data, size_t size) - { - // skip encoding autodetection if input buffer is too small - if (size < 4) return encoding_utf8; - - uint8_t d0 = data[0], d1 = data[1], d2 = data[2], d3 = data[3]; - - // look for BOM in first few bytes - if (d0 == 0 && d1 == 0 && d2 == 0xfe && d3 == 0xff) return encoding_utf32_be; - if (d0 == 0xff && d1 == 0xfe && d2 == 0 && d3 == 0) return encoding_utf32_le; - if (d0 == 0xfe && d1 == 0xff) return encoding_utf16_be; - if (d0 == 0xff && d1 == 0xfe) return encoding_utf16_le; - if (d0 == 0xef && d1 == 0xbb && d2 == 0xbf) return encoding_utf8; - - // look for <, (contents); - - return guess_buffer_encoding(data, size); - } - - PUGI__FN bool get_mutable_buffer(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable) - { - size_t length = size / sizeof(char_t); - - if (is_mutable) - { - out_buffer = static_cast(const_cast(contents)); - out_length = length; - } - else - { - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - if (contents) - memcpy(buffer, contents, length * sizeof(char_t)); - else - assert(length == 0); - - buffer[length] = 0; - - out_buffer = buffer; - out_length = length + 1; - } - - return true; - } - -#ifdef PUGIXML_WCHAR_MODE - PUGI__FN bool need_endian_swap_utf(xml_encoding le, xml_encoding re) - { - return (le == encoding_utf16_be && re == encoding_utf16_le) || (le == encoding_utf16_le && re == encoding_utf16_be) || - (le == encoding_utf32_be && re == encoding_utf32_le) || (le == encoding_utf32_le && re == encoding_utf32_be); - } - - PUGI__FN bool convert_buffer_endian_swap(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable) - { - const char_t* data = static_cast(contents); - size_t length = size / sizeof(char_t); - - if (is_mutable) - { - char_t* buffer = const_cast(data); - - convert_wchar_endian_swap(buffer, data, length); - - out_buffer = buffer; - out_length = length; - } - else - { - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - convert_wchar_endian_swap(buffer, data, length); - buffer[length] = 0; - - out_buffer = buffer; - out_length = length + 1; - } - - return true; - } - - template PUGI__FN bool convert_buffer_generic(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, D) - { - const typename D::type* data = static_cast(contents); - size_t data_length = size / sizeof(typename D::type); - - // first pass: get length in wchar_t units - size_t length = D::process(data, data_length, 0, wchar_counter()); - - // allocate buffer of suitable length - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - // second pass: convert utf16 input to wchar_t - wchar_writer::value_type obegin = reinterpret_cast(buffer); - wchar_writer::value_type oend = D::process(data, data_length, obegin, wchar_writer()); - - assert(oend == obegin + length); - *oend = 0; - - out_buffer = buffer; - out_length = length + 1; - - return true; - } - - PUGI__FN bool convert_buffer(char_t*& out_buffer, size_t& out_length, xml_encoding encoding, const void* contents, size_t size, bool is_mutable) - { - // get native encoding - xml_encoding wchar_encoding = get_wchar_encoding(); - - // fast path: no conversion required - if (encoding == wchar_encoding) - return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable); - - // only endian-swapping is required - if (need_endian_swap_utf(encoding, wchar_encoding)) - return convert_buffer_endian_swap(out_buffer, out_length, contents, size, is_mutable); - - // source encoding is utf8 - if (encoding == encoding_utf8) - return convert_buffer_generic(out_buffer, out_length, contents, size, utf8_decoder()); - - // source encoding is utf16 - if (encoding == encoding_utf16_be || encoding == encoding_utf16_le) - { - xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be; - - return (native_encoding == encoding) ? - convert_buffer_generic(out_buffer, out_length, contents, size, utf16_decoder()) : - convert_buffer_generic(out_buffer, out_length, contents, size, utf16_decoder()); - } - - // source encoding is utf32 - if (encoding == encoding_utf32_be || encoding == encoding_utf32_le) - { - xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be; - - return (native_encoding == encoding) ? - convert_buffer_generic(out_buffer, out_length, contents, size, utf32_decoder()) : - convert_buffer_generic(out_buffer, out_length, contents, size, utf32_decoder()); - } - - // source encoding is latin1 - if (encoding == encoding_latin1) - return convert_buffer_generic(out_buffer, out_length, contents, size, latin1_decoder()); - - assert(false && "Invalid encoding"); // unreachable - return false; - } -#else - template PUGI__FN bool convert_buffer_generic(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, D) - { - const typename D::type* data = static_cast(contents); - size_t data_length = size / sizeof(typename D::type); - - // first pass: get length in utf8 units - size_t length = D::process(data, data_length, 0, utf8_counter()); - - // allocate buffer of suitable length - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - // second pass: convert utf16 input to utf8 - uint8_t* obegin = reinterpret_cast(buffer); - uint8_t* oend = D::process(data, data_length, obegin, utf8_writer()); - - assert(oend == obegin + length); - *oend = 0; - - out_buffer = buffer; - out_length = length + 1; - - return true; - } - - PUGI__FN size_t get_latin1_7bit_prefix_length(const uint8_t* data, size_t size) - { - for (size_t i = 0; i < size; ++i) - if (data[i] > 127) - return i; - - return size; - } - - PUGI__FN bool convert_buffer_latin1(char_t*& out_buffer, size_t& out_length, const void* contents, size_t size, bool is_mutable) - { - const uint8_t* data = static_cast(contents); - size_t data_length = size; - - // get size of prefix that does not need utf8 conversion - size_t prefix_length = get_latin1_7bit_prefix_length(data, data_length); - assert(prefix_length <= data_length); - - const uint8_t* postfix = data + prefix_length; - size_t postfix_length = data_length - prefix_length; - - // if no conversion is needed, just return the original buffer - if (postfix_length == 0) return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable); - - // first pass: get length in utf8 units - size_t length = prefix_length + latin1_decoder::process(postfix, postfix_length, 0, utf8_counter()); - - // allocate buffer of suitable length - char_t* buffer = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!buffer) return false; - - // second pass: convert latin1 input to utf8 - memcpy(buffer, data, prefix_length); - - uint8_t* obegin = reinterpret_cast(buffer); - uint8_t* oend = latin1_decoder::process(postfix, postfix_length, obegin + prefix_length, utf8_writer()); - - assert(oend == obegin + length); - *oend = 0; - - out_buffer = buffer; - out_length = length + 1; - - return true; - } - - PUGI__FN bool convert_buffer(char_t*& out_buffer, size_t& out_length, xml_encoding encoding, const void* contents, size_t size, bool is_mutable) - { - // fast path: no conversion required - if (encoding == encoding_utf8) - return get_mutable_buffer(out_buffer, out_length, contents, size, is_mutable); - - // source encoding is utf16 - if (encoding == encoding_utf16_be || encoding == encoding_utf16_le) - { - xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be; - - return (native_encoding == encoding) ? - convert_buffer_generic(out_buffer, out_length, contents, size, utf16_decoder()) : - convert_buffer_generic(out_buffer, out_length, contents, size, utf16_decoder()); - } - - // source encoding is utf32 - if (encoding == encoding_utf32_be || encoding == encoding_utf32_le) - { - xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be; - - return (native_encoding == encoding) ? - convert_buffer_generic(out_buffer, out_length, contents, size, utf32_decoder()) : - convert_buffer_generic(out_buffer, out_length, contents, size, utf32_decoder()); - } - - // source encoding is latin1 - if (encoding == encoding_latin1) - return convert_buffer_latin1(out_buffer, out_length, contents, size, is_mutable); - - assert(false && "Invalid encoding"); // unreachable - return false; - } -#endif - - PUGI__FN size_t as_utf8_begin(const wchar_t* str, size_t length) - { - // get length in utf8 characters - return wchar_decoder::process(str, length, 0, utf8_counter()); - } - - PUGI__FN void as_utf8_end(char* buffer, size_t size, const wchar_t* str, size_t length) - { - // convert to utf8 - uint8_t* begin = reinterpret_cast(buffer); - uint8_t* end = wchar_decoder::process(str, length, begin, utf8_writer()); - - assert(begin + size == end); - (void)!end; - (void)!size; - } - -#ifndef PUGIXML_NO_STL - PUGI__FN std::string as_utf8_impl(const wchar_t* str, size_t length) - { - // first pass: get length in utf8 characters - size_t size = as_utf8_begin(str, length); - - // allocate resulting string - std::string result; - result.resize(size); - - // second pass: convert to utf8 - if (size > 0) as_utf8_end(&result[0], size, str, length); - - return result; - } - - PUGI__FN std::basic_string as_wide_impl(const char* str, size_t size) - { - const uint8_t* data = reinterpret_cast(str); - - // first pass: get length in wchar_t units - size_t length = utf8_decoder::process(data, size, 0, wchar_counter()); - - // allocate resulting string - std::basic_string result; - result.resize(length); - - // second pass: convert to wchar_t - if (length > 0) - { - wchar_writer::value_type begin = reinterpret_cast(&result[0]); - wchar_writer::value_type end = utf8_decoder::process(data, size, begin, wchar_writer()); - - assert(begin + length == end); - (void)!end; - } - - return result; - } -#endif - - template - inline bool strcpy_insitu_allow(size_t length, const Header& header, uintptr_t header_mask, char_t* target) - { - // never reuse shared memory - if (header & xml_memory_page_contents_shared_mask) return false; - - size_t target_length = strlength(target); - - // always reuse document buffer memory if possible - if ((header & header_mask) == 0) return target_length >= length; - - // reuse heap memory if waste is not too great - const size_t reuse_threshold = 32; - - return target_length >= length && (target_length < reuse_threshold || target_length - length < target_length / 2); - } - - template - PUGI__FN bool strcpy_insitu(String& dest, Header& header, uintptr_t header_mask, const char_t* source, size_t source_length) - { - if (source_length == 0) - { - // empty string and null pointer are equivalent, so just deallocate old memory - xml_allocator* alloc = PUGI__GETPAGE_IMPL(header)->allocator; - - if (header & header_mask) alloc->deallocate_string(dest); - - // mark the string as not allocated - dest = 0; - header &= ~header_mask; - - return true; - } - else if (dest && strcpy_insitu_allow(source_length, header, header_mask, dest)) - { - // we can reuse old buffer, so just copy the new data (including zero terminator) - memcpy(dest, source, source_length * sizeof(char_t)); - dest[source_length] = 0; - - return true; - } - else - { - xml_allocator* alloc = PUGI__GETPAGE_IMPL(header)->allocator; - - if (!alloc->reserve()) return false; - - // allocate new buffer - char_t* buf = alloc->allocate_string(source_length + 1); - if (!buf) return false; - - // copy the string (including zero terminator) - memcpy(buf, source, source_length * sizeof(char_t)); - buf[source_length] = 0; - - // deallocate old buffer (*after* the above to protect against overlapping memory and/or allocation failures) - if (header & header_mask) alloc->deallocate_string(dest); - - // the string is now allocated, so set the flag - dest = buf; - header |= header_mask; - - return true; - } - } - - struct gap - { - char_t* end; - size_t size; - - gap(): end(0), size(0) - { - } - - // Push new gap, move s count bytes further (skipping the gap). - // Collapse previous gap. - void push(char_t*& s, size_t count) - { - if (end) // there was a gap already; collapse it - { - // Move [old_gap_end, new_gap_start) to [old_gap_start, ...) - assert(s >= end); - memmove(end - size, end, reinterpret_cast(s) - reinterpret_cast(end)); - } - - s += count; // end of current gap - - // "merge" two gaps - end = s; - size += count; - } - - // Collapse all gaps, return past-the-end pointer - char_t* flush(char_t* s) - { - if (end) - { - // Move [old_gap_end, current_pos) to [old_gap_start, ...) - assert(s >= end); - memmove(end - size, end, reinterpret_cast(s) - reinterpret_cast(end)); - - return s - size; - } - else return s; - } - }; - - PUGI__FN char_t* strconv_escape(char_t* s, gap& g) - { - char_t* stre = s + 1; - - switch (*stre) - { - case '#': // &#... - { - unsigned int ucsc = 0; - - if (stre[1] == 'x') // &#x... (hex code) - { - stre += 2; - - char_t ch = *stre; - - if (ch == ';') return stre; - - for (;;) - { - if (static_cast(ch - '0') <= 9) - ucsc = 16 * ucsc + (ch - '0'); - else if (static_cast((ch | ' ') - 'a') <= 5) - ucsc = 16 * ucsc + ((ch | ' ') - 'a' + 10); - else if (ch == ';') - break; - else // cancel - return stre; - - ch = *++stre; - } - - ++stre; - } - else // &#... (dec code) - { - char_t ch = *++stre; - - if (ch == ';') return stre; - - for (;;) - { - if (static_cast(ch - '0') <= 9) - ucsc = 10 * ucsc + (ch - '0'); - else if (ch == ';') - break; - else // cancel - return stre; - - ch = *++stre; - } - - ++stre; - } - - #ifdef PUGIXML_WCHAR_MODE - s = reinterpret_cast(wchar_writer::any(reinterpret_cast(s), ucsc)); - #else - s = reinterpret_cast(utf8_writer::any(reinterpret_cast(s), ucsc)); - #endif - - g.push(s, stre - s); - return stre; - } - - case 'a': // &a - { - ++stre; - - if (*stre == 'm') // &am - { - if (*++stre == 'p' && *++stre == ';') // & - { - *s++ = '&'; - ++stre; - - g.push(s, stre - s); - return stre; - } - } - else if (*stre == 'p') // &ap - { - if (*++stre == 'o' && *++stre == 's' && *++stre == ';') // ' - { - *s++ = '\''; - ++stre; - - g.push(s, stre - s); - return stre; - } - } - break; - } - - case 'g': // &g - { - if (*++stre == 't' && *++stre == ';') // > - { - *s++ = '>'; - ++stre; - - g.push(s, stre - s); - return stre; - } - break; - } - - case 'l': // &l - { - if (*++stre == 't' && *++stre == ';') // < - { - *s++ = '<'; - ++stre; - - g.push(s, stre - s); - return stre; - } - break; - } - - case 'q': // &q - { - if (*++stre == 'u' && *++stre == 'o' && *++stre == 't' && *++stre == ';') // " - { - *s++ = '"'; - ++stre; - - g.push(s, stre - s); - return stre; - } - break; - } - - default: - break; - } - - return stre; - } - - // Parser utilities - #define PUGI__ENDSWITH(c, e) ((c) == (e) || ((c) == 0 && endch == (e))) - #define PUGI__SKIPWS() { while (PUGI__IS_CHARTYPE(*s, ct_space)) ++s; } - #define PUGI__OPTSET(OPT) ( optmsk & (OPT) ) - #define PUGI__PUSHNODE(TYPE) { cursor = append_new_node(cursor, *alloc, TYPE); if (!cursor) PUGI__THROW_ERROR(status_out_of_memory, s); } - #define PUGI__POPNODE() { cursor = cursor->parent; } - #define PUGI__SCANFOR(X) { while (*s != 0 && !(X)) ++s; } - #define PUGI__SCANWHILE(X) { while (X) ++s; } - #define PUGI__SCANWHILE_UNROLL(X) { for (;;) { char_t ss = s[0]; if (PUGI__UNLIKELY(!(X))) { break; } ss = s[1]; if (PUGI__UNLIKELY(!(X))) { s += 1; break; } ss = s[2]; if (PUGI__UNLIKELY(!(X))) { s += 2; break; } ss = s[3]; if (PUGI__UNLIKELY(!(X))) { s += 3; break; } s += 4; } } - #define PUGI__ENDSEG() { ch = *s; *s = 0; ++s; } - #define PUGI__THROW_ERROR(err, m) return error_offset = m, error_status = err, static_cast(0) - #define PUGI__CHECK_ERROR(err, m) { if (*s == 0) PUGI__THROW_ERROR(err, m); } - - PUGI__FN char_t* strconv_comment(char_t* s, char_t endch) - { - gap g; - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_comment)); - - if (*s == '\r') // Either a single 0x0d or 0x0d 0x0a pair - { - *s++ = '\n'; // replace first one with 0x0a - - if (*s == '\n') g.push(s, 1); - } - else if (s[0] == '-' && s[1] == '-' && PUGI__ENDSWITH(s[2], '>')) // comment ends here - { - *g.flush(s) = 0; - - return s + (s[2] == '>' ? 3 : 2); - } - else if (*s == 0) - { - return 0; - } - else ++s; - } - } - - PUGI__FN char_t* strconv_cdata(char_t* s, char_t endch) - { - gap g; - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_cdata)); - - if (*s == '\r') // Either a single 0x0d or 0x0d 0x0a pair - { - *s++ = '\n'; // replace first one with 0x0a - - if (*s == '\n') g.push(s, 1); - } - else if (s[0] == ']' && s[1] == ']' && PUGI__ENDSWITH(s[2], '>')) // CDATA ends here - { - *g.flush(s) = 0; - - return s + 1; - } - else if (*s == 0) - { - return 0; - } - else ++s; - } - } - - typedef char_t* (*strconv_pcdata_t)(char_t*); - - template struct strconv_pcdata_impl - { - static char_t* parse(char_t* s) - { - gap g; - - char_t* begin = s; - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_pcdata)); - - if (*s == '<') // PCDATA ends here - { - char_t* end = g.flush(s); - - if (opt_trim::value) - while (end > begin && PUGI__IS_CHARTYPE(end[-1], ct_space)) - --end; - - *end = 0; - - return s + 1; - } - else if (opt_eol::value && *s == '\r') // Either a single 0x0d or 0x0d 0x0a pair - { - *s++ = '\n'; // replace first one with 0x0a - - if (*s == '\n') g.push(s, 1); - } - else if (opt_escape::value && *s == '&') - { - s = strconv_escape(s, g); - } - else if (*s == 0) - { - char_t* end = g.flush(s); - - if (opt_trim::value) - while (end > begin && PUGI__IS_CHARTYPE(end[-1], ct_space)) - --end; - - *end = 0; - - return s; - } - else ++s; - } - } - }; - - PUGI__FN strconv_pcdata_t get_strconv_pcdata(unsigned int optmask) - { - PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_trim_pcdata == 0x0800); - - switch (((optmask >> 4) & 3) | ((optmask >> 9) & 4)) // get bitmask for flags (trim eol escapes); this simultaneously checks 3 options from assertion above - { - case 0: return strconv_pcdata_impl::parse; - case 1: return strconv_pcdata_impl::parse; - case 2: return strconv_pcdata_impl::parse; - case 3: return strconv_pcdata_impl::parse; - case 4: return strconv_pcdata_impl::parse; - case 5: return strconv_pcdata_impl::parse; - case 6: return strconv_pcdata_impl::parse; - case 7: return strconv_pcdata_impl::parse; - default: assert(false); return 0; // unreachable - } - } - - typedef char_t* (*strconv_attribute_t)(char_t*, char_t); - - template struct strconv_attribute_impl - { - static char_t* parse_wnorm(char_t* s, char_t end_quote) - { - gap g; - - // trim leading whitespaces - if (PUGI__IS_CHARTYPE(*s, ct_space)) - { - char_t* str = s; - - do ++str; - while (PUGI__IS_CHARTYPE(*str, ct_space)); - - g.push(s, str - s); - } - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_attr_ws | ct_space)); - - if (*s == end_quote) - { - char_t* str = g.flush(s); - - do *str-- = 0; - while (PUGI__IS_CHARTYPE(*str, ct_space)); - - return s + 1; - } - else if (PUGI__IS_CHARTYPE(*s, ct_space)) - { - *s++ = ' '; - - if (PUGI__IS_CHARTYPE(*s, ct_space)) - { - char_t* str = s + 1; - while (PUGI__IS_CHARTYPE(*str, ct_space)) ++str; - - g.push(s, str - s); - } - } - else if (opt_escape::value && *s == '&') - { - s = strconv_escape(s, g); - } - else if (!*s) - { - return 0; - } - else ++s; - } - } - - static char_t* parse_wconv(char_t* s, char_t end_quote) - { - gap g; - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_attr_ws)); - - if (*s == end_quote) - { - *g.flush(s) = 0; - - return s + 1; - } - else if (PUGI__IS_CHARTYPE(*s, ct_space)) - { - if (*s == '\r') - { - *s++ = ' '; - - if (*s == '\n') g.push(s, 1); - } - else *s++ = ' '; - } - else if (opt_escape::value && *s == '&') - { - s = strconv_escape(s, g); - } - else if (!*s) - { - return 0; - } - else ++s; - } - } - - static char_t* parse_eol(char_t* s, char_t end_quote) - { - gap g; - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_attr)); - - if (*s == end_quote) - { - *g.flush(s) = 0; - - return s + 1; - } - else if (*s == '\r') - { - *s++ = '\n'; - - if (*s == '\n') g.push(s, 1); - } - else if (opt_escape::value && *s == '&') - { - s = strconv_escape(s, g); - } - else if (!*s) - { - return 0; - } - else ++s; - } - } - - static char_t* parse_simple(char_t* s, char_t end_quote) - { - gap g; - - while (true) - { - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPE(ss, ct_parse_attr)); - - if (*s == end_quote) - { - *g.flush(s) = 0; - - return s + 1; - } - else if (opt_escape::value && *s == '&') - { - s = strconv_escape(s, g); - } - else if (!*s) - { - return 0; - } - else ++s; - } - } - }; - - PUGI__FN strconv_attribute_t get_strconv_attribute(unsigned int optmask) - { - PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_wconv_attribute == 0x40 && parse_wnorm_attribute == 0x80); - - switch ((optmask >> 4) & 15) // get bitmask for flags (wnorm wconv eol escapes); this simultaneously checks 4 options from assertion above - { - case 0: return strconv_attribute_impl::parse_simple; - case 1: return strconv_attribute_impl::parse_simple; - case 2: return strconv_attribute_impl::parse_eol; - case 3: return strconv_attribute_impl::parse_eol; - case 4: return strconv_attribute_impl::parse_wconv; - case 5: return strconv_attribute_impl::parse_wconv; - case 6: return strconv_attribute_impl::parse_wconv; - case 7: return strconv_attribute_impl::parse_wconv; - case 8: return strconv_attribute_impl::parse_wnorm; - case 9: return strconv_attribute_impl::parse_wnorm; - case 10: return strconv_attribute_impl::parse_wnorm; - case 11: return strconv_attribute_impl::parse_wnorm; - case 12: return strconv_attribute_impl::parse_wnorm; - case 13: return strconv_attribute_impl::parse_wnorm; - case 14: return strconv_attribute_impl::parse_wnorm; - case 15: return strconv_attribute_impl::parse_wnorm; - default: assert(false); return 0; // unreachable - } - } - - inline xml_parse_result make_parse_result(xml_parse_status status, ptrdiff_t offset = 0) - { - xml_parse_result result; - result.status = status; - result.offset = offset; - - return result; - } - - struct xml_parser - { - xml_allocator* alloc; - char_t* error_offset; - xml_parse_status error_status; - - xml_parser(xml_allocator* alloc_): alloc(alloc_), error_offset(0), error_status(status_ok) - { - } - - // DOCTYPE consists of nested sections of the following possible types: - // , , "...", '...' - // - // - // First group can not contain nested groups - // Second group can contain nested groups of the same type - // Third group can contain all other groups - char_t* parse_doctype_primitive(char_t* s) - { - if (*s == '"' || *s == '\'') - { - // quoted string - char_t ch = *s++; - PUGI__SCANFOR(*s == ch); - if (!*s) PUGI__THROW_ERROR(status_bad_doctype, s); - - s++; - } - else if (s[0] == '<' && s[1] == '?') - { - // - s += 2; - PUGI__SCANFOR(s[0] == '?' && s[1] == '>'); // no need for ENDSWITH because ?> can't terminate proper doctype - if (!*s) PUGI__THROW_ERROR(status_bad_doctype, s); - - s += 2; - } - else if (s[0] == '<' && s[1] == '!' && s[2] == '-' && s[3] == '-') - { - s += 4; - PUGI__SCANFOR(s[0] == '-' && s[1] == '-' && s[2] == '>'); // no need for ENDSWITH because --> can't terminate proper doctype - if (!*s) PUGI__THROW_ERROR(status_bad_doctype, s); - - s += 3; - } - else PUGI__THROW_ERROR(status_bad_doctype, s); - - return s; - } - - char_t* parse_doctype_ignore(char_t* s) - { - size_t depth = 0; - - assert(s[0] == '<' && s[1] == '!' && s[2] == '['); - s += 3; - - while (*s) - { - if (s[0] == '<' && s[1] == '!' && s[2] == '[') - { - // nested ignore section - s += 3; - depth++; - } - else if (s[0] == ']' && s[1] == ']' && s[2] == '>') - { - // ignore section end - s += 3; - - if (depth == 0) - return s; - - depth--; - } - else s++; - } - - PUGI__THROW_ERROR(status_bad_doctype, s); - } - - char_t* parse_doctype_group(char_t* s, char_t endch) - { - size_t depth = 0; - - assert((s[0] == '<' || s[0] == 0) && s[1] == '!'); - s += 2; - - while (*s) - { - if (s[0] == '<' && s[1] == '!' && s[2] != '-') - { - if (s[2] == '[') - { - // ignore - s = parse_doctype_ignore(s); - if (!s) return s; - } - else - { - // some control group - s += 2; - depth++; - } - } - else if (s[0] == '<' || s[0] == '"' || s[0] == '\'') - { - // unknown tag (forbidden), or some primitive group - s = parse_doctype_primitive(s); - if (!s) return s; - } - else if (*s == '>') - { - if (depth == 0) - return s; - - depth--; - s++; - } - else s++; - } - - if (depth != 0 || endch != '>') PUGI__THROW_ERROR(status_bad_doctype, s); - - return s; - } - - char_t* parse_exclamation(char_t* s, xml_node_struct* cursor, unsigned int optmsk, char_t endch) - { - // parse node contents, starting with exclamation mark - ++s; - - if (*s == '-') // 'value = s; // Save the offset. - } - - if (PUGI__OPTSET(parse_eol) && PUGI__OPTSET(parse_comments)) - { - s = strconv_comment(s, endch); - - if (!s) PUGI__THROW_ERROR(status_bad_comment, cursor->value); - } - else - { - // Scan for terminating '-->'. - PUGI__SCANFOR(s[0] == '-' && s[1] == '-' && PUGI__ENDSWITH(s[2], '>')); - PUGI__CHECK_ERROR(status_bad_comment, s); - - if (PUGI__OPTSET(parse_comments)) - *s = 0; // Zero-terminate this segment at the first terminating '-'. - - s += (s[2] == '>' ? 3 : 2); // Step over the '\0->'. - } - } - else PUGI__THROW_ERROR(status_bad_comment, s); - } - else if (*s == '[') - { - // 'value = s; // Save the offset. - - if (PUGI__OPTSET(parse_eol)) - { - s = strconv_cdata(s, endch); - - if (!s) PUGI__THROW_ERROR(status_bad_cdata, cursor->value); - } - else - { - // Scan for terminating ']]>'. - PUGI__SCANFOR(s[0] == ']' && s[1] == ']' && PUGI__ENDSWITH(s[2], '>')); - PUGI__CHECK_ERROR(status_bad_cdata, s); - - *s++ = 0; // Zero-terminate this segment. - } - } - else // Flagged for discard, but we still have to scan for the terminator. - { - // Scan for terminating ']]>'. - PUGI__SCANFOR(s[0] == ']' && s[1] == ']' && PUGI__ENDSWITH(s[2], '>')); - PUGI__CHECK_ERROR(status_bad_cdata, s); - - ++s; - } - - s += (s[1] == '>' ? 2 : 1); // Step over the last ']>'. - } - else PUGI__THROW_ERROR(status_bad_cdata, s); - } - else if (s[0] == 'D' && s[1] == 'O' && s[2] == 'C' && s[3] == 'T' && s[4] == 'Y' && s[5] == 'P' && PUGI__ENDSWITH(s[6], 'E')) - { - s -= 2; - - if (cursor->parent) PUGI__THROW_ERROR(status_bad_doctype, s); - - char_t* mark = s + 9; - - s = parse_doctype_group(s, endch); - if (!s) return s; - - assert((*s == 0 && endch == '>') || *s == '>'); - if (*s) *s++ = 0; - - if (PUGI__OPTSET(parse_doctype)) - { - while (PUGI__IS_CHARTYPE(*mark, ct_space)) ++mark; - - PUGI__PUSHNODE(node_doctype); - - cursor->value = mark; - } - } - else if (*s == 0 && endch == '-') PUGI__THROW_ERROR(status_bad_comment, s); - else if (*s == 0 && endch == '[') PUGI__THROW_ERROR(status_bad_cdata, s); - else PUGI__THROW_ERROR(status_unrecognized_tag, s); - - return s; - } - - char_t* parse_question(char_t* s, xml_node_struct*& ref_cursor, unsigned int optmsk, char_t endch) - { - // load into registers - xml_node_struct* cursor = ref_cursor; - char_t ch = 0; - - // parse node contents, starting with question mark - ++s; - - // read PI target - char_t* target = s; - - if (!PUGI__IS_CHARTYPE(*s, ct_start_symbol)) PUGI__THROW_ERROR(status_bad_pi, s); - - PUGI__SCANWHILE(PUGI__IS_CHARTYPE(*s, ct_symbol)); - PUGI__CHECK_ERROR(status_bad_pi, s); - - // determine node type; stricmp / strcasecmp is not portable - bool declaration = (target[0] | ' ') == 'x' && (target[1] | ' ') == 'm' && (target[2] | ' ') == 'l' && target + 3 == s; - - if (declaration ? PUGI__OPTSET(parse_declaration) : PUGI__OPTSET(parse_pi)) - { - if (declaration) - { - // disallow non top-level declarations - if (cursor->parent) PUGI__THROW_ERROR(status_bad_pi, s); - - PUGI__PUSHNODE(node_declaration); - } - else - { - PUGI__PUSHNODE(node_pi); - } - - cursor->name = target; - - PUGI__ENDSEG(); - - // parse value/attributes - if (ch == '?') - { - // empty node - if (!PUGI__ENDSWITH(*s, '>')) PUGI__THROW_ERROR(status_bad_pi, s); - s += (*s == '>'); - - PUGI__POPNODE(); - } - else if (PUGI__IS_CHARTYPE(ch, ct_space)) - { - PUGI__SKIPWS(); - - // scan for tag end - char_t* value = s; - - PUGI__SCANFOR(s[0] == '?' && PUGI__ENDSWITH(s[1], '>')); - PUGI__CHECK_ERROR(status_bad_pi, s); - - if (declaration) - { - // replace ending ? with / so that 'element' terminates properly - *s = '/'; - - // we exit from this function with cursor at node_declaration, which is a signal to parse() to go to LOC_ATTRIBUTES - s = value; - } - else - { - // store value and step over > - cursor->value = value; - - PUGI__POPNODE(); - - PUGI__ENDSEG(); - - s += (*s == '>'); - } - } - else PUGI__THROW_ERROR(status_bad_pi, s); - } - else - { - // scan for tag end - PUGI__SCANFOR(s[0] == '?' && PUGI__ENDSWITH(s[1], '>')); - PUGI__CHECK_ERROR(status_bad_pi, s); - - s += (s[1] == '>' ? 2 : 1); - } - - // store from registers - ref_cursor = cursor; - - return s; - } - - char_t* parse_tree(char_t* s, xml_node_struct* root, unsigned int optmsk, char_t endch) - { - strconv_attribute_t strconv_attribute = get_strconv_attribute(optmsk); - strconv_pcdata_t strconv_pcdata = get_strconv_pcdata(optmsk); - - char_t ch = 0; - xml_node_struct* cursor = root; - char_t* mark = s; - - while (*s != 0) - { - if (*s == '<') - { - ++s; - - LOC_TAG: - if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) // '<#...' - { - PUGI__PUSHNODE(node_element); // Append a new node to the tree. - - cursor->name = s; - - PUGI__SCANWHILE_UNROLL(PUGI__IS_CHARTYPE(ss, ct_symbol)); // Scan for a terminator. - PUGI__ENDSEG(); // Save char in 'ch', terminate & step over. - - if (ch == '>') - { - // end of tag - } - else if (PUGI__IS_CHARTYPE(ch, ct_space)) - { - LOC_ATTRIBUTES: - while (true) - { - PUGI__SKIPWS(); // Eat any whitespace. - - if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) // <... #... - { - xml_attribute_struct* a = append_new_attribute(cursor, *alloc); // Make space for this attribute. - if (!a) PUGI__THROW_ERROR(status_out_of_memory, s); - - a->name = s; // Save the offset. - - PUGI__SCANWHILE_UNROLL(PUGI__IS_CHARTYPE(ss, ct_symbol)); // Scan for a terminator. - PUGI__ENDSEG(); // Save char in 'ch', terminate & step over. - - if (PUGI__IS_CHARTYPE(ch, ct_space)) - { - PUGI__SKIPWS(); // Eat any whitespace. - - ch = *s; - ++s; - } - - if (ch == '=') // '<... #=...' - { - PUGI__SKIPWS(); // Eat any whitespace. - - if (*s == '"' || *s == '\'') // '<... #="...' - { - ch = *s; // Save quote char to avoid breaking on "''" -or- '""'. - ++s; // Step over the quote. - a->value = s; // Save the offset. - - s = strconv_attribute(s, ch); - - if (!s) PUGI__THROW_ERROR(status_bad_attribute, a->value); - - // After this line the loop continues from the start; - // Whitespaces, / and > are ok, symbols and EOF are wrong, - // everything else will be detected - if (PUGI__IS_CHARTYPE(*s, ct_start_symbol)) PUGI__THROW_ERROR(status_bad_attribute, s); - } - else PUGI__THROW_ERROR(status_bad_attribute, s); - } - else PUGI__THROW_ERROR(status_bad_attribute, s); - } - else if (*s == '/') - { - ++s; - - if (*s == '>') - { - PUGI__POPNODE(); - s++; - break; - } - else if (*s == 0 && endch == '>') - { - PUGI__POPNODE(); - break; - } - else PUGI__THROW_ERROR(status_bad_start_element, s); - } - else if (*s == '>') - { - ++s; - - break; - } - else if (*s == 0 && endch == '>') - { - break; - } - else PUGI__THROW_ERROR(status_bad_start_element, s); - } - - // !!! - } - else if (ch == '/') // '<#.../' - { - if (!PUGI__ENDSWITH(*s, '>')) PUGI__THROW_ERROR(status_bad_start_element, s); - - PUGI__POPNODE(); // Pop. - - s += (*s == '>'); - } - else if (ch == 0) - { - // we stepped over null terminator, backtrack & handle closing tag - --s; - - if (endch != '>') PUGI__THROW_ERROR(status_bad_start_element, s); - } - else PUGI__THROW_ERROR(status_bad_start_element, s); - } - else if (*s == '/') - { - ++s; - - mark = s; - - char_t* name = cursor->name; - if (!name) PUGI__THROW_ERROR(status_end_element_mismatch, mark); - - while (PUGI__IS_CHARTYPE(*s, ct_symbol)) - { - if (*s++ != *name++) PUGI__THROW_ERROR(status_end_element_mismatch, mark); - } - - if (*name) - { - if (*s == 0 && name[0] == endch && name[1] == 0) PUGI__THROW_ERROR(status_bad_end_element, s); - else PUGI__THROW_ERROR(status_end_element_mismatch, mark); - } - - PUGI__POPNODE(); // Pop. - - PUGI__SKIPWS(); - - if (*s == 0) - { - if (endch != '>') PUGI__THROW_ERROR(status_bad_end_element, s); - } - else - { - if (*s != '>') PUGI__THROW_ERROR(status_bad_end_element, s); - ++s; - } - } - else if (*s == '?') // 'first_child) continue; - } - } - - if (!PUGI__OPTSET(parse_trim_pcdata)) - s = mark; - - if (cursor->parent || PUGI__OPTSET(parse_fragment)) - { - if (PUGI__OPTSET(parse_embed_pcdata) && cursor->parent && !cursor->first_child && !cursor->value) - { - cursor->value = s; // Save the offset. - } - else - { - PUGI__PUSHNODE(node_pcdata); // Append a new node on the tree. - - cursor->value = s; // Save the offset. - - PUGI__POPNODE(); // Pop since this is a standalone. - } - - s = strconv_pcdata(s); - - if (!*s) break; - } - else - { - PUGI__SCANFOR(*s == '<'); // '...<' - if (!*s) break; - - ++s; - } - - // We're after '<' - goto LOC_TAG; - } - } - - // check that last tag is closed - if (cursor != root) PUGI__THROW_ERROR(status_end_element_mismatch, s); - - return s; - } - - #ifdef PUGIXML_WCHAR_MODE - static char_t* parse_skip_bom(char_t* s) - { - unsigned int bom = 0xfeff; - return (s[0] == static_cast(bom)) ? s + 1 : s; - } - #else - static char_t* parse_skip_bom(char_t* s) - { - return (s[0] == '\xef' && s[1] == '\xbb' && s[2] == '\xbf') ? s + 3 : s; - } - #endif - - static bool has_element_node_siblings(xml_node_struct* node) - { - while (node) - { - if (PUGI__NODETYPE(node) == node_element) return true; - - node = node->next_sibling; - } - - return false; - } - - static xml_parse_result parse(char_t* buffer, size_t length, xml_document_struct* xmldoc, xml_node_struct* root, unsigned int optmsk) - { - // early-out for empty documents - if (length == 0) - return make_parse_result(PUGI__OPTSET(parse_fragment) ? status_ok : status_no_document_element); - - // get last child of the root before parsing - xml_node_struct* last_root_child = root->first_child ? root->first_child->prev_sibling_c + 0 : 0; - - // create parser on stack - xml_parser parser(static_cast(xmldoc)); - - // save last character and make buffer zero-terminated (speeds up parsing) - char_t endch = buffer[length - 1]; - buffer[length - 1] = 0; - - // skip BOM to make sure it does not end up as part of parse output - char_t* buffer_data = parse_skip_bom(buffer); - - // perform actual parsing - parser.parse_tree(buffer_data, root, optmsk, endch); - - xml_parse_result result = make_parse_result(parser.error_status, parser.error_offset ? parser.error_offset - buffer : 0); - assert(result.offset >= 0 && static_cast(result.offset) <= length); - - if (result) - { - // since we removed last character, we have to handle the only possible false positive (stray <) - if (endch == '<') - return make_parse_result(status_unrecognized_tag, length - 1); - - // check if there are any element nodes parsed - xml_node_struct* first_root_child_parsed = last_root_child ? last_root_child->next_sibling + 0 : root->first_child+ 0; - - if (!PUGI__OPTSET(parse_fragment) && !has_element_node_siblings(first_root_child_parsed)) - return make_parse_result(status_no_document_element, length - 1); - } - else - { - // roll back offset if it occurs on a null terminator in the source buffer - if (result.offset > 0 && static_cast(result.offset) == length - 1 && endch == 0) - result.offset--; - } - - return result; - } - }; - - // Output facilities - PUGI__FN xml_encoding get_write_native_encoding() - { - #ifdef PUGIXML_WCHAR_MODE - return get_wchar_encoding(); - #else - return encoding_utf8; - #endif - } - - PUGI__FN xml_encoding get_write_encoding(xml_encoding encoding) - { - // replace wchar encoding with utf implementation - if (encoding == encoding_wchar) return get_wchar_encoding(); - - // replace utf16 encoding with utf16 with specific endianness - if (encoding == encoding_utf16) return is_little_endian() ? encoding_utf16_le : encoding_utf16_be; - - // replace utf32 encoding with utf32 with specific endianness - if (encoding == encoding_utf32) return is_little_endian() ? encoding_utf32_le : encoding_utf32_be; - - // only do autodetection if no explicit encoding is requested - if (encoding != encoding_auto) return encoding; - - // assume utf8 encoding - return encoding_utf8; - } - - template PUGI__FN size_t convert_buffer_output_generic(typename T::value_type dest, const char_t* data, size_t length, D, T) - { - PUGI__STATIC_ASSERT(sizeof(char_t) == sizeof(typename D::type)); - - typename T::value_type end = D::process(reinterpret_cast(data), length, dest, T()); - - return static_cast(end - dest) * sizeof(*dest); - } - - template PUGI__FN size_t convert_buffer_output_generic(typename T::value_type dest, const char_t* data, size_t length, D, T, bool opt_swap) - { - PUGI__STATIC_ASSERT(sizeof(char_t) == sizeof(typename D::type)); - - typename T::value_type end = D::process(reinterpret_cast(data), length, dest, T()); - - if (opt_swap) - { - for (typename T::value_type i = dest; i != end; ++i) - *i = endian_swap(*i); - } - - return static_cast(end - dest) * sizeof(*dest); - } - -#ifdef PUGIXML_WCHAR_MODE - PUGI__FN size_t get_valid_length(const char_t* data, size_t length) - { - if (length < 1) return 0; - - // discard last character if it's the lead of a surrogate pair - return (sizeof(wchar_t) == 2 && static_cast(static_cast(data[length - 1]) - 0xD800) < 0x400) ? length - 1 : length; - } - - PUGI__FN size_t convert_buffer_output(char_t* r_char, uint8_t* r_u8, uint16_t* r_u16, uint32_t* r_u32, const char_t* data, size_t length, xml_encoding encoding) - { - // only endian-swapping is required - if (need_endian_swap_utf(encoding, get_wchar_encoding())) - { - convert_wchar_endian_swap(r_char, data, length); - - return length * sizeof(char_t); - } - - // convert to utf8 - if (encoding == encoding_utf8) - return convert_buffer_output_generic(r_u8, data, length, wchar_decoder(), utf8_writer()); - - // convert to utf16 - if (encoding == encoding_utf16_be || encoding == encoding_utf16_le) - { - xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be; - - return convert_buffer_output_generic(r_u16, data, length, wchar_decoder(), utf16_writer(), native_encoding != encoding); - } - - // convert to utf32 - if (encoding == encoding_utf32_be || encoding == encoding_utf32_le) - { - xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be; - - return convert_buffer_output_generic(r_u32, data, length, wchar_decoder(), utf32_writer(), native_encoding != encoding); - } - - // convert to latin1 - if (encoding == encoding_latin1) - return convert_buffer_output_generic(r_u8, data, length, wchar_decoder(), latin1_writer()); - - assert(false && "Invalid encoding"); // unreachable - return 0; - } -#else - PUGI__FN size_t get_valid_length(const char_t* data, size_t length) - { - if (length < 5) return 0; - - for (size_t i = 1; i <= 4; ++i) - { - uint8_t ch = static_cast(data[length - i]); - - // either a standalone character or a leading one - if ((ch & 0xc0) != 0x80) return length - i; - } - - // there are four non-leading characters at the end, sequence tail is broken so might as well process the whole chunk - return length; - } - - PUGI__FN size_t convert_buffer_output(char_t* /* r_char */, uint8_t* r_u8, uint16_t* r_u16, uint32_t* r_u32, const char_t* data, size_t length, xml_encoding encoding) - { - if (encoding == encoding_utf16_be || encoding == encoding_utf16_le) - { - xml_encoding native_encoding = is_little_endian() ? encoding_utf16_le : encoding_utf16_be; - - return convert_buffer_output_generic(r_u16, data, length, utf8_decoder(), utf16_writer(), native_encoding != encoding); - } - - if (encoding == encoding_utf32_be || encoding == encoding_utf32_le) - { - xml_encoding native_encoding = is_little_endian() ? encoding_utf32_le : encoding_utf32_be; - - return convert_buffer_output_generic(r_u32, data, length, utf8_decoder(), utf32_writer(), native_encoding != encoding); - } - - if (encoding == encoding_latin1) - return convert_buffer_output_generic(r_u8, data, length, utf8_decoder(), latin1_writer()); - - assert(false && "Invalid encoding"); // unreachable - return 0; - } -#endif - - class xml_buffered_writer - { - xml_buffered_writer(const xml_buffered_writer&); - xml_buffered_writer& operator=(const xml_buffered_writer&); - - public: - xml_buffered_writer(xml_writer& writer_, xml_encoding user_encoding): writer(writer_), bufsize(0), encoding(get_write_encoding(user_encoding)) - { - PUGI__STATIC_ASSERT(bufcapacity >= 8); - } - - size_t flush() - { - flush(buffer, bufsize); - bufsize = 0; - return 0; - } - - void flush(const char_t* data, size_t size) - { - if (size == 0) return; - - // fast path, just write data - if (encoding == get_write_native_encoding()) - writer.write(data, size * sizeof(char_t)); - else - { - // convert chunk - size_t result = convert_buffer_output(scratch.data_char, scratch.data_u8, scratch.data_u16, scratch.data_u32, data, size, encoding); - assert(result <= sizeof(scratch)); - - // write data - writer.write(scratch.data_u8, result); - } - } - - void write_direct(const char_t* data, size_t length) - { - // flush the remaining buffer contents - flush(); - - // handle large chunks - if (length > bufcapacity) - { - if (encoding == get_write_native_encoding()) - { - // fast path, can just write data chunk - writer.write(data, length * sizeof(char_t)); - return; - } - - // need to convert in suitable chunks - while (length > bufcapacity) - { - // get chunk size by selecting such number of characters that are guaranteed to fit into scratch buffer - // and form a complete codepoint sequence (i.e. discard start of last codepoint if necessary) - size_t chunk_size = get_valid_length(data, bufcapacity); - assert(chunk_size); - - // convert chunk and write - flush(data, chunk_size); - - // iterate - data += chunk_size; - length -= chunk_size; - } - - // small tail is copied below - bufsize = 0; - } - - memcpy(buffer + bufsize, data, length * sizeof(char_t)); - bufsize += length; - } - - void write_buffer(const char_t* data, size_t length) - { - size_t offset = bufsize; - - if (offset + length <= bufcapacity) - { - memcpy(buffer + offset, data, length * sizeof(char_t)); - bufsize = offset + length; - } - else - { - write_direct(data, length); - } - } - - void write_string(const char_t* data) - { - // write the part of the string that fits in the buffer - size_t offset = bufsize; - - while (*data && offset < bufcapacity) - buffer[offset++] = *data++; - - // write the rest - if (offset < bufcapacity) - { - bufsize = offset; - } - else - { - // backtrack a bit if we have split the codepoint - size_t length = offset - bufsize; - size_t extra = length - get_valid_length(data - length, length); - - bufsize = offset - extra; - - write_direct(data - extra, strlength(data) + extra); - } - } - - void write(char_t d0) - { - size_t offset = bufsize; - if (offset > bufcapacity - 1) offset = flush(); - - buffer[offset + 0] = d0; - bufsize = offset + 1; - } - - void write(char_t d0, char_t d1) - { - size_t offset = bufsize; - if (offset > bufcapacity - 2) offset = flush(); - - buffer[offset + 0] = d0; - buffer[offset + 1] = d1; - bufsize = offset + 2; - } - - void write(char_t d0, char_t d1, char_t d2) - { - size_t offset = bufsize; - if (offset > bufcapacity - 3) offset = flush(); - - buffer[offset + 0] = d0; - buffer[offset + 1] = d1; - buffer[offset + 2] = d2; - bufsize = offset + 3; - } - - void write(char_t d0, char_t d1, char_t d2, char_t d3) - { - size_t offset = bufsize; - if (offset > bufcapacity - 4) offset = flush(); - - buffer[offset + 0] = d0; - buffer[offset + 1] = d1; - buffer[offset + 2] = d2; - buffer[offset + 3] = d3; - bufsize = offset + 4; - } - - void write(char_t d0, char_t d1, char_t d2, char_t d3, char_t d4) - { - size_t offset = bufsize; - if (offset > bufcapacity - 5) offset = flush(); - - buffer[offset + 0] = d0; - buffer[offset + 1] = d1; - buffer[offset + 2] = d2; - buffer[offset + 3] = d3; - buffer[offset + 4] = d4; - bufsize = offset + 5; - } - - void write(char_t d0, char_t d1, char_t d2, char_t d3, char_t d4, char_t d5) - { - size_t offset = bufsize; - if (offset > bufcapacity - 6) offset = flush(); - - buffer[offset + 0] = d0; - buffer[offset + 1] = d1; - buffer[offset + 2] = d2; - buffer[offset + 3] = d3; - buffer[offset + 4] = d4; - buffer[offset + 5] = d5; - bufsize = offset + 6; - } - - // utf8 maximum expansion: x4 (-> utf32) - // utf16 maximum expansion: x2 (-> utf32) - // utf32 maximum expansion: x1 - enum - { - bufcapacitybytes = - #ifdef PUGIXML_MEMORY_OUTPUT_STACK - PUGIXML_MEMORY_OUTPUT_STACK - #else - 10240 - #endif - , - bufcapacity = bufcapacitybytes / (sizeof(char_t) + 4) - }; - - char_t buffer[bufcapacity]; - - union - { - uint8_t data_u8[4 * bufcapacity]; - uint16_t data_u16[2 * bufcapacity]; - uint32_t data_u32[bufcapacity]; - char_t data_char[bufcapacity]; - } scratch; - - xml_writer& writer; - size_t bufsize; - xml_encoding encoding; - }; - - PUGI__FN void text_output_escaped(xml_buffered_writer& writer, const char_t* s, chartypex_t type, unsigned int flags) - { - while (*s) - { - const char_t* prev = s; - - // While *s is a usual symbol - PUGI__SCANWHILE_UNROLL(!PUGI__IS_CHARTYPEX(ss, type)); - - writer.write_buffer(prev, static_cast(s - prev)); - - switch (*s) - { - case 0: break; - case '&': - writer.write('&', 'a', 'm', 'p', ';'); - ++s; - break; - case '<': - writer.write('&', 'l', 't', ';'); - ++s; - break; - case '>': - writer.write('&', 'g', 't', ';'); - ++s; - break; - case '"': - if (flags & format_attribute_single_quote) - writer.write('"'); - else - writer.write('&', 'q', 'u', 'o', 't', ';'); - ++s; - break; - case '\'': - if (flags & format_attribute_single_quote) - writer.write('&', 'a', 'p', 'o', 's', ';'); - else - writer.write('\''); - ++s; - break; - default: // s is not a usual symbol - { - unsigned int ch = static_cast(*s++); - assert(ch < 32); - - if (!(flags & format_skip_control_chars)) - writer.write('&', '#', static_cast((ch / 10) + '0'), static_cast((ch % 10) + '0'), ';'); - } - } - } - } - - PUGI__FN void text_output(xml_buffered_writer& writer, const char_t* s, chartypex_t type, unsigned int flags) - { - if (flags & format_no_escapes) - writer.write_string(s); - else - text_output_escaped(writer, s, type, flags); - } - - PUGI__FN void text_output_cdata(xml_buffered_writer& writer, const char_t* s) - { - do - { - writer.write('<', '!', '[', 'C', 'D'); - writer.write('A', 'T', 'A', '['); - - const char_t* prev = s; - - // look for ]]> sequence - we can't output it as is since it terminates CDATA - while (*s && !(s[0] == ']' && s[1] == ']' && s[2] == '>')) ++s; - - // skip ]] if we stopped at ]]>, > will go to the next CDATA section - if (*s) s += 2; - - writer.write_buffer(prev, static_cast(s - prev)); - - writer.write(']', ']', '>'); - } - while (*s); - } - - PUGI__FN void text_output_indent(xml_buffered_writer& writer, const char_t* indent, size_t indent_length, unsigned int depth) - { - switch (indent_length) - { - case 1: - { - for (unsigned int i = 0; i < depth; ++i) - writer.write(indent[0]); - break; - } - - case 2: - { - for (unsigned int i = 0; i < depth; ++i) - writer.write(indent[0], indent[1]); - break; - } - - case 3: - { - for (unsigned int i = 0; i < depth; ++i) - writer.write(indent[0], indent[1], indent[2]); - break; - } - - case 4: - { - for (unsigned int i = 0; i < depth; ++i) - writer.write(indent[0], indent[1], indent[2], indent[3]); - break; - } - - default: - { - for (unsigned int i = 0; i < depth; ++i) - writer.write_buffer(indent, indent_length); - } - } - } - - PUGI__FN void node_output_comment(xml_buffered_writer& writer, const char_t* s) - { - writer.write('<', '!', '-', '-'); - - while (*s) - { - const char_t* prev = s; - - // look for -\0 or -- sequence - we can't output it since -- is illegal in comment body - while (*s && !(s[0] == '-' && (s[1] == '-' || s[1] == 0))) ++s; - - writer.write_buffer(prev, static_cast(s - prev)); - - if (*s) - { - assert(*s == '-'); - - writer.write('-', ' '); - ++s; - } - } - - writer.write('-', '-', '>'); - } - - PUGI__FN void node_output_pi_value(xml_buffered_writer& writer, const char_t* s) - { - while (*s) - { - const char_t* prev = s; - - // look for ?> sequence - we can't output it since ?> terminates PI - while (*s && !(s[0] == '?' && s[1] == '>')) ++s; - - writer.write_buffer(prev, static_cast(s - prev)); - - if (*s) - { - assert(s[0] == '?' && s[1] == '>'); - - writer.write('?', ' ', '>'); - s += 2; - } - } - } - - PUGI__FN void node_output_attributes(xml_buffered_writer& writer, xml_node_struct* node, const char_t* indent, size_t indent_length, unsigned int flags, unsigned int depth) - { - const char_t* default_name = PUGIXML_TEXT(":anonymous"); - const char_t enquotation_char = (flags & format_attribute_single_quote) ? '\'' : '"'; - - for (xml_attribute_struct* a = node->first_attribute; a; a = a->next_attribute) - { - if ((flags & (format_indent_attributes | format_raw)) == format_indent_attributes) - { - writer.write('\n'); - - text_output_indent(writer, indent, indent_length, depth + 1); - } - else - { - writer.write(' '); - } - - writer.write_string(a->name ? a->name + 0 : default_name); - writer.write('=', enquotation_char); - - if (a->value) - text_output(writer, a->value, ctx_special_attr, flags); - - writer.write(enquotation_char); - } - } - - PUGI__FN bool node_output_start(xml_buffered_writer& writer, xml_node_struct* node, const char_t* indent, size_t indent_length, unsigned int flags, unsigned int depth) - { - const char_t* default_name = PUGIXML_TEXT(":anonymous"); - const char_t* name = node->name ? node->name + 0 : default_name; - - writer.write('<'); - writer.write_string(name); - - if (node->first_attribute) - node_output_attributes(writer, node, indent, indent_length, flags, depth); - - // element nodes can have value if parse_embed_pcdata was used - if (!node->value) - { - if (!node->first_child) - { - if (flags & format_no_empty_element_tags) - { - writer.write('>', '<', '/'); - writer.write_string(name); - writer.write('>'); - - return false; - } - else - { - if ((flags & format_raw) == 0) - writer.write(' '); - - writer.write('/', '>'); - - return false; - } - } - else - { - writer.write('>'); - - return true; - } - } - else - { - writer.write('>'); - - text_output(writer, node->value, ctx_special_pcdata, flags); - - if (!node->first_child) - { - writer.write('<', '/'); - writer.write_string(name); - writer.write('>'); - - return false; - } - else - { - return true; - } - } - } - - PUGI__FN void node_output_end(xml_buffered_writer& writer, xml_node_struct* node) - { - const char_t* default_name = PUGIXML_TEXT(":anonymous"); - const char_t* name = node->name ? node->name + 0 : default_name; - - writer.write('<', '/'); - writer.write_string(name); - writer.write('>'); - } - - PUGI__FN void node_output_simple(xml_buffered_writer& writer, xml_node_struct* node, unsigned int flags) - { - const char_t* default_name = PUGIXML_TEXT(":anonymous"); - - switch (PUGI__NODETYPE(node)) - { - case node_pcdata: - text_output(writer, node->value ? node->value + 0 : PUGIXML_TEXT(""), ctx_special_pcdata, flags); - break; - - case node_cdata: - text_output_cdata(writer, node->value ? node->value + 0 : PUGIXML_TEXT("")); - break; - - case node_comment: - node_output_comment(writer, node->value ? node->value + 0 : PUGIXML_TEXT("")); - break; - - case node_pi: - writer.write('<', '?'); - writer.write_string(node->name ? node->name + 0 : default_name); - - if (node->value) - { - writer.write(' '); - node_output_pi_value(writer, node->value); - } - - writer.write('?', '>'); - break; - - case node_declaration: - writer.write('<', '?'); - writer.write_string(node->name ? node->name + 0 : default_name); - node_output_attributes(writer, node, PUGIXML_TEXT(""), 0, flags | format_raw, 0); - writer.write('?', '>'); - break; - - case node_doctype: - writer.write('<', '!', 'D', 'O', 'C'); - writer.write('T', 'Y', 'P', 'E'); - - if (node->value) - { - writer.write(' '); - writer.write_string(node->value); - } - - writer.write('>'); - break; - - default: - assert(false && "Invalid node type"); // unreachable - } - } - - enum indent_flags_t - { - indent_newline = 1, - indent_indent = 2 - }; - - PUGI__FN void node_output(xml_buffered_writer& writer, xml_node_struct* root, const char_t* indent, unsigned int flags, unsigned int depth) - { - size_t indent_length = ((flags & (format_indent | format_indent_attributes)) && (flags & format_raw) == 0) ? strlength(indent) : 0; - unsigned int indent_flags = indent_indent; - - xml_node_struct* node = root; - - do - { - assert(node); - - // begin writing current node - if (PUGI__NODETYPE(node) == node_pcdata || PUGI__NODETYPE(node) == node_cdata) - { - node_output_simple(writer, node, flags); - - indent_flags = 0; - } - else - { - if ((indent_flags & indent_newline) && (flags & format_raw) == 0) - writer.write('\n'); - - if ((indent_flags & indent_indent) && indent_length) - text_output_indent(writer, indent, indent_length, depth); - - if (PUGI__NODETYPE(node) == node_element) - { - indent_flags = indent_newline | indent_indent; - - if (node_output_start(writer, node, indent, indent_length, flags, depth)) - { - // element nodes can have value if parse_embed_pcdata was used - if (node->value) - indent_flags = 0; - - node = node->first_child; - depth++; - continue; - } - } - else if (PUGI__NODETYPE(node) == node_document) - { - indent_flags = indent_indent; - - if (node->first_child) - { - node = node->first_child; - continue; - } - } - else - { - node_output_simple(writer, node, flags); - - indent_flags = indent_newline | indent_indent; - } - } - - // continue to the next node - while (node != root) - { - if (node->next_sibling) - { - node = node->next_sibling; - break; - } - - node = node->parent; - - // write closing node - if (PUGI__NODETYPE(node) == node_element) - { - depth--; - - if ((indent_flags & indent_newline) && (flags & format_raw) == 0) - writer.write('\n'); - - if ((indent_flags & indent_indent) && indent_length) - text_output_indent(writer, indent, indent_length, depth); - - node_output_end(writer, node); - - indent_flags = indent_newline | indent_indent; - } - } - } - while (node != root); - - if ((indent_flags & indent_newline) && (flags & format_raw) == 0) - writer.write('\n'); - } - - PUGI__FN bool has_declaration(xml_node_struct* node) - { - for (xml_node_struct* child = node->first_child; child; child = child->next_sibling) - { - xml_node_type type = PUGI__NODETYPE(child); - - if (type == node_declaration) return true; - if (type == node_element) return false; - } - - return false; - } - - PUGI__FN bool is_attribute_of(xml_attribute_struct* attr, xml_node_struct* node) - { - for (xml_attribute_struct* a = node->first_attribute; a; a = a->next_attribute) - if (a == attr) - return true; - - return false; - } - - PUGI__FN bool allow_insert_attribute(xml_node_type parent) - { - return parent == node_element || parent == node_declaration; - } - - PUGI__FN bool allow_insert_child(xml_node_type parent, xml_node_type child) - { - if (parent != node_document && parent != node_element) return false; - if (child == node_document || child == node_null) return false; - if (parent != node_document && (child == node_declaration || child == node_doctype)) return false; - - return true; - } - - PUGI__FN bool allow_move(xml_node parent, xml_node child) - { - // check that child can be a child of parent - if (!allow_insert_child(parent.type(), child.type())) - return false; - - // check that node is not moved between documents - if (parent.root() != child.root()) - return false; - - // check that new parent is not in the child subtree - xml_node cur = parent; - - while (cur) - { - if (cur == child) - return false; - - cur = cur.parent(); - } - - return true; - } - - template - PUGI__FN void node_copy_string(String& dest, Header& header, uintptr_t header_mask, char_t* source, Header& source_header, xml_allocator* alloc) - { - assert(!dest && (header & header_mask) == 0); - - if (source) - { - if (alloc && (source_header & header_mask) == 0) - { - dest = source; - - // since strcpy_insitu can reuse document buffer memory we need to mark both source and dest as shared - header |= xml_memory_page_contents_shared_mask; - source_header |= xml_memory_page_contents_shared_mask; - } - else - strcpy_insitu(dest, header, header_mask, source, strlength(source)); - } - } - - PUGI__FN void node_copy_contents(xml_node_struct* dn, xml_node_struct* sn, xml_allocator* shared_alloc) - { - node_copy_string(dn->name, dn->header, xml_memory_page_name_allocated_mask, sn->name, sn->header, shared_alloc); - node_copy_string(dn->value, dn->header, xml_memory_page_value_allocated_mask, sn->value, sn->header, shared_alloc); - - for (xml_attribute_struct* sa = sn->first_attribute; sa; sa = sa->next_attribute) - { - xml_attribute_struct* da = append_new_attribute(dn, get_allocator(dn)); - - if (da) - { - node_copy_string(da->name, da->header, xml_memory_page_name_allocated_mask, sa->name, sa->header, shared_alloc); - node_copy_string(da->value, da->header, xml_memory_page_value_allocated_mask, sa->value, sa->header, shared_alloc); - } - } - } - - PUGI__FN void node_copy_tree(xml_node_struct* dn, xml_node_struct* sn) - { - xml_allocator& alloc = get_allocator(dn); - xml_allocator* shared_alloc = (&alloc == &get_allocator(sn)) ? &alloc : 0; - - node_copy_contents(dn, sn, shared_alloc); - - xml_node_struct* dit = dn; - xml_node_struct* sit = sn->first_child; - - while (sit && sit != sn) - { - // loop invariant: dit is inside the subtree rooted at dn - assert(dit); - - // when a tree is copied into one of the descendants, we need to skip that subtree to avoid an infinite loop - if (sit != dn) - { - xml_node_struct* copy = append_new_node(dit, alloc, PUGI__NODETYPE(sit)); - - if (copy) - { - node_copy_contents(copy, sit, shared_alloc); - - if (sit->first_child) - { - dit = copy; - sit = sit->first_child; - continue; - } - } - } - - // continue to the next node - do - { - if (sit->next_sibling) - { - sit = sit->next_sibling; - break; - } - - sit = sit->parent; - dit = dit->parent; - - // loop invariant: dit is inside the subtree rooted at dn while sit is inside sn - assert(sit == sn || dit); - } - while (sit != sn); - } - - assert(!sit || dit == dn->parent); - } - - PUGI__FN void node_copy_attribute(xml_attribute_struct* da, xml_attribute_struct* sa) - { - xml_allocator& alloc = get_allocator(da); - xml_allocator* shared_alloc = (&alloc == &get_allocator(sa)) ? &alloc : 0; - - node_copy_string(da->name, da->header, xml_memory_page_name_allocated_mask, sa->name, sa->header, shared_alloc); - node_copy_string(da->value, da->header, xml_memory_page_value_allocated_mask, sa->value, sa->header, shared_alloc); - } - - inline bool is_text_node(xml_node_struct* node) - { - xml_node_type type = PUGI__NODETYPE(node); - - return type == node_pcdata || type == node_cdata; - } - - // get value with conversion functions - template PUGI__FN PUGI__UNSIGNED_OVERFLOW U string_to_integer(const char_t* value, U minv, U maxv) - { - U result = 0; - const char_t* s = value; - - while (PUGI__IS_CHARTYPE(*s, ct_space)) - s++; - - bool negative = (*s == '-'); - - s += (*s == '+' || *s == '-'); - - bool overflow = false; - - if (s[0] == '0' && (s[1] | ' ') == 'x') - { - s += 2; - - // since overflow detection relies on length of the sequence skip leading zeros - while (*s == '0') - s++; - - const char_t* start = s; - - for (;;) - { - if (static_cast(*s - '0') < 10) - result = result * 16 + (*s - '0'); - else if (static_cast((*s | ' ') - 'a') < 6) - result = result * 16 + ((*s | ' ') - 'a' + 10); - else - break; - - s++; - } - - size_t digits = static_cast(s - start); - - overflow = digits > sizeof(U) * 2; - } - else - { - // since overflow detection relies on length of the sequence skip leading zeros - while (*s == '0') - s++; - - const char_t* start = s; - - for (;;) - { - if (static_cast(*s - '0') < 10) - result = result * 10 + (*s - '0'); - else - break; - - s++; - } - - size_t digits = static_cast(s - start); - - PUGI__STATIC_ASSERT(sizeof(U) == 8 || sizeof(U) == 4 || sizeof(U) == 2); - - const size_t max_digits10 = sizeof(U) == 8 ? 20 : sizeof(U) == 4 ? 10 : 5; - const char_t max_lead = sizeof(U) == 8 ? '1' : sizeof(U) == 4 ? '4' : '6'; - const size_t high_bit = sizeof(U) * 8 - 1; - - overflow = digits >= max_digits10 && !(digits == max_digits10 && (*start < max_lead || (*start == max_lead && result >> high_bit))); - } - - if (negative) - { - // Workaround for crayc++ CC-3059: Expected no overflow in routine. - #ifdef _CRAYC - return (overflow || result > ~minv + 1) ? minv : ~result + 1; - #else - return (overflow || result > 0 - minv) ? minv : 0 - result; - #endif - } - else - return (overflow || result > maxv) ? maxv : result; - } - - PUGI__FN int get_value_int(const char_t* value) - { - return string_to_integer(value, static_cast(INT_MIN), INT_MAX); - } - - PUGI__FN unsigned int get_value_uint(const char_t* value) - { - return string_to_integer(value, 0, UINT_MAX); - } - - PUGI__FN double get_value_double(const char_t* value) - { - #ifdef PUGIXML_WCHAR_MODE - return wcstod(value, 0); - #else - return strtod(value, 0); - #endif - } - - PUGI__FN float get_value_float(const char_t* value) - { - #ifdef PUGIXML_WCHAR_MODE - return static_cast(wcstod(value, 0)); - #else - return static_cast(strtod(value, 0)); - #endif - } - - PUGI__FN bool get_value_bool(const char_t* value) - { - // only look at first char - char_t first = *value; - - // 1*, t* (true), T* (True), y* (yes), Y* (YES) - return (first == '1' || first == 't' || first == 'T' || first == 'y' || first == 'Y'); - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN long long get_value_llong(const char_t* value) - { - return string_to_integer(value, static_cast(LLONG_MIN), LLONG_MAX); - } - - PUGI__FN unsigned long long get_value_ullong(const char_t* value) - { - return string_to_integer(value, 0, ULLONG_MAX); - } -#endif - - template PUGI__FN PUGI__UNSIGNED_OVERFLOW char_t* integer_to_string(char_t* begin, char_t* end, U value, bool negative) - { - char_t* result = end - 1; - U rest = negative ? 0 - value : value; - - do - { - *result-- = static_cast('0' + (rest % 10)); - rest /= 10; - } - while (rest); - - assert(result >= begin); - (void)begin; - - *result = '-'; - - return result + !negative; - } - - // set value with conversion functions - template - PUGI__FN bool set_value_ascii(String& dest, Header& header, uintptr_t header_mask, char* buf) - { - #ifdef PUGIXML_WCHAR_MODE - char_t wbuf[128]; - assert(strlen(buf) < sizeof(wbuf) / sizeof(wbuf[0])); - - size_t offset = 0; - for (; buf[offset]; ++offset) wbuf[offset] = buf[offset]; - - return strcpy_insitu(dest, header, header_mask, wbuf, offset); - #else - return strcpy_insitu(dest, header, header_mask, buf, strlen(buf)); - #endif - } - - template - PUGI__FN bool set_value_integer(String& dest, Header& header, uintptr_t header_mask, U value, bool negative) - { - char_t buf[64]; - char_t* end = buf + sizeof(buf) / sizeof(buf[0]); - char_t* begin = integer_to_string(buf, end, value, negative); - - return strcpy_insitu(dest, header, header_mask, begin, end - begin); - } - - template - PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, float value, int precision) - { - char buf[128]; - PUGI__SNPRINTF(buf, "%.*g", precision, double(value)); - - return set_value_ascii(dest, header, header_mask, buf); - } - - template - PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, double value, int precision) - { - char buf[128]; - PUGI__SNPRINTF(buf, "%.*g", precision, value); - - return set_value_ascii(dest, header, header_mask, buf); - } - - template - PUGI__FN bool set_value_bool(String& dest, Header& header, uintptr_t header_mask, bool value) - { - return strcpy_insitu(dest, header, header_mask, value ? PUGIXML_TEXT("true") : PUGIXML_TEXT("false"), value ? 4 : 5); - } - - PUGI__FN xml_parse_result load_buffer_impl(xml_document_struct* doc, xml_node_struct* root, void* contents, size_t size, unsigned int options, xml_encoding encoding, bool is_mutable, bool own, char_t** out_buffer) - { - // check input buffer - if (!contents && size) return make_parse_result(status_io_error); - - // get actual encoding - xml_encoding buffer_encoding = impl::get_buffer_encoding(encoding, contents, size); - - // get private buffer - char_t* buffer = 0; - size_t length = 0; - - // coverity[var_deref_model] - if (!impl::convert_buffer(buffer, length, buffer_encoding, contents, size, is_mutable)) return impl::make_parse_result(status_out_of_memory); - - // delete original buffer if we performed a conversion - if (own && buffer != contents && contents) impl::xml_memory::deallocate(contents); - - // grab onto buffer if it's our buffer, user is responsible for deallocating contents himself - if (own || buffer != contents) *out_buffer = buffer; - - // store buffer for offset_debug - doc->buffer = buffer; - - // parse - xml_parse_result res = impl::xml_parser::parse(buffer, length, doc, root, options); - - // remember encoding - res.encoding = buffer_encoding; - - return res; - } - - // we need to get length of entire file to load it in memory; the only (relatively) sane way to do it is via seek/tell trick - PUGI__FN xml_parse_status get_file_size(FILE* file, size_t& out_result) - { - #if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 && !defined(_WIN32_WCE) - // there are 64-bit versions of fseek/ftell, let's use them - typedef __int64 length_type; - - _fseeki64(file, 0, SEEK_END); - length_type length = _ftelli64(file); - _fseeki64(file, 0, SEEK_SET); - #elif defined(__MINGW32__) && !defined(__NO_MINGW_LFS) && (!defined(__STRICT_ANSI__) || defined(__MINGW64_VERSION_MAJOR)) - // there are 64-bit versions of fseek/ftell, let's use them - typedef off64_t length_type; - - fseeko64(file, 0, SEEK_END); - length_type length = ftello64(file); - fseeko64(file, 0, SEEK_SET); - #else - // if this is a 32-bit OS, long is enough; if this is a unix system, long is 64-bit, which is enough; otherwise we can't do anything anyway. - typedef long length_type; - - fseek(file, 0, SEEK_END); - length_type length = ftell(file); - fseek(file, 0, SEEK_SET); - #endif - - // check for I/O errors - if (length < 0) return status_io_error; - - // check for overflow - size_t result = static_cast(length); - - if (static_cast(result) != length) return status_out_of_memory; - - // finalize - out_result = result; - - return status_ok; - } - - // This function assumes that buffer has extra sizeof(char_t) writable bytes after size - PUGI__FN size_t zero_terminate_buffer(void* buffer, size_t size, xml_encoding encoding) - { - // We only need to zero-terminate if encoding conversion does not do it for us - #ifdef PUGIXML_WCHAR_MODE - xml_encoding wchar_encoding = get_wchar_encoding(); - - if (encoding == wchar_encoding || need_endian_swap_utf(encoding, wchar_encoding)) - { - size_t length = size / sizeof(char_t); - - static_cast(buffer)[length] = 0; - return (length + 1) * sizeof(char_t); - } - #else - if (encoding == encoding_utf8) - { - static_cast(buffer)[size] = 0; - return size + 1; - } - #endif - - return size; - } - - PUGI__FN xml_parse_result load_file_impl(xml_document_struct* doc, FILE* file, unsigned int options, xml_encoding encoding, char_t** out_buffer) - { - if (!file) return make_parse_result(status_file_not_found); - - // get file size (can result in I/O errors) - size_t size = 0; - xml_parse_status size_status = get_file_size(file, size); - if (size_status != status_ok) return make_parse_result(size_status); - - size_t max_suffix_size = sizeof(char_t); - - // allocate buffer for the whole file - char* contents = static_cast(xml_memory::allocate(size + max_suffix_size)); - if (!contents) return make_parse_result(status_out_of_memory); - - // read file in memory - size_t read_size = fread(contents, 1, size, file); - - if (read_size != size) - { - xml_memory::deallocate(contents); - return make_parse_result(status_io_error); - } - - xml_encoding real_encoding = get_buffer_encoding(encoding, contents, size); - - return load_buffer_impl(doc, doc, contents, zero_terminate_buffer(contents, size, real_encoding), options, real_encoding, true, true, out_buffer); - } - - PUGI__FN void close_file(FILE* file) - { - fclose(file); - } - -#ifndef PUGIXML_NO_STL - template struct xml_stream_chunk - { - static xml_stream_chunk* create() - { - void* memory = xml_memory::allocate(sizeof(xml_stream_chunk)); - if (!memory) return 0; - - return new (memory) xml_stream_chunk(); - } - - static void destroy(xml_stream_chunk* chunk) - { - // free chunk chain - while (chunk) - { - xml_stream_chunk* next_ = chunk->next; - - xml_memory::deallocate(chunk); - - chunk = next_; - } - } - - xml_stream_chunk(): next(0), size(0) - { - } - - xml_stream_chunk* next; - size_t size; - - T data[xml_memory_page_size / sizeof(T)]; - }; - - template PUGI__FN xml_parse_status load_stream_data_noseek(std::basic_istream& stream, void** out_buffer, size_t* out_size) - { - auto_deleter > chunks(0, xml_stream_chunk::destroy); - - // read file to a chunk list - size_t total = 0; - xml_stream_chunk* last = 0; - - while (!stream.eof()) - { - // allocate new chunk - xml_stream_chunk* chunk = xml_stream_chunk::create(); - if (!chunk) return status_out_of_memory; - - // append chunk to list - if (last) last = last->next = chunk; - else chunks.data = last = chunk; - - // read data to chunk - stream.read(chunk->data, static_cast(sizeof(chunk->data) / sizeof(T))); - chunk->size = static_cast(stream.gcount()) * sizeof(T); - - // read may set failbit | eofbit in case gcount() is less than read length, so check for other I/O errors - if (stream.bad() || (!stream.eof() && stream.fail())) return status_io_error; - - // guard against huge files (chunk size is small enough to make this overflow check work) - if (total + chunk->size < total) return status_out_of_memory; - total += chunk->size; - } - - size_t max_suffix_size = sizeof(char_t); - - // copy chunk list to a contiguous buffer - char* buffer = static_cast(xml_memory::allocate(total + max_suffix_size)); - if (!buffer) return status_out_of_memory; - - char* write = buffer; - - for (xml_stream_chunk* chunk = chunks.data; chunk; chunk = chunk->next) - { - assert(write + chunk->size <= buffer + total); - memcpy(write, chunk->data, chunk->size); - write += chunk->size; - } - - assert(write == buffer + total); - - // return buffer - *out_buffer = buffer; - *out_size = total; - - return status_ok; - } - - template PUGI__FN xml_parse_status load_stream_data_seek(std::basic_istream& stream, void** out_buffer, size_t* out_size) - { - // get length of remaining data in stream - typename std::basic_istream::pos_type pos = stream.tellg(); - stream.seekg(0, std::ios::end); - std::streamoff length = stream.tellg() - pos; - stream.seekg(pos); - - if (stream.fail() || pos < 0) return status_io_error; - - // guard against huge files - size_t read_length = static_cast(length); - - if (static_cast(read_length) != length || length < 0) return status_out_of_memory; - - size_t max_suffix_size = sizeof(char_t); - - // read stream data into memory (guard against stream exceptions with buffer holder) - auto_deleter buffer(xml_memory::allocate(read_length * sizeof(T) + max_suffix_size), xml_memory::deallocate); - if (!buffer.data) return status_out_of_memory; - - stream.read(static_cast(buffer.data), static_cast(read_length)); - - // read may set failbit | eofbit in case gcount() is less than read_length (i.e. line ending conversion), so check for other I/O errors - if (stream.bad() || (!stream.eof() && stream.fail())) return status_io_error; - - // return buffer - size_t actual_length = static_cast(stream.gcount()); - assert(actual_length <= read_length); - - *out_buffer = buffer.release(); - *out_size = actual_length * sizeof(T); - - return status_ok; - } - - template PUGI__FN xml_parse_result load_stream_impl(xml_document_struct* doc, std::basic_istream& stream, unsigned int options, xml_encoding encoding, char_t** out_buffer) - { - void* buffer = 0; - size_t size = 0; - xml_parse_status status = status_ok; - - // if stream has an error bit set, bail out (otherwise tellg() can fail and we'll clear error bits) - if (stream.fail()) return make_parse_result(status_io_error); - - // load stream to memory (using seek-based implementation if possible, since it's faster and takes less memory) - if (stream.tellg() < 0) - { - stream.clear(); // clear error flags that could be set by a failing tellg - status = load_stream_data_noseek(stream, &buffer, &size); - } - else - status = load_stream_data_seek(stream, &buffer, &size); - - if (status != status_ok) return make_parse_result(status); - - xml_encoding real_encoding = get_buffer_encoding(encoding, buffer, size); - - return load_buffer_impl(doc, doc, buffer, zero_terminate_buffer(buffer, size, real_encoding), options, real_encoding, true, true, out_buffer); - } -#endif - -#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) || (defined(__MINGW32__) && (!defined(__STRICT_ANSI__) || defined(__MINGW64_VERSION_MAJOR))) - PUGI__FN FILE* open_file_wide(const wchar_t* path, const wchar_t* mode) - { - return _wfopen(path, mode); - } -#else - PUGI__FN char* convert_path_heap(const wchar_t* str) - { - assert(str); - - // first pass: get length in utf8 characters - size_t length = strlength_wide(str); - size_t size = as_utf8_begin(str, length); - - // allocate resulting string - char* result = static_cast(xml_memory::allocate(size + 1)); - if (!result) return 0; - - // second pass: convert to utf8 - as_utf8_end(result, size, str, length); - - // zero-terminate - result[size] = 0; - - return result; - } - - PUGI__FN FILE* open_file_wide(const wchar_t* path, const wchar_t* mode) - { - // there is no standard function to open wide paths, so our best bet is to try utf8 path - char* path_utf8 = convert_path_heap(path); - if (!path_utf8) return 0; - - // convert mode to ASCII (we mirror _wfopen interface) - char mode_ascii[4] = {0}; - for (size_t i = 0; mode[i]; ++i) mode_ascii[i] = static_cast(mode[i]); - - // try to open the utf8 path - FILE* result = fopen(path_utf8, mode_ascii); - - // free dummy buffer - xml_memory::deallocate(path_utf8); - - return result; - } -#endif - - PUGI__FN bool save_file_impl(const xml_document& doc, FILE* file, const char_t* indent, unsigned int flags, xml_encoding encoding) - { - if (!file) return false; - - xml_writer_file writer(file); - doc.save(writer, indent, flags, encoding); - - return ferror(file) == 0; - } - - struct name_null_sentry - { - xml_node_struct* node; - char_t* name; - - name_null_sentry(xml_node_struct* node_): node(node_), name(node_->name) - { - node->name = 0; - } - - ~name_null_sentry() - { - node->name = name; - } - }; -PUGI__NS_END - -namespace pugi -{ - PUGI__FN xml_writer_file::xml_writer_file(void* file_): file(file_) - { - } - - PUGI__FN void xml_writer_file::write(const void* data, size_t size) - { - size_t result = fwrite(data, 1, size, static_cast(file)); - (void)!result; // unfortunately we can't do proper error handling here - } - -#ifndef PUGIXML_NO_STL - PUGI__FN xml_writer_stream::xml_writer_stream(std::basic_ostream >& stream): narrow_stream(&stream), wide_stream(0) - { - } - - PUGI__FN xml_writer_stream::xml_writer_stream(std::basic_ostream >& stream): narrow_stream(0), wide_stream(&stream) - { - } - - PUGI__FN void xml_writer_stream::write(const void* data, size_t size) - { - if (narrow_stream) - { - assert(!wide_stream); - narrow_stream->write(reinterpret_cast(data), static_cast(size)); - } - else - { - assert(wide_stream); - assert(size % sizeof(wchar_t) == 0); - - wide_stream->write(reinterpret_cast(data), static_cast(size / sizeof(wchar_t))); - } - } -#endif - - PUGI__FN xml_tree_walker::xml_tree_walker(): _depth(0) - { - } - - PUGI__FN xml_tree_walker::~xml_tree_walker() - { - } - - PUGI__FN int xml_tree_walker::depth() const - { - return _depth; - } - - PUGI__FN bool xml_tree_walker::begin(xml_node&) - { - return true; - } - - PUGI__FN bool xml_tree_walker::end(xml_node&) - { - return true; - } - - PUGI__FN xml_attribute::xml_attribute(): _attr(0) - { - } - - PUGI__FN xml_attribute::xml_attribute(xml_attribute_struct* attr): _attr(attr) - { - } - - PUGI__FN static void unspecified_bool_xml_attribute(xml_attribute***) - { - } - - PUGI__FN xml_attribute::operator xml_attribute::unspecified_bool_type() const - { - return _attr ? unspecified_bool_xml_attribute : 0; - } - - PUGI__FN bool xml_attribute::operator!() const - { - return !_attr; - } - - PUGI__FN bool xml_attribute::operator==(const xml_attribute& r) const - { - return (_attr == r._attr); - } - - PUGI__FN bool xml_attribute::operator!=(const xml_attribute& r) const - { - return (_attr != r._attr); - } - - PUGI__FN bool xml_attribute::operator<(const xml_attribute& r) const - { - return (_attr < r._attr); - } - - PUGI__FN bool xml_attribute::operator>(const xml_attribute& r) const - { - return (_attr > r._attr); - } - - PUGI__FN bool xml_attribute::operator<=(const xml_attribute& r) const - { - return (_attr <= r._attr); - } - - PUGI__FN bool xml_attribute::operator>=(const xml_attribute& r) const - { - return (_attr >= r._attr); - } - - PUGI__FN xml_attribute xml_attribute::next_attribute() const - { - return _attr ? xml_attribute(_attr->next_attribute) : xml_attribute(); - } - - PUGI__FN xml_attribute xml_attribute::previous_attribute() const - { - return _attr && _attr->prev_attribute_c->next_attribute ? xml_attribute(_attr->prev_attribute_c) : xml_attribute(); - } - - PUGI__FN const char_t* xml_attribute::as_string(const char_t* def) const - { - return (_attr && _attr->value) ? _attr->value + 0 : def; - } - - PUGI__FN int xml_attribute::as_int(int def) const - { - return (_attr && _attr->value) ? impl::get_value_int(_attr->value) : def; - } - - PUGI__FN unsigned int xml_attribute::as_uint(unsigned int def) const - { - return (_attr && _attr->value) ? impl::get_value_uint(_attr->value) : def; - } - - PUGI__FN double xml_attribute::as_double(double def) const - { - return (_attr && _attr->value) ? impl::get_value_double(_attr->value) : def; - } - - PUGI__FN float xml_attribute::as_float(float def) const - { - return (_attr && _attr->value) ? impl::get_value_float(_attr->value) : def; - } - - PUGI__FN bool xml_attribute::as_bool(bool def) const - { - return (_attr && _attr->value) ? impl::get_value_bool(_attr->value) : def; - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN long long xml_attribute::as_llong(long long def) const - { - return (_attr && _attr->value) ? impl::get_value_llong(_attr->value) : def; - } - - PUGI__FN unsigned long long xml_attribute::as_ullong(unsigned long long def) const - { - return (_attr && _attr->value) ? impl::get_value_ullong(_attr->value) : def; - } -#endif - - PUGI__FN bool xml_attribute::empty() const - { - return !_attr; - } - - PUGI__FN const char_t* xml_attribute::name() const - { - return (_attr && _attr->name) ? _attr->name + 0 : PUGIXML_TEXT(""); - } - - PUGI__FN const char_t* xml_attribute::value() const - { - return (_attr && _attr->value) ? _attr->value + 0 : PUGIXML_TEXT(""); - } - - PUGI__FN size_t xml_attribute::hash_value() const - { - return static_cast(reinterpret_cast(_attr) / sizeof(xml_attribute_struct)); - } - - PUGI__FN xml_attribute_struct* xml_attribute::internal_object() const - { - return _attr; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(const char_t* rhs) - { - set_value(rhs); - return *this; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(int rhs) - { - set_value(rhs); - return *this; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(unsigned int rhs) - { - set_value(rhs); - return *this; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(long rhs) - { - set_value(rhs); - return *this; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(unsigned long rhs) - { - set_value(rhs); - return *this; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(double rhs) - { - set_value(rhs); - return *this; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(float rhs) - { - set_value(rhs); - return *this; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(bool rhs) - { - set_value(rhs); - return *this; - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN xml_attribute& xml_attribute::operator=(long long rhs) - { - set_value(rhs); - return *this; - } - - PUGI__FN xml_attribute& xml_attribute::operator=(unsigned long long rhs) - { - set_value(rhs); - return *this; - } -#endif - - PUGI__FN bool xml_attribute::set_name(const char_t* rhs) - { - if (!_attr) return false; - - return impl::strcpy_insitu(_attr->name, _attr->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs)); - } - - PUGI__FN bool xml_attribute::set_value(const char_t* rhs) - { - if (!_attr) return false; - - return impl::strcpy_insitu(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, impl::strlength(rhs)); - } - - PUGI__FN bool xml_attribute::set_value(int rhs) - { - if (!_attr) return false; - - return impl::set_value_integer(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, rhs < 0); - } - - PUGI__FN bool xml_attribute::set_value(unsigned int rhs) - { - if (!_attr) return false; - - return impl::set_value_integer(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, false); - } - - PUGI__FN bool xml_attribute::set_value(long rhs) - { - if (!_attr) return false; - - return impl::set_value_integer(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, rhs < 0); - } - - PUGI__FN bool xml_attribute::set_value(unsigned long rhs) - { - if (!_attr) return false; - - return impl::set_value_integer(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, false); - } - - PUGI__FN bool xml_attribute::set_value(double rhs) - { - if (!_attr) return false; - - return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, default_double_precision); - } - - PUGI__FN bool xml_attribute::set_value(double rhs, int precision) - { - if (!_attr) return false; - - return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, precision); - } - - PUGI__FN bool xml_attribute::set_value(float rhs) - { - if (!_attr) return false; - - return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, default_float_precision); - } - - PUGI__FN bool xml_attribute::set_value(float rhs, int precision) - { - if (!_attr) return false; - - return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, precision); - } - - PUGI__FN bool xml_attribute::set_value(bool rhs) - { - if (!_attr) return false; - - return impl::set_value_bool(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN bool xml_attribute::set_value(long long rhs) - { - if (!_attr) return false; - - return impl::set_value_integer(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, rhs < 0); - } - - PUGI__FN bool xml_attribute::set_value(unsigned long long rhs) - { - if (!_attr) return false; - - return impl::set_value_integer(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, false); - } -#endif - -#ifdef __BORLANDC__ - PUGI__FN bool operator&&(const xml_attribute& lhs, bool rhs) - { - return (bool)lhs && rhs; - } - - PUGI__FN bool operator||(const xml_attribute& lhs, bool rhs) - { - return (bool)lhs || rhs; - } -#endif - - PUGI__FN xml_node::xml_node(): _root(0) - { - } - - PUGI__FN xml_node::xml_node(xml_node_struct* p): _root(p) - { - } - - PUGI__FN static void unspecified_bool_xml_node(xml_node***) - { - } - - PUGI__FN xml_node::operator xml_node::unspecified_bool_type() const - { - return _root ? unspecified_bool_xml_node : 0; - } - - PUGI__FN bool xml_node::operator!() const - { - return !_root; - } - - PUGI__FN xml_node::iterator xml_node::begin() const - { - return iterator(_root ? _root->first_child + 0 : 0, _root); - } - - PUGI__FN xml_node::iterator xml_node::end() const - { - return iterator(0, _root); - } - - PUGI__FN xml_node::attribute_iterator xml_node::attributes_begin() const - { - return attribute_iterator(_root ? _root->first_attribute + 0 : 0, _root); - } - - PUGI__FN xml_node::attribute_iterator xml_node::attributes_end() const - { - return attribute_iterator(0, _root); - } - - PUGI__FN xml_object_range xml_node::children() const - { - return xml_object_range(begin(), end()); - } - - PUGI__FN xml_object_range xml_node::children(const char_t* name_) const - { - return xml_object_range(xml_named_node_iterator(child(name_)._root, _root, name_), xml_named_node_iterator(0, _root, name_)); - } - - PUGI__FN xml_object_range xml_node::attributes() const - { - return xml_object_range(attributes_begin(), attributes_end()); - } - - PUGI__FN bool xml_node::operator==(const xml_node& r) const - { - return (_root == r._root); - } - - PUGI__FN bool xml_node::operator!=(const xml_node& r) const - { - return (_root != r._root); - } - - PUGI__FN bool xml_node::operator<(const xml_node& r) const - { - return (_root < r._root); - } - - PUGI__FN bool xml_node::operator>(const xml_node& r) const - { - return (_root > r._root); - } - - PUGI__FN bool xml_node::operator<=(const xml_node& r) const - { - return (_root <= r._root); - } - - PUGI__FN bool xml_node::operator>=(const xml_node& r) const - { - return (_root >= r._root); - } - - PUGI__FN bool xml_node::empty() const - { - return !_root; - } - - PUGI__FN const char_t* xml_node::name() const - { - return (_root && _root->name) ? _root->name + 0 : PUGIXML_TEXT(""); - } - - PUGI__FN xml_node_type xml_node::type() const - { - return _root ? PUGI__NODETYPE(_root) : node_null; - } - - PUGI__FN const char_t* xml_node::value() const - { - return (_root && _root->value) ? _root->value + 0 : PUGIXML_TEXT(""); - } - - PUGI__FN xml_node xml_node::child(const char_t* name_) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - if (i->name && impl::strequal(name_, i->name)) return xml_node(i); - - return xml_node(); - } - - PUGI__FN xml_attribute xml_node::attribute(const char_t* name_) const - { - if (!_root) return xml_attribute(); - - for (xml_attribute_struct* i = _root->first_attribute; i; i = i->next_attribute) - if (i->name && impl::strequal(name_, i->name)) - return xml_attribute(i); - - return xml_attribute(); - } - - PUGI__FN xml_node xml_node::next_sibling(const char_t* name_) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->next_sibling; i; i = i->next_sibling) - if (i->name && impl::strequal(name_, i->name)) return xml_node(i); - - return xml_node(); - } - - PUGI__FN xml_node xml_node::next_sibling() const - { - return _root ? xml_node(_root->next_sibling) : xml_node(); - } - - PUGI__FN xml_node xml_node::previous_sibling(const char_t* name_) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->prev_sibling_c; i->next_sibling; i = i->prev_sibling_c) - if (i->name && impl::strequal(name_, i->name)) return xml_node(i); - - return xml_node(); - } - - PUGI__FN xml_attribute xml_node::attribute(const char_t* name_, xml_attribute& hint_) const - { - xml_attribute_struct* hint = hint_._attr; - - // if hint is not an attribute of node, behavior is not defined - assert(!hint || (_root && impl::is_attribute_of(hint, _root))); - - if (!_root) return xml_attribute(); - - // optimistically search from hint up until the end - for (xml_attribute_struct* i = hint; i; i = i->next_attribute) - if (i->name && impl::strequal(name_, i->name)) - { - // update hint to maximize efficiency of searching for consecutive attributes - hint_._attr = i->next_attribute; - - return xml_attribute(i); - } - - // wrap around and search from the first attribute until the hint - // 'j' null pointer check is technically redundant, but it prevents a crash in case the assertion above fails - for (xml_attribute_struct* j = _root->first_attribute; j && j != hint; j = j->next_attribute) - if (j->name && impl::strequal(name_, j->name)) - { - // update hint to maximize efficiency of searching for consecutive attributes - hint_._attr = j->next_attribute; - - return xml_attribute(j); - } - - return xml_attribute(); - } - - PUGI__FN xml_node xml_node::previous_sibling() const - { - if (!_root) return xml_node(); - - if (_root->prev_sibling_c->next_sibling) return xml_node(_root->prev_sibling_c); - else return xml_node(); - } - - PUGI__FN xml_node xml_node::parent() const - { - return _root ? xml_node(_root->parent) : xml_node(); - } - - PUGI__FN xml_node xml_node::root() const - { - return _root ? xml_node(&impl::get_document(_root)) : xml_node(); - } - - PUGI__FN xml_text xml_node::text() const - { - return xml_text(_root); - } - - PUGI__FN const char_t* xml_node::child_value() const - { - if (!_root) return PUGIXML_TEXT(""); - - // element nodes can have value if parse_embed_pcdata was used - if (PUGI__NODETYPE(_root) == node_element && _root->value) - return _root->value; - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - if (impl::is_text_node(i) && i->value) - return i->value; - - return PUGIXML_TEXT(""); - } - - PUGI__FN const char_t* xml_node::child_value(const char_t* name_) const - { - return child(name_).child_value(); - } - - PUGI__FN xml_attribute xml_node::first_attribute() const - { - return _root ? xml_attribute(_root->first_attribute) : xml_attribute(); - } - - PUGI__FN xml_attribute xml_node::last_attribute() const - { - return _root && _root->first_attribute ? xml_attribute(_root->first_attribute->prev_attribute_c) : xml_attribute(); - } - - PUGI__FN xml_node xml_node::first_child() const - { - return _root ? xml_node(_root->first_child) : xml_node(); - } - - PUGI__FN xml_node xml_node::last_child() const - { - return _root && _root->first_child ? xml_node(_root->first_child->prev_sibling_c) : xml_node(); - } - - PUGI__FN bool xml_node::set_name(const char_t* rhs) - { - xml_node_type type_ = _root ? PUGI__NODETYPE(_root) : node_null; - - if (type_ != node_element && type_ != node_pi && type_ != node_declaration) - return false; - - return impl::strcpy_insitu(_root->name, _root->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs)); - } - - PUGI__FN bool xml_node::set_value(const char_t* rhs) - { - xml_node_type type_ = _root ? PUGI__NODETYPE(_root) : node_null; - - if (type_ != node_pcdata && type_ != node_cdata && type_ != node_comment && type_ != node_pi && type_ != node_doctype) - return false; - - return impl::strcpy_insitu(_root->value, _root->header, impl::xml_memory_page_value_allocated_mask, rhs, impl::strlength(rhs)); - } - - PUGI__FN xml_attribute xml_node::append_attribute(const char_t* name_) - { - if (!impl::allow_insert_attribute(type())) return xml_attribute(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_attribute(); - - xml_attribute a(impl::allocate_attribute(alloc)); - if (!a) return xml_attribute(); - - impl::append_attribute(a._attr, _root); - - a.set_name(name_); - - return a; - } - - PUGI__FN xml_attribute xml_node::prepend_attribute(const char_t* name_) - { - if (!impl::allow_insert_attribute(type())) return xml_attribute(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_attribute(); - - xml_attribute a(impl::allocate_attribute(alloc)); - if (!a) return xml_attribute(); - - impl::prepend_attribute(a._attr, _root); - - a.set_name(name_); - - return a; - } - - PUGI__FN xml_attribute xml_node::insert_attribute_after(const char_t* name_, const xml_attribute& attr) - { - if (!impl::allow_insert_attribute(type())) return xml_attribute(); - if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_attribute(); - - xml_attribute a(impl::allocate_attribute(alloc)); - if (!a) return xml_attribute(); - - impl::insert_attribute_after(a._attr, attr._attr, _root); - - a.set_name(name_); - - return a; - } - - PUGI__FN xml_attribute xml_node::insert_attribute_before(const char_t* name_, const xml_attribute& attr) - { - if (!impl::allow_insert_attribute(type())) return xml_attribute(); - if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_attribute(); - - xml_attribute a(impl::allocate_attribute(alloc)); - if (!a) return xml_attribute(); - - impl::insert_attribute_before(a._attr, attr._attr, _root); - - a.set_name(name_); - - return a; - } - - PUGI__FN xml_attribute xml_node::append_copy(const xml_attribute& proto) - { - if (!proto) return xml_attribute(); - if (!impl::allow_insert_attribute(type())) return xml_attribute(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_attribute(); - - xml_attribute a(impl::allocate_attribute(alloc)); - if (!a) return xml_attribute(); - - impl::append_attribute(a._attr, _root); - impl::node_copy_attribute(a._attr, proto._attr); - - return a; - } - - PUGI__FN xml_attribute xml_node::prepend_copy(const xml_attribute& proto) - { - if (!proto) return xml_attribute(); - if (!impl::allow_insert_attribute(type())) return xml_attribute(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_attribute(); - - xml_attribute a(impl::allocate_attribute(alloc)); - if (!a) return xml_attribute(); - - impl::prepend_attribute(a._attr, _root); - impl::node_copy_attribute(a._attr, proto._attr); - - return a; - } - - PUGI__FN xml_attribute xml_node::insert_copy_after(const xml_attribute& proto, const xml_attribute& attr) - { - if (!proto) return xml_attribute(); - if (!impl::allow_insert_attribute(type())) return xml_attribute(); - if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_attribute(); - - xml_attribute a(impl::allocate_attribute(alloc)); - if (!a) return xml_attribute(); - - impl::insert_attribute_after(a._attr, attr._attr, _root); - impl::node_copy_attribute(a._attr, proto._attr); - - return a; - } - - PUGI__FN xml_attribute xml_node::insert_copy_before(const xml_attribute& proto, const xml_attribute& attr) - { - if (!proto) return xml_attribute(); - if (!impl::allow_insert_attribute(type())) return xml_attribute(); - if (!attr || !impl::is_attribute_of(attr._attr, _root)) return xml_attribute(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_attribute(); - - xml_attribute a(impl::allocate_attribute(alloc)); - if (!a) return xml_attribute(); - - impl::insert_attribute_before(a._attr, attr._attr, _root); - impl::node_copy_attribute(a._attr, proto._attr); - - return a; - } - - PUGI__FN xml_node xml_node::append_child(xml_node_type type_) - { - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_node(); - - xml_node n(impl::allocate_node(alloc, type_)); - if (!n) return xml_node(); - - impl::append_node(n._root, _root); - - if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml")); - - return n; - } - - PUGI__FN xml_node xml_node::prepend_child(xml_node_type type_) - { - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_node(); - - xml_node n(impl::allocate_node(alloc, type_)); - if (!n) return xml_node(); - - impl::prepend_node(n._root, _root); - - if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml")); - - return n; - } - - PUGI__FN xml_node xml_node::insert_child_before(xml_node_type type_, const xml_node& node) - { - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - if (!node._root || node._root->parent != _root) return xml_node(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_node(); - - xml_node n(impl::allocate_node(alloc, type_)); - if (!n) return xml_node(); - - impl::insert_node_before(n._root, node._root); - - if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml")); - - return n; - } - - PUGI__FN xml_node xml_node::insert_child_after(xml_node_type type_, const xml_node& node) - { - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - if (!node._root || node._root->parent != _root) return xml_node(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_node(); - - xml_node n(impl::allocate_node(alloc, type_)); - if (!n) return xml_node(); - - impl::insert_node_after(n._root, node._root); - - if (type_ == node_declaration) n.set_name(PUGIXML_TEXT("xml")); - - return n; - } - - PUGI__FN xml_node xml_node::append_child(const char_t* name_) - { - xml_node result = append_child(node_element); - - result.set_name(name_); - - return result; - } - - PUGI__FN xml_node xml_node::prepend_child(const char_t* name_) - { - xml_node result = prepend_child(node_element); - - result.set_name(name_); - - return result; - } - - PUGI__FN xml_node xml_node::insert_child_after(const char_t* name_, const xml_node& node) - { - xml_node result = insert_child_after(node_element, node); - - result.set_name(name_); - - return result; - } - - PUGI__FN xml_node xml_node::insert_child_before(const char_t* name_, const xml_node& node) - { - xml_node result = insert_child_before(node_element, node); - - result.set_name(name_); - - return result; - } - - PUGI__FN xml_node xml_node::append_copy(const xml_node& proto) - { - xml_node_type type_ = proto.type(); - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_node(); - - xml_node n(impl::allocate_node(alloc, type_)); - if (!n) return xml_node(); - - impl::append_node(n._root, _root); - impl::node_copy_tree(n._root, proto._root); - - return n; - } - - PUGI__FN xml_node xml_node::prepend_copy(const xml_node& proto) - { - xml_node_type type_ = proto.type(); - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_node(); - - xml_node n(impl::allocate_node(alloc, type_)); - if (!n) return xml_node(); - - impl::prepend_node(n._root, _root); - impl::node_copy_tree(n._root, proto._root); - - return n; - } - - PUGI__FN xml_node xml_node::insert_copy_after(const xml_node& proto, const xml_node& node) - { - xml_node_type type_ = proto.type(); - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - if (!node._root || node._root->parent != _root) return xml_node(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_node(); - - xml_node n(impl::allocate_node(alloc, type_)); - if (!n) return xml_node(); - - impl::insert_node_after(n._root, node._root); - impl::node_copy_tree(n._root, proto._root); - - return n; - } - - PUGI__FN xml_node xml_node::insert_copy_before(const xml_node& proto, const xml_node& node) - { - xml_node_type type_ = proto.type(); - if (!impl::allow_insert_child(type(), type_)) return xml_node(); - if (!node._root || node._root->parent != _root) return xml_node(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_node(); - - xml_node n(impl::allocate_node(alloc, type_)); - if (!n) return xml_node(); - - impl::insert_node_before(n._root, node._root); - impl::node_copy_tree(n._root, proto._root); - - return n; - } - - PUGI__FN xml_node xml_node::append_move(const xml_node& moved) - { - if (!impl::allow_move(*this, moved)) return xml_node(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_node(); - - // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers - impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask; - - impl::remove_node(moved._root); - impl::append_node(moved._root, _root); - - return moved; - } - - PUGI__FN xml_node xml_node::prepend_move(const xml_node& moved) - { - if (!impl::allow_move(*this, moved)) return xml_node(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_node(); - - // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers - impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask; - - impl::remove_node(moved._root); - impl::prepend_node(moved._root, _root); - - return moved; - } - - PUGI__FN xml_node xml_node::insert_move_after(const xml_node& moved, const xml_node& node) - { - if (!impl::allow_move(*this, moved)) return xml_node(); - if (!node._root || node._root->parent != _root) return xml_node(); - if (moved._root == node._root) return xml_node(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_node(); - - // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers - impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask; - - impl::remove_node(moved._root); - impl::insert_node_after(moved._root, node._root); - - return moved; - } - - PUGI__FN xml_node xml_node::insert_move_before(const xml_node& moved, const xml_node& node) - { - if (!impl::allow_move(*this, moved)) return xml_node(); - if (!node._root || node._root->parent != _root) return xml_node(); - if (moved._root == node._root) return xml_node(); - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return xml_node(); - - // disable document_buffer_order optimization since moving nodes around changes document order without changing buffer pointers - impl::get_document(_root).header |= impl::xml_memory_page_contents_shared_mask; - - impl::remove_node(moved._root); - impl::insert_node_before(moved._root, node._root); - - return moved; - } - - PUGI__FN bool xml_node::remove_attribute(const char_t* name_) - { - return remove_attribute(attribute(name_)); - } - - PUGI__FN bool xml_node::remove_attribute(const xml_attribute& a) - { - if (!_root || !a._attr) return false; - if (!impl::is_attribute_of(a._attr, _root)) return false; - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return false; - - impl::remove_attribute(a._attr, _root); - impl::destroy_attribute(a._attr, alloc); - - return true; - } - - PUGI__FN bool xml_node::remove_attributes() - { - if (!_root) return false; - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return false; - - for (xml_attribute_struct* attr = _root->first_attribute; attr; ) - { - xml_attribute_struct* next = attr->next_attribute; - - impl::destroy_attribute(attr, alloc); - - attr = next; - } - - _root->first_attribute = 0; - - return true; - } - - PUGI__FN bool xml_node::remove_child(const char_t* name_) - { - return remove_child(child(name_)); - } - - PUGI__FN bool xml_node::remove_child(const xml_node& n) - { - if (!_root || !n._root || n._root->parent != _root) return false; - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return false; - - impl::remove_node(n._root); - impl::destroy_node(n._root, alloc); - - return true; - } - - PUGI__FN bool xml_node::remove_children() - { - if (!_root) return false; - - impl::xml_allocator& alloc = impl::get_allocator(_root); - if (!alloc.reserve()) return false; - - for (xml_node_struct* child = _root->first_child; child; ) - { - xml_node_struct* next = child->next_sibling; - - impl::destroy_node(child, alloc); - - child = next; - } - - _root->first_child = 0; - - return true; - } - - PUGI__FN xml_parse_result xml_node::append_buffer(const void* contents, size_t size, unsigned int options, xml_encoding encoding) - { - // append_buffer is only valid for elements/documents - if (!impl::allow_insert_child(type(), node_element)) return impl::make_parse_result(status_append_invalid_root); - - // get document node - impl::xml_document_struct* doc = &impl::get_document(_root); - - // disable document_buffer_order optimization since in a document with multiple buffers comparing buffer pointers does not make sense - doc->header |= impl::xml_memory_page_contents_shared_mask; - - // get extra buffer element (we'll store the document fragment buffer there so that we can deallocate it later) - impl::xml_memory_page* page = 0; - impl::xml_extra_buffer* extra = static_cast(doc->allocate_memory(sizeof(impl::xml_extra_buffer) + sizeof(void*), page)); - (void)page; - - if (!extra) return impl::make_parse_result(status_out_of_memory); - - #ifdef PUGIXML_COMPACT - // align the memory block to a pointer boundary; this is required for compact mode where memory allocations are only 4b aligned - // note that this requires up to sizeof(void*)-1 additional memory, which the allocation above takes into account - extra = reinterpret_cast((reinterpret_cast(extra) + (sizeof(void*) - 1)) & ~(sizeof(void*) - 1)); - #endif - - // add extra buffer to the list - extra->buffer = 0; - extra->next = doc->extra_buffers; - doc->extra_buffers = extra; - - // name of the root has to be NULL before parsing - otherwise closing node mismatches will not be detected at the top level - impl::name_null_sentry sentry(_root); - - return impl::load_buffer_impl(doc, _root, const_cast(contents), size, options, encoding, false, false, &extra->buffer); - } - - PUGI__FN xml_node xml_node::find_child_by_attribute(const char_t* name_, const char_t* attr_name, const char_t* attr_value) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - if (i->name && impl::strequal(name_, i->name)) - { - for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute) - if (a->name && impl::strequal(attr_name, a->name) && impl::strequal(attr_value, a->value ? a->value + 0 : PUGIXML_TEXT(""))) - return xml_node(i); - } - - return xml_node(); - } - - PUGI__FN xml_node xml_node::find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const - { - if (!_root) return xml_node(); - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute) - if (a->name && impl::strequal(attr_name, a->name) && impl::strequal(attr_value, a->value ? a->value + 0 : PUGIXML_TEXT(""))) - return xml_node(i); - - return xml_node(); - } - -#ifndef PUGIXML_NO_STL - PUGI__FN string_t xml_node::path(char_t delimiter) const - { - if (!_root) return string_t(); - - size_t offset = 0; - - for (xml_node_struct* i = _root; i; i = i->parent) - { - offset += (i != _root); - offset += i->name ? impl::strlength(i->name) : 0; - } - - string_t result; - result.resize(offset); - - for (xml_node_struct* j = _root; j; j = j->parent) - { - if (j != _root) - result[--offset] = delimiter; - - if (j->name) - { - size_t length = impl::strlength(j->name); - - offset -= length; - memcpy(&result[offset], j->name, length * sizeof(char_t)); - } - } - - assert(offset == 0); - - return result; - } -#endif - - PUGI__FN xml_node xml_node::first_element_by_path(const char_t* path_, char_t delimiter) const - { - xml_node context = path_[0] == delimiter ? root() : *this; - - if (!context._root) return xml_node(); - - const char_t* path_segment = path_; - - while (*path_segment == delimiter) ++path_segment; - - const char_t* path_segment_end = path_segment; - - while (*path_segment_end && *path_segment_end != delimiter) ++path_segment_end; - - if (path_segment == path_segment_end) return context; - - const char_t* next_segment = path_segment_end; - - while (*next_segment == delimiter) ++next_segment; - - if (*path_segment == '.' && path_segment + 1 == path_segment_end) - return context.first_element_by_path(next_segment, delimiter); - else if (*path_segment == '.' && *(path_segment+1) == '.' && path_segment + 2 == path_segment_end) - return context.parent().first_element_by_path(next_segment, delimiter); - else - { - for (xml_node_struct* j = context._root->first_child; j; j = j->next_sibling) - { - if (j->name && impl::strequalrange(j->name, path_segment, static_cast(path_segment_end - path_segment))) - { - xml_node subsearch = xml_node(j).first_element_by_path(next_segment, delimiter); - - if (subsearch) return subsearch; - } - } - - return xml_node(); - } - } - - PUGI__FN bool xml_node::traverse(xml_tree_walker& walker) - { - walker._depth = -1; - - xml_node arg_begin(_root); - if (!walker.begin(arg_begin)) return false; - - xml_node_struct* cur = _root ? _root->first_child + 0 : 0; - - if (cur) - { - ++walker._depth; - - do - { - xml_node arg_for_each(cur); - if (!walker.for_each(arg_for_each)) - return false; - - if (cur->first_child) - { - ++walker._depth; - cur = cur->first_child; - } - else if (cur->next_sibling) - cur = cur->next_sibling; - else - { - while (!cur->next_sibling && cur != _root && cur->parent) - { - --walker._depth; - cur = cur->parent; - } - - if (cur != _root) - cur = cur->next_sibling; - } - } - while (cur && cur != _root); - } - - assert(walker._depth == -1); - - xml_node arg_end(_root); - return walker.end(arg_end); - } - - PUGI__FN size_t xml_node::hash_value() const - { - return static_cast(reinterpret_cast(_root) / sizeof(xml_node_struct)); - } - - PUGI__FN xml_node_struct* xml_node::internal_object() const - { - return _root; - } - - PUGI__FN void xml_node::print(xml_writer& writer, const char_t* indent, unsigned int flags, xml_encoding encoding, unsigned int depth) const - { - if (!_root) return; - - impl::xml_buffered_writer buffered_writer(writer, encoding); - - impl::node_output(buffered_writer, _root, indent, flags, depth); - - buffered_writer.flush(); - } - -#ifndef PUGIXML_NO_STL - PUGI__FN void xml_node::print(std::basic_ostream >& stream, const char_t* indent, unsigned int flags, xml_encoding encoding, unsigned int depth) const - { - xml_writer_stream writer(stream); - - print(writer, indent, flags, encoding, depth); - } - - PUGI__FN void xml_node::print(std::basic_ostream >& stream, const char_t* indent, unsigned int flags, unsigned int depth) const - { - xml_writer_stream writer(stream); - - print(writer, indent, flags, encoding_wchar, depth); - } -#endif - - PUGI__FN ptrdiff_t xml_node::offset_debug() const - { - if (!_root) return -1; - - impl::xml_document_struct& doc = impl::get_document(_root); - - // we can determine the offset reliably only if there is exactly once parse buffer - if (!doc.buffer || doc.extra_buffers) return -1; - - switch (type()) - { - case node_document: - return 0; - - case node_element: - case node_declaration: - case node_pi: - return _root->name && (_root->header & impl::xml_memory_page_name_allocated_or_shared_mask) == 0 ? _root->name - doc.buffer : -1; - - case node_pcdata: - case node_cdata: - case node_comment: - case node_doctype: - return _root->value && (_root->header & impl::xml_memory_page_value_allocated_or_shared_mask) == 0 ? _root->value - doc.buffer : -1; - - default: - assert(false && "Invalid node type"); // unreachable - return -1; - } - } - -#ifdef __BORLANDC__ - PUGI__FN bool operator&&(const xml_node& lhs, bool rhs) - { - return (bool)lhs && rhs; - } - - PUGI__FN bool operator||(const xml_node& lhs, bool rhs) - { - return (bool)lhs || rhs; - } -#endif - - PUGI__FN xml_text::xml_text(xml_node_struct* root): _root(root) - { - } - - PUGI__FN xml_node_struct* xml_text::_data() const - { - if (!_root || impl::is_text_node(_root)) return _root; - - // element nodes can have value if parse_embed_pcdata was used - if (PUGI__NODETYPE(_root) == node_element && _root->value) - return _root; - - for (xml_node_struct* node = _root->first_child; node; node = node->next_sibling) - if (impl::is_text_node(node)) - return node; - - return 0; - } - - PUGI__FN xml_node_struct* xml_text::_data_new() - { - xml_node_struct* d = _data(); - if (d) return d; - - return xml_node(_root).append_child(node_pcdata).internal_object(); - } - - PUGI__FN xml_text::xml_text(): _root(0) - { - } - - PUGI__FN static void unspecified_bool_xml_text(xml_text***) - { - } - - PUGI__FN xml_text::operator xml_text::unspecified_bool_type() const - { - return _data() ? unspecified_bool_xml_text : 0; - } - - PUGI__FN bool xml_text::operator!() const - { - return !_data(); - } - - PUGI__FN bool xml_text::empty() const - { - return _data() == 0; - } - - PUGI__FN const char_t* xml_text::get() const - { - xml_node_struct* d = _data(); - - return (d && d->value) ? d->value + 0 : PUGIXML_TEXT(""); - } - - PUGI__FN const char_t* xml_text::as_string(const char_t* def) const - { - xml_node_struct* d = _data(); - - return (d && d->value) ? d->value + 0 : def; - } - - PUGI__FN int xml_text::as_int(int def) const - { - xml_node_struct* d = _data(); - - return (d && d->value) ? impl::get_value_int(d->value) : def; - } - - PUGI__FN unsigned int xml_text::as_uint(unsigned int def) const - { - xml_node_struct* d = _data(); - - return (d && d->value) ? impl::get_value_uint(d->value) : def; - } - - PUGI__FN double xml_text::as_double(double def) const - { - xml_node_struct* d = _data(); - - return (d && d->value) ? impl::get_value_double(d->value) : def; - } - - PUGI__FN float xml_text::as_float(float def) const - { - xml_node_struct* d = _data(); - - return (d && d->value) ? impl::get_value_float(d->value) : def; - } - - PUGI__FN bool xml_text::as_bool(bool def) const - { - xml_node_struct* d = _data(); - - return (d && d->value) ? impl::get_value_bool(d->value) : def; - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN long long xml_text::as_llong(long long def) const - { - xml_node_struct* d = _data(); - - return (d && d->value) ? impl::get_value_llong(d->value) : def; - } - - PUGI__FN unsigned long long xml_text::as_ullong(unsigned long long def) const - { - xml_node_struct* d = _data(); - - return (d && d->value) ? impl::get_value_ullong(d->value) : def; - } -#endif - - PUGI__FN bool xml_text::set(const char_t* rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::strcpy_insitu(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, impl::strlength(rhs)) : false; - } - - PUGI__FN bool xml_text::set(int rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_integer(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, rhs < 0) : false; - } - - PUGI__FN bool xml_text::set(unsigned int rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_integer(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, false) : false; - } - - PUGI__FN bool xml_text::set(long rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_integer(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, rhs < 0) : false; - } - - PUGI__FN bool xml_text::set(unsigned long rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_integer(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, false) : false; - } - - PUGI__FN bool xml_text::set(float rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, default_float_precision) : false; - } - - PUGI__FN bool xml_text::set(float rhs, int precision) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, precision) : false; - } - - PUGI__FN bool xml_text::set(double rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, default_double_precision) : false; - } - - PUGI__FN bool xml_text::set(double rhs, int precision) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, precision) : false; - } - - PUGI__FN bool xml_text::set(bool rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_bool(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN bool xml_text::set(long long rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_integer(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, rhs < 0) : false; - } - - PUGI__FN bool xml_text::set(unsigned long long rhs) - { - xml_node_struct* dn = _data_new(); - - return dn ? impl::set_value_integer(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, false) : false; - } -#endif - - PUGI__FN xml_text& xml_text::operator=(const char_t* rhs) - { - set(rhs); - return *this; - } - - PUGI__FN xml_text& xml_text::operator=(int rhs) - { - set(rhs); - return *this; - } - - PUGI__FN xml_text& xml_text::operator=(unsigned int rhs) - { - set(rhs); - return *this; - } - - PUGI__FN xml_text& xml_text::operator=(long rhs) - { - set(rhs); - return *this; - } - - PUGI__FN xml_text& xml_text::operator=(unsigned long rhs) - { - set(rhs); - return *this; - } - - PUGI__FN xml_text& xml_text::operator=(double rhs) - { - set(rhs); - return *this; - } - - PUGI__FN xml_text& xml_text::operator=(float rhs) - { - set(rhs); - return *this; - } - - PUGI__FN xml_text& xml_text::operator=(bool rhs) - { - set(rhs); - return *this; - } - -#ifdef PUGIXML_HAS_LONG_LONG - PUGI__FN xml_text& xml_text::operator=(long long rhs) - { - set(rhs); - return *this; - } - - PUGI__FN xml_text& xml_text::operator=(unsigned long long rhs) - { - set(rhs); - return *this; - } -#endif - - PUGI__FN xml_node xml_text::data() const - { - return xml_node(_data()); - } - -#ifdef __BORLANDC__ - PUGI__FN bool operator&&(const xml_text& lhs, bool rhs) - { - return (bool)lhs && rhs; - } - - PUGI__FN bool operator||(const xml_text& lhs, bool rhs) - { - return (bool)lhs || rhs; - } -#endif - - PUGI__FN xml_node_iterator::xml_node_iterator() - { - } - - PUGI__FN xml_node_iterator::xml_node_iterator(const xml_node& node): _wrap(node), _parent(node.parent()) - { - } - - PUGI__FN xml_node_iterator::xml_node_iterator(xml_node_struct* ref, xml_node_struct* parent): _wrap(ref), _parent(parent) - { - } - - PUGI__FN bool xml_node_iterator::operator==(const xml_node_iterator& rhs) const - { - return _wrap._root == rhs._wrap._root && _parent._root == rhs._parent._root; - } - - PUGI__FN bool xml_node_iterator::operator!=(const xml_node_iterator& rhs) const - { - return _wrap._root != rhs._wrap._root || _parent._root != rhs._parent._root; - } - - PUGI__FN xml_node& xml_node_iterator::operator*() const - { - assert(_wrap._root); - return _wrap; - } - - PUGI__FN xml_node* xml_node_iterator::operator->() const - { - assert(_wrap._root); - return const_cast(&_wrap); // BCC5 workaround - } - - PUGI__FN const xml_node_iterator& xml_node_iterator::operator++() - { - assert(_wrap._root); - _wrap._root = _wrap._root->next_sibling; - return *this; - } - - PUGI__FN xml_node_iterator xml_node_iterator::operator++(int) - { - xml_node_iterator temp = *this; - ++*this; - return temp; - } - - PUGI__FN const xml_node_iterator& xml_node_iterator::operator--() - { - _wrap = _wrap._root ? _wrap.previous_sibling() : _parent.last_child(); - return *this; - } - - PUGI__FN xml_node_iterator xml_node_iterator::operator--(int) - { - xml_node_iterator temp = *this; - --*this; - return temp; - } - - PUGI__FN xml_attribute_iterator::xml_attribute_iterator() - { - } - - PUGI__FN xml_attribute_iterator::xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent): _wrap(attr), _parent(parent) - { - } - - PUGI__FN xml_attribute_iterator::xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent): _wrap(ref), _parent(parent) - { - } - - PUGI__FN bool xml_attribute_iterator::operator==(const xml_attribute_iterator& rhs) const - { - return _wrap._attr == rhs._wrap._attr && _parent._root == rhs._parent._root; - } - - PUGI__FN bool xml_attribute_iterator::operator!=(const xml_attribute_iterator& rhs) const - { - return _wrap._attr != rhs._wrap._attr || _parent._root != rhs._parent._root; - } - - PUGI__FN xml_attribute& xml_attribute_iterator::operator*() const - { - assert(_wrap._attr); - return _wrap; - } - - PUGI__FN xml_attribute* xml_attribute_iterator::operator->() const - { - assert(_wrap._attr); - return const_cast(&_wrap); // BCC5 workaround - } - - PUGI__FN const xml_attribute_iterator& xml_attribute_iterator::operator++() - { - assert(_wrap._attr); - _wrap._attr = _wrap._attr->next_attribute; - return *this; - } - - PUGI__FN xml_attribute_iterator xml_attribute_iterator::operator++(int) - { - xml_attribute_iterator temp = *this; - ++*this; - return temp; - } - - PUGI__FN const xml_attribute_iterator& xml_attribute_iterator::operator--() - { - _wrap = _wrap._attr ? _wrap.previous_attribute() : _parent.last_attribute(); - return *this; - } - - PUGI__FN xml_attribute_iterator xml_attribute_iterator::operator--(int) - { - xml_attribute_iterator temp = *this; - --*this; - return temp; - } - - PUGI__FN xml_named_node_iterator::xml_named_node_iterator(): _name(0) - { - } - - PUGI__FN xml_named_node_iterator::xml_named_node_iterator(const xml_node& node, const char_t* name): _wrap(node), _parent(node.parent()), _name(name) - { - } - - PUGI__FN xml_named_node_iterator::xml_named_node_iterator(xml_node_struct* ref, xml_node_struct* parent, const char_t* name): _wrap(ref), _parent(parent), _name(name) - { - } - - PUGI__FN bool xml_named_node_iterator::operator==(const xml_named_node_iterator& rhs) const - { - return _wrap._root == rhs._wrap._root && _parent._root == rhs._parent._root; - } - - PUGI__FN bool xml_named_node_iterator::operator!=(const xml_named_node_iterator& rhs) const - { - return _wrap._root != rhs._wrap._root || _parent._root != rhs._parent._root; - } - - PUGI__FN xml_node& xml_named_node_iterator::operator*() const - { - assert(_wrap._root); - return _wrap; - } - - PUGI__FN xml_node* xml_named_node_iterator::operator->() const - { - assert(_wrap._root); - return const_cast(&_wrap); // BCC5 workaround - } - - PUGI__FN const xml_named_node_iterator& xml_named_node_iterator::operator++() - { - assert(_wrap._root); - _wrap = _wrap.next_sibling(_name); - return *this; - } - - PUGI__FN xml_named_node_iterator xml_named_node_iterator::operator++(int) - { - xml_named_node_iterator temp = *this; - ++*this; - return temp; - } - - PUGI__FN const xml_named_node_iterator& xml_named_node_iterator::operator--() - { - if (_wrap._root) - _wrap = _wrap.previous_sibling(_name); - else - { - _wrap = _parent.last_child(); - - if (!impl::strequal(_wrap.name(), _name)) - _wrap = _wrap.previous_sibling(_name); - } - - return *this; - } - - PUGI__FN xml_named_node_iterator xml_named_node_iterator::operator--(int) - { - xml_named_node_iterator temp = *this; - --*this; - return temp; - } - - PUGI__FN xml_parse_result::xml_parse_result(): status(status_internal_error), offset(0), encoding(encoding_auto) - { - } - - PUGI__FN xml_parse_result::operator bool() const - { - return status == status_ok; - } - - PUGI__FN const char* xml_parse_result::description() const - { - switch (status) - { - case status_ok: return "No error"; - - case status_file_not_found: return "File was not found"; - case status_io_error: return "Error reading from file/stream"; - case status_out_of_memory: return "Could not allocate memory"; - case status_internal_error: return "Internal error occurred"; - - case status_unrecognized_tag: return "Could not determine tag type"; - - case status_bad_pi: return "Error parsing document declaration/processing instruction"; - case status_bad_comment: return "Error parsing comment"; - case status_bad_cdata: return "Error parsing CDATA section"; - case status_bad_doctype: return "Error parsing document type declaration"; - case status_bad_pcdata: return "Error parsing PCDATA section"; - case status_bad_start_element: return "Error parsing start element tag"; - case status_bad_attribute: return "Error parsing element attribute"; - case status_bad_end_element: return "Error parsing end element tag"; - case status_end_element_mismatch: return "Start-end tags mismatch"; - - case status_append_invalid_root: return "Unable to append nodes: root is not an element or document"; - - case status_no_document_element: return "No document element found"; - - default: return "Unknown error"; - } - } - - PUGI__FN xml_document::xml_document(): _buffer(0) - { - _create(); - } - - PUGI__FN xml_document::~xml_document() - { - _destroy(); - } - -#ifdef PUGIXML_HAS_MOVE - PUGI__FN xml_document::xml_document(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT: _buffer(0) - { - _create(); - _move(rhs); - } - - PUGI__FN xml_document& xml_document::operator=(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT - { - if (this == &rhs) return *this; - - _destroy(); - _create(); - _move(rhs); - - return *this; - } -#endif - - PUGI__FN void xml_document::reset() - { - _destroy(); - _create(); - } - - PUGI__FN void xml_document::reset(const xml_document& proto) - { - reset(); - - impl::node_copy_tree(_root, proto._root); - } - - PUGI__FN void xml_document::_create() - { - assert(!_root); - - #ifdef PUGIXML_COMPACT - // space for page marker for the first page (uint32_t), rounded up to pointer size; assumes pointers are at least 32-bit - const size_t page_offset = sizeof(void*); - #else - const size_t page_offset = 0; - #endif - - // initialize sentinel page - PUGI__STATIC_ASSERT(sizeof(impl::xml_memory_page) + sizeof(impl::xml_document_struct) + page_offset <= sizeof(_memory)); - - // prepare page structure - impl::xml_memory_page* page = impl::xml_memory_page::construct(_memory); - assert(page); - - page->busy_size = impl::xml_memory_page_size; - - // setup first page marker - #ifdef PUGIXML_COMPACT - // round-trip through void* to avoid 'cast increases required alignment of target type' warning - page->compact_page_marker = reinterpret_cast(static_cast(reinterpret_cast(page) + sizeof(impl::xml_memory_page))); - *page->compact_page_marker = sizeof(impl::xml_memory_page); - #endif - - // allocate new root - _root = new (reinterpret_cast(page) + sizeof(impl::xml_memory_page) + page_offset) impl::xml_document_struct(page); - _root->prev_sibling_c = _root; - - // setup sentinel page - page->allocator = static_cast(_root); - - // setup hash table pointer in allocator - #ifdef PUGIXML_COMPACT - page->allocator->_hash = &static_cast(_root)->hash; - #endif - - // verify the document allocation - assert(reinterpret_cast(_root) + sizeof(impl::xml_document_struct) <= _memory + sizeof(_memory)); - } - - PUGI__FN void xml_document::_destroy() - { - assert(_root); - - // destroy static storage - if (_buffer) - { - impl::xml_memory::deallocate(_buffer); - _buffer = 0; - } - - // destroy extra buffers (note: no need to destroy linked list nodes, they're allocated using document allocator) - for (impl::xml_extra_buffer* extra = static_cast(_root)->extra_buffers; extra; extra = extra->next) - { - if (extra->buffer) impl::xml_memory::deallocate(extra->buffer); - } - - // destroy dynamic storage, leave sentinel page (it's in static memory) - impl::xml_memory_page* root_page = PUGI__GETPAGE(_root); - assert(root_page && !root_page->prev); - assert(reinterpret_cast(root_page) >= _memory && reinterpret_cast(root_page) < _memory + sizeof(_memory)); - - for (impl::xml_memory_page* page = root_page->next; page; ) - { - impl::xml_memory_page* next = page->next; - - impl::xml_allocator::deallocate_page(page); - - page = next; - } - - #ifdef PUGIXML_COMPACT - // destroy hash table - static_cast(_root)->hash.clear(); - #endif - - _root = 0; - } - -#ifdef PUGIXML_HAS_MOVE - PUGI__FN void xml_document::_move(xml_document& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT - { - impl::xml_document_struct* doc = static_cast(_root); - impl::xml_document_struct* other = static_cast(rhs._root); - - // save first child pointer for later; this needs hash access - xml_node_struct* other_first_child = other->first_child; - - #ifdef PUGIXML_COMPACT - // reserve space for the hash table up front; this is the only operation that can fail - // if it does, we have no choice but to throw (if we have exceptions) - if (other_first_child) - { - size_t other_children = 0; - for (xml_node_struct* node = other_first_child; node; node = node->next_sibling) - other_children++; - - // in compact mode, each pointer assignment could result in a hash table request - // during move, we have to relocate document first_child and parents of all children - // normally there's just one child and its parent has a pointerless encoding but - // we assume the worst here - if (!other->_hash->reserve(other_children + 1)) - { - #ifdef PUGIXML_NO_EXCEPTIONS - return; - #else - throw std::bad_alloc(); - #endif - } - } - #endif - - // move allocation state - doc->_root = other->_root; - doc->_busy_size = other->_busy_size; - - // move buffer state - doc->buffer = other->buffer; - doc->extra_buffers = other->extra_buffers; - _buffer = rhs._buffer; - - #ifdef PUGIXML_COMPACT - // move compact hash; note that the hash table can have pointers to other but they will be "inactive", similarly to nodes removed with remove_child - doc->hash = other->hash; - doc->_hash = &doc->hash; - - // make sure we don't access other hash up until the end when we reinitialize other document - other->_hash = 0; - #endif - - // move page structure - impl::xml_memory_page* doc_page = PUGI__GETPAGE(doc); - assert(doc_page && !doc_page->prev && !doc_page->next); - - impl::xml_memory_page* other_page = PUGI__GETPAGE(other); - assert(other_page && !other_page->prev); - - // relink pages since root page is embedded into xml_document - if (impl::xml_memory_page* page = other_page->next) - { - assert(page->prev == other_page); - - page->prev = doc_page; - - doc_page->next = page; - other_page->next = 0; - } - - // make sure pages point to the correct document state - for (impl::xml_memory_page* page = doc_page->next; page; page = page->next) - { - assert(page->allocator == other); - - page->allocator = doc; - - #ifdef PUGIXML_COMPACT - // this automatically migrates most children between documents and prevents ->parent assignment from allocating - if (page->compact_shared_parent == other) - page->compact_shared_parent = doc; - #endif - } - - // move tree structure - assert(!doc->first_child); - - doc->first_child = other_first_child; - - for (xml_node_struct* node = other_first_child; node; node = node->next_sibling) - { - #ifdef PUGIXML_COMPACT - // most children will have migrated when we reassigned compact_shared_parent - assert(node->parent == other || node->parent == doc); - - node->parent = doc; - #else - assert(node->parent == other); - node->parent = doc; - #endif - } - - // reset other document - new (other) impl::xml_document_struct(PUGI__GETPAGE(other)); - rhs._buffer = 0; - } -#endif - -#ifndef PUGIXML_NO_STL - PUGI__FN xml_parse_result xml_document::load(std::basic_istream >& stream, unsigned int options, xml_encoding encoding) - { - reset(); - - return impl::load_stream_impl(static_cast(_root), stream, options, encoding, &_buffer); - } - - PUGI__FN xml_parse_result xml_document::load(std::basic_istream >& stream, unsigned int options) - { - reset(); - - return impl::load_stream_impl(static_cast(_root), stream, options, encoding_wchar, &_buffer); - } -#endif - - PUGI__FN xml_parse_result xml_document::load_string(const char_t* contents, unsigned int options) - { - // Force native encoding (skip autodetection) - #ifdef PUGIXML_WCHAR_MODE - xml_encoding encoding = encoding_wchar; - #else - xml_encoding encoding = encoding_utf8; - #endif - - return load_buffer(contents, impl::strlength(contents) * sizeof(char_t), options, encoding); - } - - PUGI__FN xml_parse_result xml_document::load(const char_t* contents, unsigned int options) - { - return load_string(contents, options); - } - - PUGI__FN xml_parse_result xml_document::load_file(const char* path_, unsigned int options, xml_encoding encoding) - { - reset(); - - using impl::auto_deleter; // MSVC7 workaround - auto_deleter file(fopen(path_, "rb"), impl::close_file); - - return impl::load_file_impl(static_cast(_root), file.data, options, encoding, &_buffer); - } - - PUGI__FN xml_parse_result xml_document::load_file(const wchar_t* path_, unsigned int options, xml_encoding encoding) - { - reset(); - - using impl::auto_deleter; // MSVC7 workaround - auto_deleter file(impl::open_file_wide(path_, L"rb"), impl::close_file); - - return impl::load_file_impl(static_cast(_root), file.data, options, encoding, &_buffer); - } - - PUGI__FN xml_parse_result xml_document::load_buffer(const void* contents, size_t size, unsigned int options, xml_encoding encoding) - { - reset(); - - return impl::load_buffer_impl(static_cast(_root), _root, const_cast(contents), size, options, encoding, false, false, &_buffer); - } - - PUGI__FN xml_parse_result xml_document::load_buffer_inplace(void* contents, size_t size, unsigned int options, xml_encoding encoding) - { - reset(); - - return impl::load_buffer_impl(static_cast(_root), _root, contents, size, options, encoding, true, false, &_buffer); - } - - PUGI__FN xml_parse_result xml_document::load_buffer_inplace_own(void* contents, size_t size, unsigned int options, xml_encoding encoding) - { - reset(); - - return impl::load_buffer_impl(static_cast(_root), _root, contents, size, options, encoding, true, true, &_buffer); - } - - PUGI__FN void xml_document::save(xml_writer& writer, const char_t* indent, unsigned int flags, xml_encoding encoding) const - { - impl::xml_buffered_writer buffered_writer(writer, encoding); - - if ((flags & format_write_bom) && encoding != encoding_latin1) - { - // BOM always represents the codepoint U+FEFF, so just write it in native encoding - #ifdef PUGIXML_WCHAR_MODE - unsigned int bom = 0xfeff; - buffered_writer.write(static_cast(bom)); - #else - buffered_writer.write('\xef', '\xbb', '\xbf'); - #endif - } - - if (!(flags & format_no_declaration) && !impl::has_declaration(_root)) - { - buffered_writer.write_string(PUGIXML_TEXT("'); - if (!(flags & format_raw)) buffered_writer.write('\n'); - } - - impl::node_output(buffered_writer, _root, indent, flags, 0); - - buffered_writer.flush(); - } - -#ifndef PUGIXML_NO_STL - PUGI__FN void xml_document::save(std::basic_ostream >& stream, const char_t* indent, unsigned int flags, xml_encoding encoding) const - { - xml_writer_stream writer(stream); - - save(writer, indent, flags, encoding); - } - - PUGI__FN void xml_document::save(std::basic_ostream >& stream, const char_t* indent, unsigned int flags) const - { - xml_writer_stream writer(stream); - - save(writer, indent, flags, encoding_wchar); - } -#endif - - PUGI__FN bool xml_document::save_file(const char* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const - { - using impl::auto_deleter; // MSVC7 workaround - auto_deleter file(fopen(path_, (flags & format_save_file_text) ? "w" : "wb"), impl::close_file); - - return impl::save_file_impl(*this, file.data, indent, flags, encoding); - } - - PUGI__FN bool xml_document::save_file(const wchar_t* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const - { - using impl::auto_deleter; // MSVC7 workaround - auto_deleter file(impl::open_file_wide(path_, (flags & format_save_file_text) ? L"w" : L"wb"), impl::close_file); - - return impl::save_file_impl(*this, file.data, indent, flags, encoding); - } - - PUGI__FN xml_node xml_document::document_element() const - { - assert(_root); - - for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling) - if (PUGI__NODETYPE(i) == node_element) - return xml_node(i); - - return xml_node(); - } - -#ifndef PUGIXML_NO_STL - PUGI__FN std::string PUGIXML_FUNCTION as_utf8(const wchar_t* str) - { - assert(str); - - return impl::as_utf8_impl(str, impl::strlength_wide(str)); - } - - PUGI__FN std::string PUGIXML_FUNCTION as_utf8(const std::basic_string& str) - { - return impl::as_utf8_impl(str.c_str(), str.size()); - } - - PUGI__FN std::basic_string PUGIXML_FUNCTION as_wide(const char* str) - { - assert(str); - - return impl::as_wide_impl(str, strlen(str)); - } - - PUGI__FN std::basic_string PUGIXML_FUNCTION as_wide(const std::string& str) - { - return impl::as_wide_impl(str.c_str(), str.size()); - } -#endif - - PUGI__FN void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate) - { - impl::xml_memory::allocate = allocate; - impl::xml_memory::deallocate = deallocate; - } - - PUGI__FN allocation_function PUGIXML_FUNCTION get_memory_allocation_function() - { - return impl::xml_memory::allocate; - } - - PUGI__FN deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function() - { - return impl::xml_memory::deallocate; - } -} - -#if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC)) -namespace std -{ - // Workarounds for (non-standard) iterator category detection for older versions (MSVC7/IC8 and earlier) - PUGI__FN std::bidirectional_iterator_tag _Iter_cat(const pugi::xml_node_iterator&) - { - return std::bidirectional_iterator_tag(); - } - - PUGI__FN std::bidirectional_iterator_tag _Iter_cat(const pugi::xml_attribute_iterator&) - { - return std::bidirectional_iterator_tag(); - } - - PUGI__FN std::bidirectional_iterator_tag _Iter_cat(const pugi::xml_named_node_iterator&) - { - return std::bidirectional_iterator_tag(); - } -} -#endif - -#if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC) -namespace std -{ - // Workarounds for (non-standard) iterator category detection - PUGI__FN std::bidirectional_iterator_tag __iterator_category(const pugi::xml_node_iterator&) - { - return std::bidirectional_iterator_tag(); - } - - PUGI__FN std::bidirectional_iterator_tag __iterator_category(const pugi::xml_attribute_iterator&) - { - return std::bidirectional_iterator_tag(); - } - - PUGI__FN std::bidirectional_iterator_tag __iterator_category(const pugi::xml_named_node_iterator&) - { - return std::bidirectional_iterator_tag(); - } -} -#endif - -#ifndef PUGIXML_NO_XPATH -// STL replacements -PUGI__NS_BEGIN - struct equal_to - { - template bool operator()(const T& lhs, const T& rhs) const - { - return lhs == rhs; - } - }; - - struct not_equal_to - { - template bool operator()(const T& lhs, const T& rhs) const - { - return lhs != rhs; - } - }; - - struct less - { - template bool operator()(const T& lhs, const T& rhs) const - { - return lhs < rhs; - } - }; - - struct less_equal - { - template bool operator()(const T& lhs, const T& rhs) const - { - return lhs <= rhs; - } - }; - - template inline void swap(T& lhs, T& rhs) - { - T temp = lhs; - lhs = rhs; - rhs = temp; - } - - template PUGI__FN I min_element(I begin, I end, const Pred& pred) - { - I result = begin; - - for (I it = begin + 1; it != end; ++it) - if (pred(*it, *result)) - result = it; - - return result; - } - - template PUGI__FN void reverse(I begin, I end) - { - while (end - begin > 1) - swap(*begin++, *--end); - } - - template PUGI__FN I unique(I begin, I end) - { - // fast skip head - while (end - begin > 1 && *begin != *(begin + 1)) - begin++; - - if (begin == end) - return begin; - - // last written element - I write = begin++; - - // merge unique elements - while (begin != end) - { - if (*begin != *write) - *++write = *begin++; - else - begin++; - } - - // past-the-end (write points to live element) - return write + 1; - } - - template PUGI__FN void insertion_sort(T* begin, T* end, const Pred& pred) - { - if (begin == end) - return; - - for (T* it = begin + 1; it != end; ++it) - { - T val = *it; - T* hole = it; - - // move hole backwards - while (hole > begin && pred(val, *(hole - 1))) - { - *hole = *(hole - 1); - hole--; - } - - // fill hole with element - *hole = val; - } - } - - template inline I median3(I first, I middle, I last, const Pred& pred) - { - if (pred(*middle, *first)) - swap(middle, first); - if (pred(*last, *middle)) - swap(last, middle); - if (pred(*middle, *first)) - swap(middle, first); - - return middle; - } - - template PUGI__FN void partition3(T* begin, T* end, T pivot, const Pred& pred, T** out_eqbeg, T** out_eqend) - { - // invariant: array is split into 4 groups: = < ? > (each variable denotes the boundary between the groups) - T* eq = begin; - T* lt = begin; - T* gt = end; - - while (lt < gt) - { - if (pred(*lt, pivot)) - lt++; - else if (*lt == pivot) - swap(*eq++, *lt++); - else - swap(*lt, *--gt); - } - - // we now have just 4 groups: = < >; move equal elements to the middle - T* eqbeg = gt; - - for (T* it = begin; it != eq; ++it) - swap(*it, *--eqbeg); - - *out_eqbeg = eqbeg; - *out_eqend = gt; - } - - template PUGI__FN void sort(I begin, I end, const Pred& pred) - { - // sort large chunks - while (end - begin > 16) - { - // find median element - I middle = begin + (end - begin) / 2; - I median = median3(begin, middle, end - 1, pred); - - // partition in three chunks (< = >) - I eqbeg, eqend; - partition3(begin, end, *median, pred, &eqbeg, &eqend); - - // loop on larger half - if (eqbeg - begin > end - eqend) - { - sort(eqend, end, pred); - end = eqbeg; - } - else - { - sort(begin, eqbeg, pred); - begin = eqend; - } - } - - // insertion sort small chunk - insertion_sort(begin, end, pred); - } - - PUGI__FN bool hash_insert(const void** table, size_t size, const void* key) - { - assert(key); - - unsigned int h = static_cast(reinterpret_cast(key)); - - // MurmurHash3 32-bit finalizer - h ^= h >> 16; - h *= 0x85ebca6bu; - h ^= h >> 13; - h *= 0xc2b2ae35u; - h ^= h >> 16; - - size_t hashmod = size - 1; - size_t bucket = h & hashmod; - - for (size_t probe = 0; probe <= hashmod; ++probe) - { - if (table[bucket] == 0) - { - table[bucket] = key; - return true; - } - - if (table[bucket] == key) - return false; - - // hash collision, quadratic probing - bucket = (bucket + probe + 1) & hashmod; - } - - assert(false && "Hash table is full"); // unreachable - return false; - } -PUGI__NS_END - -// Allocator used for AST and evaluation stacks -PUGI__NS_BEGIN - static const size_t xpath_memory_page_size = - #ifdef PUGIXML_MEMORY_XPATH_PAGE_SIZE - PUGIXML_MEMORY_XPATH_PAGE_SIZE - #else - 4096 - #endif - ; - - static const uintptr_t xpath_memory_block_alignment = sizeof(double) > sizeof(void*) ? sizeof(double) : sizeof(void*); - - struct xpath_memory_block - { - xpath_memory_block* next; - size_t capacity; - - union - { - char data[xpath_memory_page_size]; - double alignment; - }; - }; - - struct xpath_allocator - { - xpath_memory_block* _root; - size_t _root_size; - bool* _error; - - xpath_allocator(xpath_memory_block* root, bool* error = 0): _root(root), _root_size(0), _error(error) - { - } - - void* allocate(size_t size) - { - // round size up to block alignment boundary - size = (size + xpath_memory_block_alignment - 1) & ~(xpath_memory_block_alignment - 1); - - if (_root_size + size <= _root->capacity) - { - void* buf = &_root->data[0] + _root_size; - _root_size += size; - return buf; - } - else - { - // make sure we have at least 1/4th of the page free after allocation to satisfy subsequent allocation requests - size_t block_capacity_base = sizeof(_root->data); - size_t block_capacity_req = size + block_capacity_base / 4; - size_t block_capacity = (block_capacity_base > block_capacity_req) ? block_capacity_base : block_capacity_req; - - size_t block_size = block_capacity + offsetof(xpath_memory_block, data); - - xpath_memory_block* block = static_cast(xml_memory::allocate(block_size)); - if (!block) - { - if (_error) *_error = true; - return 0; - } - - block->next = _root; - block->capacity = block_capacity; - - _root = block; - _root_size = size; - - return block->data; - } - } - - void* reallocate(void* ptr, size_t old_size, size_t new_size) - { - // round size up to block alignment boundary - old_size = (old_size + xpath_memory_block_alignment - 1) & ~(xpath_memory_block_alignment - 1); - new_size = (new_size + xpath_memory_block_alignment - 1) & ~(xpath_memory_block_alignment - 1); - - // we can only reallocate the last object - assert(ptr == 0 || static_cast(ptr) + old_size == &_root->data[0] + _root_size); - - // try to reallocate the object inplace - if (ptr && _root_size - old_size + new_size <= _root->capacity) - { - _root_size = _root_size - old_size + new_size; - return ptr; - } - - // allocate a new block - void* result = allocate(new_size); - if (!result) return 0; - - // we have a new block - if (ptr) - { - // copy old data (we only support growing) - assert(new_size >= old_size); - memcpy(result, ptr, old_size); - - // free the previous page if it had no other objects - assert(_root->data == result); - assert(_root->next); - - if (_root->next->data == ptr) - { - // deallocate the whole page, unless it was the first one - xpath_memory_block* next = _root->next->next; - - if (next) - { - xml_memory::deallocate(_root->next); - _root->next = next; - } - } - } - - return result; - } - - void revert(const xpath_allocator& state) - { - // free all new pages - xpath_memory_block* cur = _root; - - while (cur != state._root) - { - xpath_memory_block* next = cur->next; - - xml_memory::deallocate(cur); - - cur = next; - } - - // restore state - _root = state._root; - _root_size = state._root_size; - } - - void release() - { - xpath_memory_block* cur = _root; - assert(cur); - - while (cur->next) - { - xpath_memory_block* next = cur->next; - - xml_memory::deallocate(cur); - - cur = next; - } - } - }; - - struct xpath_allocator_capture - { - xpath_allocator_capture(xpath_allocator* alloc): _target(alloc), _state(*alloc) - { - } - - ~xpath_allocator_capture() - { - _target->revert(_state); - } - - xpath_allocator* _target; - xpath_allocator _state; - }; - - struct xpath_stack - { - xpath_allocator* result; - xpath_allocator* temp; - }; - - struct xpath_stack_data - { - xpath_memory_block blocks[2]; - xpath_allocator result; - xpath_allocator temp; - xpath_stack stack; - bool oom; - - xpath_stack_data(): result(blocks + 0, &oom), temp(blocks + 1, &oom), oom(false) - { - blocks[0].next = blocks[1].next = 0; - blocks[0].capacity = blocks[1].capacity = sizeof(blocks[0].data); - - stack.result = &result; - stack.temp = &temp; - } - - ~xpath_stack_data() - { - result.release(); - temp.release(); - } - }; -PUGI__NS_END - -// String class -PUGI__NS_BEGIN - class xpath_string - { - const char_t* _buffer; - bool _uses_heap; - size_t _length_heap; - - static char_t* duplicate_string(const char_t* string, size_t length, xpath_allocator* alloc) - { - char_t* result = static_cast(alloc->allocate((length + 1) * sizeof(char_t))); - if (!result) return 0; - - memcpy(result, string, length * sizeof(char_t)); - result[length] = 0; - - return result; - } - - xpath_string(const char_t* buffer, bool uses_heap_, size_t length_heap): _buffer(buffer), _uses_heap(uses_heap_), _length_heap(length_heap) - { - } - - public: - static xpath_string from_const(const char_t* str) - { - return xpath_string(str, false, 0); - } - - static xpath_string from_heap_preallocated(const char_t* begin, const char_t* end) - { - assert(begin <= end && *end == 0); - - return xpath_string(begin, true, static_cast(end - begin)); - } - - static xpath_string from_heap(const char_t* begin, const char_t* end, xpath_allocator* alloc) - { - assert(begin <= end); - - if (begin == end) - return xpath_string(); - - size_t length = static_cast(end - begin); - const char_t* data = duplicate_string(begin, length, alloc); - - return data ? xpath_string(data, true, length) : xpath_string(); - } - - xpath_string(): _buffer(PUGIXML_TEXT("")), _uses_heap(false), _length_heap(0) - { - } - - void append(const xpath_string& o, xpath_allocator* alloc) - { - // skip empty sources - if (!*o._buffer) return; - - // fast append for constant empty target and constant source - if (!*_buffer && !_uses_heap && !o._uses_heap) - { - _buffer = o._buffer; - } - else - { - // need to make heap copy - size_t target_length = length(); - size_t source_length = o.length(); - size_t result_length = target_length + source_length; - - // allocate new buffer - char_t* result = static_cast(alloc->reallocate(_uses_heap ? const_cast(_buffer) : 0, (target_length + 1) * sizeof(char_t), (result_length + 1) * sizeof(char_t))); - if (!result) return; - - // append first string to the new buffer in case there was no reallocation - if (!_uses_heap) memcpy(result, _buffer, target_length * sizeof(char_t)); - - // append second string to the new buffer - memcpy(result + target_length, o._buffer, source_length * sizeof(char_t)); - result[result_length] = 0; - - // finalize - _buffer = result; - _uses_heap = true; - _length_heap = result_length; - } - } - - const char_t* c_str() const - { - return _buffer; - } - - size_t length() const - { - return _uses_heap ? _length_heap : strlength(_buffer); - } - - char_t* data(xpath_allocator* alloc) - { - // make private heap copy - if (!_uses_heap) - { - size_t length_ = strlength(_buffer); - const char_t* data_ = duplicate_string(_buffer, length_, alloc); - - if (!data_) return 0; - - _buffer = data_; - _uses_heap = true; - _length_heap = length_; - } - - return const_cast(_buffer); - } - - bool empty() const - { - return *_buffer == 0; - } - - bool operator==(const xpath_string& o) const - { - return strequal(_buffer, o._buffer); - } - - bool operator!=(const xpath_string& o) const - { - return !strequal(_buffer, o._buffer); - } - - bool uses_heap() const - { - return _uses_heap; - } - }; -PUGI__NS_END - -PUGI__NS_BEGIN - PUGI__FN bool starts_with(const char_t* string, const char_t* pattern) - { - while (*pattern && *string == *pattern) - { - string++; - pattern++; - } - - return *pattern == 0; - } - - PUGI__FN const char_t* find_char(const char_t* s, char_t c) - { - #ifdef PUGIXML_WCHAR_MODE - return wcschr(s, c); - #else - return strchr(s, c); - #endif - } - - PUGI__FN const char_t* find_substring(const char_t* s, const char_t* p) - { - #ifdef PUGIXML_WCHAR_MODE - // MSVC6 wcsstr bug workaround (if s is empty it always returns 0) - return (*p == 0) ? s : wcsstr(s, p); - #else - return strstr(s, p); - #endif - } - - // Converts symbol to lower case, if it is an ASCII one - PUGI__FN char_t tolower_ascii(char_t ch) - { - return static_cast(ch - 'A') < 26 ? static_cast(ch | ' ') : ch; - } - - PUGI__FN xpath_string string_value(const xpath_node& na, xpath_allocator* alloc) - { - if (na.attribute()) - return xpath_string::from_const(na.attribute().value()); - else - { - xml_node n = na.node(); - - switch (n.type()) - { - case node_pcdata: - case node_cdata: - case node_comment: - case node_pi: - return xpath_string::from_const(n.value()); - - case node_document: - case node_element: - { - xpath_string result; - - // element nodes can have value if parse_embed_pcdata was used - if (n.value()[0]) - result.append(xpath_string::from_const(n.value()), alloc); - - xml_node cur = n.first_child(); - - while (cur && cur != n) - { - if (cur.type() == node_pcdata || cur.type() == node_cdata) - result.append(xpath_string::from_const(cur.value()), alloc); - - if (cur.first_child()) - cur = cur.first_child(); - else if (cur.next_sibling()) - cur = cur.next_sibling(); - else - { - while (!cur.next_sibling() && cur != n) - cur = cur.parent(); - - if (cur != n) cur = cur.next_sibling(); - } - } - - return result; - } - - default: - return xpath_string(); - } - } - } - - PUGI__FN bool node_is_before_sibling(xml_node_struct* ln, xml_node_struct* rn) - { - assert(ln->parent == rn->parent); - - // there is no common ancestor (the shared parent is null), nodes are from different documents - if (!ln->parent) return ln < rn; - - // determine sibling order - xml_node_struct* ls = ln; - xml_node_struct* rs = rn; - - while (ls && rs) - { - if (ls == rn) return true; - if (rs == ln) return false; - - ls = ls->next_sibling; - rs = rs->next_sibling; - } - - // if rn sibling chain ended ln must be before rn - return !rs; - } - - PUGI__FN bool node_is_before(xml_node_struct* ln, xml_node_struct* rn) - { - // find common ancestor at the same depth, if any - xml_node_struct* lp = ln; - xml_node_struct* rp = rn; - - while (lp && rp && lp->parent != rp->parent) - { - lp = lp->parent; - rp = rp->parent; - } - - // parents are the same! - if (lp && rp) return node_is_before_sibling(lp, rp); - - // nodes are at different depths, need to normalize heights - bool left_higher = !lp; - - while (lp) - { - lp = lp->parent; - ln = ln->parent; - } - - while (rp) - { - rp = rp->parent; - rn = rn->parent; - } - - // one node is the ancestor of the other - if (ln == rn) return left_higher; - - // find common ancestor... again - while (ln->parent != rn->parent) - { - ln = ln->parent; - rn = rn->parent; - } - - return node_is_before_sibling(ln, rn); - } - - PUGI__FN bool node_is_ancestor(xml_node_struct* parent, xml_node_struct* node) - { - while (node && node != parent) node = node->parent; - - return parent && node == parent; - } - - PUGI__FN const void* document_buffer_order(const xpath_node& xnode) - { - xml_node_struct* node = xnode.node().internal_object(); - - if (node) - { - if ((get_document(node).header & xml_memory_page_contents_shared_mask) == 0) - { - if (node->name && (node->header & impl::xml_memory_page_name_allocated_or_shared_mask) == 0) return node->name; - if (node->value && (node->header & impl::xml_memory_page_value_allocated_or_shared_mask) == 0) return node->value; - } - - return 0; - } - - xml_attribute_struct* attr = xnode.attribute().internal_object(); - - if (attr) - { - if ((get_document(attr).header & xml_memory_page_contents_shared_mask) == 0) - { - if ((attr->header & impl::xml_memory_page_name_allocated_or_shared_mask) == 0) return attr->name; - if ((attr->header & impl::xml_memory_page_value_allocated_or_shared_mask) == 0) return attr->value; - } - - return 0; - } - - return 0; - } - - struct document_order_comparator - { - bool operator()(const xpath_node& lhs, const xpath_node& rhs) const - { - // optimized document order based check - const void* lo = document_buffer_order(lhs); - const void* ro = document_buffer_order(rhs); - - if (lo && ro) return lo < ro; - - // slow comparison - xml_node ln = lhs.node(), rn = rhs.node(); - - // compare attributes - if (lhs.attribute() && rhs.attribute()) - { - // shared parent - if (lhs.parent() == rhs.parent()) - { - // determine sibling order - for (xml_attribute a = lhs.attribute(); a; a = a.next_attribute()) - if (a == rhs.attribute()) - return true; - - return false; - } - - // compare attribute parents - ln = lhs.parent(); - rn = rhs.parent(); - } - else if (lhs.attribute()) - { - // attributes go after the parent element - if (lhs.parent() == rhs.node()) return false; - - ln = lhs.parent(); - } - else if (rhs.attribute()) - { - // attributes go after the parent element - if (rhs.parent() == lhs.node()) return true; - - rn = rhs.parent(); - } - - if (ln == rn) return false; - - if (!ln || !rn) return ln < rn; - - return node_is_before(ln.internal_object(), rn.internal_object()); - } - }; - - PUGI__FN double gen_nan() - { - #if defined(__STDC_IEC_559__) || ((FLT_RADIX - 0 == 2) && (FLT_MAX_EXP - 0 == 128) && (FLT_MANT_DIG - 0 == 24)) - PUGI__STATIC_ASSERT(sizeof(float) == sizeof(uint32_t)); - typedef uint32_t UI; // BCC5 workaround - union { float f; UI i; } u; - u.i = 0x7fc00000; - return double(u.f); - #else - // fallback - const volatile double zero = 0.0; - return zero / zero; - #endif - } - - PUGI__FN bool is_nan(double value) - { - #if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) - return !!_isnan(value); - #elif defined(fpclassify) && defined(FP_NAN) - return fpclassify(value) == FP_NAN; - #else - // fallback - const volatile double v = value; - return v != v; - #endif - } - - PUGI__FN const char_t* convert_number_to_string_special(double value) - { - #if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) - if (_finite(value)) return (value == 0) ? PUGIXML_TEXT("0") : 0; - if (_isnan(value)) return PUGIXML_TEXT("NaN"); - return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity"); - #elif defined(fpclassify) && defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO) - switch (fpclassify(value)) - { - case FP_NAN: - return PUGIXML_TEXT("NaN"); - - case FP_INFINITE: - return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity"); - - case FP_ZERO: - return PUGIXML_TEXT("0"); - - default: - return 0; - } - #else - // fallback - const volatile double v = value; - - if (v == 0) return PUGIXML_TEXT("0"); - if (v != v) return PUGIXML_TEXT("NaN"); - if (v * 2 == v) return value > 0 ? PUGIXML_TEXT("Infinity") : PUGIXML_TEXT("-Infinity"); - return 0; - #endif - } - - PUGI__FN bool convert_number_to_boolean(double value) - { - return (value != 0 && !is_nan(value)); - } - - PUGI__FN void truncate_zeros(char* begin, char* end) - { - while (begin != end && end[-1] == '0') end--; - - *end = 0; - } - - // gets mantissa digits in the form of 0.xxxxx with 0. implied and the exponent -#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 && !defined(_WIN32_WCE) - PUGI__FN void convert_number_to_mantissa_exponent(double value, char (&buffer)[32], char** out_mantissa, int* out_exponent) - { - // get base values - int sign, exponent; - _ecvt_s(buffer, sizeof(buffer), value, DBL_DIG + 1, &exponent, &sign); - - // truncate redundant zeros - truncate_zeros(buffer, buffer + strlen(buffer)); - - // fill results - *out_mantissa = buffer; - *out_exponent = exponent; - } -#else - PUGI__FN void convert_number_to_mantissa_exponent(double value, char (&buffer)[32], char** out_mantissa, int* out_exponent) - { - // get a scientific notation value with IEEE DBL_DIG decimals - PUGI__SNPRINTF(buffer, "%.*e", DBL_DIG, value); - - // get the exponent (possibly negative) - char* exponent_string = strchr(buffer, 'e'); - assert(exponent_string); - - int exponent = atoi(exponent_string + 1); - - // extract mantissa string: skip sign - char* mantissa = buffer[0] == '-' ? buffer + 1 : buffer; - assert(mantissa[0] != '0' && mantissa[1] == '.'); - - // divide mantissa by 10 to eliminate integer part - mantissa[1] = mantissa[0]; - mantissa++; - exponent++; - - // remove extra mantissa digits and zero-terminate mantissa - truncate_zeros(mantissa, exponent_string); - - // fill results - *out_mantissa = mantissa; - *out_exponent = exponent; - } -#endif - - PUGI__FN xpath_string convert_number_to_string(double value, xpath_allocator* alloc) - { - // try special number conversion - const char_t* special = convert_number_to_string_special(value); - if (special) return xpath_string::from_const(special); - - // get mantissa + exponent form - char mantissa_buffer[32]; - - char* mantissa; - int exponent; - convert_number_to_mantissa_exponent(value, mantissa_buffer, &mantissa, &exponent); - - // allocate a buffer of suitable length for the number - size_t result_size = strlen(mantissa_buffer) + (exponent > 0 ? exponent : -exponent) + 4; - char_t* result = static_cast(alloc->allocate(sizeof(char_t) * result_size)); - if (!result) return xpath_string(); - - // make the number! - char_t* s = result; - - // sign - if (value < 0) *s++ = '-'; - - // integer part - if (exponent <= 0) - { - *s++ = '0'; - } - else - { - while (exponent > 0) - { - assert(*mantissa == 0 || static_cast(*mantissa - '0') <= 9); - *s++ = *mantissa ? *mantissa++ : '0'; - exponent--; - } - } - - // fractional part - if (*mantissa) - { - // decimal point - *s++ = '.'; - - // extra zeroes from negative exponent - while (exponent < 0) - { - *s++ = '0'; - exponent++; - } - - // extra mantissa digits - while (*mantissa) - { - assert(static_cast(*mantissa - '0') <= 9); - *s++ = *mantissa++; - } - } - - // zero-terminate - assert(s < result + result_size); - *s = 0; - - return xpath_string::from_heap_preallocated(result, s); - } - - PUGI__FN bool check_string_to_number_format(const char_t* string) - { - // parse leading whitespace - while (PUGI__IS_CHARTYPE(*string, ct_space)) ++string; - - // parse sign - if (*string == '-') ++string; - - if (!*string) return false; - - // if there is no integer part, there should be a decimal part with at least one digit - if (!PUGI__IS_CHARTYPEX(string[0], ctx_digit) && (string[0] != '.' || !PUGI__IS_CHARTYPEX(string[1], ctx_digit))) return false; - - // parse integer part - while (PUGI__IS_CHARTYPEX(*string, ctx_digit)) ++string; - - // parse decimal part - if (*string == '.') - { - ++string; - - while (PUGI__IS_CHARTYPEX(*string, ctx_digit)) ++string; - } - - // parse trailing whitespace - while (PUGI__IS_CHARTYPE(*string, ct_space)) ++string; - - return *string == 0; - } - - PUGI__FN double convert_string_to_number(const char_t* string) - { - // check string format - if (!check_string_to_number_format(string)) return gen_nan(); - - // parse string - #ifdef PUGIXML_WCHAR_MODE - return wcstod(string, 0); - #else - return strtod(string, 0); - #endif - } - - PUGI__FN bool convert_string_to_number_scratch(char_t (&buffer)[32], const char_t* begin, const char_t* end, double* out_result) - { - size_t length = static_cast(end - begin); - char_t* scratch = buffer; - - if (length >= sizeof(buffer) / sizeof(buffer[0])) - { - // need to make dummy on-heap copy - scratch = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!scratch) return false; - } - - // copy string to zero-terminated buffer and perform conversion - memcpy(scratch, begin, length * sizeof(char_t)); - scratch[length] = 0; - - *out_result = convert_string_to_number(scratch); - - // free dummy buffer - if (scratch != buffer) xml_memory::deallocate(scratch); - - return true; - } - - PUGI__FN double round_nearest(double value) - { - return floor(value + 0.5); - } - - PUGI__FN double round_nearest_nzero(double value) - { - // same as round_nearest, but returns -0 for [-0.5, -0] - // ceil is used to differentiate between +0 and -0 (we return -0 for [-0.5, -0] and +0 for +0) - return (value >= -0.5 && value <= 0) ? ceil(value) : floor(value + 0.5); - } - - PUGI__FN const char_t* qualified_name(const xpath_node& node) - { - return node.attribute() ? node.attribute().name() : node.node().name(); - } - - PUGI__FN const char_t* local_name(const xpath_node& node) - { - const char_t* name = qualified_name(node); - const char_t* p = find_char(name, ':'); - - return p ? p + 1 : name; - } - - struct namespace_uri_predicate - { - const char_t* prefix; - size_t prefix_length; - - namespace_uri_predicate(const char_t* name) - { - const char_t* pos = find_char(name, ':'); - - prefix = pos ? name : 0; - prefix_length = pos ? static_cast(pos - name) : 0; - } - - bool operator()(xml_attribute a) const - { - const char_t* name = a.name(); - - if (!starts_with(name, PUGIXML_TEXT("xmlns"))) return false; - - return prefix ? name[5] == ':' && strequalrange(name + 6, prefix, prefix_length) : name[5] == 0; - } - }; - - PUGI__FN const char_t* namespace_uri(xml_node node) - { - namespace_uri_predicate pred = node.name(); - - xml_node p = node; - - while (p) - { - xml_attribute a = p.find_attribute(pred); - - if (a) return a.value(); - - p = p.parent(); - } - - return PUGIXML_TEXT(""); - } - - PUGI__FN const char_t* namespace_uri(xml_attribute attr, xml_node parent) - { - namespace_uri_predicate pred = attr.name(); - - // Default namespace does not apply to attributes - if (!pred.prefix) return PUGIXML_TEXT(""); - - xml_node p = parent; - - while (p) - { - xml_attribute a = p.find_attribute(pred); - - if (a) return a.value(); - - p = p.parent(); - } - - return PUGIXML_TEXT(""); - } - - PUGI__FN const char_t* namespace_uri(const xpath_node& node) - { - return node.attribute() ? namespace_uri(node.attribute(), node.parent()) : namespace_uri(node.node()); - } - - PUGI__FN char_t* normalize_space(char_t* buffer) - { - char_t* write = buffer; - - for (char_t* it = buffer; *it; ) - { - char_t ch = *it++; - - if (PUGI__IS_CHARTYPE(ch, ct_space)) - { - // replace whitespace sequence with single space - while (PUGI__IS_CHARTYPE(*it, ct_space)) it++; - - // avoid leading spaces - if (write != buffer) *write++ = ' '; - } - else *write++ = ch; - } - - // remove trailing space - if (write != buffer && PUGI__IS_CHARTYPE(write[-1], ct_space)) write--; - - // zero-terminate - *write = 0; - - return write; - } - - PUGI__FN char_t* translate(char_t* buffer, const char_t* from, const char_t* to, size_t to_length) - { - char_t* write = buffer; - - while (*buffer) - { - PUGI__DMC_VOLATILE char_t ch = *buffer++; - - const char_t* pos = find_char(from, ch); - - if (!pos) - *write++ = ch; // do not process - else if (static_cast(pos - from) < to_length) - *write++ = to[pos - from]; // replace - } - - // zero-terminate - *write = 0; - - return write; - } - - PUGI__FN unsigned char* translate_table_generate(xpath_allocator* alloc, const char_t* from, const char_t* to) - { - unsigned char table[128] = {0}; - - while (*from) - { - unsigned int fc = static_cast(*from); - unsigned int tc = static_cast(*to); - - if (fc >= 128 || tc >= 128) - return 0; - - // code=128 means "skip character" - if (!table[fc]) - table[fc] = static_cast(tc ? tc : 128); - - from++; - if (tc) to++; - } - - for (int i = 0; i < 128; ++i) - if (!table[i]) - table[i] = static_cast(i); - - void* result = alloc->allocate(sizeof(table)); - if (!result) return 0; - - memcpy(result, table, sizeof(table)); - - return static_cast(result); - } - - PUGI__FN char_t* translate_table(char_t* buffer, const unsigned char* table) - { - char_t* write = buffer; - - while (*buffer) - { - char_t ch = *buffer++; - unsigned int index = static_cast(ch); - - if (index < 128) - { - unsigned char code = table[index]; - - // code=128 means "skip character" (table size is 128 so 128 can be a special value) - // this code skips these characters without extra branches - *write = static_cast(code); - write += 1 - (code >> 7); - } - else - { - *write++ = ch; - } - } - - // zero-terminate - *write = 0; - - return write; - } - - inline bool is_xpath_attribute(const char_t* name) - { - return !(starts_with(name, PUGIXML_TEXT("xmlns")) && (name[5] == 0 || name[5] == ':')); - } - - struct xpath_variable_boolean: xpath_variable - { - xpath_variable_boolean(): xpath_variable(xpath_type_boolean), value(false) - { - } - - bool value; - char_t name[1]; - }; - - struct xpath_variable_number: xpath_variable - { - xpath_variable_number(): xpath_variable(xpath_type_number), value(0) - { - } - - double value; - char_t name[1]; - }; - - struct xpath_variable_string: xpath_variable - { - xpath_variable_string(): xpath_variable(xpath_type_string), value(0) - { - } - - ~xpath_variable_string() - { - if (value) xml_memory::deallocate(value); - } - - char_t* value; - char_t name[1]; - }; - - struct xpath_variable_node_set: xpath_variable - { - xpath_variable_node_set(): xpath_variable(xpath_type_node_set) - { - } - - xpath_node_set value; - char_t name[1]; - }; - - static const xpath_node_set dummy_node_set; - - PUGI__FN PUGI__UNSIGNED_OVERFLOW unsigned int hash_string(const char_t* str) - { - // Jenkins one-at-a-time hash (http://en.wikipedia.org/wiki/Jenkins_hash_function#one-at-a-time) - unsigned int result = 0; - - while (*str) - { - result += static_cast(*str++); - result += result << 10; - result ^= result >> 6; - } - - result += result << 3; - result ^= result >> 11; - result += result << 15; - - return result; - } - - template PUGI__FN T* new_xpath_variable(const char_t* name) - { - size_t length = strlength(name); - if (length == 0) return 0; // empty variable names are invalid - - // $$ we can't use offsetof(T, name) because T is non-POD, so we just allocate additional length characters - void* memory = xml_memory::allocate(sizeof(T) + length * sizeof(char_t)); - if (!memory) return 0; - - T* result = new (memory) T(); - - memcpy(result->name, name, (length + 1) * sizeof(char_t)); - - return result; - } - - PUGI__FN xpath_variable* new_xpath_variable(xpath_value_type type, const char_t* name) - { - switch (type) - { - case xpath_type_node_set: - return new_xpath_variable(name); - - case xpath_type_number: - return new_xpath_variable(name); - - case xpath_type_string: - return new_xpath_variable(name); - - case xpath_type_boolean: - return new_xpath_variable(name); - - default: - return 0; - } - } - - template PUGI__FN void delete_xpath_variable(T* var) - { - var->~T(); - xml_memory::deallocate(var); - } - - PUGI__FN void delete_xpath_variable(xpath_value_type type, xpath_variable* var) - { - switch (type) - { - case xpath_type_node_set: - delete_xpath_variable(static_cast(var)); - break; - - case xpath_type_number: - delete_xpath_variable(static_cast(var)); - break; - - case xpath_type_string: - delete_xpath_variable(static_cast(var)); - break; - - case xpath_type_boolean: - delete_xpath_variable(static_cast(var)); - break; - - default: - assert(false && "Invalid variable type"); // unreachable - } - } - - PUGI__FN bool copy_xpath_variable(xpath_variable* lhs, const xpath_variable* rhs) - { - switch (rhs->type()) - { - case xpath_type_node_set: - return lhs->set(static_cast(rhs)->value); - - case xpath_type_number: - return lhs->set(static_cast(rhs)->value); - - case xpath_type_string: - return lhs->set(static_cast(rhs)->value); - - case xpath_type_boolean: - return lhs->set(static_cast(rhs)->value); - - default: - assert(false && "Invalid variable type"); // unreachable - return false; - } - } - - PUGI__FN bool get_variable_scratch(char_t (&buffer)[32], xpath_variable_set* set, const char_t* begin, const char_t* end, xpath_variable** out_result) - { - size_t length = static_cast(end - begin); - char_t* scratch = buffer; - - if (length >= sizeof(buffer) / sizeof(buffer[0])) - { - // need to make dummy on-heap copy - scratch = static_cast(xml_memory::allocate((length + 1) * sizeof(char_t))); - if (!scratch) return false; - } - - // copy string to zero-terminated buffer and perform lookup - memcpy(scratch, begin, length * sizeof(char_t)); - scratch[length] = 0; - - *out_result = set->get(scratch); - - // free dummy buffer - if (scratch != buffer) xml_memory::deallocate(scratch); - - return true; - } -PUGI__NS_END - -// Internal node set class -PUGI__NS_BEGIN - PUGI__FN xpath_node_set::type_t xpath_get_order(const xpath_node* begin, const xpath_node* end) - { - if (end - begin < 2) - return xpath_node_set::type_sorted; - - document_order_comparator cmp; - - bool first = cmp(begin[0], begin[1]); - - for (const xpath_node* it = begin + 1; it + 1 < end; ++it) - if (cmp(it[0], it[1]) != first) - return xpath_node_set::type_unsorted; - - return first ? xpath_node_set::type_sorted : xpath_node_set::type_sorted_reverse; - } - - PUGI__FN xpath_node_set::type_t xpath_sort(xpath_node* begin, xpath_node* end, xpath_node_set::type_t type, bool rev) - { - xpath_node_set::type_t order = rev ? xpath_node_set::type_sorted_reverse : xpath_node_set::type_sorted; - - if (type == xpath_node_set::type_unsorted) - { - xpath_node_set::type_t sorted = xpath_get_order(begin, end); - - if (sorted == xpath_node_set::type_unsorted) - { - sort(begin, end, document_order_comparator()); - - type = xpath_node_set::type_sorted; - } - else - type = sorted; - } - - if (type != order) reverse(begin, end); - - return order; - } - - PUGI__FN xpath_node xpath_first(const xpath_node* begin, const xpath_node* end, xpath_node_set::type_t type) - { - if (begin == end) return xpath_node(); - - switch (type) - { - case xpath_node_set::type_sorted: - return *begin; - - case xpath_node_set::type_sorted_reverse: - return *(end - 1); - - case xpath_node_set::type_unsorted: - return *min_element(begin, end, document_order_comparator()); - - default: - assert(false && "Invalid node set type"); // unreachable - return xpath_node(); - } - } - - class xpath_node_set_raw - { - xpath_node_set::type_t _type; - - xpath_node* _begin; - xpath_node* _end; - xpath_node* _eos; - - public: - xpath_node_set_raw(): _type(xpath_node_set::type_unsorted), _begin(0), _end(0), _eos(0) - { - } - - xpath_node* begin() const - { - return _begin; - } - - xpath_node* end() const - { - return _end; - } - - bool empty() const - { - return _begin == _end; - } - - size_t size() const - { - return static_cast(_end - _begin); - } - - xpath_node first() const - { - return xpath_first(_begin, _end, _type); - } - - void push_back_grow(const xpath_node& node, xpath_allocator* alloc); - - void push_back(const xpath_node& node, xpath_allocator* alloc) - { - if (_end != _eos) - *_end++ = node; - else - push_back_grow(node, alloc); - } - - void append(const xpath_node* begin_, const xpath_node* end_, xpath_allocator* alloc) - { - if (begin_ == end_) return; - - size_t size_ = static_cast(_end - _begin); - size_t capacity = static_cast(_eos - _begin); - size_t count = static_cast(end_ - begin_); - - if (size_ + count > capacity) - { - // reallocate the old array or allocate a new one - xpath_node* data = static_cast(alloc->reallocate(_begin, capacity * sizeof(xpath_node), (size_ + count) * sizeof(xpath_node))); - if (!data) return; - - // finalize - _begin = data; - _end = data + size_; - _eos = data + size_ + count; - } - - memcpy(_end, begin_, count * sizeof(xpath_node)); - _end += count; - } - - void sort_do() - { - _type = xpath_sort(_begin, _end, _type, false); - } - - void truncate(xpath_node* pos) - { - assert(_begin <= pos && pos <= _end); - - _end = pos; - } - - void remove_duplicates(xpath_allocator* alloc) - { - if (_type == xpath_node_set::type_unsorted && _end - _begin > 2) - { - xpath_allocator_capture cr(alloc); - - size_t size_ = static_cast(_end - _begin); - - size_t hash_size = 1; - while (hash_size < size_ + size_ / 2) hash_size *= 2; - - const void** hash_data = static_cast(alloc->allocate(hash_size * sizeof(void**))); - if (!hash_data) return; - - memset(hash_data, 0, hash_size * sizeof(const void**)); - - xpath_node* write = _begin; - - for (xpath_node* it = _begin; it != _end; ++it) - { - const void* attr = it->attribute().internal_object(); - const void* node = it->node().internal_object(); - const void* key = attr ? attr : node; - - if (key && hash_insert(hash_data, hash_size, key)) - { - *write++ = *it; - } - } - - _end = write; - } - else - { - _end = unique(_begin, _end); - } - } - - xpath_node_set::type_t type() const - { - return _type; - } - - void set_type(xpath_node_set::type_t value) - { - _type = value; - } - }; - - PUGI__FN_NO_INLINE void xpath_node_set_raw::push_back_grow(const xpath_node& node, xpath_allocator* alloc) - { - size_t capacity = static_cast(_eos - _begin); - - // get new capacity (1.5x rule) - size_t new_capacity = capacity + capacity / 2 + 1; - - // reallocate the old array or allocate a new one - xpath_node* data = static_cast(alloc->reallocate(_begin, capacity * sizeof(xpath_node), new_capacity * sizeof(xpath_node))); - if (!data) return; - - // finalize - _begin = data; - _end = data + capacity; - _eos = data + new_capacity; - - // push - *_end++ = node; - } -PUGI__NS_END - -PUGI__NS_BEGIN - struct xpath_context - { - xpath_node n; - size_t position, size; - - xpath_context(const xpath_node& n_, size_t position_, size_t size_): n(n_), position(position_), size(size_) - { - } - }; - - enum lexeme_t - { - lex_none = 0, - lex_equal, - lex_not_equal, - lex_less, - lex_greater, - lex_less_or_equal, - lex_greater_or_equal, - lex_plus, - lex_minus, - lex_multiply, - lex_union, - lex_var_ref, - lex_open_brace, - lex_close_brace, - lex_quoted_string, - lex_number, - lex_slash, - lex_double_slash, - lex_open_square_brace, - lex_close_square_brace, - lex_string, - lex_comma, - lex_axis_attribute, - lex_dot, - lex_double_dot, - lex_double_colon, - lex_eof - }; - - struct xpath_lexer_string - { - const char_t* begin; - const char_t* end; - - xpath_lexer_string(): begin(0), end(0) - { - } - - bool operator==(const char_t* other) const - { - size_t length = static_cast(end - begin); - - return strequalrange(other, begin, length); - } - }; - - class xpath_lexer - { - const char_t* _cur; - const char_t* _cur_lexeme_pos; - xpath_lexer_string _cur_lexeme_contents; - - lexeme_t _cur_lexeme; - - public: - explicit xpath_lexer(const char_t* query): _cur(query) - { - next(); - } - - const char_t* state() const - { - return _cur; - } - - void next() - { - const char_t* cur = _cur; - - while (PUGI__IS_CHARTYPE(*cur, ct_space)) ++cur; - - // save lexeme position for error reporting - _cur_lexeme_pos = cur; - - switch (*cur) - { - case 0: - _cur_lexeme = lex_eof; - break; - - case '>': - if (*(cur+1) == '=') - { - cur += 2; - _cur_lexeme = lex_greater_or_equal; - } - else - { - cur += 1; - _cur_lexeme = lex_greater; - } - break; - - case '<': - if (*(cur+1) == '=') - { - cur += 2; - _cur_lexeme = lex_less_or_equal; - } - else - { - cur += 1; - _cur_lexeme = lex_less; - } - break; - - case '!': - if (*(cur+1) == '=') - { - cur += 2; - _cur_lexeme = lex_not_equal; - } - else - { - _cur_lexeme = lex_none; - } - break; - - case '=': - cur += 1; - _cur_lexeme = lex_equal; - - break; - - case '+': - cur += 1; - _cur_lexeme = lex_plus; - - break; - - case '-': - cur += 1; - _cur_lexeme = lex_minus; - - break; - - case '*': - cur += 1; - _cur_lexeme = lex_multiply; - - break; - - case '|': - cur += 1; - _cur_lexeme = lex_union; - - break; - - case '$': - cur += 1; - - if (PUGI__IS_CHARTYPEX(*cur, ctx_start_symbol)) - { - _cur_lexeme_contents.begin = cur; - - while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++; - - if (cur[0] == ':' && PUGI__IS_CHARTYPEX(cur[1], ctx_symbol)) // qname - { - cur++; // : - - while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++; - } - - _cur_lexeme_contents.end = cur; - - _cur_lexeme = lex_var_ref; - } - else - { - _cur_lexeme = lex_none; - } - - break; - - case '(': - cur += 1; - _cur_lexeme = lex_open_brace; - - break; - - case ')': - cur += 1; - _cur_lexeme = lex_close_brace; - - break; - - case '[': - cur += 1; - _cur_lexeme = lex_open_square_brace; - - break; - - case ']': - cur += 1; - _cur_lexeme = lex_close_square_brace; - - break; - - case ',': - cur += 1; - _cur_lexeme = lex_comma; - - break; - - case '/': - if (*(cur+1) == '/') - { - cur += 2; - _cur_lexeme = lex_double_slash; - } - else - { - cur += 1; - _cur_lexeme = lex_slash; - } - break; - - case '.': - if (*(cur+1) == '.') - { - cur += 2; - _cur_lexeme = lex_double_dot; - } - else if (PUGI__IS_CHARTYPEX(*(cur+1), ctx_digit)) - { - _cur_lexeme_contents.begin = cur; // . - - ++cur; - - while (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) cur++; - - _cur_lexeme_contents.end = cur; - - _cur_lexeme = lex_number; - } - else - { - cur += 1; - _cur_lexeme = lex_dot; - } - break; - - case '@': - cur += 1; - _cur_lexeme = lex_axis_attribute; - - break; - - case '"': - case '\'': - { - char_t terminator = *cur; - - ++cur; - - _cur_lexeme_contents.begin = cur; - while (*cur && *cur != terminator) cur++; - _cur_lexeme_contents.end = cur; - - if (!*cur) - _cur_lexeme = lex_none; - else - { - cur += 1; - _cur_lexeme = lex_quoted_string; - } - - break; - } - - case ':': - if (*(cur+1) == ':') - { - cur += 2; - _cur_lexeme = lex_double_colon; - } - else - { - _cur_lexeme = lex_none; - } - break; - - default: - if (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) - { - _cur_lexeme_contents.begin = cur; - - while (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) cur++; - - if (*cur == '.') - { - cur++; - - while (PUGI__IS_CHARTYPEX(*cur, ctx_digit)) cur++; - } - - _cur_lexeme_contents.end = cur; - - _cur_lexeme = lex_number; - } - else if (PUGI__IS_CHARTYPEX(*cur, ctx_start_symbol)) - { - _cur_lexeme_contents.begin = cur; - - while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++; - - if (cur[0] == ':') - { - if (cur[1] == '*') // namespace test ncname:* - { - cur += 2; // :* - } - else if (PUGI__IS_CHARTYPEX(cur[1], ctx_symbol)) // namespace test qname - { - cur++; // : - - while (PUGI__IS_CHARTYPEX(*cur, ctx_symbol)) cur++; - } - } - - _cur_lexeme_contents.end = cur; - - _cur_lexeme = lex_string; - } - else - { - _cur_lexeme = lex_none; - } - } - - _cur = cur; - } - - lexeme_t current() const - { - return _cur_lexeme; - } - - const char_t* current_pos() const - { - return _cur_lexeme_pos; - } - - const xpath_lexer_string& contents() const - { - assert(_cur_lexeme == lex_var_ref || _cur_lexeme == lex_number || _cur_lexeme == lex_string || _cur_lexeme == lex_quoted_string); - - return _cur_lexeme_contents; - } - }; - - enum ast_type_t - { - ast_unknown, - ast_op_or, // left or right - ast_op_and, // left and right - ast_op_equal, // left = right - ast_op_not_equal, // left != right - ast_op_less, // left < right - ast_op_greater, // left > right - ast_op_less_or_equal, // left <= right - ast_op_greater_or_equal, // left >= right - ast_op_add, // left + right - ast_op_subtract, // left - right - ast_op_multiply, // left * right - ast_op_divide, // left / right - ast_op_mod, // left % right - ast_op_negate, // left - right - ast_op_union, // left | right - ast_predicate, // apply predicate to set; next points to next predicate - ast_filter, // select * from left where right - ast_string_constant, // string constant - ast_number_constant, // number constant - ast_variable, // variable - ast_func_last, // last() - ast_func_position, // position() - ast_func_count, // count(left) - ast_func_id, // id(left) - ast_func_local_name_0, // local-name() - ast_func_local_name_1, // local-name(left) - ast_func_namespace_uri_0, // namespace-uri() - ast_func_namespace_uri_1, // namespace-uri(left) - ast_func_name_0, // name() - ast_func_name_1, // name(left) - ast_func_string_0, // string() - ast_func_string_1, // string(left) - ast_func_concat, // concat(left, right, siblings) - ast_func_starts_with, // starts_with(left, right) - ast_func_contains, // contains(left, right) - ast_func_substring_before, // substring-before(left, right) - ast_func_substring_after, // substring-after(left, right) - ast_func_substring_2, // substring(left, right) - ast_func_substring_3, // substring(left, right, third) - ast_func_string_length_0, // string-length() - ast_func_string_length_1, // string-length(left) - ast_func_normalize_space_0, // normalize-space() - ast_func_normalize_space_1, // normalize-space(left) - ast_func_translate, // translate(left, right, third) - ast_func_boolean, // boolean(left) - ast_func_not, // not(left) - ast_func_true, // true() - ast_func_false, // false() - ast_func_lang, // lang(left) - ast_func_number_0, // number() - ast_func_number_1, // number(left) - ast_func_sum, // sum(left) - ast_func_floor, // floor(left) - ast_func_ceiling, // ceiling(left) - ast_func_round, // round(left) - ast_step, // process set left with step - ast_step_root, // select root node - - ast_opt_translate_table, // translate(left, right, third) where right/third are constants - ast_opt_compare_attribute // @name = 'string' - }; - - enum axis_t - { - axis_ancestor, - axis_ancestor_or_self, - axis_attribute, - axis_child, - axis_descendant, - axis_descendant_or_self, - axis_following, - axis_following_sibling, - axis_namespace, - axis_parent, - axis_preceding, - axis_preceding_sibling, - axis_self - }; - - enum nodetest_t - { - nodetest_none, - nodetest_name, - nodetest_type_node, - nodetest_type_comment, - nodetest_type_pi, - nodetest_type_text, - nodetest_pi, - nodetest_all, - nodetest_all_in_namespace - }; - - enum predicate_t - { - predicate_default, - predicate_posinv, - predicate_constant, - predicate_constant_one - }; - - enum nodeset_eval_t - { - nodeset_eval_all, - nodeset_eval_any, - nodeset_eval_first - }; - - template struct axis_to_type - { - static const axis_t axis; - }; - - template const axis_t axis_to_type::axis = N; - - class xpath_ast_node - { - private: - // node type - char _type; - char _rettype; - - // for ast_step - char _axis; - - // for ast_step/ast_predicate/ast_filter - char _test; - - // tree node structure - xpath_ast_node* _left; - xpath_ast_node* _right; - xpath_ast_node* _next; - - union - { - // value for ast_string_constant - const char_t* string; - // value for ast_number_constant - double number; - // variable for ast_variable - xpath_variable* variable; - // node test for ast_step (node name/namespace/node type/pi target) - const char_t* nodetest; - // table for ast_opt_translate_table - const unsigned char* table; - } _data; - - xpath_ast_node(const xpath_ast_node&); - xpath_ast_node& operator=(const xpath_ast_node&); - - template static bool compare_eq(xpath_ast_node* lhs, xpath_ast_node* rhs, const xpath_context& c, const xpath_stack& stack, const Comp& comp) - { - xpath_value_type lt = lhs->rettype(), rt = rhs->rettype(); - - if (lt != xpath_type_node_set && rt != xpath_type_node_set) - { - if (lt == xpath_type_boolean || rt == xpath_type_boolean) - return comp(lhs->eval_boolean(c, stack), rhs->eval_boolean(c, stack)); - else if (lt == xpath_type_number || rt == xpath_type_number) - return comp(lhs->eval_number(c, stack), rhs->eval_number(c, stack)); - else if (lt == xpath_type_string || rt == xpath_type_string) - { - xpath_allocator_capture cr(stack.result); - - xpath_string ls = lhs->eval_string(c, stack); - xpath_string rs = rhs->eval_string(c, stack); - - return comp(ls, rs); - } - } - else if (lt == xpath_type_node_set && rt == xpath_type_node_set) - { - xpath_allocator_capture cr(stack.result); - - xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all); - xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); - - for (const xpath_node* li = ls.begin(); li != ls.end(); ++li) - for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) - { - xpath_allocator_capture cri(stack.result); - - if (comp(string_value(*li, stack.result), string_value(*ri, stack.result))) - return true; - } - - return false; - } - else - { - if (lt == xpath_type_node_set) - { - swap(lhs, rhs); - swap(lt, rt); - } - - if (lt == xpath_type_boolean) - return comp(lhs->eval_boolean(c, stack), rhs->eval_boolean(c, stack)); - else if (lt == xpath_type_number) - { - xpath_allocator_capture cr(stack.result); - - double l = lhs->eval_number(c, stack); - xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); - - for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) - { - xpath_allocator_capture cri(stack.result); - - if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str()))) - return true; - } - - return false; - } - else if (lt == xpath_type_string) - { - xpath_allocator_capture cr(stack.result); - - xpath_string l = lhs->eval_string(c, stack); - xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); - - for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) - { - xpath_allocator_capture cri(stack.result); - - if (comp(l, string_value(*ri, stack.result))) - return true; - } - - return false; - } - } - - assert(false && "Wrong types"); // unreachable - return false; - } - - static bool eval_once(xpath_node_set::type_t type, nodeset_eval_t eval) - { - return type == xpath_node_set::type_sorted ? eval != nodeset_eval_all : eval == nodeset_eval_any; - } - - template static bool compare_rel(xpath_ast_node* lhs, xpath_ast_node* rhs, const xpath_context& c, const xpath_stack& stack, const Comp& comp) - { - xpath_value_type lt = lhs->rettype(), rt = rhs->rettype(); - - if (lt != xpath_type_node_set && rt != xpath_type_node_set) - return comp(lhs->eval_number(c, stack), rhs->eval_number(c, stack)); - else if (lt == xpath_type_node_set && rt == xpath_type_node_set) - { - xpath_allocator_capture cr(stack.result); - - xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all); - xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); - - for (const xpath_node* li = ls.begin(); li != ls.end(); ++li) - { - xpath_allocator_capture cri(stack.result); - - double l = convert_string_to_number(string_value(*li, stack.result).c_str()); - - for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) - { - xpath_allocator_capture crii(stack.result); - - if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str()))) - return true; - } - } - - return false; - } - else if (lt != xpath_type_node_set && rt == xpath_type_node_set) - { - xpath_allocator_capture cr(stack.result); - - double l = lhs->eval_number(c, stack); - xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); - - for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) - { - xpath_allocator_capture cri(stack.result); - - if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str()))) - return true; - } - - return false; - } - else if (lt == xpath_type_node_set && rt != xpath_type_node_set) - { - xpath_allocator_capture cr(stack.result); - - xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all); - double r = rhs->eval_number(c, stack); - - for (const xpath_node* li = ls.begin(); li != ls.end(); ++li) - { - xpath_allocator_capture cri(stack.result); - - if (comp(convert_string_to_number(string_value(*li, stack.result).c_str()), r)) - return true; - } - - return false; - } - else - { - assert(false && "Wrong types"); // unreachable - return false; - } - } - - static void apply_predicate_boolean(xpath_node_set_raw& ns, size_t first, xpath_ast_node* expr, const xpath_stack& stack, bool once) - { - assert(ns.size() >= first); - assert(expr->rettype() != xpath_type_number); - - size_t i = 1; - size_t size = ns.size() - first; - - xpath_node* last = ns.begin() + first; - - // remove_if... or well, sort of - for (xpath_node* it = last; it != ns.end(); ++it, ++i) - { - xpath_context c(*it, i, size); - - if (expr->eval_boolean(c, stack)) - { - *last++ = *it; - - if (once) break; - } - } - - ns.truncate(last); - } - - static void apply_predicate_number(xpath_node_set_raw& ns, size_t first, xpath_ast_node* expr, const xpath_stack& stack, bool once) - { - assert(ns.size() >= first); - assert(expr->rettype() == xpath_type_number); - - size_t i = 1; - size_t size = ns.size() - first; - - xpath_node* last = ns.begin() + first; - - // remove_if... or well, sort of - for (xpath_node* it = last; it != ns.end(); ++it, ++i) - { - xpath_context c(*it, i, size); - - if (expr->eval_number(c, stack) == static_cast(i)) - { - *last++ = *it; - - if (once) break; - } - } - - ns.truncate(last); - } - - static void apply_predicate_number_const(xpath_node_set_raw& ns, size_t first, xpath_ast_node* expr, const xpath_stack& stack) - { - assert(ns.size() >= first); - assert(expr->rettype() == xpath_type_number); - - size_t size = ns.size() - first; - - xpath_node* last = ns.begin() + first; - - xpath_context c(xpath_node(), 1, size); - - double er = expr->eval_number(c, stack); - - if (er >= 1.0 && er <= static_cast(size)) - { - size_t eri = static_cast(er); - - if (er == static_cast(eri)) - { - xpath_node r = last[eri - 1]; - - *last++ = r; - } - } - - ns.truncate(last); - } - - void apply_predicate(xpath_node_set_raw& ns, size_t first, const xpath_stack& stack, bool once) - { - if (ns.size() == first) return; - - assert(_type == ast_filter || _type == ast_predicate); - - if (_test == predicate_constant || _test == predicate_constant_one) - apply_predicate_number_const(ns, first, _right, stack); - else if (_right->rettype() == xpath_type_number) - apply_predicate_number(ns, first, _right, stack, once); - else - apply_predicate_boolean(ns, first, _right, stack, once); - } - - void apply_predicates(xpath_node_set_raw& ns, size_t first, const xpath_stack& stack, nodeset_eval_t eval) - { - if (ns.size() == first) return; - - bool last_once = eval_once(ns.type(), eval); - - for (xpath_ast_node* pred = _right; pred; pred = pred->_next) - pred->apply_predicate(ns, first, stack, !pred->_next && last_once); - } - - bool step_push(xpath_node_set_raw& ns, xml_attribute_struct* a, xml_node_struct* parent, xpath_allocator* alloc) - { - assert(a); - - const char_t* name = a->name ? a->name + 0 : PUGIXML_TEXT(""); - - switch (_test) - { - case nodetest_name: - if (strequal(name, _data.nodetest) && is_xpath_attribute(name)) - { - ns.push_back(xpath_node(xml_attribute(a), xml_node(parent)), alloc); - return true; - } - break; - - case nodetest_type_node: - case nodetest_all: - if (is_xpath_attribute(name)) - { - ns.push_back(xpath_node(xml_attribute(a), xml_node(parent)), alloc); - return true; - } - break; - - case nodetest_all_in_namespace: - if (starts_with(name, _data.nodetest) && is_xpath_attribute(name)) - { - ns.push_back(xpath_node(xml_attribute(a), xml_node(parent)), alloc); - return true; - } - break; - - default: - ; - } - - return false; - } - - bool step_push(xpath_node_set_raw& ns, xml_node_struct* n, xpath_allocator* alloc) - { - assert(n); - - xml_node_type type = PUGI__NODETYPE(n); - - switch (_test) - { - case nodetest_name: - if (type == node_element && n->name && strequal(n->name, _data.nodetest)) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - case nodetest_type_node: - ns.push_back(xml_node(n), alloc); - return true; - - case nodetest_type_comment: - if (type == node_comment) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - case nodetest_type_text: - if (type == node_pcdata || type == node_cdata) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - case nodetest_type_pi: - if (type == node_pi) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - case nodetest_pi: - if (type == node_pi && n->name && strequal(n->name, _data.nodetest)) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - case nodetest_all: - if (type == node_element) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - case nodetest_all_in_namespace: - if (type == node_element && n->name && starts_with(n->name, _data.nodetest)) - { - ns.push_back(xml_node(n), alloc); - return true; - } - break; - - default: - assert(false && "Unknown axis"); // unreachable - } - - return false; - } - - template void step_fill(xpath_node_set_raw& ns, xml_node_struct* n, xpath_allocator* alloc, bool once, T) - { - const axis_t axis = T::axis; - - switch (axis) - { - case axis_attribute: - { - for (xml_attribute_struct* a = n->first_attribute; a; a = a->next_attribute) - if (step_push(ns, a, n, alloc) & once) - return; - - break; - } - - case axis_child: - { - for (xml_node_struct* c = n->first_child; c; c = c->next_sibling) - if (step_push(ns, c, alloc) & once) - return; - - break; - } - - case axis_descendant: - case axis_descendant_or_self: - { - if (axis == axis_descendant_or_self) - if (step_push(ns, n, alloc) & once) - return; - - xml_node_struct* cur = n->first_child; - - while (cur) - { - if (step_push(ns, cur, alloc) & once) - return; - - if (cur->first_child) - cur = cur->first_child; - else - { - while (!cur->next_sibling) - { - cur = cur->parent; - - if (cur == n) return; - } - - cur = cur->next_sibling; - } - } - - break; - } - - case axis_following_sibling: - { - for (xml_node_struct* c = n->next_sibling; c; c = c->next_sibling) - if (step_push(ns, c, alloc) & once) - return; - - break; - } - - case axis_preceding_sibling: - { - for (xml_node_struct* c = n->prev_sibling_c; c->next_sibling; c = c->prev_sibling_c) - if (step_push(ns, c, alloc) & once) - return; - - break; - } - - case axis_following: - { - xml_node_struct* cur = n; - - // exit from this node so that we don't include descendants - while (!cur->next_sibling) - { - cur = cur->parent; - - if (!cur) return; - } - - cur = cur->next_sibling; - - while (cur) - { - if (step_push(ns, cur, alloc) & once) - return; - - if (cur->first_child) - cur = cur->first_child; - else - { - while (!cur->next_sibling) - { - cur = cur->parent; - - if (!cur) return; - } - - cur = cur->next_sibling; - } - } - - break; - } - - case axis_preceding: - { - xml_node_struct* cur = n; - - // exit from this node so that we don't include descendants - while (!cur->prev_sibling_c->next_sibling) - { - cur = cur->parent; - - if (!cur) return; - } - - cur = cur->prev_sibling_c; - - while (cur) - { - if (cur->first_child) - cur = cur->first_child->prev_sibling_c; - else - { - // leaf node, can't be ancestor - if (step_push(ns, cur, alloc) & once) - return; - - while (!cur->prev_sibling_c->next_sibling) - { - cur = cur->parent; - - if (!cur) return; - - if (!node_is_ancestor(cur, n)) - if (step_push(ns, cur, alloc) & once) - return; - } - - cur = cur->prev_sibling_c; - } - } - - break; - } - - case axis_ancestor: - case axis_ancestor_or_self: - { - if (axis == axis_ancestor_or_self) - if (step_push(ns, n, alloc) & once) - return; - - xml_node_struct* cur = n->parent; - - while (cur) - { - if (step_push(ns, cur, alloc) & once) - return; - - cur = cur->parent; - } - - break; - } - - case axis_self: - { - step_push(ns, n, alloc); - - break; - } - - case axis_parent: - { - if (n->parent) - step_push(ns, n->parent, alloc); - - break; - } - - default: - assert(false && "Unimplemented axis"); // unreachable - } - } - - template void step_fill(xpath_node_set_raw& ns, xml_attribute_struct* a, xml_node_struct* p, xpath_allocator* alloc, bool once, T v) - { - const axis_t axis = T::axis; - - switch (axis) - { - case axis_ancestor: - case axis_ancestor_or_self: - { - if (axis == axis_ancestor_or_self && _test == nodetest_type_node) // reject attributes based on principal node type test - if (step_push(ns, a, p, alloc) & once) - return; - - xml_node_struct* cur = p; - - while (cur) - { - if (step_push(ns, cur, alloc) & once) - return; - - cur = cur->parent; - } - - break; - } - - case axis_descendant_or_self: - case axis_self: - { - if (_test == nodetest_type_node) // reject attributes based on principal node type test - step_push(ns, a, p, alloc); - - break; - } - - case axis_following: - { - xml_node_struct* cur = p; - - while (cur) - { - if (cur->first_child) - cur = cur->first_child; - else - { - while (!cur->next_sibling) - { - cur = cur->parent; - - if (!cur) return; - } - - cur = cur->next_sibling; - } - - if (step_push(ns, cur, alloc) & once) - return; - } - - break; - } - - case axis_parent: - { - step_push(ns, p, alloc); - - break; - } - - case axis_preceding: - { - // preceding:: axis does not include attribute nodes and attribute ancestors (they are the same as parent's ancestors), so we can reuse node preceding - step_fill(ns, p, alloc, once, v); - break; - } - - default: - assert(false && "Unimplemented axis"); // unreachable - } - } - - template void step_fill(xpath_node_set_raw& ns, const xpath_node& xn, xpath_allocator* alloc, bool once, T v) - { - const axis_t axis = T::axis; - const bool axis_has_attributes = (axis == axis_ancestor || axis == axis_ancestor_or_self || axis == axis_descendant_or_self || axis == axis_following || axis == axis_parent || axis == axis_preceding || axis == axis_self); - - if (xn.node()) - step_fill(ns, xn.node().internal_object(), alloc, once, v); - else if (axis_has_attributes && xn.attribute() && xn.parent()) - step_fill(ns, xn.attribute().internal_object(), xn.parent().internal_object(), alloc, once, v); - } - - template xpath_node_set_raw step_do(const xpath_context& c, const xpath_stack& stack, nodeset_eval_t eval, T v) - { - const axis_t axis = T::axis; - const bool axis_reverse = (axis == axis_ancestor || axis == axis_ancestor_or_self || axis == axis_preceding || axis == axis_preceding_sibling); - const xpath_node_set::type_t axis_type = axis_reverse ? xpath_node_set::type_sorted_reverse : xpath_node_set::type_sorted; - - bool once = - (axis == axis_attribute && _test == nodetest_name) || - (!_right && eval_once(axis_type, eval)) || - // coverity[mixed_enums] - (_right && !_right->_next && _right->_test == predicate_constant_one); - - xpath_node_set_raw ns; - ns.set_type(axis_type); - - if (_left) - { - xpath_node_set_raw s = _left->eval_node_set(c, stack, nodeset_eval_all); - - // self axis preserves the original order - if (axis == axis_self) ns.set_type(s.type()); - - for (const xpath_node* it = s.begin(); it != s.end(); ++it) - { - size_t size = ns.size(); - - // in general, all axes generate elements in a particular order, but there is no order guarantee if axis is applied to two nodes - if (axis != axis_self && size != 0) ns.set_type(xpath_node_set::type_unsorted); - - step_fill(ns, *it, stack.result, once, v); - if (_right) apply_predicates(ns, size, stack, eval); - } - } - else - { - step_fill(ns, c.n, stack.result, once, v); - if (_right) apply_predicates(ns, 0, stack, eval); - } - - // child, attribute and self axes always generate unique set of nodes - // for other axis, if the set stayed sorted, it stayed unique because the traversal algorithms do not visit the same node twice - if (axis != axis_child && axis != axis_attribute && axis != axis_self && ns.type() == xpath_node_set::type_unsorted) - ns.remove_duplicates(stack.temp); - - return ns; - } - - public: - xpath_ast_node(ast_type_t type, xpath_value_type rettype_, const char_t* value): - _type(static_cast(type)), _rettype(static_cast(rettype_)), _axis(0), _test(0), _left(0), _right(0), _next(0) - { - assert(type == ast_string_constant); - _data.string = value; - } - - xpath_ast_node(ast_type_t type, xpath_value_type rettype_, double value): - _type(static_cast(type)), _rettype(static_cast(rettype_)), _axis(0), _test(0), _left(0), _right(0), _next(0) - { - assert(type == ast_number_constant); - _data.number = value; - } - - xpath_ast_node(ast_type_t type, xpath_value_type rettype_, xpath_variable* value): - _type(static_cast(type)), _rettype(static_cast(rettype_)), _axis(0), _test(0), _left(0), _right(0), _next(0) - { - assert(type == ast_variable); - _data.variable = value; - } - - xpath_ast_node(ast_type_t type, xpath_value_type rettype_, xpath_ast_node* left = 0, xpath_ast_node* right = 0): - _type(static_cast(type)), _rettype(static_cast(rettype_)), _axis(0), _test(0), _left(left), _right(right), _next(0) - { - } - - xpath_ast_node(ast_type_t type, xpath_ast_node* left, axis_t axis, nodetest_t test, const char_t* contents): - _type(static_cast(type)), _rettype(xpath_type_node_set), _axis(static_cast(axis)), _test(static_cast(test)), _left(left), _right(0), _next(0) - { - assert(type == ast_step); - _data.nodetest = contents; - } - - xpath_ast_node(ast_type_t type, xpath_ast_node* left, xpath_ast_node* right, predicate_t test): - _type(static_cast(type)), _rettype(xpath_type_node_set), _axis(0), _test(static_cast(test)), _left(left), _right(right), _next(0) - { - assert(type == ast_filter || type == ast_predicate); - } - - void set_next(xpath_ast_node* value) - { - _next = value; - } - - void set_right(xpath_ast_node* value) - { - _right = value; - } - - bool eval_boolean(const xpath_context& c, const xpath_stack& stack) - { - switch (_type) - { - case ast_op_or: - return _left->eval_boolean(c, stack) || _right->eval_boolean(c, stack); - - case ast_op_and: - return _left->eval_boolean(c, stack) && _right->eval_boolean(c, stack); - - case ast_op_equal: - return compare_eq(_left, _right, c, stack, equal_to()); - - case ast_op_not_equal: - return compare_eq(_left, _right, c, stack, not_equal_to()); - - case ast_op_less: - return compare_rel(_left, _right, c, stack, less()); - - case ast_op_greater: - return compare_rel(_right, _left, c, stack, less()); - - case ast_op_less_or_equal: - return compare_rel(_left, _right, c, stack, less_equal()); - - case ast_op_greater_or_equal: - return compare_rel(_right, _left, c, stack, less_equal()); - - case ast_func_starts_with: - { - xpath_allocator_capture cr(stack.result); - - xpath_string lr = _left->eval_string(c, stack); - xpath_string rr = _right->eval_string(c, stack); - - return starts_with(lr.c_str(), rr.c_str()); - } - - case ast_func_contains: - { - xpath_allocator_capture cr(stack.result); - - xpath_string lr = _left->eval_string(c, stack); - xpath_string rr = _right->eval_string(c, stack); - - return find_substring(lr.c_str(), rr.c_str()) != 0; - } - - case ast_func_boolean: - return _left->eval_boolean(c, stack); - - case ast_func_not: - return !_left->eval_boolean(c, stack); - - case ast_func_true: - return true; - - case ast_func_false: - return false; - - case ast_func_lang: - { - if (c.n.attribute()) return false; - - xpath_allocator_capture cr(stack.result); - - xpath_string lang = _left->eval_string(c, stack); - - for (xml_node n = c.n.node(); n; n = n.parent()) - { - xml_attribute a = n.attribute(PUGIXML_TEXT("xml:lang")); - - if (a) - { - const char_t* value = a.value(); - - // strnicmp / strncasecmp is not portable - for (const char_t* lit = lang.c_str(); *lit; ++lit) - { - if (tolower_ascii(*lit) != tolower_ascii(*value)) return false; - ++value; - } - - return *value == 0 || *value == '-'; - } - } - - return false; - } - - case ast_opt_compare_attribute: - { - const char_t* value = (_right->_type == ast_string_constant) ? _right->_data.string : _right->_data.variable->get_string(); - - xml_attribute attr = c.n.node().attribute(_left->_data.nodetest); - - return attr && strequal(attr.value(), value) && is_xpath_attribute(attr.name()); - } - - case ast_variable: - { - assert(_rettype == _data.variable->type()); - - if (_rettype == xpath_type_boolean) - return _data.variable->get_boolean(); - - // variable needs to be converted to the correct type, this is handled by the fallthrough block below - break; - } - - default: - ; - } - - // none of the ast types that return the value directly matched, we need to perform type conversion - switch (_rettype) - { - case xpath_type_number: - return convert_number_to_boolean(eval_number(c, stack)); - - case xpath_type_string: - { - xpath_allocator_capture cr(stack.result); - - return !eval_string(c, stack).empty(); - } - - case xpath_type_node_set: - { - xpath_allocator_capture cr(stack.result); - - return !eval_node_set(c, stack, nodeset_eval_any).empty(); - } - - default: - assert(false && "Wrong expression for return type boolean"); // unreachable - return false; - } - } - - double eval_number(const xpath_context& c, const xpath_stack& stack) - { - switch (_type) - { - case ast_op_add: - return _left->eval_number(c, stack) + _right->eval_number(c, stack); - - case ast_op_subtract: - return _left->eval_number(c, stack) - _right->eval_number(c, stack); - - case ast_op_multiply: - return _left->eval_number(c, stack) * _right->eval_number(c, stack); - - case ast_op_divide: - return _left->eval_number(c, stack) / _right->eval_number(c, stack); - - case ast_op_mod: - return fmod(_left->eval_number(c, stack), _right->eval_number(c, stack)); - - case ast_op_negate: - return -_left->eval_number(c, stack); - - case ast_number_constant: - return _data.number; - - case ast_func_last: - return static_cast(c.size); - - case ast_func_position: - return static_cast(c.position); - - case ast_func_count: - { - xpath_allocator_capture cr(stack.result); - - return static_cast(_left->eval_node_set(c, stack, nodeset_eval_all).size()); - } - - case ast_func_string_length_0: - { - xpath_allocator_capture cr(stack.result); - - return static_cast(string_value(c.n, stack.result).length()); - } - - case ast_func_string_length_1: - { - xpath_allocator_capture cr(stack.result); - - return static_cast(_left->eval_string(c, stack).length()); - } - - case ast_func_number_0: - { - xpath_allocator_capture cr(stack.result); - - return convert_string_to_number(string_value(c.n, stack.result).c_str()); - } - - case ast_func_number_1: - return _left->eval_number(c, stack); - - case ast_func_sum: - { - xpath_allocator_capture cr(stack.result); - - double r = 0; - - xpath_node_set_raw ns = _left->eval_node_set(c, stack, nodeset_eval_all); - - for (const xpath_node* it = ns.begin(); it != ns.end(); ++it) - { - xpath_allocator_capture cri(stack.result); - - r += convert_string_to_number(string_value(*it, stack.result).c_str()); - } - - return r; - } - - case ast_func_floor: - { - double r = _left->eval_number(c, stack); - - return r == r ? floor(r) : r; - } - - case ast_func_ceiling: - { - double r = _left->eval_number(c, stack); - - return r == r ? ceil(r) : r; - } - - case ast_func_round: - return round_nearest_nzero(_left->eval_number(c, stack)); - - case ast_variable: - { - assert(_rettype == _data.variable->type()); - - if (_rettype == xpath_type_number) - return _data.variable->get_number(); - - // variable needs to be converted to the correct type, this is handled by the fallthrough block below - break; - } - - default: - ; - } - - // none of the ast types that return the value directly matched, we need to perform type conversion - switch (_rettype) - { - case xpath_type_boolean: - return eval_boolean(c, stack) ? 1 : 0; - - case xpath_type_string: - { - xpath_allocator_capture cr(stack.result); - - return convert_string_to_number(eval_string(c, stack).c_str()); - } - - case xpath_type_node_set: - { - xpath_allocator_capture cr(stack.result); - - return convert_string_to_number(eval_string(c, stack).c_str()); - } - - default: - assert(false && "Wrong expression for return type number"); // unreachable - return 0; - } - } - - xpath_string eval_string_concat(const xpath_context& c, const xpath_stack& stack) - { - assert(_type == ast_func_concat); - - xpath_allocator_capture ct(stack.temp); - - // count the string number - size_t count = 1; - for (xpath_ast_node* nc = _right; nc; nc = nc->_next) count++; - - // allocate a buffer for temporary string objects - xpath_string* buffer = static_cast(stack.temp->allocate(count * sizeof(xpath_string))); - if (!buffer) return xpath_string(); - - // evaluate all strings to temporary stack - xpath_stack swapped_stack = {stack.temp, stack.result}; - - buffer[0] = _left->eval_string(c, swapped_stack); - - size_t pos = 1; - for (xpath_ast_node* n = _right; n; n = n->_next, ++pos) buffer[pos] = n->eval_string(c, swapped_stack); - assert(pos == count); - - // get total length - size_t length = 0; - for (size_t i = 0; i < count; ++i) length += buffer[i].length(); - - // create final string - char_t* result = static_cast(stack.result->allocate((length + 1) * sizeof(char_t))); - if (!result) return xpath_string(); - - char_t* ri = result; - - for (size_t j = 0; j < count; ++j) - for (const char_t* bi = buffer[j].c_str(); *bi; ++bi) - *ri++ = *bi; - - *ri = 0; - - return xpath_string::from_heap_preallocated(result, ri); - } - - xpath_string eval_string(const xpath_context& c, const xpath_stack& stack) - { - switch (_type) - { - case ast_string_constant: - return xpath_string::from_const(_data.string); - - case ast_func_local_name_0: - { - xpath_node na = c.n; - - return xpath_string::from_const(local_name(na)); - } - - case ast_func_local_name_1: - { - xpath_allocator_capture cr(stack.result); - - xpath_node_set_raw ns = _left->eval_node_set(c, stack, nodeset_eval_first); - xpath_node na = ns.first(); - - return xpath_string::from_const(local_name(na)); - } - - case ast_func_name_0: - { - xpath_node na = c.n; - - return xpath_string::from_const(qualified_name(na)); - } - - case ast_func_name_1: - { - xpath_allocator_capture cr(stack.result); - - xpath_node_set_raw ns = _left->eval_node_set(c, stack, nodeset_eval_first); - xpath_node na = ns.first(); - - return xpath_string::from_const(qualified_name(na)); - } - - case ast_func_namespace_uri_0: - { - xpath_node na = c.n; - - return xpath_string::from_const(namespace_uri(na)); - } - - case ast_func_namespace_uri_1: - { - xpath_allocator_capture cr(stack.result); - - xpath_node_set_raw ns = _left->eval_node_set(c, stack, nodeset_eval_first); - xpath_node na = ns.first(); - - return xpath_string::from_const(namespace_uri(na)); - } - - case ast_func_string_0: - return string_value(c.n, stack.result); - - case ast_func_string_1: - return _left->eval_string(c, stack); - - case ast_func_concat: - return eval_string_concat(c, stack); - - case ast_func_substring_before: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_string s = _left->eval_string(c, swapped_stack); - xpath_string p = _right->eval_string(c, swapped_stack); - - const char_t* pos = find_substring(s.c_str(), p.c_str()); - - return pos ? xpath_string::from_heap(s.c_str(), pos, stack.result) : xpath_string(); - } - - case ast_func_substring_after: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_string s = _left->eval_string(c, swapped_stack); - xpath_string p = _right->eval_string(c, swapped_stack); - - const char_t* pos = find_substring(s.c_str(), p.c_str()); - if (!pos) return xpath_string(); - - const char_t* rbegin = pos + p.length(); - const char_t* rend = s.c_str() + s.length(); - - return s.uses_heap() ? xpath_string::from_heap(rbegin, rend, stack.result) : xpath_string::from_const(rbegin); - } - - case ast_func_substring_2: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_string s = _left->eval_string(c, swapped_stack); - size_t s_length = s.length(); - - double first = round_nearest(_right->eval_number(c, stack)); - - if (is_nan(first)) return xpath_string(); // NaN - else if (first >= static_cast(s_length + 1)) return xpath_string(); - - size_t pos = first < 1 ? 1 : static_cast(first); - assert(1 <= pos && pos <= s_length + 1); - - const char_t* rbegin = s.c_str() + (pos - 1); - const char_t* rend = s.c_str() + s.length(); - - return s.uses_heap() ? xpath_string::from_heap(rbegin, rend, stack.result) : xpath_string::from_const(rbegin); - } - - case ast_func_substring_3: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_string s = _left->eval_string(c, swapped_stack); - size_t s_length = s.length(); - - double first = round_nearest(_right->eval_number(c, stack)); - double last = first + round_nearest(_right->_next->eval_number(c, stack)); - - if (is_nan(first) || is_nan(last)) return xpath_string(); - else if (first >= static_cast(s_length + 1)) return xpath_string(); - else if (first >= last) return xpath_string(); - else if (last < 1) return xpath_string(); - - size_t pos = first < 1 ? 1 : static_cast(first); - size_t end = last >= static_cast(s_length + 1) ? s_length + 1 : static_cast(last); - - assert(1 <= pos && pos <= end && end <= s_length + 1); - const char_t* rbegin = s.c_str() + (pos - 1); - const char_t* rend = s.c_str() + (end - 1); - - return (end == s_length + 1 && !s.uses_heap()) ? xpath_string::from_const(rbegin) : xpath_string::from_heap(rbegin, rend, stack.result); - } - - case ast_func_normalize_space_0: - { - xpath_string s = string_value(c.n, stack.result); - - char_t* begin = s.data(stack.result); - if (!begin) return xpath_string(); - - char_t* end = normalize_space(begin); - - return xpath_string::from_heap_preallocated(begin, end); - } - - case ast_func_normalize_space_1: - { - xpath_string s = _left->eval_string(c, stack); - - char_t* begin = s.data(stack.result); - if (!begin) return xpath_string(); - - char_t* end = normalize_space(begin); - - return xpath_string::from_heap_preallocated(begin, end); - } - - case ast_func_translate: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_string s = _left->eval_string(c, stack); - xpath_string from = _right->eval_string(c, swapped_stack); - xpath_string to = _right->_next->eval_string(c, swapped_stack); - - char_t* begin = s.data(stack.result); - if (!begin) return xpath_string(); - - char_t* end = translate(begin, from.c_str(), to.c_str(), to.length()); - - return xpath_string::from_heap_preallocated(begin, end); - } - - case ast_opt_translate_table: - { - xpath_string s = _left->eval_string(c, stack); - - char_t* begin = s.data(stack.result); - if (!begin) return xpath_string(); - - char_t* end = translate_table(begin, _data.table); - - return xpath_string::from_heap_preallocated(begin, end); - } - - case ast_variable: - { - assert(_rettype == _data.variable->type()); - - if (_rettype == xpath_type_string) - return xpath_string::from_const(_data.variable->get_string()); - - // variable needs to be converted to the correct type, this is handled by the fallthrough block below - break; - } - - default: - ; - } - - // none of the ast types that return the value directly matched, we need to perform type conversion - switch (_rettype) - { - case xpath_type_boolean: - return xpath_string::from_const(eval_boolean(c, stack) ? PUGIXML_TEXT("true") : PUGIXML_TEXT("false")); - - case xpath_type_number: - return convert_number_to_string(eval_number(c, stack), stack.result); - - case xpath_type_node_set: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_node_set_raw ns = eval_node_set(c, swapped_stack, nodeset_eval_first); - return ns.empty() ? xpath_string() : string_value(ns.first(), stack.result); - } - - default: - assert(false && "Wrong expression for return type string"); // unreachable - return xpath_string(); - } - } - - xpath_node_set_raw eval_node_set(const xpath_context& c, const xpath_stack& stack, nodeset_eval_t eval) - { - switch (_type) - { - case ast_op_union: - { - xpath_allocator_capture cr(stack.temp); - - xpath_stack swapped_stack = {stack.temp, stack.result}; - - xpath_node_set_raw ls = _left->eval_node_set(c, stack, eval); - xpath_node_set_raw rs = _right->eval_node_set(c, swapped_stack, eval); - - // we can optimize merging two sorted sets, but this is a very rare operation, so don't bother - ls.set_type(xpath_node_set::type_unsorted); - - ls.append(rs.begin(), rs.end(), stack.result); - ls.remove_duplicates(stack.temp); - - return ls; - } - - case ast_filter: - { - xpath_node_set_raw set = _left->eval_node_set(c, stack, _test == predicate_constant_one ? nodeset_eval_first : nodeset_eval_all); - - // either expression is a number or it contains position() call; sort by document order - if (_test != predicate_posinv) set.sort_do(); - - bool once = eval_once(set.type(), eval); - - apply_predicate(set, 0, stack, once); - - return set; - } - - case ast_func_id: - return xpath_node_set_raw(); - - case ast_step: - { - switch (_axis) - { - case axis_ancestor: - return step_do(c, stack, eval, axis_to_type()); - - case axis_ancestor_or_self: - return step_do(c, stack, eval, axis_to_type()); - - case axis_attribute: - return step_do(c, stack, eval, axis_to_type()); - - case axis_child: - return step_do(c, stack, eval, axis_to_type()); - - case axis_descendant: - return step_do(c, stack, eval, axis_to_type()); - - case axis_descendant_or_self: - return step_do(c, stack, eval, axis_to_type()); - - case axis_following: - return step_do(c, stack, eval, axis_to_type()); - - case axis_following_sibling: - return step_do(c, stack, eval, axis_to_type()); - - case axis_namespace: - // namespaced axis is not supported - return xpath_node_set_raw(); - - case axis_parent: - return step_do(c, stack, eval, axis_to_type()); - - case axis_preceding: - return step_do(c, stack, eval, axis_to_type()); - - case axis_preceding_sibling: - return step_do(c, stack, eval, axis_to_type()); - - case axis_self: - return step_do(c, stack, eval, axis_to_type()); - - default: - assert(false && "Unknown axis"); // unreachable - return xpath_node_set_raw(); - } - } - - case ast_step_root: - { - assert(!_right); // root step can't have any predicates - - xpath_node_set_raw ns; - - ns.set_type(xpath_node_set::type_sorted); - - if (c.n.node()) ns.push_back(c.n.node().root(), stack.result); - else if (c.n.attribute()) ns.push_back(c.n.parent().root(), stack.result); - - return ns; - } - - case ast_variable: - { - assert(_rettype == _data.variable->type()); - - if (_rettype == xpath_type_node_set) - { - const xpath_node_set& s = _data.variable->get_node_set(); - - xpath_node_set_raw ns; - - ns.set_type(s.type()); - ns.append(s.begin(), s.end(), stack.result); - - return ns; - } - - // variable needs to be converted to the correct type, this is handled by the fallthrough block below - break; - } - - default: - ; - } - - // none of the ast types that return the value directly matched, but conversions to node set are invalid - assert(false && "Wrong expression for return type node set"); // unreachable - return xpath_node_set_raw(); - } - - void optimize(xpath_allocator* alloc) - { - if (_left) - _left->optimize(alloc); - - if (_right) - _right->optimize(alloc); - - if (_next) - _next->optimize(alloc); - - // coverity[var_deref_model] - optimize_self(alloc); - } - - void optimize_self(xpath_allocator* alloc) - { - // Rewrite [position()=expr] with [expr] - // Note that this step has to go before classification to recognize [position()=1] - if ((_type == ast_filter || _type == ast_predicate) && - _right && // workaround for clang static analyzer (_right is never null for ast_filter/ast_predicate) - _right->_type == ast_op_equal && _right->_left->_type == ast_func_position && _right->_right->_rettype == xpath_type_number) - { - _right = _right->_right; - } - - // Classify filter/predicate ops to perform various optimizations during evaluation - if ((_type == ast_filter || _type == ast_predicate) && _right) // workaround for clang static analyzer (_right is never null for ast_filter/ast_predicate) - { - assert(_test == predicate_default); - - if (_right->_type == ast_number_constant && _right->_data.number == 1.0) - _test = predicate_constant_one; - else if (_right->_rettype == xpath_type_number && (_right->_type == ast_number_constant || _right->_type == ast_variable || _right->_type == ast_func_last)) - _test = predicate_constant; - else if (_right->_rettype != xpath_type_number && _right->is_posinv_expr()) - _test = predicate_posinv; - } - - // Rewrite descendant-or-self::node()/child::foo with descendant::foo - // The former is a full form of //foo, the latter is much faster since it executes the node test immediately - // Do a similar kind of rewrite for self/descendant/descendant-or-self axes - // Note that we only rewrite positionally invariant steps (//foo[1] != /descendant::foo[1]) - if (_type == ast_step && (_axis == axis_child || _axis == axis_self || _axis == axis_descendant || _axis == axis_descendant_or_self) && - _left && _left->_type == ast_step && _left->_axis == axis_descendant_or_self && _left->_test == nodetest_type_node && !_left->_right && - is_posinv_step()) - { - if (_axis == axis_child || _axis == axis_descendant) - _axis = axis_descendant; - else - _axis = axis_descendant_or_self; - - _left = _left->_left; - } - - // Use optimized lookup table implementation for translate() with constant arguments - if (_type == ast_func_translate && - _right && // workaround for clang static analyzer (_right is never null for ast_func_translate) - _right->_type == ast_string_constant && _right->_next->_type == ast_string_constant) - { - unsigned char* table = translate_table_generate(alloc, _right->_data.string, _right->_next->_data.string); - - if (table) - { - _type = ast_opt_translate_table; - _data.table = table; - } - } - - // Use optimized path for @attr = 'value' or @attr = $value - if (_type == ast_op_equal && - _left && _right && // workaround for clang static analyzer and Coverity (_left and _right are never null for ast_op_equal) - // coverity[mixed_enums] - _left->_type == ast_step && _left->_axis == axis_attribute && _left->_test == nodetest_name && !_left->_left && !_left->_right && - (_right->_type == ast_string_constant || (_right->_type == ast_variable && _right->_rettype == xpath_type_string))) - { - _type = ast_opt_compare_attribute; - } - } - - bool is_posinv_expr() const - { - switch (_type) - { - case ast_func_position: - case ast_func_last: - return false; - - case ast_string_constant: - case ast_number_constant: - case ast_variable: - return true; - - case ast_step: - case ast_step_root: - return true; - - case ast_predicate: - case ast_filter: - return true; - - default: - if (_left && !_left->is_posinv_expr()) return false; - - for (xpath_ast_node* n = _right; n; n = n->_next) - if (!n->is_posinv_expr()) return false; - - return true; - } - } - - bool is_posinv_step() const - { - assert(_type == ast_step); - - for (xpath_ast_node* n = _right; n; n = n->_next) - { - assert(n->_type == ast_predicate); - - if (n->_test != predicate_posinv) - return false; - } - - return true; - } - - xpath_value_type rettype() const - { - return static_cast(_rettype); - } - }; - - struct xpath_parser - { - xpath_allocator* _alloc; - xpath_lexer _lexer; - - const char_t* _query; - xpath_variable_set* _variables; - - xpath_parse_result* _result; - - char_t _scratch[32]; - - xpath_ast_node* error(const char* message) - { - _result->error = message; - _result->offset = _lexer.current_pos() - _query; - - return 0; - } - - xpath_ast_node* error_oom() - { - assert(_alloc->_error); - *_alloc->_error = true; - - return 0; - } - - void* alloc_node() - { - return _alloc->allocate(sizeof(xpath_ast_node)); - } - - xpath_ast_node* alloc_node(ast_type_t type, xpath_value_type rettype, const char_t* value) - { - void* memory = alloc_node(); - return memory ? new (memory) xpath_ast_node(type, rettype, value) : 0; - } - - xpath_ast_node* alloc_node(ast_type_t type, xpath_value_type rettype, double value) - { - void* memory = alloc_node(); - return memory ? new (memory) xpath_ast_node(type, rettype, value) : 0; - } - - xpath_ast_node* alloc_node(ast_type_t type, xpath_value_type rettype, xpath_variable* value) - { - void* memory = alloc_node(); - return memory ? new (memory) xpath_ast_node(type, rettype, value) : 0; - } - - xpath_ast_node* alloc_node(ast_type_t type, xpath_value_type rettype, xpath_ast_node* left = 0, xpath_ast_node* right = 0) - { - void* memory = alloc_node(); - return memory ? new (memory) xpath_ast_node(type, rettype, left, right) : 0; - } - - xpath_ast_node* alloc_node(ast_type_t type, xpath_ast_node* left, axis_t axis, nodetest_t test, const char_t* contents) - { - void* memory = alloc_node(); - return memory ? new (memory) xpath_ast_node(type, left, axis, test, contents) : 0; - } - - xpath_ast_node* alloc_node(ast_type_t type, xpath_ast_node* left, xpath_ast_node* right, predicate_t test) - { - void* memory = alloc_node(); - return memory ? new (memory) xpath_ast_node(type, left, right, test) : 0; - } - - const char_t* alloc_string(const xpath_lexer_string& value) - { - if (!value.begin) - return PUGIXML_TEXT(""); - - size_t length = static_cast(value.end - value.begin); - - char_t* c = static_cast(_alloc->allocate((length + 1) * sizeof(char_t))); - if (!c) return 0; - - memcpy(c, value.begin, length * sizeof(char_t)); - c[length] = 0; - - return c; - } - - xpath_ast_node* parse_function(const xpath_lexer_string& name, size_t argc, xpath_ast_node* args[2]) - { - switch (name.begin[0]) - { - case 'b': - if (name == PUGIXML_TEXT("boolean") && argc == 1) - return alloc_node(ast_func_boolean, xpath_type_boolean, args[0]); - - break; - - case 'c': - if (name == PUGIXML_TEXT("count") && argc == 1) - { - if (args[0]->rettype() != xpath_type_node_set) return error("Function has to be applied to node set"); - return alloc_node(ast_func_count, xpath_type_number, args[0]); - } - else if (name == PUGIXML_TEXT("contains") && argc == 2) - return alloc_node(ast_func_contains, xpath_type_boolean, args[0], args[1]); - else if (name == PUGIXML_TEXT("concat") && argc >= 2) - return alloc_node(ast_func_concat, xpath_type_string, args[0], args[1]); - else if (name == PUGIXML_TEXT("ceiling") && argc == 1) - return alloc_node(ast_func_ceiling, xpath_type_number, args[0]); - - break; - - case 'f': - if (name == PUGIXML_TEXT("false") && argc == 0) - return alloc_node(ast_func_false, xpath_type_boolean); - else if (name == PUGIXML_TEXT("floor") && argc == 1) - return alloc_node(ast_func_floor, xpath_type_number, args[0]); - - break; - - case 'i': - if (name == PUGIXML_TEXT("id") && argc == 1) - return alloc_node(ast_func_id, xpath_type_node_set, args[0]); - - break; - - case 'l': - if (name == PUGIXML_TEXT("last") && argc == 0) - return alloc_node(ast_func_last, xpath_type_number); - else if (name == PUGIXML_TEXT("lang") && argc == 1) - return alloc_node(ast_func_lang, xpath_type_boolean, args[0]); - else if (name == PUGIXML_TEXT("local-name") && argc <= 1) - { - if (argc == 1 && args[0]->rettype() != xpath_type_node_set) return error("Function has to be applied to node set"); - return alloc_node(argc == 0 ? ast_func_local_name_0 : ast_func_local_name_1, xpath_type_string, args[0]); - } - - break; - - case 'n': - if (name == PUGIXML_TEXT("name") && argc <= 1) - { - if (argc == 1 && args[0]->rettype() != xpath_type_node_set) return error("Function has to be applied to node set"); - return alloc_node(argc == 0 ? ast_func_name_0 : ast_func_name_1, xpath_type_string, args[0]); - } - else if (name == PUGIXML_TEXT("namespace-uri") && argc <= 1) - { - if (argc == 1 && args[0]->rettype() != xpath_type_node_set) return error("Function has to be applied to node set"); - return alloc_node(argc == 0 ? ast_func_namespace_uri_0 : ast_func_namespace_uri_1, xpath_type_string, args[0]); - } - else if (name == PUGIXML_TEXT("normalize-space") && argc <= 1) - return alloc_node(argc == 0 ? ast_func_normalize_space_0 : ast_func_normalize_space_1, xpath_type_string, args[0], args[1]); - else if (name == PUGIXML_TEXT("not") && argc == 1) - return alloc_node(ast_func_not, xpath_type_boolean, args[0]); - else if (name == PUGIXML_TEXT("number") && argc <= 1) - return alloc_node(argc == 0 ? ast_func_number_0 : ast_func_number_1, xpath_type_number, args[0]); - - break; - - case 'p': - if (name == PUGIXML_TEXT("position") && argc == 0) - return alloc_node(ast_func_position, xpath_type_number); - - break; - - case 'r': - if (name == PUGIXML_TEXT("round") && argc == 1) - return alloc_node(ast_func_round, xpath_type_number, args[0]); - - break; - - case 's': - if (name == PUGIXML_TEXT("string") && argc <= 1) - return alloc_node(argc == 0 ? ast_func_string_0 : ast_func_string_1, xpath_type_string, args[0]); - else if (name == PUGIXML_TEXT("string-length") && argc <= 1) - return alloc_node(argc == 0 ? ast_func_string_length_0 : ast_func_string_length_1, xpath_type_number, args[0]); - else if (name == PUGIXML_TEXT("starts-with") && argc == 2) - return alloc_node(ast_func_starts_with, xpath_type_boolean, args[0], args[1]); - else if (name == PUGIXML_TEXT("substring-before") && argc == 2) - return alloc_node(ast_func_substring_before, xpath_type_string, args[0], args[1]); - else if (name == PUGIXML_TEXT("substring-after") && argc == 2) - return alloc_node(ast_func_substring_after, xpath_type_string, args[0], args[1]); - else if (name == PUGIXML_TEXT("substring") && (argc == 2 || argc == 3)) - return alloc_node(argc == 2 ? ast_func_substring_2 : ast_func_substring_3, xpath_type_string, args[0], args[1]); - else if (name == PUGIXML_TEXT("sum") && argc == 1) - { - if (args[0]->rettype() != xpath_type_node_set) return error("Function has to be applied to node set"); - return alloc_node(ast_func_sum, xpath_type_number, args[0]); - } - - break; - - case 't': - if (name == PUGIXML_TEXT("translate") && argc == 3) - return alloc_node(ast_func_translate, xpath_type_string, args[0], args[1]); - else if (name == PUGIXML_TEXT("true") && argc == 0) - return alloc_node(ast_func_true, xpath_type_boolean); - - break; - - default: - break; - } - - return error("Unrecognized function or wrong parameter count"); - } - - axis_t parse_axis_name(const xpath_lexer_string& name, bool& specified) - { - specified = true; - - switch (name.begin[0]) - { - case 'a': - if (name == PUGIXML_TEXT("ancestor")) - return axis_ancestor; - else if (name == PUGIXML_TEXT("ancestor-or-self")) - return axis_ancestor_or_self; - else if (name == PUGIXML_TEXT("attribute")) - return axis_attribute; - - break; - - case 'c': - if (name == PUGIXML_TEXT("child")) - return axis_child; - - break; - - case 'd': - if (name == PUGIXML_TEXT("descendant")) - return axis_descendant; - else if (name == PUGIXML_TEXT("descendant-or-self")) - return axis_descendant_or_self; - - break; - - case 'f': - if (name == PUGIXML_TEXT("following")) - return axis_following; - else if (name == PUGIXML_TEXT("following-sibling")) - return axis_following_sibling; - - break; - - case 'n': - if (name == PUGIXML_TEXT("namespace")) - return axis_namespace; - - break; - - case 'p': - if (name == PUGIXML_TEXT("parent")) - return axis_parent; - else if (name == PUGIXML_TEXT("preceding")) - return axis_preceding; - else if (name == PUGIXML_TEXT("preceding-sibling")) - return axis_preceding_sibling; - - break; - - case 's': - if (name == PUGIXML_TEXT("self")) - return axis_self; - - break; - - default: - break; - } - - specified = false; - return axis_child; - } - - nodetest_t parse_node_test_type(const xpath_lexer_string& name) - { - switch (name.begin[0]) - { - case 'c': - if (name == PUGIXML_TEXT("comment")) - return nodetest_type_comment; - - break; - - case 'n': - if (name == PUGIXML_TEXT("node")) - return nodetest_type_node; - - break; - - case 'p': - if (name == PUGIXML_TEXT("processing-instruction")) - return nodetest_type_pi; - - break; - - case 't': - if (name == PUGIXML_TEXT("text")) - return nodetest_type_text; - - break; - - default: - break; - } - - return nodetest_none; - } - - // PrimaryExpr ::= VariableReference | '(' Expr ')' | Literal | Number | FunctionCall - xpath_ast_node* parse_primary_expression() - { - switch (_lexer.current()) - { - case lex_var_ref: - { - xpath_lexer_string name = _lexer.contents(); - - if (!_variables) - return error("Unknown variable: variable set is not provided"); - - xpath_variable* var = 0; - if (!get_variable_scratch(_scratch, _variables, name.begin, name.end, &var)) - return error_oom(); - - if (!var) - return error("Unknown variable: variable set does not contain the given name"); - - _lexer.next(); - - return alloc_node(ast_variable, var->type(), var); - } - - case lex_open_brace: - { - _lexer.next(); - - xpath_ast_node* n = parse_expression(); - if (!n) return 0; - - if (_lexer.current() != lex_close_brace) - return error("Expected ')' to match an opening '('"); - - _lexer.next(); - - return n; - } - - case lex_quoted_string: - { - const char_t* value = alloc_string(_lexer.contents()); - if (!value) return 0; - - _lexer.next(); - - return alloc_node(ast_string_constant, xpath_type_string, value); - } - - case lex_number: - { - double value = 0; - - if (!convert_string_to_number_scratch(_scratch, _lexer.contents().begin, _lexer.contents().end, &value)) - return error_oom(); - - _lexer.next(); - - return alloc_node(ast_number_constant, xpath_type_number, value); - } - - case lex_string: - { - xpath_ast_node* args[2] = {0}; - size_t argc = 0; - - xpath_lexer_string function = _lexer.contents(); - _lexer.next(); - - xpath_ast_node* last_arg = 0; - - if (_lexer.current() != lex_open_brace) - return error("Unrecognized function call"); - _lexer.next(); - - while (_lexer.current() != lex_close_brace) - { - if (argc > 0) - { - if (_lexer.current() != lex_comma) - return error("No comma between function arguments"); - _lexer.next(); - } - - xpath_ast_node* n = parse_expression(); - if (!n) return 0; - - if (argc < 2) args[argc] = n; - else last_arg->set_next(n); - - argc++; - last_arg = n; - } - - _lexer.next(); - - return parse_function(function, argc, args); - } - - default: - return error("Unrecognizable primary expression"); - } - } - - // FilterExpr ::= PrimaryExpr | FilterExpr Predicate - // Predicate ::= '[' PredicateExpr ']' - // PredicateExpr ::= Expr - xpath_ast_node* parse_filter_expression() - { - xpath_ast_node* n = parse_primary_expression(); - if (!n) return 0; - - while (_lexer.current() == lex_open_square_brace) - { - _lexer.next(); - - if (n->rettype() != xpath_type_node_set) - return error("Predicate has to be applied to node set"); - - xpath_ast_node* expr = parse_expression(); - if (!expr) return 0; - - n = alloc_node(ast_filter, n, expr, predicate_default); - if (!n) return 0; - - if (_lexer.current() != lex_close_square_brace) - return error("Expected ']' to match an opening '['"); - - _lexer.next(); - } - - return n; - } - - // Step ::= AxisSpecifier NodeTest Predicate* | AbbreviatedStep - // AxisSpecifier ::= AxisName '::' | '@'? - // NodeTest ::= NameTest | NodeType '(' ')' | 'processing-instruction' '(' Literal ')' - // NameTest ::= '*' | NCName ':' '*' | QName - // AbbreviatedStep ::= '.' | '..' - xpath_ast_node* parse_step(xpath_ast_node* set) - { - if (set && set->rettype() != xpath_type_node_set) - return error("Step has to be applied to node set"); - - bool axis_specified = false; - axis_t axis = axis_child; // implied child axis - - if (_lexer.current() == lex_axis_attribute) - { - axis = axis_attribute; - axis_specified = true; - - _lexer.next(); - } - else if (_lexer.current() == lex_dot) - { - _lexer.next(); - - if (_lexer.current() == lex_open_square_brace) - return error("Predicates are not allowed after an abbreviated step"); - - return alloc_node(ast_step, set, axis_self, nodetest_type_node, 0); - } - else if (_lexer.current() == lex_double_dot) - { - _lexer.next(); - - if (_lexer.current() == lex_open_square_brace) - return error("Predicates are not allowed after an abbreviated step"); - - return alloc_node(ast_step, set, axis_parent, nodetest_type_node, 0); - } - - nodetest_t nt_type = nodetest_none; - xpath_lexer_string nt_name; - - if (_lexer.current() == lex_string) - { - // node name test - nt_name = _lexer.contents(); - _lexer.next(); - - // was it an axis name? - if (_lexer.current() == lex_double_colon) - { - // parse axis name - if (axis_specified) - return error("Two axis specifiers in one step"); - - axis = parse_axis_name(nt_name, axis_specified); - - if (!axis_specified) - return error("Unknown axis"); - - // read actual node test - _lexer.next(); - - if (_lexer.current() == lex_multiply) - { - nt_type = nodetest_all; - nt_name = xpath_lexer_string(); - _lexer.next(); - } - else if (_lexer.current() == lex_string) - { - nt_name = _lexer.contents(); - _lexer.next(); - } - else - { - return error("Unrecognized node test"); - } - } - - if (nt_type == nodetest_none) - { - // node type test or processing-instruction - if (_lexer.current() == lex_open_brace) - { - _lexer.next(); - - if (_lexer.current() == lex_close_brace) - { - _lexer.next(); - - nt_type = parse_node_test_type(nt_name); - - if (nt_type == nodetest_none) - return error("Unrecognized node type"); - - nt_name = xpath_lexer_string(); - } - else if (nt_name == PUGIXML_TEXT("processing-instruction")) - { - if (_lexer.current() != lex_quoted_string) - return error("Only literals are allowed as arguments to processing-instruction()"); - - nt_type = nodetest_pi; - nt_name = _lexer.contents(); - _lexer.next(); - - if (_lexer.current() != lex_close_brace) - return error("Unmatched brace near processing-instruction()"); - _lexer.next(); - } - else - { - return error("Unmatched brace near node type test"); - } - } - // QName or NCName:* - else - { - if (nt_name.end - nt_name.begin > 2 && nt_name.end[-2] == ':' && nt_name.end[-1] == '*') // NCName:* - { - nt_name.end--; // erase * - - nt_type = nodetest_all_in_namespace; - } - else - { - nt_type = nodetest_name; - } - } - } - } - else if (_lexer.current() == lex_multiply) - { - nt_type = nodetest_all; - _lexer.next(); - } - else - { - return error("Unrecognized node test"); - } - - const char_t* nt_name_copy = alloc_string(nt_name); - if (!nt_name_copy) return 0; - - xpath_ast_node* n = alloc_node(ast_step, set, axis, nt_type, nt_name_copy); - if (!n) return 0; - - xpath_ast_node* last = 0; - - while (_lexer.current() == lex_open_square_brace) - { - _lexer.next(); - - xpath_ast_node* expr = parse_expression(); - if (!expr) return 0; - - xpath_ast_node* pred = alloc_node(ast_predicate, 0, expr, predicate_default); - if (!pred) return 0; - - if (_lexer.current() != lex_close_square_brace) - return error("Expected ']' to match an opening '['"); - _lexer.next(); - - if (last) last->set_next(pred); - else n->set_right(pred); - - last = pred; - } - - return n; - } - - // RelativeLocationPath ::= Step | RelativeLocationPath '/' Step | RelativeLocationPath '//' Step - xpath_ast_node* parse_relative_location_path(xpath_ast_node* set) - { - xpath_ast_node* n = parse_step(set); - if (!n) return 0; - - while (_lexer.current() == lex_slash || _lexer.current() == lex_double_slash) - { - lexeme_t l = _lexer.current(); - _lexer.next(); - - if (l == lex_double_slash) - { - n = alloc_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); - if (!n) return 0; - } - - n = parse_step(n); - if (!n) return 0; - } - - return n; - } - - // LocationPath ::= RelativeLocationPath | AbsoluteLocationPath - // AbsoluteLocationPath ::= '/' RelativeLocationPath? | '//' RelativeLocationPath - xpath_ast_node* parse_location_path() - { - if (_lexer.current() == lex_slash) - { - _lexer.next(); - - xpath_ast_node* n = alloc_node(ast_step_root, xpath_type_node_set); - if (!n) return 0; - - // relative location path can start from axis_attribute, dot, double_dot, multiply and string lexemes; any other lexeme means standalone root path - lexeme_t l = _lexer.current(); - - if (l == lex_string || l == lex_axis_attribute || l == lex_dot || l == lex_double_dot || l == lex_multiply) - return parse_relative_location_path(n); - else - return n; - } - else if (_lexer.current() == lex_double_slash) - { - _lexer.next(); - - xpath_ast_node* n = alloc_node(ast_step_root, xpath_type_node_set); - if (!n) return 0; - - n = alloc_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); - if (!n) return 0; - - return parse_relative_location_path(n); - } - - // else clause moved outside of if because of bogus warning 'control may reach end of non-void function being inlined' in gcc 4.0.1 - return parse_relative_location_path(0); - } - - // PathExpr ::= LocationPath - // | FilterExpr - // | FilterExpr '/' RelativeLocationPath - // | FilterExpr '//' RelativeLocationPath - // UnionExpr ::= PathExpr | UnionExpr '|' PathExpr - // UnaryExpr ::= UnionExpr | '-' UnaryExpr - xpath_ast_node* parse_path_or_unary_expression() - { - // Clarification. - // PathExpr begins with either LocationPath or FilterExpr. - // FilterExpr begins with PrimaryExpr - // PrimaryExpr begins with '$' in case of it being a variable reference, - // '(' in case of it being an expression, string literal, number constant or - // function call. - if (_lexer.current() == lex_var_ref || _lexer.current() == lex_open_brace || - _lexer.current() == lex_quoted_string || _lexer.current() == lex_number || - _lexer.current() == lex_string) - { - if (_lexer.current() == lex_string) - { - // This is either a function call, or not - if not, we shall proceed with location path - const char_t* state = _lexer.state(); - - while (PUGI__IS_CHARTYPE(*state, ct_space)) ++state; - - if (*state != '(') - return parse_location_path(); - - // This looks like a function call; however this still can be a node-test. Check it. - if (parse_node_test_type(_lexer.contents()) != nodetest_none) - return parse_location_path(); - } - - xpath_ast_node* n = parse_filter_expression(); - if (!n) return 0; - - if (_lexer.current() == lex_slash || _lexer.current() == lex_double_slash) - { - lexeme_t l = _lexer.current(); - _lexer.next(); - - if (l == lex_double_slash) - { - if (n->rettype() != xpath_type_node_set) - return error("Step has to be applied to node set"); - - n = alloc_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0); - if (!n) return 0; - } - - // select from location path - return parse_relative_location_path(n); - } - - return n; - } - else if (_lexer.current() == lex_minus) - { - _lexer.next(); - - // precedence 7+ - only parses union expressions - xpath_ast_node* n = parse_expression(7); - if (!n) return 0; - - return alloc_node(ast_op_negate, xpath_type_number, n); - } - else - { - return parse_location_path(); - } - } - - struct binary_op_t - { - ast_type_t asttype; - xpath_value_type rettype; - int precedence; - - binary_op_t(): asttype(ast_unknown), rettype(xpath_type_none), precedence(0) - { - } - - binary_op_t(ast_type_t asttype_, xpath_value_type rettype_, int precedence_): asttype(asttype_), rettype(rettype_), precedence(precedence_) - { - } - - static binary_op_t parse(xpath_lexer& lexer) - { - switch (lexer.current()) - { - case lex_string: - if (lexer.contents() == PUGIXML_TEXT("or")) - return binary_op_t(ast_op_or, xpath_type_boolean, 1); - else if (lexer.contents() == PUGIXML_TEXT("and")) - return binary_op_t(ast_op_and, xpath_type_boolean, 2); - else if (lexer.contents() == PUGIXML_TEXT("div")) - return binary_op_t(ast_op_divide, xpath_type_number, 6); - else if (lexer.contents() == PUGIXML_TEXT("mod")) - return binary_op_t(ast_op_mod, xpath_type_number, 6); - else - return binary_op_t(); - - case lex_equal: - return binary_op_t(ast_op_equal, xpath_type_boolean, 3); - - case lex_not_equal: - return binary_op_t(ast_op_not_equal, xpath_type_boolean, 3); - - case lex_less: - return binary_op_t(ast_op_less, xpath_type_boolean, 4); - - case lex_greater: - return binary_op_t(ast_op_greater, xpath_type_boolean, 4); - - case lex_less_or_equal: - return binary_op_t(ast_op_less_or_equal, xpath_type_boolean, 4); - - case lex_greater_or_equal: - return binary_op_t(ast_op_greater_or_equal, xpath_type_boolean, 4); - - case lex_plus: - return binary_op_t(ast_op_add, xpath_type_number, 5); - - case lex_minus: - return binary_op_t(ast_op_subtract, xpath_type_number, 5); - - case lex_multiply: - return binary_op_t(ast_op_multiply, xpath_type_number, 6); - - case lex_union: - return binary_op_t(ast_op_union, xpath_type_node_set, 7); - - default: - return binary_op_t(); - } - } - }; - - xpath_ast_node* parse_expression_rec(xpath_ast_node* lhs, int limit) - { - binary_op_t op = binary_op_t::parse(_lexer); - - while (op.asttype != ast_unknown && op.precedence >= limit) - { - _lexer.next(); - - xpath_ast_node* rhs = parse_path_or_unary_expression(); - if (!rhs) return 0; - - binary_op_t nextop = binary_op_t::parse(_lexer); - - while (nextop.asttype != ast_unknown && nextop.precedence > op.precedence) - { - rhs = parse_expression_rec(rhs, nextop.precedence); - if (!rhs) return 0; - - nextop = binary_op_t::parse(_lexer); - } - - if (op.asttype == ast_op_union && (lhs->rettype() != xpath_type_node_set || rhs->rettype() != xpath_type_node_set)) - return error("Union operator has to be applied to node sets"); - - lhs = alloc_node(op.asttype, op.rettype, lhs, rhs); - if (!lhs) return 0; - - op = binary_op_t::parse(_lexer); - } - - return lhs; - } - - // Expr ::= OrExpr - // OrExpr ::= AndExpr | OrExpr 'or' AndExpr - // AndExpr ::= EqualityExpr | AndExpr 'and' EqualityExpr - // EqualityExpr ::= RelationalExpr - // | EqualityExpr '=' RelationalExpr - // | EqualityExpr '!=' RelationalExpr - // RelationalExpr ::= AdditiveExpr - // | RelationalExpr '<' AdditiveExpr - // | RelationalExpr '>' AdditiveExpr - // | RelationalExpr '<=' AdditiveExpr - // | RelationalExpr '>=' AdditiveExpr - // AdditiveExpr ::= MultiplicativeExpr - // | AdditiveExpr '+' MultiplicativeExpr - // | AdditiveExpr '-' MultiplicativeExpr - // MultiplicativeExpr ::= UnaryExpr - // | MultiplicativeExpr '*' UnaryExpr - // | MultiplicativeExpr 'div' UnaryExpr - // | MultiplicativeExpr 'mod' UnaryExpr - xpath_ast_node* parse_expression(int limit = 0) - { - xpath_ast_node* n = parse_path_or_unary_expression(); - if (!n) return 0; - - return parse_expression_rec(n, limit); - } - - xpath_parser(const char_t* query, xpath_variable_set* variables, xpath_allocator* alloc, xpath_parse_result* result): _alloc(alloc), _lexer(query), _query(query), _variables(variables), _result(result) - { - } - - xpath_ast_node* parse() - { - xpath_ast_node* n = parse_expression(); - if (!n) return 0; - - // check if there are unparsed tokens left - if (_lexer.current() != lex_eof) - return error("Incorrect query"); - - return n; - } - - static xpath_ast_node* parse(const char_t* query, xpath_variable_set* variables, xpath_allocator* alloc, xpath_parse_result* result) - { - xpath_parser parser(query, variables, alloc, result); - - return parser.parse(); - } - }; - - struct xpath_query_impl - { - static xpath_query_impl* create() - { - void* memory = xml_memory::allocate(sizeof(xpath_query_impl)); - if (!memory) return 0; - - return new (memory) xpath_query_impl(); - } - - static void destroy(xpath_query_impl* impl) - { - // free all allocated pages - impl->alloc.release(); - - // free allocator memory (with the first page) - xml_memory::deallocate(impl); - } - - xpath_query_impl(): root(0), alloc(&block, &oom), oom(false) - { - block.next = 0; - block.capacity = sizeof(block.data); - } - - xpath_ast_node* root; - xpath_allocator alloc; - xpath_memory_block block; - bool oom; - }; - - PUGI__FN impl::xpath_ast_node* evaluate_node_set_prepare(xpath_query_impl* impl) - { - if (!impl) return 0; - - if (impl->root->rettype() != xpath_type_node_set) - { - #ifdef PUGIXML_NO_EXCEPTIONS - return 0; - #else - xpath_parse_result res; - res.error = "Expression does not evaluate to node set"; - - throw xpath_exception(res); - #endif - } - - return impl->root; - } -PUGI__NS_END - -namespace pugi -{ -#ifndef PUGIXML_NO_EXCEPTIONS - PUGI__FN xpath_exception::xpath_exception(const xpath_parse_result& result_): _result(result_) - { - assert(_result.error); - } - - PUGI__FN const char* xpath_exception::what() const throw() - { - return _result.error; - } - - PUGI__FN const xpath_parse_result& xpath_exception::result() const - { - return _result; - } -#endif - - PUGI__FN xpath_node::xpath_node() - { - } - - PUGI__FN xpath_node::xpath_node(const xml_node& node_): _node(node_) - { - } - - PUGI__FN xpath_node::xpath_node(const xml_attribute& attribute_, const xml_node& parent_): _node(attribute_ ? parent_ : xml_node()), _attribute(attribute_) - { - } - - PUGI__FN xml_node xpath_node::node() const - { - return _attribute ? xml_node() : _node; - } - - PUGI__FN xml_attribute xpath_node::attribute() const - { - return _attribute; - } - - PUGI__FN xml_node xpath_node::parent() const - { - return _attribute ? _node : _node.parent(); - } - - PUGI__FN static void unspecified_bool_xpath_node(xpath_node***) - { - } - - PUGI__FN xpath_node::operator xpath_node::unspecified_bool_type() const - { - return (_node || _attribute) ? unspecified_bool_xpath_node : 0; - } - - PUGI__FN bool xpath_node::operator!() const - { - return !(_node || _attribute); - } - - PUGI__FN bool xpath_node::operator==(const xpath_node& n) const - { - return _node == n._node && _attribute == n._attribute; - } - - PUGI__FN bool xpath_node::operator!=(const xpath_node& n) const - { - return _node != n._node || _attribute != n._attribute; - } - -#ifdef __BORLANDC__ - PUGI__FN bool operator&&(const xpath_node& lhs, bool rhs) - { - return (bool)lhs && rhs; - } - - PUGI__FN bool operator||(const xpath_node& lhs, bool rhs) - { - return (bool)lhs || rhs; - } -#endif - - PUGI__FN void xpath_node_set::_assign(const_iterator begin_, const_iterator end_, type_t type_) - { - assert(begin_ <= end_); - - size_t size_ = static_cast(end_ - begin_); - - // use internal buffer for 0 or 1 elements, heap buffer otherwise - xpath_node* storage = (size_ <= 1) ? _storage : static_cast(impl::xml_memory::allocate(size_ * sizeof(xpath_node))); - - if (!storage) - { - #ifdef PUGIXML_NO_EXCEPTIONS - return; - #else - throw std::bad_alloc(); - #endif - } - - // deallocate old buffer - if (_begin != _storage) - impl::xml_memory::deallocate(_begin); - - // size check is necessary because for begin_ = end_ = nullptr, memcpy is UB - if (size_) - memcpy(storage, begin_, size_ * sizeof(xpath_node)); - - _begin = storage; - _end = storage + size_; - _type = type_; - } - -#ifdef PUGIXML_HAS_MOVE - PUGI__FN void xpath_node_set::_move(xpath_node_set& rhs) PUGIXML_NOEXCEPT - { - _type = rhs._type; - _storage[0] = rhs._storage[0]; - _begin = (rhs._begin == rhs._storage) ? _storage : rhs._begin; - _end = _begin + (rhs._end - rhs._begin); - - rhs._type = type_unsorted; - rhs._begin = rhs._storage; - rhs._end = rhs._storage; - } -#endif - - PUGI__FN xpath_node_set::xpath_node_set(): _type(type_unsorted), _begin(_storage), _end(_storage) - { - } - - PUGI__FN xpath_node_set::xpath_node_set(const_iterator begin_, const_iterator end_, type_t type_): _type(type_unsorted), _begin(_storage), _end(_storage) - { - _assign(begin_, end_, type_); - } - - PUGI__FN xpath_node_set::~xpath_node_set() - { - if (_begin != _storage) - impl::xml_memory::deallocate(_begin); - } - - PUGI__FN xpath_node_set::xpath_node_set(const xpath_node_set& ns): _type(type_unsorted), _begin(_storage), _end(_storage) - { - _assign(ns._begin, ns._end, ns._type); - } - - PUGI__FN xpath_node_set& xpath_node_set::operator=(const xpath_node_set& ns) - { - if (this == &ns) return *this; - - _assign(ns._begin, ns._end, ns._type); - - return *this; - } - -#ifdef PUGIXML_HAS_MOVE - PUGI__FN xpath_node_set::xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT: _type(type_unsorted), _begin(_storage), _end(_storage) - { - _move(rhs); - } - - PUGI__FN xpath_node_set& xpath_node_set::operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT - { - if (this == &rhs) return *this; - - if (_begin != _storage) - impl::xml_memory::deallocate(_begin); - - _move(rhs); - - return *this; - } -#endif - - PUGI__FN xpath_node_set::type_t xpath_node_set::type() const - { - return _type; - } - - PUGI__FN size_t xpath_node_set::size() const - { - return _end - _begin; - } - - PUGI__FN bool xpath_node_set::empty() const - { - return _begin == _end; - } - - PUGI__FN const xpath_node& xpath_node_set::operator[](size_t index) const - { - assert(index < size()); - return _begin[index]; - } - - PUGI__FN xpath_node_set::const_iterator xpath_node_set::begin() const - { - return _begin; - } - - PUGI__FN xpath_node_set::const_iterator xpath_node_set::end() const - { - return _end; - } - - PUGI__FN void xpath_node_set::sort(bool reverse) - { - _type = impl::xpath_sort(_begin, _end, _type, reverse); - } - - PUGI__FN xpath_node xpath_node_set::first() const - { - return impl::xpath_first(_begin, _end, _type); - } - - PUGI__FN xpath_parse_result::xpath_parse_result(): error("Internal error"), offset(0) - { - } - - PUGI__FN xpath_parse_result::operator bool() const - { - return error == 0; - } - - PUGI__FN const char* xpath_parse_result::description() const - { - return error ? error : "No error"; - } - - PUGI__FN xpath_variable::xpath_variable(xpath_value_type type_): _type(type_), _next(0) - { - } - - PUGI__FN const char_t* xpath_variable::name() const - { - switch (_type) - { - case xpath_type_node_set: - return static_cast(this)->name; - - case xpath_type_number: - return static_cast(this)->name; - - case xpath_type_string: - return static_cast(this)->name; - - case xpath_type_boolean: - return static_cast(this)->name; - - default: - assert(false && "Invalid variable type"); // unreachable - return 0; - } - } - - PUGI__FN xpath_value_type xpath_variable::type() const - { - return _type; - } - - PUGI__FN bool xpath_variable::get_boolean() const - { - return (_type == xpath_type_boolean) ? static_cast(this)->value : false; - } - - PUGI__FN double xpath_variable::get_number() const - { - return (_type == xpath_type_number) ? static_cast(this)->value : impl::gen_nan(); - } - - PUGI__FN const char_t* xpath_variable::get_string() const - { - const char_t* value = (_type == xpath_type_string) ? static_cast(this)->value : 0; - return value ? value : PUGIXML_TEXT(""); - } - - PUGI__FN const xpath_node_set& xpath_variable::get_node_set() const - { - return (_type == xpath_type_node_set) ? static_cast(this)->value : impl::dummy_node_set; - } - - PUGI__FN bool xpath_variable::set(bool value) - { - if (_type != xpath_type_boolean) return false; - - static_cast(this)->value = value; - return true; - } - - PUGI__FN bool xpath_variable::set(double value) - { - if (_type != xpath_type_number) return false; - - static_cast(this)->value = value; - return true; - } - - PUGI__FN bool xpath_variable::set(const char_t* value) - { - if (_type != xpath_type_string) return false; - - impl::xpath_variable_string* var = static_cast(this); - - // duplicate string - size_t size = (impl::strlength(value) + 1) * sizeof(char_t); - - char_t* copy = static_cast(impl::xml_memory::allocate(size)); - if (!copy) return false; - - memcpy(copy, value, size); - - // replace old string - if (var->value) impl::xml_memory::deallocate(var->value); - var->value = copy; - - return true; - } - - PUGI__FN bool xpath_variable::set(const xpath_node_set& value) - { - if (_type != xpath_type_node_set) return false; - - static_cast(this)->value = value; - return true; - } - - PUGI__FN xpath_variable_set::xpath_variable_set() - { - for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) - _data[i] = 0; - } - - PUGI__FN xpath_variable_set::~xpath_variable_set() - { - for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) - _destroy(_data[i]); - } - - PUGI__FN xpath_variable_set::xpath_variable_set(const xpath_variable_set& rhs) - { - for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) - _data[i] = 0; - - _assign(rhs); - } - - PUGI__FN xpath_variable_set& xpath_variable_set::operator=(const xpath_variable_set& rhs) - { - if (this == &rhs) return *this; - - _assign(rhs); - - return *this; - } - -#ifdef PUGIXML_HAS_MOVE - PUGI__FN xpath_variable_set::xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT - { - for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) - { - _data[i] = rhs._data[i]; - rhs._data[i] = 0; - } - } - - PUGI__FN xpath_variable_set& xpath_variable_set::operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT - { - for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) - { - _destroy(_data[i]); - - _data[i] = rhs._data[i]; - rhs._data[i] = 0; - } - - return *this; - } -#endif - - PUGI__FN void xpath_variable_set::_assign(const xpath_variable_set& rhs) - { - xpath_variable_set temp; - - for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) - if (rhs._data[i] && !_clone(rhs._data[i], &temp._data[i])) - return; - - _swap(temp); - } - - PUGI__FN void xpath_variable_set::_swap(xpath_variable_set& rhs) - { - for (size_t i = 0; i < sizeof(_data) / sizeof(_data[0]); ++i) - { - xpath_variable* chain = _data[i]; - - _data[i] = rhs._data[i]; - rhs._data[i] = chain; - } - } - - PUGI__FN xpath_variable* xpath_variable_set::_find(const char_t* name) const - { - const size_t hash_size = sizeof(_data) / sizeof(_data[0]); - size_t hash = impl::hash_string(name) % hash_size; - - // look for existing variable - for (xpath_variable* var = _data[hash]; var; var = var->_next) - if (impl::strequal(var->name(), name)) - return var; - - return 0; - } - - PUGI__FN bool xpath_variable_set::_clone(xpath_variable* var, xpath_variable** out_result) - { - xpath_variable* last = 0; - - while (var) - { - // allocate storage for new variable - xpath_variable* nvar = impl::new_xpath_variable(var->_type, var->name()); - if (!nvar) return false; - - // link the variable to the result immediately to handle failures gracefully - if (last) - last->_next = nvar; - else - *out_result = nvar; - - last = nvar; - - // copy the value; this can fail due to out-of-memory conditions - if (!impl::copy_xpath_variable(nvar, var)) return false; - - var = var->_next; - } - - return true; - } - - PUGI__FN void xpath_variable_set::_destroy(xpath_variable* var) - { - while (var) - { - xpath_variable* next = var->_next; - - impl::delete_xpath_variable(var->_type, var); - - var = next; - } - } - - PUGI__FN xpath_variable* xpath_variable_set::add(const char_t* name, xpath_value_type type) - { - const size_t hash_size = sizeof(_data) / sizeof(_data[0]); - size_t hash = impl::hash_string(name) % hash_size; - - // look for existing variable - for (xpath_variable* var = _data[hash]; var; var = var->_next) - if (impl::strequal(var->name(), name)) - return var->type() == type ? var : 0; - - // add new variable - xpath_variable* result = impl::new_xpath_variable(type, name); - - if (result) - { - result->_next = _data[hash]; - - _data[hash] = result; - } - - return result; - } - - PUGI__FN bool xpath_variable_set::set(const char_t* name, bool value) - { - xpath_variable* var = add(name, xpath_type_boolean); - return var ? var->set(value) : false; - } - - PUGI__FN bool xpath_variable_set::set(const char_t* name, double value) - { - xpath_variable* var = add(name, xpath_type_number); - return var ? var->set(value) : false; - } - - PUGI__FN bool xpath_variable_set::set(const char_t* name, const char_t* value) - { - xpath_variable* var = add(name, xpath_type_string); - return var ? var->set(value) : false; - } - - PUGI__FN bool xpath_variable_set::set(const char_t* name, const xpath_node_set& value) - { - xpath_variable* var = add(name, xpath_type_node_set); - return var ? var->set(value) : false; - } - - PUGI__FN xpath_variable* xpath_variable_set::get(const char_t* name) - { - return _find(name); - } - - PUGI__FN const xpath_variable* xpath_variable_set::get(const char_t* name) const - { - return _find(name); - } - - PUGI__FN xpath_query::xpath_query(const char_t* query, xpath_variable_set* variables): _impl(0) - { - impl::xpath_query_impl* qimpl = impl::xpath_query_impl::create(); - - if (!qimpl) - { - #ifdef PUGIXML_NO_EXCEPTIONS - _result.error = "Out of memory"; - #else - throw std::bad_alloc(); - #endif - } - else - { - using impl::auto_deleter; // MSVC7 workaround - auto_deleter impl(qimpl, impl::xpath_query_impl::destroy); - - qimpl->root = impl::xpath_parser::parse(query, variables, &qimpl->alloc, &_result); - - if (qimpl->root) - { - qimpl->root->optimize(&qimpl->alloc); - - _impl = impl.release(); - _result.error = 0; - } - else - { - #ifdef PUGIXML_NO_EXCEPTIONS - if (qimpl->oom) _result.error = "Out of memory"; - #else - if (qimpl->oom) throw std::bad_alloc(); - throw xpath_exception(_result); - #endif - } - } - } - - PUGI__FN xpath_query::xpath_query(): _impl(0) - { - } - - PUGI__FN xpath_query::~xpath_query() - { - if (_impl) - impl::xpath_query_impl::destroy(static_cast(_impl)); - } - -#ifdef PUGIXML_HAS_MOVE - PUGI__FN xpath_query::xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT - { - _impl = rhs._impl; - _result = rhs._result; - rhs._impl = 0; - rhs._result = xpath_parse_result(); - } - - PUGI__FN xpath_query& xpath_query::operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT - { - if (this == &rhs) return *this; - - if (_impl) - impl::xpath_query_impl::destroy(static_cast(_impl)); - - _impl = rhs._impl; - _result = rhs._result; - rhs._impl = 0; - rhs._result = xpath_parse_result(); - - return *this; - } -#endif - - PUGI__FN xpath_value_type xpath_query::return_type() const - { - if (!_impl) return xpath_type_none; - - return static_cast(_impl)->root->rettype(); - } - - PUGI__FN bool xpath_query::evaluate_boolean(const xpath_node& n) const - { - if (!_impl) return false; - - impl::xpath_context c(n, 1, 1); - impl::xpath_stack_data sd; - - bool r = static_cast(_impl)->root->eval_boolean(c, sd.stack); - - if (sd.oom) - { - #ifdef PUGIXML_NO_EXCEPTIONS - return false; - #else - throw std::bad_alloc(); - #endif - } - - return r; - } - - PUGI__FN double xpath_query::evaluate_number(const xpath_node& n) const - { - if (!_impl) return impl::gen_nan(); - - impl::xpath_context c(n, 1, 1); - impl::xpath_stack_data sd; - - double r = static_cast(_impl)->root->eval_number(c, sd.stack); - - if (sd.oom) - { - #ifdef PUGIXML_NO_EXCEPTIONS - return impl::gen_nan(); - #else - throw std::bad_alloc(); - #endif - } - - return r; - } - -#ifndef PUGIXML_NO_STL - PUGI__FN string_t xpath_query::evaluate_string(const xpath_node& n) const - { - if (!_impl) return string_t(); - - impl::xpath_context c(n, 1, 1); - impl::xpath_stack_data sd; - - impl::xpath_string r = static_cast(_impl)->root->eval_string(c, sd.stack); - - if (sd.oom) - { - #ifdef PUGIXML_NO_EXCEPTIONS - return string_t(); - #else - throw std::bad_alloc(); - #endif - } - - return string_t(r.c_str(), r.length()); - } -#endif - - PUGI__FN size_t xpath_query::evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const - { - impl::xpath_context c(n, 1, 1); - impl::xpath_stack_data sd; - - impl::xpath_string r = _impl ? static_cast(_impl)->root->eval_string(c, sd.stack) : impl::xpath_string(); - - if (sd.oom) - { - #ifdef PUGIXML_NO_EXCEPTIONS - r = impl::xpath_string(); - #else - throw std::bad_alloc(); - #endif - } - - size_t full_size = r.length() + 1; - - if (capacity > 0) - { - size_t size = (full_size < capacity) ? full_size : capacity; - assert(size > 0); - - memcpy(buffer, r.c_str(), (size - 1) * sizeof(char_t)); - buffer[size - 1] = 0; - } - - return full_size; - } - - PUGI__FN xpath_node_set xpath_query::evaluate_node_set(const xpath_node& n) const - { - impl::xpath_ast_node* root = impl::evaluate_node_set_prepare(static_cast(_impl)); - if (!root) return xpath_node_set(); - - impl::xpath_context c(n, 1, 1); - impl::xpath_stack_data sd; - - impl::xpath_node_set_raw r = root->eval_node_set(c, sd.stack, impl::nodeset_eval_all); - - if (sd.oom) - { - #ifdef PUGIXML_NO_EXCEPTIONS - return xpath_node_set(); - #else - throw std::bad_alloc(); - #endif - } - - return xpath_node_set(r.begin(), r.end(), r.type()); - } - - PUGI__FN xpath_node xpath_query::evaluate_node(const xpath_node& n) const - { - impl::xpath_ast_node* root = impl::evaluate_node_set_prepare(static_cast(_impl)); - if (!root) return xpath_node(); - - impl::xpath_context c(n, 1, 1); - impl::xpath_stack_data sd; - - impl::xpath_node_set_raw r = root->eval_node_set(c, sd.stack, impl::nodeset_eval_first); - - if (sd.oom) - { - #ifdef PUGIXML_NO_EXCEPTIONS - return xpath_node(); - #else - throw std::bad_alloc(); - #endif - } - - return r.first(); - } - - PUGI__FN const xpath_parse_result& xpath_query::result() const - { - return _result; - } - - PUGI__FN static void unspecified_bool_xpath_query(xpath_query***) - { - } - - PUGI__FN xpath_query::operator xpath_query::unspecified_bool_type() const - { - return _impl ? unspecified_bool_xpath_query : 0; - } - - PUGI__FN bool xpath_query::operator!() const - { - return !_impl; - } - - PUGI__FN xpath_node xml_node::select_node(const char_t* query, xpath_variable_set* variables) const - { - xpath_query q(query, variables); - return q.evaluate_node(*this); - } - - PUGI__FN xpath_node xml_node::select_node(const xpath_query& query) const - { - return query.evaluate_node(*this); - } - - PUGI__FN xpath_node_set xml_node::select_nodes(const char_t* query, xpath_variable_set* variables) const - { - xpath_query q(query, variables); - return q.evaluate_node_set(*this); - } - - PUGI__FN xpath_node_set xml_node::select_nodes(const xpath_query& query) const - { - return query.evaluate_node_set(*this); - } - - PUGI__FN xpath_node xml_node::select_single_node(const char_t* query, xpath_variable_set* variables) const - { - xpath_query q(query, variables); - return q.evaluate_node(*this); - } - - PUGI__FN xpath_node xml_node::select_single_node(const xpath_query& query) const - { - return query.evaluate_node(*this); - } -} - -#endif - -#ifdef __BORLANDC__ -# pragma option pop -#endif - -// Intel C++ does not properly keep warning state for function templates, -// so popping warning state at the end of translation unit leads to warnings in the middle. -#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) -# pragma warning(pop) -#endif - -#if defined(_MSC_VER) && defined(__c2__) -# pragma clang diagnostic pop -#endif - -// Undefine all local macros (makes sure we're not leaking macros in header-only mode) -#undef PUGI__NO_INLINE -#undef PUGI__UNLIKELY -#undef PUGI__STATIC_ASSERT -#undef PUGI__DMC_VOLATILE -#undef PUGI__UNSIGNED_OVERFLOW -#undef PUGI__MSVC_CRT_VERSION -#undef PUGI__SNPRINTF -#undef PUGI__NS_BEGIN -#undef PUGI__NS_END -#undef PUGI__FN -#undef PUGI__FN_NO_INLINE -#undef PUGI__GETHEADER_IMPL -#undef PUGI__GETPAGE_IMPL -#undef PUGI__GETPAGE -#undef PUGI__NODETYPE -#undef PUGI__IS_CHARTYPE_IMPL -#undef PUGI__IS_CHARTYPE -#undef PUGI__IS_CHARTYPEX -#undef PUGI__ENDSWITH -#undef PUGI__SKIPWS -#undef PUGI__OPTSET -#undef PUGI__PUSHNODE -#undef PUGI__POPNODE -#undef PUGI__SCANFOR -#undef PUGI__SCANWHILE -#undef PUGI__SCANWHILE_UNROLL -#undef PUGI__ENDSEG -#undef PUGI__THROW_ERROR -#undef PUGI__CHECK_ERROR - -#endif - -/** - * Copyright (c) 2006-2019 Arseny Kapoulkine - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ diff --git a/external/pugixml/src/pugixml.hpp b/external/pugixml/src/pugixml.hpp deleted file mode 100644 index dc26615d8..000000000 --- a/external/pugixml/src/pugixml.hpp +++ /dev/null @@ -1,1499 +0,0 @@ -/** - * pugixml parser - version 1.10 - * -------------------------------------------------------- - * Copyright (C) 2006-2019, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) - * Report bugs and download new versions at https://pugixml.org/ - * - * This library is distributed under the MIT License. See notice at the end - * of this file. - * - * This work is based on the pugxml parser, which is: - * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) - */ - -#ifndef PUGIXML_VERSION -// Define version macro; evaluates to major * 1000 + minor * 10 + patch so that it's safe to use in less-than comparisons -// Note: pugixml used major * 100 + minor * 10 + patch format up until 1.9 (which had version identifier 190); starting from pugixml 1.10, the minor version number is two digits -# define PUGIXML_VERSION 1100 -#endif - -// Include user configuration file (this can define various configuration macros) -#include "pugiconfig.hpp" - -#ifndef HEADER_PUGIXML_HPP -#define HEADER_PUGIXML_HPP - -// Include stddef.h for size_t and ptrdiff_t -#include - -// Include exception header for XPath -#if !defined(PUGIXML_NO_XPATH) && !defined(PUGIXML_NO_EXCEPTIONS) -# include -#endif - -// Include STL headers -#ifndef PUGIXML_NO_STL -# include -# include -# include -#endif - -// Macro for deprecated features -#ifndef PUGIXML_DEPRECATED -# if defined(__GNUC__) -# define PUGIXML_DEPRECATED __attribute__((deprecated)) -# elif defined(_MSC_VER) && _MSC_VER >= 1300 -# define PUGIXML_DEPRECATED __declspec(deprecated) -# else -# define PUGIXML_DEPRECATED -# endif -#endif - -// If no API is defined, assume default -#ifndef PUGIXML_API -# define PUGIXML_API -#endif - -// If no API for classes is defined, assume default -#ifndef PUGIXML_CLASS -# define PUGIXML_CLASS PUGIXML_API -#endif - -// If no API for functions is defined, assume default -#ifndef PUGIXML_FUNCTION -# define PUGIXML_FUNCTION PUGIXML_API -#endif - -// If the platform is known to have long long support, enable long long functions -#ifndef PUGIXML_HAS_LONG_LONG -# if __cplusplus >= 201103 -# define PUGIXML_HAS_LONG_LONG -# elif defined(_MSC_VER) && _MSC_VER >= 1400 -# define PUGIXML_HAS_LONG_LONG -# endif -#endif - -// If the platform is known to have move semantics support, compile move ctor/operator implementation -#ifndef PUGIXML_HAS_MOVE -# if __cplusplus >= 201103 -# define PUGIXML_HAS_MOVE -# elif defined(_MSC_VER) && _MSC_VER >= 1600 -# define PUGIXML_HAS_MOVE -# endif -#endif - -// If C++ is 2011 or higher, add 'noexcept' specifiers -#ifndef PUGIXML_NOEXCEPT -# if __cplusplus >= 201103 -# define PUGIXML_NOEXCEPT noexcept -# elif defined(_MSC_VER) && _MSC_VER >= 1900 -# define PUGIXML_NOEXCEPT noexcept -# else -# define PUGIXML_NOEXCEPT -# endif -#endif - -// Some functions can not be noexcept in compact mode -#ifdef PUGIXML_COMPACT -# define PUGIXML_NOEXCEPT_IF_NOT_COMPACT -#else -# define PUGIXML_NOEXCEPT_IF_NOT_COMPACT PUGIXML_NOEXCEPT -#endif - -// If C++ is 2011 or higher, add 'override' qualifiers -#ifndef PUGIXML_OVERRIDE -# if __cplusplus >= 201103 -# define PUGIXML_OVERRIDE override -# elif defined(_MSC_VER) && _MSC_VER >= 1700 -# define PUGIXML_OVERRIDE override -# else -# define PUGIXML_OVERRIDE -# endif -#endif - -// If C++ is 2011 or higher, use 'nullptr' -#ifndef PUGIXML_NULL -# if __cplusplus >= 201103 -# define PUGIXML_NULL nullptr -# else -# define PUGIXML_NULL 0 -# endif -#endif - -// Character interface macros -#ifdef PUGIXML_WCHAR_MODE -# define PUGIXML_TEXT(t) L ## t -# define PUGIXML_CHAR wchar_t -#else -# define PUGIXML_TEXT(t) t -# define PUGIXML_CHAR char -#endif - -namespace pugi -{ - // Character type used for all internal storage and operations; depends on PUGIXML_WCHAR_MODE - typedef PUGIXML_CHAR char_t; - -#ifndef PUGIXML_NO_STL - // String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE - typedef std::basic_string, std::allocator > string_t; -#endif -} - -// The PugiXML namespace -namespace pugi -{ - // Tree node types - enum xml_node_type - { - node_null, // Empty (null) node handle - node_document, // A document tree's absolute root - node_element, // Element tag, i.e. '' - node_pcdata, // Plain character data, i.e. 'text' - node_cdata, // Character data, i.e. '' - node_comment, // Comment tag, i.e. '' - node_pi, // Processing instruction, i.e. '' - node_declaration, // Document declaration, i.e. '' - node_doctype // Document type declaration, i.e. '' - }; - - // Parsing options - - // Minimal parsing mode (equivalent to turning all other flags off). - // Only elements and PCDATA sections are added to the DOM tree, no text conversions are performed. - const unsigned int parse_minimal = 0x0000; - - // This flag determines if processing instructions (node_pi) are added to the DOM tree. This flag is off by default. - const unsigned int parse_pi = 0x0001; - - // This flag determines if comments (node_comment) are added to the DOM tree. This flag is off by default. - const unsigned int parse_comments = 0x0002; - - // This flag determines if CDATA sections (node_cdata) are added to the DOM tree. This flag is on by default. - const unsigned int parse_cdata = 0x0004; - - // This flag determines if plain character data (node_pcdata) that consist only of whitespace are added to the DOM tree. - // This flag is off by default; turning it on usually results in slower parsing and more memory consumption. - const unsigned int parse_ws_pcdata = 0x0008; - - // This flag determines if character and entity references are expanded during parsing. This flag is on by default. - const unsigned int parse_escapes = 0x0010; - - // This flag determines if EOL characters are normalized (converted to #xA) during parsing. This flag is on by default. - const unsigned int parse_eol = 0x0020; - - // This flag determines if attribute values are normalized using CDATA normalization rules during parsing. This flag is on by default. - const unsigned int parse_wconv_attribute = 0x0040; - - // This flag determines if attribute values are normalized using NMTOKENS normalization rules during parsing. This flag is off by default. - const unsigned int parse_wnorm_attribute = 0x0080; - - // This flag determines if document declaration (node_declaration) is added to the DOM tree. This flag is off by default. - const unsigned int parse_declaration = 0x0100; - - // This flag determines if document type declaration (node_doctype) is added to the DOM tree. This flag is off by default. - const unsigned int parse_doctype = 0x0200; - - // This flag determines if plain character data (node_pcdata) that is the only child of the parent node and that consists only - // of whitespace is added to the DOM tree. - // This flag is off by default; turning it on may result in slower parsing and more memory consumption. - const unsigned int parse_ws_pcdata_single = 0x0400; - - // This flag determines if leading and trailing whitespace is to be removed from plain character data. This flag is off by default. - const unsigned int parse_trim_pcdata = 0x0800; - - // This flag determines if plain character data that does not have a parent node is added to the DOM tree, and if an empty document - // is a valid document. This flag is off by default. - const unsigned int parse_fragment = 0x1000; - - // This flag determines if plain character data is be stored in the parent element's value. This significantly changes the structure of - // the document; this flag is only recommended for parsing documents with many PCDATA nodes in memory-constrained environments. - // This flag is off by default. - const unsigned int parse_embed_pcdata = 0x2000; - - // The default parsing mode. - // Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded, - // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules. - const unsigned int parse_default = parse_cdata | parse_escapes | parse_wconv_attribute | parse_eol; - - // The full parsing mode. - // Nodes of all types are added to the DOM tree, character/reference entities are expanded, - // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules. - const unsigned int parse_full = parse_default | parse_pi | parse_comments | parse_declaration | parse_doctype; - - // These flags determine the encoding of input data for XML document - enum xml_encoding - { - encoding_auto, // Auto-detect input encoding using BOM or < / class xml_object_range - { - public: - typedef It const_iterator; - typedef It iterator; - - xml_object_range(It b, It e): _begin(b), _end(e) - { - } - - It begin() const { return _begin; } - It end() const { return _end; } - - private: - It _begin, _end; - }; - - // Writer interface for node printing (see xml_node::print) - class PUGIXML_CLASS xml_writer - { - public: - virtual ~xml_writer() {} - - // Write memory chunk into stream/file/whatever - virtual void write(const void* data, size_t size) = 0; - }; - - // xml_writer implementation for FILE* - class PUGIXML_CLASS xml_writer_file: public xml_writer - { - public: - // Construct writer from a FILE* object; void* is used to avoid header dependencies on stdio - xml_writer_file(void* file); - - virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE; - - private: - void* file; - }; - - #ifndef PUGIXML_NO_STL - // xml_writer implementation for streams - class PUGIXML_CLASS xml_writer_stream: public xml_writer - { - public: - // Construct writer from an output stream object - xml_writer_stream(std::basic_ostream >& stream); - xml_writer_stream(std::basic_ostream >& stream); - - virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE; - - private: - std::basic_ostream >* narrow_stream; - std::basic_ostream >* wide_stream; - }; - #endif - - // A light-weight handle for manipulating attributes in DOM tree - class PUGIXML_CLASS xml_attribute - { - friend class xml_attribute_iterator; - friend class xml_node; - - private: - xml_attribute_struct* _attr; - - typedef void (*unspecified_bool_type)(xml_attribute***); - - public: - // Default constructor. Constructs an empty attribute. - xml_attribute(); - - // Constructs attribute from internal pointer - explicit xml_attribute(xml_attribute_struct* attr); - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - - // Comparison operators (compares wrapped attribute pointers) - bool operator==(const xml_attribute& r) const; - bool operator!=(const xml_attribute& r) const; - bool operator<(const xml_attribute& r) const; - bool operator>(const xml_attribute& r) const; - bool operator<=(const xml_attribute& r) const; - bool operator>=(const xml_attribute& r) const; - - // Check if attribute is empty - bool empty() const; - - // Get attribute name/value, or "" if attribute is empty - const char_t* name() const; - const char_t* value() const; - - // Get attribute value, or the default value if attribute is empty - const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const; - - // Get attribute value as a number, or the default value if conversion did not succeed or attribute is empty - int as_int(int def = 0) const; - unsigned int as_uint(unsigned int def = 0) const; - double as_double(double def = 0) const; - float as_float(float def = 0) const; - - #ifdef PUGIXML_HAS_LONG_LONG - long long as_llong(long long def = 0) const; - unsigned long long as_ullong(unsigned long long def = 0) const; - #endif - - // Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty - bool as_bool(bool def = false) const; - - // Set attribute name/value (returns false if attribute is empty or there is not enough memory) - bool set_name(const char_t* rhs); - bool set_value(const char_t* rhs); - - // Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") - bool set_value(int rhs); - bool set_value(unsigned int rhs); - bool set_value(long rhs); - bool set_value(unsigned long rhs); - bool set_value(double rhs); - bool set_value(double rhs, int precision); - bool set_value(float rhs); - bool set_value(float rhs, int precision); - bool set_value(bool rhs); - - #ifdef PUGIXML_HAS_LONG_LONG - bool set_value(long long rhs); - bool set_value(unsigned long long rhs); - #endif - - // Set attribute value (equivalent to set_value without error checking) - xml_attribute& operator=(const char_t* rhs); - xml_attribute& operator=(int rhs); - xml_attribute& operator=(unsigned int rhs); - xml_attribute& operator=(long rhs); - xml_attribute& operator=(unsigned long rhs); - xml_attribute& operator=(double rhs); - xml_attribute& operator=(float rhs); - xml_attribute& operator=(bool rhs); - - #ifdef PUGIXML_HAS_LONG_LONG - xml_attribute& operator=(long long rhs); - xml_attribute& operator=(unsigned long long rhs); - #endif - - // Get next/previous attribute in the attribute list of the parent node - xml_attribute next_attribute() const; - xml_attribute previous_attribute() const; - - // Get hash value (unique for handles to the same object) - size_t hash_value() const; - - // Get internal pointer - xml_attribute_struct* internal_object() const; - }; - -#ifdef __BORLANDC__ - // Borland C++ workaround - bool PUGIXML_FUNCTION operator&&(const xml_attribute& lhs, bool rhs); - bool PUGIXML_FUNCTION operator||(const xml_attribute& lhs, bool rhs); -#endif - - // A light-weight handle for manipulating nodes in DOM tree - class PUGIXML_CLASS xml_node - { - friend class xml_attribute_iterator; - friend class xml_node_iterator; - friend class xml_named_node_iterator; - - protected: - xml_node_struct* _root; - - typedef void (*unspecified_bool_type)(xml_node***); - - public: - // Default constructor. Constructs an empty node. - xml_node(); - - // Constructs node from internal pointer - explicit xml_node(xml_node_struct* p); - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - - // Comparison operators (compares wrapped node pointers) - bool operator==(const xml_node& r) const; - bool operator!=(const xml_node& r) const; - bool operator<(const xml_node& r) const; - bool operator>(const xml_node& r) const; - bool operator<=(const xml_node& r) const; - bool operator>=(const xml_node& r) const; - - // Check if node is empty. - bool empty() const; - - // Get node type - xml_node_type type() const; - - // Get node name, or "" if node is empty or it has no name - const char_t* name() const; - - // Get node value, or "" if node is empty or it has no value - // Note: For text node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes. - const char_t* value() const; - - // Get attribute list - xml_attribute first_attribute() const; - xml_attribute last_attribute() const; - - // Get children list - xml_node first_child() const; - xml_node last_child() const; - - // Get next/previous sibling in the children list of the parent node - xml_node next_sibling() const; - xml_node previous_sibling() const; - - // Get parent node - xml_node parent() const; - - // Get root of DOM tree this node belongs to - xml_node root() const; - - // Get text object for the current node - xml_text text() const; - - // Get child, attribute or next/previous sibling with the specified name - xml_node child(const char_t* name) const; - xml_attribute attribute(const char_t* name) const; - xml_node next_sibling(const char_t* name) const; - xml_node previous_sibling(const char_t* name) const; - - // Get attribute, starting the search from a hint (and updating hint so that searching for a sequence of attributes is fast) - xml_attribute attribute(const char_t* name, xml_attribute& hint) const; - - // Get child value of current node; that is, value of the first child node of type PCDATA/CDATA - const char_t* child_value() const; - - // Get child value of child with specified name. Equivalent to child(name).child_value(). - const char_t* child_value(const char_t* name) const; - - // Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value) - bool set_name(const char_t* rhs); - bool set_value(const char_t* rhs); - - // Add attribute with specified name. Returns added attribute, or empty attribute on errors. - xml_attribute append_attribute(const char_t* name); - xml_attribute prepend_attribute(const char_t* name); - xml_attribute insert_attribute_after(const char_t* name, const xml_attribute& attr); - xml_attribute insert_attribute_before(const char_t* name, const xml_attribute& attr); - - // Add a copy of the specified attribute. Returns added attribute, or empty attribute on errors. - xml_attribute append_copy(const xml_attribute& proto); - xml_attribute prepend_copy(const xml_attribute& proto); - xml_attribute insert_copy_after(const xml_attribute& proto, const xml_attribute& attr); - xml_attribute insert_copy_before(const xml_attribute& proto, const xml_attribute& attr); - - // Add child node with specified type. Returns added node, or empty node on errors. - xml_node append_child(xml_node_type type = node_element); - xml_node prepend_child(xml_node_type type = node_element); - xml_node insert_child_after(xml_node_type type, const xml_node& node); - xml_node insert_child_before(xml_node_type type, const xml_node& node); - - // Add child element with specified name. Returns added node, or empty node on errors. - xml_node append_child(const char_t* name); - xml_node prepend_child(const char_t* name); - xml_node insert_child_after(const char_t* name, const xml_node& node); - xml_node insert_child_before(const char_t* name, const xml_node& node); - - // Add a copy of the specified node as a child. Returns added node, or empty node on errors. - xml_node append_copy(const xml_node& proto); - xml_node prepend_copy(const xml_node& proto); - xml_node insert_copy_after(const xml_node& proto, const xml_node& node); - xml_node insert_copy_before(const xml_node& proto, const xml_node& node); - - // Move the specified node to become a child of this node. Returns moved node, or empty node on errors. - xml_node append_move(const xml_node& moved); - xml_node prepend_move(const xml_node& moved); - xml_node insert_move_after(const xml_node& moved, const xml_node& node); - xml_node insert_move_before(const xml_node& moved, const xml_node& node); - - // Remove specified attribute - bool remove_attribute(const xml_attribute& a); - bool remove_attribute(const char_t* name); - - // Remove all attributes - bool remove_attributes(); - - // Remove specified child - bool remove_child(const xml_node& n); - bool remove_child(const char_t* name); - - // Remove all children - bool remove_children(); - - // Parses buffer as an XML document fragment and appends all nodes as children of the current node. - // Copies/converts the buffer, so it may be deleted or changed after the function returns. - // Note: append_buffer allocates memory that has the lifetime of the owning document; removing the appended nodes does not immediately reclaim that memory. - xml_parse_result append_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Find attribute using predicate. Returns first attribute for which predicate returned true. - template xml_attribute find_attribute(Predicate pred) const - { - if (!_root) return xml_attribute(); - - for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute()) - if (pred(attrib)) - return attrib; - - return xml_attribute(); - } - - // Find child node using predicate. Returns first child for which predicate returned true. - template xml_node find_child(Predicate pred) const - { - if (!_root) return xml_node(); - - for (xml_node node = first_child(); node; node = node.next_sibling()) - if (pred(node)) - return node; - - return xml_node(); - } - - // Find node from subtree using predicate. Returns first node from subtree (depth-first), for which predicate returned true. - template xml_node find_node(Predicate pred) const - { - if (!_root) return xml_node(); - - xml_node cur = first_child(); - - while (cur._root && cur._root != _root) - { - if (pred(cur)) return cur; - - if (cur.first_child()) cur = cur.first_child(); - else if (cur.next_sibling()) cur = cur.next_sibling(); - else - { - while (!cur.next_sibling() && cur._root != _root) cur = cur.parent(); - - if (cur._root != _root) cur = cur.next_sibling(); - } - } - - return xml_node(); - } - - // Find child node by attribute name/value - xml_node find_child_by_attribute(const char_t* name, const char_t* attr_name, const char_t* attr_value) const; - xml_node find_child_by_attribute(const char_t* attr_name, const char_t* attr_value) const; - - #ifndef PUGIXML_NO_STL - // Get the absolute node path from root as a text string. - string_t path(char_t delimiter = '/') const; - #endif - - // Search for a node by path consisting of node names and . or .. elements. - xml_node first_element_by_path(const char_t* path, char_t delimiter = '/') const; - - // Recursively traverse subtree with xml_tree_walker - bool traverse(xml_tree_walker& walker); - - #ifndef PUGIXML_NO_XPATH - // Select single node by evaluating XPath query. Returns first node from the resulting node set. - xpath_node select_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const; - xpath_node select_node(const xpath_query& query) const; - - // Select node set by evaluating XPath query - xpath_node_set select_nodes(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const; - xpath_node_set select_nodes(const xpath_query& query) const; - - // (deprecated: use select_node instead) Select single node by evaluating XPath query. - PUGIXML_DEPRECATED xpath_node select_single_node(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL) const; - PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const; - - #endif - - // Print subtree using a writer object - void print(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; - - #ifndef PUGIXML_NO_STL - // Print subtree to stream - void print(std::basic_ostream >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto, unsigned int depth = 0) const; - void print(std::basic_ostream >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const; - #endif - - // Child nodes iterators - typedef xml_node_iterator iterator; - - iterator begin() const; - iterator end() const; - - // Attribute iterators - typedef xml_attribute_iterator attribute_iterator; - - attribute_iterator attributes_begin() const; - attribute_iterator attributes_end() const; - - // Range-based for support - xml_object_range children() const; - xml_object_range children(const char_t* name) const; - xml_object_range attributes() const; - - // Get node offset in parsed file/string (in char_t units) for debugging purposes - ptrdiff_t offset_debug() const; - - // Get hash value (unique for handles to the same object) - size_t hash_value() const; - - // Get internal pointer - xml_node_struct* internal_object() const; - }; - -#ifdef __BORLANDC__ - // Borland C++ workaround - bool PUGIXML_FUNCTION operator&&(const xml_node& lhs, bool rhs); - bool PUGIXML_FUNCTION operator||(const xml_node& lhs, bool rhs); -#endif - - // A helper for working with text inside PCDATA nodes - class PUGIXML_CLASS xml_text - { - friend class xml_node; - - xml_node_struct* _root; - - typedef void (*unspecified_bool_type)(xml_text***); - - explicit xml_text(xml_node_struct* root); - - xml_node_struct* _data_new(); - xml_node_struct* _data() const; - - public: - // Default constructor. Constructs an empty object. - xml_text(); - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - - // Check if text object is empty - bool empty() const; - - // Get text, or "" if object is empty - const char_t* get() const; - - // Get text, or the default value if object is empty - const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const; - - // Get text as a number, or the default value if conversion did not succeed or object is empty - int as_int(int def = 0) const; - unsigned int as_uint(unsigned int def = 0) const; - double as_double(double def = 0) const; - float as_float(float def = 0) const; - - #ifdef PUGIXML_HAS_LONG_LONG - long long as_llong(long long def = 0) const; - unsigned long long as_ullong(unsigned long long def = 0) const; - #endif - - // Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty - bool as_bool(bool def = false) const; - - // Set text (returns false if object is empty or there is not enough memory) - bool set(const char_t* rhs); - - // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") - bool set(int rhs); - bool set(unsigned int rhs); - bool set(long rhs); - bool set(unsigned long rhs); - bool set(double rhs); - bool set(double rhs, int precision); - bool set(float rhs); - bool set(float rhs, int precision); - bool set(bool rhs); - - #ifdef PUGIXML_HAS_LONG_LONG - bool set(long long rhs); - bool set(unsigned long long rhs); - #endif - - // Set text (equivalent to set without error checking) - xml_text& operator=(const char_t* rhs); - xml_text& operator=(int rhs); - xml_text& operator=(unsigned int rhs); - xml_text& operator=(long rhs); - xml_text& operator=(unsigned long rhs); - xml_text& operator=(double rhs); - xml_text& operator=(float rhs); - xml_text& operator=(bool rhs); - - #ifdef PUGIXML_HAS_LONG_LONG - xml_text& operator=(long long rhs); - xml_text& operator=(unsigned long long rhs); - #endif - - // Get the data node (node_pcdata or node_cdata) for this object - xml_node data() const; - }; - -#ifdef __BORLANDC__ - // Borland C++ workaround - bool PUGIXML_FUNCTION operator&&(const xml_text& lhs, bool rhs); - bool PUGIXML_FUNCTION operator||(const xml_text& lhs, bool rhs); -#endif - - // Child node iterator (a bidirectional iterator over a collection of xml_node) - class PUGIXML_CLASS xml_node_iterator - { - friend class xml_node; - - private: - mutable xml_node _wrap; - xml_node _parent; - - xml_node_iterator(xml_node_struct* ref, xml_node_struct* parent); - - public: - // Iterator traits - typedef ptrdiff_t difference_type; - typedef xml_node value_type; - typedef xml_node* pointer; - typedef xml_node& reference; - - #ifndef PUGIXML_NO_STL - typedef std::bidirectional_iterator_tag iterator_category; - #endif - - // Default constructor - xml_node_iterator(); - - // Construct an iterator which points to the specified node - xml_node_iterator(const xml_node& node); - - // Iterator operators - bool operator==(const xml_node_iterator& rhs) const; - bool operator!=(const xml_node_iterator& rhs) const; - - xml_node& operator*() const; - xml_node* operator->() const; - - const xml_node_iterator& operator++(); - xml_node_iterator operator++(int); - - const xml_node_iterator& operator--(); - xml_node_iterator operator--(int); - }; - - // Attribute iterator (a bidirectional iterator over a collection of xml_attribute) - class PUGIXML_CLASS xml_attribute_iterator - { - friend class xml_node; - - private: - mutable xml_attribute _wrap; - xml_node _parent; - - xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent); - - public: - // Iterator traits - typedef ptrdiff_t difference_type; - typedef xml_attribute value_type; - typedef xml_attribute* pointer; - typedef xml_attribute& reference; - - #ifndef PUGIXML_NO_STL - typedef std::bidirectional_iterator_tag iterator_category; - #endif - - // Default constructor - xml_attribute_iterator(); - - // Construct an iterator which points to the specified attribute - xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent); - - // Iterator operators - bool operator==(const xml_attribute_iterator& rhs) const; - bool operator!=(const xml_attribute_iterator& rhs) const; - - xml_attribute& operator*() const; - xml_attribute* operator->() const; - - const xml_attribute_iterator& operator++(); - xml_attribute_iterator operator++(int); - - const xml_attribute_iterator& operator--(); - xml_attribute_iterator operator--(int); - }; - - // Named node range helper - class PUGIXML_CLASS xml_named_node_iterator - { - friend class xml_node; - - public: - // Iterator traits - typedef ptrdiff_t difference_type; - typedef xml_node value_type; - typedef xml_node* pointer; - typedef xml_node& reference; - - #ifndef PUGIXML_NO_STL - typedef std::bidirectional_iterator_tag iterator_category; - #endif - - // Default constructor - xml_named_node_iterator(); - - // Construct an iterator which points to the specified node - xml_named_node_iterator(const xml_node& node, const char_t* name); - - // Iterator operators - bool operator==(const xml_named_node_iterator& rhs) const; - bool operator!=(const xml_named_node_iterator& rhs) const; - - xml_node& operator*() const; - xml_node* operator->() const; - - const xml_named_node_iterator& operator++(); - xml_named_node_iterator operator++(int); - - const xml_named_node_iterator& operator--(); - xml_named_node_iterator operator--(int); - - private: - mutable xml_node _wrap; - xml_node _parent; - const char_t* _name; - - xml_named_node_iterator(xml_node_struct* ref, xml_node_struct* parent, const char_t* name); - }; - - // Abstract tree walker class (see xml_node::traverse) - class PUGIXML_CLASS xml_tree_walker - { - friend class xml_node; - - private: - int _depth; - - protected: - // Get current traversal depth - int depth() const; - - public: - xml_tree_walker(); - virtual ~xml_tree_walker(); - - // Callback that is called when traversal begins - virtual bool begin(xml_node& node); - - // Callback that is called for each node traversed - virtual bool for_each(xml_node& node) = 0; - - // Callback that is called when traversal ends - virtual bool end(xml_node& node); - }; - - // Parsing status, returned as part of xml_parse_result object - enum xml_parse_status - { - status_ok = 0, // No error - - status_file_not_found, // File was not found during load_file() - status_io_error, // Error reading from file/stream - status_out_of_memory, // Could not allocate memory - status_internal_error, // Internal error occurred - - status_unrecognized_tag, // Parser could not determine tag type - - status_bad_pi, // Parsing error occurred while parsing document declaration/processing instruction - status_bad_comment, // Parsing error occurred while parsing comment - status_bad_cdata, // Parsing error occurred while parsing CDATA section - status_bad_doctype, // Parsing error occurred while parsing document type declaration - status_bad_pcdata, // Parsing error occurred while parsing PCDATA section - status_bad_start_element, // Parsing error occurred while parsing start element tag - status_bad_attribute, // Parsing error occurred while parsing element attribute - status_bad_end_element, // Parsing error occurred while parsing end element tag - status_end_element_mismatch,// There was a mismatch of start-end tags (closing tag had incorrect name, some tag was not closed or there was an excessive closing tag) - - status_append_invalid_root, // Unable to append nodes since root type is not node_element or node_document (exclusive to xml_node::append_buffer) - - status_no_document_element // Parsing resulted in a document without element nodes - }; - - // Parsing result - struct PUGIXML_CLASS xml_parse_result - { - // Parsing status (see xml_parse_status) - xml_parse_status status; - - // Last parsed offset (in char_t units from start of input data) - ptrdiff_t offset; - - // Source document encoding - xml_encoding encoding; - - // Default constructor, initializes object to failed state - xml_parse_result(); - - // Cast to bool operator - operator bool() const; - - // Get error description - const char* description() const; - }; - - // Document class (DOM tree root) - class PUGIXML_CLASS xml_document: public xml_node - { - private: - char_t* _buffer; - - char _memory[192]; - - // Non-copyable semantics - xml_document(const xml_document&); - xml_document& operator=(const xml_document&); - - void _create(); - void _destroy(); - void _move(xml_document& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT; - - public: - // Default constructor, makes empty document - xml_document(); - - // Destructor, invalidates all node/attribute handles to this document - ~xml_document(); - - #ifdef PUGIXML_HAS_MOVE - // Move semantics support - xml_document(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT; - xml_document& operator=(xml_document&& rhs) PUGIXML_NOEXCEPT_IF_NOT_COMPACT; - #endif - - // Removes all nodes, leaving the empty document - void reset(); - - // Removes all nodes, then copies the entire contents of the specified document - void reset(const xml_document& proto); - - #ifndef PUGIXML_NO_STL - // Load document from stream. - xml_parse_result load(std::basic_istream >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - xml_parse_result load(std::basic_istream >& stream, unsigned int options = parse_default); - #endif - - // (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied. - PUGIXML_DEPRECATED xml_parse_result load(const char_t* contents, unsigned int options = parse_default); - - // Load document from zero-terminated string. No encoding conversions are applied. - xml_parse_result load_string(const char_t* contents, unsigned int options = parse_default); - - // Load document from file - xml_parse_result load_file(const char* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - xml_parse_result load_file(const wchar_t* path, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Load document from buffer. Copies/converts the buffer, so it may be deleted or changed after the function returns. - xml_parse_result load_buffer(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data). - // You should ensure that buffer data will persist throughout the document's lifetime, and free the buffer memory manually once document is destroyed. - xml_parse_result load_buffer_inplace(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Load document from buffer, using the buffer for in-place parsing (the buffer is modified and used for storage of document data). - // You should allocate the buffer with pugixml allocation function; document will free the buffer when it is no longer needed (you can't use it anymore). - xml_parse_result load_buffer_inplace_own(void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); - - // Save XML document to writer (semantics is slightly different from xml_node::print, see documentation for details). - void save(xml_writer& writer, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - - #ifndef PUGIXML_NO_STL - // Save XML document to stream (semantics is slightly different from xml_node::print, see documentation for details). - void save(std::basic_ostream >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - void save(std::basic_ostream >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const; - #endif - - // Save XML to file - bool save_file(const char* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - bool save_file(const wchar_t* path, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; - - // Get document element - xml_node document_element() const; - }; - -#ifndef PUGIXML_NO_XPATH - // XPath query return type - enum xpath_value_type - { - xpath_type_none, // Unknown type (query failed to compile) - xpath_type_node_set, // Node set (xpath_node_set) - xpath_type_number, // Number - xpath_type_string, // String - xpath_type_boolean // Boolean - }; - - // XPath parsing result - struct PUGIXML_CLASS xpath_parse_result - { - // Error message (0 if no error) - const char* error; - - // Last parsed offset (in char_t units from string start) - ptrdiff_t offset; - - // Default constructor, initializes object to failed state - xpath_parse_result(); - - // Cast to bool operator - operator bool() const; - - // Get error description - const char* description() const; - }; - - // A single XPath variable - class PUGIXML_CLASS xpath_variable - { - friend class xpath_variable_set; - - protected: - xpath_value_type _type; - xpath_variable* _next; - - xpath_variable(xpath_value_type type); - - // Non-copyable semantics - xpath_variable(const xpath_variable&); - xpath_variable& operator=(const xpath_variable&); - - public: - // Get variable name - const char_t* name() const; - - // Get variable type - xpath_value_type type() const; - - // Get variable value; no type conversion is performed, default value (false, NaN, empty string, empty node set) is returned on type mismatch error - bool get_boolean() const; - double get_number() const; - const char_t* get_string() const; - const xpath_node_set& get_node_set() const; - - // Set variable value; no type conversion is performed, false is returned on type mismatch error - bool set(bool value); - bool set(double value); - bool set(const char_t* value); - bool set(const xpath_node_set& value); - }; - - // A set of XPath variables - class PUGIXML_CLASS xpath_variable_set - { - private: - xpath_variable* _data[64]; - - void _assign(const xpath_variable_set& rhs); - void _swap(xpath_variable_set& rhs); - - xpath_variable* _find(const char_t* name) const; - - static bool _clone(xpath_variable* var, xpath_variable** out_result); - static void _destroy(xpath_variable* var); - - public: - // Default constructor/destructor - xpath_variable_set(); - ~xpath_variable_set(); - - // Copy constructor/assignment operator - xpath_variable_set(const xpath_variable_set& rhs); - xpath_variable_set& operator=(const xpath_variable_set& rhs); - - #ifdef PUGIXML_HAS_MOVE - // Move semantics support - xpath_variable_set(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT; - xpath_variable_set& operator=(xpath_variable_set&& rhs) PUGIXML_NOEXCEPT; - #endif - - // Add a new variable or get the existing one, if the types match - xpath_variable* add(const char_t* name, xpath_value_type type); - - // Set value of an existing variable; no type conversion is performed, false is returned if there is no such variable or if types mismatch - bool set(const char_t* name, bool value); - bool set(const char_t* name, double value); - bool set(const char_t* name, const char_t* value); - bool set(const char_t* name, const xpath_node_set& value); - - // Get existing variable by name - xpath_variable* get(const char_t* name); - const xpath_variable* get(const char_t* name) const; - }; - - // A compiled XPath query object - class PUGIXML_CLASS xpath_query - { - private: - void* _impl; - xpath_parse_result _result; - - typedef void (*unspecified_bool_type)(xpath_query***); - - // Non-copyable semantics - xpath_query(const xpath_query&); - xpath_query& operator=(const xpath_query&); - - public: - // Construct a compiled object from XPath expression. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on compilation errors. - explicit xpath_query(const char_t* query, xpath_variable_set* variables = PUGIXML_NULL); - - // Constructor - xpath_query(); - - // Destructor - ~xpath_query(); - - #ifdef PUGIXML_HAS_MOVE - // Move semantics support - xpath_query(xpath_query&& rhs) PUGIXML_NOEXCEPT; - xpath_query& operator=(xpath_query&& rhs) PUGIXML_NOEXCEPT; - #endif - - // Get query expression return type - xpath_value_type return_type() const; - - // Evaluate expression as boolean value in the specified context; performs type conversion if necessary. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. - bool evaluate_boolean(const xpath_node& n) const; - - // Evaluate expression as double value in the specified context; performs type conversion if necessary. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. - double evaluate_number(const xpath_node& n) const; - - #ifndef PUGIXML_NO_STL - // Evaluate expression as string value in the specified context; performs type conversion if necessary. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. - string_t evaluate_string(const xpath_node& n) const; - #endif - - // Evaluate expression as string value in the specified context; performs type conversion if necessary. - // At most capacity characters are written to the destination buffer, full result size is returned (includes terminating zero). - // If PUGIXML_NO_EXCEPTIONS is not defined, throws std::bad_alloc on out of memory errors. - // If PUGIXML_NO_EXCEPTIONS is defined, returns empty set instead. - size_t evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const; - - // Evaluate expression as node set in the specified context. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors. - // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node set instead. - xpath_node_set evaluate_node_set(const xpath_node& n) const; - - // Evaluate expression as node set in the specified context. - // Return first node in document order, or empty node if node set is empty. - // If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on type mismatch and std::bad_alloc on out of memory errors. - // If PUGIXML_NO_EXCEPTIONS is defined, returns empty node instead. - xpath_node evaluate_node(const xpath_node& n) const; - - // Get parsing result (used to get compilation errors in PUGIXML_NO_EXCEPTIONS mode) - const xpath_parse_result& result() const; - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - }; - - #ifndef PUGIXML_NO_EXCEPTIONS - #if defined(_MSC_VER) - // C4275 can be ignored in Visual C++ if you are deriving - // from a type in the Standard C++ Library - #pragma warning(push) - #pragma warning(disable: 4275) - #endif - // XPath exception class - class PUGIXML_CLASS xpath_exception: public std::exception - { - private: - xpath_parse_result _result; - - public: - // Construct exception from parse result - explicit xpath_exception(const xpath_parse_result& result); - - // Get error message - virtual const char* what() const throw() PUGIXML_OVERRIDE; - - // Get parse result - const xpath_parse_result& result() const; - }; - #if defined(_MSC_VER) - #pragma warning(pop) - #endif - #endif - - // XPath node class (either xml_node or xml_attribute) - class PUGIXML_CLASS xpath_node - { - private: - xml_node _node; - xml_attribute _attribute; - - typedef void (*unspecified_bool_type)(xpath_node***); - - public: - // Default constructor; constructs empty XPath node - xpath_node(); - - // Construct XPath node from XML node/attribute - xpath_node(const xml_node& node); - xpath_node(const xml_attribute& attribute, const xml_node& parent); - - // Get node/attribute, if any - xml_node node() const; - xml_attribute attribute() const; - - // Get parent of contained node/attribute - xml_node parent() const; - - // Safe bool conversion operator - operator unspecified_bool_type() const; - - // Borland C++ workaround - bool operator!() const; - - // Comparison operators - bool operator==(const xpath_node& n) const; - bool operator!=(const xpath_node& n) const; - }; - -#ifdef __BORLANDC__ - // Borland C++ workaround - bool PUGIXML_FUNCTION operator&&(const xpath_node& lhs, bool rhs); - bool PUGIXML_FUNCTION operator||(const xpath_node& lhs, bool rhs); -#endif - - // A fixed-size collection of XPath nodes - class PUGIXML_CLASS xpath_node_set - { - public: - // Collection type - enum type_t - { - type_unsorted, // Not ordered - type_sorted, // Sorted by document order (ascending) - type_sorted_reverse // Sorted by document order (descending) - }; - - // Constant iterator type - typedef const xpath_node* const_iterator; - - // We define non-constant iterator to be the same as constant iterator so that various generic algorithms (i.e. boost foreach) work - typedef const xpath_node* iterator; - - // Default constructor. Constructs empty set. - xpath_node_set(); - - // Constructs a set from iterator range; data is not checked for duplicates and is not sorted according to provided type, so be careful - xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted); - - // Destructor - ~xpath_node_set(); - - // Copy constructor/assignment operator - xpath_node_set(const xpath_node_set& ns); - xpath_node_set& operator=(const xpath_node_set& ns); - - #ifdef PUGIXML_HAS_MOVE - // Move semantics support - xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT; - xpath_node_set& operator=(xpath_node_set&& rhs) PUGIXML_NOEXCEPT; - #endif - - // Get collection type - type_t type() const; - - // Get collection size - size_t size() const; - - // Indexing operator - const xpath_node& operator[](size_t index) const; - - // Collection iterators - const_iterator begin() const; - const_iterator end() const; - - // Sort the collection in ascending/descending order by document order - void sort(bool reverse = false); - - // Get first node in the collection by document order - xpath_node first() const; - - // Check if collection is empty - bool empty() const; - - private: - type_t _type; - - xpath_node _storage[1]; - - xpath_node* _begin; - xpath_node* _end; - - void _assign(const_iterator begin, const_iterator end, type_t type); - void _move(xpath_node_set& rhs) PUGIXML_NOEXCEPT; - }; -#endif - -#ifndef PUGIXML_NO_STL - // Convert wide string to UTF8 - std::basic_string, std::allocator > PUGIXML_FUNCTION as_utf8(const wchar_t* str); - std::basic_string, std::allocator > PUGIXML_FUNCTION as_utf8(const std::basic_string, std::allocator >& str); - - // Convert UTF8 to wide string - std::basic_string, std::allocator > PUGIXML_FUNCTION as_wide(const char* str); - std::basic_string, std::allocator > PUGIXML_FUNCTION as_wide(const std::basic_string, std::allocator >& str); -#endif - - // Memory allocation function interface; returns pointer to allocated memory or NULL on failure - typedef void* (*allocation_function)(size_t size); - - // Memory deallocation function interface - typedef void (*deallocation_function)(void* ptr); - - // Override default memory management functions. All subsequent allocations/deallocations will be performed via supplied functions. - void PUGIXML_FUNCTION set_memory_management_functions(allocation_function allocate, deallocation_function deallocate); - - // Get current memory management functions - allocation_function PUGIXML_FUNCTION get_memory_allocation_function(); - deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function(); -} - -#if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC)) -namespace std -{ - // Workarounds for (non-standard) iterator category detection for older versions (MSVC7/IC8 and earlier) - std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_node_iterator&); - std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_attribute_iterator&); - std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_named_node_iterator&); -} -#endif - -#if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC) -namespace std -{ - // Workarounds for (non-standard) iterator category detection - std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_node_iterator&); - std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_attribute_iterator&); - std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_named_node_iterator&); -} -#endif - -#endif - -// Make sure implementation is included in header-only mode -// Use macro expansion in #include to work around QMake (QTBUG-11923) -#if defined(PUGIXML_HEADER_ONLY) && !defined(PUGIXML_SOURCE) -# define PUGIXML_SOURCE "pugixml.cpp" -# include PUGIXML_SOURCE -#endif - -/** - * Copyright (c) 2006-2019 Arseny Kapoulkine - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ diff --git a/external/pugixml/tests/allocator.cpp b/external/pugixml/tests/allocator.cpp deleted file mode 100644 index 588e45617..000000000 --- a/external/pugixml/tests/allocator.cpp +++ /dev/null @@ -1,175 +0,0 @@ -#include "allocator.hpp" - -#include -#include -#include - -// Address sanitizer -#if defined(__has_feature) -# define ADDRESS_SANITIZER __has_feature(address_sanitizer) -#else -# if defined(__SANITIZE_ADDRESS__) -# define ADDRESS_SANITIZER 1 -# else -# define ADDRESS_SANITIZER 0 -# endif -#endif - -// Low-level allocation functions -#if defined(_WIN32) || defined(_WIN64) -# ifdef __MWERKS__ -# pragma ANSI_strict off // disable ANSI strictness to include windows.h -# pragma cpp_extensions on // enable some extensions to include windows.h -# endif - -# if defined(_MSC_VER) -# pragma warning(disable: 4201) // nonstandard extension used: nameless struct/union -# endif - -# ifdef _XBOX_VER -# define NOD3D -# include -# else -# include -# endif - -namespace -{ - const size_t page_size = 4096; - - size_t align_to_page(size_t value) - { - return (value + page_size - 1) & ~(page_size - 1); - } - - void* allocate_page_aligned(size_t size) - { - // We can't use VirtualAlloc because it has 64Kb granularity so we run out of address space quickly - // We can't use malloc because of occasional problems with CW on CRT termination - static HANDLE heap = HeapCreate(0, 0, 0); - - void* result = HeapAlloc(heap, 0, size + page_size); - - return reinterpret_cast(align_to_page(reinterpret_cast(result))); - } - - void* allocate(size_t size) - { - size_t aligned_size = align_to_page(size); - - void* ptr = allocate_page_aligned(aligned_size + page_size); - if (!ptr) return 0; - - char* end = static_cast(ptr) + aligned_size; - - DWORD old_flags; - VirtualProtect(end, page_size, PAGE_NOACCESS, &old_flags); - - return end - size; - } - - void deallocate(void* ptr, size_t size) - { - size_t aligned_size = align_to_page(size); - - void* rptr = static_cast(ptr) + size - aligned_size; - - DWORD old_flags; - VirtualProtect(rptr, aligned_size + page_size, PAGE_NOACCESS, &old_flags); - } -} -#elif (defined(__APPLE__) || defined(__linux__)) && (defined(__i386) || defined(__x86_64)) && !ADDRESS_SANITIZER -# include - -namespace -{ - const size_t page_size = 4096; - - size_t align_to_page(size_t value) - { - return (value + page_size - 1) & ~(page_size - 1); - } - - void* allocate_page_aligned(size_t size) - { - void* result = malloc(size + page_size); - - return reinterpret_cast(align_to_page(reinterpret_cast(result))); - } - - void* allocate(size_t size) - { - size_t aligned_size = align_to_page(size); - - void* ptr = allocate_page_aligned(aligned_size + page_size); - if (!ptr) return 0; - - char* end = static_cast(ptr) + aligned_size; - - int res = mprotect(end, page_size, PROT_NONE); - assert(res == 0); - (void)!res; - - return end - size; - } - - void deallocate(void* ptr, size_t size) - { - size_t aligned_size = align_to_page(size); - - void* rptr = static_cast(ptr) + size - aligned_size; - - int res = mprotect(rptr, aligned_size + page_size, PROT_NONE); - assert(res == 0); - (void)!res; - } -} -#else -namespace -{ - void* allocate(size_t size) - { - return malloc(size); - } - - void deallocate(void* ptr, size_t size) - { - (void)size; - - free(ptr); - } -} -#endif - -// High-level allocation functions -const size_t memory_alignment = sizeof(double) > sizeof(void*) ? sizeof(double) : sizeof(void*); - -void* memory_allocate(size_t size) -{ - void* result = allocate(size + memory_alignment); - if (!result) return 0; - - memcpy(result, &size, sizeof(size_t)); - - return static_cast(result) + memory_alignment; -} - -size_t memory_size(void* ptr) -{ - assert(ptr); - - size_t result; - memcpy(&result, static_cast(ptr) - memory_alignment, sizeof(size_t)); - - return result; -} - -void memory_deallocate(void* ptr) -{ - if (!ptr) return; - - size_t size = memory_size(ptr); - - deallocate(static_cast(ptr) - memory_alignment, size + memory_alignment); -} - diff --git a/external/pugixml/tests/allocator.hpp b/external/pugixml/tests/allocator.hpp deleted file mode 100644 index cb52c91d1..000000000 --- a/external/pugixml/tests/allocator.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef HEADER_TEST_ALLOCATOR_HPP -#define HEADER_TEST_ALLOCATOR_HPP - -#include - -void* memory_allocate(size_t size); -size_t memory_size(void* ptr); -void memory_deallocate(void* ptr); - -#endif diff --git a/external/pugixml/tests/autotest-appveyor.ps1 b/external/pugixml/tests/autotest-appveyor.ps1 deleted file mode 100644 index dfed8c53f..000000000 --- a/external/pugixml/tests/autotest-appveyor.ps1 +++ /dev/null @@ -1,84 +0,0 @@ -function Invoke-CmdScript($scriptName) -{ - $cmdLine = """$scriptName"" $args & set" - & $Env:SystemRoot\system32\cmd.exe /c $cmdLine | - select-string '^([^=]*)=(.*)$' | foreach-object { - $varName = $_.Matches[0].Groups[1].Value - $varValue = $_.Matches[0].Groups[2].Value - set-item Env:$varName $varValue - } -} - -$sources = @("src/pugixml.cpp") + (Get-ChildItem -Path "tests/*.cpp" -Exclude "fuzz_*.cpp") -$failed = $FALSE - -foreach ($vs in $args) -{ - foreach ($arch in "x86","x64") - { - Write-Output "# Setting up VS$vs $arch" - - if ($vs -eq 15) - { - $vsdevcmdarch = if ($arch -eq "x64") { "amd64" } else { "x86" } - Invoke-CmdScript "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" "-arch=$vsdevcmdarch" - } - elseif ($vs -eq 19){ - $vsdevcmdarch = if ($arch -eq "x64") { "amd64" } else { "x86" } - Invoke-CmdScript "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" "-arch=$vsdevcmdarch" - } - else - { - Invoke-CmdScript "C:\Program Files (x86)\Microsoft Visual Studio $vs.0\VC\vcvarsall.bat" $arch - } - - if (! $?) { throw "Error setting up VS$vs $arch" } - - foreach ($defines in "standard", "PUGIXML_WCHAR_MODE", "PUGIXML_COMPACT") - { - $target = "tests_vs${vs}_${arch}_${defines}" - $deflist = if ($defines -eq "standard") { "" } else { "/D$defines" } - - Add-AppveyorTest $target -Outcome Running - - Write-Output "# Building $target.exe" - & cmd /c "cl.exe /Fe$target.exe /EHsc /W4 /WX $deflist $sources 2>&1" | Tee-Object -Variable buildOutput - - if ($?) - { - Write-Output "# Running $target.exe" - - $sw = [Diagnostics.Stopwatch]::StartNew() - - & .\$target | Tee-Object -Variable testOutput - - if ($?) - { - Write-Output "# Passed" - - Update-AppveyorTest $target -Outcome Passed -StdOut ($testOutput | out-string) -Duration $sw.ElapsedMilliseconds - } - else - { - Write-Output "# Failed" - - Update-AppveyorTest $target -Outcome Failed -StdOut ($testOutput | out-string) -ErrorMessage "Running failed" - - $failed = $TRUE - } - } - else - { - Write-Output "# Failed to build" - - Update-AppveyorTest $target -Outcome Failed -StdOut ($buildOutput | out-string) -ErrorMessage "Compilation failed" - - $failed = $TRUE - } - } - } -} - -if ($failed) { throw "One or more build steps failed" } - -Write-Output "# End" diff --git a/external/pugixml/tests/data/empty.xml b/external/pugixml/tests/data/empty.xml deleted file mode 100644 index e69de29bb..000000000 diff --git a/external/pugixml/tests/data/large.xml b/external/pugixml/tests/data/large.xml deleted file mode 100644 index dfee7975c..000000000 --- a/external/pugixml/tests/data/large.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/external/pugixml/tests/data/latintest_latin1.xml b/external/pugixml/tests/data/latintest_latin1.xml deleted file mode 100644 index 3336f0ce5..000000000 --- a/external/pugixml/tests/data/latintest_latin1.xml +++ /dev/null @@ -1 +0,0 @@ -
00000535351010MllerJrg
<Test>
10
<Test 2>
20
This is a text.
\ No newline at end of file diff --git a/external/pugixml/tests/data/latintest_utf8.xml b/external/pugixml/tests/data/latintest_utf8.xml deleted file mode 100644 index 3efad30fc..000000000 --- a/external/pugixml/tests/data/latintest_utf8.xml +++ /dev/null @@ -1 +0,0 @@ -
00000535351010MüllerJörg
<Test>
10
<Test 2>
20
This is a text.
\ No newline at end of file diff --git a/external/pugixml/tests/data/multiline.xml b/external/pugixml/tests/data/multiline.xml deleted file mode 100644 index 0f0fe3ca7..000000000 --- a/external/pugixml/tests/data/multiline.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/external/pugixml/tests/data/small.xml b/external/pugixml/tests/data/small.xml deleted file mode 100644 index 6187c16d7..000000000 --- a/external/pugixml/tests/data/small.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/external/pugixml/tests/data/truncation.xml b/external/pugixml/tests/data/truncation.xml deleted file mode 100644 index 1b0e9a877..000000000 --- a/external/pugixml/tests/data/truncation.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - some text - - some more text - - - <汉语 名字="name" 价值="value">世界有很多语言𤭢 - - - <氏名> - <氏>山田 - <名>太郎 - - - \ No newline at end of file diff --git a/external/pugixml/tests/data/utftest_utf16_be.xml b/external/pugixml/tests/data/utftest_utf16_be.xml deleted file mode 100644 index 025d079adf475d7557c7e0cff264db07b4e1b537..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4176 zcmcgvOH5p46h1Y#hGIxvxiDP}EQlI`Gay3S%T#C~D#J{}3<8-70U2h74l@)6C^SCm z3K$;*(}cKbjEQk?jP1e@SH6<&)Vgw`E^O+iMiaHI-}&!j?!9yGz(UQ<%>4H}zw@2{ zKXWhXbc!z0Jmo1wE0m^1TA~~ksX#r{L}6+r#_uVLPy^MIPK|Vi;&hslG)`x!pF-Q= zu`qlSxKBXZPeZtCqE*C7(|N>QqZV4G63ybb8}Vkao`FRrVhc1X4u8yd_&dIZ2qH5r zR0d;x1PJJa3z${@xRzSGd^)aJ<_0V^T%(rFmBOSp2%(}hjz(OB!!+VS0^b!(mU7`}Ba zPLG2N4_a+N>x5O07SVdOJ}oM2X~$sy426_eC-i+->&m7>i(nl`^g-==waJFmXf@{8A7^#J8GB?onmIDL zG5%=z_7*9o5{Ohgz6*~Q(oUlx4953l^{+g-aGmQ?_siWU6dN~b)X9{n@(WbB*V%}UReofoAMp{+(9 z)M04@vFfR-=}%+j-NS(vX8#PU|GF9rO+X$SZGhfpb^Z5bUF_Sn$j05|XIz+@eC_Vm zUgj_9eJw6)WQV7v4P;7>)n8fVi(J^ey!G||oO-SIt7&nK&+{CQ?pMVD;>ylAC{}$W zz8hV*p1ODGg#d)QV;^U^7$4z5ejA@npgqG61mXpXz}V1v=A?7~t2rqX)(4S2LvzPo zZo&k;!`JXBTq&=t3z7rQ&jg-qyD_Q4n4evkb*AUPI6uuP=$UZNDrGmDr_Y|A3Q3LG zrR;sCqfA}Y;G^-)=$VkVZ;i}|{y$DloqEAdRz1zmsyBr!o;yl-raXZ&-iG%8xmxke zRm9b*o-12v4tjaAHKag{C=p{m@XppAukkFu%H_ZvtJtkfRlnU=(FV_neJ6?8^@Gja z+21f14snhLaM}i3yFSW&T;@TUeLTK@T^26?x-4yQT?d{isy?r^Pgb#0wlZPl1oMv6 z!38ezWqwE1JcqjsAHv(}lzJN}QX}uY@k!zakMeBnAs(qYgN*1^)6fSCc8eErFcX1u z%~g@BSDClI;+;1aFf~)CFu_@lqOKuhhTgBke+s&IU*4Df|HB{;%nF@nnwoW6QdcFg IuDqfD1ASO0vj6}9 diff --git a/external/pugixml/tests/data/utftest_utf16_be_bom.xml b/external/pugixml/tests/data/utftest_utf16_be_bom.xml deleted file mode 100644 index 080f4e23855b5add0e04d6c711e5eb1acbf42508..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4178 zcmcgvOH5p46h1Y#hGIxvxiDP}EQlI`Gay3iWh%4~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vJoAR@+W+UzvEl5 zk~K(W70+fm0L^D$pM_5Y-g3|>&@^IXluvu!sv=H9Ysr!n3ptMzEz z^a#FnZI~Vf2f~ky58P-2S~s+MwV2kY^=olx#I(cEe~Kc?svGit%yp&HrNuBGhWA13 z1Z+ALPA?WO&Lou-!g?HLkhdT&f{7WhlL_L(npso9EDQ>#=Gr_MD1gr*e3ZdM25-W& ztiJ?~i;80d8nP3FYm-$kB0pLKnkB?CXjb_=OQ+z=P`($Hf4lNvFLf|I7Q~$RmSsMDk{TbL58^iJ-iA{L-^vbs8uuKz9zc zD=IWYbPLa)fwsl9DyPD&?>-Sf!hRI&%2`^1Z3O2h58rZP3wRe>(P_5Mkv>_@Hf@-v z-8om2<;f4B6Q$!A$Hc~3aYf2DSvrtfbC**L!<*yB@@veGd_NvdJdI@;gpL6z7ll zOa6ej`EM=^pP6}3qB(Z>}#K8e?>vQ1xkHD=j$0g1A5t<|xZN@kmUe$9x;p^hxXgDXZS zJt6svt!ve52YDz5dSW&G-q!x*U+Yv-a#VTRI&~RT8gyFK#aGp_KeLY~zAZ|m; z=uG>L&=^2(%R(^f=_{Gf6V8@Rx?AHy%^JFI{ zlQ#uD7r4lm_+6Fh9Nx0Lk0x*vl>Y%mYT?Z{KTY1?F`i94z@rU1ipgA{s|9c%Z$H+s z{6jjFClgO)vTuLIn{SoS`_jlP$vKWApCPjo?lj@o05#i@f2j3-cd!}~5fV>Nv~soA LT==1B{uBNO$s`!$ diff --git a/external/pugixml/tests/data/utftest_utf16_be_nodecl.xml b/external/pugixml/tests/data/utftest_utf16_be_nodecl.xml deleted file mode 100644 index 450f7058d624732dbac5e4704cb23cc0bcb45c6c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4130 zcmcgvO-vkR7=CM}hGIxPc`!XJ9Eci$cR_^KVI#BR(5$ZTm2?j&;(o@v;uQIRgfY7Xlx?3eMoh~ENGhai_#1~F#vorcz=4lREKHH7TT zq*2%|qIEV57(A#CM<3Yjo2?_%@9=Jq+9$T4TuQhE<;tG5U=GBP!i8PQd<2 z3MsE{=m)Sil}(os!8(rU!^SE2bSj))EMA-mT2cu8dYDGtg1m@M%%VH#YJ8B1jnz}> zp!C#|EusSj^s@+k34KW8PC6~}=h5S$>TwPhIh8?rE?xB^($VJNzl5AQ>>`OdhaH&3 zN@6do_|D|93zAK#@oLPm-_M$YGxoqrG;?fvbMnFRt!=V%*NgALV}y*;m`gu;-D{jg z=k>{IJF#k-qWA8{R@7FaCtR~_#g2nS@M-xxSn^MoZ&659tYua8R%P;5e`ECfS;?TH zc;eDi=;{nmu4A&TbOF;VDm)`}6Td$JZ?i`(Gj#j7PsI<2F@_1sc@icF;SA*wUrucS z_u?xyjrLhGr%IWIoiHTA5S7z4RhoJavM`;*)gxZE#AB6du&toC*B-r!8y0U*1{KYf z)$uX&$CFJulKgRsoV&2Xs&`m>af+!|CD_SK(ZgKRxiE#26{+X}w=Xx|p ztI4G+rs!0L39xRI-{;TxUEb%vxDY=#d%xtbSUA}#-4qRf0NXDRd4jrdb>nKIPONOt zioVMGxgXO@m)w`)m+bVC2@T7xsb;mXrVj|pP&c1d+lSk&l-8QV;~y?1o=7vJetrr}rx^iy>O|F<$J zZPMd^WFC!uox5=`b7iNav?6rW$b&i@Z6H=Nbv6A-th{$L(88XdW%XZIIvi5FYIptt#BdY>N1Hv^}})Q{IB4JBb?(QoVFp)u8;Bnmw8yYk02zK%h3kc zb!bje_373=S;bD-3d6_==3S|S3tZ&O{FbVD0e2Zbg16Nf^)^zZX5M}6qr`O{=lR%u zJXVu~tmsv2=z|5jMMoUmi9lZSROFde=8Z3T_w^;PW(pN1ILlGgHDYn--3I)pV2XF; aecAs%4D!IN&}nRH*X>9>mB9Mo4gDX5?I9fi diff --git a/external/pugixml/tests/data/utftest_utf16_le.xml b/external/pugixml/tests/data/utftest_utf16_le.xml deleted file mode 100644 index df5a8f774f9ec615de268c10bef065bdd76125a4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?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zRd7}Dq3G__`8%nXE>=cpTAZqVoaG`9#rybO?&D3MJ<2)h0#CT(d)G5{p+8)3%Wa; zvr3IlcD?SN3W@z*+1}qBrRz!!eob%$JB#gW%e;OP{r~HlCUxPLIcwc!r>!rAEbbj8 z+$m21M+?3KWHjT>Rm5nv?v>3n1HIfBl~fRS;Z6029p2kom(|Vw(@7OcZPJcKc{E;0nTwRPFpWKcYTz*QB5BzyOkNehq{6@3RhYiT-Uw! z6jh(sx>}ubf_GTzD4@%%^Ltj!GkD9O{!!dT`qs6?Fjn*7*wCRpNUvyh zEW&`-Dwv6&zUE#z=UQd>n|F42{_Rapp~3`bIf}aa4|-_L{`#h@V(q@*sPr2q@}R7u Rb9Yl+x0X695o`Mk{Xc-UDX;(l diff --git a/external/pugixml/tests/data/utftest_utf16_le_clean.xml b/external/pugixml/tests/data/utftest_utf16_le_clean.xml deleted file mode 100644 index 79563c592384a3adfe9fd478400e9aed5ed62034..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3932 zcmcgvO-x)>6h4|)1DK|+T$nDVEE+WeXQ;HaKBhvIs0>5H3<8-70Xxh*I?Nypw9xp2 zD`5N~m?p$cV@yo<#%LFYxbiRQPOU39>cXaOG@4jj{LZ~R?|X0F8%#9j1?IkczVn^$ zoO|z?J3Du5I!PC3hKdxUMat0}&67iADp40TQ=D3f@p+OGWYZyP!4sqSMttN0{)NBc z8yr(}VwKqhHBlqRPr^SBP6uoSc$8=YF>;F29XG3p6F@EOS{8xQZ_S98foBew^H4K~ z`Lh@ofSAYU3_eS=gi%qA^5B?2#2laZT9PRq6itcOqosgJ8qYSRmQ7oLRGZS`15OEe#Z*W*@9d3C_vgR!kJM}Ujb0NDGi z6BxH!qSLR%uQN@vN?}+HbI4nimr;pHR3{grPh+%Zsi5f7b2F$w3H2<4qk=l*@Fta( z`R7sNvZ}EIgzN;VwXUjPQBbV|w9~iw^rFE%P8cg;1{d!{7DXdF3YTaoaN9BVnD;iuqq9eGPVmI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(Pci^gByY zckiaepGS$UzUnjDGM^P7?x_);EB5r7zgh1a$>ST&lJAMXWS_U~_2M!g!|YCOYULBw zV`yHnV?Av7ggDr@uFo)QQ?ykpm&ivPFQT;>DxVT=hvnnQpWL(b8l&IR)=|61{^R|# zRz2?6lqApdeuBGb{2%H$)X1Q9IZ*DwXHmEBn!?WL)Fe4|klYTn@;iQ%+`hgrb=u4J zuBrWerFVFkoIP9nISb3q<8AP_ zhn{LR<5KWS7>_f`?IJK~0Dc1(ea9X2Vo&Gqq4uH^a_yEgx|MnrY3XI@9|nd7ANdmr{|^^SAk(EP$W)Y2IshSFS0{Fch~ z@)u$ss1DE_x+lu5Y0=h%eIDg{jph^2HlG&&bvWDFzsqjrIsQ)MyuWvdym-x`W(N*5bw5=WhK2j_nsN0sOw(Tmrn?7`vYJ{=Kpgur}U} zvF~fHYt2R82VJisU$tsKtXENYkoCIYeM+t#d)cm)YqS?fa}WDG-ofsrxE}5?dzt1@ z@H&X=Y#-w{_NVKg{a+teda0=fqasD>#HP-|88U0Vwp47ePdW`_rFYteE oGQWQvJ--*vO*zkPtc^PTmuG$7xdz^A^_X2`yRJ!)@BIJy|B7fQ^Z)<= diff --git a/external/pugixml/tests/data/utftest_utf32_be_clean.xml b/external/pugixml/tests/data/utftest_utf32_be_clean.xml deleted file mode 100644 index df9fe01f60b584d0c9dd007b8834028d22425f73..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7860 zcmd6sOKes}6vs#MX{g5N%7tMuxG-u2KSdPrSrnoIEukPZMH*0ATC3D5uNoh?YKyOE zNQ@g}OpJSD#Dy`gd?oCB?bQWFHyBNPP=Eh>=Uk?@_q&hQ1&e=XzM1o$b7oF&ojW`0 zoVx?u4UT}v!5Hx15ZDJMz*ArZ8~{&%JHb`pMz9jJ!*9vC3rOa2up+=a_ZqZ2LHk2+ z27Cv8VV}K>F7O&{BI{!IyMSb_2hu+bWT$MBZTo=-+S>!gJ)&Q|Il0_>?osiM?O~Xun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#cAbl-(i50v;9C;$Ke diff --git a/external/pugixml/tests/data/utftest_utf32_be_nodecl.xml b/external/pugixml/tests/data/utftest_utf32_be_nodecl.xml deleted file mode 100644 index b450b48c8cbe411a374c24b3ea882be75437676d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8256 zcmd6sNsJXm7{^QUG=L#`@?ba=9*i1+r-&jhagZS@%s?Cv$RLwJnPC|OM*$h*f+rTY zXh@6~V@!;9W0Zq2p4<{{Zg=&d(F;ZsH~js(>uYNI_3Q4}j{}E)s=E5yzptvk*Uve3 zr*m!*SPj;Ld%;Gq6>I>5z&rQqP0norn!6F8_Zmejnjzr9HQ+GV8L*de3LF88!9nmO zmAR@k{7TPF$ywCpnTK`(u65qZ*K2)u(7Z(0-QvqSZT%9vJ;2%vHytSM7Kp zddbjeK8!QhdvcM~YFUh`Vk^1QuNccuJ?kveDEp*aXQ1rTn%OP=X1~^CljLZP`cPap zE^uyib2?9aiQ}jEM6|0WWEy|l}>kjOZeffPW z8l7>0#^P7%UrAi1?oV@}7-Ts%Tl2LLe9iJ}bR|BOTb#LnVC!p9a0^R6s4|dbj?Vk7nnX+ROQ2k1eY?M9H?ZF_> zy6hK?M#Wd}O|Qw3o>&*}w?j8MH|-5(-TfZg7=d>CyR6G5^);$-f&0jGNnS>?fc03P z=UG6ObY^st6>OcgUc#@wB(o#%W@~xA@V=|B1@u!_q;*>r6VZug8+CG!eQti(de)D5 z-o?Ns?F;d4y@B|jVIJ(X^$yHkN zzbs%mqp%pL@6dWqX9s@`-4FlBw&QMm`faw|WyqA?Dn1X5fd1nrotqiL?iaub=S*HA zM|FNHP;Eu^Rm#(Y?$NiLdlq|V=~P@4pGaRJT@QN3M$$cBYIp2w$V)B026hzsBcE>p zIo*Y{RXT$Vi)&A{0q^iJ`l2_Td*f2Bq~AzI-M#CvKSqJ9p6b(N$)63t_S6vbl0Cio zFYYe+pvTZ#-uH;GU(|82*N~j@mu;FVCN*^|)uux#xL4!Cf@@H}xE9q-k9?@;&Ix z^Y&a*$QhpR+^NI(_EhTM@uT?m)rG0kD%t(!Y5E8@?*)5+eh>DUiwk0Ju%Sv;lU!|D z&)LEGd4PUw^gnushwxcvYcFSE(RsX!`0b~s+QhgPyb{LajEe1QFsDI$Lo9l>JMdXg zr|+TaMQ8ci&1ZN^`8;xp5b;?LxqG2=&+t1l=|RsjegrgfFP-8XKQx1^oUO)NnUhFg zNB>CQ<5mQyzfg~}80a^X`nsIX4*qVj@$d@pH|jAW{>q*#*9(@?SJ@ls)tT4Pdqy!S zeBXooTD{{kVkrMY9%}J4u%XbG0=kh-N_H%$U#cC?^r7Dje9wF#z6w5BWP3|bw;>FtMPW(=c z)h}EE_`cg-19Z1Bc0KF$du0_MH@X|G?`v;O*DUT$^OcWRt=bRy%JVkK*9GrWqI#^7 zUCURKXQO-%``qqe?Ip{H_LzE^_EGRUuso}e(L461@}K;#I?kwb!1nec-XZJ75BbaW z4D-!^y*Ye2qk5yJeUL|oVEb%-dCy%dE;VH}sfnKZHS^ELC`VoQ6?u61OJYjAU*i02 ztJfR_+Gq4XZS|zud&<`kQ2s*v&&}og*U|HP@!Y)gv9;Q$(|_r#@7dQ7_gXz>7uv2l K3G|)+pZ^cvh96-7 diff --git a/external/pugixml/tests/data/utftest_utf32_le.xml b/external/pugixml/tests/data/utftest_utf32_le.xml deleted file mode 100644 index 79fd27a7a28bd09b2e5bee284f56663950a74a70..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8348 zcmd6sNsJXm7=T-%1~5cV9t?+qgHa>9$RdogMrB}L9C0L|1VlCk21F5v3!Z>+i^jxw zF~-DrH%2)aK!%Ub5vte%MUONLY4W_~}m;tL{2v)(}unAhQ1`^DB5$+wo z9_HTXw#q8A9unyD2pE?<1jc(5X2GLy7^PYq}c}_-q^O1M`ad7W<7ofn%e*w#+%NQ}!%!wx0S_ zK7qA#OdVrwS)T;TXx|tU7?=0PW33Y?AARO!9Nv4aeRa)!4y=K0`CB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MfR`c0*>jA~c7fy1=d<>A zQQrfuYncJsdhc1jt+5GvrgUvyv4OJ@ZNKNBgk6boyAXA0YOB}r({8WlHFL|8AER#T z%5nJY`SE&>J~w{W+)SVAY#2O~y7rV?4~}2dfAYWMzf)o@PT@Z4(IS>6^D5+f%{BCz QoH4t}b{mtBFZ=)eKZ)HX_W%F@ diff --git a/external/pugixml/tests/data/utftest_utf32_le_bom.xml b/external/pugixml/tests/data/utftest_utf32_le_bom.xml deleted file mode 100644 index 995e02c60d4a80a46c451d97bb3a59b7671a81b5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8352 zcmd6sNvsq_7=T-%1~5cV9t?+qgHa>9$Ra#tjmm>J@rg)435aY8JP<`7E_ec-TQnxd zi!mm~yD`ea7*B4AH@CZbkmyCDi3|9B^X8YP)6?BEj{}D<)m{DXRn=9~bM9=GEy=R% zc6bu@!lRJj33wO|!eg)-_QO6{3e#Z@%!JvUd+iLs6qpR!o(3yn2v)$oun}6Y3KGnD z8SWpu9_HTXw#q8A782<5Fc_CS0>*m;X29cc2zGSt7t$KvcCg=88)Y%7F9{-^_etzG z_!iE9&qA(fBXsiplaRLt=3w1+g7I2QYq|>(_-rfe1@nsf7W<7ofn%e*w#+%NQ}!%! zwx0S_K7qA#OdVrwS)T;TXx|tU7?=0PW33Y?AARO!9Nv4aeRa)!7OaA9`CBjNN-Ci4 zJ)m7}iFFH~iR)s0qHaqsXHLQbnA^FwZz0Tw8_@N72@JuF+&8K1YGl>dmJGl$SPp{_ zb)L$#_U{1W3}5Ps^7iXL?9Ag@d-fZXv9E!}V83}pJ*(mC_9MJD}P&R?<+4z<9nQelQe~4@6vGUHH1j=i} zHged?wa=rrRW+)st#TmKQiea566`(jQ{VexL*)U3{b zt|On;`T2M)_k$F15{vW1mMpuD7wj*i7(aDk-s6qGsy>PNy8>J<;=FcUEP`a7v{h?1 z>QJmt%)7d^8T$Eo=e)AUG4HPD+HrGk-3DdrRvF)MArteaD!;0_+=WBOB4IPeIAZOV zYm9HmRpnGQ_S@D>_+AFI8+P=Q_vQ0L4`$g!2Ht&MUsDP) ziF*mzcaT@kGt#0C3p&qd(P}Sbs%+^qibucB_1y!nXng-IT!koH~tehP2H$M6sAgUv%(cFnf)`4?>zb4%FDllS{x z$L{B}#;pH&9p=-@44B*Li<*YdqJ9(KKR&?T$O3%pSe9MM!fR5ign!Zh=t*jHG|QeN z=2H;%wB!7~73gjg@mA^7#hkDu+Io|{ci`y@eOfQ;qtEbHCfAFfVfJU&c2(T@T*Ge@ zy?){-%g3B=$>kir%Vg_(M*K0Bz03`DPjI$*gR!~d^(_09O{wYHP3Yz+v(?M|3|rc1 zfx1oB^j{mY>}JOMYx4Mx_fXk74|{dB%*Ws!Q>;ysd}2I`y1mv_JI;rXSns3c=J@n# zBcD&vR+C&pKiW%aY{rvMS#8H#k3V>?PGs-33fClY96q>h?OPv@@9;55LAYFLE=#h3~w-;`!0GDzU}MYf6dw~igO@tw$ies;APpi&9}eh z?5Fj9ANcLWYmNi$Z=CVnEH7&u+A|j8%AX%z;T_@`;t1^ycm_rxbXpyqx^Ya%N$3^F zrAaNj>GrcnITtV0bMEg<0M84T!ERU$?rpZ+-t~h#TMmwmdt#jXHg@`=b}h!BNv$0# z3B6*yn%L;3+s}B_oq2k-na{7zc9UGgUbN;OwT?a5wG`vw8uKi39A1SOXU{P{+X;?8 zpU>LgMSTyru4Ni%>x1X{w#FvxnbNg+)jG~bwEdog5_ToV?PAoWsjXhePrJRI*UT+X zevG=UE63rB7su*7^1|3za}#~8vtjT|>e^FoEjWHr|B2_uey7A*oWy<9qeU!D=2gh| UnrrAaIb(K{?KUPMU-tj`e`?Yv^Z)<= diff --git a/external/pugixml/tests/data/utftest_utf32_le_clean.xml b/external/pugixml/tests/data/utftest_utf32_le_clean.xml deleted file mode 100644 index 70d1c7576c3e71bd94e47d1a4da455e6e79e7149..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7860 zcmd6sNsJan7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gTIBE2oz!X{tmB-sg7GDAJOS474j2cK(_o8whHRI3LnqEV zaUP7ht9oCn(@(zOSrxfXoC7DZS4??o^bF`X!weS656@R+e`Wn9zg_qJ0-vJarn6D`JXR-P7pMM2pT4uoXTQ7-RnObn zjx$tUoN>;Ky0_8k>c1)nYgzVLC0FMw^t;ZvdSf}G6zEHpomjUa(==*h5Y+Q}F%;mp zH(u={-vj(M7vE64&!06T3^6VM&uZd#@?aX*Y{MhpI`%R8doTEX!Ry_ietc8PWsO67 z#$sIg{{9N@2KV^GjN9QE7>3Xp?CI3aTY-#(PI)exYS>S&>%L;YU2Nyf-HV>G{qz zcg1SXEsPg(Mk%l({{ckK7bpM# diff --git a/external/pugixml/tests/data/utftest_utf32_le_nodecl.xml b/external/pugixml/tests/data/utftest_utf32_le_nodecl.xml deleted file mode 100644 index c3c0329be7e010cb357226fa95c6c0d5f7bee152..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8256 zcmd6sNvsq_7=TNn1~5cV9t?+qgHa>9$RZF~qw?TQd?FH10wSxx15pIxf+yg)MPp*T z7-M3*8>1YI@#L0xbGxetiC#3CxPRY!^Gnm|>FJrrfy0;TuKxF`>Z<8kl2V!mt6&gT z!acAFTCf^2%y|*+8@nFj-siT;DzgqUOoyZJP@8?U55qB-0gu8F*x9~cNIMgDfc>`G zSO!yIGAsdOR9`YgJnzm<=@G)zB$_>*YA)66)R!+SQg=xA2*{F4rgOw)FCpX2SxQ+rGAMAvF!WYyP}EQ95+0tO)JJe6zh-wwtZzSI@v?bm^CN3Uki)De)EWW z*43r1o`x;YKXYN;7~hbq%c*Ycx38V>|GbYl>SDcv7_FD{Q=jey%3G5| zU_D(|QJZyKpKIU$Kx=KMK_~gBWhXzK_KEMXX&f8Cb)z3+G#+Eguo~<){#aYq*XQ9k z?C7WH%jZWPNNFMi?>?`uDJ7ZAy@c#r$SXGo7PVQ>em;vlX~pVAt${^zxsPb)KEZo4mP8a~VVO?-cUKYJq!@Qo8G zUCF|0Qmc%A(f`P4YIHoMXNdU>ggxyzzi$P)M~Qgrbh^cyu_fAioxOM2lNb85Ue-sS z;jc=r7e7Pn&#vvdxQn@l-zIwf#8H)xIp0#qIeb^icJmqW$5{3DtZc7OAq;%lr&m+G&BhP1f`u8&kTO@&1xLzTrJowa&v{w^|lsaE~e1rb#|A z9%bEL>#7~+!w0PQ5pr{UdbLr^r);Z9E}b4ojt$?@nbDLqbZ=68~P<#Teo z81uB7?eUJ&vBN3tBj&xZ5uz?F^6JHQ=v|C>o7(DUtOhsm+m(06+2NG_;eB%NiQe;! z+7#c%yQ$ql*ua@;E$s_ndm60mDwqI~TdQGxL%!FzLod!(aTYC(X{YzUx^;S)=T#K- z;v71aJ!tw9V`osmeZCL2u9Feg%yIVEa;%}-DZcPs^jAJV`rTz=8_yS>ab|$OnLO8( zeU|l``0nS7k?}41?{+3Dp9SmWyTz+d(Xa2k^4YUkld9*v*pKsDUA%GDjd5tA(@zXl zxmee--zvFo{=!B-^FZD4o{2Ixq{>!torhevRy!?F*X!kw!S9P~6QkcccGAXoBK!H- zHOesUV(^?O{udC;^TSKLLp(zq zqumKl!3cy-tF6;*95ZqfdgXCxQp--d{p?ZB#Y^>^`zsT`^TK7Y2iAaln{B6e{Q%Ea zfMesH80WrC?Y^j8i!o?YYsX4LuUxMtHah9{GhW@!JiXd1=GV=3lU&1IwB{bQjy>45 z6yxC<^DJ``UWOQF&oMsR1&%+T&qlwC`W|py%QVo|d(ZN1jZN4yrEBx5^_-1p`#lF` z>`IK=#i&bDTfL5-c6&XqnOl+K7BiqkJWqlxv{h6X8K%bL*SXzwWr)VaQveF o6aO9iof2zt68BM$7O^y$S0UePuA$fDjM+)H)0l*O)&J-J0jM({VE_OC diff --git a/external/pugixml/tests/data/utftest_utf8.xml b/external/pugixml/tests/data/utftest_utf8.xml deleted file mode 100644 index 81f9059f7..000000000 --- a/external/pugixml/tests/data/utftest_utf8.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - -<週報> - The world has many languages - Мир имеет много языков - el mundo tiene muchos idiomas - 世界有很多语言 - <Русский название="name" ценность="value"><имеет> - <汉语 名字="name" 价值="value">世界有很多语言𤭢 - "Mëtæl!" - <ä>Umlaut Element - - <年月週> - <年度>1997 - <月度>1 - <週>1 - - - <氏名> - <氏>山田 - <名>太郎 - - - <業務報告リスト> - <業務報告> - <業務名>XMLエディターの作成 - <業務コード>X3355-23 - <工数管理> - <見積もり工数>1600 - <実績工数>320 - <当月見積もり工数>160 - <当月実績工数>24 - - <予定項目リスト> - <予定項目> -

XMLエディターの基本仕様の作成

- - - <実施事項リスト> - <実施事項> -

XMLエディターの基本仕様の作成

- - <実施事項> -

競合他社製品の機能調査

- - - <上長への要請事項リスト> - <上長への要請事項> -

特になし

- - - <問題点対策> -

XMLとは何かわからない。

- - - - <業務報告> - <業務名>検索エンジンの開発 - <業務コード>S8821-76 - <工数管理> - <見積もり工数>120 - <実績工数>6 - <当月見積もり工数>32 - <当月実績工数>2 - - <予定項目リスト> - <予定項目> -

gooの機能を調べてみる

- - - <実施事項リスト> - <実施事項> -

更に、どういう検索エンジンがあるか調査する

- - - <上長への要請事項リスト> - <上長への要請事項> -

開発をするのはめんどうなので、Yahoo!を買収して下さい。

- - - <問題点対策> -

検索エンジンで車を走らせることができない。(要調査)

- - - - diff --git a/external/pugixml/tests/data/utftest_utf8_bom.xml b/external/pugixml/tests/data/utftest_utf8_bom.xml deleted file mode 100644 index d34cdb851..000000000 --- a/external/pugixml/tests/data/utftest_utf8_bom.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - -<週報> - The world has many languages - Мир имеет много языков - el mundo tiene muchos idiomas - 世界有很多语言 - <Русский название="name" ценность="value"><имеет> - <汉语 名字="name" 价值="value">世界有很多语言𤭢 - "Mëtæl!" - <ä>Umlaut Element - - <年月週> - <年度>1997 - <月度>1 - <週>1 - - - <氏名> - <氏>山田 - <名>太郎 - - - <業務報告リスト> - <業務報告> - <業務名>XMLエディターの作成 - <業務コード>X3355-23 - <工数管理> - <見積もり工数>1600 - <実績工数>320 - <当月見積もり工数>160 - <当月実績工数>24 - - <予定項目リスト> - <予定項目> -

XMLエディターの基本仕様の作成

- - - <実施事項リスト> - <実施事項> -

XMLエディターの基本仕様の作成

- - <実施事項> -

競合他社製品の機能調査

- - - <上長への要請事項リスト> - <上長への要請事項> -

特になし

- - - <問題点対策> -

XMLとは何かわからない。

- - - - <業務報告> - <業務名>検索エンジンの開発 - <業務コード>S8821-76 - <工数管理> - <見積もり工数>120 - <実績工数>6 - <当月見積もり工数>32 - <当月実績工数>2 - - <予定項目リスト> - <予定項目> -

gooの機能を調べてみる

- - - <実施事項リスト> - <実施事項> -

更に、どういう検索エンジンがあるか調査する

- - - <上長への要請事項リスト> - <上長への要請事項> -

開発をするのはめんどうなので、Yahoo!を買収して下さい。

- - - <問題点対策> -

検索エンジンで車を走らせることができない。(要調査)

- - - - diff --git a/external/pugixml/tests/data/utftest_utf8_clean.xml b/external/pugixml/tests/data/utftest_utf8_clean.xml deleted file mode 100644 index 160807aba..000000000 --- a/external/pugixml/tests/data/utftest_utf8_clean.xml +++ /dev/null @@ -1,84 +0,0 @@ -<週報> - The world has many languages - Мир имеет много языков - el mundo tiene muchos idiomas - 世界有很多语言 - <Русский название="name" ценность="value"><имеет> - <汉语 名字="name" 价值="value">世界有很多语言𤭢 - quot;Mëtæl!quot; - <ä>Umlaut Element - - <年月週> - <年度>1997 - <月度>1 - <週>1 - - - <氏名> - <氏>山田 - <名>太郎 - - - <業務報告リスト> - <業務報告> - <業務名>XMLエディターの作成 - <業務コード>X3355-23 - <工数管理> - <見積もり工数>1600 - <実績工数>320 - <当月見積もり工数>160 - <当月実績工数>24 - - <予定項目リスト> - <予定項目> -

XMLエディターの基本仕様の作成

- - - <実施事項リスト> - <実施事項> -

XMLエディターの基本仕様の作成

- - <実施事項> -

競合他社製品の機能調査

- - - <上長への要請事項リスト> - <上長への要請事項> -

特になし

- - - <問題点対策> -

XMLとは何かわからない。

- - - - <業務報告> - <業務名>検索エンジンの開発 - <業務コード>S8821-76 - <工数管理> - <見積もり工数>120 - <実績工数>6 - <当月見積もり工数>32 - <当月実績工数>2 - - <予定項目リスト> - <予定項目> -

gooの機能を調べてみる

- - - <実施事項リスト> - <実施事項> -

更に、どういう検索エンジンがあるか調査する

- - - <上長への要請事項リスト> - <上長への要請事項> -

開発をするのはめんどうなので、Yahoo!を買収して下さい。

- - - <問題点対策> -

検索エンジンで車を走らせることができない。(要調査)

- - - - \ No newline at end of file diff --git a/external/pugixml/tests/data/utftest_utf8_nodecl.xml b/external/pugixml/tests/data/utftest_utf8_nodecl.xml deleted file mode 100644 index b908c5dee..000000000 --- a/external/pugixml/tests/data/utftest_utf8_nodecl.xml +++ /dev/null @@ -1,86 +0,0 @@ - - -<週報> - The world has many languages - Мир имеет много языков - el mundo tiene muchos idiomas - 世界有很多语言 - <Русский название="name" ценность="value"><имеет> - <汉语 名字="name" 价值="value">世界有很多语言𤭢 - "Mëtæl!" - <ä>Umlaut Element - - <年月週> - <年度>1997 - <月度>1 - <週>1 - - - <氏名> - <氏>山田 - <名>太郎 - - - <業務報告リスト> - <業務報告> - <業務名>XMLエディターの作成 - <業務コード>X3355-23 - <工数管理> - <見積もり工数>1600 - <実績工数>320 - <当月見積もり工数>160 - <当月実績工数>24 - - <予定項目リスト> - <予定項目> -

XMLエディターの基本仕様の作成

- - - <実施事項リスト> - <実施事項> -

XMLエディターの基本仕様の作成

- - <実施事項> -

競合他社製品の機能調査

- - - <上長への要請事項リスト> - <上長への要請事項> -

特になし

- - - <問題点対策> -

XMLとは何かわからない。

- - - - <業務報告> - <業務名>検索エンジンの開発 - <業務コード>S8821-76 - <工数管理> - <見積もり工数>120 - <実績工数>6 - <当月見積もり工数>32 - <当月実績工数>2 - - <予定項目リスト> - <予定項目> -

gooの機能を調べてみる

- - - <実施事項リスト> - <実施事項> -

更に、どういう検索エンジンがあるか調査する

- - - <上長への要請事項リスト> - <上長への要請事項> -

開発をするのはめんどうなので、Yahoo!を買収して下さい。

- - - <問題点対策> -

検索エンジンで車を走らせることができない。(要調査)

- - - - diff --git a/external/pugixml/tests/data/тест.xml b/external/pugixml/tests/data/тест.xml deleted file mode 100644 index 6187c16d7..000000000 --- a/external/pugixml/tests/data/тест.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/external/pugixml/tests/data_fuzz_parse/basic.xml b/external/pugixml/tests/data_fuzz_parse/basic.xml deleted file mode 100644 index a8eaa09d4..000000000 --- a/external/pugixml/tests/data_fuzz_parse/basic.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/external/pugixml/tests/data_fuzz_parse/doctype.xml b/external/pugixml/tests/data_fuzz_parse/doctype.xml deleted file mode 100644 index dd1831d1c..000000000 --- a/external/pugixml/tests/data_fuzz_parse/doctype.xml +++ /dev/null @@ -1 +0,0 @@ - ]> ]]> ]> ]> \ No newline at end of file diff --git a/external/pugixml/tests/data_fuzz_parse/refs.xml b/external/pugixml/tests/data_fuzz_parse/refs.xml deleted file mode 100644 index e42df5f69..000000000 --- a/external/pugixml/tests/data_fuzz_parse/refs.xml +++ /dev/null @@ -1 +0,0 @@ - pcdata < > & " ' « &unknown; %entity; \ No newline at end of file diff --git a/external/pugixml/tests/data_fuzz_parse/types.xml b/external/pugixml/tests/data_fuzz_parse/types.xml deleted file mode 100644 index dc6369a4a..000000000 --- a/external/pugixml/tests/data_fuzz_parse/types.xml +++ /dev/null @@ -1 +0,0 @@ - pcdata \ No newline at end of file diff --git a/external/pugixml/tests/data_fuzz_parse/utf16.xml b/external/pugixml/tests/data_fuzz_parse/utf16.xml deleted file mode 100644 index 3847a93954c31d41bfd07448bbacb669a247cf9d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 700 zcma)4Jx>Bb6r5rkO=vBw779D$Fd?GeK?E_H0209{u`p*qyoewID*wPp{L!9WK#?#trJYMi(C1Xu&}QaV*2)o<<5G%riTT zE$ktS3aTg}2mKg7inF%NbD7>83Oq${ORPFBh&wRP1o8c57>0?h8Ifg^%cJTm;(J8)$W^1Nb6PFhU4ELD%bdF0q!KzlB&XcbWlewL zEq<14QBqv!=Noe;_tnMW_yI(Z{R2OsNNJT-n_TNEsn(#Cqb#+mR`_@5Ntk~ADWVd! ztrCnlD#em`63q!} Tl0n|BMLemNoXPaX{8{(`!{K>3 diff --git a/external/pugixml/tests/data_fuzz_parse/utf32.xml b/external/pugixml/tests/data_fuzz_parse/utf32.xml deleted file mode 100644 index 51b8a89a2cba2383642768bd0b9d7c71222ed152..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 652 zcmaLTJBk895XSKimxZ}QYp(7@D) - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) -{ - pugi::xml_document doc; - - doc.load_buffer(Data, Size); - doc.load_buffer(Data, Size, pugi::parse_minimal); - doc.load_buffer(Data, Size, pugi::parse_full); - - return 0; -} diff --git a/external/pugixml/tests/fuzz_parse.dict b/external/pugixml/tests/fuzz_parse.dict deleted file mode 100644 index b1a0067bc..000000000 --- a/external/pugixml/tests/fuzz_parse.dict +++ /dev/null @@ -1,72 +0,0 @@ -# -# AFL dictionary for XML -# ---------------------- -# -# Several basic syntax elements and attributes, modeled on libxml2. -# -# Created by Michal Zalewski -# - -attr_encoding=" encoding=\"1\"" -attr_generic=" a=\"1\"" -attr_href=" href=\"1\"" -attr_standalone=" standalone=\"no\"" -attr_version=" version=\"1\"" -attr_xml_base=" xml:base=\"1\"" -attr_xml_id=" xml:id=\"1\"" -attr_xml_lang=" xml:lang=\"1\"" -attr_xml_space=" xml:space=\"1\"" -attr_xmlns=" xmlns=\"1\"" - -entity_builtin="<" -entity_decimal="" -entity_external="&a;" -entity_hex="" - -string_any="ANY" -string_brackets="[]" -string_cdata="CDATA" -string_col_fallback=":fallback" -string_col_generic=":a" -string_col_include=":include" -string_dashes="--" -string_empty="EMPTY" -string_empty_dblquotes="\"\"" -string_empty_quotes="''" -string_entities="ENTITIES" -string_entity="ENTITY" -string_fixed="#FIXED" -string_id="ID" -string_idref="IDREF" -string_idrefs="IDREFS" -string_implied="#IMPLIED" -string_nmtoken="NMTOKEN" -string_nmtokens="NMTOKENS" -string_notation="NOTATION" -string_parentheses="()" -string_pcdata="#PCDATA" -string_percent="%a" -string_public="PUBLIC" -string_required="#REQUIRED" -string_schema=":schema" -string_system="SYSTEM" -string_ucs4="UCS-4" -string_utf16="UTF-16" -string_utf8="UTF-8" -string_xmlns="xmlns:" - -tag_attlist="" -tag_doctype="" -tag_open_close="" -tag_open_exclamation="" -tag_xml_q="" diff --git a/external/pugixml/tests/fuzz_setup.sh b/external/pugixml/tests/fuzz_setup.sh deleted file mode 100755 index b8ba32dbb..000000000 --- a/external/pugixml/tests/fuzz_setup.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -sudo apt-get --yes install subversion screen gcc g++ cmake ninja-build golang autoconf libtool apache2 python-dev pkg-config zlib1g-dev libgcrypt11-dev - -mkdir -p clang -cd clang -git clone https://chromium.googlesource.com/chromium/src/tools/clang -cd .. -clang/clang/scripts/update.py -sudo cp -rf third_party/llvm-build/Release+Asserts/lib/* /usr/local/lib/ -sudo cp -rf third_party/llvm-build/Release+Asserts/bin/* /usr/local/bin diff --git a/external/pugixml/tests/fuzz_xpath.cpp b/external/pugixml/tests/fuzz_xpath.cpp deleted file mode 100644 index c7ff4cd0f..000000000 --- a/external/pugixml/tests/fuzz_xpath.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "../src/pugixml.hpp" - -#include -#include - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) -{ - char* text = new char[Size + 1]; - memcpy(text, Data, Size); - text[Size] = 0; - -#ifdef PUGIXML_NO_EXCEPTIONS - pugi::xpath_query q(text); -#else - try - { - pugi::xpath_query q(text); - } - catch (pugi::xpath_exception&) - { - } -#endif - - delete[] text; - return 0; -} diff --git a/external/pugixml/tests/fuzz_xpath.dict b/external/pugixml/tests/fuzz_xpath.dict deleted file mode 100644 index c469f6ef3..000000000 --- a/external/pugixml/tests/fuzz_xpath.dict +++ /dev/null @@ -1,72 +0,0 @@ -"boolean" -"count" -"contains" -"concat" -"ceiling" -"false" -"floor" -"id" -"last" -"lang" -"local-name" -"name" -"namespace-uri" -"normalize-space" -"not" -"number" -"position" -"round" -"string" -"string-length" -"starts-with" -"substring-before" -"substring-after" -"substring" -"sum" -"translate" -"true" -"ancestor" -"ancestor-or-self" -"attribute" -"child" -"descendant" -"descendant-or-self" -"following" -"following-sibling" -"namespace" -"parent" -"preceding" -"preceding-sibling" -"self" -"comment" -"node" -"processing-instruction" -"text" -"or" -"and" -"div" -"mod" -">" -">=" -"<" -"<=" -"!" -"!=" -"=" -"+" -"-" -"*" -"|" -"$" -"(" -")" -"[" -"]" -"," -"//" -"/" -".." -"." -"@" -"::" -":" diff --git a/external/pugixml/tests/helpers.hpp b/external/pugixml/tests/helpers.hpp deleted file mode 100644 index 6dfdc4b43..000000000 --- a/external/pugixml/tests/helpers.hpp +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef HEADER_TEST_HELPERS_HPP -#define HEADER_TEST_HELPERS_HPP - -#include "test.hpp" - -#include - -template static void generic_bool_ops_test(const T& obj) -{ - T null; - - CHECK(!null); - CHECK(obj); - CHECK(!!obj); - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4800) // forcing value to bool 'true' or 'false' (performance warning) - we really want to just cast to bool instead of !! -#endif - - bool b1 = null, b2 = obj; - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - - CHECK(!b1); - CHECK(b2); - - CHECK(obj && b2); - CHECK(obj || b2); - CHECK(obj && obj); - CHECK(obj || obj); -} - -template static void generic_eq_ops_test(const T& obj1, const T& obj2) -{ - T null = T(); - - // operator== - CHECK(null == null); - CHECK(obj1 == obj1); - CHECK(!(null == obj1)); - CHECK(!(null == obj2)); - CHECK(T(null) == null); - CHECK(T(obj1) == obj1); - - // operator!= - CHECK(!(null != null)); - CHECK(!(obj1 != obj1)); - CHECK(null != obj1); - CHECK(null != obj2); - CHECK(!(T(null) != null)); - CHECK(!(T(obj1) != obj1)); -} - -template static void generic_rel_ops_test(T obj1, T obj2) -{ - T null = T(); - - // obj1 < obj2 (we use operator<, but there is no other choice - if (obj1 > obj2) - { - T temp = obj1; - obj1 = obj2; - obj2 = temp; - } - - // operator< - CHECK(null < obj1); - CHECK(null < obj2); - CHECK(obj1 < obj2); - CHECK(!(null < null)); - CHECK(!(obj1 < obj1)); - CHECK(!(obj1 < null)); - CHECK(!(obj2 < obj1)); - - // operator<= - CHECK(null <= obj1); - CHECK(null <= obj2); - CHECK(obj1 <= obj2); - CHECK(null <= null); - CHECK(obj1 <= obj1); - CHECK(!(obj1 <= null)); - CHECK(!(obj2 <= obj1)); - - // operator> - CHECK(obj1 > null); - CHECK(obj2 > null); - CHECK(obj2 > obj1); - CHECK(!(null > null)); - CHECK(!(obj1 > obj1)); - CHECK(!(null > obj1)); - CHECK(!(obj1 > obj2)); - - // operator>= - CHECK(obj1 >= null); - CHECK(obj2 >= null); - CHECK(obj2 >= obj1); - CHECK(null >= null); - CHECK(obj1 >= obj1); - CHECK(!(null >= obj1)); - CHECK(!(obj1 >= obj2)); -} - -template static void generic_empty_test(const T& obj) -{ - T null; - - CHECK(null.empty()); - CHECK(!obj.empty()); -} - -#endif diff --git a/external/pugixml/tests/main.cpp b/external/pugixml/tests/main.cpp deleted file mode 100644 index 352b58bb0..000000000 --- a/external/pugixml/tests/main.cpp +++ /dev/null @@ -1,218 +0,0 @@ -#include "test.hpp" -#include "allocator.hpp" - -#include -#include -#include -#include - -#include - -#ifndef PUGIXML_NO_EXCEPTIONS -# include -#endif - -#ifdef _WIN32_WCE -# undef DebugBreak -# pragma warning(disable: 4201) // nonstandard extension used: nameless struct/union -# include -#endif - -test_runner* test_runner::_tests = 0; -size_t test_runner::_memory_fail_threshold = 0; -bool test_runner::_memory_fail_triggered = false; -jmp_buf test_runner::_failure_buffer; -const char* test_runner::_failure_message; -const char* test_runner::_temp_path; - -static size_t g_memory_total_size = 0; -static size_t g_memory_total_count = 0; -static size_t g_memory_fail_triggered = false; - -static void* custom_allocate(size_t size) -{ - if (test_runner::_memory_fail_threshold > 0 && test_runner::_memory_fail_threshold < g_memory_total_size + size) - { - g_memory_fail_triggered = true; - test_runner::_memory_fail_triggered = true; - - return 0; - } - else - { - void* ptr = memory_allocate(size); - if (!ptr) return 0; - - g_memory_total_size += memory_size(ptr); - g_memory_total_count++; - - return ptr; - } -} - -#ifndef PUGIXML_NO_EXCEPTIONS -static void* custom_allocate_throw(size_t size) -{ - void* result = custom_allocate(size); - - if (!result) - throw std::bad_alloc(); - - return result; -} -#endif - -static void custom_deallocate(void* ptr) -{ - assert(ptr); - - g_memory_total_size -= memory_size(ptr); - g_memory_total_count--; - - memory_deallocate(ptr); -} - -static void replace_memory_management() -{ - // create some document to touch original functions - { - pugi::xml_document doc; - doc.append_child().set_name(STR("node")); - } - - // replace functions - pugi::set_memory_management_functions(custom_allocate, custom_deallocate); -} - -#if defined(_MSC_VER) && _MSC_VER > 1200 && _MSC_VER < 1400 && !defined(__INTEL_COMPILER) && !defined(__DMC__) -#include - -namespace std -{ - _CRTIMP2 _Prhand _Raise_handler; - _CRTIMP2 void __cdecl _Throw(const exception&) {} -} -#endif - -static bool run_test(test_runner* test, const char* test_name, pugi::allocation_function allocate) -{ -#ifndef PUGIXML_NO_EXCEPTIONS - try - { -#endif - g_memory_total_size = 0; - g_memory_total_count = 0; - g_memory_fail_triggered = false; - test_runner::_memory_fail_threshold = 0; - test_runner::_memory_fail_triggered = false; - - pugi::set_memory_management_functions(allocate, custom_deallocate); - -#ifdef _MSC_VER -# pragma warning(push) -# pragma warning(disable: 4611) // interaction between _setjmp and C++ object destruction is non-portable -# pragma warning(disable: 4793) // function compiled as native: presence of '_setjmp' makes a function unmanaged -#endif - - volatile int result = setjmp(test_runner::_failure_buffer); - -#ifdef _MSC_VER -# pragma warning(pop) -#endif - - if (result) - { - printf("Test %s failed: %s\n", test_name, test_runner::_failure_message); - return false; - } - - test->run(); - - if (test_runner::_memory_fail_triggered) - { - printf("Test %s failed: unguarded memory fail triggered\n", test_name); - return false; - } - - if (g_memory_total_size != 0 || g_memory_total_count != 0) - { - printf("Test %s failed: memory leaks found (%u bytes in %u allocations)\n", test_name, static_cast(g_memory_total_size), static_cast(g_memory_total_count)); - return false; - } - - return true; -#ifndef PUGIXML_NO_EXCEPTIONS - } - catch (const std::exception& e) - { - printf("Test %s failed: exception %s\n", test_name, e.what()); - return false; - } - catch (...) - { - printf("Test %s failed for unknown reason\n", test_name); - return false; - } -#endif -} - -#if defined(__CELLOS_LV2__) && defined(PUGIXML_NO_EXCEPTIONS) && !defined(__SNC__) -#include - -void std::exception::_Raise() const -{ - abort(); -} -#endif - -int main(int, char** argv) -{ -#ifdef __BORLANDC__ - _control87(MCW_EM | PC_53, MCW_EM | MCW_PC); -#endif - - // setup temp path as the executable folder - std::string temp = argv[0]; - std::string::size_type slash = temp.find_last_of("\\/"); - temp.erase((slash != std::string::npos) ? slash + 1 : 0); - - test_runner::_temp_path = temp.c_str(); - - replace_memory_management(); - - unsigned int total = 0; - unsigned int passed = 0; - - test_runner* test = 0; // gcc3 "variable might be used uninitialized in this function" bug workaround - - for (test = test_runner::_tests; test; test = test->_next) - { - total++; - passed += run_test(test, test->_name, custom_allocate); - - if (g_memory_fail_triggered) - { - // run tests that trigger memory failures twice - with an allocator that returns NULL and with an allocator that throws - #ifndef PUGIXML_NO_EXCEPTIONS - total++; - passed += run_test(test, (test->_name + std::string(" (throw)")).c_str(), custom_allocate_throw); - #endif - } - } - - unsigned int failed = total - passed; - - if (failed != 0) - printf("FAILURE: %u out of %u tests failed.\n", failed, total); - else - printf("Success: %u tests passed.\n", total); - - return failed; -} - -#ifdef _WIN32_WCE -int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) -{ - return main(0, NULL); -} -#endif diff --git a/external/pugixml/tests/test.cpp b/external/pugixml/tests/test.cpp deleted file mode 100644 index a97116eae..000000000 --- a/external/pugixml/tests/test.cpp +++ /dev/null @@ -1,220 +0,0 @@ -#define _SCL_SECURE_NO_WARNINGS -#define _SCL_SECURE_NO_DEPRECATE - -#include "test.hpp" - -#include "writer_string.hpp" - -#include -#include -#include -#include - -#include -#include - -#ifndef PUGIXML_NO_XPATH -static void build_document_order(std::vector& result, pugi::xml_node root) -{ - result.push_back(pugi::xpath_node()); - - pugi::xml_node cur = root; - - for (;;) - { - result.push_back(cur); - - for (pugi::xml_attribute a = cur.first_attribute(); a; a = a.next_attribute()) - result.push_back(pugi::xpath_node(a, cur)); - - if (cur.first_child()) - cur = cur.first_child(); - else if (cur.next_sibling()) - cur = cur.next_sibling(); - else - { - while (cur && !cur.next_sibling()) cur = cur.parent(); - cur = cur.next_sibling(); - - if (!cur) break; - } - } -} -#endif - -bool test_string_equal(const pugi::char_t* lhs, const pugi::char_t* rhs) -{ - return (!lhs || !rhs) ? lhs == rhs : - #ifdef PUGIXML_WCHAR_MODE - wcscmp(lhs, rhs) == 0; - #else - strcmp(lhs, rhs) == 0; - #endif -} - -bool test_node(const pugi::xml_node& node, const pugi::char_t* contents, const pugi::char_t* indent, unsigned int flags) -{ - xml_writer_string writer; - - node.print(writer, indent, flags, get_native_encoding()); - - return writer.as_string() == contents; -} - -bool test_double_nan(double value) -{ -#if defined(_MSC_VER) || defined(__BORLANDC__) - return _isnan(value) != 0; -#else - return value != value; -#endif -} - -#ifndef PUGIXML_NO_XPATH -static size_t strlength(const pugi::char_t* s) -{ -#ifdef PUGIXML_WCHAR_MODE - return wcslen(s); -#else - return strlen(s); -#endif -} - -bool test_xpath_string(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables, const pugi::char_t* expected) -{ - pugi::xpath_query q(query, variables); - if (!q) return false; - - const size_t capacity = 64; - pugi::char_t result[capacity]; - - size_t size = q.evaluate_string(result, capacity, node); - - if (size != strlength(expected) + 1) - return false; - - if (size <= capacity) - return test_string_equal(result, expected); - - std::basic_string buffer(size, ' '); - - return q.evaluate_string(&buffer[0], size, node) == size && test_string_equal(buffer.c_str(), expected); -} - -bool test_xpath_boolean(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables, bool expected) -{ - pugi::xpath_query q(query, variables); - if (!q) return false; - - return q.evaluate_boolean(node) == expected; -} - -bool test_xpath_number(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables, double expected) -{ - pugi::xpath_query q(query, variables); - if (!q) return false; - - double value = q.evaluate_number(node); - double absolute_error = fabs(value - expected); - - const double tolerance = 1e-15; - return absolute_error < tolerance || absolute_error < fabs(expected) * tolerance; -} - -bool test_xpath_number_nan(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables) -{ - pugi::xpath_query q(query, variables); - if (!q) return false; - - return test_double_nan(q.evaluate_number(node)); -} - -bool test_xpath_fail_compile(const pugi::char_t* query, pugi::xpath_variable_set* variables) -{ -#ifdef PUGIXML_NO_EXCEPTIONS - return !pugi::xpath_query(query, variables); -#else - try - { - pugi::xpath_query q(query, variables); - return false; - } - catch (const pugi::xpath_exception&) - { - return true; - } -#endif -} - -void xpath_node_set_tester::check(bool condition) -{ - if (!condition) - { - test_runner::_failure_message = message; - longjmp(test_runner::_failure_buffer, 1); - } -} - -xpath_node_set_tester::xpath_node_set_tester(const pugi::xpath_node_set& set, const char* message_): last(0), message(message_) -{ - result = set; - - // only sort unsorted sets so that we're able to verify reverse order for some axes - if (result.type() == pugi::xpath_node_set::type_unsorted) result.sort(); - - if (result.empty()) - { - document_order = 0; - document_size = 0; - } - else - { - std::vector order; - build_document_order(order, (result[0].attribute() ? result[0].parent() : result[0].node()).root()); - - document_order = new pugi::xpath_node[order.size()]; - std::copy(order.begin(), order.end(), document_order); - - document_size = order.size(); - } -} - -xpath_node_set_tester::~xpath_node_set_tester() -{ - // check that we processed everything - check(last == result.size()); - - delete[] document_order; -} - -xpath_node_set_tester& xpath_node_set_tester::operator%(unsigned int expected) -{ - // check element count - check(last < result.size()); - - // check document order - check(expected < document_size); - check(result.begin()[last] == document_order[expected]); - - // continue to the next element - last++; - - return *this; -} - -#endif - -bool is_little_endian() -{ - unsigned int ui = 1; - return *reinterpret_cast(&ui) == 1; -} - -pugi::xml_encoding get_native_encoding() -{ -#ifdef PUGIXML_WCHAR_MODE - return pugi::encoding_wchar; -#else - return pugi::encoding_utf8; -#endif -} diff --git a/external/pugixml/tests/test.hpp b/external/pugixml/tests/test.hpp deleted file mode 100644 index dd14af681..000000000 --- a/external/pugixml/tests/test.hpp +++ /dev/null @@ -1,175 +0,0 @@ -#ifndef HEADER_TEST_TEST_HPP -#define HEADER_TEST_TEST_HPP - -#include "../src/pugixml.hpp" - -#include - -#ifndef PUGIXML_NO_EXCEPTIONS -#include -#endif - -struct test_runner -{ - test_runner(const char* name) - { - _name = name; - _next = _tests; - _tests = this; - } - - virtual ~test_runner() {} - - virtual void run() = 0; - - const char* _name; - test_runner* _next; - - static test_runner* _tests; - static size_t _memory_fail_threshold; - static bool _memory_fail_triggered; - static jmp_buf _failure_buffer; - static const char* _failure_message; - - static const char* _temp_path; -}; - -bool test_string_equal(const pugi::char_t* lhs, const pugi::char_t* rhs); - -template inline bool test_node_name_value(const Node& node, const pugi::char_t* name, const pugi::char_t* value) -{ - return test_string_equal(node.name(), name) && test_string_equal(node.value(), value); -} - -bool test_node(const pugi::xml_node& node, const pugi::char_t* contents, const pugi::char_t* indent, unsigned int flags); -bool test_double_nan(double value); - -#ifndef PUGIXML_NO_XPATH -bool test_xpath_string(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables, const pugi::char_t* expected); -bool test_xpath_boolean(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables, bool expected); -bool test_xpath_number(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables, double expected); -bool test_xpath_number_nan(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables); - -bool test_xpath_fail_compile(const pugi::char_t* query, pugi::xpath_variable_set* variables); - -struct xpath_node_set_tester -{ - pugi::xpath_node* document_order; - size_t document_size; - - pugi::xpath_node_set result; - unsigned int last; - const char* message; - - void check(bool condition); - - xpath_node_set_tester(const pugi::xpath_node_set& set, const char* message); - ~xpath_node_set_tester(); - - xpath_node_set_tester& operator%(unsigned int expected); -}; - -#endif - -struct dummy_fixture {}; - -#define TEST_FIXTURE(name, fixture) \ - struct test_runner_helper_##name: fixture \ - { \ - void run(); \ - }; \ - static struct test_runner_##name: test_runner \ - { \ - test_runner_##name(): test_runner(#name) {} \ - \ - virtual void run() PUGIXML_OVERRIDE \ - { \ - test_runner_helper_##name helper; \ - helper.run(); \ - } \ - } test_runner_instance_##name; \ - void test_runner_helper_##name::run() - -#define TEST(name) TEST_FIXTURE(name, dummy_fixture) - -#define TEST_XML_FLAGS(name, xml, flags) \ - struct test_fixture_##name \ - { \ - pugi::xml_document doc; \ - \ - test_fixture_##name() \ - { \ - CHECK(doc.load_string(PUGIXML_TEXT(xml), flags)); \ - } \ - \ - private: \ - test_fixture_##name(const test_fixture_##name&); \ - test_fixture_##name& operator=(const test_fixture_##name&); \ - }; \ - \ - TEST_FIXTURE(name, test_fixture_##name) - -#define TEST_XML(name, xml) TEST_XML_FLAGS(name, xml, pugi::parse_default) - -#define CHECK_JOIN(text, file, line) text " at " file ":" #line -#define CHECK_JOIN2(text, file, line) CHECK_JOIN(text, file, line) -#define CHECK_TEXT(condition, text) if (condition) ; else test_runner::_failure_message = CHECK_JOIN2(text, __FILE__, __LINE__), longjmp(test_runner::_failure_buffer, 1) -#define CHECK_FORCE_FAIL(text) test_runner::_failure_message = CHECK_JOIN2(text, __FILE__, __LINE__), longjmp(test_runner::_failure_buffer, 1) - -#if (defined(_MSC_VER) && _MSC_VER == 1200) || defined(__MWERKS__) || (defined(__BORLANDC__) && __BORLANDC__ <= 0x540) -# define STRINGIZE(value) "??" // Some compilers have issues with stringizing expressions that contain strings w/escaping inside -#else -# define STRINGIZE(value) #value -#endif - -#define CHECK(condition) CHECK_TEXT(condition, STRINGIZE(condition) " is false") -#define CHECK_STRING(value, expected) CHECK_TEXT(test_string_equal(value, expected), STRINGIZE(value) " is not equal to " STRINGIZE(expected)) -#define CHECK_DOUBLE(value, expected) CHECK_TEXT((value > expected ? value - expected : expected - value) < 1e-6, STRINGIZE(value) " is not equal to " STRINGIZE(expected)) -#define CHECK_DOUBLE_NAN(value) CHECK_TEXT(test_double_nan(value), STRINGIZE(value) " is not equal to NaN") -#define CHECK_NAME_VALUE(node, name, value) CHECK_TEXT(test_node_name_value(node, name, value), STRINGIZE(node) " name/value do not match " STRINGIZE(name) " and " STRINGIZE(value)) -#define CHECK_NODE_EX(node, expected, indent, flags) CHECK_TEXT(test_node(node, expected, indent, flags), STRINGIZE(node) " contents does not match " STRINGIZE(expected)) -#define CHECK_NODE(node, expected) CHECK_NODE_EX(node, expected, PUGIXML_TEXT(""), pugi::format_raw) - -#ifndef PUGIXML_NO_XPATH -#define CHECK_XPATH_STRING_VAR(node, query, variables, expected) CHECK_TEXT(test_xpath_string(node, query, variables, expected), STRINGIZE(query) " does not evaluate to " STRINGIZE(expected) " in context " STRINGIZE(node)) -#define CHECK_XPATH_BOOLEAN_VAR(node, query, variables, expected) CHECK_TEXT(test_xpath_boolean(node, query, variables, expected), STRINGIZE(query) " does not evaluate to " STRINGIZE(expected) " in context " STRINGIZE(node)) -#define CHECK_XPATH_NUMBER_VAR(node, query, variables, expected) CHECK_TEXT(test_xpath_number(node, query, variables, expected), STRINGIZE(query) " does not evaluate to " STRINGIZE(expected) " in context " STRINGIZE(node)) -#define CHECK_XPATH_NUMBER_NAN_VAR(node, query, variables) CHECK_TEXT(test_xpath_number_nan(node, query, variables), STRINGIZE(query) " does not evaluate to NaN in context " STRINGIZE(node)) -#define CHECK_XPATH_NODESET_VAR(node, query, variables) xpath_node_set_tester(pugi::xpath_query(query, variables).evaluate_node_set(node), CHECK_JOIN2(STRINGIZE(query) " does not evaluate to expected set in context " STRINGIZE(node), __FILE__, __LINE__)) -#define CHECK_XPATH_FAIL_VAR(query, variables) CHECK_TEXT(test_xpath_fail_compile(query, variables), STRINGIZE(query) " should not compile") - -#define CHECK_XPATH_STRING(node, query, expected) CHECK_XPATH_STRING_VAR(node, query, 0, expected) -#define CHECK_XPATH_BOOLEAN(node, query, expected) CHECK_XPATH_BOOLEAN_VAR(node, query, 0, expected) -#define CHECK_XPATH_NUMBER(node, query, expected) CHECK_XPATH_NUMBER_VAR(node, query, 0, expected) -#define CHECK_XPATH_NUMBER_NAN(node, query) CHECK_XPATH_NUMBER_NAN_VAR(node, query, 0) -#define CHECK_XPATH_NODESET(node, query) CHECK_XPATH_NODESET_VAR(node, query, 0) -#define CHECK_XPATH_FAIL(query) CHECK_XPATH_FAIL_VAR(query, 0) -#endif - -#ifdef PUGIXML_NO_EXCEPTIONS -#define CHECK_ALLOC_FAIL(code) do { CHECK(!test_runner::_memory_fail_triggered); code; CHECK(test_runner::_memory_fail_triggered); test_runner::_memory_fail_triggered = false; } while (test_runner::_memory_fail_triggered) -#else -#define CHECK_ALLOC_FAIL(code) do { CHECK(!test_runner::_memory_fail_triggered); try { code; } catch (std::bad_alloc&) {} CHECK(test_runner::_memory_fail_triggered); test_runner::_memory_fail_triggered = false; } while (test_runner::_memory_fail_triggered) -#endif - -#define STR(text) PUGIXML_TEXT(text) - -#if defined(__DMC__) || defined(__BORLANDC__) -#define U_LITERALS // DMC does not understand \x01234 (it parses first three digits), but understands \u01234 -#endif - -#if (defined(_MSC_VER) && _MSC_VER == 1200) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER == 800) || defined(__BORLANDC__) -// NaN comparison on MSVC6 is incorrect, see http://www.nabble.com/assertDoubleEquals,-NaN---Microsoft-Visual-Studio-6-td9137859.html -// IC8 and BCC are also affected by the same bug -# define MSVC6_NAN_BUG -#endif - -inline wchar_t wchar_cast(unsigned int value) -{ - return static_cast(value); // to avoid C4310 on MSVC -} - -bool is_little_endian(); -pugi::xml_encoding get_native_encoding(); - -#endif diff --git a/external/pugixml/tests/test_compact.cpp b/external/pugixml/tests/test_compact.cpp deleted file mode 100644 index 89bbfaa01..000000000 --- a/external/pugixml/tests/test_compact.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#ifdef PUGIXML_COMPACT -#include "test.hpp" - -using namespace pugi; - -static void overflow_hash_table(xml_document& doc) -{ - xml_node n = doc.child(STR("n")); - - // compact encoding assumes next_sibling is a forward-only pointer so we can allocate hash entries by reordering nodes - // we allocate enough hash entries to be exactly on the edge of rehash threshold - for (int i = 0; i < 8; ++i) - CHECK(n.prepend_child(node_element)); -} - -TEST_XML_FLAGS(compact_out_of_memory_string, "", parse_pi) -{ - test_runner::_memory_fail_threshold = 1; - - overflow_hash_table(doc); - - xml_attribute a = doc.child(STR("n")).attribute(STR("a")); - xml_node pi = doc.last_child(); - - CHECK_ALLOC_FAIL(CHECK(!pi.set_name(STR("name")))); - CHECK_ALLOC_FAIL(CHECK(!pi.set_value(STR("value")))); - CHECK_ALLOC_FAIL(CHECK(!a.set_name(STR("name")))); - CHECK_ALLOC_FAIL(CHECK(!a.set_value(STR("value")))); -} - -TEST_XML(compact_out_of_memory_attribute, "") -{ - test_runner::_memory_fail_threshold = 1; - - overflow_hash_table(doc); - - xml_node n = doc.child(STR("n")); - xml_attribute a = n.attribute(STR("a")); - - CHECK_ALLOC_FAIL(CHECK(!n.append_attribute(STR("")))); - CHECK_ALLOC_FAIL(CHECK(!n.prepend_attribute(STR("")))); - CHECK_ALLOC_FAIL(CHECK(!n.insert_attribute_after(STR(""), a))); - CHECK_ALLOC_FAIL(CHECK(!n.insert_attribute_before(STR(""), a))); -} - -TEST_XML(compact_out_of_memory_attribute_copy, "") -{ - test_runner::_memory_fail_threshold = 1; - - overflow_hash_table(doc); - - xml_node n = doc.child(STR("n")); - xml_attribute a = n.attribute(STR("a")); - - CHECK_ALLOC_FAIL(CHECK(!n.append_copy(a))); - CHECK_ALLOC_FAIL(CHECK(!n.prepend_copy(a))); - CHECK_ALLOC_FAIL(CHECK(!n.insert_copy_after(a, a))); - CHECK_ALLOC_FAIL(CHECK(!n.insert_copy_before(a, a))); -} - -TEST_XML(compact_out_of_memory_node, "") -{ - test_runner::_memory_fail_threshold = 1; - - overflow_hash_table(doc); - - xml_node n = doc.child(STR("n")); - - CHECK_ALLOC_FAIL(CHECK(!doc.append_child(node_element))); - CHECK_ALLOC_FAIL(CHECK(!doc.prepend_child(node_element))); - CHECK_ALLOC_FAIL(CHECK(!doc.insert_child_after(node_element, n))); - CHECK_ALLOC_FAIL(CHECK(!doc.insert_child_before(node_element, n))); -} - -TEST_XML(compact_out_of_memory_node_copy, "") -{ - test_runner::_memory_fail_threshold = 1; - - overflow_hash_table(doc); - - xml_node n = doc.child(STR("n")); - - CHECK_ALLOC_FAIL(CHECK(!doc.append_copy(n))); - CHECK_ALLOC_FAIL(CHECK(!doc.prepend_copy(n))); - CHECK_ALLOC_FAIL(CHECK(!doc.insert_copy_after(n, n))); - CHECK_ALLOC_FAIL(CHECK(!doc.insert_copy_before(n, n))); -} - -TEST_XML(compact_out_of_memory_node_move, "") -{ - test_runner::_memory_fail_threshold = 1; - - overflow_hash_table(doc); - - xml_node n = doc.child(STR("n")); - xml_node ne = doc.child(STR("ne")); - - CHECK_ALLOC_FAIL(CHECK(!doc.append_move(n))); - CHECK_ALLOC_FAIL(CHECK(!doc.prepend_move(n))); - CHECK_ALLOC_FAIL(CHECK(!doc.insert_move_after(n, ne))); - CHECK_ALLOC_FAIL(CHECK(!doc.insert_move_before(n, ne))); -} - -TEST_XML(compact_out_of_memory_remove, "") -{ - test_runner::_memory_fail_threshold = 1; - - overflow_hash_table(doc); - - xml_node n = doc.child(STR("n")); - xml_attribute a = n.attribute(STR("a")); - - CHECK_ALLOC_FAIL(CHECK(!n.remove_attribute(a))); - CHECK_ALLOC_FAIL(CHECK(!doc.remove_child(n))); -} - -TEST_XML(compact_pointer_attribute_list, "") -{ - xml_node n = doc.child(STR("n")); - xml_attribute a = n.attribute(STR("a")); - - // make sure we fill the page with node x - for (int i = 0; i < 1000; ++i) - doc.append_child(STR("x")); - - // this requires extended encoding for prev_attribute_c/next_attribute - n.append_attribute(STR("b")); - - // this requires extended encoding for first_attribute - n.remove_attribute(a); - - CHECK(!n.attribute(STR("a"))); - CHECK(n.attribute(STR("b"))); -} - -TEST_XML(compact_pointer_node_list, "") -{ - xml_node n = doc.child(STR("n")); - - // make sure we fill the page with node x - // this requires extended encoding for prev_sibling_c/next_sibling - for (int i = 0; i < 1000; ++i) - doc.append_child(STR("x")); - - // this requires extended encoding for first_child - n.append_child(STR("child")); - - CHECK(n.child(STR("child"))); -} -#endif diff --git a/external/pugixml/tests/test_deprecated.cpp b/external/pugixml/tests/test_deprecated.cpp deleted file mode 100644 index 81191107b..000000000 --- a/external/pugixml/tests/test_deprecated.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#define PUGIXML_DEPRECATED // Suppress deprecated declarations to avoid warnings - -#include "test.hpp" - -using namespace pugi; - -TEST(document_deprecated_load) -{ - xml_document doc; - CHECK(doc.load(STR(""))); - CHECK_NODE(doc, STR("")); -} - -#ifndef PUGIXML_NO_XPATH -TEST_XML(xpath_api_deprecated_select_single_node, "") -{ - xpath_node n1 = doc.select_single_node(STR("node/foo")); - - xpath_query q(STR("node/foo")); - xpath_node n2 = doc.select_single_node(q); - - CHECK(n1.node().attribute(STR("id")).as_int() == 1); - CHECK(n2.node().attribute(STR("id")).as_int() == 1); -} -#endif diff --git a/external/pugixml/tests/test_document.cpp b/external/pugixml/tests/test_document.cpp deleted file mode 100644 index 8ed2e2125..000000000 --- a/external/pugixml/tests/test_document.cpp +++ /dev/null @@ -1,1809 +0,0 @@ -#define _CRT_SECURE_NO_WARNINGS -#define _SCL_SECURE_NO_WARNINGS -#define _SCL_SECURE_NO_DEPRECATE -#define _CRT_NONSTDC_NO_DEPRECATE 0 - -#include // because Borland's STL is braindead, we have to include _before_ in order to get memcpy - -#include "test.hpp" - -#include "writer_string.hpp" - -#include -#include - -#include -#include - -#include -#include - -#ifndef PUGIXML_NO_EXCEPTIONS -# include -#endif - -#ifdef __MINGW32__ -# include // for unlink in C++0x mode -#endif - -#if defined(__CELLOS_LV2__) || defined(ANDROID) || defined(_GLIBCXX_HAVE_UNISTD_H) || defined(__APPLE__) -# include // for unlink -#endif - -using namespace pugi; - -static bool load_file_in_memory(const char* path, char*& data, size_t& size) -{ - FILE* file = fopen(path, "rb"); - if (!file) return false; - - fseek(file, 0, SEEK_END); - long length = ftell(file); - fseek(file, 0, SEEK_SET); - - CHECK(length >= 0); - size = static_cast(length); - data = new char[size]; - - CHECK(fread(data, 1, size, file) == size); - fclose(file); - - return true; -} - -static bool test_file_contents(const char* path, const char* data, size_t size) -{ - char* fdata; - size_t fsize; - if (!load_file_in_memory(path, fdata, fsize)) return false; - - bool result = (size == fsize && memcmp(data, fdata, size) == 0); - - delete[] fdata; - - return result; -} - -TEST(document_create_empty) -{ - xml_document doc; - CHECK_NODE(doc, STR("")); -} - -TEST(document_create) -{ - xml_document doc; - doc.append_child().set_name(STR("node")); - CHECK_NODE(doc, STR("")); -} - -#ifndef PUGIXML_NO_STL -TEST(document_load_stream) -{ - xml_document doc; - - std::istringstream iss(""); - CHECK(doc.load(iss)); - CHECK_NODE(doc, STR("")); -} - -TEST(document_load_stream_offset) -{ - xml_document doc; - - std::istringstream iss(" "); - - std::string s; - iss >> s; - - CHECK(doc.load(iss)); - CHECK_NODE(doc, STR("")); -} - -TEST(document_load_stream_text) -{ - xml_document doc; - - std::ifstream iss("tests/data/multiline.xml"); - CHECK(doc.load(iss)); - CHECK_NODE(doc, STR("")); -} - -TEST(document_load_stream_error) -{ - xml_document doc; - - std::ifstream fs("filedoesnotexist"); - CHECK(doc.load(fs).status == status_io_error); -} - -TEST(document_load_stream_out_of_memory) -{ - xml_document doc; - - std::istringstream iss(""); - test_runner::_memory_fail_threshold = 1; - CHECK_ALLOC_FAIL(CHECK(doc.load(iss).status == status_out_of_memory)); -} - -TEST(document_load_stream_wide_out_of_memory) -{ - xml_document doc; - - std::basic_istringstream iss(L""); - test_runner::_memory_fail_threshold = 1; - CHECK_ALLOC_FAIL(CHECK(doc.load(iss).status == status_out_of_memory)); -} - -TEST(document_load_stream_empty) -{ - std::istringstream iss; - - xml_document doc; - doc.load(iss); // parse result depends on STL implementation - CHECK(!doc.first_child()); -} - -TEST(document_load_stream_wide) -{ - xml_document doc; - - std::basic_istringstream iss(L""); - CHECK(doc.load(iss)); - CHECK_NODE(doc, STR("")); -} - -#ifndef PUGIXML_NO_EXCEPTIONS -TEST(document_load_stream_exceptions) -{ - xml_document doc; - - // Windows has newline translation for text-mode files, so reading from this stream reaches eof and sets fail|eof bits. - // This test does not cause stream to throw an exception on Linux - I have no idea how to get read() to fail except - // newline translation. - std::ifstream iss("tests/data/multiline.xml"); - iss.exceptions(std::ios::eofbit | std::ios::badbit | std::ios::failbit); - - try - { - doc.load(iss); - - CHECK(iss.good()); // if the exception was not thrown, stream reading should succeed without errors - } - catch (const std::ios_base::failure&) - { - CHECK(!doc.first_child()); - } -} -#endif - -TEST(document_load_stream_error_previous) -{ - xml_document doc; - CHECK(doc.load_string(STR(""))); - CHECK(doc.first_child()); - - std::ifstream fs1("filedoesnotexist"); - CHECK(doc.load(fs1).status == status_io_error); - CHECK(!doc.first_child()); -} - -TEST(document_load_stream_wide_error_previous) -{ - xml_document doc; - CHECK(doc.load_string(STR(""))); - CHECK(doc.first_child()); - - std::basic_ifstream fs1("filedoesnotexist"); - CHECK(doc.load(fs1).status == status_io_error); - CHECK(!doc.first_child()); -} - -template class char_array_buffer: public std::basic_streambuf -{ -public: - char_array_buffer(T* begin, T* end) - { - this->setg(begin, begin, end); - } -}; - -TEST(document_load_stream_nonseekable) -{ - char contents[] = ""; - char_array_buffer buffer(contents, contents + sizeof(contents) / sizeof(contents[0])); - std::istream in(&buffer); - - xml_document doc; - CHECK(doc.load(in)); - CHECK_NODE(doc, STR("")); -} - -TEST(document_load_stream_wide_nonseekable) -{ - wchar_t contents[] = L""; - char_array_buffer buffer(contents, contents + sizeof(contents) / sizeof(contents[0])); - std::basic_istream in(&buffer); - - xml_document doc; - CHECK(doc.load(in)); - CHECK_NODE(doc, STR("")); -} - -TEST(document_load_stream_nonseekable_large) -{ - std::basic_string str; - str += STR(""); - for (int i = 0; i < 10000; ++i) str += STR(""); - str += STR(""); - - char_array_buffer buffer(&str[0], &str[0] + str.length()); - std::basic_istream in(&buffer); - - xml_document doc; - CHECK(doc.load(in)); - CHECK_NODE(doc, str.c_str()); -} - -TEST(document_load_stream_nonseekable_out_of_memory) -{ - char contents[] = ""; - char_array_buffer buffer(contents, contents + sizeof(contents) / sizeof(contents[0])); - std::istream in(&buffer); - - test_runner::_memory_fail_threshold = 1; - - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory)); -} - -TEST(document_load_stream_wide_nonseekable_out_of_memory) -{ - wchar_t contents[] = L""; - char_array_buffer buffer(contents, contents + sizeof(contents) / sizeof(contents[0])); - std::basic_istream in(&buffer); - - test_runner::_memory_fail_threshold = 1; - - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory)); -} - -TEST(document_load_stream_nonseekable_out_of_memory_large) -{ - std::basic_string str; - str += ""; - for (int i = 0; i < 10000; ++i) str += ""; - str += ""; - - char_array_buffer buffer(&str[0], &str[0] + str.length()); - std::basic_istream in(&buffer); - - test_runner::_memory_fail_threshold = 32768 * 3 + 4096; - - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory)); -} - -TEST(document_load_stream_wide_nonseekable_out_of_memory_large) -{ - std::basic_string str; - str += L""; - for (int i = 0; i < 10000; ++i) str += L""; - str += L""; - - char_array_buffer buffer(&str[0], &str[0] + str.length()); - std::basic_istream in(&buffer); - - test_runner::_memory_fail_threshold = 32768 * 3 * sizeof(wchar_t) + 4096; - - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory)); -} - -template class seek_fail_buffer: public std::basic_streambuf -{ -public: - int seeks; - - seek_fail_buffer(): seeks(0) - { - } - - typename std::basic_streambuf::pos_type seekoff(typename std::basic_streambuf::off_type, std::ios_base::seekdir, std::ios_base::openmode) PUGIXML_OVERRIDE - { - seeks++; - - // pretend that our buffer is seekable (this is called by tellg) - return seeks == 1 ? 0 : -1; - } -}; - -TEST(document_load_stream_seekable_fail_seek) -{ - seek_fail_buffer buffer; - std::basic_istream in(&buffer); - - xml_document doc; - CHECK(doc.load(in).status == status_io_error); -} - -TEST(document_load_stream_wide_seekable_fail_seek) -{ - seek_fail_buffer buffer; - std::basic_istream in(&buffer); - - xml_document doc; - CHECK(doc.load(in).status == status_io_error); -} - -template class tell_fail_buffer: public std::basic_streambuf -{ -public: - int seeks; - - tell_fail_buffer(): seeks(0) - { - } - - typename std::basic_streambuf::pos_type seekoff(typename std::basic_streambuf::off_type, std::ios_base::seekdir dir, std::ios_base::openmode) PUGIXML_OVERRIDE - { - seeks++; - - return seeks > 1 && dir == std::ios_base::cur ? -1 : 0; - } - - typename std::basic_streambuf::pos_type seekpos(typename std::basic_streambuf::pos_type, std::ios_base::openmode) PUGIXML_OVERRIDE - { - return 0; - } -}; - -TEST(document_load_stream_seekable_fail_tell) -{ - tell_fail_buffer buffer; - std::basic_istream in(&buffer); - - xml_document doc; - CHECK(doc.load(in).status == status_io_error); -} - -TEST(document_load_stream_wide_seekable_fail_tell) -{ - tell_fail_buffer buffer; - std::basic_istream in(&buffer); - - xml_document doc; - CHECK(doc.load(in).status == status_io_error); -} - -#ifndef PUGIXML_NO_EXCEPTIONS -template class read_fail_buffer: public std::basic_streambuf -{ -public: - typename std::basic_streambuf::int_type underflow() PUGIXML_OVERRIDE - { - throw std::runtime_error("underflow failed"); - - #ifdef __DMC__ - return 0; - #endif - } -}; - -TEST(document_load_stream_nonseekable_fail_read) -{ - read_fail_buffer buffer; - std::basic_istream in(&buffer); - - xml_document doc; - CHECK(doc.load(in).status == status_io_error); -} - -TEST(document_load_stream_wide_nonseekable_fail_read) -{ - read_fail_buffer buffer; - std::basic_istream in(&buffer); - - xml_document doc; - CHECK(doc.load(in).status == status_io_error); -} - -template class read_fail_seekable_buffer: public std::basic_streambuf -{ -public: - typename std::basic_streambuf::pos_type offset; - - read_fail_seekable_buffer(): offset(0) - { - } - - typename std::basic_streambuf::int_type underflow() PUGIXML_OVERRIDE - { - throw std::runtime_error("underflow failed"); - - #ifdef __DMC__ - return 0; - #endif - } - - typename std::basic_streambuf::pos_type seekoff(typename std::basic_streambuf::off_type off, std::ios_base::seekdir dir, std::ios_base::openmode) PUGIXML_OVERRIDE - { - switch (dir) - { - case std::ios_base::beg: offset = off; break; - case std::ios_base::cur: offset += off; break; - case std::ios_base::end: offset = 16 + off; break; - default: ; - } - return offset; - } - - typename std::basic_streambuf::pos_type seekpos(typename std::basic_streambuf::pos_type pos, std::ios_base::openmode) PUGIXML_OVERRIDE - { - offset = pos; - return pos; - } -}; - -TEST(document_load_stream_seekable_fail_read) -{ - read_fail_seekable_buffer buffer; - std::basic_istream in(&buffer); - - xml_document doc; - CHECK(doc.load(in).status == status_io_error); -} - -TEST(document_load_stream_wide_seekable_fail_read) -{ - read_fail_seekable_buffer buffer; - std::basic_istream in(&buffer); - - xml_document doc; - CHECK(doc.load(in).status == status_io_error); -} -#endif -#endif - -TEST(document_load_string) -{ - xml_document doc; - - CHECK(doc.load_string(STR(""))); - CHECK_NODE(doc, STR("")); -} - -TEST(document_load_file) -{ - xml_document doc; - - CHECK(doc.load_file("tests/data/small.xml")); - CHECK_NODE(doc, STR("")); -} - -TEST(document_load_file_empty) -{ - xml_document doc; - - CHECK(doc.load_file("tests/data/empty.xml").status == status_no_document_element); - CHECK(!doc.first_child()); -} - -TEST(document_load_file_large) -{ - xml_document doc; - - CHECK(doc.load_file("tests/data/large.xml")); - - std::basic_string str; - str += STR(""); - for (int i = 0; i < 10000; ++i) str += STR(""); - str += STR(""); - - CHECK_NODE(doc, str.c_str()); -} - -TEST(document_load_file_error) -{ - xml_document doc; - - CHECK(doc.load_file("filedoesnotexist").status == status_file_not_found); -} - -TEST(document_load_file_out_of_memory) -{ - test_runner::_memory_fail_threshold = 1; - - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.load_file("tests/data/small.xml").status == status_out_of_memory)); -} - -TEST(document_load_file_out_of_memory_file_leak) -{ - test_runner::_memory_fail_threshold = 1; - - xml_document doc; - - for (int i = 0; i < 256; ++i) - CHECK_ALLOC_FAIL(CHECK(doc.load_file("tests/data/small.xml").status == status_out_of_memory)); - - test_runner::_memory_fail_threshold = 0; - - CHECK(doc.load_file("tests/data/small.xml")); - CHECK_NODE(doc, STR("")); -} - -TEST(document_load_file_wide_out_of_memory_file_leak) -{ - test_runner::_memory_fail_threshold = 256; - - xml_document doc; - - for (int i = 0; i < 256; ++i) - CHECK_ALLOC_FAIL(CHECK(doc.load_file(L"tests/data/small.xml").status == status_out_of_memory)); - - test_runner::_memory_fail_threshold = 0; - - CHECK(doc.load_file(L"tests/data/small.xml")); - CHECK_NODE(doc, STR("")); -} - -TEST(document_load_file_error_previous) -{ - xml_document doc; - CHECK(doc.load_string(STR(""))); - CHECK(doc.first_child()); - - CHECK(doc.load_file("filedoesnotexist").status == status_file_not_found); - CHECK(!doc.first_child()); -} - -TEST(document_load_file_wide_ascii) -{ - xml_document doc; - - CHECK(doc.load_file(L"tests/data/small.xml")); - CHECK_NODE(doc, STR("")); -} - -#if !defined(__DMC__) && !defined(__MWERKS__) && !(defined(__MINGW32__) && defined(__STRICT_ANSI__) && !defined(__MINGW64_VERSION_MAJOR)) && !defined(__BORLANDC__) -TEST(document_load_file_wide_unicode) -{ - xml_document doc; - - CHECK(doc.load_file(L"tests/data/\x0442\x0435\x0441\x0442.xml")); - CHECK_NODE(doc, STR("")); -} -#endif - -TEST(document_load_file_wide_out_of_memory) -{ - test_runner::_memory_fail_threshold = 1; - - xml_document doc; - - xml_parse_result result; - result.status = status_out_of_memory; - CHECK_ALLOC_FAIL(result = doc.load_file(L"tests/data/small.xml")); - - CHECK(result.status == status_out_of_memory || result.status == status_file_not_found); -} - -#if defined(__APPLE__) -TEST(document_load_file_special_folder) -{ - xml_document doc; - xml_parse_result result = doc.load_file("."); - CHECK(result.status == status_io_error); -} -#endif - -#if defined(__linux__) -TEST(document_load_file_special_device) -{ - xml_document doc; - xml_parse_result result = doc.load_file("/dev/tty"); - CHECK(result.status == status_file_not_found || result.status == status_io_error); -} -#endif - -TEST_XML(document_save, "") -{ - xml_writer_string writer; - - doc.save(writer, STR(""), format_no_declaration | format_raw, get_native_encoding()); - - CHECK(writer.as_string() == STR("")); -} - -#ifndef PUGIXML_NO_STL -TEST_XML(document_save_stream, "") -{ - std::ostringstream oss; - - doc.save(oss, STR(""), format_no_declaration | format_raw); - - CHECK(oss.str() == ""); -} - -TEST_XML(document_save_stream_wide, "") -{ - std::basic_ostringstream oss; - - doc.save(oss, STR(""), format_no_declaration | format_raw); - - CHECK(oss.str() == L""); -} -#endif - -TEST_XML(document_save_bom, "") -{ - unsigned int flags = format_no_declaration | format_raw | format_write_bom; - - // specific encodings - CHECK(test_save_narrow(doc, flags, encoding_utf8, "\xef\xbb\xbf", 7)); - CHECK(test_save_narrow(doc, flags, encoding_utf16_be, "\xfe\xff\x00<\x00n\x00/\x00>", 10)); - CHECK(test_save_narrow(doc, flags, encoding_utf16_le, "\xff\xfe<\x00n\x00/\x00>\x00", 10)); - CHECK(test_save_narrow(doc, flags, encoding_utf32_be, "\x00\x00\xfe\xff\x00\x00\x00<\x00\x00\x00n\x00\x00\x00/\x00\x00\x00>", 20)); - CHECK(test_save_narrow(doc, flags, encoding_utf32_le, "\xff\xfe\x00\x00<\x00\x00\x00n\x00\x00\x00/\x00\x00\x00>\x00\x00\x00", 20)); - CHECK(test_save_narrow(doc, flags, encoding_latin1, "", 4)); - - // encodings synonyms - CHECK(save_narrow(doc, flags, encoding_utf16) == save_narrow(doc, flags, (is_little_endian() ? encoding_utf16_le : encoding_utf16_be))); - CHECK(save_narrow(doc, flags, encoding_utf32) == save_narrow(doc, flags, (is_little_endian() ? encoding_utf32_le : encoding_utf32_be))); - - size_t wcharsize = sizeof(wchar_t); - CHECK(save_narrow(doc, flags, encoding_wchar) == save_narrow(doc, flags, (wcharsize == 2 ? encoding_utf16 : encoding_utf32))); -} - -TEST_XML(document_save_declaration, "") -{ - xml_writer_string writer; - - doc.save(writer, STR(""), format_default, get_native_encoding()); - - CHECK(writer.as_string() == STR("\n\n")); -} - -TEST(document_save_declaration_empty) -{ - xml_document doc; - - xml_writer_string writer; - - doc.save(writer, STR(""), format_default, get_native_encoding()); - - CHECK(writer.as_string() == STR("\n")); -} - -TEST_XML(document_save_declaration_present_first, "") -{ - doc.insert_child_before(node_declaration, doc.first_child()).append_attribute(STR("encoding")) = STR("utf8"); - - xml_writer_string writer; - - doc.save(writer, STR(""), format_default, get_native_encoding()); - - CHECK(writer.as_string() == STR("\n\n")); -} - -TEST_XML(document_save_declaration_present_second, "") -{ - doc.insert_child_before(node_declaration, doc.first_child()).append_attribute(STR("encoding")) = STR("utf8"); - doc.insert_child_before(node_comment, doc.first_child()).set_value(STR("text")); - - xml_writer_string writer; - - doc.save(writer, STR(""), format_default, get_native_encoding()); - - CHECK(writer.as_string() == STR("\n\n\n")); -} - -TEST_XML(document_save_declaration_present_last, "") -{ - doc.append_child(node_declaration).append_attribute(STR("encoding")) = STR("utf8"); - - xml_writer_string writer; - - doc.save(writer, STR(""), format_default, get_native_encoding()); - - // node writer only looks for declaration before the first element child - CHECK(writer.as_string() == STR("\n\n\n")); -} - -TEST_XML(document_save_declaration_latin1, "") -{ - xml_writer_string writer; - - doc.save(writer, STR(""), format_default, encoding_latin1); - - CHECK(writer.as_narrow() == "\n\n"); -} - -TEST_XML(document_save_declaration_raw, "") -{ - xml_writer_string writer; - - doc.save(writer, STR(""), format_raw, get_native_encoding()); - - CHECK(writer.as_string() == STR("")); -} - -struct temp_file -{ - char path[512]; - - temp_file() - { - static int index = 0; - sprintf(path, "%stempfile%d", test_runner::_temp_path, index++); - } - - ~temp_file() - { - #ifndef _WIN32_WCE - CHECK(unlink(path) == 0); - #endif - } -}; - -TEST_XML(document_save_file, "") -{ - temp_file f; - - CHECK(doc.save_file(f.path)); - - CHECK(doc.load_file(f.path, parse_default | parse_declaration)); - CHECK_NODE(doc, STR("")); -} - -TEST_XML(document_save_file_wide, "") -{ - temp_file f; - - // widen the path - wchar_t wpath[sizeof(f.path)]; - std::copy(f.path, f.path + strlen(f.path) + 1, wpath + 0); - - CHECK(doc.save_file(wpath)); - - CHECK(doc.load_file(f.path, parse_default | parse_declaration)); - CHECK_NODE(doc, STR("")); -} - -TEST_XML(document_save_file_error, "") -{ - CHECK(!doc.save_file("tests/data/unknown/output.xml")); -} - -TEST_XML(document_save_file_text, "") -{ - temp_file f; - - CHECK(doc.save_file(f.path, STR(""), format_no_declaration | format_save_file_text)); - CHECK(test_file_contents(f.path, "\n", 9) || test_file_contents(f.path, "\r\n", 10)); - - CHECK(doc.save_file(f.path, STR(""), format_no_declaration)); - CHECK(test_file_contents(f.path, "\n", 9)); -} - -TEST_XML(document_save_file_wide_text, "") -{ - temp_file f; - - // widen the path - wchar_t wpath[sizeof(f.path)]; - std::copy(f.path, f.path + strlen(f.path) + 1, wpath + 0); - - CHECK(doc.save_file(wpath, STR(""), format_no_declaration | format_save_file_text)); - CHECK(test_file_contents(f.path, "\n", 9) || test_file_contents(f.path, "\r\n", 10)); - - CHECK(doc.save_file(wpath, STR(""), format_no_declaration)); - CHECK(test_file_contents(f.path, "\n", 9)); -} - -TEST_XML(document_save_file_leak, "") -{ - temp_file f; - - for (int i = 0; i < 256; ++i) - CHECK(doc.save_file(f.path)); -} - -TEST_XML(document_save_file_wide_leak, "") -{ - temp_file f; - - // widen the path - wchar_t wpath[sizeof(f.path)]; - std::copy(f.path, f.path + strlen(f.path) + 1, wpath + 0); - - for (int i = 0; i < 256; ++i) - CHECK(doc.save_file(wpath)); -} - -TEST(document_load_buffer) -{ - const char_t text[] = STR(""); - - xml_document doc; - - CHECK(doc.load_buffer(text, sizeof(text))); - CHECK_NODE(doc, STR("")); -} - -TEST(document_load_buffer_inplace) -{ - char_t text[] = STR(""); - - xml_document doc; - - CHECK(doc.load_buffer_inplace(text, sizeof(text))); - CHECK_NODE(doc, STR("")); -} - -TEST(document_load_buffer_inplace_own) -{ - allocation_function alloc = get_memory_allocation_function(); - - size_t size = strlen("") * sizeof(char_t); - - char_t* text = static_cast(alloc(size)); - CHECK(text); - - memcpy(text, STR(""), size); - - xml_document doc; - - CHECK(doc.load_buffer_inplace_own(text, size)); - CHECK_NODE(doc, STR("")); -} - -TEST(document_parse_result_bool) -{ - xml_parse_result result; - - result.status = status_ok; - CHECK(result); - CHECK(!!result); - CHECK(result == true); - - for (int i = 1; i < 20; ++i) - { - result.status = static_cast(i); - CHECK(!result); - CHECK(result == false); - } -} - -TEST(document_parse_result_description) -{ - xml_parse_result result; - - for (int i = 0; i < 20; ++i) - { - result.status = static_cast(i); - - CHECK(result.description() != 0); - CHECK(result.description()[0] != 0); - } -} - -TEST(document_load_fail) -{ - xml_document doc; - CHECK(!doc.load_string(STR(""))); - CHECK(doc.child(STR("foo")).child(STR("bar"))); -} - -inline void check_utftest_document(const xml_document& doc) -{ - // ascii text - CHECK_STRING(doc.last_child().first_child().name(), STR("English")); - - // check that we have parsed some non-ascii text - CHECK(static_cast(doc.last_child().last_child().name()[0]) >= 0x80); - - // check magic string - const char_t* v = doc.last_child().child(STR("Heavy")).previous_sibling().child_value(); - -#ifdef PUGIXML_WCHAR_MODE - CHECK(v[0] == 0x4e16 && v[1] == 0x754c && v[2] == 0x6709 && v[3] == 0x5f88 && v[4] == 0x591a && v[5] == wchar_cast(0x8bed) && v[6] == wchar_cast(0x8a00)); - - // last character is a surrogate pair - size_t wcharsize = sizeof(wchar_t); - - CHECK(wcharsize == 2 ? (v[7] == wchar_cast(0xd852) && v[8] == wchar_cast(0xdf62)) : (v[7] == wchar_cast(0x24b62))); -#else - // unicode string - CHECK_STRING(v, "\xe4\xb8\x96\xe7\x95\x8c\xe6\x9c\x89\xe5\xbe\x88\xe5\xa4\x9a\xe8\xaf\xad\xe8\xa8\x80\xf0\xa4\xad\xa2"); -#endif -} - -TEST(document_load_file_convert_auto) -{ - const char* files[] = - { - "tests/data/utftest_utf16_be.xml", - "tests/data/utftest_utf16_be_bom.xml", - "tests/data/utftest_utf16_be_nodecl.xml", - "tests/data/utftest_utf16_le.xml", - "tests/data/utftest_utf16_le_bom.xml", - "tests/data/utftest_utf16_le_nodecl.xml", - "tests/data/utftest_utf32_be.xml", - "tests/data/utftest_utf32_be_bom.xml", - "tests/data/utftest_utf32_be_nodecl.xml", - "tests/data/utftest_utf32_le.xml", - "tests/data/utftest_utf32_le_bom.xml", - "tests/data/utftest_utf32_le_nodecl.xml", - "tests/data/utftest_utf8.xml", - "tests/data/utftest_utf8_bom.xml", - "tests/data/utftest_utf8_nodecl.xml" - }; - - xml_encoding encodings[] = - { - encoding_utf16_be, encoding_utf16_be, encoding_utf16_be, - encoding_utf16_le, encoding_utf16_le, encoding_utf16_le, - encoding_utf32_be, encoding_utf32_be, encoding_utf32_be, - encoding_utf32_le, encoding_utf32_le, encoding_utf32_le, - encoding_utf8, encoding_utf8, encoding_utf8 - }; - - for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i) - { - xml_document doc; - xml_parse_result res = doc.load_file(files[i]); - - CHECK(res); - CHECK(res.encoding == encodings[i]); - check_utftest_document(doc); - } -} - -TEST(document_load_file_convert_specific) -{ - const char* files[] = - { - "tests/data/utftest_utf16_be.xml", - "tests/data/utftest_utf16_be_bom.xml", - "tests/data/utftest_utf16_be_nodecl.xml", - "tests/data/utftest_utf16_le.xml", - "tests/data/utftest_utf16_le_bom.xml", - "tests/data/utftest_utf16_le_nodecl.xml", - "tests/data/utftest_utf32_be.xml", - "tests/data/utftest_utf32_be_bom.xml", - "tests/data/utftest_utf32_be_nodecl.xml", - "tests/data/utftest_utf32_le.xml", - "tests/data/utftest_utf32_le_bom.xml", - "tests/data/utftest_utf32_le_nodecl.xml", - "tests/data/utftest_utf8.xml", - "tests/data/utftest_utf8_bom.xml", - "tests/data/utftest_utf8_nodecl.xml" - }; - - xml_encoding encodings[] = - { - encoding_utf16_be, encoding_utf16_be, encoding_utf16_be, - encoding_utf16_le, encoding_utf16_le, encoding_utf16_le, - encoding_utf32_be, encoding_utf32_be, encoding_utf32_be, - encoding_utf32_le, encoding_utf32_le, encoding_utf32_le, - encoding_utf8, encoding_utf8, encoding_utf8 - }; - - for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i) - { - for (unsigned int j = 0; j < sizeof(files) / sizeof(files[0]); ++j) - { - xml_encoding encoding = encodings[j]; - - xml_document doc; - xml_parse_result res = doc.load_file(files[i], parse_default, encoding); - - if (encoding == encodings[i]) - { - CHECK(res); - CHECK(res.encoding == encoding); - check_utftest_document(doc); - } - else - { - // should not get past first tag - CHECK(!doc.first_child()); - } - } - } -} - -TEST(document_load_file_convert_native_endianness) -{ - const char* files[2][6] = - { - { - "tests/data/utftest_utf16_be.xml", - "tests/data/utftest_utf16_be_bom.xml", - "tests/data/utftest_utf16_be_nodecl.xml", - "tests/data/utftest_utf32_be.xml", - "tests/data/utftest_utf32_be_bom.xml", - "tests/data/utftest_utf32_be_nodecl.xml", - }, - { - "tests/data/utftest_utf16_le.xml", - "tests/data/utftest_utf16_le_bom.xml", - "tests/data/utftest_utf16_le_nodecl.xml", - "tests/data/utftest_utf32_le.xml", - "tests/data/utftest_utf32_le_bom.xml", - "tests/data/utftest_utf32_le_nodecl.xml", - } - }; - - xml_encoding encodings[] = - { - encoding_utf16, encoding_utf16, encoding_utf16, - encoding_utf32, encoding_utf32, encoding_utf32 - }; - - for (unsigned int i = 0; i < sizeof(files[0]) / sizeof(files[0][0]); ++i) - { - const char* right_file = files[is_little_endian()][i]; - const char* wrong_file = files[!is_little_endian()][i]; - - for (unsigned int j = 0; j < sizeof(encodings) / sizeof(encodings[0]); ++j) - { - xml_encoding encoding = encodings[j]; - - // check file with right endianness - { - xml_document doc; - xml_parse_result res = doc.load_file(right_file, parse_default, encoding); - - if (encoding == encodings[i]) - { - CHECK(res); - check_utftest_document(doc); - } - else - { - // should not get past first tag - CHECK(!doc.first_child()); - } - } - - // check file with wrong endianness - { - xml_document doc; - doc.load_file(wrong_file, parse_default, encoding); - CHECK(!doc.first_child()); - } - } - } -} - -struct file_data_t -{ - const char* path; - xml_encoding encoding; - - char* data; - size_t size; -}; - - -TEST(document_contents_preserve) -{ - file_data_t files[] = - { - {"tests/data/utftest_utf16_be_clean.xml", encoding_utf16_be, 0, 0}, - {"tests/data/utftest_utf16_le_clean.xml", encoding_utf16_le, 0, 0}, - {"tests/data/utftest_utf32_be_clean.xml", encoding_utf32_be, 0, 0}, - {"tests/data/utftest_utf32_le_clean.xml", encoding_utf32_le, 0, 0}, - {"tests/data/utftest_utf8_clean.xml", encoding_utf8, 0, 0} - }; - - // load files in memory - for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i) - { - CHECK(load_file_in_memory(files[i].path, files[i].data, files[i].size)); - } - - // convert each file to each format and compare bitwise - for (unsigned int src = 0; src < sizeof(files) / sizeof(files[0]); ++src) - { - for (unsigned int dst = 0; dst < sizeof(files) / sizeof(files[0]); ++dst) - { - // parse into document (preserve comments, declaration and whitespace pcdata) - xml_document doc; - CHECK(doc.load_buffer(files[src].data, files[src].size, parse_default | parse_ws_pcdata | parse_declaration | parse_comments)); - - // compare saved document with the original (raw formatting, without extra declaration, write bom if it was in original file) - CHECK(test_save_narrow(doc, format_raw | format_no_declaration | format_write_bom, files[dst].encoding, files[dst].data, files[dst].size)); - } - } - - // cleanup - for (unsigned int j = 0; j < sizeof(files) / sizeof(files[0]); ++j) - { - delete[] files[j].data; - } -} - -TEST(document_contents_preserve_latin1) -{ - file_data_t files[] = - { - {"tests/data/latintest_utf8.xml", encoding_utf8, 0, 0}, - {"tests/data/latintest_latin1.xml", encoding_latin1, 0, 0} - }; - - // load files in memory - for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i) - { - CHECK(load_file_in_memory(files[i].path, files[i].data, files[i].size)); - } - - // convert each file to each format and compare bitwise - for (unsigned int src = 0; src < sizeof(files) / sizeof(files[0]); ++src) - { - for (unsigned int dst = 0; dst < sizeof(files) / sizeof(files[0]); ++dst) - { - // parse into document (preserve comments, declaration and whitespace pcdata) - xml_document doc; - CHECK(doc.load_buffer(files[src].data, files[src].size, parse_default | parse_ws_pcdata | parse_declaration | parse_comments)); - - // compare saved document with the original (raw formatting, without extra declaration, write bom if it was in original file) - CHECK(test_save_narrow(doc, format_raw | format_no_declaration | format_write_bom, files[dst].encoding, files[dst].data, files[dst].size)); - } - } - - // cleanup - for (unsigned int j = 0; j < sizeof(files) / sizeof(files[0]); ++j) - { - delete[] files[j].data; - } -} - -static bool test_parse_fail(const void* buffer, size_t size, xml_encoding encoding = encoding_utf8) -{ - // copy buffer to heap (to enable out-of-bounds checks) - void* temp = malloc(size); - memcpy(temp, buffer, size); - - // check that this parses without buffer overflows (yielding an error) - xml_document doc; - bool result = doc.load_buffer_inplace(temp, size, parse_default, encoding); - - free(temp); - - return !result; -} - -TEST(document_convert_invalid_utf8) -{ - // invalid 1-byte input - CHECK(test_parse_fail("<\xb0", 2)); - - // invalid 2-byte input - CHECK(test_parse_fail("<\xc0", 2)); - CHECK(test_parse_fail("<\xd0", 2)); - - // invalid 3-byte input - CHECK(test_parse_fail("<\xe2\x80", 3)); - CHECK(test_parse_fail("<\xe2", 2)); - - // invalid 4-byte input - CHECK(test_parse_fail("<\xf2\x97\x98", 4)); - CHECK(test_parse_fail("<\xf2\x97", 3)); - CHECK(test_parse_fail("<\xf2", 2)); - - // invalid 5-byte input - CHECK(test_parse_fail("<\xf8", 2)); -} - -TEST(document_convert_invalid_utf16) -{ - // check non-terminated degenerate handling - CHECK(test_parse_fail("\x00<\xda\x1d", 4, encoding_utf16_be)); - CHECK(test_parse_fail("<\x00\x1d\xda", 4, encoding_utf16_le)); - - // check incorrect leading code - CHECK(test_parse_fail("\x00<\xde\x24", 4, encoding_utf16_be)); - CHECK(test_parse_fail("<\x00\x24\xde", 4, encoding_utf16_le)); -} - -TEST(document_load_buffer_empty) -{ - xml_encoding encodings[] = - { - encoding_auto, - encoding_utf8, - encoding_utf16_le, - encoding_utf16_be, - encoding_utf16, - encoding_utf32_le, - encoding_utf32_be, - encoding_utf32, - encoding_wchar, - encoding_latin1 - }; - - char buffer[1]; - - for (unsigned int i = 0; i < sizeof(encodings) / sizeof(encodings[0]); ++i) - { - xml_encoding encoding = encodings[i]; - - xml_document doc; - CHECK(doc.load_buffer(buffer, 0, parse_default, encoding).status == status_no_document_element && !doc.first_child()); - CHECK(doc.load_buffer(0, 0, parse_default, encoding).status == status_no_document_element && !doc.first_child()); - - CHECK(doc.load_buffer_inplace(buffer, 0, parse_default, encoding).status == status_no_document_element && !doc.first_child()); - CHECK(doc.load_buffer_inplace(0, 0, parse_default, encoding).status == status_no_document_element && !doc.first_child()); - - void* own_buffer = get_memory_allocation_function()(1); - - CHECK(doc.load_buffer_inplace_own(own_buffer, 0, parse_default, encoding).status == status_no_document_element && !doc.first_child()); - CHECK(doc.load_buffer_inplace_own(0, 0, parse_default, encoding).status == status_no_document_element && !doc.first_child()); - } -} - -TEST(document_load_buffer_empty_fragment) -{ - xml_encoding encodings[] = - { - encoding_auto, - encoding_utf8, - encoding_utf16_le, - encoding_utf16_be, - encoding_utf16, - encoding_utf32_le, - encoding_utf32_be, - encoding_utf32, - encoding_wchar, - encoding_latin1 - }; - - char buffer[1]; - - for (unsigned int i = 0; i < sizeof(encodings) / sizeof(encodings[0]); ++i) - { - xml_encoding encoding = encodings[i]; - - xml_document doc; - CHECK(doc.load_buffer(buffer, 0, parse_fragment, encoding) && !doc.first_child()); - CHECK(doc.load_buffer(0, 0, parse_fragment, encoding) && !doc.first_child()); - - CHECK(doc.load_buffer_inplace(buffer, 0, parse_fragment, encoding) && !doc.first_child()); - CHECK(doc.load_buffer_inplace(0, 0, parse_fragment, encoding) && !doc.first_child()); - - void* own_buffer = get_memory_allocation_function()(1); - - CHECK(doc.load_buffer_inplace_own(own_buffer, 0, parse_fragment, encoding) && !doc.first_child()); - CHECK(doc.load_buffer_inplace_own(0, 0, parse_fragment, encoding) && !doc.first_child()); - } -} - -TEST(document_load_buffer_null) -{ - xml_document doc; - - CHECK(doc.load_buffer(0, 12).status == status_io_error && !doc.first_child()); - CHECK(doc.load_buffer(0, 12, parse_fragment).status == status_io_error && !doc.first_child()); - - CHECK(doc.load_buffer_inplace(0, 12).status == status_io_error && !doc.first_child()); - CHECK(doc.load_buffer_inplace_own(0, 12).status == status_io_error && !doc.first_child()); -} - -TEST(document_progressive_truncation) -{ - char* original_data; - size_t original_size; - - CHECK(load_file_in_memory("tests/data/truncation.xml", original_data, original_size)); - - char* buffer = new char[original_size]; - - for (size_t i = 1; i <= original_size; ++i) - { - char* truncated_data = buffer + original_size - i; - - // default flags - { - memcpy(truncated_data, original_data, i); - - xml_document doc; - bool result = doc.load_buffer_inplace(truncated_data, i); - - // only eof is parseable - CHECK((i == original_size) ? result : !result); - } - - // fragment mode - { - memcpy(truncated_data, original_data, i); - - xml_document doc; - bool result = doc.load_buffer_inplace(truncated_data, i, parse_default | parse_fragment); - - // some truncate locations are parseable - those that come after declaration, declaration + doctype, declaration + doctype + comment and eof - CHECK(((i >= 21 && i <= 23) || (i >= 66 && i <= 68) || (i >= 95 && i <= 97) || i == original_size) ? result : !result); - } - } - - delete[] buffer; - delete[] original_data; -} - -TEST(document_load_buffer_short) -{ - char* data = new char[4]; - memcpy(data, "abcd", 4); - - xml_document doc; - - CHECK(doc.load_buffer(data, 4).status == status_no_document_element); - CHECK(doc.load_buffer(data + 1, 3).status == status_no_document_element); - CHECK(doc.load_buffer(data + 2, 2).status == status_no_document_element); - CHECK(doc.load_buffer(data + 3, 1).status == status_no_document_element); - CHECK(doc.load_buffer(data + 4, 0).status == status_no_document_element); - CHECK(doc.load_buffer(0, 0).status == status_no_document_element); - - delete[] data; -} - -TEST(document_load_buffer_short_fragment) -{ - char* data = new char[4]; - memcpy(data, "abcd", 4); - - xml_document doc; - - CHECK(doc.load_buffer(data, 4, parse_fragment) && test_string_equal(doc.text().get(), STR("abcd"))); - CHECK(doc.load_buffer(data + 1, 3, parse_fragment) && test_string_equal(doc.text().get(), STR("bcd"))); - CHECK(doc.load_buffer(data + 2, 2, parse_fragment) && test_string_equal(doc.text().get(), STR("cd"))); - CHECK(doc.load_buffer(data + 3, 1, parse_fragment) && test_string_equal(doc.text().get(), STR("d"))); - CHECK(doc.load_buffer(data + 4, 0, parse_fragment) && !doc.first_child()); - CHECK(doc.load_buffer(0, 0, parse_fragment) && !doc.first_child()); - - delete[] data; -} - -TEST(document_load_buffer_inplace_short) -{ - char* data = new char[4]; - memcpy(data, "abcd", 4); - - xml_document doc; - - CHECK(doc.load_buffer_inplace(data, 4).status == status_no_document_element); - CHECK(doc.load_buffer_inplace(data + 1, 3).status == status_no_document_element); - CHECK(doc.load_buffer_inplace(data + 2, 2).status == status_no_document_element); - CHECK(doc.load_buffer_inplace(data + 3, 1).status == status_no_document_element); - CHECK(doc.load_buffer_inplace(data + 4, 0).status == status_no_document_element); - CHECK(doc.load_buffer_inplace(0, 0).status == status_no_document_element); - - delete[] data; -} - -#ifndef PUGIXML_NO_EXCEPTIONS -TEST(document_load_exceptions) -{ - bool thrown = false; - - try - { - xml_document doc; - if (!doc.load_string(STR("", parse_default | parse_declaration | parse_comments) -{ - CHECK(doc.document_element() == doc.child(STR("node"))); -} - -TEST_XML_FLAGS(document_element_absent, "", parse_comments | parse_fragment) -{ - CHECK(doc.document_element() == xml_node()); -} - -TEST_XML(document_reset, "") -{ - CHECK(doc.first_child()); - - doc.reset(); - CHECK(!doc.first_child()); - CHECK_NODE(doc, STR("")); - - doc.reset(); - CHECK(!doc.first_child()); - CHECK_NODE(doc, STR("")); - - CHECK(doc.load_string(STR(""))); - CHECK(doc.first_child()); - CHECK_NODE(doc, STR("")); - - doc.reset(); - CHECK(!doc.first_child()); - CHECK_NODE(doc, STR("")); -} - -TEST(document_reset_empty) -{ - xml_document doc; - - doc.reset(); - CHECK(!doc.first_child()); - CHECK_NODE(doc, STR("")); -} - -TEST_XML(document_reset_copy, "") -{ - xml_document doc2; - - CHECK_NODE(doc2, STR("")); - - doc2.reset(doc); - - CHECK_NODE(doc2, STR("")); - CHECK(doc.first_child() != doc2.first_child()); - - doc.reset(doc2); - - CHECK_NODE(doc, STR("")); - CHECK(doc.first_child() != doc2.first_child()); - - CHECK(doc.first_child().offset_debug() == -1); -} - -TEST_XML(document_reset_copy_self, "") -{ - CHECK_NODE(doc, STR("")); - - doc.reset(doc); - - CHECK(!doc.first_child()); - CHECK_NODE(doc, STR("")); -} - -TEST(document_load_buffer_utf_truncated) -{ - const unsigned char utf8[] = {'<', 0xe2, 0x82, 0xac, '/', '>'}; - const unsigned char utf16_be[] = {0, '<', 0x20, 0xac, 0, '/', 0, '>'}; - const unsigned char utf16_le[] = {'<', 0, 0xac, 0x20, '/', 0, '>', 0}; - const unsigned char utf32_be[] = {0, 0, 0, '<', 0, 0, 0x20, 0xac, 0, 0, 0, '/', 0, 0, 0, '>'}; - const unsigned char utf32_le[] = {'<', 0, 0, 0, 0xac, 0x20, 0, 0, '/', 0, 0, 0, '>', 0, 0, 0}; - - struct document_data_t - { - xml_encoding encoding; - - const unsigned char* data; - size_t size; - }; - - const document_data_t data[] = - { - { encoding_utf8, utf8, sizeof(utf8) }, - { encoding_utf16_be, utf16_be, sizeof(utf16_be) }, - { encoding_utf16_le, utf16_le, sizeof(utf16_le) }, - { encoding_utf32_be, utf32_be, sizeof(utf32_be) }, - { encoding_utf32_le, utf32_le, sizeof(utf32_le) }, - }; - - for (size_t i = 0; i < sizeof(data) / sizeof(data[0]); ++i) - { - const document_data_t& d = data[i]; - - for (size_t j = 0; j <= d.size; ++j) - { - char* buffer = new char[j]; - memcpy(buffer, d.data, j); - - xml_document doc; - xml_parse_result res = doc.load_buffer(buffer, j, parse_default, d.encoding); - - if (j == d.size) - { - CHECK(res); - - const char_t* name = doc.first_child().name(); - - #ifdef PUGIXML_WCHAR_MODE - CHECK(name[0] == 0x20ac && name[1] == 0); - #else - CHECK_STRING(name, "\xe2\x82\xac"); - #endif - } - else - { - CHECK(!res || !doc.first_child()); - } - - delete[] buffer; - } - } -} - -#ifndef PUGIXML_NO_STL -TEST(document_load_stream_truncated) -{ - const unsigned char utf32_be[] = {0, 0, 0, '<', 0, 0, 0x20, 0xac, 0, 0, 0, '/', 0, 0, 0, '>'}; - - for (size_t i = 0; i <= sizeof(utf32_be); ++i) - { - std::string prefix(reinterpret_cast(utf32_be), i); - std::istringstream iss(prefix); - - xml_document doc; - xml_parse_result res = doc.load(iss); - - if (i == sizeof(utf32_be)) - { - CHECK(res); - } - else - { - CHECK(!res || !doc.first_child()); - - if (i < 8) - { - CHECK(!doc.first_child()); - } - else - { - const char_t* name = doc.first_child().name(); - - #ifdef PUGIXML_WCHAR_MODE - CHECK(name[0] == 0x20ac && name[1] == 0); - #else - CHECK_STRING(name, "\xe2\x82\xac"); - #endif - } - } - } -} -#endif - -TEST(document_alignment) -{ - char buf[256 + sizeof(xml_document)]; - - for (size_t offset = 0; offset < 256; offset += sizeof(void*)) - { - xml_document* doc = new (buf + offset) xml_document; - - CHECK(doc->load_string(STR(""))); - CHECK_NODE(*doc, STR("")); - - doc->~xml_document(); - } -} - -TEST(document_convert_out_of_memory) -{ - file_data_t files[] = - { - {"tests/data/utftest_utf16_be_clean.xml", encoding_utf16_be, 0, 0}, - {"tests/data/utftest_utf16_le_clean.xml", encoding_utf16_le, 0, 0}, - {"tests/data/utftest_utf32_be_clean.xml", encoding_utf32_be, 0, 0}, - {"tests/data/utftest_utf32_le_clean.xml", encoding_utf32_le, 0, 0}, - {"tests/data/utftest_utf8_clean.xml", encoding_utf8, 0, 0}, - {"tests/data/latintest_latin1.xml", encoding_latin1, 0, 0} - }; - - // load files in memory - for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i) - { - CHECK(load_file_in_memory(files[i].path, files[i].data, files[i].size)); - } - - // disallow allocations - test_runner::_memory_fail_threshold = 1; - - for (unsigned int src = 0; src < sizeof(files) / sizeof(files[0]); ++src) - { - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.load_buffer(files[src].data, files[src].size, parse_default, files[src].encoding).status == status_out_of_memory)); - } - - // cleanup - for (unsigned int j = 0; j < sizeof(files) / sizeof(files[0]); ++j) - { - delete[] files[j].data; - } -} - -#ifdef PUGIXML_HAS_MOVE -TEST_XML(document_move_ctor, "") -{ - xml_document other = std::move(doc); - - CHECK(doc.first_child().empty()); - - CHECK_STRING(other.first_child().name(), STR("node1")); - CHECK(other.first_child().parent() == other); - - CHECK_STRING(other.last_child().name(), STR("node2")); - CHECK(other.last_child().parent() == other); -} - -TEST_XML(document_move_assign, "") -{ - xml_document other; - CHECK(other.load_string(STR(""))); - - other = std::move(doc); - - CHECK(doc.first_child().empty()); - - CHECK_STRING(other.first_child().name(), STR("node1")); - CHECK(other.first_child().parent() == other); - - CHECK_STRING(other.last_child().name(), STR("node2")); - CHECK(other.last_child().parent() == other); -} - -TEST_XML(document_move_zero_alloc, "") -{ - test_runner::_memory_fail_threshold = 1; - - xml_document other = std::move(doc); - - CHECK(doc.first_child().empty()); - - CHECK_STRING(other.first_child().name(), STR("node1")); - CHECK(other.first_child().parent() == other); - - CHECK_STRING(other.last_child().name(), STR("node2")); - CHECK(other.last_child().parent() == other); -} - -TEST(document_move_append_buffer) -{ - xml_document* doc = new xml_document(); - CHECK(doc->load_string(STR(""))); - CHECK(doc->child(STR("node1")).append_buffer("", 8)); - CHECK(doc->child(STR("node1")).append_buffer("", 8)); - - xml_document other = std::move(*doc); - delete doc; - - CHECK(other.child(STR("node1")).append_buffer("", 8)); - CHECK(other.child(STR("node1")).append_buffer("", 8)); - - CHECK_NODE(other, STR("")); -} - -TEST(document_move_append_child) -{ - xml_document* doc = new xml_document(); - CHECK(doc->load_string(STR(""))); - - xml_document other = std::move(*doc); - delete doc; - - for (int i = 0; i < 3000; ++i) - other.child(STR("node1")).append_child(STR("node")); - - for (int i = 0; i < 3000; ++i) - other.child(STR("node1")).remove_child(other.child(STR("node1")).last_child()); - - CHECK_NODE(other, STR("")); - - other.remove_child(other.first_child()); - - CHECK(!other.first_child()); -} - -TEST(document_move_empty) -{ - xml_document* doc = new xml_document(); - xml_document other = std::move(*doc); - delete doc; -} - -TEST(document_move_large) -{ - xml_document* doc = new xml_document(); - - xml_node dn = doc->append_child(STR("node")); - - for (int i = 0; i < 3000; ++i) - dn.append_child(STR("child")); - - xml_document other = std::move(*doc); - delete doc; - - xml_node on = other.child(STR("node")); - - for (int i = 0; i < 3000; ++i) - CHECK(on.remove_child(on.first_child())); - - CHECK(!on.first_child()); -} - -TEST_XML(document_move_buffer, "") -{ - CHECK(doc.child(STR("node2")).offset_debug() == 9); - - xml_document other = std::move(doc); - - CHECK(other.child(STR("node2")).offset_debug() == 9); -} - -TEST_XML(document_move_append_child_zero_alloc, "") -{ - test_runner::_memory_fail_threshold = 1; - - xml_document other = std::move(doc); - - CHECK(other.append_child(STR("node3"))); - - CHECK_NODE(other, STR("")); -} - -TEST(document_move_empty_zero_alloc) -{ - xml_document* docs = new xml_document[32]; - - test_runner::_memory_fail_threshold = 1; - - for (int i = 1; i < 32; ++i) - docs[i] = std::move(docs[i-1]); - - delete[] docs; -} - -#ifndef PUGIXML_COMPACT -TEST(document_move_repeated_zero_alloc) -{ - xml_document docs[32]; - - CHECK(docs[0].load_string(STR(""))); - - test_runner::_memory_fail_threshold = 1; - - for (int i = 1; i < 32; ++i) - docs[i] = std::move(docs[i-1]); - - for (int i = 0; i < 31; ++i) - CHECK(!docs[i].first_child()); - - CHECK_NODE(docs[31], STR("")); -} -#endif - -#ifdef PUGIXML_COMPACT -TEST(document_move_compact_fail) -{ - xml_document docs[32]; - - CHECK(docs[0].load_string(STR(""))); - - test_runner::_memory_fail_threshold = 1; - - int safe_count = 21; - - for (int i = 1; i <= safe_count; ++i) - docs[i] = std::move(docs[i-1]); - - CHECK_ALLOC_FAIL(docs[safe_count+1] = std::move(docs[safe_count])); - - for (int i = 0; i < safe_count; ++i) - CHECK(!docs[i].first_child()); - - CHECK_NODE(docs[safe_count], STR("")); - CHECK(!docs[safe_count+1].first_child()); -} -#endif -#endif diff --git a/external/pugixml/tests/test_dom_modify.cpp b/external/pugixml/tests/test_dom_modify.cpp deleted file mode 100644 index ff9d4407e..000000000 --- a/external/pugixml/tests/test_dom_modify.cpp +++ /dev/null @@ -1,1845 +0,0 @@ -#include "test.hpp" - -#include -#include - -#include -#include -#include - -using namespace pugi; - -TEST_XML(dom_attr_assign, "") -{ - xml_node node = doc.child(STR("node")); - - node.append_attribute(STR("attr1")) = STR("v1"); - xml_attribute() = STR("v1"); - - node.append_attribute(STR("attr2")) = -2147483647; - node.append_attribute(STR("attr3")) = -2147483647 - 1; - xml_attribute() = -2147483647 - 1; - - node.append_attribute(STR("attr4")) = 4294967295u; - node.append_attribute(STR("attr5")) = 4294967294u; - xml_attribute() = 4294967295u; - - node.append_attribute(STR("attr6")) = 0.5; - xml_attribute() = 0.5; - - node.append_attribute(STR("attr7")) = 0.25f; - xml_attribute() = 0.25f; - - node.append_attribute(STR("attr8")) = true; - xml_attribute() = true; - - CHECK_NODE(node, STR("")); -} - -TEST_XML(dom_attr_set_name, "") -{ - xml_attribute attr = doc.child(STR("node")).attribute(STR("attr")); - - CHECK(attr.set_name(STR("n"))); - CHECK(!xml_attribute().set_name(STR("n"))); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_attr_set_value, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.append_attribute(STR("attr1")).set_value(STR("v1"))); - CHECK(!xml_attribute().set_value(STR("v1"))); - - CHECK(node.append_attribute(STR("attr2")).set_value(-2147483647)); - CHECK(node.append_attribute(STR("attr3")).set_value(-2147483647 - 1)); - CHECK(!xml_attribute().set_value(-2147483647)); - - CHECK(node.append_attribute(STR("attr4")).set_value(4294967295u)); - CHECK(node.append_attribute(STR("attr5")).set_value(4294967294u)); - CHECK(!xml_attribute().set_value(4294967295u)); - - CHECK(node.append_attribute(STR("attr6")).set_value(0.5)); - CHECK(!xml_attribute().set_value(0.5)); - - CHECK(node.append_attribute(STR("attr7")).set_value(0.25f)); - CHECK(!xml_attribute().set_value(0.25f)); - - CHECK(node.append_attribute(STR("attr8")).set_value(true)); - CHECK(!xml_attribute().set_value(true)); - - CHECK_NODE(node, STR("")); -} - -#if LONG_MAX > 2147483647 -TEST_XML(dom_attr_assign_long, "") -{ - xml_node node = doc.child(STR("node")); - - node.append_attribute(STR("attr1")) = -9223372036854775807l; - node.append_attribute(STR("attr2")) = -9223372036854775807l - 1; - xml_attribute() = -9223372036854775807l - 1; - - node.append_attribute(STR("attr3")) = 18446744073709551615ul; - node.append_attribute(STR("attr4")) = 18446744073709551614ul; - xml_attribute() = 18446744073709551615ul; - - CHECK_NODE(node, STR("")); -} - -TEST_XML(dom_attr_set_value_long, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.append_attribute(STR("attr1")).set_value(-9223372036854775807l)); - CHECK(node.append_attribute(STR("attr2")).set_value(-9223372036854775807l - 1)); - CHECK(!xml_attribute().set_value(-9223372036854775807l - 1)); - - CHECK(node.append_attribute(STR("attr3")).set_value(18446744073709551615ul)); - CHECK(node.append_attribute(STR("attr4")).set_value(18446744073709551614ul)); - CHECK(!xml_attribute().set_value(18446744073709551615ul)); - - CHECK_NODE(node, STR("")); -} -#else -TEST_XML(dom_attr_assign_long, "") -{ - xml_node node = doc.child(STR("node")); - - node.append_attribute(STR("attr1")) = -2147483647l; - node.append_attribute(STR("attr2")) = -2147483647l - 1; - xml_attribute() = -2147483647l - 1; - - node.append_attribute(STR("attr3")) = 4294967295ul; - node.append_attribute(STR("attr4")) = 4294967294ul; - xml_attribute() = 4294967295ul; - - CHECK_NODE(node, STR("")); -} - -TEST_XML(dom_attr_set_value_long, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.append_attribute(STR("attr1")).set_value(-2147483647l)); - CHECK(node.append_attribute(STR("attr2")).set_value(-2147483647l - 1)); - CHECK(!xml_attribute().set_value(-2147483647l - 1)); - - CHECK(node.append_attribute(STR("attr3")).set_value(4294967295ul)); - CHECK(node.append_attribute(STR("attr4")).set_value(4294967294ul)); - CHECK(!xml_attribute().set_value(4294967295ul)); - - CHECK_NODE(node, STR("")); -} -#endif - -#ifdef PUGIXML_HAS_LONG_LONG -TEST_XML(dom_attr_assign_llong, "") -{ - xml_node node = doc.child(STR("node")); - - node.append_attribute(STR("attr1")) = -9223372036854775807ll; - node.append_attribute(STR("attr2")) = -9223372036854775807ll - 1; - xml_attribute() = -9223372036854775807ll - 1; - - node.append_attribute(STR("attr3")) = 18446744073709551615ull; - node.append_attribute(STR("attr4")) = 18446744073709551614ull; - xml_attribute() = 18446744073709551615ull; - - CHECK_NODE(node, STR("")); -} - -TEST_XML(dom_attr_set_value_llong, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.append_attribute(STR("attr1")).set_value(-9223372036854775807ll)); - CHECK(node.append_attribute(STR("attr2")).set_value(-9223372036854775807ll - 1)); - CHECK(!xml_attribute().set_value(-9223372036854775807ll - 1)); - - CHECK(node.append_attribute(STR("attr3")).set_value(18446744073709551615ull)); - CHECK(node.append_attribute(STR("attr4")).set_value(18446744073709551614ull)); - CHECK(!xml_attribute().set_value(18446744073709551615ull)); - - CHECK_NODE(node, STR("")); -} -#endif - -TEST_XML(dom_attr_assign_large_number_float, "") -{ - xml_node node = doc.child(STR("node")); - - node.attribute(STR("attr")) = std::numeric_limits::max(); - - CHECK(test_node(node, STR(""), STR(""), format_raw) || - test_node(node, STR(""), STR(""), format_raw)); -} - -TEST_XML(dom_attr_assign_large_number_double, "") -{ - xml_node node = doc.child(STR("node")); - - node.attribute(STR("attr")) = std::numeric_limits::max(); - - // Borland C does not print double values with enough precision -#ifdef __BORLANDC__ - CHECK_NODE(node, STR("")); -#else - CHECK_NODE(node, STR("")); -#endif -} - -TEST_XML(dom_node_set_name, "text") -{ - CHECK(doc.child(STR("node")).set_name(STR("n"))); - CHECK(!doc.child(STR("node")).first_child().set_name(STR("n"))); - CHECK(!xml_node().set_name(STR("n"))); - - CHECK_NODE(doc, STR("text")); -} - -TEST_XML(dom_node_set_value, "text") -{ - CHECK(doc.child(STR("node")).first_child().set_value(STR("no text"))); - CHECK(!doc.child(STR("node")).set_value(STR("no text"))); - CHECK(!xml_node().set_value(STR("no text"))); - - CHECK_NODE(doc, STR("no text")); -} - -TEST_XML(dom_node_set_value_allocated, "text") -{ - CHECK(doc.child(STR("node")).first_child().set_value(STR("no text"))); - CHECK(!doc.child(STR("node")).set_value(STR("no text"))); - CHECK(!xml_node().set_value(STR("no text"))); - CHECK(doc.child(STR("node")).first_child().set_value(STR("no text at all"))); - - CHECK_NODE(doc, STR("no text at all")); -} - -TEST_XML(dom_node_prepend_attribute, "") -{ - CHECK(xml_node().prepend_attribute(STR("a")) == xml_attribute()); - CHECK(doc.prepend_attribute(STR("a")) == xml_attribute()); - - xml_attribute a1 = doc.child(STR("node")).prepend_attribute(STR("a1")); - CHECK(a1); - a1 = STR("v1"); - - xml_attribute a2 = doc.child(STR("node")).prepend_attribute(STR("a2")); - CHECK(a2 && a1 != a2); - a2 = STR("v2"); - - xml_attribute a3 = doc.child(STR("node")).child(STR("child")).prepend_attribute(STR("a3")); - CHECK(a3 && a1 != a3 && a2 != a3); - a3 = STR("v3"); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_append_attribute, "") -{ - CHECK(xml_node().append_attribute(STR("a")) == xml_attribute()); - CHECK(doc.append_attribute(STR("a")) == xml_attribute()); - - xml_attribute a1 = doc.child(STR("node")).append_attribute(STR("a1")); - CHECK(a1); - a1 = STR("v1"); - - xml_attribute a2 = doc.child(STR("node")).append_attribute(STR("a2")); - CHECK(a2 && a1 != a2); - a2 = STR("v2"); - - xml_attribute a3 = doc.child(STR("node")).child(STR("child")).append_attribute(STR("a3")); - CHECK(a3 && a1 != a3 && a2 != a3); - a3 = STR("v3"); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_insert_attribute_after, "") -{ - CHECK(xml_node().insert_attribute_after(STR("a"), xml_attribute()) == xml_attribute()); - - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - xml_attribute a1 = node.attribute(STR("a1")); - xml_attribute a2 = child.attribute(STR("a2")); - - CHECK(node.insert_attribute_after(STR("a"), xml_attribute()) == xml_attribute()); - CHECK(node.insert_attribute_after(STR("a"), a2) == xml_attribute()); - - xml_attribute a3 = node.insert_attribute_after(STR("a3"), a1); - CHECK(a3 && a3 != a2 && a3 != a1); - a3 = STR("v3"); - - xml_attribute a4 = node.insert_attribute_after(STR("a4"), a1); - CHECK(a4 && a4 != a3 && a4 != a2 && a4 != a1); - a4 = STR("v4"); - - xml_attribute a5 = node.insert_attribute_after(STR("a5"), a3); - CHECK(a5 && a5 != a4 && a5 != a3 && a5 != a2 && a5 != a1); - a5 = STR("v5"); - - CHECK(child.insert_attribute_after(STR("a"), a4) == xml_attribute()); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_insert_attribute_before, "") -{ - CHECK(xml_node().insert_attribute_before(STR("a"), xml_attribute()) == xml_attribute()); - - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - xml_attribute a1 = node.attribute(STR("a1")); - xml_attribute a2 = child.attribute(STR("a2")); - - CHECK(node.insert_attribute_before(STR("a"), xml_attribute()) == xml_attribute()); - CHECK(node.insert_attribute_before(STR("a"), a2) == xml_attribute()); - - xml_attribute a3 = node.insert_attribute_before(STR("a3"), a1); - CHECK(a3 && a3 != a2 && a3 != a1); - a3 = STR("v3"); - - xml_attribute a4 = node.insert_attribute_before(STR("a4"), a1); - CHECK(a4 && a4 != a3 && a4 != a2 && a4 != a1); - a4 = STR("v4"); - - xml_attribute a5 = node.insert_attribute_before(STR("a5"), a3); - CHECK(a5 && a5 != a4 && a5 != a3 && a5 != a2 && a5 != a1); - a5 = STR("v5"); - - CHECK(child.insert_attribute_before(STR("a"), a4) == xml_attribute()); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_prepend_copy_attribute, "") -{ - CHECK(xml_node().prepend_copy(xml_attribute()) == xml_attribute()); - CHECK(xml_node().prepend_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute()); - CHECK(doc.prepend_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute()); - CHECK(doc.child(STR("node")).prepend_copy(xml_attribute()) == xml_attribute()); - - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - xml_attribute a1 = node.attribute(STR("a1")); - xml_attribute a2 = child.attribute(STR("a2")); - - xml_attribute a3 = node.prepend_copy(a1); - CHECK(a3 && a3 != a2 && a3 != a1); - - xml_attribute a4 = node.prepend_copy(a2); - CHECK(a4 && a4 != a3 && a4 != a2 && a4 != a1); - - xml_attribute a5 = node.last_child().prepend_copy(a1); - CHECK(a5 && a5 != a4 && a5 != a3 && a5 != a2 && a5 != a1); - - CHECK_NODE(doc, STR("")); - - a3.set_name(STR("a3")); - a3 = STR("v3"); - - a4.set_name(STR("a4")); - a4 = STR("v4"); - - a5.set_name(STR("a5")); - a5 = STR("v5"); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_append_copy_attribute, "") -{ - CHECK(xml_node().append_copy(xml_attribute()) == xml_attribute()); - CHECK(xml_node().append_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute()); - CHECK(doc.append_copy(doc.child(STR("node")).attribute(STR("a1"))) == xml_attribute()); - CHECK(doc.child(STR("node")).append_copy(xml_attribute()) == xml_attribute()); - - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - xml_attribute a1 = node.attribute(STR("a1")); - xml_attribute a2 = child.attribute(STR("a2")); - - xml_attribute a3 = node.append_copy(a1); - CHECK(a3 && a3 != a2 && a3 != a1); - - xml_attribute a4 = node.append_copy(a2); - CHECK(a4 && a4 != a3 && a4 != a2 && a4 != a1); - - xml_attribute a5 = node.last_child().append_copy(a1); - CHECK(a5 && a5 != a4 && a5 != a3 && a5 != a2 && a5 != a1); - - CHECK_NODE(doc, STR("")); - - a3.set_name(STR("a3")); - a3 = STR("v3"); - - a4.set_name(STR("a4")); - a4 = STR("v4"); - - a5.set_name(STR("a5")); - a5 = STR("v5"); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_insert_copy_after_attribute, "text") -{ - CHECK(xml_node().insert_copy_after(xml_attribute(), xml_attribute()) == xml_attribute()); - - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - xml_attribute a1 = node.attribute(STR("a1")); - xml_attribute a2 = child.attribute(STR("a2")); - - CHECK(node.insert_copy_after(a1, xml_attribute()) == xml_attribute()); - CHECK(node.insert_copy_after(xml_attribute(), a1) == xml_attribute()); - CHECK(node.insert_copy_after(a2, a2) == xml_attribute()); - CHECK(node.last_child().insert_copy_after(a2, a2) == xml_attribute()); - - xml_attribute a3 = node.insert_copy_after(a1, a1); - CHECK(a3 && a3 != a2 && a3 != a1); - - xml_attribute a4 = node.insert_copy_after(a2, a1); - CHECK(a4 && a4 != a3 && a4 != a2 && a4 != a1); - - xml_attribute a5 = node.insert_copy_after(a4, a1); - CHECK(a5 && a5 != a4 && a5 != a3 && a5 != a2 && a5 != a1); - - CHECK(child.insert_copy_after(a4, a4) == xml_attribute()); - - CHECK_NODE(doc, STR("text")); - - a3.set_name(STR("a3")); - a3 = STR("v3"); - - a4.set_name(STR("a4")); - a4 = STR("v4"); - - a5.set_name(STR("a5")); - a5 = STR("v5"); - - CHECK_NODE(doc, STR("text")); -} - -TEST_XML(dom_node_insert_copy_before_attribute, "text") -{ - CHECK(xml_node().insert_copy_before(xml_attribute(), xml_attribute()) == xml_attribute()); - - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - xml_attribute a1 = node.attribute(STR("a1")); - xml_attribute a2 = child.attribute(STR("a2")); - - CHECK(node.insert_copy_before(a1, xml_attribute()) == xml_attribute()); - CHECK(node.insert_copy_before(xml_attribute(), a1) == xml_attribute()); - CHECK(node.insert_copy_before(a2, a2) == xml_attribute()); - CHECK(node.last_child().insert_copy_before(a2, a2) == xml_attribute()); - - xml_attribute a3 = node.insert_copy_before(a1, a1); - CHECK(a3 && a3 != a2 && a3 != a1); - - xml_attribute a4 = node.insert_copy_before(a2, a1); - CHECK(a4 && a4 != a3 && a4 != a2 && a4 != a1); - - xml_attribute a5 = node.insert_copy_before(a4, a1); - CHECK(a5 && a5 != a4 && a5 != a3 && a5 != a2 && a5 != a1); - - CHECK(child.insert_copy_before(a4, a4) == xml_attribute()); - - CHECK_NODE(doc, STR("text")); - - a3.set_name(STR("a3")); - a3 = STR("v3"); - - a4.set_name(STR("a4")); - a4 = STR("v4"); - - a5.set_name(STR("a5")); - a5 = STR("v5"); - - CHECK_NODE(doc, STR("text")); -} - -TEST_XML(dom_node_remove_attribute, "") -{ - CHECK(!xml_node().remove_attribute(STR("a"))); - CHECK(!xml_node().remove_attribute(xml_attribute())); - - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - CHECK(!node.remove_attribute(STR("a"))); - CHECK(!node.remove_attribute(xml_attribute())); - CHECK(!node.remove_attribute(child.attribute(STR("a4")))); - - CHECK_NODE(doc, STR("")); - - CHECK(node.remove_attribute(STR("a1"))); - CHECK(node.remove_attribute(node.attribute(STR("a3")))); - CHECK(child.remove_attribute(STR("a4"))); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_remove_attributes, "") -{ - CHECK(!xml_node().remove_attributes()); - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - CHECK(child.remove_attributes()); - CHECK_NODE(child, STR("")); - - CHECK(node.remove_attributes()); - CHECK_NODE(node, STR("")); -} - -TEST_XML(dom_node_remove_attributes_lots, "") -{ - xml_node node = doc.child(STR("node")); - - // this test makes sure we generate at least 2 pages (64K) worth of attribute data - // so that we can trigger page deallocation to make sure code is memory safe - for (size_t i = 0; i < 10000; ++i) - node.append_attribute(STR("a")) = STR("v"); - - CHECK_STRING(node.attribute(STR("a")).value(), STR("v")); - - CHECK(node.remove_attributes()); - - CHECK_STRING(node.attribute(STR("a")).value(), STR("")); - CHECK_NODE(node, STR("")); -} - -TEST_XML(dom_node_prepend_child, "foo") -{ - CHECK(xml_node().prepend_child() == xml_node()); - CHECK(doc.child(STR("node")).first_child().prepend_child() == xml_node()); - CHECK(doc.prepend_child(node_document) == xml_node()); - CHECK(doc.prepend_child(node_null) == xml_node()); - - xml_node n1 = doc.child(STR("node")).prepend_child(); - CHECK(n1); - CHECK(n1.set_name(STR("n1"))); - - xml_node n2 = doc.child(STR("node")).prepend_child(); - CHECK(n2 && n1 != n2); - CHECK(n2.set_name(STR("n2"))); - - xml_node n3 = doc.child(STR("node")).child(STR("child")).prepend_child(node_pcdata); - CHECK(n3 && n1 != n3 && n2 != n3); - CHECK(n3.set_value(STR("n3"))); - - xml_node n4 = doc.prepend_child(node_comment); - CHECK(n4 && n1 != n4 && n2 != n4 && n3 != n4); - CHECK(n4.set_value(STR("n4"))); - - CHECK_NODE(doc, STR("foon3")); -} - -TEST_XML(dom_node_append_child, "foo") -{ - CHECK(xml_node().append_child() == xml_node()); - CHECK(doc.child(STR("node")).first_child().append_child() == xml_node()); - CHECK(doc.append_child(node_document) == xml_node()); - CHECK(doc.append_child(node_null) == xml_node()); - - xml_node n1 = doc.child(STR("node")).append_child(); - CHECK(n1); - CHECK(n1.set_name(STR("n1"))); - - xml_node n2 = doc.child(STR("node")).append_child(); - CHECK(n2 && n1 != n2); - CHECK(n2.set_name(STR("n2"))); - - xml_node n3 = doc.child(STR("node")).child(STR("child")).append_child(node_pcdata); - CHECK(n3 && n1 != n3 && n2 != n3); - CHECK(n3.set_value(STR("n3"))); - - xml_node n4 = doc.append_child(node_comment); - CHECK(n4 && n1 != n4 && n2 != n4 && n3 != n4); - CHECK(n4.set_value(STR("n4"))); - - CHECK_NODE(doc, STR("foon3")); -} - -TEST_XML(dom_node_insert_child_after, "foo") -{ - CHECK(xml_node().insert_child_after(node_element, xml_node()) == xml_node()); - CHECK(doc.child(STR("node")).first_child().insert_child_after(node_element, xml_node()) == xml_node()); - CHECK(doc.insert_child_after(node_document, xml_node()) == xml_node()); - CHECK(doc.insert_child_after(node_null, xml_node()) == xml_node()); - - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - CHECK(node.insert_child_after(node_element, xml_node()) == xml_node()); - CHECK(node.insert_child_after(node_element, node) == xml_node()); - CHECK(child.insert_child_after(node_element, node) == xml_node()); - - xml_node n1 = node.insert_child_after(node_element, child); - CHECK(n1 && n1 != node && n1 != child); - CHECK(n1.set_name(STR("n1"))); - - xml_node n2 = node.insert_child_after(node_element, child); - CHECK(n2 && n2 != node && n2 != child && n2 != n1); - CHECK(n2.set_name(STR("n2"))); - - xml_node n3 = node.insert_child_after(node_pcdata, n2); - CHECK(n3 && n3 != node && n3 != child && n3 != n1 && n3 != n2); - CHECK(n3.set_value(STR("n3"))); - - xml_node n4 = node.insert_child_after(node_pi, node.first_child()); - CHECK(n4 && n4 != node && n4 != child && n4 != n1 && n4 != n2 && n4 != n3); - CHECK(n4.set_name(STR("n4"))); - - CHECK(child.insert_child_after(node_element, n3) == xml_node()); - - CHECK_NODE(doc, STR("foon3")); -} - -TEST_XML(dom_node_insert_child_before, "foo") -{ - CHECK(xml_node().insert_child_before(node_element, xml_node()) == xml_node()); - CHECK(doc.child(STR("node")).first_child().insert_child_before(node_element, xml_node()) == xml_node()); - CHECK(doc.insert_child_before(node_document, xml_node()) == xml_node()); - CHECK(doc.insert_child_before(node_null, xml_node()) == xml_node()); - - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - CHECK(node.insert_child_before(node_element, xml_node()) == xml_node()); - CHECK(node.insert_child_before(node_element, node) == xml_node()); - CHECK(child.insert_child_before(node_element, node) == xml_node()); - - xml_node n1 = node.insert_child_before(node_element, child); - CHECK(n1 && n1 != node && n1 != child); - CHECK(n1.set_name(STR("n1"))); - - xml_node n2 = node.insert_child_before(node_element, child); - CHECK(n2 && n2 != node && n2 != child && n2 != n1); - CHECK(n2.set_name(STR("n2"))); - - xml_node n3 = node.insert_child_before(node_pcdata, n2); - CHECK(n3 && n3 != node && n3 != child && n3 != n1 && n3 != n2); - CHECK(n3.set_value(STR("n3"))); - - xml_node n4 = node.insert_child_before(node_pi, node.first_child()); - CHECK(n4 && n4 != node && n4 != child && n4 != n1 && n4 != n2 && n4 != n3); - CHECK(n4.set_name(STR("n4"))); - - CHECK(child.insert_child_before(node_element, n3) == xml_node()); - - CHECK_NODE(doc, STR("foon3")); -} - -TEST_XML(dom_node_prepend_child_name, "foo") -{ - CHECK(xml_node().prepend_child(STR("")) == xml_node()); - CHECK(doc.child(STR("node")).first_child().prepend_child(STR("")) == xml_node()); - - xml_node n1 = doc.child(STR("node")).prepend_child(STR("n1")); - CHECK(n1); - - xml_node n2 = doc.child(STR("node")).prepend_child(STR("n2")); - CHECK(n2 && n1 != n2); - - CHECK_NODE(doc, STR("foo")); -} - -TEST_XML(dom_node_append_child_name, "foo") -{ - CHECK(xml_node().append_child(STR("")) == xml_node()); - CHECK(doc.child(STR("node")).first_child().append_child(STR("")) == xml_node()); - - xml_node n1 = doc.child(STR("node")).append_child(STR("n1")); - CHECK(n1); - - xml_node n2 = doc.child(STR("node")).append_child(STR("n2")); - CHECK(n2 && n1 != n2); - - CHECK_NODE(doc, STR("foo")); -} - -TEST_XML(dom_node_insert_child_after_name, "foo") -{ - CHECK(xml_node().insert_child_after(STR(""), xml_node()) == xml_node()); - CHECK(doc.child(STR("node")).first_child().insert_child_after(STR(""), xml_node()) == xml_node()); - - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - CHECK(node.insert_child_after(STR(""), node) == xml_node()); - CHECK(child.insert_child_after(STR(""), node) == xml_node()); - - xml_node n1 = node.insert_child_after(STR("n1"), child); - CHECK(n1 && n1 != node && n1 != child); - - xml_node n2 = node.insert_child_after(STR("n2"), child); - CHECK(n2 && n2 != node && n2 != child && n2 != n1); - - CHECK(child.insert_child_after(STR(""), n2) == xml_node()); - - CHECK_NODE(doc, STR("foo")); -} - -TEST_XML(dom_node_insert_child_before_name, "foo") -{ - CHECK(xml_node().insert_child_before(STR(""), xml_node()) == xml_node()); - CHECK(doc.child(STR("node")).first_child().insert_child_before(STR(""), xml_node()) == xml_node()); - - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - CHECK(node.insert_child_before(STR(""), node) == xml_node()); - CHECK(child.insert_child_before(STR(""), node) == xml_node()); - - xml_node n1 = node.insert_child_before(STR("n1"), child); - CHECK(n1 && n1 != node && n1 != child); - - xml_node n2 = node.insert_child_before(STR("n2"), child); - CHECK(n2 && n2 != node && n2 != child && n2 != n1); - - CHECK(child.insert_child_before(STR(""), n2) == xml_node()); - - CHECK_NODE(doc, STR("foo")); -} - -TEST_XML(dom_node_remove_child, "") -{ - CHECK(!xml_node().remove_child(STR("a"))); - CHECK(!xml_node().remove_child(xml_node())); - - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - CHECK(!node.remove_child(STR("a"))); - CHECK(!node.remove_child(xml_node())); - CHECK(!node.remove_child(child.child(STR("n4")))); - - CHECK_NODE(doc, STR("")); - - CHECK(node.remove_child(STR("n1"))); - CHECK(node.remove_child(node.child(STR("n3")))); - CHECK(child.remove_child(STR("n4"))); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_remove_children, "") -{ - CHECK(!xml_node().remove_children()); - xml_node node = doc.child(STR("node")); - xml_node child = node.child(STR("child")); - - CHECK(child.remove_children()); - CHECK_NODE(child, STR("")); - - CHECK(node.remove_children()); - CHECK_NODE(node, STR("")); -} - -TEST_XML(dom_node_remove_children_lots, "") -{ - xml_node node = doc.child(STR("node")); - - // this test makes sure we generate at least 2 pages (64K) worth of node data - // so that we can trigger page deallocation to make sure code is memory safe - for (size_t i = 0; i < 10000; ++i) - node.append_child().set_name(STR("n")); - - CHECK(node.child(STR("n"))); - - CHECK(node.remove_children()); - - CHECK(!node.child(STR("n"))); - CHECK_NODE(node, STR("")); -} - -TEST_XML(dom_node_remove_child_complex, "") -{ - CHECK(doc.child(STR("node")).remove_child(STR("n1"))); - - CHECK_NODE(doc, STR("")); - - CHECK(doc.remove_child(STR("node"))); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_remove_child_complex_allocated, "") -{ - doc.append_copy(doc.child(STR("node"))); - - CHECK(doc.remove_child(STR("node"))); - CHECK(doc.remove_child(STR("node"))); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_prepend_copy, "foo") -{ - CHECK(xml_node().prepend_copy(xml_node()) == xml_node()); - CHECK(doc.child(STR("node")).first_child().prepend_copy(doc.child(STR("node"))) == xml_node()); - CHECK(doc.prepend_copy(doc) == xml_node()); - CHECK(doc.prepend_copy(xml_node()) == xml_node()); - - xml_node n1 = doc.child(STR("node")).prepend_copy(doc.child(STR("node")).first_child()); - CHECK(n1); - CHECK_STRING(n1.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoo")); - - xml_node n2 = doc.child(STR("node")).prepend_copy(doc.child(STR("node")).child(STR("child"))); - CHECK(n2 && n2 != n1); - CHECK_STRING(n2.name(), STR("child")); - CHECK_NODE(doc, STR("foofoo")); - - xml_node n3 = doc.child(STR("node")).child(STR("child")).prepend_copy(doc.child(STR("node")).first_child().next_sibling()); - CHECK(n3 && n3 != n1 && n3 != n2); - CHECK_STRING(n3.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoofoo")); -} - -TEST_XML(dom_node_append_copy, "foo") -{ - CHECK(xml_node().append_copy(xml_node()) == xml_node()); - CHECK(doc.child(STR("node")).first_child().append_copy(doc.child(STR("node"))) == xml_node()); - CHECK(doc.append_copy(doc) == xml_node()); - CHECK(doc.append_copy(xml_node()) == xml_node()); - - xml_node n1 = doc.child(STR("node")).append_copy(doc.child(STR("node")).first_child()); - CHECK(n1); - CHECK_STRING(n1.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoo")); - - xml_node n2 = doc.child(STR("node")).append_copy(doc.child(STR("node")).child(STR("child"))); - CHECK(n2 && n2 != n1); - CHECK_STRING(n2.name(), STR("child")); - CHECK_NODE(doc, STR("foofoo")); - - xml_node n3 = doc.child(STR("node")).child(STR("child")).append_copy(doc.child(STR("node")).first_child()); - CHECK(n3 && n3 != n1 && n3 != n2); - CHECK_STRING(n3.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoofoo")); -} - -TEST_XML(dom_node_insert_copy_after, "foo") -{ - xml_node child = doc.child(STR("node")).child(STR("child")); - - CHECK(xml_node().insert_copy_after(xml_node(), xml_node()) == xml_node()); - CHECK(doc.child(STR("node")).first_child().insert_copy_after(doc.child(STR("node")), doc.child(STR("node"))) == xml_node()); - CHECK(doc.insert_copy_after(doc, doc) == xml_node()); - CHECK(doc.insert_copy_after(xml_node(), doc.child(STR("node"))) == xml_node()); - CHECK(doc.insert_copy_after(doc.child(STR("node")), xml_node()) == xml_node()); - CHECK(doc.insert_copy_after(doc.child(STR("node")), child) == xml_node()); - - xml_node n1 = doc.child(STR("node")).insert_copy_after(child, doc.child(STR("node")).first_child()); - CHECK(n1); - CHECK_STRING(n1.name(), STR("child")); - CHECK_NODE(doc, STR("foo")); - - xml_node n2 = doc.child(STR("node")).insert_copy_after(doc.child(STR("node")).first_child(), doc.child(STR("node")).last_child()); - CHECK(n2 && n2 != n1); - CHECK_STRING(n2.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoo")); - - xml_node n3 = doc.child(STR("node")).insert_copy_after(doc.child(STR("node")).first_child(), doc.child(STR("node")).first_child()); - CHECK(n3 && n3 != n1 && n3 != n2); - CHECK_STRING(n3.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoofoo")); -} - -TEST_XML(dom_node_insert_copy_before, "foo") -{ - xml_node child = doc.child(STR("node")).child(STR("child")); - - CHECK(xml_node().insert_copy_before(xml_node(), xml_node()) == xml_node()); - CHECK(doc.child(STR("node")).first_child().insert_copy_before(doc.child(STR("node")), doc.child(STR("node"))) == xml_node()); - CHECK(doc.insert_copy_before(doc, doc) == xml_node()); - CHECK(doc.insert_copy_before(xml_node(), doc.child(STR("node"))) == xml_node()); - CHECK(doc.insert_copy_before(doc.child(STR("node")), xml_node()) == xml_node()); - CHECK(doc.insert_copy_before(doc.child(STR("node")), child) == xml_node()); - - xml_node n1 = doc.child(STR("node")).insert_copy_before(child, doc.child(STR("node")).first_child()); - CHECK(n1); - CHECK_STRING(n1.name(), STR("child")); - CHECK_NODE(doc, STR("foo")); - - xml_node n2 = doc.child(STR("node")).insert_copy_before(doc.child(STR("node")).first_child(), doc.child(STR("node")).last_child()); - CHECK(n2 && n2 != n1); - CHECK_STRING(n2.name(), STR("child")); - CHECK_NODE(doc, STR("foo")); - - xml_node n3 = doc.child(STR("node")).insert_copy_before(doc.child(STR("node")).first_child().next_sibling(), doc.child(STR("node")).first_child()); - CHECK(n3 && n3 != n1 && n3 != n2); - CHECK_STRING(n3.value(), STR("foo")); - CHECK_NODE(doc, STR("foofoo")); -} - -TEST_XML(dom_node_copy_recursive, "foo") -{ - doc.child(STR("node")).append_copy(doc.child(STR("node"))); - CHECK_NODE(doc, STR("foofoo")); -} - -TEST_XML(dom_node_copy_crossdoc, "") -{ - xml_document newdoc; - newdoc.append_copy(doc.child(STR("node"))); - CHECK_NODE(doc, STR("")); - CHECK_NODE(newdoc, STR("")); -} - -TEST_XML(dom_node_copy_crossdoc_attribute, "") -{ - xml_document newdoc; - newdoc.append_child(STR("copy")).append_copy(doc.child(STR("node")).attribute(STR("attr"))); - CHECK_NODE(doc, STR("")); - CHECK_NODE(newdoc, STR("")); -} - -TEST_XML_FLAGS(dom_node_copy_types, "pcdata", parse_full) -{ - doc.append_copy(doc.child(STR("root"))); - CHECK_NODE(doc, STR("pcdatapcdata")); - - doc.insert_copy_before(doc.first_child(), doc.first_child()); - CHECK_NODE(doc, STR("pcdatapcdata")); - - doc.insert_copy_after(doc.first_child().next_sibling().next_sibling(), doc.first_child()); - CHECK_NODE(doc, STR("pcdatapcdata")); -} - -TEST(dom_node_declaration_name) -{ - xml_document doc; - doc.append_child(node_declaration); - - // name 'xml' is auto-assigned - CHECK(doc.first_child().type() == node_declaration); - CHECK_STRING(doc.first_child().name(), STR("xml")); - - doc.insert_child_after(node_declaration, doc.first_child()); - doc.insert_child_before(node_declaration, doc.first_child()); - doc.prepend_child(node_declaration); - - CHECK_NODE(doc, STR("")); -} - -TEST(dom_node_declaration_attributes) -{ - xml_document doc; - xml_node node = doc.append_child(node_declaration); - node.append_attribute(STR("version")) = STR("1.0"); - node.append_attribute(STR("encoding")) = STR("utf-8"); - - CHECK_NODE(doc, STR("")); -} - -TEST(dom_node_declaration_top_level) -{ - xml_document doc; - doc.append_child().set_name(STR("node")); - - xml_node node = doc.first_child(); - node.append_child(node_pcdata).set_value(STR("text")); - - CHECK(node.insert_child_before(node_declaration, node.first_child()) == xml_node()); - CHECK(node.insert_child_after(node_declaration, node.first_child()) == xml_node()); - CHECK(node.append_child(node_declaration) == xml_node()); - - CHECK_NODE(doc, STR("text")); - - CHECK(doc.insert_child_before(node_declaration, node)); - CHECK(doc.insert_child_after(node_declaration, node)); - CHECK(doc.append_child(node_declaration)); - - CHECK_NODE(doc, STR("text")); -} - -TEST(dom_node_declaration_copy) -{ - xml_document doc; - doc.append_child(node_declaration); - - doc.append_child().set_name(STR("node")); - - doc.last_child().append_copy(doc.first_child()); - - CHECK_NODE(doc, STR("")); -} - -TEST(dom_string_out_of_memory) -{ - const unsigned int length = 65536; - static char_t string[length + 1]; - - for (unsigned int i = 0; i < length; ++i) string[i] = 'a'; - string[length] = 0; - - xml_document doc; - xml_node node = doc.append_child(); - xml_attribute attr = node.append_attribute(STR("a")); - xml_node text = node.append_child(node_pcdata); - - // no value => long value - test_runner::_memory_fail_threshold = 32; - - CHECK_ALLOC_FAIL(CHECK(!node.set_name(string))); - CHECK_ALLOC_FAIL(CHECK(!text.set_value(string))); - CHECK_ALLOC_FAIL(CHECK(!attr.set_name(string))); - CHECK_ALLOC_FAIL(CHECK(!attr.set_value(string))); - - // set some names/values - test_runner::_memory_fail_threshold = 0; - - node.set_name(STR("n")); - attr.set_value(STR("v")); - text.set_value(STR("t")); - - // some value => long value - test_runner::_memory_fail_threshold = 32; - - CHECK_ALLOC_FAIL(CHECK(!node.set_name(string))); - CHECK_ALLOC_FAIL(CHECK(!text.set_value(string))); - CHECK_ALLOC_FAIL(CHECK(!attr.set_name(string))); - CHECK_ALLOC_FAIL(CHECK(!attr.set_value(string))); - - // check that original state was preserved - test_runner::_memory_fail_threshold = 0; - - CHECK_NODE(doc, STR("t")); -} - -TEST(dom_node_out_of_memory) -{ - test_runner::_memory_fail_threshold = 65536; - - // exhaust memory limit - xml_document doc; - - xml_node n = doc.append_child(); - CHECK(n.set_name(STR("n"))); - - xml_attribute a = n.append_attribute(STR("a")); - CHECK(a); - - CHECK_ALLOC_FAIL(while (n.append_child(node_comment)) { /* nop */ }); - CHECK_ALLOC_FAIL(while (n.append_attribute(STR("b"))) { /* nop */ }); - - // verify all node modification operations - CHECK_ALLOC_FAIL(CHECK(!n.append_child())); - CHECK_ALLOC_FAIL(CHECK(!n.prepend_child())); - CHECK_ALLOC_FAIL(CHECK(!n.insert_child_after(node_element, n.first_child()))); - CHECK_ALLOC_FAIL(CHECK(!n.insert_child_before(node_element, n.first_child()))); - CHECK_ALLOC_FAIL(CHECK(!n.append_attribute(STR("")))); - CHECK_ALLOC_FAIL(CHECK(!n.prepend_attribute(STR("")))); - CHECK_ALLOC_FAIL(CHECK(!n.insert_attribute_after(STR(""), a))); - CHECK_ALLOC_FAIL(CHECK(!n.insert_attribute_before(STR(""), a))); - - // verify node copy operations - CHECK_ALLOC_FAIL(CHECK(!n.append_copy(n.first_child()))); - CHECK_ALLOC_FAIL(CHECK(!n.prepend_copy(n.first_child()))); - CHECK_ALLOC_FAIL(CHECK(!n.insert_copy_after(n.first_child(), n.first_child()))); - CHECK_ALLOC_FAIL(CHECK(!n.insert_copy_before(n.first_child(), n.first_child()))); - CHECK_ALLOC_FAIL(CHECK(!n.append_copy(a))); - CHECK_ALLOC_FAIL(CHECK(!n.prepend_copy(a))); - CHECK_ALLOC_FAIL(CHECK(!n.insert_copy_after(a, a))); - CHECK_ALLOC_FAIL(CHECK(!n.insert_copy_before(a, a))); -} - -TEST(dom_node_memory_limit) -{ - const unsigned int length = 65536; - static char_t string[length + 1]; - - for (unsigned int i = 0; i < length; ++i) string[i] = 'a'; - string[length] = 0; - - test_runner::_memory_fail_threshold = 32768 * 2 + sizeof(string); - - xml_document doc; - - for (int j = 0; j < 32; ++j) - { - CHECK(doc.append_child().set_name(string)); - CHECK(doc.remove_child(doc.first_child())); - } -} - -TEST(dom_node_memory_limit_pi) -{ - const unsigned int length = 65536; - static char_t string[length + 1]; - - for (unsigned int i = 0; i < length; ++i) string[i] = 'a'; - string[length] = 0; - - test_runner::_memory_fail_threshold = 32768 * 2 + sizeof(string); - - xml_document doc; - - for (int j = 0; j < 32; ++j) - { - CHECK(doc.append_child(node_pi).set_value(string)); - CHECK(doc.remove_child(doc.first_child())); - } -} - -TEST(dom_node_doctype_top_level) -{ - xml_document doc; - doc.append_child().set_name(STR("node")); - - xml_node node = doc.first_child(); - node.append_child(node_pcdata).set_value(STR("text")); - - CHECK(node.insert_child_before(node_doctype, node.first_child()) == xml_node()); - CHECK(node.insert_child_after(node_doctype, node.first_child()) == xml_node()); - CHECK(node.append_child(node_doctype) == xml_node()); - - CHECK_NODE(doc, STR("text")); - - CHECK(doc.insert_child_before(node_doctype, node)); - CHECK(doc.insert_child_after(node_doctype, node)); - CHECK(doc.append_child(node_doctype)); - - CHECK_NODE(doc, STR("text")); -} - -TEST(dom_node_doctype_copy) -{ - xml_document doc; - doc.append_child(node_doctype); - - doc.append_child().set_name(STR("node")); - - doc.last_child().append_copy(doc.first_child()); - - CHECK_NODE(doc, STR("")); -} - -TEST(dom_node_doctype_value) -{ - xml_document doc; - xml_node node = doc.append_child(node_doctype); - - CHECK(node.type() == node_doctype); - CHECK_STRING(node.value(), STR("")); - CHECK_NODE(node, STR("")); - - CHECK(node.set_value(STR("id [ foo ]"))); - CHECK_NODE(node, STR("")); -} - -TEST_XML(dom_node_append_buffer_native, "test") -{ - xml_node node = doc.child(STR("node")); - - const char_t data1[] = STR("text"); - const char_t data2[] = STR(""); - - CHECK(node.append_buffer(data1, sizeof(data1))); - CHECK(node.append_buffer(data2, sizeof(data2))); - CHECK(node.append_buffer(data1, sizeof(data1))); - CHECK(node.append_buffer(data2, sizeof(data2))); - CHECK(node.append_buffer(data2, sizeof(data2))); - - CHECK_NODE(doc, STR("testtexttext")); -} - -TEST_XML(dom_node_append_buffer_convert, "test") -{ - xml_node node = doc.child(STR("node")); - - const char data[] = {0, 0, 0, '<', 0, 0, 0, 'n', 0, 0, 0, '/', 0, 0, 0, '>'}; - - CHECK(node.append_buffer(data, sizeof(data))); - CHECK(node.append_buffer(data, sizeof(data), parse_default, encoding_utf32_be)); - - CHECK_NODE(doc, STR("test")); -} - - -TEST_XML(dom_node_append_buffer_remove, "test") -{ - xml_node node = doc.child(STR("node")); - - const char data1[] = "text"; - const char data2[] = ""; - - CHECK(node.append_buffer(data1, sizeof(data1))); - CHECK(node.append_buffer(data2, sizeof(data2))); - CHECK(node.append_buffer(data1, sizeof(data1))); - CHECK(node.append_buffer(data2, sizeof(data2))); - - CHECK_NODE(doc, STR("testtexttext")); - - while (node.remove_child(STR("child2"))) {} - - CHECK_NODE(doc, STR("test")); - - while (node.remove_child(STR("child1"))) {} - - CHECK_NODE(doc, STR("test")); - - while (node.remove_child(STR("child3"))) {} - - CHECK_NODE(doc, STR("test")); - - CHECK(doc.remove_child(STR("node"))); - - CHECK(!doc.first_child()); -} - -TEST(dom_node_append_buffer_empty_document) -{ - xml_document doc; - - const char data[] = "text"; - - doc.append_buffer(data, sizeof(data)); - - CHECK_NODE(doc, STR("text")); -} - -TEST_XML(dom_node_append_buffer_invalid_type, "test") -{ - const char data[] = "text"; - - CHECK(xml_node().append_buffer(data, sizeof(data)).status == status_append_invalid_root); - CHECK(doc.first_child().first_child().append_buffer(data, sizeof(data)).status == status_append_invalid_root); -} - -TEST_XML(dom_node_append_buffer_close_external, "") -{ - xml_node node = doc.child(STR("node")); - - const char data[] = ""; - - CHECK(node.append_buffer(data, sizeof(data)).status == status_end_element_mismatch); - CHECK_NODE(doc, STR("")); - - CHECK(node.append_buffer(data, sizeof(data)).status == status_end_element_mismatch); - CHECK_NODE(doc, STR("")); -} - -TEST(dom_node_append_buffer_out_of_memory_extra) -{ - test_runner::_memory_fail_threshold = 1; - - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.append_buffer("", 4).status == status_out_of_memory)); - CHECK(!doc.first_child()); -} - -TEST(dom_node_append_buffer_out_of_memory_buffer) -{ - test_runner::_memory_fail_threshold = 32768 + 128; - - char data[128] = {0}; - - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.append_buffer(data, sizeof(data)).status == status_out_of_memory)); - CHECK(!doc.first_child()); -} - -TEST(dom_node_append_buffer_out_of_memory_nodes) -{ - unsigned int count = 4000; - std::basic_string data; - - for (unsigned int i = 0; i < count; ++i) - data += STR(""); - - test_runner::_memory_fail_threshold = 32768 + 128 + data.length() * sizeof(char_t) + 32; - -#ifdef PUGIXML_COMPACT - // ... and some space for hash table - test_runner::_memory_fail_threshold += 2048; -#endif - - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.append_buffer(data.c_str(), data.length() * sizeof(char_t), parse_fragment).status == status_out_of_memory)); - - unsigned int valid = 0; - - for (xml_node n = doc.first_child(); n; n = n.next_sibling()) - { - CHECK_STRING(n.name(), STR("a")); - valid++; - } - - CHECK(valid > 0 && valid < count); -} - -TEST(dom_node_append_buffer_out_of_memory_name) -{ - test_runner::_memory_fail_threshold = 32768 + 4096; - - char data[4096] = {0}; - - xml_document doc; - CHECK(doc.append_child(STR("root"))); - CHECK_ALLOC_FAIL(CHECK(doc.first_child().append_buffer(data, sizeof(data)).status == status_out_of_memory)); - CHECK_STRING(doc.first_child().name(), STR("root")); -} - -TEST_XML(dom_node_append_buffer_fragment, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.append_buffer("1", 1).status == status_no_document_element); - CHECK_NODE(doc, STR("1")); - - CHECK(node.append_buffer("2", 1, parse_fragment)); - CHECK_NODE(doc, STR("12")); - - CHECK(node.append_buffer("3", 1).status == status_no_document_element); - CHECK_NODE(doc, STR("123")); - - CHECK(node.append_buffer("4", 1, parse_fragment)); - CHECK_NODE(doc, STR("1234")); -} - -TEST_XML(dom_node_append_buffer_empty, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.append_buffer("", 0).status == status_no_document_element); - CHECK(node.append_buffer("", 0, parse_fragment).status == status_ok); - - CHECK(node.append_buffer(0, 0).status == status_no_document_element); - CHECK(node.append_buffer(0, 0, parse_fragment).status == status_ok); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_prepend_move, "foo") -{ - xml_node child = doc.child(STR("node")).child(STR("child")); - - CHECK(xml_node().prepend_move(xml_node()) == xml_node()); - CHECK(doc.child(STR("node")).first_child().prepend_move(child) == xml_node()); - CHECK(doc.prepend_move(doc) == xml_node()); - CHECK(doc.prepend_move(xml_node()) == xml_node()); - - xml_node n1 = doc.child(STR("node")).prepend_move(doc.child(STR("node")).first_child()); - CHECK(n1 && n1 == doc.child(STR("node")).first_child()); - CHECK_STRING(n1.value(), STR("foo")); - CHECK_NODE(doc, STR("foo")); - - xml_node n2 = doc.child(STR("node")).prepend_move(doc.child(STR("node")).child(STR("child"))); - CHECK(n2 && n2 != n1 && n2 == child); - CHECK_STRING(n2.name(), STR("child")); - CHECK_NODE(doc, STR("foo")); - - xml_node n3 = doc.child(STR("node")).child(STR("child")).prepend_move(doc.child(STR("node")).first_child().next_sibling()); - CHECK(n3 && n3 == n1 && n3 != n2); - CHECK_STRING(n3.value(), STR("foo")); - CHECK_NODE(doc, STR("foo")); -} - -TEST_XML(dom_node_append_move, "foo") -{ - xml_node child = doc.child(STR("node")).child(STR("child")); - - CHECK(xml_node().append_move(xml_node()) == xml_node()); - CHECK(doc.child(STR("node")).first_child().append_move(child) == xml_node()); - CHECK(doc.append_move(doc) == xml_node()); - CHECK(doc.append_move(xml_node()) == xml_node()); - - xml_node n1 = doc.child(STR("node")).append_move(doc.child(STR("node")).first_child()); - CHECK(n1 && n1 == doc.child(STR("node")).last_child()); - CHECK_STRING(n1.value(), STR("foo")); - CHECK_NODE(doc, STR("foo")); - - xml_node n2 = doc.child(STR("node")).append_move(doc.child(STR("node")).last_child()); - CHECK(n2 && n2 == n1); - CHECK_STRING(n2.value(), STR("foo")); - CHECK_NODE(doc, STR("foo")); - - xml_node n3 = doc.child(STR("node")).child(STR("child")).append_move(doc.child(STR("node")).last_child()); - CHECK(n3 && n3 == n1 && n3 == n2); - CHECK_STRING(n3.value(), STR("foo")); - CHECK_NODE(doc, STR("foo")); -} - -TEST_XML(dom_node_insert_move_after, "foobar") -{ - xml_node child = doc.child(STR("node")).child(STR("child")); - - CHECK(xml_node().insert_move_after(xml_node(), xml_node()) == xml_node()); - CHECK(doc.child(STR("node")).first_child().insert_move_after(doc.child(STR("node")), doc.child(STR("node"))) == xml_node()); - CHECK(doc.insert_move_after(doc, doc) == xml_node()); - CHECK(doc.insert_move_after(xml_node(), doc.child(STR("node"))) == xml_node()); - CHECK(doc.insert_move_after(doc.child(STR("node")), xml_node()) == xml_node()); - CHECK(doc.insert_move_after(doc.child(STR("node")), child) == xml_node()); - - xml_node n1 = doc.child(STR("node")).insert_move_after(child, doc.child(STR("node")).first_child()); - CHECK(n1 && n1 == child); - CHECK_STRING(n1.name(), STR("child")); - CHECK_NODE(doc, STR("foobar")); - - xml_node n2 = doc.child(STR("node")).insert_move_after(doc.child(STR("node")).first_child(), child); - CHECK(n2 && n2 != n1); - CHECK_STRING(n2.value(), STR("foo")); - CHECK_NODE(doc, STR("barfoo")); - - xml_node n3 = child.insert_move_after(doc.child(STR("node")).last_child(), child.first_child()); - CHECK(n3 && n3 != n1 && n3 == n2); - CHECK_STRING(n3.value(), STR("foo")); - CHECK_NODE(doc, STR("barfoo")); -} - -TEST_XML(dom_node_insert_move_before, "foobar") -{ - xml_node child = doc.child(STR("node")).child(STR("child")); - - CHECK(xml_node().insert_move_before(xml_node(), xml_node()) == xml_node()); - CHECK(doc.child(STR("node")).first_child().insert_move_before(doc.child(STR("node")), doc.child(STR("node"))) == xml_node()); - CHECK(doc.insert_move_before(doc, doc) == xml_node()); - CHECK(doc.insert_move_before(xml_node(), doc.child(STR("node"))) == xml_node()); - CHECK(doc.insert_move_before(doc.child(STR("node")), xml_node()) == xml_node()); - CHECK(doc.insert_move_before(doc.child(STR("node")), child) == xml_node()); - - xml_node n1 = doc.child(STR("node")).insert_move_before(child, doc.child(STR("node")).first_child()); - CHECK(n1 && n1 == child); - CHECK_STRING(n1.name(), STR("child")); - CHECK_NODE(doc, STR("barfoo")); - - xml_node n2 = doc.child(STR("node")).insert_move_before(doc.child(STR("node")).last_child(), child); - CHECK(n2 && n2 != n1); - CHECK_STRING(n2.value(), STR("foo")); - CHECK_NODE(doc, STR("foobar")); - - xml_node n3 = child.insert_move_before(doc.child(STR("node")).first_child(), child.first_child()); - CHECK(n3 && n3 != n1 && n3 == n2); - CHECK_STRING(n3.value(), STR("foo")); - CHECK_NODE(doc, STR("foobar")); -} - -TEST_XML(dom_node_move_recursive, "foo") -{ - xml_node root = doc.child(STR("root")); - xml_node node = root.child(STR("node")); - xml_node foo = node.first_child(); - xml_node child = node.last_child(); - - CHECK(node.prepend_move(node) == xml_node()); - CHECK(node.prepend_move(root) == xml_node()); - - CHECK(node.append_move(node) == xml_node()); - CHECK(node.append_move(root) == xml_node()); - - CHECK(node.insert_move_before(node, foo) == xml_node()); - CHECK(node.insert_move_before(root, foo) == xml_node()); - - CHECK(node.insert_move_after(node, foo) == xml_node()); - CHECK(node.insert_move_after(root, foo) == xml_node()); - - CHECK(child.append_move(node) == xml_node()); - - CHECK_NODE(doc, STR("foo")); -} - -TEST_XML(dom_node_move_marker, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(doc.insert_move_before(node, node) == xml_node()); - CHECK(doc.insert_move_after(node, node) == xml_node()); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_move_crossdoc, "") -{ - xml_document newdoc; - CHECK(newdoc.append_move(doc.child(STR("node"))) == xml_node()); - CHECK_NODE(newdoc, STR("")); -} - -TEST_XML(dom_node_move_tree, "t1t2t3t4") -{ - xml_node root = doc.child(STR("root")); - xml_node n1 = root.child(STR("n1")); - xml_node n2 = root.child(STR("n2")); - xml_node n3 = root.child(STR("n3")); - xml_node n4 = root.child(STR("n4")); - - // n2 n1 n3 n4 - CHECK(n2 == root.prepend_move(n2)); - - // n2 n3 n4 n1 - CHECK(n1 == root.append_move(n1)); - - // n2 n4 n3 n1 - CHECK(n4 == root.insert_move_before(n4, n3)); - - // n2 n4 n1 + n3 - CHECK(n3 == doc.insert_move_after(n3, root)); - - CHECK_NODE(doc, STR("t2t4t1t3")); - - CHECK(n1 == root.child(STR("n1"))); - CHECK(n2 == root.child(STR("n2"))); - CHECK(n3 == doc.child(STR("n3"))); - CHECK(n4 == root.child(STR("n4"))); -} - -TEST(dom_node_copy_stackless) -{ - unsigned int count = 20000; - std::basic_string data; - - for (unsigned int i = 0; i < count; ++i) - data += STR(""); - - data += STR("text"); - - for (unsigned int j = 0; j < count; ++j) - data += STR(""); - - xml_document doc; - CHECK(doc.load_string(data.c_str())); - - xml_document copy; - CHECK(copy.append_copy(doc.first_child())); - - CHECK_NODE(doc, data.c_str()); -} - -TEST(dom_node_copy_copyless) -{ - std::basic_string data; - data += STR(""); - for (int i = 0; i < 10000; ++i) - data += STR("pcdata"); - data += STR(""); - - std::basic_string datacopy = data; - - // the document is parsed in-place so there should only be 1 page worth of allocations - test_runner::_memory_fail_threshold = 32768 + 128; - -#ifdef PUGIXML_COMPACT - // ... and some space for hash table - test_runner::_memory_fail_threshold += 2048; -#endif - - xml_document doc; - CHECK(doc.load_buffer_inplace(&datacopy[0], datacopy.size() * sizeof(char_t), parse_full)); - - // this copy should share all string storage; since there are not a lot of nodes we should not have *any* allocations here (everything will fit in the same page in the document) - xml_node copy = doc.append_copy(doc.child(STR("node"))); - xml_node copy2 = doc.append_copy(copy); - - CHECK_NODE(copy, data.c_str()); - CHECK_NODE(copy2, data.c_str()); -} - -TEST(dom_node_copy_copyless_mix) -{ - xml_document doc; - CHECK(doc.load_string(STR("pcdata"), parse_full)); - - xml_node child = doc.child(STR("node")).child(STR("child")); - - child.set_name(STR("copychild")); - child.attribute(STR("attr2")).set_name(STR("copyattr2")); - child.attribute(STR("attr1")).set_value(STR("copyvalue1")); - - std::basic_string data; - for (int i = 0; i < 10000; ++i) - data += STR("pcdata"); - - doc.child(STR("node")).text().set(data.c_str()); - - xml_node copy = doc.append_copy(doc.child(STR("node"))); - xml_node copy2 = doc.append_copy(copy); - - std::basic_string dataxml; - dataxml += STR(""); - dataxml += data; - dataxml += STR(""); - - CHECK_NODE(copy, dataxml.c_str()); - CHECK_NODE(copy2, dataxml.c_str()); -} - -TEST_XML(dom_node_copy_copyless_taint, "") -{ - xml_node node = doc.child(STR("node")); - xml_node copy = doc.append_copy(node); - - CHECK_NODE(doc, STR("")); - - node.set_name(STR("nod1")); - - CHECK_NODE(doc, STR("")); - - xml_node copy2 = doc.append_copy(copy); - - CHECK_NODE(doc, STR("")); - - copy.attribute(STR("attr")).set_value(STR("valu2")); - - CHECK_NODE(doc, STR("")); - - copy2.attribute(STR("attr")).set_name(STR("att3")); - - CHECK_NODE(doc, STR("")); -} - -TEST(dom_node_copy_attribute_copyless) -{ - std::basic_string data; - data += STR(""); - - std::basic_string datacopy = data; - - // the document is parsed in-place so there should only be 1 page worth of allocations - test_runner::_memory_fail_threshold = 32768 + 128; - -#ifdef PUGIXML_COMPACT - // ... and some space for hash table - test_runner::_memory_fail_threshold += 2048; -#endif - - xml_document doc; - CHECK(doc.load_buffer_inplace(&datacopy[0], datacopy.size() * sizeof(char_t), parse_full)); - - // this copy should share all string storage; since there are not a lot of nodes we should not have *any* allocations here (everything will fit in the same page in the document) - xml_node copy1 = doc.append_child(STR("node")); - copy1.append_copy(doc.first_child().first_attribute()); - - xml_node copy2 = doc.append_child(STR("node")); - copy2.append_copy(copy1.first_attribute()); - - CHECK_NODE(copy1, data.c_str()); - CHECK_NODE(copy2, data.c_str()); -} - -TEST_XML(dom_node_copy_attribute_copyless_taint, "") -{ - xml_node node = doc.child(STR("node")); - xml_attribute attr = node.first_attribute(); - - xml_node copy1 = doc.append_child(STR("copy1")); - xml_node copy2 = doc.append_child(STR("copy2")); - xml_node copy3 = doc.append_child(STR("copy3")); - - CHECK_NODE(doc, STR("")); - - copy1.append_copy(attr); - - CHECK_NODE(doc, STR("")); - - attr.set_name(STR("att1")); - copy2.append_copy(attr); - - CHECK_NODE(doc, STR("")); - - copy1.first_attribute().set_value(STR("valu2")); - copy3.append_copy(copy1.first_attribute()); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_copy_out_of_memory_node, "text1text2") -{ - test_runner::_memory_fail_threshold = 32768 * 2 + 4096; - - xml_document copy; - CHECK_ALLOC_FAIL(for (int i = 0; i < 1000; ++i) copy.append_copy(doc.first_child())); -} - -TEST_XML(dom_node_copy_out_of_memory_attr, "") -{ - test_runner::_memory_fail_threshold = 32768 * 2 + 4096; - - xml_document copy; - CHECK_ALLOC_FAIL(for (int i = 0; i < 1000; ++i) copy.append_copy(doc.first_child())); -} - -TEST_XML(dom_node_remove_deallocate, "text") -{ - xml_node node = doc.child(STR("node")); - - xml_attribute attr = node.attribute(STR("attr")); - attr.set_name(STR("longattr")); - attr.set_value(STR("longvalue")); - - node.set_name(STR("longnode")); - node.text().set(STR("longtext")); - - node.remove_attribute(attr); - doc.remove_child(node); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(dom_node_set_deallocate, "text") -{ - xml_node node = doc.child(STR("node")); - - xml_attribute attr = node.attribute(STR("attr")); - - attr.set_name(STR("longattr")); - attr.set_value(STR("longvalue")); - node.set_name(STR("longnode")); - - attr.set_name(STR("")); - attr.set_value(STR("")); - node.set_name(STR("")); - node.text().set(STR("")); - - CHECK_NODE(doc, STR("<:anonymous :anonymous=\"\">")); -} - -TEST(dom_node_copy_declaration_empty_name) -{ - xml_document doc1; - xml_node decl1 = doc1.append_child(node_declaration); - decl1.set_name(STR("")); - - xml_document doc2; - xml_node decl2 = doc2.append_copy(decl1); - - CHECK_STRING(decl2.name(), STR("")); -} - -template bool fp_equal(T lhs, T rhs) -{ - // Several compilers compare float/double values on x87 stack without proper rounding - // This causes roundtrip tests to fail, although they correctly preserve the data. -#if (defined(_MSC_VER) && _MSC_VER < 1400) || defined(__MWERKS__) - return memcmp(&lhs, &rhs, sizeof(T)) == 0; -#else - return lhs == rhs; -#endif -} - -TEST(dom_fp_roundtrip_min_max_float) -{ - xml_document doc; - xml_node node = doc.append_child(STR("node")); - xml_attribute attr = node.append_attribute(STR("attr")); - - node.text().set(std::numeric_limits::min()); - CHECK(fp_equal(node.text().as_float(), std::numeric_limits::min())); - - attr.set_value(std::numeric_limits::max()); - CHECK(fp_equal(attr.as_float(), std::numeric_limits::max())); -} - -TEST(dom_fp_roundtrip_min_max_double) -{ - xml_document doc; - xml_node node = doc.append_child(STR("node")); - xml_attribute attr = node.append_attribute(STR("attr")); - - attr.set_value(std::numeric_limits::min()); - CHECK(fp_equal(attr.as_double(), std::numeric_limits::min())); - - node.text().set(std::numeric_limits::max()); - CHECK(fp_equal(node.text().as_double(), std::numeric_limits::max())); -} - -TEST(dom_fp_double_custom_precision) -{ - xml_document doc; - xml_node node = doc.append_child(STR("node")); - xml_attribute attr = node.append_attribute(STR("attr")); - - attr.set_value(std::numeric_limits::min(), 20); - CHECK(fp_equal(attr.as_double(), std::numeric_limits::min())); - - attr.set_value(1.0f, 5); - CHECK(fp_equal(attr.as_double(), static_cast(1.0f))); - - attr.set_value(3.1415926f, 3); - CHECK(!fp_equal(attr.as_double(), static_cast(3.1415926f))); - - node.text().set(1.0f, 5); - CHECK(fp_equal(node.text().as_double(), static_cast(1.0f))); - - node.text().set(3.1415926f, 3); - CHECK(!fp_equal(node.text().as_double(), static_cast(3.1415926f))); - - node.text().set(std::numeric_limits::max(), 20); - CHECK(fp_equal(node.text().as_double(), std::numeric_limits::max())); -} - -const double fp_roundtrip_base[] = -{ - 0.31830988618379067154, - 0.43429448190325182765, - 0.57721566490153286061, - 0.69314718055994530942, - 0.70710678118654752440, - 0.78539816339744830962, -}; - -TEST(dom_fp_roundtrip_float) -{ - xml_document doc; - - for (int e = -125; e <= 128; ++e) - { - for (size_t i = 0; i < sizeof(fp_roundtrip_base) / sizeof(fp_roundtrip_base[0]); ++i) - { - float value = static_cast(ldexp(fp_roundtrip_base[i], e)); - - doc.text().set(value); - CHECK(fp_equal(doc.text().as_float(), value)); - } - } -} - -// Borland C does not print double values with enough precision -#ifndef __BORLANDC__ -TEST(dom_fp_roundtrip_double) -{ - xml_document doc; - - for (int e = -1021; e <= 1024; ++e) - { - for (size_t i = 0; i < sizeof(fp_roundtrip_base) / sizeof(fp_roundtrip_base[0]); ++i) - { - #if (defined(_MSC_VER) && _MSC_VER < 1400) || defined(__MWERKS__) - // Not all runtime libraries guarantee roundtripping for denormals - if (e == -1021 && fp_roundtrip_base[i] < 0.5) - continue; - #endif - - #ifdef __DMC__ - // Digital Mars C does not roundtrip on exactly one combination - if (e == -12 && i == 1) - continue; - #endif - - double value = ldexp(fp_roundtrip_base[i], e); - - doc.text().set(value); - CHECK(fp_equal(doc.text().as_double(), value)); - } - } -} -#endif diff --git a/external/pugixml/tests/test_dom_text.cpp b/external/pugixml/tests/test_dom_text.cpp deleted file mode 100644 index c71e54ea4..000000000 --- a/external/pugixml/tests/test_dom_text.cpp +++ /dev/null @@ -1,447 +0,0 @@ -#include "test.hpp" - -#include "helpers.hpp" - -#include - -using namespace pugi; - -TEST_XML_FLAGS(dom_text_empty, "foo", parse_default | parse_pi) -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.child(STR("a")).text()); - CHECK(node.child(STR("b")).text()); - CHECK(!node.child(STR("c")).text()); - CHECK(!node.child(STR("d")).text()); - CHECK(!xml_node().text()); - CHECK(!xml_text()); - - generic_empty_test(node.child(STR("a")).text()); -} - -TEST_XML(dom_text_bool_ops, "foo") -{ - generic_bool_ops_test(doc.child(STR("node")).text()); -} - -TEST_XML_FLAGS(dom_text_get, "foo", parse_default | parse_pi) -{ - xml_node node = doc.child(STR("node")); - - CHECK_STRING(node.child(STR("a")).text().get(), STR("foo")); - CHECK_STRING(node.child(STR("a")).first_child().text().get(), STR("foo")); - - CHECK_STRING(node.child(STR("b")).text().get(), STR("bar")); - CHECK_STRING(node.child(STR("b")).last_child().text().get(), STR("bar")); - - CHECK_STRING(node.child(STR("c")).text().get(), STR("")); - CHECK_STRING(node.child(STR("c")).first_child().text().get(), STR("")); - - CHECK_STRING(node.child(STR("d")).text().get(), STR("")); - - CHECK_STRING(xml_node().text().get(), STR("")); -} - -TEST_XML_FLAGS(dom_text_as_string, "foo", parse_default | parse_pi) -{ - xml_node node = doc.child(STR("node")); - - CHECK_STRING(node.child(STR("a")).text().as_string(), STR("foo")); - CHECK_STRING(node.child(STR("a")).first_child().text().as_string(), STR("foo")); - - CHECK_STRING(node.child(STR("b")).text().as_string(), STR("bar")); - CHECK_STRING(node.child(STR("b")).last_child().text().as_string(), STR("bar")); - - CHECK_STRING(node.child(STR("c")).text().as_string(), STR("")); - CHECK_STRING(node.child(STR("c")).first_child().text().as_string(), STR("")); - - CHECK_STRING(node.child(STR("d")).text().as_string(), STR("")); - - CHECK_STRING(xml_node().text().as_string(), STR("")); -} - -TEST_XML(dom_text_as_int, "1-1-214748364821474836470") -{ - xml_node node = doc.child(STR("node")); - - CHECK(xml_text().as_int() == 0); - CHECK(node.child(STR("text1")).text().as_int() == 1); - CHECK(node.child(STR("text2")).text().as_int() == -1); - CHECK(node.child(STR("text3")).text().as_int() == -2147483647 - 1); - CHECK(node.child(STR("text4")).text().as_int() == 2147483647); - CHECK(node.child(STR("text5")).text().as_int() == 0); -} - -TEST_XML(dom_text_as_int_hex, "07770x5ab0XFf-0x20-0x800000000x") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.child(STR("text1")).text().as_int() == 777); // no octal support! intentional - CHECK(node.child(STR("text2")).text().as_int() == 1451); - CHECK(node.child(STR("text3")).text().as_int() == 255); - CHECK(node.child(STR("text4")).text().as_int() == -32); - CHECK(node.child(STR("text5")).text().as_int() == -2147483647 - 1); - CHECK(node.child(STR("text6")).text().as_int() == 0); -} - -TEST_XML(dom_text_as_uint, "01214748364742949672950") -{ - xml_node node = doc.child(STR("node")); - - CHECK(xml_text().as_uint() == 0); - CHECK(node.child(STR("text1")).text().as_uint() == 0); - CHECK(node.child(STR("text2")).text().as_uint() == 1); - CHECK(node.child(STR("text3")).text().as_uint() == 2147483647); - CHECK(node.child(STR("text4")).text().as_uint() == 4294967295u); - CHECK(node.child(STR("text5")).text().as_uint() == 0); -} - -TEST_XML(dom_text_as_uint_hex, "07770x5ab0XFf0x200xFFFFFFFF0x") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.child(STR("text1")).text().as_uint() == 777); // no octal support! intentional - CHECK(node.child(STR("text2")).text().as_uint() == 1451); - CHECK(node.child(STR("text3")).text().as_uint() == 255); - CHECK(node.child(STR("text4")).text().as_uint() == 32); - CHECK(node.child(STR("text5")).text().as_uint() == 4294967295u); - CHECK(node.child(STR("text6")).text().as_uint() == 0); -} - -TEST_XML(dom_text_as_integer_space, " \t\n1234\n\t 0x123- 16- 0x10") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.child(STR("text1")).text().as_int() == 1234); - CHECK(node.child(STR("text2")).text().as_int() == 291); - CHECK(node.child(STR("text3")).text().as_int() == 0); - CHECK(node.child(STR("text4")).text().as_int() == 0); -} - -TEST_XML(dom_text_as_float, "010.12-5.13e-43.14159265358979323846") -{ - xml_node node = doc.child(STR("node")); - - CHECK(xml_text().as_float() == 0); - CHECK_DOUBLE(double(node.child(STR("text1")).text().as_float()), 0); - CHECK_DOUBLE(double(node.child(STR("text2")).text().as_float()), 1); - CHECK_DOUBLE(double(node.child(STR("text3")).text().as_float()), 0.12); - CHECK_DOUBLE(double(node.child(STR("text4")).text().as_float()), -5.1); - CHECK_DOUBLE(double(node.child(STR("text5")).text().as_float()), 3e-4); - CHECK_DOUBLE(double(node.child(STR("text6")).text().as_float()), 3.14159265358979323846); -} - -TEST_XML(dom_text_as_double, "010.12-5.13e-43.14159265358979323846") -{ - xml_node node = doc.child(STR("node")); - - CHECK(xml_text().as_double() == 0); - CHECK_DOUBLE(node.child(STR("text1")).text().as_double(), 0); - CHECK_DOUBLE(node.child(STR("text2")).text().as_double(), 1); - CHECK_DOUBLE(node.child(STR("text3")).text().as_double(), 0.12); - CHECK_DOUBLE(node.child(STR("text4")).text().as_double(), -5.1); - CHECK_DOUBLE(node.child(STR("text5")).text().as_double(), 3e-4); - CHECK_DOUBLE(node.child(STR("text6")).text().as_double(), 3.14159265358979323846); -} - -TEST_XML(dom_text_as_bool, "01trueTrueYesyesfalse") -{ - xml_node node = doc.child(STR("node")); - - CHECK(!xml_text().as_bool()); - CHECK(!node.child(STR("text1")).text().as_bool()); - CHECK(node.child(STR("text2")).text().as_bool()); - CHECK(node.child(STR("text3")).text().as_bool()); - CHECK(node.child(STR("text4")).text().as_bool()); - CHECK(node.child(STR("text5")).text().as_bool()); - CHECK(node.child(STR("text6")).text().as_bool()); - CHECK(!node.child(STR("text7")).text().as_bool()); -} - -#ifdef PUGIXML_HAS_LONG_LONG -TEST_XML(dom_text_as_llong, "1-1-922337203685477580892233720368547758070") -{ - xml_node node = doc.child(STR("node")); - - CHECK(xml_text().as_llong() == 0); - CHECK(node.child(STR("text1")).text().as_llong() == 1); - CHECK(node.child(STR("text2")).text().as_llong() == -1); - CHECK(node.child(STR("text3")).text().as_llong() == -9223372036854775807ll - 1); - CHECK(node.child(STR("text4")).text().as_llong() == 9223372036854775807ll); - CHECK(node.child(STR("text5")).text().as_llong() == 0); -} - -TEST_XML(dom_text_as_llong_hex, "07770x5ab0XFf-0x20-0x80000000000000000x") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.child(STR("text1")).text().as_llong() == 777); // no octal support! intentional - CHECK(node.child(STR("text2")).text().as_llong() == 1451); - CHECK(node.child(STR("text3")).text().as_llong() == 255); - CHECK(node.child(STR("text4")).text().as_llong() == -32); - CHECK(node.child(STR("text5")).text().as_llong() == -9223372036854775807ll - 1); - CHECK(node.child(STR("text6")).text().as_llong() == 0); -} - -TEST_XML(dom_text_as_ullong, "019223372036854775807184467440737095516150") -{ - xml_node node = doc.child(STR("node")); - - CHECK(xml_text().as_ullong() == 0); - CHECK(node.child(STR("text1")).text().as_ullong() == 0); - CHECK(node.child(STR("text2")).text().as_ullong() == 1); - CHECK(node.child(STR("text3")).text().as_ullong() == 9223372036854775807ll); - CHECK(node.child(STR("text4")).text().as_ullong() == 18446744073709551615ull); - CHECK(node.child(STR("text5")).text().as_ullong() == 0); -} - -TEST_XML(dom_text_as_ullong_hex, "07770x5ab0XFf0x200xFFFFFFFFFFFFFFFF0x") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.child(STR("text1")).text().as_ullong() == 777); // no octal support! intentional - CHECK(node.child(STR("text2")).text().as_ullong() == 1451); - CHECK(node.child(STR("text3")).text().as_ullong() == 255); - CHECK(node.child(STR("text4")).text().as_ullong() == 32); - CHECK(node.child(STR("text5")).text().as_ullong() == 18446744073709551615ull); - CHECK(node.child(STR("text6")).text().as_ullong() == 0); -} -#endif - -TEST_XML(dom_text_get_no_state, "") -{ - xml_node node = doc.child(STR("node")); - xml_text t = node.text(); - - CHECK(!t); - CHECK(t.get() && *t.get() == 0); - CHECK(!node.first_child()); - - node.append_child(node_pcdata); - - CHECK(t); - CHECK_STRING(t.get(), STR("")); - - node.first_child().set_value(STR("test")); - - CHECK(t); - CHECK_STRING(t.get(), STR("test")); -} - -TEST_XML(dom_text_set, "") -{ - xml_node node = doc.child(STR("node")); - xml_text t = node.text(); - - t.set(STR("")); - CHECK(node.first_child().type() == node_pcdata); - CHECK_NODE(node, STR("")); - - t.set(STR("boo")); - CHECK(node.first_child().type() == node_pcdata); - CHECK(node.first_child() == node.last_child()); - CHECK_NODE(node, STR("boo")); - - t.set(STR("foobarfoobar")); - CHECK(node.first_child().type() == node_pcdata); - CHECK(node.first_child() == node.last_child()); - CHECK_NODE(node, STR("foobarfoobar")); -} - -TEST_XML(dom_text_assign, "") -{ - xml_node node = doc.child(STR("node")); - - node.append_child(STR("text1")).text() = STR("v1"); - xml_text() = STR("v1"); - - node.append_child(STR("text2")).text() = -2147483647; - node.append_child(STR("text3")).text() = -2147483647 - 1; - xml_text() = -2147483647 - 1; - - node.append_child(STR("text4")).text() = 4294967295u; - node.append_child(STR("text5")).text() = 4294967294u; - xml_text() = 4294967295u; - - node.append_child(STR("text6")).text() = 0.5; - xml_text() = 0.5; - - node.append_child(STR("text7")).text() = 0.25f; - xml_text() = 0.25f; - - node.append_child(STR("text8")).text() = true; - xml_text() = true; - - CHECK_NODE(node, STR("v1-2147483647-2147483648429496729542949672940.50.25true")); -} - -TEST_XML(dom_text_set_value, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.append_child(STR("text1")).text().set(STR("v1"))); - CHECK(!xml_text().set(STR("v1"))); - - CHECK(node.append_child(STR("text2")).text().set(-2147483647)); - CHECK(node.append_child(STR("text3")).text().set(-2147483647 - 1)); - CHECK(!xml_text().set(-2147483647 - 1)); - - CHECK(node.append_child(STR("text4")).text().set(4294967295u)); - CHECK(node.append_child(STR("text5")).text().set(4294967294u)); - CHECK(!xml_text().set(4294967295u)); - - CHECK(node.append_child(STR("text6")).text().set(0.5)); - CHECK(!xml_text().set(0.5)); - - CHECK(node.append_child(STR("text7")).text().set(0.25f)); - CHECK(!xml_text().set(0.25f)); - - CHECK(node.append_child(STR("text8")).text().set(true)); - CHECK(!xml_text().set(true)); - - CHECK_NODE(node, STR("v1-2147483647-2147483648429496729542949672940.50.25true")); -} - -#if LONG_MAX > 2147483647 -TEST_XML(dom_text_assign_long, "") -{ - xml_node node = doc.child(STR("node")); - - node.append_child(STR("text1")).text() = -9223372036854775807l; - node.append_child(STR("text2")).text() = -9223372036854775807l - 1; - xml_text() = -9223372036854775807l - 1; - - node.append_child(STR("text3")).text() = 18446744073709551615ul; - node.append_child(STR("text4")).text() = 18446744073709551614ul; - xml_text() = 18446744073709551615ul; - - CHECK_NODE(node, STR("-9223372036854775807-92233720368547758081844674407370955161518446744073709551614")); -} - -TEST_XML(dom_text_set_value_long, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.append_child(STR("text1")).text().set(-9223372036854775807l)); - CHECK(node.append_child(STR("text2")).text().set(-9223372036854775807l - 1)); - CHECK(!xml_text().set(-9223372036854775807l - 1)); - - CHECK(node.append_child(STR("text3")).text().set(18446744073709551615ul)); - CHECK(node.append_child(STR("text4")).text().set(18446744073709551614ul)); - CHECK(!xml_text().set(18446744073709551615ul)); - - CHECK_NODE(node, STR("-9223372036854775807-92233720368547758081844674407370955161518446744073709551614")); -} -#else -TEST_XML(dom_text_assign_long, "") -{ - xml_node node = doc.child(STR("node")); - - node.append_child(STR("text1")).text() = -2147483647l; - node.append_child(STR("text2")).text() = -2147483647l - 1; - xml_text() = -2147483647l - 1; - - node.append_child(STR("text3")).text() = 4294967295ul; - node.append_child(STR("text4")).text() = 4294967294ul; - xml_text() = 4294967295ul; - - CHECK_NODE(node, STR("-2147483647-214748364842949672954294967294")); -} - -TEST_XML(dom_text_set_value_long, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.append_child(STR("text1")).text().set(-2147483647l)); - CHECK(node.append_child(STR("text2")).text().set(-2147483647l - 1)); - CHECK(!xml_text().set(-2147483647l - 1)); - - CHECK(node.append_child(STR("text3")).text().set(4294967295ul)); - CHECK(node.append_child(STR("text4")).text().set(4294967294ul)); - CHECK(!xml_text().set(4294967295ul)); - - CHECK_NODE(node, STR("-2147483647-214748364842949672954294967294")); -} -#endif - -#ifdef PUGIXML_HAS_LONG_LONG -TEST_XML(dom_text_assign_llong, "") -{ - xml_node node = doc.child(STR("node")); - - node.append_child(STR("text1")).text() = -9223372036854775807ll; - node.append_child(STR("text2")).text() = -9223372036854775807ll - 1; - xml_text() = -9223372036854775807ll - 1; - - node.append_child(STR("text3")).text() = 18446744073709551615ull; - node.append_child(STR("text4")).text() = 18446744073709551614ull; - xml_text() = 18446744073709551615ull; - - CHECK_NODE(node, STR("-9223372036854775807-92233720368547758081844674407370955161518446744073709551614")); -} - -TEST_XML(dom_text_set_value_llong, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.append_child(STR("text1")).text().set(-9223372036854775807ll)); - CHECK(node.append_child(STR("text2")).text().set(-9223372036854775807ll - 1)); - CHECK(!xml_text().set(-9223372036854775807ll - 1)); - - CHECK(node.append_child(STR("text3")).text().set(18446744073709551615ull)); - CHECK(node.append_child(STR("text4")).text().set(18446744073709551614ull)); - CHECK(!xml_text().set(18446744073709551615ull)); - - CHECK_NODE(node, STR("-9223372036854775807-92233720368547758081844674407370955161518446744073709551614")); -} -#endif - -TEST_XML(dom_text_middle, "notthisonetext") -{ - xml_node node = doc.child(STR("node")); - xml_text t = node.text(); - - CHECK_STRING(t.get(), STR("text")); - t.set(STR("notext")); - - CHECK_NODE(node, STR("notthisonenotext")); - CHECK(node.remove_child(t.data())); - - CHECK(!t); - CHECK_NODE(node, STR("notthisone")); - - t.set(STR("yestext")); - - CHECK(t); - CHECK_NODE(node, STR("notthisoneyestext")); - CHECK(t.data() == node.last_child()); -} - -TEST_XML_FLAGS(dom_text_data, "foo", parse_default | parse_pi) -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.child(STR("a")).text().data() == node.child(STR("a")).first_child()); - CHECK(node.child(STR("b")).text().data() == node.child(STR("b")).first_child()); - CHECK(!node.child(STR("c")).text().data()); - CHECK(!node.child(STR("d")).text().data()); - CHECK(!xml_text().data()); -} - -TEST(dom_text_defaults) -{ - xml_text text; - - CHECK_STRING(text.as_string(STR("foo")), STR("foo")); - CHECK(text.as_int(42) == 42); - CHECK(text.as_uint(42) == 42); - CHECK(text.as_double(42) == 42); - CHECK(text.as_float(42) == 42); - CHECK(text.as_bool(true) == true); - -#ifdef PUGIXML_HAS_LONG_LONG - CHECK(text.as_llong(42) == 42); - CHECK(text.as_ullong(42) == 42); -#endif -} diff --git a/external/pugixml/tests/test_dom_traverse.cpp b/external/pugixml/tests/test_dom_traverse.cpp deleted file mode 100644 index 4a2403d4c..000000000 --- a/external/pugixml/tests/test_dom_traverse.cpp +++ /dev/null @@ -1,1299 +0,0 @@ -#define _CRT_SECURE_NO_WARNINGS -#define _SCL_SECURE_NO_WARNINGS -#define _SCL_SECURE_NO_DEPRECATE - -#include "test.hpp" - -#include -#include -#include - -#include -#include -#include -#include - -#include "helpers.hpp" - -using namespace pugi; - -#ifdef PUGIXML_NO_STL -template static I move_iter(I base, int n) -{ - if (n > 0) while (n--) ++base; - else while (n++) --base; - return base; -} -#else -template static I move_iter(I base, int n) -{ - std::advance(base, n); - return base; -} -#endif - -TEST_XML(dom_attr_bool_ops, "") -{ - generic_bool_ops_test(doc.child(STR("node")).attribute(STR("attr"))); -} - -TEST_XML(dom_attr_eq_ops, "") -{ - generic_eq_ops_test(doc.child(STR("node")).attribute(STR("attr1")), doc.child(STR("node")).attribute(STR("attr2"))); -} - -TEST_XML(dom_attr_rel_ops, "") -{ - generic_rel_ops_test(doc.child(STR("node")).attribute(STR("attr1")), doc.child(STR("node")).attribute(STR("attr2"))); -} - -TEST_XML(dom_attr_empty, "") -{ - generic_empty_test(doc.child(STR("node")).attribute(STR("attr"))); -} - -TEST_XML(dom_attr_next_previous_attribute, "") -{ - xml_attribute attr1 = doc.child(STR("node")).attribute(STR("attr1")); - xml_attribute attr2 = doc.child(STR("node")).attribute(STR("attr2")); - - CHECK(attr1.next_attribute() == attr2); - CHECK(attr2.next_attribute() == xml_attribute()); - - CHECK(attr1.previous_attribute() == xml_attribute()); - CHECK(attr2.previous_attribute() == attr1); - - CHECK(xml_attribute().next_attribute() == xml_attribute()); - CHECK(xml_attribute().previous_attribute() == xml_attribute()); -} - -TEST_XML(dom_attr_name_value, "") -{ - xml_attribute attr = doc.child(STR("node")).attribute(STR("attr")); - - CHECK_NAME_VALUE(attr, STR("attr"), STR("1")); - CHECK_NAME_VALUE(xml_attribute(), STR(""), STR("")); -} - -TEST_XML(dom_attr_as_string, "") -{ - xml_attribute attr = doc.child(STR("node")).attribute(STR("attr")); - - CHECK_STRING(attr.as_string(), STR("1")); - CHECK_STRING(xml_attribute().as_string(), STR("")); -} - -TEST_XML(dom_attr_as_int, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(xml_attribute().as_int() == 0); - CHECK(node.attribute(STR("attr1")).as_int() == 1); - CHECK(node.attribute(STR("attr2")).as_int() == -1); - CHECK(node.attribute(STR("attr3")).as_int() == -2147483647 - 1); - CHECK(node.attribute(STR("attr4")).as_int() == 2147483647); - CHECK(node.attribute(STR("attr5")).as_int() == 0); -} - -TEST_XML(dom_attr_as_int_hex, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_int() == 777); // no octal support! intentional - CHECK(node.attribute(STR("attr2")).as_int() == 1451); - CHECK(node.attribute(STR("attr3")).as_int() == 255); - CHECK(node.attribute(STR("attr4")).as_int() == -32); - CHECK(node.attribute(STR("attr5")).as_int() == -2147483647 - 1); - CHECK(node.attribute(STR("attr6")).as_int() == 0); -} - -TEST_XML(dom_attr_as_uint, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(xml_attribute().as_uint() == 0); - CHECK(node.attribute(STR("attr1")).as_uint() == 0); - CHECK(node.attribute(STR("attr2")).as_uint() == 1); - CHECK(node.attribute(STR("attr3")).as_uint() == 2147483647); - CHECK(node.attribute(STR("attr4")).as_uint() == 4294967295u); - CHECK(node.attribute(STR("attr5")).as_uint() == 0); -} - -TEST_XML(dom_attr_as_uint_hex, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_uint() == 777); // no octal support! intentional - CHECK(node.attribute(STR("attr2")).as_uint() == 1451); - CHECK(node.attribute(STR("attr3")).as_uint() == 255); - CHECK(node.attribute(STR("attr4")).as_uint() == 32); - CHECK(node.attribute(STR("attr5")).as_uint() == 4294967295u); - CHECK(node.attribute(STR("attr6")).as_uint() == 0); -} - -TEST_XML(dom_attr_as_integer_space, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_int() == 1234); - CHECK(node.attribute(STR("attr2")).as_int() == 291); - CHECK(node.attribute(STR("attr3")).as_int() == 0); - CHECK(node.attribute(STR("attr4")).as_int() == 0); - -#ifdef PUGIXML_HAS_LONG_LONG - CHECK(node.attribute(STR("attr1")).as_llong() == 1234); -#endif -} - -TEST_XML(dom_attr_as_float, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(xml_attribute().as_float() == 0); - CHECK_DOUBLE(double(node.attribute(STR("attr1")).as_float()), 0); - CHECK_DOUBLE(double(node.attribute(STR("attr2")).as_float()), 1); - CHECK_DOUBLE(double(node.attribute(STR("attr3")).as_float()), 0.12); - CHECK_DOUBLE(double(node.attribute(STR("attr4")).as_float()), -5.1); - CHECK_DOUBLE(double(node.attribute(STR("attr5")).as_float()), 3e-4); - CHECK_DOUBLE(double(node.attribute(STR("attr6")).as_float()), 3.14159265358979323846); -} - -TEST_XML(dom_attr_as_double, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(xml_attribute().as_double() == 0); - CHECK_DOUBLE(node.attribute(STR("attr1")).as_double(), 0); - CHECK_DOUBLE(node.attribute(STR("attr2")).as_double(), 1); - CHECK_DOUBLE(node.attribute(STR("attr3")).as_double(), 0.12); - CHECK_DOUBLE(node.attribute(STR("attr4")).as_double(), -5.1); - CHECK_DOUBLE(node.attribute(STR("attr5")).as_double(), 3e-4); - CHECK_DOUBLE(node.attribute(STR("attr6")).as_double(), 3.14159265358979323846); -} - -TEST_XML(dom_attr_as_bool, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(!xml_attribute().as_bool()); - CHECK(!node.attribute(STR("attr1")).as_bool()); - CHECK(node.attribute(STR("attr2")).as_bool()); - CHECK(node.attribute(STR("attr3")).as_bool()); - CHECK(node.attribute(STR("attr4")).as_bool()); - CHECK(node.attribute(STR("attr5")).as_bool()); - CHECK(node.attribute(STR("attr6")).as_bool()); - CHECK(!node.attribute(STR("attr7")).as_bool()); -} - -#ifdef PUGIXML_HAS_LONG_LONG -TEST_XML(dom_attr_as_llong, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(xml_attribute().as_llong() == 0); - CHECK(node.attribute(STR("attr1")).as_llong() == 1); - CHECK(node.attribute(STR("attr2")).as_llong() == -1); - CHECK(node.attribute(STR("attr3")).as_llong() == -9223372036854775807ll - 1); - CHECK(node.attribute(STR("attr4")).as_llong() == 9223372036854775807ll); - CHECK(node.attribute(STR("attr5")).as_llong() == 0); -} - -TEST_XML(dom_attr_as_llong_hex, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_llong() == 777); // no octal support! intentional - CHECK(node.attribute(STR("attr2")).as_llong() == 1451); - CHECK(node.attribute(STR("attr3")).as_llong() == 255); - CHECK(node.attribute(STR("attr4")).as_llong() == -32); - CHECK(node.attribute(STR("attr5")).as_llong() == -9223372036854775807ll - 1); - CHECK(node.attribute(STR("attr6")).as_llong() == 0); -} - -TEST_XML(dom_attr_as_ullong, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(xml_attribute().as_ullong() == 0); - CHECK(node.attribute(STR("attr1")).as_ullong() == 0); - CHECK(node.attribute(STR("attr2")).as_ullong() == 1); - CHECK(node.attribute(STR("attr3")).as_ullong() == 9223372036854775807ull); - CHECK(node.attribute(STR("attr4")).as_ullong() == 18446744073709551615ull); - CHECK(node.attribute(STR("attr5")).as_ullong() == 0); -} - -TEST_XML(dom_attr_as_ullong_hex, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_ullong() == 777); // no octal support! intentional - CHECK(node.attribute(STR("attr2")).as_ullong() == 1451); - CHECK(node.attribute(STR("attr3")).as_ullong() == 255); - CHECK(node.attribute(STR("attr4")).as_ullong() == 32); - CHECK(node.attribute(STR("attr5")).as_ullong() == 18446744073709551615ull); - CHECK(node.attribute(STR("attr6")).as_ullong() == 0); -} -#endif - -TEST(dom_attr_defaults) -{ - xml_attribute attr; - - CHECK_STRING(attr.as_string(STR("foo")), STR("foo")); - CHECK(attr.as_int(42) == 42); - CHECK(attr.as_uint(42) == 42); - CHECK(attr.as_double(42) == 42); - CHECK(attr.as_float(42) == 42); - CHECK(attr.as_bool(true) == true); - -#ifdef PUGIXML_HAS_LONG_LONG - CHECK(attr.as_llong(42) == 42); - CHECK(attr.as_ullong(42) == 42); -#endif -} - -TEST_XML(dom_attr_iterator, "") -{ - xml_node node1 = doc.child(STR("node")).child(STR("node1")); - xml_node node2 = doc.child(STR("node")).child(STR("node2")); - xml_node node3 = doc.child(STR("node")).child(STR("node3")); - - CHECK(xml_node().attributes_begin() == xml_attribute_iterator()); - CHECK(xml_node().attributes_end() == xml_attribute_iterator()); - - CHECK(node1.attributes_begin() == xml_attribute_iterator(node1.attribute(STR("attr1")), node1)); - CHECK(move_iter(node1.attributes_begin(), 1) == node1.attributes_end()); - CHECK(move_iter(node1.attributes_end(), -1) == node1.attributes_begin()); - CHECK(*node1.attributes_begin() == node1.attribute(STR("attr1"))); - CHECK_STRING(node1.attributes_begin()->name(), STR("attr1")); - - CHECK(move_iter(node2.attributes_begin(), 2) == node2.attributes_end()); - CHECK(move_iter(node2.attributes_end(), -2) == node2.attributes_begin()); - - CHECK(node3.attributes_begin() != xml_attribute_iterator()); - CHECK(node3.attributes_begin() == node3.attributes_end()); - - xml_attribute_iterator it = xml_attribute_iterator(node2.attribute(STR("attr2")), node2); - xml_attribute_iterator itt = it; - - CHECK(itt++ == it); - CHECK(itt == node2.attributes_end()); - - CHECK(itt-- == node2.attributes_end()); - CHECK(itt == it); - - CHECK(++itt == node2.attributes_end()); - CHECK(itt == node2.attributes_end()); - - CHECK(--itt == it); - CHECK(itt == it); - - CHECK(++itt != it); -} - -TEST_XML(dom_attr_iterator_end, "") -{ - xml_node node1 = doc.child(STR("node")).child(STR("node1")); - xml_node node2 = doc.child(STR("node")).child(STR("node2")); - xml_node node3 = doc.child(STR("node")).child(STR("node3")); - - CHECK(node1.attributes_end() != node2.attributes_end() && node1.attributes_end() != node3.attributes_end() && node2.attributes_end() != node3.attributes_end()); - CHECK(node1.attributes_end() != xml_attribute_iterator() && node2.attributes_end() != xml_attribute_iterator() && node3.attributes_end() != xml_attribute_iterator()); -} - -TEST_XML(dom_attr_iterator_invalidate, "") -{ - xml_node node2 = doc.child(STR("node")).child(STR("node2")); - - xml_attribute_iterator it1 = node2.attributes_begin(); - xml_attribute_iterator it2 = move_iter(it1, 1); - xml_attribute_iterator it3 = move_iter(it2, 1); - - CHECK(it3 == node2.attributes_end()); - - // removing attr2, it2 is invalid now, it3 is still past-the-end - node2.remove_attribute(*it2); - - CHECK(node2.attributes_end() == it3); - CHECK(move_iter(it1, 1) == it3); - CHECK(move_iter(it3, -1) == it1); - CHECK_STRING(it1->name(), STR("attr1")); - - // adding attr2 back, it3 is still past-the-end! - xml_attribute_iterator it2new = xml_attribute_iterator(node2.append_attribute(STR("attr2-new")), node2); - - CHECK(node2.attributes_end() == it3); - CHECK(move_iter(it1, 1) == it2new); - CHECK(move_iter(it2new, 1) == it3); - CHECK(move_iter(it3, -1) == it2new); - CHECK_STRING(it2new->name(), STR("attr2-new")); - - // removing both attributes, it3 is now equal to the begin - node2.remove_attribute(*it1); - node2.remove_attribute(*it2new); - CHECK(!node2.first_attribute()); - - CHECK(node2.attributes_begin() == it3); - CHECK(node2.attributes_end() == it3); -} - -TEST_XML(dom_attr_iterator_const, "") -{ - xml_node node = doc.child(STR("node")); - - const xml_attribute_iterator i1 = node.attributes_begin(); - const xml_attribute_iterator i2 = ++xml_attribute_iterator(i1); - const xml_attribute_iterator i3 = ++xml_attribute_iterator(i2); - - CHECK(*i1 == node.attribute(STR("attr1"))); - CHECK(*i2 == node.attribute(STR("attr2"))); - CHECK(i3 == node.attributes_end()); - - CHECK_STRING(i1->name(), STR("attr1")); - CHECK_STRING(i2->name(), STR("attr2")); -} - -TEST_XML(dom_node_bool_ops, "") -{ - generic_bool_ops_test(doc.child(STR("node"))); -} - -TEST_XML(dom_node_eq_ops, "") -{ - generic_eq_ops_test(doc.child(STR("node")).child(STR("node1")), doc.child(STR("node")).child(STR("node2"))); -} - -TEST_XML(dom_node_rel_ops, "") -{ - generic_rel_ops_test(doc.child(STR("node")).child(STR("node1")), doc.child(STR("node")).child(STR("node2"))); -} - -TEST_XML(dom_node_empty, "") -{ - generic_empty_test(doc.child(STR("node"))); -} - -TEST_XML(dom_node_iterator, "") -{ - xml_node node1 = doc.child(STR("node")).child(STR("node1")); - xml_node node2 = doc.child(STR("node")).child(STR("node2")); - xml_node node3 = doc.child(STR("node")).child(STR("node3")); - - CHECK(xml_node().begin() == xml_node_iterator()); - CHECK(xml_node().end() == xml_node_iterator()); - - CHECK(node1.begin() == xml_node_iterator(node1.child(STR("child1")))); - CHECK(move_iter(node1.begin(), 1) == node1.end()); - CHECK(move_iter(node1.end(), -1) == node1.begin()); - CHECK(*node1.begin() == node1.child(STR("child1"))); - CHECK_STRING(node1.begin()->name(), STR("child1")); - - CHECK(move_iter(node2.begin(), 2) == node2.end()); - CHECK(move_iter(node2.end(), -2) == node2.begin()); - - CHECK(node3.begin() != xml_node_iterator()); - CHECK(node3.begin() == node3.end()); - - xml_node_iterator it = node2.child(STR("child2")); - xml_node_iterator itt = it; - - CHECK(itt++ == it); - CHECK(itt == node2.end()); - - CHECK(itt-- == node2.end()); - CHECK(itt == it); - - CHECK(++itt == node2.end()); - CHECK(itt == node2.end()); - - CHECK(--itt == it); - CHECK(itt == it); - - CHECK(++itt != it); -} - -TEST_XML(dom_node_iterator_end, "") -{ - xml_node node1 = doc.child(STR("node")).child(STR("node1")); - xml_node node2 = doc.child(STR("node")).child(STR("node2")); - xml_node node3 = doc.child(STR("node")).child(STR("node3")); - - CHECK(node1.end() != node2.end() && node1.end() != node3.end() && node2.end() != node3.end()); - CHECK(node1.end() != xml_node_iterator() && node2.end() != xml_node_iterator() && node3.end() != xml_node_iterator()); -} - -TEST_XML(dom_node_iterator_invalidate, "") -{ - xml_node node2 = doc.child(STR("node")).child(STR("node2")); - - xml_node_iterator it1 = node2.begin(); - xml_node_iterator it2 = move_iter(it1, 1); - xml_node_iterator it3 = move_iter(it2, 1); - - CHECK(it3 == node2.end()); - - // removing child2, it2 is invalid now, it3 is still past-the-end - node2.remove_child(*it2); - - CHECK(node2.end() == it3); - CHECK(move_iter(it1, 1) == it3); - CHECK(move_iter(it3, -1) == it1); - CHECK_STRING(it1->name(), STR("child1")); - - // adding attr2 back, it3 is still past-the-end! - xml_node_iterator it2new = node2.append_child(); - it2new->set_name(STR("child2-new")); - - CHECK(node2.end() == it3); - CHECK(move_iter(it1, 1) == it2new); - CHECK(move_iter(it2new, 1) == it3); - CHECK(move_iter(it3, -1) == it2new); - CHECK_STRING(it2new->name(), STR("child2-new")); - - // removing both nodes, it3 is now equal to the begin - node2.remove_child(*it1); - node2.remove_child(*it2new); - CHECK(!node2.first_child()); - - CHECK(node2.begin() == it3); - CHECK(node2.end() == it3); -} - -TEST_XML(dom_node_iterator_const, "") -{ - xml_node node = doc.child(STR("node")); - - const xml_node_iterator i1 = node.begin(); - const xml_node_iterator i2 = ++xml_node_iterator(i1); - const xml_node_iterator i3 = ++xml_node_iterator(i2); - - CHECK(*i1 == node.child(STR("child1"))); - CHECK(*i2 == node.child(STR("child2"))); - CHECK(i3 == node.end()); - - CHECK_STRING(i1->name(), STR("child1")); - CHECK_STRING(i2->name(), STR("child2")); -} - -TEST_XML(dom_node_parent, "") -{ - CHECK(xml_node().parent() == xml_node()); - CHECK(doc.child(STR("node")).child(STR("child")).parent() == doc.child(STR("node"))); - CHECK(doc.child(STR("node")).parent() == doc); -} - -TEST_XML(dom_node_root, "") -{ - CHECK(xml_node().root() == xml_node()); - CHECK(doc.child(STR("node")).child(STR("child")).root() == doc); - CHECK(doc.child(STR("node")).root() == doc); -} - -TEST_XML_FLAGS(dom_node_type, "pcdata", parse_default | parse_pi | parse_comments | parse_declaration | parse_doctype) -{ - CHECK(xml_node().type() == node_null); - CHECK(doc.type() == node_document); - - xml_node_iterator it = doc.begin(); - - CHECK((it++)->type() == node_declaration); - CHECK((it++)->type() == node_doctype); - CHECK((it++)->type() == node_pi); - CHECK((it++)->type() == node_comment); - CHECK((it++)->type() == node_element); - - xml_node_iterator cit = doc.child(STR("node")).begin(); - - CHECK((cit++)->type() == node_pcdata); - CHECK((cit++)->type() == node_cdata); -} - -TEST_XML_FLAGS(dom_node_name_value, "pcdata", parse_default | parse_pi | parse_comments | parse_declaration | parse_doctype) -{ - CHECK_NAME_VALUE(xml_node(), STR(""), STR("")); - CHECK_NAME_VALUE(doc, STR(""), STR("")); - - xml_node_iterator it = doc.begin(); - - CHECK_NAME_VALUE(*it++, STR("xml"), STR("")); - CHECK_NAME_VALUE(*it++, STR(""), STR("id")); - CHECK_NAME_VALUE(*it++, STR("pi"), STR("")); - CHECK_NAME_VALUE(*it++, STR(""), STR("comment")); - CHECK_NAME_VALUE(*it++, STR("node"), STR("")); - - xml_node_iterator cit = doc.child(STR("node")).begin(); - - CHECK_NAME_VALUE(*cit++, STR(""), STR("pcdata")); - CHECK_NAME_VALUE(*cit++, STR(""), STR("cdata")); -} - -TEST_XML(dom_node_child, "") -{ - CHECK(xml_node().child(STR("n")) == xml_node()); - - CHECK(doc.child(STR("n")) == xml_node()); - CHECK_NAME_VALUE(doc.child(STR("node")), STR("node"), STR("")); - CHECK(doc.child(STR("node")).child(STR("child2")) == doc.child(STR("node")).last_child()); -} - -TEST_XML(dom_node_attribute, "") -{ - CHECK(xml_node().attribute(STR("a")) == xml_attribute()); - - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("n")) == xml_attribute()); - CHECK_NAME_VALUE(node.attribute(STR("attr1")), STR("attr1"), STR("0")); - CHECK(node.attribute(STR("attr2")) == node.last_attribute()); -} - -TEST_XML(dom_node_next_previous_sibling, "") -{ - CHECK(xml_node().next_sibling() == xml_node()); - CHECK(xml_node().next_sibling(STR("n")) == xml_node()); - - CHECK(xml_node().previous_sibling() == xml_node()); - CHECK(xml_node().previous_sibling(STR("n")) == xml_node()); - - xml_node child1 = doc.child(STR("node")).child(STR("child1")); - xml_node child2 = doc.child(STR("node")).child(STR("child2")); - xml_node child3 = doc.child(STR("node")).child(STR("child3")); - - CHECK(child1.next_sibling() == child2); - CHECK(child3.next_sibling() == xml_node()); - - CHECK(child1.previous_sibling() == xml_node()); - CHECK(child3.previous_sibling() == child2); - - CHECK(child1.next_sibling(STR("child3")) == child3); - CHECK(child1.next_sibling(STR("child")) == xml_node()); - - CHECK(child3.previous_sibling(STR("child1")) == child1); - CHECK(child3.previous_sibling(STR("child")) == xml_node()); -} - -TEST_XML(dom_node_child_value, "value1value2value4") -{ - CHECK_STRING(xml_node().child_value(), STR("")); - CHECK_STRING(xml_node().child_value(STR("n")), STR("")); - - xml_node node = doc.child(STR("node")); - - CHECK_STRING(node.child_value(), STR("value4")); - CHECK_STRING(node.child(STR("child1")).child_value(), STR("value1")); - CHECK_STRING(node.child(STR("child2")).child_value(), STR("value2")); - CHECK_STRING(node.child(STR("child3")).child_value(), STR("value3")); - CHECK_STRING(node.child_value(STR("child3")), STR("value3")); - CHECK_STRING(node.child_value(STR("novalue")), STR("")); -} - -TEST_XML(dom_node_first_last_attribute, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.first_attribute() == node.attribute(STR("attr1"))); - CHECK(node.last_attribute() == node.attribute(STR("attr2"))); - - CHECK(xml_node().first_attribute() == xml_attribute()); - CHECK(xml_node().last_attribute() == xml_attribute()); - - CHECK(doc.first_attribute() == xml_attribute()); - CHECK(doc.last_attribute() == xml_attribute()); -} - -TEST_XML(dom_node_first_last_child, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.first_child() == node.child(STR("child1"))); - CHECK(node.last_child() == node.child(STR("child2"))); - - CHECK(xml_node().first_child() == xml_node()); - CHECK(xml_node().last_child() == xml_node()); - - CHECK(doc.first_child() == node); - CHECK(doc.last_child() == node); -} - -TEST_XML(dom_node_find_child_by_attribute, "") -{ - CHECK(xml_node().find_child_by_attribute(STR("name"), STR("attr"), STR("value")) == xml_node()); - CHECK(xml_node().find_child_by_attribute(STR("attr"), STR("value")) == xml_node()); - - xml_node node = doc.child(STR("node")); - - CHECK(node.find_child_by_attribute(STR("child2"), STR("attr"), STR("value3")) == node.last_child()); - CHECK(node.find_child_by_attribute(STR("child2"), STR("attr3"), STR("value3")) == xml_node()); - CHECK(node.find_child_by_attribute(STR("attr"), STR("value2")) == node.child(STR("child2"))); - CHECK(node.find_child_by_attribute(STR("attr3"), STR("value")) == xml_node()); -} - -TEST(dom_node_find_child_by_attribute_null) -{ - xml_document doc; - xml_node node0 = doc.append_child(); - xml_node node1 = doc.append_child(STR("a")); - xml_node node2 = doc.append_child(STR("a")); - xml_node node3 = doc.append_child(STR("a")); - - (void)node0; - - // this adds an attribute with null name and/or value in the internal representation - node1.append_attribute(STR("")); - node2.append_attribute(STR("id")); - node3.append_attribute(STR("id")) = STR("1"); - - // make sure find_child_by_attribute works if name/value is null - CHECK(doc.find_child_by_attribute(STR("unknown"), STR("wrong")) == xml_node()); - CHECK(doc.find_child_by_attribute(STR("id"), STR("wrong")) == xml_node()); - CHECK(doc.find_child_by_attribute(STR("id"), STR("")) == node2); - CHECK(doc.find_child_by_attribute(STR("id"), STR("1")) == node3); - - CHECK(doc.find_child_by_attribute(STR("a"), STR("unknown"), STR("wrong")) == xml_node()); - CHECK(doc.find_child_by_attribute(STR("a"), STR("id"), STR("wrong")) == xml_node()); - CHECK(doc.find_child_by_attribute(STR("a"), STR("id"), STR("")) == node2); - CHECK(doc.find_child_by_attribute(STR("a"), STR("id"), STR("1")) == node3); -} - -struct find_predicate_const -{ - bool result; - - find_predicate_const(bool result_): result(result_) - { - } - - template bool operator()(const T&) const - { - return result; - } -}; - -struct find_predicate_prefix -{ - const char_t* prefix; - - find_predicate_prefix(const char_t* prefix_): prefix(prefix_) - { - } - - template bool operator()(const T& obj) const - { - #ifdef PUGIXML_WCHAR_MODE - // can't use wcsncmp here because of a bug in DMC - return std::basic_string(obj.name()).compare(0, wcslen(prefix), prefix) == 0; - #else - return strncmp(obj.name(), prefix, strlen(prefix)) == 0; - #endif - } -}; - -TEST_XML(dom_node_find_attribute, "") -{ - CHECK(xml_node().find_attribute(find_predicate_const(true)) == xml_attribute()); - - xml_node node = doc.child(STR("node")); - - CHECK(doc.find_attribute(find_predicate_const(true)) == xml_attribute()); - CHECK(node.find_attribute(find_predicate_const(true)) == node.first_attribute()); - CHECK(node.find_attribute(find_predicate_const(false)) == xml_attribute()); - CHECK(node.find_attribute(find_predicate_prefix(STR("attr2"))) == node.last_attribute()); - CHECK(node.find_attribute(find_predicate_prefix(STR("attr"))) == node.first_attribute()); -} - -TEST_XML(dom_node_find_child, "") -{ - CHECK(xml_node().find_child(find_predicate_const(true)) == xml_node()); - - xml_node node = doc.child(STR("node")); - - CHECK(node.child(STR("node")).child(STR("child1")).find_child(find_predicate_const(true)) == xml_node()); - CHECK(node.find_child(find_predicate_const(true)) == node.first_child()); - CHECK(node.find_child(find_predicate_const(false)) == xml_node()); - CHECK(node.find_child(find_predicate_prefix(STR("child2"))) == node.last_child()); - CHECK(node.find_child(find_predicate_prefix(STR("child"))) == node.first_child()); -} - -TEST_XML(dom_node_find_node, "") -{ - CHECK(xml_node().find_node(find_predicate_const(true)) == xml_node()); - - xml_node node = doc.child(STR("node")); - - CHECK(node.child(STR("node")).child(STR("child1")).find_node(find_predicate_const(true)) == xml_node()); - CHECK(node.find_node(find_predicate_const(true)) == node.first_child()); - CHECK(node.find_node(find_predicate_const(false)) == xml_node()); - CHECK(node.find_node(find_predicate_prefix(STR("child2"))) == node.last_child()); - CHECK(node.find_node(find_predicate_prefix(STR("child"))) == node.first_child()); - CHECK(doc.find_node(find_predicate_prefix(STR("child"))) == node.first_child()); - CHECK(doc.find_node(find_predicate_prefix(STR("child2"))) == node.last_child()); - CHECK(doc.find_node(find_predicate_prefix(STR("child3"))) == xml_node()); -} - -#ifndef PUGIXML_NO_STL -TEST_XML(dom_node_path, "text") -{ - CHECK(xml_node().path() == STR("")); - - CHECK(doc.path() == STR("")); - CHECK(doc.child(STR("node")).path() == STR("/node")); - CHECK(doc.child(STR("node")).child(STR("child1")).path() == STR("/node/child1")); - CHECK(doc.child(STR("node")).child(STR("child1")).child(STR("child2")).path() == STR("/node/child1/child2")); - CHECK(doc.child(STR("node")).child(STR("child1")).first_child().path() == STR("/node/child1/")); - - CHECK(doc.child(STR("node")).child(STR("child1")).path('\\') == STR("\\node\\child1")); - - doc.append_child(node_element); - CHECK(doc.last_child().path() == STR("/")); -} -#endif - -TEST_XML(dom_node_first_element_by_path, "text") -{ - CHECK(xml_node().first_element_by_path(STR("/")) == xml_node()); - CHECK(xml_node().first_element_by_path(STR("a")) == xml_node()); - - CHECK(doc.first_element_by_path(STR("")) == doc); - CHECK(doc.first_element_by_path(STR("/")) == doc); - - CHECK(doc.first_element_by_path(STR("/node/")) == doc.child(STR("node"))); - CHECK(doc.first_element_by_path(STR("node/")) == doc.child(STR("node"))); - CHECK(doc.first_element_by_path(STR("node")) == doc.child(STR("node"))); - CHECK(doc.first_element_by_path(STR("/node")) == doc.child(STR("node"))); - -#ifndef PUGIXML_NO_STL - CHECK(doc.first_element_by_path(STR("/node/child1/child2")).path() == STR("/node/child1/child2")); -#endif - - CHECK(doc.first_element_by_path(STR("/node/child2")) == xml_node()); - - CHECK(doc.first_element_by_path(STR("\\node\\child1"), '\\') == doc.child(STR("node")).child(STR("child1"))); - - CHECK(doc.child(STR("node")).first_element_by_path(STR("..")) == doc); - CHECK(doc.child(STR("node")).first_element_by_path(STR(".")) == doc.child(STR("node"))); - - CHECK(doc.child(STR("node")).first_element_by_path(STR("../node/./child1/../.")) == doc.child(STR("node"))); - - CHECK(doc.child(STR("node")).first_element_by_path(STR("child1")) == doc.child(STR("node")).child(STR("child1"))); - CHECK(doc.child(STR("node")).first_element_by_path(STR("child1/")) == doc.child(STR("node")).child(STR("child1"))); - CHECK(doc.child(STR("node")).first_element_by_path(STR("child")) == xml_node()); - CHECK(doc.child(STR("node")).first_element_by_path(STR("child11")) == xml_node()); - - CHECK(doc.first_element_by_path(STR("//node")) == doc.child(STR("node"))); -} - -struct test_walker: xml_tree_walker -{ - std::basic_string log; - unsigned int call_count; - unsigned int stop_count; - - test_walker(unsigned int stop_count_ = 0): call_count(0), stop_count(stop_count_) - { - } - - std::basic_string depthstr() const - { - char buf[32]; - sprintf(buf, "%d", depth()); - - #ifdef PUGIXML_WCHAR_MODE - wchar_t wbuf[32]; - std::copy(buf, buf + strlen(buf) + 1, &wbuf[0]); - - return std::basic_string(wbuf); - #else - return std::basic_string(buf); - #endif - } - - virtual bool begin(xml_node& node) PUGIXML_OVERRIDE - { - log += STR("|"); - log += depthstr(); - log += STR(" <"); - log += node.name(); - log += STR("="); - log += node.value(); - - return ++call_count != stop_count && xml_tree_walker::begin(node); - } - - virtual bool for_each(xml_node& node) PUGIXML_OVERRIDE - { - log += STR("|"); - log += depthstr(); - log += STR(" !"); - log += node.name(); - log += STR("="); - log += node.value(); - - return ++call_count != stop_count && xml_tree_walker::end(node); - } - - virtual bool end(xml_node& node) PUGIXML_OVERRIDE - { - log += STR("|"); - log += depthstr(); - log += STR(" >"); - log += node.name(); - log += STR("="); - log += node.value(); - - return ++call_count != stop_count; - } -}; - -TEST_XML(dom_node_traverse, "text") -{ - test_walker walker; - - CHECK(doc.traverse(walker)); - - CHECK(walker.call_count == 5); - CHECK(walker.log == STR("|-1 <=|0 !node=|1 !child=|2 !=text|-1 >=")); -} - -TEST_XML(dom_node_traverse_siblings, "text") -{ - test_walker walker; - - CHECK(doc.traverse(walker)); - - CHECK(walker.call_count == 7); - CHECK(walker.log == STR("|-1 <=|0 !node=|1 !child=|1 !child=|2 !=text|1 !child=|-1 >=")); -} - -TEST(dom_node_traverse_empty) -{ - test_walker walker; - - CHECK(xml_node().traverse(walker)); - - CHECK(walker.call_count == 2); - CHECK(walker.log == STR("|-1 <=|-1 >=")); -} - -TEST_XML(dom_node_traverse_child, "textnode") -{ - test_walker walker; - - CHECK(doc.child(STR("node")).traverse(walker)); - - CHECK(walker.call_count == 4); - CHECK(walker.log == STR("|-1 node=")); -} - -TEST_XML(dom_node_traverse_stop_begin, "text") -{ - test_walker walker(1); - - CHECK(!doc.traverse(walker)); - - CHECK(walker.call_count == 1); - CHECK(walker.log == STR("|-1 <=")); -} - -TEST_XML(dom_node_traverse_stop_for_each, "text") -{ - test_walker walker(3); - - CHECK(!doc.traverse(walker)); - - CHECK(walker.call_count == 3); - CHECK(walker.log == STR("|-1 <=|0 !node=|1 !child=")); -} - -TEST_XML(dom_node_traverse_stop_end, "text") -{ - test_walker walker(5); - - CHECK(!doc.traverse(walker)); - - CHECK(walker.call_count == 5); - CHECK(walker.log == STR("|-1 <=|0 !node=|1 !child=|2 !=text|-1 >=")); -} - -TEST_XML_FLAGS(dom_offset_debug, "pcdata", parse_default | parse_pi | parse_comments | parse_declaration | parse_doctype) -{ - CHECK(xml_node().offset_debug() == -1); - CHECK(doc.offset_debug() == 0); - - xml_node_iterator it = doc.begin(); - - CHECK((it++)->offset_debug() == 2); - CHECK((it++)->offset_debug() == 16); - CHECK((it++)->offset_debug() == 19); - CHECK((it++)->offset_debug() == 27); - CHECK((it++)->offset_debug() == 38); - - xml_node_iterator cit = doc.child(STR("node")).begin(); - - CHECK((cit++)->offset_debug() == 43); - CHECK((cit++)->offset_debug() == 58); -} - -TEST(dom_offset_debug_encoding) -{ - char buf[] = { 0, '<', 0, 'n', 0, '/', 0, '>' }; - - xml_document doc; - CHECK(doc.load_buffer(buf, sizeof(buf))); - - CHECK(doc.offset_debug() == 0); - CHECK(doc.first_child().offset_debug() == 1); -} - -TEST_XML(dom_offset_debug_append, "") -{ - xml_node c1 = doc.first_child(); - xml_node c2 = doc.append_child(STR("node")); - xml_node c3 = doc.append_child(node_pcdata); - - CHECK(doc.offset_debug() == 0); - CHECK(c1.offset_debug() == 1); - CHECK(c2.offset_debug() == -1); - CHECK(c3.offset_debug() == -1); - - c1.set_name(STR("nodenode")); - CHECK(c1.offset_debug() == -1); -} - -TEST_XML(dom_offset_debug_append_buffer, "") -{ - CHECK(doc.offset_debug() == 0); - CHECK(doc.first_child().offset_debug() == 1); - - CHECK(doc.append_buffer("", 7)); - CHECK(doc.offset_debug() == -1); - CHECK(doc.first_child().offset_debug() == -1); - CHECK(doc.last_child().offset_debug() == -1); -} - -TEST_XML(dom_internal_object, "value") -{ - xml_node node = doc.child(STR("node")); - xml_attribute attr = node.first_attribute(); - xml_node value = node.first_child(); - - CHECK(xml_node().internal_object() == 0); - CHECK(xml_attribute().internal_object() == 0); - - CHECK(node.internal_object() != 0); - CHECK(value.internal_object() != 0); - CHECK(node.internal_object() != value.internal_object()); - - CHECK(attr.internal_object() != 0); - - xml_node node_copy = node; - CHECK(node_copy.internal_object() == node.internal_object()); - - xml_attribute attr_copy = attr; - CHECK(attr_copy.internal_object() == attr.internal_object()); -} - -TEST_XML(dom_hash_value, "value") -{ - xml_node node = doc.child(STR("node")); - xml_attribute attr = node.first_attribute(); - xml_node value = node.first_child(); - - CHECK(xml_node().hash_value() == 0); - CHECK(xml_attribute().hash_value() == 0); - - CHECK(node.hash_value() != 0); - CHECK(value.hash_value() != 0); - CHECK(node.hash_value() != value.hash_value()); - - CHECK(attr.hash_value() != 0); - - xml_node node_copy = node; - CHECK(node_copy.hash_value() == node.hash_value()); - - xml_attribute attr_copy = attr; - CHECK(attr_copy.hash_value() == attr.hash_value()); -} - -TEST_XML(dom_node_named_iterator, "") -{ - xml_node node1 = doc.child(STR("node")).child(STR("node1")); - xml_node node2 = doc.child(STR("node")).child(STR("node2")); - xml_node node3 = doc.child(STR("node")).child(STR("node3")); - xml_node node4 = doc.child(STR("node")).child(STR("node4")); - - CHECK(xml_named_node_iterator(xml_node(), STR("child")) == xml_named_node_iterator()); - - xml_object_range r1 = node1.children(STR("child")); - xml_object_range r2 = node2.children(STR("child")); - xml_object_range r3 = node3.children(STR("child")); - xml_object_range r4 = node4.children(STR("child")); - - CHECK(r1.begin() != r1.end()); - CHECK(*r1.begin() == node1.first_child()); - CHECK(r1.begin() == move_iter(r1.end(), -1)); - CHECK(move_iter(r1.begin(), 1) == r1.end()); - - CHECK(r2.begin() != r2.end()); - CHECK(*r2.begin() == node2.first_child()); - CHECK(*move_iter(r2.begin(), 1) == node2.last_child()); - CHECK(r2.begin() == move_iter(r2.end(), -2)); - CHECK(move_iter(r2.begin(), 1) == move_iter(r2.end(), -1)); - CHECK(move_iter(r2.begin(), 2) == r2.end()); - - CHECK(r3.begin() == r3.end()); - CHECK(!(r3.begin() != r3.end())); - - CHECK(r4.begin() != r4.end()); - CHECK(*r4.begin() == node4.first_child()); - CHECK(r4.begin() == move_iter(r4.end(), -1)); - CHECK(move_iter(r4.begin(), 1) == r4.end()); - - xml_named_node_iterator it = r1.begin(); - xml_named_node_iterator itt = it; - - CHECK(itt == it); - - CHECK(itt++ == it); - CHECK(itt == r1.end()); - - CHECK(itt != it); - CHECK(itt == ++it); - - CHECK(itt-- == r1.end()); - CHECK(itt == r1.begin()); - - CHECK(itt->offset_debug() == 14); -} - -TEST_XML(dom_node_children_attributes, "") -{ - xml_object_range r1 = doc.children(); - - CHECK(r1.begin() == doc.begin()); - CHECK(r1.end() == doc.end()); - - xml_object_range r2 = xml_node().children(); - - CHECK(r2.begin() == xml_node_iterator()); - CHECK(r2.end() == xml_node_iterator()); - - xml_node node = doc.child(STR("node1")); - - xml_object_range r3 = node.attributes(); - - CHECK(r3.begin() == node.attributes_begin()); - CHECK(r3.end() == node.attributes_end()); - - xml_object_range r4 = xml_node().attributes(); - - CHECK(r4.begin() == xml_attribute_iterator()); - CHECK(r4.end() == xml_attribute_iterator()); -} - -TEST_XML(dom_unspecified_bool_coverage, "text") -{ - xml_node node = doc.first_child(); - - CHECK(node); - static_cast(node)(0); - - CHECK(node.first_attribute()); - static_cast(node.first_attribute())(0); - - CHECK(node.text()); - static_cast(node.text())(0); - -#ifndef PUGIXML_NO_XPATH - xpath_query q(STR("/node")); - - CHECK(q); - static_cast(q)(0); - - xpath_node qn = q.evaluate_node(doc); - - CHECK(qn); - static_cast(qn)(0); -#endif -} - -#if __cplusplus >= 201103 -TEST_XML(dom_ranged_for, "354") -{ - int index = 1; - - for (xml_node n: doc.children()) - { - for (xml_attribute a: n.attributes()) - { - CHECK(a.as_int() == index); - index++; - } - - for (xml_node c: n.children(STR("test"))) - { - CHECK(c.text().as_int() == index); - index++; - } - } - - CHECK(index == 5); -} -#endif - -TEST_XML(dom_node_attribute_hinted, "") -{ - xml_node node = doc.first_child(); - xml_attribute attr1 = node.attribute(STR("attr1")); - xml_attribute attr2 = node.attribute(STR("attr2")); - xml_attribute attr3 = node.attribute(STR("attr3")); - - xml_attribute hint; - CHECK(!xml_node().attribute(STR("test"), hint) && !hint); - - CHECK(node.attribute(STR("attr2"), hint) == attr2 && hint == attr3); - CHECK(node.attribute(STR("attr3"), hint) == attr3 && !hint); - - CHECK(node.attribute(STR("attr1"), hint) == attr1 && hint == attr2); - CHECK(node.attribute(STR("attr2"), hint) == attr2 && hint == attr3); - CHECK(node.attribute(STR("attr1"), hint) == attr1 && hint == attr2); - CHECK(node.attribute(STR("attr1"), hint) == attr1 && hint == attr2); - - CHECK(!node.attribute(STR("attr"), hint) && hint == attr2); -} - -TEST_XML(dom_as_int_overflow, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_int() == -2147483647 - 1); - CHECK(node.attribute(STR("attr2")).as_int() == 2147483647); - CHECK(node.attribute(STR("attr3")).as_int() == -2147483647 - 1); -} - -TEST_XML(dom_as_uint_overflow, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_uint() == 0); - CHECK(node.attribute(STR("attr2")).as_uint() == 4294967295u); - CHECK(node.attribute(STR("attr3")).as_uint() == 4294967295u); - CHECK(node.attribute(STR("attr4")).as_uint() == 4294967295u); -} - -TEST_XML(dom_as_int_hex_overflow, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_int() == -2147483647 - 1); - CHECK(node.attribute(STR("attr2")).as_int() == 2147483647); -} - -TEST_XML(dom_as_uint_hex_overflow, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_uint() == 0); - CHECK(node.attribute(STR("attr2")).as_uint() == 4294967295u); - CHECK(node.attribute(STR("attr3")).as_uint() == 4294967295u); -} - -TEST_XML(dom_as_int_many_digits, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_int() == 1); - CHECK(node.attribute(STR("attr1")).as_uint() == 1); -} - -TEST_XML(dom_as_int_hex_many_digits, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_int() == 1); - CHECK(node.attribute(STR("attr1")).as_uint() == 1); -} - -#ifdef PUGIXML_HAS_LONG_LONG -TEST_XML(dom_as_llong_overflow, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_llong() == -9223372036854775807ll - 1); - CHECK(node.attribute(STR("attr2")).as_llong() == 9223372036854775807ll); - CHECK(node.attribute(STR("attr3")).as_llong() == -9223372036854775807ll - 1); -} - -TEST_XML(dom_as_ullong_overflow, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_ullong() == 0); - CHECK(node.attribute(STR("attr2")).as_ullong() == 18446744073709551615ull); - CHECK(node.attribute(STR("attr3")).as_ullong() == 18446744073709551615ull); - CHECK(node.attribute(STR("attr4")).as_ullong() == 18446744073709551615ull); -} - -TEST_XML(dom_as_llong_hex_overflow, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_llong() == -9223372036854775807ll - 1); - CHECK(node.attribute(STR("attr2")).as_llong() == 9223372036854775807ll); -} - -TEST_XML(dom_as_ullong_hex_overflow, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_ullong() == 0); - CHECK(node.attribute(STR("attr2")).as_ullong() == 18446744073709551615ull); - CHECK(node.attribute(STR("attr3")).as_ullong() == 18446744073709551615ull); -} - -TEST_XML(dom_as_llong_many_digits, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_llong() == 1); - CHECK(node.attribute(STR("attr1")).as_ullong() == 1); -} - -TEST_XML(dom_as_llong_hex_many_digits, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_llong() == 1); - CHECK(node.attribute(STR("attr1")).as_ullong() == 1); -} -#endif - -TEST_XML(dom_as_int_plus, "") -{ - xml_node node = doc.child(STR("node")); - - CHECK(node.attribute(STR("attr1")).as_int() == 1); - CHECK(node.attribute(STR("attr1")).as_uint() == 1); - CHECK(node.attribute(STR("attr2")).as_int() == 10); - CHECK(node.attribute(STR("attr2")).as_uint() == 10); - -#ifdef PUGIXML_HAS_LONG_LONG - CHECK(node.attribute(STR("attr1")).as_llong() == 1); - CHECK(node.attribute(STR("attr1")).as_ullong() == 1); - CHECK(node.attribute(STR("attr2")).as_llong() == 10); - CHECK(node.attribute(STR("attr2")).as_ullong() == 10); -#endif -} - -TEST(dom_node_anonymous) -{ - xml_document doc; - doc.append_child(node_element); - doc.append_child(node_element); - doc.append_child(node_pcdata); - - CHECK(doc.child(STR("node")) == xml_node()); - CHECK(doc.first_child().next_sibling(STR("node")) == xml_node()); - CHECK(doc.last_child().previous_sibling(STR("node")) == xml_node()); - CHECK_STRING(doc.child_value(), STR("")); - CHECK_STRING(doc.last_child().child_value(), STR("")); -} diff --git a/external/pugixml/tests/test_header_guard.cpp b/external/pugixml/tests/test_header_guard.cpp deleted file mode 100644 index 2f6592829..000000000 --- a/external/pugixml/tests/test_header_guard.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// Tests header guards -#include "../src/pugixml.hpp" -#include "../src/pugixml.hpp" diff --git a/external/pugixml/tests/test_header_iosfwd_1.cpp b/external/pugixml/tests/test_header_iosfwd_1.cpp deleted file mode 100644 index 0ed528a63..000000000 --- a/external/pugixml/tests/test_header_iosfwd_1.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// Tests compatibility with iosfwd -#include "../src/pugixml.hpp" -#include diff --git a/external/pugixml/tests/test_header_iosfwd_2.cpp b/external/pugixml/tests/test_header_iosfwd_2.cpp deleted file mode 100644 index 865d0d809..000000000 --- a/external/pugixml/tests/test_header_iosfwd_2.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// Tests compatibility with iosfwd -#include -#include "../src/pugixml.hpp" diff --git a/external/pugixml/tests/test_header_iostream_1.cpp b/external/pugixml/tests/test_header_iostream_1.cpp deleted file mode 100644 index a836d4fc6..000000000 --- a/external/pugixml/tests/test_header_iostream_1.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// Tests compatibility with iostream -#include "../src/pugixml.hpp" -#include diff --git a/external/pugixml/tests/test_header_iostream_2.cpp b/external/pugixml/tests/test_header_iostream_2.cpp deleted file mode 100644 index c0be50bc8..000000000 --- a/external/pugixml/tests/test_header_iostream_2.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// Tests compatibility with iostream -#include -#include "../src/pugixml.hpp" diff --git a/external/pugixml/tests/test_header_only_1.cpp b/external/pugixml/tests/test_header_only_1.cpp deleted file mode 100644 index 2e90b3383..000000000 --- a/external/pugixml/tests/test_header_only_1.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#define PUGIXML_HEADER_ONLY -#define pugi pugih - -#include "test.hpp" - -// Check header guards -#include "../src/pugixml.hpp" -#include "../src/pugixml.hpp" - -using namespace pugi; - -TEST(header_only_1) -{ - xml_document doc; - CHECK(doc.load_string(STR(""))); - CHECK_STRING(doc.first_child().name(), STR("node")); - -#ifndef PUGIXML_NO_XPATH - CHECK(doc.first_child() == doc.select_node(STR("//*")).node()); -#endif -} diff --git a/external/pugixml/tests/test_header_only_2.cpp b/external/pugixml/tests/test_header_only_2.cpp deleted file mode 100644 index e4e876d03..000000000 --- a/external/pugixml/tests/test_header_only_2.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#define PUGIXML_HEADER_ONLY -#define pugi pugih - -#include "test.hpp" - -// Check header guards -#include "../src/pugixml.hpp" -#include "../src/pugixml.hpp" - -using namespace pugi; - -TEST(header_only_2) -{ - xml_document doc; - CHECK(doc.load_string(STR(""))); - CHECK_STRING(doc.first_child().name(), STR("node")); - -#ifndef PUGIXML_NO_XPATH - CHECK(doc.first_child() == doc.select_node(STR("//*")).node()); -#endif -} diff --git a/external/pugixml/tests/test_header_string_1.cpp b/external/pugixml/tests/test_header_string_1.cpp deleted file mode 100644 index 07d1263b6..000000000 --- a/external/pugixml/tests/test_header_string_1.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// Tests compatibility with string -#include "../src/pugixml.hpp" -#include diff --git a/external/pugixml/tests/test_header_string_2.cpp b/external/pugixml/tests/test_header_string_2.cpp deleted file mode 100644 index 2813fc93f..000000000 --- a/external/pugixml/tests/test_header_string_2.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// Tests compatibility with string -#include -#include "../src/pugixml.hpp" diff --git a/external/pugixml/tests/test_header_string_iostream.cpp b/external/pugixml/tests/test_header_string_iostream.cpp deleted file mode 100644 index 321008041..000000000 --- a/external/pugixml/tests/test_header_string_iostream.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// Tests compatibility with string/iostream -#include -#include "../src/pugixml.hpp" -#include -#include diff --git a/external/pugixml/tests/test_memory.cpp b/external/pugixml/tests/test_memory.cpp deleted file mode 100644 index 325873626..000000000 --- a/external/pugixml/tests/test_memory.cpp +++ /dev/null @@ -1,303 +0,0 @@ -#include "test.hpp" - -#include "writer_string.hpp" -#include "allocator.hpp" - -#include -#include - -using namespace pugi; - -namespace -{ - int page_allocs = 0; - int page_deallocs = 0; - - bool is_page(size_t size) - { - return size >= 16384; - } - - void* allocate(size_t size) - { - void* ptr = memory_allocate(size); - page_allocs += is_page(memory_size(ptr)); - return ptr; - } - - void deallocate(void* ptr) - { - page_deallocs += is_page(memory_size(ptr)); - memory_deallocate(ptr); - } -} - -TEST(memory_custom_memory_management) -{ - page_allocs = page_deallocs = 0; - - // remember old functions - allocation_function old_allocate = get_memory_allocation_function(); - deallocation_function old_deallocate = get_memory_deallocation_function(); - - // replace functions - set_memory_management_functions(allocate, deallocate); - - { - // parse document - xml_document doc; - - CHECK(page_allocs == 0 && page_deallocs == 0); - - CHECK(doc.load_string(STR(""))); - - CHECK(page_allocs == 1 && page_deallocs == 0); - - // modify document (no new page) - CHECK(doc.first_child().set_name(STR("foobars"))); - CHECK(page_allocs == 1 && page_deallocs == 0); - - // modify document (new page) - std::basic_string s(65536, 'x'); - - CHECK(doc.first_child().set_name(s.c_str())); - CHECK(page_allocs == 2 && page_deallocs == 0); - - // modify document (new page, old one should die) - s += s; - - CHECK(doc.first_child().set_name(s.c_str())); - CHECK(page_allocs == 3 && page_deallocs == 1); - } - - CHECK(page_allocs == 3 && page_deallocs == 3); - - // restore old functions - set_memory_management_functions(old_allocate, old_deallocate); -} - -TEST(memory_large_allocations) -{ - page_allocs = page_deallocs = 0; - - // remember old functions - allocation_function old_allocate = get_memory_allocation_function(); - deallocation_function old_deallocate = get_memory_deallocation_function(); - - // replace functions - set_memory_management_functions(allocate, deallocate); - - { - xml_document doc; - - CHECK(page_allocs == 0 && page_deallocs == 0); - - // initial fill - for (size_t i = 0; i < 128; ++i) - { - std::basic_string s(i * 128, 'x'); - - CHECK(doc.append_child(node_pcdata).set_value(s.c_str())); - } - - CHECK(page_allocs > 0 && page_deallocs == 0); - - // grow-prune loop - while (doc.first_child()) - { - xml_node node; - - // grow - for (node = doc.first_child(); node; node = node.next_sibling()) - { - std::basic_string s = node.value(); - - CHECK(node.set_value((s + s).c_str())); - } - - // prune - for (node = doc.first_child(); node; ) - { - xml_node next = node.next_sibling().next_sibling(); - - node.parent().remove_child(node); - - node = next; - } - } - - CHECK(page_allocs == page_deallocs + 1); // only one live page left (it waits for new allocations) - - char buffer; - CHECK(doc.load_buffer_inplace(&buffer, 0, parse_fragment, get_native_encoding())); - - CHECK(page_allocs == page_deallocs); // no live pages left - } - - CHECK(page_allocs == page_deallocs); // everything is freed - - // restore old functions - set_memory_management_functions(old_allocate, old_deallocate); -} - -TEST(memory_page_management) -{ - page_allocs = page_deallocs = 0; - - // remember old functions - allocation_function old_allocate = get_memory_allocation_function(); - deallocation_function old_deallocate = get_memory_deallocation_function(); - - // replace functions - set_memory_management_functions(allocate, deallocate); - - { - xml_document doc; - - CHECK(page_allocs == 0 && page_deallocs == 0); - - // initial fill - std::vector nodes; - - for (size_t i = 0; i < 4000; ++i) - { - xml_node node = doc.append_child(STR("n")); - CHECK(node); - - nodes.push_back(node); - } - - CHECK(page_allocs > 0 && page_deallocs == 0); - - // grow-prune loop - size_t offset = 0; - size_t prime = 15485863; - - while (nodes.size() > 0) - { - offset = (offset + prime) % nodes.size(); - - doc.remove_child(nodes[offset]); - - nodes[offset] = nodes.back(); - nodes.pop_back(); - } - - CHECK(page_allocs == page_deallocs + 1); // only one live page left (it waits for new allocations) - - char buffer; - CHECK(doc.load_buffer_inplace(&buffer, 0, parse_fragment, get_native_encoding())); - - CHECK(page_allocs == page_deallocs); // no live pages left - } - - CHECK(page_allocs == page_deallocs); // everything is freed - - // restore old functions - set_memory_management_functions(old_allocate, old_deallocate); -} - -TEST(memory_string_allocate_increasing) -{ - xml_document doc; - - doc.append_child(node_pcdata).set_value(STR("x")); - - std::basic_string s = STR("ab"); - - for (int i = 0; i < 17; ++i) - { - doc.append_child(node_pcdata).set_value(s.c_str()); - - s += s; - } - - std::string result = save_narrow(doc, format_no_declaration | format_raw, encoding_utf8); - - CHECK(result.size() == 262143); - CHECK(result[0] == 'x'); - - for (size_t j = 1; j < result.size(); ++j) - { - CHECK(result[j] == (j % 2 ? 'a' : 'b')); - } -} - -TEST(memory_string_allocate_decreasing) -{ - xml_document doc; - - std::basic_string s = STR("ab"); - - for (int i = 0; i < 17; ++i) s += s; - - for (int j = 0; j < 17; ++j) - { - s.resize(s.size() / 2); - - doc.append_child(node_pcdata).set_value(s.c_str()); - } - - doc.append_child(node_pcdata).set_value(STR("x")); - - std::string result = save_narrow(doc, format_no_declaration | format_raw, encoding_utf8); - - CHECK(result.size() == 262143); - CHECK(result[result.size() - 1] == 'x'); - - for (size_t k = 0; k + 1 < result.size(); ++k) - { - CHECK(result[k] == (k % 2 ? 'b' : 'a')); - } -} - -TEST(memory_string_allocate_increasing_inplace) -{ - xml_document doc; - - xml_node node = doc.append_child(node_pcdata); - - node.set_value(STR("x")); - - std::basic_string s = STR("ab"); - - for (int i = 0; i < 17; ++i) - { - node.set_value(s.c_str()); - - s += s; - } - - std::string result = save_narrow(doc, format_no_declaration | format_raw, encoding_utf8); - - CHECK(result.size() == 131072); - - for (size_t j = 0; j < result.size(); ++j) - { - CHECK(result[j] == (j % 2 ? 'b' : 'a')); - } -} - -TEST(memory_string_allocate_decreasing_inplace) -{ - xml_document doc; - - xml_node node = doc.append_child(node_pcdata); - - std::basic_string s = STR("ab"); - - for (int i = 0; i < 17; ++i) s += s; - - for (int j = 0; j < 17; ++j) - { - s.resize(s.size() / 2); - - node.set_value(s.c_str()); - } - - node.set_value(STR("x")); - - std::string result = save_narrow(doc, format_no_declaration | format_raw, encoding_utf8); - - CHECK(result == "x"); -} diff --git a/external/pugixml/tests/test_parse.cpp b/external/pugixml/tests/test_parse.cpp deleted file mode 100644 index 180c70ad4..000000000 --- a/external/pugixml/tests/test_parse.cpp +++ /dev/null @@ -1,1357 +0,0 @@ -#include "test.hpp" - -#include "writer_string.hpp" - -using namespace pugi; - -TEST(parse_pi_skip) -{ - xml_document doc; - - unsigned int flag_sets[] = {parse_fragment, parse_fragment | parse_declaration}; - - for (unsigned int i = 0; i < sizeof(flag_sets) / sizeof(flag_sets[0]); ++i) - { - unsigned int flags = flag_sets[i]; - - CHECK(doc.load_string(STR(""), flags)); - CHECK(!doc.first_child()); - - CHECK(doc.load_string(STR(" value?>"), flags)); - CHECK(!doc.first_child()); - } -} - -TEST(parse_pi_parse) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_fragment | parse_pi)); - - xml_node pi1 = doc.first_child(); - xml_node pi2 = doc.last_child(); - - CHECK(pi1 != pi2); - CHECK(pi1.type() == node_pi); - CHECK_STRING(pi1.name(), STR("pi1")); - CHECK_STRING(pi1.value(), STR("")); - CHECK(pi2.type() == node_pi); - CHECK_STRING(pi2.name(), STR("pi2")); - CHECK_STRING(pi2.value(), STR("value")); -} - -TEST(parse_pi_parse_spaces) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_fragment | parse_pi)); - - xml_node pi = doc.first_child(); - - CHECK(pi.type() == node_pi); - CHECK_STRING(pi.name(), STR("target")); - CHECK_STRING(pi.value(), STR("value ")); -} - -TEST(parse_pi_error) -{ - xml_document doc; - - unsigned int flag_sets[] = {parse_fragment, parse_fragment | parse_pi}; - - for (unsigned int i = 0; i < sizeof(flag_sets) / sizeof(flag_sets[0]); ++i) - { - unsigned int flags = flag_sets[i]; - - CHECK(doc.load_string(STR(""), flags).status == status_bad_pi); - CHECK(doc.load_string(STR(""), flags).status == status_bad_pi); - CHECK(doc.load_string(STR(""), flags).status == status_bad_pi); - CHECK(doc.load_string(STR(""), flags).status == status_bad_pi); - CHECK(doc.load_string(STR(" "), flags).status == status_bad_pi); - CHECK(doc.load_string(STR(""), parse_fragment | parse_pi).status == status_bad_pi); - CHECK(doc.load_string(STR(""), parse_fragment | parse_pi).status == status_bad_pi); - CHECK(doc.load_string(STR(""), parse_fragment | parse_pi).status == status_bad_pi); -} - -TEST(parse_pi_error_buffer_boundary) -{ - char buf1[] = ""; - char buf2[] = ""), parse_fragment)); - CHECK(!doc.first_child()); -} - -TEST(parse_comments_parse) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_fragment | parse_comments)); - - xml_node c1 = doc.first_child(); - xml_node c2 = doc.last_child(); - - CHECK(c1 != c2); - CHECK(c1.type() == node_comment); - CHECK_STRING(c1.name(), STR("")); - CHECK_STRING(c1.value(), STR("")); - CHECK(c2.type() == node_comment); - CHECK_STRING(c2.name(), STR("")); - CHECK_STRING(c2.value(), STR("value")); -} - -TEST(parse_comments_parse_no_eol) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_fragment | parse_comments)); - - xml_node c = doc.first_child(); - CHECK(c.type() == node_comment); - CHECK_STRING(c.value(), STR("\r\rval1\rval2\r\nval3\nval4\r\r")); -} - -TEST(parse_comments_parse_eol) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_fragment | parse_comments | parse_eol)); - - xml_node c = doc.first_child(); - CHECK(c.type() == node_comment); - CHECK_STRING(c.value(), STR("\n\nval1\nval2\nval3\nval4\n\n")); -} - -TEST(parse_comments_error) -{ - xml_document doc; - - unsigned int flag_sets[] = {parse_fragment, parse_fragment | parse_comments, parse_fragment | parse_comments | parse_eol}; - - for (unsigned int i = 0; i < sizeof(flag_sets) / sizeof(flag_sets[0]); ++i) - { - unsigned int flags = flag_sets[i]; - - CHECK(doc.load_string(STR(""), flags).status == status_bad_comment); - CHECK(doc.load_string(STR(""), flags).status == status_bad_comment); - CHECK(doc.load_string(STR(""), flags).status == status_bad_comment); - } -} - -TEST(parse_cdata_skip) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_fragment)); - CHECK(!doc.first_child()); -} - -TEST(parse_cdata_skip_contents) -{ - xml_document doc; - CHECK(doc.load_string(STR("hello, world!"), parse_fragment)); - CHECK_NODE(doc, STR("hello, world!")); -} - -TEST(parse_cdata_parse) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_fragment | parse_cdata)); - - xml_node c1 = doc.first_child(); - xml_node c2 = doc.last_child(); - - CHECK(c1 != c2); - CHECK(c1.type() == node_cdata); - CHECK_STRING(c1.name(), STR("")); - CHECK_STRING(c1.value(), STR("")); - CHECK(c2.type() == node_cdata); - CHECK_STRING(c2.name(), STR("")); - CHECK_STRING(c2.value(), STR("value")); -} - -TEST(parse_cdata_parse_no_eol) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_fragment | parse_cdata)); - - xml_node c = doc.first_child(); - CHECK(c.type() == node_cdata); - CHECK_STRING(c.value(), STR("\r\rval1\rval2\r\nval3\nval4\r\r")); -} - -TEST(parse_cdata_parse_eol) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_fragment | parse_cdata | parse_eol)); - - xml_node c = doc.first_child(); - CHECK(c.type() == node_cdata); - CHECK_STRING(c.value(), STR("\n\nval1\nval2\nval3\nval4\n\n")); -} - -TEST(parse_cdata_error) -{ - xml_document doc; - - unsigned int flag_sets[] = {parse_fragment, parse_fragment | parse_cdata, parse_fragment | parse_cdata | parse_eol}; - - for (unsigned int i = 0; i < sizeof(flag_sets) / sizeof(flag_sets[0]); ++i) - { - unsigned int flags = flag_sets[i]; - - CHECK(doc.load_string(STR(""), flags).status == status_bad_cdata); - CHECK(doc.load_string(STR(""), flags).status == status_bad_cdata); - } -} - -TEST(parse_ws_pcdata_skip) -{ - xml_document doc; - CHECK(doc.load_string(STR(" "), parse_fragment)); - CHECK(!doc.first_child()); - - CHECK(doc.load_string(STR(" "), parse_minimal)); - - xml_node root = doc.child(STR("root")); - - CHECK(root.first_child() == root.last_child()); - CHECK(!root.first_child().first_child()); -} - -TEST(parse_ws_pcdata_parse) -{ - xml_document doc; - CHECK(doc.load_string(STR(" "), parse_minimal | parse_ws_pcdata)); - - xml_node root = doc.child(STR("root")); - - xml_node c1 = root.first_child(); - xml_node c2 = c1.next_sibling(); - xml_node c3 = c2.next_sibling(); - - CHECK(c3 == root.last_child()); - - CHECK(c1.type() == node_pcdata); - CHECK_STRING(c1.value(), STR(" ")); - CHECK(c3.type() == node_pcdata); - CHECK_STRING(c3.value(), STR(" ")); - - CHECK(c2.first_child() == c2.last_child()); - CHECK(c2.first_child().type() == node_pcdata); - CHECK_STRING(c2.first_child().value(), STR(" ")); -} - -static int get_tree_node_count(xml_node n) -{ - int result = 1; - - for (xml_node c = n.first_child(); c; c = c.next_sibling()) - result += get_tree_node_count(c); - - return result; -} - -TEST(parse_ws_pcdata_permutations) -{ - struct test_data_t - { - unsigned int mask; // 1 = default flags, 2 = parse_ws_pcdata, 4 = parse_ws_pcdata_single - const char_t* source; - const char_t* result; - int nodes; // negative if parsing should fail - }; - - test_data_t test_data[] = - { - // external pcdata should be discarded (whitespace or not) - {7, STR("ext1"), STR(""), 2}, - {7, STR("ext1ext2"), STR(""), 2}, - {7, STR(" "), STR(""), 2}, - {7, STR(" "), STR(""), 2}, - {7, STR(" "), STR(""), 2}, - // inner pcdata should be preserved - {7, STR("inner"), STR("inner"), 3}, - {7, STR("inner1inner2"), STR("inner1inner2"), 5}, - {7, STR("inner1deepinner2"), STR("inner1deepinner2"), 6}, - // empty pcdata nodes should never be created - {7, STR("inner1inner2"), STR("inner1inner2"), 5}, - {7, STR("inner2"), STR("inner2"), 4}, - {7, STR("inner1"), STR("inner1"), 4}, - {7, STR(""), STR(""), 3}, - // comments, pi or other nodes should not cause pcdata creation either - {7, STR(""), STR(""), 4}, - // leading/trailing pcdata whitespace should be preserved (note: this will change if parse_ws_pcdata_trim is introduced) - {7, STR("\t \tinner1 deep \t\ninner2\n\t"), STR("\t \tinner1 deep \t\ninner2\n\t"), 6}, - // whitespace-only pcdata preservation depends on the parsing mode - {1, STR("\n\t \n\t \n\t\n\t"), STR(""), 5}, - {2, STR("\n\t \n\t \n\t\n\t"), STR("\n\t \n\t \n\t\n\t"), 13}, - {4, STR("\n\t \n\t \n\t\n\t"), STR(" "), 7}, - // current implementation of parse_ws_pcdata_single has an unfortunate bug; reproduce it here - {4, STR("\t\t\n\n"), STR("\n\n"), 3}, - // error case: terminate PCDATA in the middle - {7, STR("abcdef"), STR("abcdef"), -3}, - {5, STR(" "), STR(""), -2}, - {2, STR(" "), STR(" "), -3}, - // error case: terminate PCDATA as early as possible - {7, STR(""), STR(""), -2}, - {7, STR("a"), STR("a"), -3}, - {5, STR(" "), STR(""), -2}, - {2, STR(" "), STR(" "), -3}, - }; - - for (size_t i = 0; i < sizeof(test_data) / sizeof(test_data[0]); ++i) - { - const test_data_t& td = test_data[i]; - - for (int flag = 0; flag < 3; ++flag) - { - if (td.mask & (1 << flag)) - { - unsigned int flags[] = {parse_default, parse_default | parse_ws_pcdata, parse_default | parse_ws_pcdata_single}; - - xml_document doc; - CHECK((td.nodes > 0) == doc.load_string(td.source, flags[flag])); - CHECK_NODE(doc, td.result); - - int nodes = get_tree_node_count(doc); - CHECK((td.nodes < 0 ? -td.nodes : td.nodes) == nodes); - } - } - } -} - -TEST(parse_ws_pcdata_fragment_permutations) -{ - struct test_data_t - { - unsigned int mask; // 1 = default flags, 2 = parse_ws_pcdata, 4 = parse_ws_pcdata_single - const char_t* source; - const char_t* result; - int nodes; // negative if parsing should fail - }; - - test_data_t test_data[] = - { - // external pcdata should be preserved - {7, STR("ext1"), STR("ext1"), 2}, - {5, STR(" "), STR(""), 1}, - {2, STR(" "), STR(" "), 2}, - {7, STR("ext1"), STR("ext1"), 3}, - {7, STR("ext2"), STR("ext2"), 3}, - {7, STR("ext1ext2"), STR("ext1ext2"), 4}, - {7, STR("ext1ext2ext3"), STR("ext1ext2ext3"), 6}, - {5, STR(" "), STR(""), 2}, - {2, STR(" "), STR(" "), 3}, - {5, STR(" "), STR(""), 2}, - {2, STR(" "), STR(" "), 3}, - {5, STR(" "), STR(""), 2}, - {2, STR(" "), STR(" "), 4}, - {5, STR(" "), STR(""), 3}, - {2, STR(" "), STR(" "), 6}, - }; - - for (size_t i = 0; i < sizeof(test_data) / sizeof(test_data[0]); ++i) - { - const test_data_t& td = test_data[i]; - - for (int flag = 0; flag < 3; ++flag) - { - if (td.mask & (1 << flag)) - { - unsigned int flags[] = {parse_default, parse_default | parse_ws_pcdata, parse_default | parse_ws_pcdata_single}; - - xml_document doc; - CHECK((td.nodes > 0) == doc.load_string(td.source, flags[flag] | parse_fragment)); - CHECK_NODE(doc, td.result); - - int nodes = get_tree_node_count(doc); - CHECK((td.nodes < 0 ? -td.nodes : td.nodes) == nodes); - } - } - } -} - -TEST(parse_pcdata_no_eol) -{ - xml_document doc; - CHECK(doc.load_string(STR("\r\rval1\rval2\r\nval3\nval4\r\r"), parse_minimal)); - - CHECK_STRING(doc.child_value(STR("root")), STR("\r\rval1\rval2\r\nval3\nval4\r\r")); -} - -TEST(parse_pcdata_eol) -{ - xml_document doc; - CHECK(doc.load_string(STR("\r\rval1\rval2\r\nval3\nval4\r\r"), parse_minimal | parse_eol)); - - CHECK_STRING(doc.child_value(STR("root")), STR("\n\nval1\nval2\nval3\nval4\n\n")); -} - -TEST(parse_pcdata_skip_ext) -{ - xml_document doc; - CHECK(doc.load_string(STR("prepost"), parse_minimal)); - CHECK(doc.first_child() == doc.last_child()); - CHECK(doc.first_child().type() == node_element); -} - -TEST(parse_pcdata_error) -{ - xml_document doc; - CHECK(doc.load_string(STR("pcdata"), parse_minimal).status == status_end_element_mismatch); -} - -TEST(parse_pcdata_trim) -{ - struct test_data_t - { - const char_t* source; - const char_t* result; - unsigned int flags; - }; - - test_data_t test_data[] = - { - { STR(" text"), STR("text"), 0 }, - { STR("\t\n text"), STR("text"), 0 }, - { STR("text "), STR("text"), 0 }, - { STR("text \t\n"), STR("text"), 0 }, - { STR("\r\n\t text \t\n\r"), STR("text"), 0 }, - { STR(" text"), STR("text"), parse_fragment }, - { STR("\t\n text"), STR("text"), parse_fragment }, - { STR("text "), STR("text"), parse_fragment }, - { STR("text \t\n"), STR("text"), parse_fragment }, - { STR("\r\n\t text \t\n\r"), STR("text"), parse_fragment }, - { STR("\r\n\t text \t\n\r more \r\n\t"), STR("text \t\n\r more"), 0 }, - { STR("\r\n\t text \t\n\r more \r\n\t"), STR("text \t\n\n more"), parse_eol }, - { STR("\r\n\t text \r\n\r\n\r\n\r\n\r\n\r\n\r\n more \r\n\t"), STR("text \n\n\n\n\n\n\n more"), parse_eol }, - { STR(" test&&&&&&& "), STR("test&&&&&&&"), 0 }, - { STR(" test&&&&&&& "), STR("test&&&&&&&"), parse_escapes }, - { STR(" test&&&&&&& "), STR("test&&&&&&&"), parse_fragment | parse_escapes }, - { STR("\r\n\t text \t\n\r m&&e \r\n\t"), STR("text \t\n\n m&&e"), parse_eol | parse_escapes } - }; - - for (size_t i = 0; i < sizeof(test_data) / sizeof(test_data[0]); ++i) - { - const test_data_t& td = test_data[i]; - - xml_document doc; - CHECK(doc.load_string(td.source, td.flags | parse_trim_pcdata)); - - const char_t* value = doc.child(STR("node")) ? doc.child_value(STR("node")) : doc.text().get(); - CHECK_STRING(value, td.result); - } -} - -TEST(parse_pcdata_trim_empty) -{ - unsigned int flags[] = { 0, parse_ws_pcdata, parse_ws_pcdata_single, parse_ws_pcdata | parse_ws_pcdata_single }; - - for (size_t i = 0; i < sizeof(flags) / sizeof(flags[0]); ++i) - { - xml_document doc; - CHECK(doc.load_string(STR(" "), flags[i] | parse_trim_pcdata)); - - xml_node node = doc.child(STR("node")); - CHECK(node); - CHECK(!node.first_child()); - } -} - -TEST(parse_escapes_skip) -{ - xml_document doc; - CHECK(doc.load_string(STR("<>&'""), parse_minimal)); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("<>&'"")); -} - -TEST(parse_escapes_parse) -{ - xml_document doc; - CHECK(doc.load_string(STR("<>&'""), parse_minimal | parse_escapes)); - CHECK_STRING(doc.child_value(STR("node")), STR("<>&'\"")); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("<>&'\"")); -} - -TEST(parse_escapes_code) -{ - xml_document doc; - CHECK(doc.load_string(STR(" "), parse_minimal | parse_escapes)); - CHECK_STRING(doc.child_value(STR("node")), STR("\01 ")); -} - -TEST(parse_escapes_code_exhaustive_dec) -{ - xml_document doc; - CHECK(doc.load_string(STR("&#/; &#:;&#a;&#A; "), parse_minimal | parse_escapes)); - CHECK_STRING(doc.child_value(STR("node")), STR("&#/;\x1\x2\x3\x4\x5\x6\x7\x8\x9&#:;&#a;&#A; ")); -} - -TEST(parse_escapes_code_exhaustive_hex) -{ - xml_document doc; - CHECK(doc.load_string(STR("&#x/; &#x:;&#x@; &#xG;&#x`; &#xg;"), parse_minimal | parse_escapes)); - CHECK_STRING(doc.child_value(STR("node")), STR("&#x/;\x1\x2\x3\x4\x5\x6\x7\x8\x9&#x:;&#x@;\xa\xb\xc\xd\xe\xf&#xG;&#x`;\xa\xb\xc\xd\xe\xf&#xg;")); -} - -TEST(parse_escapes_code_restore) -{ - xml_document doc; - CHECK(doc.load_string(STR("  - - "), parse_minimal | parse_escapes)); - CHECK_STRING(doc.child_value(STR("node")), STR("  - - ")); -} - -TEST(parse_escapes_char_restore) -{ - xml_document doc; - - CHECK(doc.load_string(STR("&q &qu &quo " "), parse_minimal | parse_escapes)); - CHECK_STRING(doc.child_value(STR("node")), STR("&q &qu &quo " ")); - - CHECK(doc.load_string(STR("&a &ap &apo &apos "), parse_minimal | parse_escapes)); - CHECK_STRING(doc.child_value(STR("node")), STR("&a &ap &apo &apos ")); - - CHECK(doc.load_string(STR("&a &am & "), parse_minimal | parse_escapes)); - CHECK_STRING(doc.child_value(STR("node")), STR("&a &am & ")); - - CHECK(doc.load_string(STR("&l < "), parse_minimal | parse_escapes)); - CHECK_STRING(doc.child_value(STR("node")), STR("&l < ")); - - CHECK(doc.load_string(STR("&g > "), parse_minimal | parse_escapes)); - CHECK_STRING(doc.child_value(STR("node")), STR("&g > ")); -} - -TEST(parse_escapes_unicode) -{ - xml_document doc; - CHECK(doc.load_string(STR("γγ𤭢"), parse_minimal | parse_escapes)); - -#ifdef PUGIXML_WCHAR_MODE - const char_t* v = doc.child_value(STR("node")); - - size_t wcharsize = sizeof(wchar_t); - - CHECK(v[0] == 0x3b3 && v[1] == 0x3b3 && (wcharsize == 2 ? v[2] == wchar_cast(0xd852) && v[3] == wchar_cast(0xdf62) : v[2] == wchar_cast(0x24b62))); -#else - CHECK_STRING(doc.child_value(STR("node")), "\xce\xb3\xce\xb3\xf0\xa4\xad\xa2"); -#endif -} - -TEST(parse_escapes_error) -{ - xml_document doc; - CHECK(doc.load_string(STR("g;&#ab;""), parse_minimal | parse_escapes)); - CHECK_STRING(doc.child_value(STR("node")), STR("g;&#ab;"")); - - CHECK(!doc.load_string(STR("&#;&#x;&;&#x-;&#-;"), parse_minimal | parse_escapes)); - CHECK_STRING(doc.child_value(STR("node")), STR("&#;&#x;&;&#x-;&#-;")); -} - -TEST(parse_escapes_attribute) -{ - xml_document doc; - - for (int wnorm = 0; wnorm < 2; ++wnorm) - for (int eol = 0; eol < 2; ++eol) - for (int wconv = 0; wconv < 2; ++wconv) - { - unsigned int flags = parse_escapes; - - flags |= (wnorm ? parse_wnorm_attribute : 0); - flags |= (eol ? parse_eol : 0); - flags |= (wconv ? parse_wconv_attribute : 0); - - CHECK(doc.load_string(STR(""), flags)); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("\"")); - } -} - -TEST(parse_attribute_spaces) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_minimal)); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id1")).value(), STR("v1")); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id2")).value(), STR("v2")); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id3")).value(), STR("v3")); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id4")).value(), STR("v4")); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id5")).value(), STR("v5")); -} - -TEST(parse_attribute_quot) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_minimal)); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id1")).value(), STR("v1")); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id2")).value(), STR("v2")); -} - -TEST(parse_attribute_no_eol_no_wconv) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_minimal)); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR(" \t\r\rval1 \rval2\r\nval3\nval4\r\r")); -} - -TEST(parse_attribute_eol_no_wconv) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_minimal | parse_eol)); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR(" \t\n\nval1 \nval2\nval3\nval4\n\n")); -} - -TEST(parse_attribute_no_eol_wconv) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_minimal | parse_wconv_attribute)); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR(" val1 val2 val3 val4 ")); -} - -TEST(parse_attribute_eol_wconv) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_minimal | parse_eol | parse_wconv_attribute)); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR(" val1 val2 val3 val4 ")); -} - -TEST(parse_attribute_wnorm) -{ - xml_document doc; - - for (int eol = 0; eol < 2; ++eol) - for (int wconv = 0; wconv < 2; ++wconv) - { - unsigned int flags = parse_minimal | parse_wnorm_attribute | (eol ? parse_eol : 0) | (wconv ? parse_wconv_attribute : 0); - CHECK(doc.load_string(STR(""), flags)); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("val1 val2 val3 val4")); - } -} - -TEST(parse_attribute_variations) -{ - xml_document doc; - - for (int wnorm = 0; wnorm < 2; ++wnorm) - for (int eol = 0; eol < 2; ++eol) - for (int wconv = 0; wconv < 2; ++wconv) - for (int escapes = 0; escapes < 2; ++escapes) - { - unsigned int flags = parse_minimal; - - flags |= (wnorm ? parse_wnorm_attribute : 0); - flags |= (eol ? parse_eol : 0); - flags |= (wconv ? parse_wconv_attribute : 0); - flags |= (escapes ? parse_escapes : 0); - - CHECK(doc.load_string(STR(""), flags)); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id")).value(), STR("1")); - } -} - - -TEST(parse_attribute_error) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_start_element); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_start_element); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_attribute); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_start_element); -} - -TEST(parse_attribute_termination_error) -{ - xml_document doc; - - for (int wnorm = 0; wnorm < 2; ++wnorm) - for (int eol = 0; eol < 2; ++eol) - for (int wconv = 0; wconv < 2; ++wconv) - { - unsigned int flags = parse_minimal; - - flags |= (wnorm ? parse_wnorm_attribute : 0); - flags |= (eol ? parse_eol : 0); - flags |= (wconv ? parse_wconv_attribute : 0); - - CHECK(doc.load_string(STR(""), flags)); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id1")).value(), STR("\"")); - CHECK_STRING(doc.child(STR("node")).attribute(STR("id2")).value(), STR("'")); - } -} - -TEST(parse_attribute_wnorm_coverage) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_wnorm_attribute)); - CHECK_NODE(doc, STR("")); - - CHECK(doc.load_string(STR(""), parse_wnorm_attribute | parse_escapes)); - CHECK_NODE(doc, STR("")); -} - -TEST(parse_attribute_wconv_coverage) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_wconv_attribute)); - CHECK_NODE(doc, STR("")); - - CHECK(doc.load_string(STR(""), parse_wconv_attribute | parse_escapes)); - CHECK_NODE(doc, STR("")); -} - -TEST(parse_attribute_eol_coverage) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_eol)); - CHECK_NODE(doc, STR("")); - - CHECK(doc.load_string(STR(""), parse_eol | parse_escapes)); - CHECK_NODE(doc, STR("")); -} - -TEST(parse_tag_single) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_minimal)); - CHECK_NODE(doc, STR("")); -} - -TEST(parse_tag_hierarchy) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_minimal)); - CHECK_NODE(doc, STR("")); -} - -TEST(parse_tag_error) -{ - xml_document doc; - CHECK(doc.load_string(STR("<"), parse_minimal).status == status_unrecognized_tag); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_start_element); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_start_element); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load_string(STR("<"), parse_minimal).status == status_unrecognized_tag); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_end_element_mismatch); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_end_element); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_start_element); - CHECK(doc.load_string(STR(""), parse_minimal).status == status_bad_start_element); -} - -TEST(parse_declaration_cases) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_fragment | parse_pi)); - CHECK(!doc.first_child()); -} - -TEST(parse_declaration_attr_cases) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_fragment | parse_pi)); - CHECK(!doc.first_child()); -} - -TEST(parse_declaration_skip) -{ - xml_document doc; - - unsigned int flag_sets[] = {parse_fragment, parse_fragment | parse_pi}; - - for (unsigned int i = 0; i < sizeof(flag_sets) / sizeof(flag_sets[0]); ++i) - { - unsigned int flags = flag_sets[i]; - - CHECK(doc.load_string(STR(""), flags)); - CHECK(!doc.first_child()); - - CHECK(doc.load_string(STR(" ?>"), flags)); - CHECK(!doc.first_child()); - } -} - -TEST(parse_declaration_parse) -{ - xml_document doc; - CHECK(doc.load_string(STR(""), parse_fragment | parse_declaration)); - - xml_node d1 = doc.first_child(); - xml_node d2 = doc.last_child(); - - CHECK(d1 != d2); - CHECK(d1.type() == node_declaration); - CHECK_STRING(d1.name(), STR("xml")); - CHECK(d2.type() == node_declaration); - CHECK_STRING(d2.name(), STR("xml")); - CHECK_STRING(d2.attribute(STR("version")).value(), STR("1.0")); -} - -TEST(parse_declaration_error) -{ - xml_document doc; - - unsigned int flag_sets[] = {parse_fragment, parse_fragment | parse_declaration}; - - for (unsigned int i = 0; i < sizeof(flag_sets) / sizeof(flag_sets[0]); ++i) - { - unsigned int flags = flag_sets[i]; - - CHECK(doc.load_string(STR(""), flags).status == status_bad_pi); - CHECK(doc.load_string(STR(""), flags).status == status_bad_pi); - } - - CHECK(doc.load_string(STR(""), parse_fragment | parse_declaration).status == status_bad_attribute); - CHECK(doc.load_string(STR(""), parse_fragment | parse_declaration).status == status_bad_pi); -} - -TEST(parse_empty) -{ - xml_document doc; - - CHECK(doc.load_string(STR("")).status == status_no_document_element && !doc.first_child()); - CHECK(doc.load_string(STR(""), parse_fragment) && !doc.first_child()); -} - -TEST(parse_out_of_memory) -{ - test_runner::_memory_fail_threshold = 256; - - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.load_string(STR("")).status == status_out_of_memory)); - CHECK(!doc.first_child()); -} - -TEST(parse_out_of_memory_halfway_node) -{ - const unsigned int count = 10000; - static char_t text[count * 4]; - - for (unsigned int i = 0; i < count; ++i) - { - text[4*i + 0] = '<'; - text[4*i + 1] = 'n'; - text[4*i + 2] = '/'; - text[4*i + 3] = '>'; - } - - test_runner::_memory_fail_threshold = 65536; - - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.load_buffer_inplace(text, sizeof(text)).status == status_out_of_memory)); - CHECK_NODE(doc.first_child(), STR("")); -} - -TEST(parse_out_of_memory_halfway_attr) -{ - const unsigned int count = 10000; - static char_t text[count * 5 + 4]; - - text[0] = '<'; - text[1] = 'n'; - - for (unsigned int i = 0; i < count; ++i) - { - text[5*i + 2] = ' '; - text[5*i + 3] = 'a'; - text[5*i + 4] = '='; - text[5*i + 5] = '"'; - text[5*i + 6] = '"'; - } - - text[5 * count + 2] = '/'; - text[5 * count + 3] = '>'; - - test_runner::_memory_fail_threshold = 65536; - - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.load_buffer_inplace(text, sizeof(text)).status == status_out_of_memory)); - CHECK_STRING(doc.first_child().name(), STR("n")); - CHECK_STRING(doc.first_child().first_attribute().name(), STR("a")); - CHECK_STRING(doc.first_child().last_attribute().name(), STR("a")); -} - -TEST(parse_out_of_memory_conversion) -{ - test_runner::_memory_fail_threshold = 1; - - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.load_buffer("", 7, parse_default, encoding_latin1).status == status_out_of_memory)); - CHECK(!doc.first_child()); -} - -TEST(parse_out_of_memory_allocator_state_sync) -{ - const unsigned int count = 10000; - static char_t text[count * 4]; - - for (unsigned int i = 0; i < count; ++i) - { - text[4*i + 0] = '<'; - text[4*i + 1] = 'n'; - text[4*i + 2] = '/'; - text[4*i + 3] = '>'; - } - - test_runner::_memory_fail_threshold = 65536; - - xml_document doc; - CHECK_ALLOC_FAIL(CHECK(doc.load_buffer_inplace(text, sizeof(text)).status == status_out_of_memory)); - CHECK_NODE(doc.first_child(), STR("")); - - test_runner::_memory_fail_threshold = 0; - - for (unsigned int j = 0; j < count; ++j) - CHECK(doc.append_child(STR("n"))); -} - -static bool test_offset(const char_t* contents, unsigned int options, xml_parse_status status, ptrdiff_t offset) -{ - xml_document doc; - xml_parse_result res = doc.load_string(contents, options); - - return res.status == status && res.offset == offset; -} - -#define CHECK_OFFSET(contents, options, status, offset) CHECK(test_offset(STR(contents), options, status, offset)) - -TEST(parse_error_offset) -{ - CHECK_OFFSET("", parse_default, status_ok, 0); - - test_runner::_memory_fail_threshold = 1; - CHECK_ALLOC_FAIL(CHECK_OFFSET("", parse_default, status_out_of_memory, 0)); - test_runner::_memory_fail_threshold = 0; - - CHECK_OFFSET("<3d/>", parse_default, status_unrecognized_tag, 1); - CHECK_OFFSET(" <3d/>", parse_default, status_unrecognized_tag, 2); - CHECK_OFFSET(" <", parse_default, status_unrecognized_tag, 1); - - CHECK_OFFSET("", parse_default, status_bad_start_element, 5); - - CHECK_OFFSET("", parse_default, status_bad_attribute, 8); - CHECK_OFFSET("valuevalue1value2outertext")); - CHECK_NODE_EX(doc, STR("\nvalue\n\nvalue1\nvalue2outer\ntext\n\n\n"), STR("\t"), 0); - CHECK_NODE_EX(doc, STR("\n\tvalue\n\t\n\t\tvalue1\n\t\tvalue2outer\n\ttext\n\t\n\n"), STR("\t"), format_indent); - } -} - -TEST_XML_FLAGS(parse_embed_pcdata_fragment, "text", parse_fragment | parse_embed_pcdata) -{ - CHECK_NODE(doc, STR("text")); - CHECK(doc.first_child().type() == node_pcdata); - CHECK_STRING(doc.first_child().value(), STR("text")); -} - -TEST_XML_FLAGS(parse_embed_pcdata_child, "text", parse_embed_pcdata) -{ - xml_node n = doc.child(STR("n")); - - CHECK_NODE(doc, STR("text")); - CHECK(n.last_child().type() == node_pcdata); - CHECK_STRING(n.last_child().value(), STR("text")); -} - -TEST_XML_FLAGS(parse_embed_pcdata_comment, "text1text2", parse_embed_pcdata) -{ - xml_node n = doc.child(STR("n")); - - CHECK_NODE(doc, STR("text1text2")); - CHECK_STRING(n.value(), STR("text1")); - CHECK(n.first_child() == n.last_child()); - CHECK(n.last_child().type() == node_pcdata); - CHECK_STRING(n.last_child().value(), STR("text2")); -} - -TEST(parse_encoding_detect) -{ - char test[] = ""; - - xml_document doc; - CHECK(doc.load_buffer(test, sizeof(test))); -} - -TEST(parse_encoding_detect_latin1) -{ - char test0[] = ""; - char test1[] = ""; - char test2[] = ""; - char test3[] = ""; - char test4[] = ""; - - xml_document doc; - CHECK(doc.load_buffer(test0, sizeof(test0)).encoding == encoding_utf8); - CHECK(doc.load_buffer(test1, sizeof(test1)).encoding == encoding_latin1); - CHECK(doc.load_buffer(test2, sizeof(test2)).encoding == encoding_latin1); - CHECK(doc.load_buffer(test3, sizeof(test3)).encoding == encoding_latin1); - CHECK(doc.load_buffer(test4, sizeof(test4)).encoding == encoding_latin1); -} - -TEST(parse_encoding_detect_auto) -{ - struct data_t - { - const char* contents; - size_t size; - xml_encoding encoding; - }; - - const data_t data[] = - { - // BOM - { "\x00\x00\xfe\xff", 4, encoding_utf32_be }, - { "\xff\xfe\x00\x00", 4, encoding_utf32_le }, - { "\xfe\xff ", 4, encoding_utf16_be }, - { "\xff\xfe ", 4, encoding_utf16_le }, - { "\xef\xbb\xbf ", 4, encoding_utf8 }, - // automatic tag detection for < or ", 16, encoding_utf32_be }, - { "<\x00\x00\x00n\x00\x00\x00/\x00\x00\x00>\x00\x00\x00", 16, encoding_utf32_le }, - { "\x00<\x00?\x00n\x00?\x00>", 10, encoding_utf16_be }, - { "<\x00?\x00n\x00?\x00>\x00", 10, encoding_utf16_le }, - { "\x00<\x00n\x00/\x00>", 8, encoding_utf16_be }, - { "<\x00n\x00/\x00>\x00", 8, encoding_utf16_le }, - // ", 25, encoding_latin1 }, - }; - - for (size_t i = 0; i < sizeof(data) / sizeof(data[0]); ++i) - { - xml_document doc; - xml_parse_result result = doc.load_buffer(data[i].contents, data[i].size, parse_fragment); - - CHECK(result); - CHECK(result.encoding == data[i].encoding); - } -} - -TEST(parse_encoding_detect_auto_incomplete) -{ - struct data_t - { - const char* contents; - size_t size; - xml_encoding encoding; - }; - - const data_t data[] = - { - // BOM - { "\x00\x00\xfe ", 4, encoding_utf8 }, - { "\x00\x00 ", 4, encoding_utf8 }, - { "\xff\xfe\x00 ", 4, encoding_utf16_le }, - { "\xfe ", 4, encoding_utf8 }, - { "\xff ", 4, encoding_utf8 }, - { "\xef\xbb ", 4, encoding_utf8 }, - { "\xef ", 4, encoding_utf8 }, - // automatic tag detection for < or \x00", 8, encoding_utf16_le }, - { "\x00", 8, encoding_utf16_be }, - { "<\x00?n/\x00>\x00", 8, encoding_utf16_le }, - { "\x00 ", 2, encoding_utf8 }, - // ", 25, encoding_utf8 }, - { "", 25, encoding_utf8 }, - { "", 25, encoding_utf8 }, - { "<_ABC encoding='latin1'/>", 25, encoding_utf8 }, - }; - - for (size_t i = 0; i < sizeof(data) / sizeof(data[0]); ++i) - { - xml_document doc; - xml_parse_result result = doc.load_buffer(data[i].contents, data[i].size, parse_fragment); - - CHECK(result); - CHECK(result.encoding == data[i].encoding); - } -} diff --git a/external/pugixml/tests/test_parse_doctype.cpp b/external/pugixml/tests/test_parse_doctype.cpp deleted file mode 100644 index 649170d0d..000000000 --- a/external/pugixml/tests/test_parse_doctype.cpp +++ /dev/null @@ -1,366 +0,0 @@ -#define _CRT_SECURE_NO_WARNINGS - -#include "test.hpp" - -#include -#include -#include - -using namespace pugi; - -static xml_parse_result load_concat(xml_document& doc, const char_t* a, const char_t* b = STR(""), const char_t* c = STR("")) -{ - char_t buffer[768]; - -#ifdef PUGIXML_WCHAR_MODE - wcscpy(buffer, a); - wcscat(buffer, b); - wcscat(buffer, c); -#else - strcpy(buffer, a); - strcat(buffer, b); - strcat(buffer, c); -#endif - - return doc.load_string(buffer, parse_fragment); -} - -static bool test_doctype_wf(const char_t* decl) -{ - xml_document doc; - - // standalone - if (!load_concat(doc, decl) || !doc.first_child().empty()) return false; - - // pcdata pre/postfix - if (!load_concat(doc, STR("a"), decl) || !test_node(doc, STR("a"), STR(""), format_raw)) return false; - if (!load_concat(doc, decl, STR("b")) || !test_node(doc, STR("b"), STR(""), format_raw)) return false; - if (!load_concat(doc, STR("a"), decl, STR("b")) || !test_node(doc, STR("ab"), STR(""), format_raw)) return false; - - // node pre/postfix - if (!load_concat(doc, STR(""), decl) || !test_node(doc, STR(""), STR(""), format_raw)) return false; - if (!load_concat(doc, decl, STR("")) || !test_node(doc, STR(""), STR(""), format_raw)) return false; - if (!load_concat(doc, STR(""), decl, STR("")) || !test_node(doc, STR(""), STR(""), format_raw)) return false; - - // check load-store contents preservation - CHECK(doc.load_string(decl, parse_doctype | parse_fragment)); - CHECK_NODE(doc, decl); - - return true; -} - -static bool test_doctype_nwf(const char_t* decl) -{ - xml_document doc; - - // standalone - if (load_concat(doc, decl).status != status_bad_doctype) return false; - - // pcdata postfix - if (load_concat(doc, decl, STR("b")).status != status_bad_doctype) return false; - - // node postfix - if (load_concat(doc, decl, STR("")).status != status_bad_doctype) return false; - - return true; -} - -#define TEST_DOCTYPE_WF(contents) CHECK(test_doctype_wf(STR(contents))) -#define TEST_DOCTYPE_NWF(contents) CHECK(test_doctype_nwf(STR(contents))) - -TEST(parse_doctype_skip) -{ - TEST_DOCTYPE_WF(""); - TEST_DOCTYPE_WF(""); - TEST_DOCTYPE_WF(""); - TEST_DOCTYPE_WF(""); - TEST_DOCTYPE_WF(""); - TEST_DOCTYPE_WF("]>"); -} - -TEST(parse_doctype_error) -{ - TEST_DOCTYPE_NWF(""); - TEST_DOCTYPE_NWF("]"); - TEST_DOCTYPE_NWF("] "); -} - -// Examples from W3C recommendations -TEST(parse_doctype_w3c_wf) -{ - TEST_DOCTYPE_WF(""); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]]> ]]>]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); -} - -TEST(parse_doctype_w3c_nwf) -{ - TEST_DOCTYPE_NWF(""); - TEST_DOCTYPE_NWF(" ]"); - TEST_DOCTYPE_NWF(""); - TEST_DOCTYPE_NWF(" ]"); - TEST_DOCTYPE_NWF(""); - TEST_DOCTYPE_NWF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" %e; ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(""); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" \"> ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" %pe; %intpe; ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF("]]> ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_NWF(" \"> \"> "); - TEST_DOCTYPE_WF(" ]>"); -} - -TEST(parse_doctype_xmlconf_eduni_2) -{ - TEST_DOCTYPE_WF("\"> %pe; ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); -} - -TEST(parse_doctype_xmlconf_eduni_3) -{ - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF("\"> ]>"); -} - -TEST(parse_doctype_xmlconf_eduni_4) -{ - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); -} - -TEST(parse_doctype_xmlconf_eduni_5) -{ - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); -} - -TEST(parse_doctype_xmlconf_ibm_1) -{ - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" %pe1; ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" \"> %pe3; ]>"); - TEST_DOCTYPE_WF(" '> %pe1; ]>"); -} - -TEST(parse_doctype_xmlconf_ibm_2) -{ - TEST_DOCTYPE_WF(" \"> ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_NWF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_NWF(" ]>"); - TEST_DOCTYPE_NWF(" ]>"); - TEST_DOCTYPE_NWF(" ]>"); - TEST_DOCTYPE_NWF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" &generalE; \"> %parameterE; ] animal>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_NWF(" \"> ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]]> ]>"); - TEST_DOCTYPE_WF(" ]]> ]>"); - TEST_DOCTYPE_NWF(" ]]> ]>"); - TEST_DOCTYPE_WF(" ]]> ]>"); - TEST_DOCTYPE_WF(" ]]> ]>"); - TEST_DOCTYPE_WF(" [INCLUDE ]]> ]>"); - TEST_DOCTYPE_NWF(" ]>"); - TEST_DOCTYPE_NWF(" ]>"); - TEST_DOCTYPE_WF(" %paaa; \"> ]>"); - TEST_DOCTYPE_WF(" \"> %paaa; ]>"); - TEST_DOCTYPE_NWF(" \" %paaa; ]>"); - TEST_DOCTYPE_WF(" ]>"); -} - -TEST(parse_doctype_xmlconf_ibm_3) -{ - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(""); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(""); - TEST_DOCTYPE_WF(""); - TEST_DOCTYPE_WF(""); - TEST_DOCTYPE_WF(""); - TEST_DOCTYPE_WF(""); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_NWF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_NWF(" ]>"); - TEST_DOCTYPE_WF(" IN PI ?> ]>"); - TEST_DOCTYPE_WF(" \"> \"> \"> %make_leopard_element; %make_small; \"> %make_big; %make_attlist; ]>"); - TEST_DOCTYPE_WF("\"> ]]> %rootElement; \"> %make_tiger_element; ]]> ]>"); - TEST_DOCTYPE_WF(" General entity reference in element content
\"> ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF("'. These must be balanced ]>"); - TEST_DOCTYPE_WF("'. These must be balanced ]]> ]]> ]>"); - TEST_DOCTYPE_WF("'. These must be balanced ]]> nesting ]]> nesting again ]]> end ]]> ]>"); - TEST_DOCTYPE_WF(" \"> %pe1; ]> ]>"); -} - -TEST(parse_doctype_xmlconf_oasis_1) -{ - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF("\"> ]]> %rootel; ]]> ]>"); - TEST_DOCTYPE_WF(" ]]>]]> ]>"); - TEST_DOCTYPE_WF(" ]]>]]> ]>"); - TEST_DOCTYPE_NWF(" ]>"); - TEST_DOCTYPE_WF(" ]]> ]>"); - TEST_DOCTYPE_NWF(" ]>"); - TEST_DOCTYPE_WF(" '. These must be balanced, but it is no section keyword is required: ] ]> ]] > ]]> ]]> ]>"); - TEST_DOCTYPE_WF(" ?>/\''\"> ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF("]>"); - - // not actually a doctype :) - xml_document doc; - CHECK(doc.load_string(STR(" "), parse_full | parse_fragment) && doc.first_child().type() == node_comment && doc.last_child().type() == node_comment && doc.first_child().next_sibling() == doc.last_child()); - CHECK(doc.load_string(STR(" &a%b&#c?>"), parse_full | parse_fragment) && doc.first_child().type() == node_pi && doc.first_child() == doc.last_child()); -} - -TEST(parse_doctype_xmlconf_xmltest_1) -{ - TEST_DOCTYPE_NWF(" ]> ]>"); - TEST_DOCTYPE_NWF(" "); - TEST_DOCTYPE_NWF(" "); - TEST_DOCTYPE_WF(" %e; -->"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF(" ]>"); - TEST_DOCTYPE_WF("\"> ]>"); - TEST_DOCTYPE_WF(" \"> ]>"); -} - -TEST_XML_FLAGS(parse_doctype_value, " \"> ]>", parse_fragment | parse_doctype) -{ - xml_node n = doc.first_child(); - - CHECK(n.type() == node_doctype); - CHECK_STRING(n.value(), STR("doc [ \"> ]")); -} - -TEST(parse_doctype_error_toplevel) -{ - xml_document doc; - CHECK(doc.load_string(STR("")).status == status_bad_doctype); - CHECK(doc.load_string(STR(""), parse_doctype).status == status_bad_doctype); -} - -TEST(parse_doctype_error_ignore) -{ - xml_document doc; - CHECK(doc.load_string(STR(" str; - - int count = 100000; - - str += STR(""); - - str += STR(">"); - - xml_document doc; - CHECK(doc.load_string(str.c_str(), parse_fragment)); -} - -TEST(parse_doctype_stackless_ignore) -{ - std::basic_string str; - - int count = 100000; - - str += STR(""); - - str += STR(">"); - - xml_document doc; - CHECK(doc.load_string(str.c_str(), parse_fragment)); -} diff --git a/external/pugixml/tests/test_unicode.cpp b/external/pugixml/tests/test_unicode.cpp deleted file mode 100644 index 4cb611427..000000000 --- a/external/pugixml/tests/test_unicode.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#ifndef PUGIXML_NO_STL - -#include "test.hpp" - -#include - -using namespace pugi; - -// letters taken from http://www.utf8-chartable.de/ - -TEST(as_wide_empty) -{ - CHECK(as_wide("") == L""); -} - -TEST(as_wide_valid_basic) -{ - // valid 1-byte, 2-byte and 3-byte inputs -#ifdef U_LITERALS - CHECK(as_wide("?\xd0\x80\xe2\x80\xbd") == L"?\u0400\u203D"); -#else - CHECK(as_wide("?\xd0\x80\xe2\x80\xbd") == L"?\x0400\x203D"); -#endif -} - -TEST(as_wide_valid_astral) -{ - // valid 4-byte input - std::basic_string b4 = as_wide("\xf2\x97\x98\xa4 \xf4\x80\x8f\xbf"); - - size_t wcharsize = sizeof(wchar_t); - - if (wcharsize == 4) - { - CHECK(b4.size() == 3 && b4[0] == wchar_cast(0x97624) && b4[1] == L' ' && b4[2] == wchar_cast(0x1003ff)); - } - else - { - CHECK(b4.size() == 5 && b4[0] == wchar_cast(0xda1d) && b4[1] == wchar_cast(0xde24) && b4[2] == L' ' && b4[3] == wchar_cast(0xdbc0) && b4[4] == wchar_cast(0xdfff)); - } -} - -TEST(as_wide_invalid) -{ - // invalid 1-byte input - CHECK(as_wide("a\xb0") == L"a"); - CHECK(as_wide("a\xb0_") == L"a_"); - - // invalid 2-byte input - CHECK(as_wide("a\xc0") == L"a"); - CHECK(as_wide("a\xd0") == L"a"); - CHECK(as_wide("a\xc0_") == L"a_"); - CHECK(as_wide("a\xd0_") == L"a_"); - - // invalid 3-byte input - CHECK(as_wide("a\xe2\x80") == L"a"); - CHECK(as_wide("a\xe2") == L"a"); - CHECK(as_wide("a\xe2\x80_") == L"a_"); - CHECK(as_wide("a\xe2_") == L"a_"); - - // invalid 4-byte input - CHECK(as_wide("a\xf2\x97\x98") == L"a"); - CHECK(as_wide("a\xf2\x97") == L"a"); - CHECK(as_wide("a\xf2") == L"a"); - CHECK(as_wide("a\xf2\x97\x98_") == L"a_"); - CHECK(as_wide("a\xf2\x97_") == L"a_"); - CHECK(as_wide("a\xf2_") == L"a_"); - - // invalid 5-byte input - std::basic_string b5 = as_wide("\xf8\nbcd"); - CHECK(b5 == L"\nbcd"); -} - -TEST(as_wide_string) -{ - std::string s = "abcd"; - - CHECK(as_wide(s) == L"abcd"); -} - -TEST(as_utf8_empty) -{ - CHECK(as_utf8(L"") == ""); -} - -TEST(as_utf8_valid_basic) -{ - // valid 1-byte, 2-byte and 3-byte outputs -#ifdef U_LITERALS - CHECK(as_utf8(L"?\u0400\u203D") == "?\xd0\x80\xe2\x80\xbd"); -#else - CHECK(as_utf8(L"?\x0400\x203D") == "?\xd0\x80\xe2\x80\xbd"); -#endif -} - -TEST(as_utf8_valid_astral) -{ - // valid 4-byte output - size_t wcharsize = sizeof(wchar_t); - - if (wcharsize == 4) - { - std::basic_string s; - s.resize(3); - s[0] = wchar_cast(0x97624); - s[1] = ' '; - s[2] = wchar_cast(0x1003ff); - - CHECK(as_utf8(s.c_str()) == "\xf2\x97\x98\xa4 \xf4\x80\x8f\xbf"); - } - else - { - #ifdef U_LITERALS - CHECK(as_utf8(L"\uda1d\ude24 \udbc0\udfff") == "\xf2\x97\x98\xa4 \xf4\x80\x8f\xbf"); - #else - CHECK(as_utf8(L"\xda1d\xde24 \xdbc0\xdfff") == "\xf2\x97\x98\xa4 \xf4\x80\x8f\xbf"); - #endif - } -} - -TEST(as_utf8_invalid) -{ - size_t wcharsize = sizeof(wchar_t); - - if (wcharsize == 2) - { - // check non-terminated degenerate handling - #ifdef U_LITERALS - CHECK(as_utf8(L"a\uda1d") == "a"); - CHECK(as_utf8(L"a\uda1d_") == "a_"); - #else - CHECK(as_utf8(L"a\xda1d") == "a"); - CHECK(as_utf8(L"a\xda1d_") == "a_"); - #endif - - // check incorrect leading code - #ifdef U_LITERALS - CHECK(as_utf8(L"a\ude24") == "a"); - CHECK(as_utf8(L"a\ude24_") == "a_"); - #else - CHECK(as_utf8(L"a\xde24") == "a"); - CHECK(as_utf8(L"a\xde24_") == "a_"); - #endif - } -} - -TEST(as_utf8_string) -{ - std::basic_string s = L"abcd"; - - CHECK(as_utf8(s) == "abcd"); -} -#endif diff --git a/external/pugixml/tests/test_version.cpp b/external/pugixml/tests/test_version.cpp deleted file mode 100644 index eeebd142f..000000000 --- a/external/pugixml/tests/test_version.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "../src/pugixml.hpp" - -#if PUGIXML_VERSION != 1100 -#error Unexpected pugixml version -#endif diff --git a/external/pugixml/tests/test_write.cpp b/external/pugixml/tests/test_write.cpp deleted file mode 100644 index 0410e82ef..000000000 --- a/external/pugixml/tests/test_write.cpp +++ /dev/null @@ -1,733 +0,0 @@ -#include "test.hpp" - -#include "writer_string.hpp" - -#include -#include -#include - -using namespace pugi; - -TEST_XML(write_simple, "text") -{ - CHECK_NODE_EX(doc, STR("\ntext\n\n"), STR(""), 0); -} - -TEST_XML(write_raw, "text") -{ - CHECK_NODE_EX(doc, STR("text"), STR(""), format_raw); -} - -TEST_XML(write_indent, "text") -{ - CHECK_NODE_EX(doc, STR("\n\t\n\t\ttext\n\t\n\n"), STR("\t"), format_indent); -} - -TEST_XML(write_indent_attributes, "text") -{ - CHECK_NODE_EX(doc, STR("\n\t\n\t\ttext\n\t\n
\n"), STR("\t"), format_indent_attributes); -} - -TEST_XML(write_indent_attributes_empty_element, "") -{ - CHECK_NODE_EX(doc, STR("\n"), STR("\t"), format_indent_attributes); -} - -TEST_XML_FLAGS(write_indent_attributes_declaration, "", parse_full) -{ - CHECK_NODE_EX(doc, STR("\n\n"), STR("\t"), format_indent_attributes); -} - -TEST_XML(write_indent_attributes_raw, "text") -{ - CHECK_NODE_EX(doc, STR("text"), STR("\t"), format_indent_attributes | format_raw); -} - -TEST_XML(write_indent_attributes_empty_indent, "text") -{ - CHECK_NODE_EX(doc, STR("\n\ntext\n\n\n"), STR(""), format_indent_attributes); -} - -TEST_XML(write_pcdata, "text") -{ - CHECK_NODE_EX(doc, STR("\n\t\n\t\ttext\n\n"), STR("\t"), format_indent); -} - -TEST_XML_FLAGS(write_cdata, "", parse_cdata | parse_fragment) -{ - CHECK_NODE(doc, STR("")); - CHECK_NODE_EX(doc, STR(""), STR(""), 0); -} - -TEST_XML_FLAGS(write_cdata_empty, "", parse_cdata | parse_fragment) -{ - CHECK_NODE(doc, STR("")); - CHECK_NODE_EX(doc, STR(""), STR(""), 0); -} - -TEST_XML_FLAGS(write_cdata_escape, "", parse_cdata | parse_fragment) -{ - CHECK_NODE(doc, STR("")); - - doc.first_child().set_value(STR("1]]>2]]>3")); - CHECK_NODE(doc, STR("2]]]]>3]]>")); - - doc.first_child().set_value(STR("1]")); - CHECK_NODE(doc, STR("")); - - doc.first_child().set_value(STR("1]]")); - CHECK_NODE(doc, STR("")); -} - -TEST_XML(write_cdata_inner, "") -{ - CHECK_NODE(doc, STR("")); - CHECK_NODE_EX(doc, STR("\n"), STR(""), 0); -} - -TEST(write_cdata_null) -{ - xml_document doc; - doc.append_child(node_cdata); - doc.append_child(STR("node")).append_child(node_cdata); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML_FLAGS(write_comment, "", parse_comments | parse_fragment) -{ - CHECK_NODE(doc, STR("")); - CHECK_NODE_EX(doc, STR("\n"), STR(""), 0); -} - -TEST(write_comment_invalid) -{ - xml_document doc; - xml_node child = doc.append_child(node_comment); - - CHECK_NODE(doc, STR("")); - - child.set_value(STR("-")); - CHECK_NODE(doc, STR("")); - - child.set_value(STR("--")); - CHECK_NODE(doc, STR("")); - - child.set_value(STR("---")); - CHECK_NODE(doc, STR("")); - - child.set_value(STR("-->")); - CHECK_NODE(doc, STR("")); - - child.set_value(STR("-->-")); - CHECK_NODE(doc, STR("")); -} - -TEST(write_comment_null) -{ - xml_document doc; - doc.append_child(node_comment); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML_FLAGS(write_pi, "", parse_pi | parse_fragment) -{ - CHECK_NODE(doc, STR("")); - CHECK_NODE_EX(doc, STR("\n"), STR(""), 0); -} - -TEST(write_pi_null) -{ - xml_document doc; - xml_node node = doc.append_child(node_pi); - - CHECK_NODE(doc, STR("")); - - node.set_value(STR("value")); - - CHECK_NODE(doc, STR("")); -} - -TEST(write_pi_invalid) -{ - xml_document doc; - xml_node node = doc.append_child(node_pi); - - node.set_name(STR("test")); - node.set_value(STR("?")); - - CHECK_NODE(doc, STR("")); - - node.set_value(STR("?>")); - - CHECK_NODE(doc, STR("?>")); - - node.set_value(STR("")); - - CHECK_NODE(doc, STR("?>")); -} - -TEST_XML_FLAGS(write_declaration, "", parse_declaration | parse_fragment) -{ - CHECK_NODE(doc, STR("")); - CHECK_NODE_EX(doc, STR("\n"), STR(""), 0); -} - -TEST_XML_FLAGS(write_doctype, "", parse_doctype | parse_fragment) -{ - CHECK_NODE(doc, STR("")); - CHECK_NODE_EX(doc, STR("\n"), STR(""), 0); -} - -TEST(write_doctype_null) -{ - xml_document doc; - doc.append_child(node_doctype); - - CHECK_NODE(doc, STR("")); -} - -TEST_XML(write_escape, "text") -{ - doc.child(STR("node")).attribute(STR("attr")) = STR("<>'\"&\x04\r\n\t"); - doc.child(STR("node")).first_child().set_value(STR("<>'\"&\x04\r\n\t")); - - CHECK_NODE(doc, STR("'"& \"><>'\"&\r\n\t")); - CHECK_NODE_EX(doc, STR("<>'\"&\r\n\t"), STR(""), format_raw | format_attribute_single_quote); -} - -TEST_XML(write_escape_roundtrip, "text") -{ - doc.child(STR("node")).attribute(STR("attr")) = STR("<>'\"&\x04\r\n\t"); - doc.child(STR("node")).first_child().set_value(STR("<>'\"&\x04\r\n\t")); - - std::string contents = write_narrow(doc, format_raw, encoding_utf8); - - CHECK(doc.load_buffer(contents.c_str(), contents.size())); - - // Note: this string is almost identical to the string from write_escape with the exception of \r - // \r in PCDATA doesn't roundtrip because it has to go through newline conversion (which could be disabled, but is active by default) - CHECK_NODE(doc, STR("'"& \"><>'\"&\n\t")); - CHECK_NODE_EX(doc, STR("<>'\"&\n\t"), STR(""), format_raw | format_attribute_single_quote); -} - -TEST_XML(write_escape_unicode, "") -{ -#ifdef PUGIXML_WCHAR_MODE - #ifdef U_LITERALS - CHECK_NODE(doc, STR("")); - #else - CHECK_NODE(doc, STR("")); - #endif -#else - CHECK_NODE(doc, STR("")); -#endif -} - -TEST_XML(write_no_escapes, "text") -{ - doc.child(STR("node")).attribute(STR("attr")) = STR("<>'\"&\x04\r\n\t"); - doc.child(STR("node")).first_child().set_value(STR("<>'\"&\x04\r\n\t")); - - CHECK_NODE_EX(doc, STR("'\"&\x04\r\n\t\"><>'\"&\x04\r\n\t"), STR(""), format_raw | format_no_escapes); -} - -struct test_writer: xml_writer -{ - std::basic_string contents; - - virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE - { - CHECK(size % sizeof(char_t) == 0); - contents.append(static_cast(data), size / sizeof(char_t)); - } -}; - -TEST_XML(write_print_writer, "") -{ - test_writer writer; - doc.print(writer, STR(""), format_default, get_native_encoding()); - - CHECK(writer.contents == STR("\n")); -} - -#ifndef PUGIXML_NO_STL -TEST_XML(write_print_stream, "") -{ - std::ostringstream oss; - doc.print(oss, STR(""), format_default, encoding_utf8); - - CHECK(oss.str() == "\n"); -} - -TEST_XML(write_print_stream_encode, "") -{ - std::ostringstream oss; - doc.print(oss, STR(""), format_default, encoding_utf16_be); - - CHECK(oss.str() == std::string("\x00<\x00n\x00 \x00/\x00>\x00\n", 12)); -} - -TEST_XML(write_print_stream_wide, "") -{ - std::basic_ostringstream oss; - doc.print(oss, STR(""), format_default, encoding_utf8); - - CHECK(oss.str() == L"\n"); -} -#endif - -TEST_XML(write_huge_chunk, "") -{ - std::basic_string name(10000, STR('n')); - doc.child(STR("node")).set_name(name.c_str()); - - test_writer writer; - doc.print(writer, STR(""), format_default, get_native_encoding()); - - CHECK(writer.contents == STR("<") + name + STR(" />\n")); -} - -TEST(write_encodings) -{ - static char s_utf8[] = "<\x54\xC2\xA2\xE2\x82\xAC\xF0\xA4\xAD\xA2/>"; - - xml_document doc; - CHECK(doc.load_buffer(s_utf8, sizeof(s_utf8), parse_default, encoding_utf8)); - - CHECK(write_narrow(doc, format_default, encoding_utf8) == "<\x54\xC2\xA2\xE2\x82\xAC\xF0\xA4\xAD\xA2 />\n"); - - CHECK(test_write_narrow(doc, format_default, encoding_utf32_le, "<\x00\x00\x00\x54\x00\x00\x00\xA2\x00\x00\x00\xAC\x20\x00\x00\x62\x4B\x02\x00 \x00\x00\x00/\x00\x00\x00>\x00\x00\x00\n\x00\x00\x00", 36)); - CHECK(test_write_narrow(doc, format_default, encoding_utf32_be, "\x00\x00\x00<\x00\x00\x00\x54\x00\x00\x00\xA2\x00\x00\x20\xAC\x00\x02\x4B\x62\x00\x00\x00 \x00\x00\x00/\x00\x00\x00>\x00\x00\x00\n", 36)); - CHECK(write_narrow(doc, format_default, encoding_utf32) == write_narrow(doc, format_default, is_little_endian() ? encoding_utf32_le : encoding_utf32_be)); - - CHECK(test_write_narrow(doc, format_default, encoding_utf16_le, "<\x00\x54\x00\xA2\x00\xAC\x20\x52\xd8\x62\xdf \x00/\x00>\x00\n\x00", 20)); - CHECK(test_write_narrow(doc, format_default, encoding_utf16_be, "\x00<\x00\x54\x00\xA2\x20\xAC\xd8\x52\xdf\x62\x00 \x00/\x00>\x00\n", 20)); - CHECK(write_narrow(doc, format_default, encoding_utf16) == write_narrow(doc, format_default, is_little_endian() ? encoding_utf16_le : encoding_utf16_be)); - - size_t wcharsize = sizeof(wchar_t); - std::basic_string v = write_wide(doc, format_default, encoding_wchar); - - if (wcharsize == 4) - { - CHECK(v.size() == 9 && v[0] == '<' && v[1] == 0x54 && v[2] == 0xA2 && v[3] == 0x20AC && v[4] == wchar_cast(0x24B62) && v[5] == ' ' && v[6] == '/' && v[7] == '>' && v[8] == '\n'); - } - else - { - CHECK(v.size() == 10 && v[0] == '<' && v[1] == 0x54 && v[2] == 0xA2 && v[3] == 0x20AC && v[4] == wchar_cast(0xd852) && v[5] == wchar_cast(0xdf62) && v[6] == ' ' && v[7] == '/' && v[8] == '>' && v[9] == '\n'); - } - - CHECK(test_write_narrow(doc, format_default, encoding_latin1, "<\x54\xA2?? />\n", 9)); -} - -#ifdef PUGIXML_WCHAR_MODE -TEST(write_encoding_huge) -{ - const unsigned int N = 16000; - - // make a large utf16 name consisting of 6-byte char pairs (6 does not divide internal buffer size, so will need split correction) - std::string s_utf16 = std::string("\x00<", 2); - - for (unsigned int i = 0; i < N; ++i) s_utf16 += "\x20\xAC\xd8\x52\xdf\x62"; - - s_utf16 += std::string("\x00/\x00>", 4); - - xml_document doc; - CHECK(doc.load_buffer(&s_utf16[0], s_utf16.length(), parse_default, encoding_utf16_be)); - - std::string s_utf8 = "<"; - - for (unsigned int j = 0; j < N; ++j) s_utf8 += "\xE2\x82\xAC\xF0\xA4\xAD\xA2"; - - s_utf8 += " />\n"; - - CHECK(test_write_narrow(doc, format_default, encoding_utf8, s_utf8.c_str(), s_utf8.length())); -} - -TEST(write_encoding_huge_invalid) -{ - size_t wcharsize = sizeof(wchar_t); - - if (wcharsize == 2) - { - const unsigned int N = 16000; - - // make a large utf16 name consisting of leading surrogate chars - std::basic_string s_utf16; - - for (unsigned int i = 0; i < N; ++i) s_utf16 += static_cast(0xd852); - - xml_document doc; - doc.append_child().set_name(s_utf16.c_str()); - - CHECK(test_write_narrow(doc, format_default, encoding_utf8, "< />\n", 5)); - } -} -#else -TEST(write_encoding_huge) -{ - const unsigned int N = 16000; - - // make a large utf8 name consisting of 3-byte chars (3 does not divide internal buffer size, so will need split correction) - std::string s_utf8 = "<"; - - for (unsigned int i = 0; i < N; ++i) s_utf8 += "\xE2\x82\xAC"; - - s_utf8 += "/>"; - - xml_document doc; - CHECK(doc.load_buffer(&s_utf8[0], s_utf8.length(), parse_default, encoding_utf8)); - - std::string s_utf16 = std::string("\x00<", 2); - - for (unsigned int j = 0; j < N; ++j) s_utf16 += "\x20\xAC"; - - s_utf16 += std::string("\x00 \x00/\x00>\x00\n", 8); - - CHECK(test_write_narrow(doc, format_default, encoding_utf16_be, s_utf16.c_str(), s_utf16.length())); -} - -TEST(write_encoding_huge_invalid) -{ - const unsigned int N = 16000; - - // make a large utf8 name consisting of non-leading chars - std::string s_utf8; - - for (unsigned int i = 0; i < N; ++i) s_utf8 += "\x82"; - - xml_document doc; - doc.append_child().set_name(s_utf8.c_str()); - - std::string s_utf16 = std::string("\x00<\x00 \x00/\x00>\x00\n", 10); - - CHECK(test_write_narrow(doc, format_default, encoding_utf16_be, s_utf16.c_str(), s_utf16.length())); -} -#endif - -TEST(write_unicode_escape) -{ - char s_utf8[] = "<\xE2\x82\xAC \xC2\xA2='\"\xF0\xA4\xAD\xA2 \"'>&\x14\xF0\xA4\xAD\xA2<"; - - xml_document doc; - CHECK(doc.load_buffer(s_utf8, sizeof(s_utf8), parse_default, encoding_utf8)); - - CHECK(write_narrow(doc, format_default, encoding_utf8) == "<\xE2\x82\xAC \xC2\xA2=\""\xF0\xA4\xAD\xA2 "\">&\xF0\xA4\xAD\xA2<\n"); -} - -#ifdef PUGIXML_WCHAR_MODE -static bool test_write_unicode_invalid(const wchar_t* name, const char* expected) -{ - xml_document doc; - doc.append_child(node_pcdata).set_value(name); - - return write_narrow(doc, format_raw, encoding_utf8) == expected; -} - -TEST(write_unicode_invalid_utf16) -{ - size_t wcharsize = sizeof(wchar_t); - - if (wcharsize == 2) - { - // check non-terminated degenerate handling - #ifdef U_LITERALS - CHECK(test_write_unicode_invalid(L"a\uda1d", "a")); - CHECK(test_write_unicode_invalid(L"a\uda1d_", "a_")); - #else - CHECK(test_write_unicode_invalid(L"a\xda1d", "a")); - CHECK(test_write_unicode_invalid(L"a\xda1d_", "a_")); - #endif - - // check incorrect leading code - #ifdef U_LITERALS - CHECK(test_write_unicode_invalid(L"a\ude24", "a")); - CHECK(test_write_unicode_invalid(L"a\ude24_", "a_")); - #else - CHECK(test_write_unicode_invalid(L"a\xde24", "a")); - CHECK(test_write_unicode_invalid(L"a\xde24_", "a_")); - #endif - } -} -#else -static bool test_write_unicode_invalid(const char* name, const wchar_t* expected) -{ - xml_document doc; - doc.append_child(node_pcdata).set_value(name); - - return write_wide(doc, format_raw, encoding_wchar) == expected; -} - -TEST(write_unicode_invalid_utf8) -{ - // invalid 1-byte input - CHECK(test_write_unicode_invalid("a\xb0", L"a")); - CHECK(test_write_unicode_invalid("a\xb0_", L"a_")); - - // invalid 2-byte input - CHECK(test_write_unicode_invalid("a\xc0", L"a")); - CHECK(test_write_unicode_invalid("a\xd0", L"a")); - CHECK(test_write_unicode_invalid("a\xc0_", L"a_")); - CHECK(test_write_unicode_invalid("a\xd0_", L"a_")); - - // invalid 3-byte input - CHECK(test_write_unicode_invalid("a\xe2\x80", L"a")); - CHECK(test_write_unicode_invalid("a\xe2", L"a")); - CHECK(test_write_unicode_invalid("a\xe2\x80_", L"a_")); - CHECK(test_write_unicode_invalid("a\xe2_", L"a_")); - - // invalid 4-byte input - CHECK(test_write_unicode_invalid("a\xf2\x97\x98", L"a")); - CHECK(test_write_unicode_invalid("a\xf2\x97", L"a")); - CHECK(test_write_unicode_invalid("a\xf2", L"a")); - CHECK(test_write_unicode_invalid("a\xf2\x97\x98_", L"a_")); - CHECK(test_write_unicode_invalid("a\xf2\x97_", L"a_")); - CHECK(test_write_unicode_invalid("a\xf2_", L"a_")); - - // invalid 5-byte input - CHECK(test_write_unicode_invalid("a\xf8_", L"a_")); -} -#endif - -TEST(write_no_name_element) -{ - xml_document doc; - xml_node root = doc.append_child(); - root.append_child(); - root.append_child().append_child(node_pcdata).set_value(STR("text")); - - CHECK_NODE(doc, STR("<:anonymous><:anonymous/><:anonymous>text")); - CHECK_NODE_EX(doc, STR("<:anonymous>\n\t<:anonymous />\n\t<:anonymous>text\n\n"), STR("\t"), format_default); -} - -TEST(write_no_name_pi) -{ - xml_document doc; - doc.append_child(node_pi); - - CHECK_NODE(doc, STR("")); -} - -TEST(write_no_name_attribute) -{ - xml_document doc; - doc.append_child().set_name(STR("root")); - doc.child(STR("root")).append_attribute(STR("")); - - CHECK_NODE(doc, STR("")); -} - -TEST(write_print_empty) -{ - test_writer writer; - xml_node().print(writer); -} - -#ifndef PUGIXML_NO_STL -TEST(write_print_stream_empty) -{ - std::ostringstream oss; - xml_node().print(oss); -} - -TEST(write_print_stream_empty_wide) -{ - std::basic_ostringstream oss; - xml_node().print(oss); -} -#endif - -TEST(write_stackless) -{ - unsigned int count = 20000; - std::basic_string data; - - for (unsigned int i = 0; i < count; ++i) - data += STR(""); - - data += STR("text"); - - for (unsigned int j = 0; j < count; ++j) - data += STR(""); - - xml_document doc; - CHECK(doc.load_string(data.c_str())); - - CHECK_NODE(doc, data.c_str()); -} - -TEST_XML(write_indent_custom, "text") -{ - CHECK_NODE_EX(doc, STR("\n\ntext\n\n\n"), STR(""), format_indent); - CHECK_NODE_EX(doc, STR("\nA\nAAtext\nA\n\n"), STR("A"), format_indent); - CHECK_NODE_EX(doc, STR("\nAB\nABABtext\nAB\n\n"), STR("AB"), format_indent); - CHECK_NODE_EX(doc, STR("\nABC\nABCABCtext\nABC\n\n"), STR("ABC"), format_indent); - CHECK_NODE_EX(doc, STR("\nABCD\nABCDABCDtext\nABCD\n\n"), STR("ABCD"), format_indent); - CHECK_NODE_EX(doc, STR("\nABCDE\nABCDEABCDEtext\nABCDE\n\n"), STR("ABCDE"), format_indent); -} - -TEST(write_pcdata_null) -{ - xml_document doc; - doc.append_child(STR("node")).append_child(node_pcdata); - - CHECK_NODE(doc, STR("")); - CHECK_NODE_EX(doc, STR("\n"), STR("\t"), format_indent); - - doc.first_child().append_child(node_pcdata); - - CHECK_NODE_EX(doc, STR("\n"), STR("\t"), format_indent); -} - -TEST(write_pcdata_whitespace_fixedpoint) -{ - const char_t* data = STR(" test \n \n \n"); - - static const unsigned int flags_parse[] = - { - 0, - parse_ws_pcdata, - parse_ws_pcdata_single, - parse_trim_pcdata - }; - - static const unsigned int flags_format[] = - { - 0, - format_raw, - format_indent - }; - - for (unsigned int i = 0; i < sizeof(flags_parse) / sizeof(flags_parse[0]); ++i) - { - xml_document doc; - CHECK(doc.load_string(data, flags_parse[i])); - - for (unsigned int j = 0; j < sizeof(flags_format) / sizeof(flags_format[0]); ++j) - { - std::string saved = write_narrow(doc, flags_format[j], encoding_auto); - - xml_document rdoc; - CHECK(rdoc.load_buffer(&saved[0], saved.size(), flags_parse[i])); - - std::string rsaved = write_narrow(rdoc, flags_format[j], encoding_auto); - - CHECK(saved == rsaved); - } - } -} - -TEST_XML_FLAGS(write_mixed, "premidpostfin", parse_full) -{ - CHECK_NODE(doc, STR("premidpostfin")); - CHECK_NODE_EX(doc, STR("\n\npremid\npostfin\n\n\n"), STR("\t"), 0); - CHECK_NODE_EX(doc, STR("\n\t\n\tpremid\n\t\tpostfin\n\t\n\n"), STR("\t"), format_indent); -} - -TEST_XML(write_no_empty_element_tags, "text") -{ - CHECK_NODE(doc, STR("text")); - CHECK_NODE_EX(doc, STR("text"), STR("\t"), format_raw | format_no_empty_element_tags); - CHECK_NODE_EX(doc, STR("\n\t\n\ttext\n\t\n\n"), STR("\t"), format_indent | format_no_empty_element_tags); -} - -TEST_XML_FLAGS(write_roundtrip, "premid<text&escapepostfin", parse_full) -{ - const unsigned int flagset[] = { format_indent, format_raw, format_no_declaration, format_indent_attributes, format_no_empty_element_tags, format_attribute_single_quote }; - size_t flagcount = sizeof(flagset) / sizeof(flagset[0]); - - for (size_t i = 0; i < (size_t(1) << flagcount); ++i) - { - unsigned int flags = 0; - - for (size_t j = 0; j < flagcount; ++j) - if (i & (size_t(1) << j)) - flags |= flagset[j]; - - std::string contents = write_narrow(doc, flags, encoding_utf8); - - xml_document verify; - CHECK(verify.load_buffer(contents.c_str(), contents.size(), parse_full)); - CHECK(test_write_narrow(verify, flags, encoding_utf8, contents.c_str(), contents.size())); - - xml_document verifyws; - CHECK(verifyws.load_buffer(contents.c_str(), contents.size(), parse_full | parse_ws_pcdata)); - CHECK(test_write_narrow(verifyws, flags, encoding_utf8, contents.c_str(), contents.size())); - } -} - -TEST(write_flush_coverage) -{ - xml_document doc; - - // this creates a node that uses short sequences of lengths 1-6 for output - xml_node n = doc.append_child(STR("n")); - - xml_attribute a = n.append_attribute(STR("a")); - - xml_attribute b = n.append_attribute(STR("b")); - b.set_value(STR("<&\"")); - - n.append_child(node_comment); - - size_t basel = save_narrow(doc, format_raw, encoding_auto).size(); - size_t bufl = 2048; - - for (size_t l = 0; l <= basel; ++l) - { - std::basic_string pad(bufl - l, STR('v')); - a.set_value(pad.c_str()); - - std::string s = save_narrow(doc, format_raw, encoding_auto); - CHECK(s.size() == basel + bufl - l); - } -} - -#ifndef PUGIXML_NO_EXCEPTIONS -struct throwing_writer: xml_writer -{ - virtual void write(const void*, size_t) PUGIXML_OVERRIDE - { - throw std::runtime_error("write failed"); - } -}; - -TEST_XML(write_throw_simple, "") -{ - try - { - throwing_writer w; - doc.print(w); - - CHECK_FORCE_FAIL("Expected exception"); - } - catch (std::runtime_error&) - { - } -} - -TEST_XML(write_throw_encoding, "") -{ - try - { - throwing_writer w; - doc.print(w, STR("\t"), format_default, encoding_utf32_be); - - CHECK_FORCE_FAIL("Expected exception"); - } - catch (std::runtime_error&) - { - } -} -#endif - -TEST_XML(write_skip_control_chars, "\f\t\n\x0F\x19") -{ - CHECK_NODE_EX(doc.first_child(), STR("\t\n\n"), STR(""), pugi::format_default | pugi::format_skip_control_chars); -} - -TEST_XML(write_keep_control_chars, "\f\t\n\x0F\x19") -{ - CHECK_NODE_EX(doc.first_child(), STR(" \t\n\n"), STR(""), pugi::format_default); -} diff --git a/external/pugixml/tests/test_xpath.cpp b/external/pugixml/tests/test_xpath.cpp deleted file mode 100644 index b057c57c0..000000000 --- a/external/pugixml/tests/test_xpath.cpp +++ /dev/null @@ -1,807 +0,0 @@ -#ifndef PUGIXML_NO_XPATH - -#include "test.hpp" - -#include -#include - -#include -#include -#include -#include - -// std::random_shuffle is deprecated in c++14, is removed in c++17. -#if defined(__cplusplus) && (__cplusplus >= 201402L) -# include -# define PUGIXML_SHUFFLE(rng) std::shuffle(rng.begin(), rng.end(), std::default_random_engine{std::random_device{}()}) -#else -# define PUGIXML_SHUFFLE(rng) std::random_shuffle(rng.begin(), rng.end()) -#endif - -using namespace pugi; - -static void load_document_copy(xml_document& doc, const char_t* text) -{ - xml_document source; - CHECK(source.load_string(text)); - - doc.append_copy(source.first_child()); -} - -TEST(xpath_allocator_many_pages) -{ - std::basic_string query = STR("0"); - - for (int i = 0; i < 128; ++i) query += STR("+string-length('abcdefgh')"); - - CHECK_XPATH_NUMBER(xml_node(), query.c_str(), 1024); -} - -TEST(xpath_allocator_large_page) -{ - std::basic_string query; - - for (int i = 0; i < 1024; ++i) query += STR("abcdefgh"); - - CHECK_XPATH_NUMBER(xml_node(), (STR("string-length('") + query + STR("')")).c_str(), 8192); -} - -TEST_XML(xpath_sort_complex, "test") -{ - // just some random union order, it should not matter probably? - xpath_node_set ns = doc.child(STR("node")).select_nodes(STR("child1 | child2 | child1/@* | . | child2/@* | child2/text()")); - - ns.sort(false); - xpath_node_set sorted = ns; - - ns.sort(true); - xpath_node_set reverse_sorted = ns; - - xpath_node_set_tester(sorted, "sorted order failed") % 2 % 3 % 4 % 5 % 6 % 7 % 8; - xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 8 % 7 % 6 % 5 % 4 % 3 % 2; -} - -TEST(xpath_sort_complex_copy) // copy the document so that document order optimization does not work -{ - xml_document doc; - load_document_copy(doc, STR("test")); - - // just some random union order, it should not matter probably? - xpath_node_set ns = doc.child(STR("node")).select_nodes(STR("child1 | child2 | child1/@* | . | child2/@* | child2/text()")); - - ns.sort(false); - xpath_node_set sorted = ns; - - ns.sort(true); - xpath_node_set reverse_sorted = ns; - - xpath_node_set_tester(sorted, "sorted order failed") % 2 % 3 % 4 % 5 % 6 % 7 % 8; - xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 8 % 7 % 6 % 5 % 4 % 3 % 2; -} - -TEST_XML(xpath_sort_children, "") -{ - xpath_node_set ns = doc.child(STR("node")).select_nodes(STR("child/subchild[@id=1] | child/subchild[@id=2]")); - - ns.sort(false); - xpath_node_set sorted = ns; - - ns.sort(true); - xpath_node_set reverse_sorted = ns; - - xpath_node_set_tester(sorted, "sorted order failed") % 4 % 7; - xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 7 % 4; -} - -TEST(xpath_sort_children_copy) // copy the document so that document order optimization does not work -{ - xml_document doc; - load_document_copy(doc, STR("")); - - xpath_node_set ns = doc.child(STR("node")).select_nodes(STR("child/subchild[@id=1] | child/subchild[@id=2]")); - - ns.sort(false); - xpath_node_set sorted = ns; - - ns.sort(true); - xpath_node_set reverse_sorted = ns; - - xpath_node_set_tester(sorted, "sorted order failed") % 4 % 7; - xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 7 % 4; -} - -TEST_XML(xpath_sort_attributes, "") -{ - xml_node n = doc.child(STR("node")); - - // we need to insert attributes manually since unsorted node sets are (always?) sorted via pointers because of remove_duplicates, - // so we need to have different document and pointer order to cover all comparator cases - n.append_attribute(STR("attr2")); - n.append_attribute(STR("attr3")); - n.insert_attribute_before(STR("attr1"), n.attribute(STR("attr2"))); - - xpath_node_set ns = n.select_nodes(STR("@* | @*")); - - ns.sort(true); - xpath_node_set reverse_sorted = ns; - - ns.sort(false); - xpath_node_set sorted = ns; - - xpath_node_set_tester(sorted, "sorted order failed") % 3 % 4 % 5; - xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 5 % 4 % 3; -} - -TEST_XML(xpath_sort_attributes_docorder, "") -{ - xml_node n = doc.child(STR("node")); - - n.first_attribute().set_name(STR("attribute1")); - n.insert_attribute_after(STR("attr3"), n.attribute(STR("attr2"))); - - xpath_node_set ns = n.select_nodes(STR("@* | @*")); - - ns.sort(true); - xpath_node_set reverse_sorted = ns; - - ns.sort(false); - xpath_node_set sorted = ns; - - xpath_node_set_tester(sorted, "sorted order failed") % 3 % 4 % 5 % 6; - xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 6 % 5 % 4 % 3; -} - -TEST(xpath_sort_random_medium) -{ - xml_document doc; - load_document_copy(doc, STR("") - STR("testtest") - STR("testtest") - STR("testtest") - STR("")); - - xpath_node_set ns = doc.select_nodes(STR("//node() | //@*")); - - std::vector nsv(ns.begin(), ns.end()); - PUGIXML_SHUFFLE(nsv); - - xpath_node_set copy(&nsv[0], &nsv[0] + nsv.size()); - copy.sort(); - - xpath_node_set_tester tester(copy, "sorted order failed"); - - for (unsigned int i = 2; i < 39; ++i) tester % i; -} - -TEST(xpath_sort_random_large) -{ - xml_document doc; - load_document_copy(doc, STR("") - STR("testtest") - STR("testtest") - STR("testtest") - STR("testtest") - STR("testtest") - STR("testtest") - STR("testtest") - STR("testtest") - STR("testtest") - STR("testtest") - STR("test")); - - xpath_node_set ns = doc.select_nodes(STR("//node() | //@*")); - - std::vector nsv(ns.begin(), ns.end()); - PUGIXML_SHUFFLE(nsv); - - xpath_node_set copy(&nsv[0], &nsv[0] + nsv.size()); - copy.sort(); - - xpath_node_set_tester tester(copy, "sorted order failed"); - - for (unsigned int i = 2; i < 129; ++i) tester % i; -} - -TEST(xpath_long_numbers_parse) -{ - const char_t* str_flt_max = STR("340282346638528860000000000000000000000"); - const char_t* str_flt_max_dec = STR("340282346638528860000000000000000000000.000000"); - - const char_t* str_dbl_max = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); - const char_t* str_dbl_max_dec = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000"); - - xml_node c; - - // check parsing - CHECK_XPATH_NUMBER(c, str_flt_max, double(std::numeric_limits::max())); - CHECK_XPATH_NUMBER(c, str_flt_max_dec, double(std::numeric_limits::max())); - CHECK_XPATH_NUMBER(c, str_dbl_max, std::numeric_limits::max()); - CHECK_XPATH_NUMBER(c, str_dbl_max_dec, std::numeric_limits::max()); -} - -static bool test_xpath_string_prefix(const xml_node& node, const char_t* query, const char_t* expected, size_t match_length) -{ - xpath_query q(query); - - char_t result[32]; - size_t size = q.evaluate_string(result, sizeof(result) / sizeof(result[0]), node); - - size_t expected_length = std::char_traits::length(expected); - - return size == expected_length + 1 && std::char_traits::compare(result, expected, match_length) == 0; -} - -TEST(xpath_long_numbers_stringize) -{ - const char_t* str_flt_max = STR("340282346638528860000000000000000000000"); - const char_t* str_flt_max_dec = STR("340282346638528860000000000000000000000.000000"); - - const char_t* str_dbl_max = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); - const char_t* str_dbl_max_dec = STR("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000"); - - xml_node c; - - CHECK(test_xpath_string_prefix(c, str_flt_max, str_flt_max, 15)); - CHECK(test_xpath_string_prefix(c, str_flt_max_dec, str_flt_max, 15)); - - CHECK(test_xpath_string_prefix(c, str_dbl_max, str_dbl_max, 15)); - CHECK(test_xpath_string_prefix(c, str_dbl_max_dec, str_dbl_max, 15)); -} - -TEST(xpath_denorm_numbers) -{ - std::basic_string query; - - // 10^-318 - double denormal - for (int i = 0; i < 106; ++i) - { - if (i != 0) query += STR(" * "); - query += STR("0.001"); - } - - // check if current fpu setup supports denormals - double denorm = xpath_query(query.c_str()).evaluate_number(xml_node()); - - if (denorm != 0.0) - { - CHECK_XPATH_STRING(xml_node(), query.c_str(), STR("0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009999987484955998")); - } -} - -TEST_XML(xpath_rexml_1, "") -{ - CHECK_XPATH_NODESET(doc, STR("//*[local-name()='c' and @id='b']")) % 6; - CHECK_XPATH_NODESET(doc, STR("//*[ local-name()='c' and @id='b' ]")) % 6; - CHECK_XPATH_NODESET(doc, STR("/a/c[@id]")) % 6; - CHECK_XPATH_NODESET(doc, STR("/a/c[(@id)]")) % 6; - CHECK_XPATH_NODESET(doc, STR("/a/c[ @id ]")) % 6; - CHECK_XPATH_NODESET(doc, STR("/a/c[ (@id) ]")) % 6; - CHECK_XPATH_NODESET(doc, STR("/a/c[( @id )]")) % 6; - CHECK_XPATH_NODESET(doc, STR("/a/c[ ( @id ) ]")) % 6; - CHECK_XPATH_NODESET(doc, STR("/a/c [ ( @id ) ] ")) % 6; - CHECK_XPATH_NODESET(doc, STR(" / a / c [ ( @id ) ] ")) % 6; -} - -TEST_XML(xpath_rexml_2, "zzz") -{ - CHECK_XPATH_NODESET(doc, STR("a:x/a:y[@p='p' and @q='q']/a:z/text()")) % 8; -} - -TEST_XML(xpath_rexml_3, "
free flowing text.
free flowing text.
free flowing text.
") -{ - CHECK_XPATH_NODESET(doc, STR("//section[../self::section[@role=\"division\"]]")) % 10 % 15; - CHECK_XPATH_NODESET(doc, STR("//section[@role=\"subdivision\" and not(../self::section[@role=\"division\"])]")) % 3; - CHECK_XPATH_NODESET(doc, STR("//section[@role=\"subdivision\"][not(../self::section[@role=\"division\"])]")) % 3; -} - -TEST_XML_FLAGS(xpath_rexml_4, "TEXT1TEXT2", parse_default | parse_comments) -{ - CHECK_XPATH_NODESET(doc, STR("/descendant-or-self::node()[count(child::node()|following-sibling::node()|preceding-sibling::node())=0]")) % 6 % 17 % 20; -} - -TEST_XML(xpath_rexml_5, "") -{ - CHECK_XPATH_FAIL(STR(".//[@id]")); - CHECK_XPATH_NODESET(doc, STR(".//self::*[@id]")) % 4 % 6; - CHECK_XPATH_NODESET(doc, STR(".//node()[@id]")) % 4 % 6; -} - -TEST_XML(xpath_rexml_6, "
ab
") -{ - CHECK_XPATH_NODESET(doc, STR("//em|//strong")) % 4 % 6; - CHECK_XPATH_NODESET(doc, STR("//*[self::em | self::strong]")) % 4 % 6; - CHECK_XPATH_NODESET(doc, STR("//*[name()=\"em\" or name()=\"strong\"]")) % 4 % 6; - CHECK_XPATH_NODESET(doc, STR("//*[self::em or self::strong]")) % 4 % 6; -} - -TEST_XML(xpath_xsl_list_1, "whatevertextselectsomething") -{ - // if I'm not last, and the next input/type isn't select - CHECK_XPATH_NODESET(doc, STR("input[type[parent::input/following-sibling::input[1]/type != 'select']]")) % 2 % 8; - CHECK_XPATH_NODESET(doc, STR("input[type[../following-sibling::input[1]/type != 'select']]")) % 2 % 8; - - CHECK_XPATH_NODESET(doc, STR("input[position()+1]")); -} - -TEST_XML(xpath_xsl_list_2, "text1text2text3text4") -{ - CHECK_XPATH_FAIL(STR(".[not(.=ancestor::TR/TD[15]/node())]")); - - CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("1")).first_child(), STR("self::node()[not(.=ancestor::TR/TD[3]/node())]")) % 5; - CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("2")).first_child(), STR("self::node()[not(.=ancestor::TR/TD[3]/node())]")) % 8; - CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("3")).first_child(), STR("self::node()[not(.=ancestor::TR/TD[3]/node())]")); - CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("4")).first_child(), STR("self::node()[not(.=ancestor::TR/TD[3]/node())]")) % 14; - - CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("1")), STR("node()[not(.=ancestor::TR/TD[3]/node())]")) % 5; - CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("2")), STR("node()[not(.=ancestor::TR/TD[3]/node())]")) % 8; - CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("3")), STR("node()[not(.=ancestor::TR/TD[3]/node())]")); - CHECK_XPATH_NODESET(doc.child(STR("TR")).find_child_by_attribute(STR("TD"), STR("id"), STR("4")), STR("node()[not(.=ancestor::TR/TD[3]/node())]")) % 14; -} - -TEST_XML(xpath_star_token, "0.5
") -{ - CHECK_XPATH_NODESET(doc, STR("//*[/* * 4]")) % 6 % 9; - CHECK_XPATH_NODESET(doc, STR("//*[/**4]")) % 6 % 9; - CHECK_XPATH_FAIL(STR("//*[/***4]")); -} - -TEST(xpath_miscellaneous) -{ - CHECK_XPATH_FAIL(STR("/root/child[a=3]/substring(child::text())")); - CHECK_XPATH_NODESET(xml_node(), STR("foo/@FOO/@bar")); -} - -TEST_XML(xpath_context_node, "5") -{ - CHECK_XPATH_NODESET(doc, STR("node")) % 2; - CHECK_XPATH_BOOLEAN(doc, STR("node"), true); - CHECK_XPATH_NUMBER(doc, STR("node"), 5); - CHECK_XPATH_STRING(doc, STR("node"), STR("5")); -} - -TEST_XML(xpath_context_position, "5") -{ - CHECK_XPATH_NODESET(doc, STR("id(position() + last())")); - CHECK_XPATH_BOOLEAN(doc, STR("position() + last() = 2"), true); - CHECK_XPATH_NUMBER(doc, STR("position() + last()"), 2); - CHECK_XPATH_STRING(doc, STR("position() + last()"), STR("2")); -} - -TEST(xpath_lexer_unknown_lexeme) -{ - CHECK_XPATH_FAIL(STR("(^3))")); - CHECK_XPATH_FAIL(STR("(!3))")); -} - -TEST(xpath_large_node_set) -{ - xml_document doc; - CHECK(doc.load_file("tests/data/large.xml")); - - xpath_node_set ns = doc.select_nodes(STR("//*")); - - CHECK(ns.size() == 10001); -} - -TEST(xpath_out_of_memory_query) -{ - test_runner::_memory_fail_threshold = 1; - - CHECK_ALLOC_FAIL(xpath_query q(STR("node"))); -} - -TEST_XML(xpath_out_of_memory_evaluate, "") -{ - test_runner::_memory_fail_threshold = 4196 * sizeof(char_t) + 4096 * 2 + 32768; - - std::basic_string query = STR("*[concat(\"a\", \""); - - query.resize(4196, 'a'); - query += STR("\")]"); - - xpath_query q(query.c_str()); - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_boolean(doc) == false)); - CHECK_ALLOC_FAIL(CHECK_DOUBLE_NAN(q.evaluate_number(doc))); - -#ifndef PUGIXML_NO_STL - CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(doc).empty())); -#endif - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, doc) == 1)); - CHECK_ALLOC_FAIL(CHECK(q.evaluate_node(doc) == xpath_node())); - CHECK_ALLOC_FAIL(CHECK(q.evaluate_node_set(doc).empty())); -} - -TEST(xpath_out_of_memory_evaluate_concat) -{ - test_runner::_memory_fail_threshold = 4196 * sizeof(char_t) + 4096 * 2; - - std::basic_string query = STR("concat(\"a\", \""); - - query.resize(4196, 'a'); - query += STR("\")"); - - xpath_query q(query.c_str()); - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, xml_node()) == 1)); -} - -TEST(xpath_out_of_memory_evaluate_concat_list) -{ - std::basic_string query = STR("concat("); - - for (size_t i = 0; i < 500; ++i) - query += STR("\"\","); - - query += STR("\"\")"); - - xpath_query q(query.c_str()); - - test_runner::_memory_fail_threshold = 1; - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, xml_node()) == 1)); -} - -TEST(xpath_out_of_memory_evaluate_substring) -{ - test_runner::_memory_fail_threshold = 4196 * sizeof(char_t) + 4096 * 2; - - std::basic_string query = STR("substring(\""); - - query.resize(4196, 'a'); - query += STR("\", 1, 4097)"); - - xpath_query q(query.c_str()); - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, xml_node()) == 1)); -} - -TEST_XML(xpath_out_of_memory_evaluate_union, "") -{ - // left hand side: size * sizeof(xpath_node) (8 on 32-bit, 16 on 64-bit) - // right hand side: same - // to make sure that when we append right hand side to left hand side, we run out of an XPath stack page (4K), we need slightly more than 2K/8 = 256 nodes on 32-bit, 128 nodes on 64-bit - size_t count = sizeof(void*) == 4 ? 300 : 150; - - for (size_t i = 0; i < count; ++i) - doc.first_child().append_child(STR("a")); - - xpath_query q(STR("a|a")); - - test_runner::_memory_fail_threshold = 1; - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_node_set(doc.child(STR("node"))).empty())); -} - -TEST_XML(xpath_out_of_memory_evaluate_union_hash, "") -{ - // left hand side: size * sizeof(xpath_node) (8 on 32-bit, 16 on 64-bit) - // right hand side: same - // hash table: size * 1.5 * sizeof(void*) - // to make sure that when we append right hand side to left hand side, we do *not* run out of an XPath stack page (4K), we need slightly less than 2K/8 = 256 nodes on 32-bit, 128 nodes on 64-bit - size_t count = sizeof(void*) == 4 ? 200 : 100; - - for (size_t i = 0; i < count; ++i) - doc.first_child().append_child(STR("a")); - - xpath_query q(STR("a|a")); - - test_runner::_memory_fail_threshold = 1; - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_node_set(doc.child(STR("node"))).empty())); -} - - -TEST_XML(xpath_out_of_memory_evaluate_predicate, "") -{ - test_runner::_memory_fail_threshold = 32768 + 4096 * 2; - - xpath_query q(STR("//a[//a[//a[//a[true()]]]]")); - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_node_set(doc).empty())); -} - -TEST_XML(xpath_out_of_memory_evaluate_normalize_space_0, " a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z ") -{ - test_runner::_memory_fail_threshold = 32768 + 4096 * 2; - - xpath_query q(STR("concat(normalize-space(), normalize-space(), normalize-space(), normalize-space(), normalize-space(), normalize-space(), normalize-space(), normalize-space())")); - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, doc.first_child()) == 1)); -} - -TEST_XML(xpath_out_of_memory_evaluate_normalize_space_1, " a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z ") -{ - test_runner::_memory_fail_threshold = 32768 + 4096 * 2; - - xpath_query q(STR("concat(normalize-space(node), normalize-space(node), normalize-space(node), normalize-space(node), normalize-space(node), normalize-space(node), normalize-space(node), normalize-space(node))")); - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, doc) == 1)); -} - -TEST_XML(xpath_out_of_memory_evaluate_translate, " a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z ") -{ - test_runner::_memory_fail_threshold = 32768 + 4096 * 2; - - xpath_query q(STR("concat(translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'), translate(node, 'a', '\xe9'))")); - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, doc) == 1)); -} - -TEST_XML(xpath_out_of_memory_evaluate_translate_table, " a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z a b c d e f g h i j k l m n o p q r s t u v w x y z ") -{ - test_runner::_memory_fail_threshold = 32768 + 4096 * 2; - - xpath_query q(STR("concat(translate(node, 'a', 'A'), translate(node, 'a', 'A'), translate(node, 'a', 'A'), translate(node, 'a', 'A'), translate(node, 'a', 'A'), translate(node, 'a', 'A'), translate(node, 'a', 'A'), translate(node, 'a', 'A'))")); - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, doc) == 1)); -} - -TEST(xpath_out_of_memory_evaluate_string_append) -{ - test_runner::_memory_fail_threshold = 32768 + 4096 * 2; - - std::basic_string literal(5000, 'a'); - - std::basic_string buf; - buf += STR("text"); - buf += literal; - buf += STR(""); - - xml_document doc; - CHECK(doc.load_buffer_inplace(&buf[0], buf.size() * sizeof(char_t))); - - xpath_query q(STR("string(n)")); - CHECK(q); - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, doc) == 1)); -} - -TEST(xpath_out_of_memory_evaluate_number_to_string) -{ - test_runner::_memory_fail_threshold = 4096 + 128; - - xpath_variable_set vars; - vars.set(STR("x"), 1e+308); - - xpath_query q(STR("concat($x, $x, $x, $x, $x, $x, $x, $x, $x, $x, $x, $x, $x, $x, $x, $x, $x)"), &vars); - - CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, xml_node()) == 1)); -} - -TEST(xpath_memory_concat_massive) -{ - xml_document doc; - xml_node node = doc.append_child(STR("node")); - - for (int i = 0; i < 5000; ++i) - node.append_child(STR("c")).text().set(i % 10); - - xpath_query q(STR("/")); - size_t size = q.evaluate_string(0, 0, node); - - CHECK(size == 5001); -} - -TEST_XML(xpath_memory_translate_table, "a") -{ - test_runner::_memory_fail_threshold = 32768 + 4096 + 128; - - // 128b per table => we need 32+ translate calls to exhaust a page - std::basic_string query = STR("concat("); - for (int i = 0; i < 64; ++i) - query += STR("translate(.,'a','A'),"); - query += STR("'')"); - - CHECK_ALLOC_FAIL(CHECK(!xpath_query(query.c_str()))); -} - -TEST_XML(xpath_sort_copy_share, "test") -{ - // copy sharing shares the name/value data for nodes that can potentially make document order optimization invalid (silently) - xml_node node = doc.child(STR("node")); - xml_node child1 = node.child(STR("child1")); - xml_node child2 = node.child(STR("child2")); - - // swap child1 & child2 - node.prepend_copy(child2); - node.append_copy(child1); - - node.remove_child(child1); - node.remove_child(child2); - - // just some random union order, it should not matter probably? - xpath_node_set ns = doc.child(STR("node")).select_nodes(STR("child1 | child2 | child1/@* | . | child2/@* | child2/text()")); - - ns.sort(false); - xpath_node_set sorted = ns; - - ns.sort(true); - xpath_node_set reverse_sorted = ns; - - xpath_node_set_tester(sorted, "sorted order failed") % 2 % 3 % 4 % 5 % 6 % 7 % 8; - xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 8 % 7 % 6 % 5 % 4 % 3 % 2; -} - -TEST_XML(xpath_sort_move_share, "test") -{ - // moving changes the relation between name/value data and document order, this can potentially make document order optimization invalid (silently) - xml_node node = doc.child(STR("node")); - xml_node child1 = node.child(STR("child1")); - xml_node child2 = node.child(STR("child2")); - - // swap child1 & child2 - node.prepend_move(child2); - node.append_move(child1); - - // just some random union order, it should not matter probably? - xpath_node_set ns = doc.child(STR("node")).select_nodes(STR("child1 | child2 | child1/@* | . | child2/@* | child2/text()")); - - ns.sort(false); - xpath_node_set sorted = ns; - - ns.sort(true); - xpath_node_set reverse_sorted = ns; - - xpath_node_set_tester(sorted, "sorted order failed") % 2 % 3 % 4 % 5 % 6 % 7 % 8; - xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 8 % 7 % 6 % 5 % 4 % 3 % 2; -} - -TEST_XML(xpath_sort_append_buffer, "") -{ - // append_buffer changes the relation between name/value data and document order, this can potentially make document order optimization invalid (silently) - const char* child1 = ""; - const char* child2 = "test "; - - doc.last_child().append_buffer(child2, strlen(child2)); - doc.first_child().append_buffer(child1, strlen(child1)); - - // just some random union order, it should not matter probably? - xpath_node_set ns = doc.select_nodes(STR("node/child1 | node/child2 | node/child1/@* | node/. | node/child2/@* | node/child2/text()")); - - ns.sort(false); - xpath_node_set sorted = ns; - - ns.sort(true); - xpath_node_set reverse_sorted = ns; - - xpath_node_set_tester(sorted, "sorted order failed") % 2 % 3 % 4 % 5 % 6 % 7 % 8 % 9; - xpath_node_set_tester(reverse_sorted, "reverse sorted order failed") % 9 % 8 % 7 % 6 % 5 % 4 % 3 % 2; -} - -TEST(xpath_sort_crossdoc) -{ - xml_document doc1; - CHECK(doc1.load_string(STR(""))); - - xml_document doc2; - CHECK(doc2.load_string(STR(""))); - - xpath_node_set ns1 = doc1.select_nodes(STR("*")); - CHECK(ns1.size() == 1); - - xpath_node_set ns2 = doc2.select_nodes(STR("*")); - CHECK(ns2.size() == 1); - - xpath_variable_set set; - set.set(STR("ns1"), ns1); - set.set(STR("ns2"), ns2); - - xpath_node_set ns = xpath_query(STR("$ns1 | $ns2"), &set).evaluate_node_set(xpath_node()); - - ns.sort(); - - CHECK(ns.size() == 2); - CHECK((ns[0] == ns1[0] && ns[1] == ns2[0]) || (ns[0] == ns2[0] && ns[1] == ns1[0])); -} - -TEST(xpath_sort_crossdoc_dynamic) -{ - xml_document doc1; - doc1.append_child(STR("node")); - - xml_document doc2; - doc2.append_child(STR("node")); - - xpath_node_set ns1 = doc1.select_nodes(STR("*")); - CHECK(ns1.size() == 1); - - xpath_node_set ns2 = doc2.select_nodes(STR("*")); - CHECK(ns2.size() == 1); - - xpath_variable_set set; - set.set(STR("ns1"), ns1); - set.set(STR("ns2"), ns2); - - xpath_node_set ns = xpath_query(STR("$ns1 | $ns2"), &set).evaluate_node_set(xpath_node()); - - ns.sort(); - - CHECK(ns.size() == 2); - CHECK((ns[0] == ns1[0] && ns[1] == ns2[0]) || (ns[0] == ns2[0] && ns[1] == ns1[0])); -} - -TEST(xpath_sort_crossdoc_different_depth) -{ - xml_document doc1; - doc1.append_child(STR("node")); - - xml_document doc2; - doc2.append_child(STR("node")).append_child(STR("node")); - - xpath_node_set ns1 = doc1.select_nodes(STR("*")); - CHECK(ns1.size() == 1); - - xpath_node_set ns2 = doc2.select_nodes(STR("*/*")); - CHECK(ns2.size() == 1); - - xpath_variable_set set; - set.set(STR("ns1"), ns1); - set.set(STR("ns2"), ns2); - - xpath_node_set ns = xpath_query(STR("$ns1 | $ns2"), &set).evaluate_node_set(xpath_node()); - - ns.sort(); - - CHECK(ns.size() == 2); - CHECK((ns[0] == ns1[0] && ns[1] == ns2[0]) || (ns[0] == ns2[0] && ns[1] == ns1[0])); -} - -TEST_XML(xpath_sort_empty_node, "") -{ - xml_node n = doc.child(STR("node")); - xpath_node nodes[] = { n.child(STR("child2")), xml_node(), n.child(STR("child1")), xml_node() }; - xpath_node_set ns(nodes, nodes + sizeof(nodes) / sizeof(nodes[0])); - - ns.sort(); - - CHECK(!ns[0] && !ns[1] && ns[2] == nodes[2] && ns[3] == nodes[0]); -} - -TEST(xpath_allocate_string_out_of_memory) -{ - std::basic_string query; - - for (int i = 0; i < 1024; ++i) query += STR("abcdefgh"); - - test_runner::_memory_fail_threshold = 8*1024; - -#ifndef __DMC__ // DigitalMars exception handling crashes instead of catching the exception... - CHECK_ALLOC_FAIL(CHECK(!xpath_query(query.c_str()))); -#endif -} - -TEST(xpath_remove_duplicates) -{ - xml_document doc; - - for (int i = 0; i < 20; ++i) - { - doc.append_child(STR("node2")); - doc.prepend_child(STR("node1")); - } - - xpath_node_set ns = doc.select_nodes(STR("/node2/preceding::* | //node1 | /node() | /* | /node1/following-sibling::*")); - - ns.sort(); - - { - xpath_node_set_tester tester(ns, "sorted order failed"); - - for (int i = 0; i < 40; ++i) - tester % (2 + i); - } -} - -TEST(xpath_anonymous_nodes) -{ - xml_document doc; - doc.append_child(node_element); - doc.append_child(node_pi); - - CHECK_XPATH_NODESET(doc, STR("/name")); - CHECK_XPATH_NODESET(doc, STR("/processing-instruction('a')")); - CHECK_XPATH_NODESET(doc, STR("/ns:*")); -} -#endif diff --git a/external/pugixml/tests/test_xpath_api.cpp b/external/pugixml/tests/test_xpath_api.cpp deleted file mode 100644 index 8687e3574..000000000 --- a/external/pugixml/tests/test_xpath_api.cpp +++ /dev/null @@ -1,644 +0,0 @@ -#ifndef PUGIXML_NO_XPATH - -#include // because Borland's STL is braindead, we have to include _before_ in order to get memcmp - -#include "test.hpp" - -#include "helpers.hpp" - -#include -#include - -using namespace pugi; - -TEST_XML(xpath_api_select_nodes, "") -{ - xpath_node_set ns1 = doc.select_nodes(STR("node/foo")); - - xpath_query q(STR("node/foo")); - xpath_node_set ns2 = doc.select_nodes(q); - - xpath_node_set_tester(ns1, "ns1") % 4 % 5; - xpath_node_set_tester(ns2, "ns2") % 4 % 5; -} - -TEST_XML(xpath_api_select_node, "") -{ - xpath_node n1 = doc.select_node(STR("node/foo")); - - xpath_query q(STR("node/foo")); - xpath_node n2 = doc.select_node(q); - - CHECK(n1.node().attribute(STR("id")).as_int() == 1); - CHECK(n2.node().attribute(STR("id")).as_int() == 1); - - xpath_node n3 = doc.select_node(STR("node/bar")); - - CHECK(!n3); - - xpath_node n4 = doc.select_node(STR("node/head/following-sibling::foo")); - xpath_node n5 = doc.select_node(STR("node/tail/preceding-sibling::foo")); - - CHECK(n4.node().attribute(STR("id")).as_int() == 1); - CHECK(n5.node().attribute(STR("id")).as_int() == 1); -} - -TEST_XML(xpath_api_node_bool_ops, "") -{ - generic_bool_ops_test(doc.select_node(STR("node"))); - generic_bool_ops_test(doc.select_node(STR("node/@attr"))); -} - -TEST_XML(xpath_api_node_eq_ops, "") -{ - generic_eq_ops_test(doc.select_node(STR("node")), doc.select_node(STR("node/@attr"))); -} - -TEST_XML(xpath_api_node_accessors, "") -{ - xpath_node null; - xpath_node node = doc.select_node(STR("node")); - xpath_node attr = doc.select_node(STR("node/@attr")); - - CHECK(!null.node()); - CHECK(!null.attribute()); - CHECK(!null.parent()); - - CHECK(node.node() == doc.child(STR("node"))); - CHECK(!node.attribute()); - CHECK(node.parent() == doc); - - CHECK(!attr.node()); - CHECK(attr.attribute() == doc.child(STR("node")).attribute(STR("attr"))); - CHECK(attr.parent() == doc.child(STR("node"))); -} - -inline void xpath_api_node_accessors_helper(const xpath_node_set& set) -{ - CHECK(set.size() == 2); - CHECK(set.type() == xpath_node_set::type_sorted); - CHECK(!set.empty()); - CHECK_STRING(set[0].node().name(), STR("foo")); - CHECK_STRING(set[1].node().name(), STR("foo")); - CHECK(set.first() == set[0]); - CHECK(set.begin() + 2 == set.end()); - CHECK(set.begin()[0] == set[0] && set.begin()[1] == set[1]); -} - -TEST_XML(xpath_api_nodeset_accessors, "") -{ - xpath_node_set null; - CHECK(null.size() == 0); - CHECK(null.type() == xpath_node_set::type_unsorted); - CHECK(null.empty()); - CHECK(!null.first()); - CHECK(null.begin() == null.end()); - - xpath_node_set set = doc.select_nodes(STR("node/foo")); - xpath_api_node_accessors_helper(set); - - xpath_node_set copy = set; - xpath_api_node_accessors_helper(copy); - - xpath_node_set assigned; - assigned = set; - xpath_api_node_accessors_helper(assigned); - - xpath_node_set nullcopy = null; -} - -TEST_XML(xpath_api_nodeset_copy, "") -{ - xpath_node_set empty; - xpath_node_set set = doc.select_nodes(STR("node/foo")); - - xpath_node_set copy1 = set; - CHECK(copy1.size() == 2); - CHECK_STRING(copy1[0].node().name(), STR("foo")); - - xpath_node_set copy2; - copy2 = set; - CHECK(copy2.size() == 2); - CHECK_STRING(copy2[0].node().name(), STR("foo")); - - xpath_node_set copy3; - copy3 = set; - copy3 = xpath_node_set(copy3); - CHECK(copy3.size() == 2); - CHECK_STRING(copy3[0].node().name(), STR("foo")); - - xpath_node_set copy4; - copy4 = set; - copy4 = copy1; - CHECK(copy4.size() == 2); - CHECK_STRING(copy4[0].node().name(), STR("foo")); - - xpath_node_set copy5; - copy5 = set; - copy5 = empty; - CHECK(copy5.size() == 0); -} - -TEST(xpath_api_nodeset_copy_empty) -{ - xpath_node_set set; - xpath_node_set set2 = set; - xpath_node_set set3; - set3 = set; -} - -TEST_XML(xpath_api_evaluate, "") -{ - xpath_query q(STR("node/@attr")); - - CHECK(q.evaluate_boolean(doc)); - CHECK(q.evaluate_number(doc) == 3); - - char_t string[3]; - CHECK(q.evaluate_string(string, 3, doc) == 2 && string[0] == '3' && string[1] == 0); - -#ifndef PUGIXML_NO_STL - CHECK(q.evaluate_string(doc) == STR("3")); -#endif - - xpath_node_set ns = q.evaluate_node_set(doc); - CHECK(ns.size() == 1 && ns[0].attribute() == doc.child(STR("node")).attribute(STR("attr"))); - - xpath_node nr = q.evaluate_node(doc); - CHECK(nr.attribute() == doc.child(STR("node")).attribute(STR("attr"))); -} - -TEST_XML(xpath_api_evaluate_attr, "") -{ - xpath_query q(STR(".")); - xpath_node n(doc.child(STR("node")).attribute(STR("attr")), doc.child(STR("node"))); - - CHECK(q.evaluate_boolean(n)); - CHECK(q.evaluate_number(n) == 3); - - char_t string[3]; - CHECK(q.evaluate_string(string, 3, n) == 2 && string[0] == '3' && string[1] == 0); - -#ifndef PUGIXML_NO_STL - CHECK(q.evaluate_string(n) == STR("3")); -#endif - - xpath_node_set ns = q.evaluate_node_set(n); - CHECK(ns.size() == 1 && ns[0] == n); - - xpath_node nr = q.evaluate_node(n); - CHECK(nr == n); -} - -#ifdef PUGIXML_NO_EXCEPTIONS -TEST_XML(xpath_api_evaluate_fail, "") -{ - xpath_query q(STR("")); - - CHECK(q.evaluate_boolean(doc) == false); - CHECK_DOUBLE_NAN(q.evaluate_number(doc)); - - CHECK(q.evaluate_string(0, 0, doc) == 1); // null terminator - -#ifndef PUGIXML_NO_STL - CHECK(q.evaluate_string(doc).empty()); -#endif - - CHECK(q.evaluate_node_set(doc).empty()); - - CHECK(!q.evaluate_node(doc)); -} -#endif - -TEST(xpath_api_evaluate_node_set_fail) -{ - xpath_query q(STR("1")); - -#ifdef PUGIXML_NO_EXCEPTIONS - CHECK(q.evaluate_node_set(xml_node()).empty()); -#else - try - { - q.evaluate_node_set(xml_node()); - - CHECK_FORCE_FAIL("Expected exception"); - } - catch (const xpath_exception&) - { - } -#endif -} - -TEST(xpath_api_evaluate_node_fail) -{ - xpath_query q(STR("1")); - -#ifdef PUGIXML_NO_EXCEPTIONS - CHECK(!q.evaluate_node(xml_node())); -#else - try - { - q.evaluate_node(xml_node()); - - CHECK_FORCE_FAIL("Expected exception"); - } - catch (const xpath_exception&) - { - } -#endif -} - -TEST(xpath_api_evaluate_string) -{ - xpath_query q(STR("\"0123456789\"")); - - std::basic_string base = STR("xxxxxxxxxxxxxxxx"); - - // test for enough space - std::basic_string s0 = base; - CHECK(q.evaluate_string(&s0[0], 16, xml_node()) == 11 && memcmp(&s0[0], STR("0123456789\0xxxxx"), 16 * sizeof(char_t)) == 0); - - // test for just enough space - std::basic_string s1 = base; - CHECK(q.evaluate_string(&s1[0], 11, xml_node()) == 11 && memcmp(&s1[0], STR("0123456789\0xxxxx"), 16 * sizeof(char_t)) == 0); - - // test for just not enough space - std::basic_string s2 = base; - CHECK(q.evaluate_string(&s2[0], 10, xml_node()) == 11 && memcmp(&s2[0], STR("012345678\0xxxxxx"), 16 * sizeof(char_t)) == 0); - - // test for not enough space - std::basic_string s3 = base; - CHECK(q.evaluate_string(&s3[0], 5, xml_node()) == 11 && memcmp(&s3[0], STR("0123\0xxxxxxxxxxx"), 16 * sizeof(char_t)) == 0); - - // test for single character buffer - std::basic_string s4 = base; - CHECK(q.evaluate_string(&s4[0], 1, xml_node()) == 11 && memcmp(&s4[0], STR("\0xxxxxxxxxxxxxxx"), 16 * sizeof(char_t)) == 0); - - // test for empty buffer - std::basic_string s5 = base; - CHECK(q.evaluate_string(&s5[0], 0, xml_node()) == 11 && memcmp(&s5[0], STR("xxxxxxxxxxxxxxxx"), 16 * sizeof(char_t)) == 0); - CHECK(q.evaluate_string(0, 0, xml_node()) == 11); -} - -TEST(xpath_api_return_type) -{ -#ifdef PUGIXML_NO_EXCEPTIONS - CHECK(xpath_query(STR("")).return_type() == xpath_type_none); -#endif - - CHECK(xpath_query(STR("node")).return_type() == xpath_type_node_set); - CHECK(xpath_query(STR("1")).return_type() == xpath_type_number); - CHECK(xpath_query(STR("'s'")).return_type() == xpath_type_string); - CHECK(xpath_query(STR("true()")).return_type() == xpath_type_boolean); -} - -TEST(xpath_api_query_bool) -{ - xpath_query q(STR("node")); - - CHECK(q); - CHECK((!q) == false); -} - -#ifdef PUGIXML_NO_EXCEPTIONS -TEST(xpath_api_query_bool_fail) -{ - xpath_query q(STR("")); - - CHECK((q ? true : false) == false); - CHECK((!q) == true); -} -#endif - -TEST(xpath_api_query_result) -{ - xpath_query q(STR("node")); - - CHECK(q.result()); - CHECK(q.result().error == 0); - CHECK(q.result().offset == 0); - CHECK(strcmp(q.result().description(), "No error") == 0); -} - -TEST(xpath_api_query_result_fail) -{ -#ifndef PUGIXML_NO_EXCEPTIONS - try - { -#endif - xpath_query q(STR("//foo/child::/bar")); - -#ifndef PUGIXML_NO_EXCEPTIONS - CHECK_FORCE_FAIL("Expected exception"); - } - catch (const xpath_exception& q) - { -#endif - xpath_parse_result result = q.result(); - - CHECK(!result); - CHECK(result.error != 0 && result.error[0] != 0); - CHECK(result.description() == result.error); - CHECK(result.offset == 13); - -#ifndef PUGIXML_NO_EXCEPTIONS - } -#endif -} - -#ifndef PUGIXML_NO_EXCEPTIONS -TEST(xpath_api_exception_what) -{ - try - { - xpath_query q(STR("")); - - CHECK_FORCE_FAIL("Expected exception"); - } - catch (const xpath_exception& e) - { - CHECK(e.what()[0] != 0); - } -} -#endif - -TEST(xpath_api_node_set_ctor_out_of_memory) -{ - test_runner::_memory_fail_threshold = 1; - - xpath_node data[2]; - - CHECK_ALLOC_FAIL(xpath_node_set ns(data, data + 2)); -} - -TEST(xpath_api_node_set_copy_ctor_out_of_memory) -{ - xpath_node data[2]; - xpath_node_set ns(data, data + 2); - - test_runner::_memory_fail_threshold = 1; - - CHECK_ALLOC_FAIL(xpath_node_set copy = ns); -} - -TEST_XML(xpath_api_node_set_assign_out_of_memory_preserve, "") -{ - xpath_node_set ns = doc.select_nodes(STR("node/*")); - CHECK(ns.size() == 2); - CHECK(ns.type() == xpath_node_set::type_sorted); - - xpath_node_set nsall = doc.select_nodes(STR("//*")); - nsall.sort(true); - CHECK(nsall.size() == 3); - CHECK(nsall.type() == xpath_node_set::type_sorted_reverse); - - test_runner::_memory_fail_threshold = 1; - - CHECK_ALLOC_FAIL(ns = nsall); - - CHECK(ns.size() == 2); - CHECK(ns.type() == xpath_node_set::type_sorted); - CHECK(ns[0] == doc.child(STR("node")).child(STR("a")) && ns[1] == doc.child(STR("node")).child(STR("b"))); -} - -TEST(xpath_api_empty) -{ - xml_node c; - - xpath_query q; - CHECK(!q); - CHECK(!q.evaluate_boolean(c)); -} - -#ifdef PUGIXML_HAS_MOVE -TEST_XML(xpath_api_nodeset_move_ctor, "") -{ - xpath_node_set set = doc.select_nodes(STR("node/bar/preceding::*")); - - CHECK(set.size() == 2); - CHECK(set.type() == xpath_node_set::type_sorted_reverse); - - test_runner::_memory_fail_threshold = 1; - - xpath_node_set move = std::move(set); - - CHECK(set.size() == 0); - CHECK(set.type() == xpath_node_set::type_unsorted); - - CHECK(move.size() == 2); - CHECK(move.type() == xpath_node_set::type_sorted_reverse); - CHECK(move[1] == doc.first_child().first_child()); -} - - -TEST_XML(xpath_api_nodeset_move_ctor_single, "") -{ - xpath_node_set set = doc.select_nodes(STR("node/bar")); - - CHECK(set.size() == 1); - CHECK(set.type() == xpath_node_set::type_sorted); - - test_runner::_memory_fail_threshold = 1; - - xpath_node_set move = std::move(set); - - CHECK(set.size() == 0); - CHECK(set.type() == xpath_node_set::type_unsorted); - - CHECK(move.size() == 1); - CHECK(move.type() == xpath_node_set::type_sorted); - CHECK(move[0] == doc.first_child().last_child()); -} - -TEST(xpath_api_nodeset_move_ctor_empty) -{ - xpath_node_set set; - set.sort(); - - CHECK(set.size() == 0); - CHECK(set.type() == xpath_node_set::type_sorted); - - test_runner::_memory_fail_threshold = 1; - - xpath_node_set move = std::move(set); - - CHECK(set.size() == 0); - CHECK(set.type() == xpath_node_set::type_unsorted); - - CHECK(move.size() == 0); - CHECK(move.type() == xpath_node_set::type_sorted); -} - -TEST_XML(xpath_api_nodeset_move_assign, "") -{ - xpath_node_set set = doc.select_nodes(STR("node/bar/preceding::*")); - - CHECK(set.size() == 2); - CHECK(set.type() == xpath_node_set::type_sorted_reverse); - - test_runner::_memory_fail_threshold = 1; - - xpath_node_set move; - - CHECK(move.size() == 0); - CHECK(move.type() == xpath_node_set::type_unsorted); - - move = std::move(set); - - CHECK(set.size() == 0); - CHECK(set.type() == xpath_node_set::type_unsorted); - - CHECK(move.size() == 2); - CHECK(move.type() == xpath_node_set::type_sorted_reverse); - CHECK(move[1] == doc.first_child().first_child()); -} - -TEST_XML(xpath_api_nodeset_move_assign_destroy, "") -{ - xpath_node_set set = doc.select_nodes(STR("node/bar/preceding::*")); - - CHECK(set.size() == 2); - CHECK(set.type() == xpath_node_set::type_sorted_reverse); - - xpath_node_set all = doc.select_nodes(STR("//*")); - - CHECK(all.size() == 4); - - test_runner::_memory_fail_threshold = 1; - - all = std::move(set); - - CHECK(set.size() == 0); - CHECK(set.type() == xpath_node_set::type_unsorted); - - CHECK(all.size() == 2); - CHECK(all.type() == xpath_node_set::type_sorted_reverse); - CHECK(all[1] == doc.first_child().first_child()); -} - -TEST_XML(xpath_api_nodeset_move_assign_single, "") -{ - xpath_node_set set = doc.select_nodes(STR("node/bar")); - - CHECK(set.size() == 1); - CHECK(set.type() == xpath_node_set::type_sorted); - - test_runner::_memory_fail_threshold = 1; - - xpath_node_set move; - - CHECK(move.size() == 0); - CHECK(move.type() == xpath_node_set::type_unsorted); - - move = std::move(set); - - CHECK(set.size() == 0); - CHECK(set.type() == xpath_node_set::type_unsorted); - - CHECK(move.size() == 1); - CHECK(move.type() == xpath_node_set::type_sorted); - CHECK(move[0] == doc.first_child().last_child()); -} - -TEST(xpath_api_nodeset_move_assign_empty) -{ - xpath_node_set set; - set.sort(); - - CHECK(set.size() == 0); - CHECK(set.type() == xpath_node_set::type_sorted); - - test_runner::_memory_fail_threshold = 1; - - xpath_node_set move; - - CHECK(move.size() == 0); - CHECK(move.type() == xpath_node_set::type_unsorted); - - move = std::move(set); - - CHECK(set.size() == 0); - CHECK(set.type() == xpath_node_set::type_unsorted); - - CHECK(move.size() == 0); - CHECK(move.type() == xpath_node_set::type_sorted); -} - -TEST_XML(xpath_api_nodeset_move_assign_self, "") -{ - xpath_node_set set = doc.select_nodes(STR("node/bar")); - - CHECK(set.size() == 1); - CHECK(set.type() == xpath_node_set::type_sorted); - - test_runner::_memory_fail_threshold = 1; - - set = std::move(*&set); -} - -TEST(xpath_api_query_move) -{ - xml_node c; - - xpath_query q1(STR("true()")); - xpath_query q4(STR("true() and false()")); - - test_runner::_memory_fail_threshold = 1; - - CHECK(q1); - CHECK(q1.evaluate_boolean(c)); - - xpath_query q2 = std::move(q1); - CHECK(!q1); - CHECK(!q1.evaluate_boolean(c)); - CHECK(q2); - CHECK(q2.evaluate_boolean(c)); - - xpath_query q3; - CHECK(!q3); - CHECK(!q3.evaluate_boolean(c)); - - q3 = std::move(q2); - CHECK(!q2); - CHECK(!q2.evaluate_boolean(c)); - CHECK(q3); - CHECK(q3.evaluate_boolean(c)); - - CHECK(q4); - CHECK(!q4.evaluate_boolean(c)); - - q4 = std::move(q3); - - CHECK(!q3); - CHECK(!q3.evaluate_boolean(c)); - CHECK(q4); - CHECK(q4.evaluate_boolean(c)); - - q4 = std::move(*&q4); - - CHECK(q4); - CHECK(q4.evaluate_boolean(c)); -} - -TEST(xpath_api_query_vector) -{ - std::vector qv; - - for (int i = 0; i < 10; ++i) - { - char_t expr[2]; - expr[0] = char_t('0' + i); - expr[1] = 0; - - qv.push_back(xpath_query(expr)); - } - - double result = 0; - - for (size_t i = 0; i < qv.size(); ++i) - result += qv[i].evaluate_number(xml_node()); - - CHECK(result == 45); -} -#endif -#endif diff --git a/external/pugixml/tests/test_xpath_functions.cpp b/external/pugixml/tests/test_xpath_functions.cpp deleted file mode 100644 index 0d1d6307a..000000000 --- a/external/pugixml/tests/test_xpath_functions.cpp +++ /dev/null @@ -1,844 +0,0 @@ -#ifndef PUGIXML_NO_XPATH - -#include "test.hpp" - -#include - -using namespace pugi; - -TEST_XML(xpath_number_number, "123") -{ - xml_node c; - xml_node n = doc.child(STR("node")).first_child(); - - // number with 0 arguments - CHECK_XPATH_NUMBER_NAN(c, STR("number()")); - CHECK_XPATH_NUMBER(n, STR("number()"), 123); - - // number with 1 string argument - CHECK_XPATH_NUMBER(c, STR("number(' -123.456 ')"), -123.456); - CHECK_XPATH_NUMBER(c, STR("number(' -123.')"), -123); - CHECK_XPATH_NUMBER(c, STR("number('123.')"), 123); - CHECK_XPATH_NUMBER(c, STR("number('.56')"), 0.56); - CHECK_XPATH_NUMBER(c, STR("number('123 ')"), 123); - CHECK_XPATH_NUMBER_NAN(c, STR("number('foobar')")); - CHECK_XPATH_NUMBER_NAN(c, STR("number('f1')")); - CHECK_XPATH_NUMBER_NAN(c, STR("number('1f')")); - CHECK_XPATH_NUMBER_NAN(c, STR("number('1.f')")); - CHECK_XPATH_NUMBER_NAN(c, STR("number('1.0f')")); - CHECK_XPATH_NUMBER_NAN(c, STR("number('123 f')")); - CHECK_XPATH_NUMBER_NAN(c, STR("number('')")); - CHECK_XPATH_NUMBER_NAN(c, STR("number('.')")); - - // number with 1 bool argument - CHECK_XPATH_NUMBER(c, STR("number(true())"), 1); - CHECK_XPATH_NUMBER(c, STR("number(false())"), 0); - - // number with 1 node set argument - CHECK_XPATH_NUMBER(n, STR("number(.)"), 123); - - // number with 1 number argument - CHECK_XPATH_NUMBER(c, STR("number(1)"), 1); - - // number with 2 arguments - CHECK_XPATH_FAIL(STR("number(1, 2)")); -} - -TEST_XML(xpath_number_sum, "123789") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // sum with 0 arguments - CHECK_XPATH_FAIL(STR("sum()")); - - // sum with 1 argument - CHECK_XPATH_NUMBER(c, STR("sum(.)"), 0); - CHECK_XPATH_NUMBER(n, STR("sum(.)"), 123789); // 123 .. 789 - - CHECK_XPATH_NUMBER(n, STR("sum(./descendant-or-self::node())"), 125490); // node + 123 + child + 789 = 123789 + 123 + 789 + 789 = 125490 - CHECK_XPATH_NUMBER(n, STR("sum(.//node())"), 1701); // 123 + child + 789 = 123 + 789 + 789 - CHECK_XPATH_NUMBER_NAN(doc.last_child(), STR("sum(.)")); - - // sum with 2 arguments - CHECK_XPATH_FAIL(STR("sum(1, 2)")); - - // sum with 1 non-node-set argument - CHECK_XPATH_FAIL(STR("sum(1)")); -} - -TEST(xpath_number_floor) -{ - xml_node c; - - // floor with 0 arguments - CHECK_XPATH_FAIL(STR("floor()")); - - // floor with 1 argument - CHECK_XPATH_NUMBER(c, STR("floor(0)"), 0); - CHECK_XPATH_NUMBER(c, STR("floor(1.2)"), 1); - CHECK_XPATH_NUMBER(c, STR("floor(1)"), 1); - CHECK_XPATH_NUMBER(c, STR("floor(-1.2)"), -2); - CHECK_XPATH_NUMBER_NAN(c, STR("floor(string('nan'))")); - CHECK_XPATH_STRING(c, STR("string(floor(1 div 0))"), STR("Infinity")); - CHECK_XPATH_STRING(c, STR("string(floor(-1 div 0))"), STR("-Infinity")); - - // floor with 2 arguments - CHECK_XPATH_FAIL(STR("floor(1, 2)")); - - // floor with argument 0 should return 0 - CHECK_XPATH_STRING(c, STR("string(1 div floor(0))"), STR("Infinity")); - - // floor with argument -0 should return -0 -#if !(defined(__APPLE__) && defined(__MACH__)) // MacOS X gcc 4.0.1 implements floor incorrectly (floor never returns -0) - CHECK_XPATH_STRING(c, STR("string(1 div floor(-0))"), STR("-Infinity")); -#endif -} - -TEST(xpath_number_ceiling) -{ - xml_node c; - - // ceiling with 0 arguments - CHECK_XPATH_FAIL(STR("ceiling()")); - - // ceiling with 1 argument - CHECK_XPATH_NUMBER(c, STR("ceiling(0)"), 0); - CHECK_XPATH_NUMBER(c, STR("ceiling(1.2)"), 2); - CHECK_XPATH_NUMBER(c, STR("ceiling(1)"), 1); - CHECK_XPATH_NUMBER(c, STR("ceiling(-1.2)"), -1); - CHECK_XPATH_NUMBER_NAN(c, STR("ceiling(string('nan'))")); - CHECK_XPATH_STRING(c, STR("string(ceiling(1 div 0))"), STR("Infinity")); - CHECK_XPATH_STRING(c, STR("string(ceiling(-1 div 0))"), STR("-Infinity")); - - // ceiling with 2 arguments - CHECK_XPATH_FAIL(STR("ceiling(1, 2)")); - - // ceiling with argument 0 should return 0 - CHECK_XPATH_STRING(c, STR("string(1 div ceiling(0))"), STR("Infinity")); - - // ceiling with argument in range (-1, -0] should result in minus zero -#if !(defined(__APPLE__) && defined(__MACH__)) && !defined(__CLR_VER) // MacOS X gcc 4.0.1 and x64 CLR implement ceil incorrectly (ceil never returns -0) - CHECK_XPATH_STRING(c, STR("string(1 div ceiling(-0))"), STR("-Infinity")); - CHECK_XPATH_STRING(c, STR("string(1 div ceiling(-0.1))"), STR("-Infinity")); -#endif -} - -TEST(xpath_number_round) -{ - xml_node c; - - // round with 0 arguments - CHECK_XPATH_FAIL(STR("round()")); - - // round with 1 argument - CHECK_XPATH_NUMBER(c, STR("round(1.2)"), 1); - CHECK_XPATH_NUMBER(c, STR("round(1.5)"), 2); - CHECK_XPATH_NUMBER(c, STR("round(1.8)"), 2); - CHECK_XPATH_NUMBER(c, STR("round(1)"), 1); - CHECK_XPATH_NUMBER(c, STR("round(-1.2)"), -1); - CHECK_XPATH_NUMBER(c, STR("round(-1.5)"), -1); - CHECK_XPATH_NUMBER(c, STR("round(-1.6)"), -2); - CHECK_XPATH_NUMBER_NAN(c, STR("round(string('nan'))")); - CHECK_XPATH_STRING(c, STR("string(round(1 div 0))"), STR("Infinity")); - CHECK_XPATH_STRING(c, STR("string(round(-1 div 0))"), STR("-Infinity")); - - // round with 2 arguments - CHECK_XPATH_FAIL(STR("round(1, 2)")); - - // round with argument in range [-0.5, -0] should result in minus zero - CHECK_XPATH_STRING(c, STR("string(1 div round(0))"), STR("Infinity")); - -#if !(defined(__APPLE__) && defined(__MACH__)) && !defined(__CLR_VER) // MacOS X gcc 4.0.1 and x64 CLR implement ceil incorrectly (ceil never returns -0) - CHECK_XPATH_STRING(c, STR("string(1 div round(-0.5))"), STR("-Infinity")); - CHECK_XPATH_STRING(c, STR("string(1 div round(-0))"), STR("-Infinity")); - CHECK_XPATH_STRING(c, STR("string(1 div round(-0.1))"), STR("-Infinity")); -#endif -} - -TEST_XML(xpath_boolean_boolean, "") -{ - xml_node c; - - // boolean with 0 arguments - CHECK_XPATH_FAIL(STR("boolean()")); - - // boolean with 1 number argument - CHECK_XPATH_BOOLEAN(c, STR("boolean(0)"), false); - CHECK_XPATH_BOOLEAN(c, STR("boolean(1)"), true); - CHECK_XPATH_BOOLEAN(c, STR("boolean(-1)"), true); - CHECK_XPATH_BOOLEAN(c, STR("boolean(0.1)"), true); - CHECK_XPATH_BOOLEAN(c, STR("boolean(number('nan'))"), false); - - // boolean with 1 string argument - CHECK_XPATH_BOOLEAN(c, STR("boolean('x')"), true); - CHECK_XPATH_BOOLEAN(c, STR("boolean('')"), false); - - // boolean with 1 node set argument - CHECK_XPATH_BOOLEAN(c, STR("boolean(.)"), false); - CHECK_XPATH_BOOLEAN(doc, STR("boolean(.)"), true); - CHECK_XPATH_BOOLEAN(doc, STR("boolean(foo)"), false); - - // boolean with 2 arguments - CHECK_XPATH_FAIL(STR("boolean(1, 2)")); -} - -TEST(xpath_boolean_not) -{ - xml_node c; - - // not with 0 arguments - CHECK_XPATH_FAIL(STR("not()")); - - // not with 1 argument - CHECK_XPATH_BOOLEAN(c, STR("not(true())"), false); - CHECK_XPATH_BOOLEAN(c, STR("not(false())"), true); - - // boolean with 2 arguments - CHECK_XPATH_FAIL(STR("not(1, 2)")); -} - -TEST(xpath_boolean_true) -{ - xml_node c; - - // true with 0 arguments - CHECK_XPATH_BOOLEAN(c, STR("true()"), true); - - // true with 1 argument - CHECK_XPATH_FAIL(STR("true(1)")); -} - -TEST(xpath_boolean_false) -{ - xml_node c; - - // false with 0 arguments - CHECK_XPATH_BOOLEAN(c, STR("false()"), false); - - // false with 1 argument - CHECK_XPATH_FAIL(STR("false(1)")); -} - -TEST_XML(xpath_boolean_lang, "") -{ - xml_node c; - - // lang with 0 arguments - CHECK_XPATH_FAIL(STR("lang()")); - - // lang with 1 argument, no language - CHECK_XPATH_BOOLEAN(c, STR("lang('en')"), false); - CHECK_XPATH_BOOLEAN(doc.child(STR("foo")), STR("lang('en')"), false); - CHECK_XPATH_BOOLEAN(doc.child(STR("foo")), STR("lang('')"), false); - CHECK_XPATH_BOOLEAN(doc.child(STR("foo")).child(STR("bar")), STR("lang('en')"), false); - - // lang with 1 argument, same language/prefix - CHECK_XPATH_BOOLEAN(doc.child(STR("node")), STR("lang('en')"), true); - CHECK_XPATH_BOOLEAN(doc.child(STR("node")).child(STR("child")), STR("lang('zh-uk')"), true); - CHECK_XPATH_BOOLEAN(doc.child(STR("node")).child(STR("child")), STR("lang('zh')"), true); - CHECK_XPATH_BOOLEAN(doc.child(STR("node")).child(STR("child")).child(STR("subchild")), STR("lang('zh')"), true); - CHECK_XPATH_BOOLEAN(doc.child(STR("node")).child(STR("child")).child(STR("subchild")), STR("lang('ZH')"), true); - - // lang with 1 argument, different language/prefix - CHECK_XPATH_BOOLEAN(doc.child(STR("node")), STR("lang('')"), false); - CHECK_XPATH_BOOLEAN(doc.child(STR("node")), STR("lang('e')"), false); - CHECK_XPATH_BOOLEAN(doc.child(STR("node")).child(STR("child")), STR("lang('en')"), false); - CHECK_XPATH_BOOLEAN(doc.child(STR("node")).child(STR("child")), STR("lang('zh-gb')"), false); - CHECK_XPATH_BOOLEAN(doc.child(STR("node")).child(STR("child")), STR("lang('r')"), false); - CHECK_XPATH_BOOLEAN(doc.child(STR("node")).child(STR("child")).child(STR("subchild")), STR("lang('en')"), false); - - // lang with 1 attribute argument - CHECK_XPATH_NODESET(doc, STR("//@*[lang('en')]")); - - // lang with 2 arguments - CHECK_XPATH_FAIL(STR("lang(1, 2)")); -} - -TEST_XML(xpath_string_string, "123789100") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // string with 0 arguments - CHECK_XPATH_STRING(c, STR("string()"), STR("")); - CHECK_XPATH_STRING(n.child(STR("child")), STR("string()"), STR("789")); - - // string with 1 node-set argument - CHECK_XPATH_STRING(n, STR("string(child)"), STR("789")); - CHECK_XPATH_STRING(n, STR("string(child/@id)"), STR("1")); - CHECK_XPATH_STRING(n, STR("string(.)"), STR("123789200100")); - - // string with 1 number argument - CHECK_XPATH_STRING(c, STR("string(0 div 0)"), STR("NaN")); - CHECK_XPATH_STRING(c, STR("string(0)"), STR("0")); - CHECK_XPATH_STRING(c, STR("string(-0)"), STR("0")); - CHECK_XPATH_STRING(c, STR("string(1 div 0)"), STR("Infinity")); - CHECK_XPATH_STRING(c, STR("string(-1 div -0)"), STR("Infinity")); - CHECK_XPATH_STRING(c, STR("string(-1 div 0)"), STR("-Infinity")); - CHECK_XPATH_STRING(c, STR("string(1 div -0)"), STR("-Infinity")); - CHECK_XPATH_STRING(c, STR("string(1234567)"), STR("1234567")); - CHECK_XPATH_STRING(c, STR("string(-1234567)"), STR("-1234567")); - CHECK_XPATH_STRING(c, STR("string(1234.5678)"), STR("1234.5678")); - CHECK_XPATH_STRING(c, STR("string(-1234.5678)"), STR("-1234.5678")); - CHECK_XPATH_STRING(c, STR("string(0.5678)"), STR("0.5678")); - CHECK_XPATH_STRING(c, STR("string(-0.5678)"), STR("-0.5678")); - CHECK_XPATH_STRING(c, STR("string(0.0)"), STR("0")); - CHECK_XPATH_STRING(c, STR("string(-0.0)"), STR("0")); - - // string with 1 boolean argument - CHECK_XPATH_STRING(c, STR("string(true())"), STR("true")); - CHECK_XPATH_STRING(c, STR("string(false())"), STR("false")); - - // string with 1 string argument - CHECK_XPATH_STRING(c, STR("string('abc')"), STR("abc")); - - // string with 2 arguments - CHECK_XPATH_FAIL(STR("string(1, 2)")); -} - -TEST(xpath_string_concat) -{ - xml_node c; - - // concat with 0 arguments - CHECK_XPATH_FAIL(STR("concat()")); - - // concat with 1 argument - CHECK_XPATH_FAIL(STR("concat('')")); - - // concat with exactly 2 arguments - CHECK_XPATH_STRING(c, STR("concat('prev','next')"), STR("prevnext")); - CHECK_XPATH_STRING(c, STR("concat('','next')"), STR("next")); - CHECK_XPATH_STRING(c, STR("concat('prev','')"), STR("prev")); - - // concat with 3 or more arguments - CHECK_XPATH_STRING(c, STR("concat('a', 'b', 'c')"), STR("abc")); - CHECK_XPATH_STRING(c, STR("concat('a', 'b', 'c', 'd')"), STR("abcd")); - CHECK_XPATH_STRING(c, STR("concat('a', 'b', 'c', 'd', 'e')"), STR("abcde")); - CHECK_XPATH_STRING(c, STR("concat('a', 'b', 'c', 'd', 'e', 'f')"), STR("abcdef")); - CHECK_XPATH_STRING(c, STR("concat('a', 'b', 'c', 'd', 'e', 'f', 'g')"), STR("abcdefg")); - CHECK_XPATH_STRING(c, STR("concat(1, 2, 3, 4, 5, 6, 7, 8)"), STR("12345678")); -} - -TEST(xpath_string_starts_with) -{ - xml_node c; - - // starts-with with 0 arguments - CHECK_XPATH_FAIL(STR("starts-with()")); - - // starts-with with 1 argument - CHECK_XPATH_FAIL(STR("starts-with('a')")); - - // starts-with with 2 arguments - CHECK_XPATH_BOOLEAN(c, STR("starts-with('abc', '')"), true); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('abc', 'a')"), true); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('abc', 'abc')"), true); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('abc', 'abcd')"), false); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('bc', 'c')"), false); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('', 'c')"), false); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('', '')"), true); - - // starts-with with 3 arguments - CHECK_XPATH_FAIL(STR("starts-with('a', 'b', 'c')")); -} - -TEST(xpath_string_contains) -{ - xml_node c; - - // contains with 0 arguments - CHECK_XPATH_FAIL(STR("contains()")); - - // contains with 1 argument - CHECK_XPATH_FAIL(STR("contains('a')")); - - // contains with 2 arguments - CHECK_XPATH_BOOLEAN(c, STR("contains('abc', '')"), true); - CHECK_XPATH_BOOLEAN(c, STR("contains('abc', 'a')"), true); - CHECK_XPATH_BOOLEAN(c, STR("contains('abc', 'abc')"), true); - CHECK_XPATH_BOOLEAN(c, STR("contains('abcd', 'bc')"), true); - CHECK_XPATH_BOOLEAN(c, STR("contains('abc', 'abcd')"), false); - CHECK_XPATH_BOOLEAN(c, STR("contains('b', 'bc')"), false); - CHECK_XPATH_BOOLEAN(c, STR("contains('', 'c')"), false); - CHECK_XPATH_BOOLEAN(c, STR("contains('', '')"), true); - - // contains with 3 arguments - CHECK_XPATH_FAIL(STR("contains('a', 'b', 'c')")); -} - -TEST(xpath_string_substring_before) -{ - xml_node c; - - // substring-before with 0 arguments - CHECK_XPATH_FAIL(STR("substring-before()")); - - // substring-before with 1 argument - CHECK_XPATH_FAIL(STR("substring-before('a')")); - - // substring-before with 2 arguments - CHECK_XPATH_STRING(c, STR("substring-before('abc', 'abc')"), STR("")); - CHECK_XPATH_STRING(c, STR("substring-before('abc', 'a')"), STR("")); - CHECK_XPATH_STRING(c, STR("substring-before('abc', 'cd')"), STR("")); - CHECK_XPATH_STRING(c, STR("substring-before('abc', 'b')"), STR("a")); - CHECK_XPATH_STRING(c, STR("substring-before('abc', 'c')"), STR("ab")); - CHECK_XPATH_STRING(c, STR("substring-before('abc', '')"), STR("")); - CHECK_XPATH_STRING(c, STR("substring-before('', '')"), STR("")); - - // substring-before with 2 arguments, from W3C standard - CHECK_XPATH_STRING(c, STR("substring-before(\"1999/04/01\",\"/\")"), STR("1999")); - - // substring-before with 3 arguments - CHECK_XPATH_FAIL(STR("substring-before('a', 'b', 'c')")); -} - -TEST(xpath_string_substring_after) -{ - xml_node c; - - // substring-after with 0 arguments - CHECK_XPATH_FAIL(STR("substring-after()")); - - // substring-after with 1 argument - CHECK_XPATH_FAIL(STR("substring-after('a')")); - - // substring-after with 2 arguments - CHECK_XPATH_STRING(c, STR("substring-after('abc', 'abc')"), STR("")); - CHECK_XPATH_STRING(c, STR("substring-after('abc', 'a')"), STR("bc")); - CHECK_XPATH_STRING(c, STR("substring-after('abc', 'cd')"), STR("")); - CHECK_XPATH_STRING(c, STR("substring-after('abc', 'b')"), STR("c")); - CHECK_XPATH_STRING(c, STR("substring-after('abc', 'c')"), STR("")); - CHECK_XPATH_STRING(c, STR("substring-after('abc', '')"), STR("abc")); - CHECK_XPATH_STRING(c, STR("substring-after('', '')"), STR("")); - - // substring-before with 2 arguments, from W3C standard - CHECK_XPATH_STRING(c, STR("substring-after(\"1999/04/01\",\"/\")"), STR("04/01")); - CHECK_XPATH_STRING(c, STR("substring-after(\"1999/04/01\",\"19\")"), STR("99/04/01")); - - // substring-after with 3 arguments - CHECK_XPATH_FAIL(STR("substring-after('a', 'b', 'c')")); -} - -TEST_XML(xpath_string_substring_after_heap, "foobar") -{ - CHECK_XPATH_STRING(doc, STR("substring-after(node, 'fo')"), STR("obar")); - CHECK_XPATH_STRING(doc, STR("substring-after(node, 'fooba')"), STR("r")); - CHECK_XPATH_STRING(doc, STR("substring-after(node, 'foobar')"), STR("")); -} - -TEST(xpath_string_substring) -{ - xml_node c; - - // substring with 0 arguments - CHECK_XPATH_FAIL(STR("substring()")); - - // substring with 1 argument - CHECK_XPATH_FAIL(STR("substring('')")); - - // substring with 2 arguments - CHECK_XPATH_STRING(c, STR("substring('abcd', 2)"), STR("bcd")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 1)"), STR("abcd")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 1.1)"), STR("abcd")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 1.5)"), STR("bcd")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 1.8)"), STR("bcd")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 10)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 0)"), STR("abcd")); - CHECK_XPATH_STRING(c, STR("substring('abcd', -100)"), STR("abcd")); - CHECK_XPATH_STRING(c, STR("substring('abcd', -1 div 0)"), STR("abcd")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 1 div 0)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 0 div 0)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('', 1)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('', 0)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring(substring('internalexternalcorrect substring',9),9)"), STR("correct substring")); - - // substring with 3 arguments - CHECK_XPATH_STRING(c, STR("substring('abcd', 2, 1)"), STR("b")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 2, 2)"), STR("bc")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 1, 0)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 1, 0.4)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 1, 0.5)"), STR("a")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 10, -5)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 0, -1)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('abcd', -100, 100)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('abcd', -100, 101)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('abcd', -100, 102)"), STR("a")); - CHECK_XPATH_STRING(c, STR("substring('abcd', -100, 103)"), STR("ab")); - CHECK_XPATH_STRING(c, STR("substring('abcd', -100, 104)"), STR("abc")); - CHECK_XPATH_STRING(c, STR("substring('abcd', -100, 105)"), STR("abcd")); - CHECK_XPATH_STRING(c, STR("substring('abcd', -100, 106)"), STR("abcd")); - CHECK_XPATH_STRING(c, STR("substring('abcd', -100, 1 div 0)"), STR("abcd")); - CHECK_XPATH_STRING(c, STR("substring('abcd', -1 div 0, 4)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 1 div 0, 0 div 0)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('abcd', 0 div 0, 1)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('', 1, 2)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('', 0, 0)"), STR("")); - - // substring with 3 arguments, from W3C standard - CHECK_XPATH_STRING(c, STR("substring('12345', 1.5, 2.6)"), STR("234")); - CHECK_XPATH_STRING(c, STR("substring('12345', 0, 3)"), STR("12")); - CHECK_XPATH_STRING(c, STR("substring('12345', 0 div 0, 3)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('12345', 1, 0 div 0)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('12345', -42, 1 div 0)"), STR("12345")); - CHECK_XPATH_STRING(c, STR("substring('12345', -1 div 0, 1 div 0)"), STR("")); - - // substring with 4 arguments - CHECK_XPATH_FAIL(STR("substring('', 1, 2, 3)")); -} - -TEST_XML(xpath_string_substring_heap, "foobar") -{ - CHECK_XPATH_STRING(doc, STR("substring(node, 3)"), STR("obar")); - CHECK_XPATH_STRING(doc, STR("substring(node, 6)"), STR("r")); - CHECK_XPATH_STRING(doc, STR("substring(node, 7)"), STR("")); -} - -TEST_XML(xpath_string_string_length, "123") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // string-length with 0 arguments - CHECK_XPATH_NUMBER(c, STR("string-length()"), 0); - CHECK_XPATH_NUMBER(n, STR("string-length()"), 3); - - // string-length with 1 argument - CHECK_XPATH_NUMBER(c, STR("string-length('')"), 0); - CHECK_XPATH_NUMBER(c, STR("string-length('a')"), 1); - CHECK_XPATH_NUMBER(c, STR("string-length('abcdef')"), 6); - - // string-length with 2 arguments - CHECK_XPATH_FAIL(STR("string-length(1, 2)")); -} - -TEST_XML_FLAGS(xpath_string_normalize_space, " \t\r\rval1 \rval2\r\nval3\nval4\r\r", parse_minimal) -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // normalize-space with 0 arguments - CHECK_XPATH_STRING(c, STR("normalize-space()"), STR("")); - CHECK_XPATH_STRING(n, STR("normalize-space()"), STR("val1 val2 val3 val4")); - - // normalize-space with 1 argument - CHECK_XPATH_STRING(c, STR("normalize-space('')"), STR("")); - CHECK_XPATH_STRING(c, STR("normalize-space('abcd')"), STR("abcd")); - CHECK_XPATH_STRING(c, STR("normalize-space(' \r\nabcd')"), STR("abcd")); - CHECK_XPATH_STRING(c, STR("normalize-space('abcd \n\r')"), STR("abcd")); - CHECK_XPATH_STRING(c, STR("normalize-space('ab\r\n\tcd')"), STR("ab cd")); - CHECK_XPATH_STRING(c, STR("normalize-space('ab cd')"), STR("ab cd")); - CHECK_XPATH_STRING(c, STR("normalize-space('\07')"), STR("\07")); - - // normalize-space with 2 arguments - CHECK_XPATH_FAIL(STR("normalize-space(1, 2)")); -} - -TEST(xpath_string_translate) -{ - xml_node c; - - // translate with 0 arguments - CHECK_XPATH_FAIL(STR("translate()")); - - // translate with 1 argument - CHECK_XPATH_FAIL(STR("translate('a')")); - - // translate with 2 arguments - CHECK_XPATH_FAIL(STR("translate('a', 'b')")); - - // translate with 3 arguments - CHECK_XPATH_STRING(c, STR("translate('abc', '', '')"), STR("abc")); - CHECK_XPATH_STRING(c, STR("translate('abc', '', 'foo')"), STR("abc")); - CHECK_XPATH_STRING(c, STR("translate('abc', 'ab', 'ba')"), STR("bac")); - CHECK_XPATH_STRING(c, STR("translate('abc', 'ab', 'f')"), STR("fc")); - CHECK_XPATH_STRING(c, STR("translate('abc', 'aabb', '1234')"), STR("13c")); - CHECK_XPATH_STRING(c, STR("translate('', 'abc', 'bac')"), STR("")); - - // translate with 3 arguments, from W3C standard - CHECK_XPATH_STRING(c, STR("translate('bar','abc','ABC')"), STR("BAr")); - CHECK_XPATH_STRING(c, STR("translate('--aaa--','abc-','ABC')"), STR("AAA")); - - // translate with 4 arguments - CHECK_XPATH_FAIL(STR("translate('a', 'b', 'c', 'd')")); -} - -TEST(xpath_string_translate_table) -{ - xml_node c; - - CHECK_XPATH_STRING(c, STR("translate('abcd\xe9 ', 'abc', 'ABC')"), STR("ABCd\xe9 ")); - CHECK_XPATH_STRING(c, STR("translate('abcd\xe9 ', 'abc\xe9', 'ABC!')"), STR("ABCd! ")); - CHECK_XPATH_STRING(c, STR("translate('abcd! ', 'abc!', 'ABC\xe9')"), STR("ABCd\xe9 ")); - CHECK_XPATH_STRING(c, STR("translate('abcde', concat('abc', 'd'), 'ABCD')"), STR("ABCDe")); - CHECK_XPATH_STRING(c, STR("translate('abcde', 'abcd', concat('ABC', 'D'))"), STR("ABCDe")); -} - -TEST(xpath_string_translate_remove) -{ - xml_node c; - - CHECK_XPATH_STRING(c, STR("translate('000000755', '0', '')"), STR("755")); - CHECK_XPATH_STRING(c, STR("translate('000000755', concat('0', ''), '')"), STR("755")); -} - -TEST_XML(xpath_nodeset_last, "") -{ - xml_node n = doc.child(STR("node")); - - // last with 0 arguments - CHECK_XPATH_NUMBER(n, STR("last()"), 1); - CHECK_XPATH_NODESET(n, STR("c1[last() = 1]")); - CHECK_XPATH_NODESET(n, STR("c1[last() = 2]")) % 3 % 4; // c1, c1 - CHECK_XPATH_NODESET(n, STR("c2/preceding-sibling::node()[last() = 2]")) % 4 % 3; // c1, c1 - - // last with 1 argument - CHECK_XPATH_FAIL(STR("last(c)")); -} - -TEST_XML(xpath_nodeset_position, "") -{ - xml_node n = doc.child(STR("node")); - - // position with 0 arguments - CHECK_XPATH_NUMBER(n, STR("position()"), 1); - CHECK_XPATH_NODESET(n, STR("c1[position() = 0]")); - CHECK_XPATH_NODESET(n, STR("c1[position() = 1]")) % 3; - CHECK_XPATH_NODESET(n, STR("c1[position() = 2]")) % 4; - CHECK_XPATH_NODESET(n, STR("c1[position() = 3]")); - CHECK_XPATH_NODESET(n, STR("c2/preceding-sibling::node()[position() = 1]")) % 4; - CHECK_XPATH_NODESET(n, STR("c2/preceding-sibling::node()[position() = 2]")) % 3; - - // position with 1 argument - CHECK_XPATH_FAIL(STR("position(c)")); -} - -TEST_XML(xpath_nodeset_count, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // count with 0 arguments - CHECK_XPATH_FAIL(STR("count()")); - - // count with 1 non-node-set argument - CHECK_XPATH_FAIL(STR("count(1)")); - CHECK_XPATH_FAIL(STR("count(true())")); - CHECK_XPATH_FAIL(STR("count('')")); - - // count with 1 node-set argument - CHECK_XPATH_NUMBER(c, STR("count(.)"), 0); - CHECK_XPATH_NUMBER(n, STR("count(.)"), 1); - CHECK_XPATH_NUMBER(n, STR("count(c1)"), 2); - CHECK_XPATH_NUMBER(n, STR("count(c2)"), 1); - CHECK_XPATH_NUMBER(n, STR("count(c3)"), 4); - CHECK_XPATH_NUMBER(n, STR("count(c4)"), 0); - - // count with 2 arguments - CHECK_XPATH_FAIL(STR("count(x, y)")); -} - -TEST_XML(xpath_nodeset_id, "") -{ - xml_node n = doc.child(STR("node")); - - // id with 0 arguments - CHECK_XPATH_FAIL(STR("id()")); - - // id with 1 argument - no DTD => no id - CHECK_XPATH_NODESET(n, STR("id('foo')")); - - // id with 2 arguments - CHECK_XPATH_FAIL(STR("id(1, 2)")); -} - -TEST_XML_FLAGS(xpath_nodeset_local_name, "text", parse_default | parse_pi) -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // local-name with 0 arguments - CHECK_XPATH_STRING(c, STR("local-name()"), STR("")); - CHECK_XPATH_STRING(n, STR("local-name()"), STR("node")); - - // local-name with 1 non-node-set argument - CHECK_XPATH_FAIL(STR("local-name(1)")); - - // local-name with 1 node-set argument - CHECK_XPATH_STRING(n, STR("local-name(c1)"), STR("c1")); - CHECK_XPATH_STRING(n, STR("local-name(c2/node())"), STR("child")); - CHECK_XPATH_STRING(n, STR("local-name(c2/attribute::node())"), STR("attr")); - CHECK_XPATH_STRING(n, STR("local-name(c1/node())"), STR("")); - CHECK_XPATH_STRING(n, STR("local-name(c4/node())"), STR("target")); - CHECK_XPATH_STRING(n, STR("local-name(c1/following-sibling::node())"), STR("c2")); - CHECK_XPATH_STRING(n, STR("local-name(c4/preceding-sibling::node())"), STR("c1")); - - // local-name with 2 arguments - CHECK_XPATH_FAIL(STR("local-name(c1, c2)")); -} - -TEST_XML_FLAGS(xpath_nodeset_namespace_uri, "text", parse_default | parse_pi) -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // namespace-uri with 0 arguments - CHECK_XPATH_STRING(c, STR("namespace-uri()"), STR("")); - CHECK_XPATH_STRING(n.child(STR("c2")).child(STR("foo:child")), STR("namespace-uri()"), STR("http://foo2")); - - // namespace-uri with 1 non-node-set argument - CHECK_XPATH_FAIL(STR("namespace-uri(1)")); - - // namespace-uri with 1 node-set argument - CHECK_XPATH_STRING(n, STR("namespace-uri(c1)"), STR("")); - CHECK_XPATH_STRING(n, STR("namespace-uri(c5/child::node())"), STR("http://foo")); - CHECK_XPATH_STRING(n, STR("namespace-uri(c2/attribute::node())"), STR("http://foo2")); - CHECK_XPATH_STRING(n, STR("namespace-uri(c2/child::node())"), STR("http://foo2")); - CHECK_XPATH_STRING(n, STR("namespace-uri(c1/child::node())"), STR("")); - CHECK_XPATH_STRING(n, STR("namespace-uri(c4/child::node())"), STR("")); - CHECK_XPATH_STRING(n, STR("namespace-uri(c3)"), STR("http://def")); - CHECK_XPATH_STRING(n, STR("namespace-uri(c3/@attr)"), STR("")); // the namespace name for an unprefixed attribute name always has no value (Namespaces in XML 1.0) - CHECK_XPATH_STRING(n, STR("namespace-uri(c3/child::node())"), STR("http://def")); - CHECK_XPATH_STRING(n, STR("namespace-uri(c6/@bar:attr)"), STR("")); - CHECK_XPATH_STRING(n, STR("namespace-uri(c7/node/@foo:attr)"), STR("http://foo")); - - // namespace-uri with 2 arguments - CHECK_XPATH_FAIL(STR("namespace-uri(c1, c2)")); -} - -TEST_XML_FLAGS(xpath_nodeset_name, "text", parse_default | parse_pi) -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // name with 0 arguments - CHECK_XPATH_STRING(c, STR("name()"), STR("")); - CHECK_XPATH_STRING(n, STR("name()"), STR("node")); - - // name with 1 non-node-set argument - CHECK_XPATH_FAIL(STR("name(1)")); - - // name with 1 node-set argument - CHECK_XPATH_STRING(n, STR("name(c1)"), STR("c1")); - CHECK_XPATH_STRING(n, STR("name(c2/node())"), STR("foo:child")); - CHECK_XPATH_STRING(n, STR("name(c2/attribute::node())"), STR("foo:attr")); - CHECK_XPATH_STRING(n, STR("name(c1/node())"), STR("")); - CHECK_XPATH_STRING(n, STR("name(c4/node())"), STR("target")); - CHECK_XPATH_STRING(n, STR("name(c1/following-sibling::node())"), STR("c2")); - CHECK_XPATH_STRING(n, STR("name(c4/preceding-sibling::node())"), STR("c1")); - - // name with 2 arguments - CHECK_XPATH_FAIL(STR("name(c1, c2)")); -} - -TEST(xpath_function_arguments) -{ - xml_node c; - - // conversion to string - CHECK_XPATH_NUMBER(c, STR("string-length(12)"), 2); - - // conversion to number - CHECK_XPATH_NUMBER(c, STR("round('1.2')"), 1); - CHECK_XPATH_NUMBER(c, STR("round('1.7')"), 2); - - // conversion to boolean - CHECK_XPATH_BOOLEAN(c, STR("not('1')"), false); - CHECK_XPATH_BOOLEAN(c, STR("not('')"), true); - - // conversion to node set - CHECK_XPATH_FAIL(STR("sum(1)")); - - // expression evaluation - CHECK_XPATH_NUMBER(c, STR("round((2 + 2 * 2) div 4)"), 2); - - // empty expressions - CHECK_XPATH_FAIL(STR("round(,)")); - CHECK_XPATH_FAIL(STR("substring(,)")); - CHECK_XPATH_FAIL(STR("substring('a',)")); - CHECK_XPATH_FAIL(STR("substring(,'a')")); - - // extra commas - CHECK_XPATH_FAIL(STR("round(,1)")); - CHECK_XPATH_FAIL(STR("round(1,)")); - - // lack of commas - CHECK_XPATH_FAIL(STR("substring(1 2)")); - - // whitespace after function name - CHECK_XPATH_BOOLEAN(c, STR("true ()"), true); - - // too many arguments - CHECK_XPATH_FAIL(STR("round(1, 2, 3, 4, 5, 6)")); -} - -TEST_XML_FLAGS(xpath_string_value, "pcdata", parse_default | parse_pi | parse_comments) -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_STRING(c, STR("string()"), STR("")); - CHECK_XPATH_STRING(doc, STR("string()"), STR("pcdatacdata")); - CHECK_XPATH_STRING(n, STR("string()"), STR("pcdatacdata")); - CHECK_XPATH_STRING(n, STR("string(c1/node())"), STR("pcdata")); - CHECK_XPATH_STRING(n, STR("string(c2/node())"), STR("")); - CHECK_XPATH_STRING(n, STR("string(c3/@attr)"), STR("avalue")); - CHECK_XPATH_STRING(n, STR("string(c4/node())"), STR("pivalue")); - CHECK_XPATH_STRING(n, STR("string(c5/node())"), STR("comment")); - CHECK_XPATH_STRING(n, STR("string(c6/node())"), STR("cdata")); -} - -TEST(xpath_string_value_empty) -{ - xml_document doc; - doc.append_child(node_pcdata).set_value(STR("head")); - doc.append_child(node_pcdata); - doc.append_child(node_pcdata).set_value(STR("tail")); - - CHECK_XPATH_STRING(doc, STR("string()"), STR("headtail")); -} - -TEST_XML(xpath_string_concat_translate, "foobar") -{ - CHECK_XPATH_STRING(doc, STR("concat('a', 'b', 'c', translate(node, 'o', 'a'), 'd')"), STR("abcfaabard")); -} - -TEST(xpath_unknown_functions) -{ - char_t query[] = STR("a()"); - - for (char ch = 'a'; ch <= 'z'; ++ch) - { - query[0] = ch; - CHECK_XPATH_FAIL(query); - - query[0] = char_t(ch - 32); - CHECK_XPATH_FAIL(query); - } -} - -TEST(xpath_string_translate_table_out_of_memory) -{ - xml_node c; - - // our goal is to generate translate table OOM without generating query OOM - std::basic_string query = STR("concat("); - - size_t count = 20; - - for (size_t i = 0; i < count; ++i) - { - if (i != 0) query += STR(","); - query += STR("translate('a','a','A')"); - } - - query += STR(")"); - - std::basic_string result(count, 'A'); - - test_runner::_memory_fail_threshold = 5000; - - CHECK_ALLOC_FAIL(CHECK_XPATH_STRING(c, query.c_str(), result.c_str())); -} -#endif diff --git a/external/pugixml/tests/test_xpath_operators.cpp b/external/pugixml/tests/test_xpath_operators.cpp deleted file mode 100644 index a3329c73e..000000000 --- a/external/pugixml/tests/test_xpath_operators.cpp +++ /dev/null @@ -1,566 +0,0 @@ -#ifndef PUGIXML_NO_XPATH - -#include "test.hpp" - -using namespace pugi; - -TEST(xpath_operators_arithmetic) -{ - xml_node c; - - // incorrect unary operator - CHECK_XPATH_FAIL(STR("-")); - - // correct unary operator - CHECK_XPATH_NUMBER(c, STR("-1"), -1); - CHECK_XPATH_NUMBER(c, STR("--1"), 1); - CHECK_XPATH_NUMBER(c, STR("---1"), -1); - - // incorrect binary operators - CHECK_XPATH_FAIL(STR("5+")); - CHECK_XPATH_FAIL(STR("5-")); - CHECK_XPATH_FAIL(STR("5*")); - CHECK_XPATH_FAIL(STR("+5")); - CHECK_XPATH_FAIL(STR("*5")); - CHECK_XPATH_FAIL(STR("1div2")); - CHECK_XPATH_FAIL(STR("1mod")); - CHECK_XPATH_FAIL(STR("1div")); - - // correct trivial binary operators - CHECK_XPATH_NUMBER(c, STR("1 + 2"), 3); - CHECK_XPATH_NUMBER(c, STR("1+2"), 3); - CHECK_XPATH_NUMBER(c, STR("1 * 2"), 2); - CHECK_XPATH_NUMBER(c, STR("1*2"), 2); - CHECK_XPATH_NUMBER(c, STR("1 div 2"), 0.5); - - // operator precedence - CHECK_XPATH_NUMBER(c, STR("2 + 2 * 2 div 1 mod 3"), 3); - CHECK_XPATH_NUMBER(c, STR("2 + 2 * 2 div (1 mod 3)"), 6); - CHECK_XPATH_NUMBER(c, STR("(2 + 2) * 2 div (1 mod 3)"), 8); - CHECK_XPATH_NUMBER(c, STR("(2 + 2) * (2 div 1) mod 3"), 2); - CHECK_XPATH_NUMBER(c, STR("2 - -2"), 4); - CHECK_XPATH_NUMBER(c, STR("2 + -2"), 0); - CHECK_XPATH_NUMBER(c, STR("2--2"), 4); - CHECK_XPATH_NUMBER(c, STR("2+-2"), 0); - CHECK_XPATH_NUMBER(c, STR("1-2-3"), -4); - - // mod, from W3C standard - CHECK_XPATH_NUMBER(c, STR("5 mod 2"), 1); - CHECK_XPATH_NUMBER(c, STR("5 mod -2"), 1); - CHECK_XPATH_NUMBER(c, STR("-5 mod 2"), -1); - CHECK_XPATH_NUMBER(c, STR("-5 mod -2"), -1); -} - -TEST(xpath_operators_arithmetic_specials) -{ - xml_node c; - - // infinity/nan - CHECK_XPATH_STRING(c, STR("1 div 0"), STR("Infinity")); - CHECK_XPATH_STRING(c, STR("-1 div 0"), STR("-Infinity")); - CHECK_XPATH_STRING(c, STR("-1 div 0 + 1 div 0"), STR("NaN")); - CHECK_XPATH_STRING(c, STR("0 div 0"), STR("NaN")); - CHECK_XPATH_STRING(c, STR("1 div 0 + 1 div 0"), STR("Infinity")); - CHECK_XPATH_STRING(c, STR("-1 div 0 + -1 div 0"), STR("-Infinity")); - CHECK_XPATH_STRING(c, STR("1 div 0 + 100"), STR("Infinity")); - CHECK_XPATH_STRING(c, STR("-1 div 0 + 100"), STR("-Infinity")); - CHECK_XPATH_STRING(c, STR("0 div 0 + 100"), STR("NaN")); - - // unary - and multiplication clarifications from recommendations errata - CHECK_XPATH_STRING(c, STR("1 div -0"), STR("-Infinity")); - CHECK_XPATH_STRING(c, STR("-1 div -0"), STR("Infinity")); - CHECK_XPATH_STRING(c, STR("1 div (-0 * 1)"), STR("-Infinity")); - CHECK_XPATH_STRING(c, STR("-1 div (0 * -1)"), STR("Infinity")); - CHECK_XPATH_STRING(c, STR("1 div (-0 div 1)"), STR("-Infinity")); - CHECK_XPATH_STRING(c, STR("-1 div (0 div -1)"), STR("Infinity")); -} - -TEST_XML(xpath_operators_arithmetic_subtraction_parse, "1023") -{ - xml_node n = doc.child(STR("node")); - - // correct subtraction parsing, from W3C standard - CHECK_XPATH_NUMBER(n, STR("foo-bar"), 10); - CHECK_XPATH_NUMBER(n, STR("foo -bar"), -1); - CHECK_XPATH_NUMBER(n, STR("foo - bar"), -1); - CHECK_XPATH_NUMBER(n, STR("-foo-bar"), -10); - CHECK_XPATH_NUMBER(n, STR("-foo -bar"), -5); -} - -TEST(xpath_operators_logical) -{ - xml_node c; - - // boolean arithmetic - CHECK_XPATH_BOOLEAN(c, STR("true() or true()"), true); - CHECK_XPATH_BOOLEAN(c, STR("true() or false()"), true); - CHECK_XPATH_BOOLEAN(c, STR("false() or false()"), false); - CHECK_XPATH_BOOLEAN(c, STR("false() or true()"), true); - - CHECK_XPATH_BOOLEAN(c, STR("true() and true()"), true); - CHECK_XPATH_BOOLEAN(c, STR("true() and false()"), false); - CHECK_XPATH_BOOLEAN(c, STR("false() and false()"), false); - CHECK_XPATH_BOOLEAN(c, STR("false() and true()"), false); - - // boolean conversion - CHECK_XPATH_BOOLEAN(c, STR("1 or ''"), true); - CHECK_XPATH_BOOLEAN(c, STR("1 and ''"), false); - CHECK_XPATH_BOOLEAN(c, STR("0 or ''"), false); - CHECK_XPATH_BOOLEAN(c, STR("0 or 'a'"), true); -} - -TEST(xpath_operators_equality_primitive_boolean) -{ - xml_node c; - - // boolean vs boolan - CHECK_XPATH_BOOLEAN(c, STR("true() = true()"), true); - CHECK_XPATH_BOOLEAN(c, STR("false() = false()"), true); - CHECK_XPATH_BOOLEAN(c, STR("true() != false()"), true); - CHECK_XPATH_BOOLEAN(c, STR("false() != false()"), false); - - // upcast to boolean - CHECK_XPATH_BOOLEAN(c, STR("true() = 2"), true); - CHECK_XPATH_BOOLEAN(c, STR("true() != 2"), false); - CHECK_XPATH_BOOLEAN(c, STR("false() = 2"), false); - CHECK_XPATH_BOOLEAN(c, STR("false() != 2"), true); - CHECK_XPATH_BOOLEAN(c, STR("false() = 0"), true); - CHECK_XPATH_BOOLEAN(c, STR("false() != 0"), false); - - CHECK_XPATH_BOOLEAN(c, STR("2 = true()"), true); - CHECK_XPATH_BOOLEAN(c, STR("2 != true()"), false); - CHECK_XPATH_BOOLEAN(c, STR("2 = false()"), false); - CHECK_XPATH_BOOLEAN(c, STR("2 != false()"), true); - CHECK_XPATH_BOOLEAN(c, STR("0 = false()"), true); - CHECK_XPATH_BOOLEAN(c, STR("0 != false()"), false); -} - -TEST(xpath_operators_equality_primitive_number) -{ - xml_node c; - - // number vs number - CHECK_XPATH_BOOLEAN(c, STR("1 = 1"), true); - CHECK_XPATH_BOOLEAN(c, STR("0.5 = 0.5"), true); - CHECK_XPATH_BOOLEAN(c, STR("1 != 2"), true); - CHECK_XPATH_BOOLEAN(c, STR("1 = -1"), false); - - // infinity/nan - CHECK_XPATH_BOOLEAN(c, STR("1 div 0 = 2 div 0"), true); - CHECK_XPATH_BOOLEAN(c, STR("-1 div 0 != 2 div 0"), true); - -#ifndef MSVC6_NAN_BUG - CHECK_XPATH_BOOLEAN(c, STR("0 div 0 = 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("0 div 0 != 1"), true); - CHECK_XPATH_BOOLEAN(c, STR("0 div 0 = 0 div 0"), false); -#endif - - // upcast to number - CHECK_XPATH_BOOLEAN(c, STR("2 = '2'"), true); - CHECK_XPATH_BOOLEAN(c, STR("2 != '2'"), false); - CHECK_XPATH_BOOLEAN(c, STR("'1' != 2"), true); - CHECK_XPATH_BOOLEAN(c, STR("'1' = 2"), false); -} - -TEST(xpath_operators_equality_primitive_string) -{ - xml_node c; - - // string vs string - CHECK_XPATH_BOOLEAN(c, STR("'a' = 'a'"), true); - CHECK_XPATH_BOOLEAN(c, STR("'a' = 'b'"), false); - CHECK_XPATH_BOOLEAN(c, STR("'ab' != 'a'"), true); - CHECK_XPATH_BOOLEAN(c, STR("'' != 'a'"), true); - CHECK_XPATH_BOOLEAN(c, STR("'a' != ''"), true); - CHECK_XPATH_BOOLEAN(c, STR("'' != ''"), false); -} - -TEST_XML(xpath_operators_equality_node_set_node_set, "abacbdabb") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // node set vs node set - CHECK_XPATH_BOOLEAN(c, STR("x = x"), false); // empty node set compares as false with any other object via any comparison operator, as per XPath spec - CHECK_XPATH_BOOLEAN(c, STR("x != x"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v = c2/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v = c3/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("c2/v = c3/v"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v = c4/v"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v = x"), false); - CHECK_XPATH_BOOLEAN(n, STR("x = c1"), false); - - CHECK_XPATH_BOOLEAN(n, STR("c1/v != c2/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v != c3/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("c2/v != c3/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v != c4/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v != c5/v"), true); // (a, b) != (a, b), since a != b, as per XPath spec (comparison operators are so not intuitive) - CHECK_XPATH_BOOLEAN(n, STR("c3/v != c6/v"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v != x"), false); - CHECK_XPATH_BOOLEAN(n, STR("x != c1/v"), false); -} - -TEST_XML(xpath_operators_equality_node_set_primitive, "1-11001nan") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // node set vs number - CHECK_XPATH_BOOLEAN(c, STR("x = 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("x != 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("1 = x"), false); - CHECK_XPATH_BOOLEAN(c, STR("1 != x"), false); - - CHECK_XPATH_BOOLEAN(n, STR("c1/v = 1"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v = -1"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v != 1"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v = 5"), false); - CHECK_XPATH_BOOLEAN(n, STR("c2/v = 1"), true); - - CHECK_XPATH_BOOLEAN(n, STR("1 = c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("-1 = c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("1 != c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("5 = c1/v"), false); - CHECK_XPATH_BOOLEAN(n, STR("1 = c2/v"), true); - -#ifndef MSVC6_NAN_BUG - CHECK_XPATH_BOOLEAN(n, STR("c2/v != 1"), true); - CHECK_XPATH_BOOLEAN(n, STR("1 != c2/v"), true); -#endif - - // node set vs string - CHECK_XPATH_BOOLEAN(c, STR("x = '1'"), false); - CHECK_XPATH_BOOLEAN(c, STR("x != '1'"), false); - CHECK_XPATH_BOOLEAN(c, STR("'1' = x"), false); - CHECK_XPATH_BOOLEAN(c, STR("'1' != x"), false); - - CHECK_XPATH_BOOLEAN(n, STR("c1/v = '1'"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v = '-1'"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v != '1'"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v = '5'"), false); - CHECK_XPATH_BOOLEAN(n, STR("c2/v = '1'"), true); - CHECK_XPATH_BOOLEAN(n, STR("c2/v != '1'"), true); - - CHECK_XPATH_BOOLEAN(n, STR("'1' = c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("'-1' = c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("'1' != c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("'5' = c1/v"), false); - CHECK_XPATH_BOOLEAN(n, STR("'1' = c2/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("'1' != c2/v"), true); - - // node set vs almost-numeric string just in case - CHECK_XPATH_BOOLEAN(n, STR("c1/v = '1.0'"), false); - - // node set vs boolean - special rules! empty sets are equal to true() - CHECK_XPATH_BOOLEAN(n, STR("x = true()"), false); - CHECK_XPATH_BOOLEAN(n, STR("x != true()"), true); - CHECK_XPATH_BOOLEAN(n, STR("x = false()"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v = true()"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v != true()"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v = false()"), false); - - CHECK_XPATH_BOOLEAN(n, STR("true() = x"), false); - CHECK_XPATH_BOOLEAN(n, STR("true() != x"), true); - CHECK_XPATH_BOOLEAN(n, STR("false() = x"), true); - CHECK_XPATH_BOOLEAN(n, STR("true() = c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("true() != c1/v"), false); - CHECK_XPATH_BOOLEAN(n, STR("false() = c1/v"), false); -} - -TEST(xpath_operators_inequality_primitive) -{ - xml_node c; - - // number vs number - CHECK_XPATH_BOOLEAN(c, STR("1 < 2"), true); - CHECK_XPATH_BOOLEAN(c, STR("1 <= 2"), true); - CHECK_XPATH_BOOLEAN(c, STR("1 > 2"), false); - CHECK_XPATH_BOOLEAN(c, STR("1 >= 2"), false); - - CHECK_XPATH_BOOLEAN(c, STR("1 < 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("1 <= 1"), true); - CHECK_XPATH_BOOLEAN(c, STR("1 > 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("1 >= 1"), true); - - // infinity/nan - CHECK_XPATH_BOOLEAN(c, STR("1 div 0 <= 2 div 0"), true); - CHECK_XPATH_BOOLEAN(c, STR("1 div 0 < 2 div 0"), false); - CHECK_XPATH_BOOLEAN(c, STR("-1 div 0 < 2 div 0"), true); - CHECK_XPATH_BOOLEAN(c, STR("-1 div 0 > 2 div 0"), false); - -#ifndef MSVC6_NAN_BUG - CHECK_XPATH_BOOLEAN(c, STR("0 div 0 < 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("0 div 0 <= 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("0 div 0 > 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("0 div 0 >= 1"), false); -#endif - - // upcast to number - CHECK_XPATH_BOOLEAN(c, STR("2 < '2'"), false); - CHECK_XPATH_BOOLEAN(c, STR("1 < '2'"), true); - CHECK_XPATH_BOOLEAN(c, STR("2 <= '2'"), true); - CHECK_XPATH_BOOLEAN(c, STR("3 <= '2'"), false); - CHECK_XPATH_BOOLEAN(c, STR("2 > '2'"), false); - CHECK_XPATH_BOOLEAN(c, STR("3 > '2'"), true); - CHECK_XPATH_BOOLEAN(c, STR("2 >= '2'"), true); - CHECK_XPATH_BOOLEAN(c, STR("3 >= '2'"), true); - CHECK_XPATH_BOOLEAN(c, STR("1 >= true()"), true); - CHECK_XPATH_BOOLEAN(c, STR("1 > true()"), false); -} - -TEST_XML(xpath_operators_inequality_node_set_node_set, "1-1-1001nan1-4") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // node set vs node set - CHECK_XPATH_BOOLEAN(c, STR("x < x"), false); - CHECK_XPATH_BOOLEAN(c, STR("x > x"), false); - CHECK_XPATH_BOOLEAN(c, STR("x <= x"), false); - CHECK_XPATH_BOOLEAN(c, STR("x >= x"), false); - - CHECK_XPATH_BOOLEAN(n, STR("c1/v > x"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v < x"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v >= x"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v <= x"), false); - - CHECK_XPATH_BOOLEAN(n, STR("x > c1/v"), false); - CHECK_XPATH_BOOLEAN(n, STR("x < c1/v"), false); - CHECK_XPATH_BOOLEAN(n, STR("x >= c1/v"), false); - CHECK_XPATH_BOOLEAN(n, STR("x <= c1/v"), false); - - CHECK_XPATH_BOOLEAN(n, STR("c1/v > c3/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v >= c3/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v < c3/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v <= c3/v"), true); - - CHECK_XPATH_BOOLEAN(n, STR("c1/v[1] > c1/v[1]"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v[1] < c1/v[1]"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v[1] >= c1/v[1]"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v[1] <= c1/v[1]"), true); - -#ifndef MSVC6_NAN_BUG - CHECK_XPATH_BOOLEAN(n, STR("c1/v > c2/v"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v >= c2/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v < c2/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v <= c2/v"), true); - - CHECK_XPATH_BOOLEAN(n, STR("c2/v[2] < c2/v[2]"), false); - CHECK_XPATH_BOOLEAN(n, STR("c2/v[2] > c2/v[2]"), false); - CHECK_XPATH_BOOLEAN(n, STR("c2/v[2] <= c2/v[2]"), false); - CHECK_XPATH_BOOLEAN(n, STR("c2/v[2] >= c2/v[2]"), false); -#endif -} - -TEST_XML(xpath_operators_inequality_node_set_primitive, "1-1-1001nan") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // node set vs number - CHECK_XPATH_BOOLEAN(c, STR("x < 0"), false); - CHECK_XPATH_BOOLEAN(c, STR("x > 0"), false); - CHECK_XPATH_BOOLEAN(c, STR("x <= 0"), false); - CHECK_XPATH_BOOLEAN(c, STR("x >= 0"), false); - - CHECK_XPATH_BOOLEAN(c, STR("0 < x"), false); - CHECK_XPATH_BOOLEAN(c, STR("0 > x"), false); - CHECK_XPATH_BOOLEAN(c, STR("0 <= x"), false); - CHECK_XPATH_BOOLEAN(c, STR("0 >= x"), false); - - CHECK_XPATH_BOOLEAN(n, STR("c1/v > 0"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v > 1"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v >= 0"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v < 0"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v <= 0"), true); - - CHECK_XPATH_BOOLEAN(n, STR("0 < c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("1 < c1/v"), false); - CHECK_XPATH_BOOLEAN(n, STR("0 <= c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("0 > c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("0 >= c1/v"), true); - - // node set vs string - CHECK_XPATH_BOOLEAN(n, STR("c1/v > '0'"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v > '1'"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v >= '0'"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v < '0'"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v <= '0'"), true); - - CHECK_XPATH_BOOLEAN(n, STR("'0' < c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("'1' < c1/v"), false); - CHECK_XPATH_BOOLEAN(n, STR("'0' <= c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("'0' > c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("'0' >= c1/v"), true); - - // node set vs boolean - CHECK_XPATH_BOOLEAN(n, STR("c1/v > false()"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v > true()"), false); - CHECK_XPATH_BOOLEAN(n, STR("c1/v >= false()"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v < false()"), true); - CHECK_XPATH_BOOLEAN(n, STR("c1/v <= false()"), true); - - CHECK_XPATH_BOOLEAN(n, STR("false() < c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("true() < c1/v"), false); - CHECK_XPATH_BOOLEAN(n, STR("false() <= c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("false() > c1/v"), true); - CHECK_XPATH_BOOLEAN(n, STR("false() >= c1/v"), true); -} - -TEST(xpath_operators_boolean_precedence) -{ - xml_node c; - - CHECK_XPATH_BOOLEAN(c, STR("1 = 0 or 2 = 2"), true); - CHECK_XPATH_BOOLEAN(c, STR("1 = (0 or 2) = false()"), false); - CHECK_XPATH_BOOLEAN(c, STR("1 < 0 or 2 > 2"), false); - CHECK_XPATH_BOOLEAN(c, STR("2 < 1 = false()"), true); - CHECK_XPATH_BOOLEAN(c, STR("2 < (1 = false())"), false); - CHECK_XPATH_BOOLEAN(c, STR("3 > 2 > 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("(3 > 2) > 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("3 > (2 > 1)"), true); -} - -TEST_XML(xpath_operators_union, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(n, STR("employee | .")) % 2 % 3 % 4 % 6 % 8 % 11; - CHECK_XPATH_NODESET(n, STR("employee[@secretary] | employee[@assistant]")) % 4 % 6 % 8 % 11; - CHECK_XPATH_NODESET(n, STR("employee[@assistant] | employee[@secretary]")) % 4 % 6 % 8 % 11; - CHECK_XPATH_NODESET(n, STR("employee[@secretary] | employee[@nobody]")) % 4 % 8 % 11; - CHECK_XPATH_NODESET(n, STR("employee[@nobody] | employee[@secretary]")) % 4 % 8 % 11; - CHECK_XPATH_NODESET(n, STR("tail/preceding-sibling::employee | .")) % 2 % 3 % 4 % 6 % 8 % 11; - CHECK_XPATH_NODESET(n, STR(". | tail/preceding-sibling::employee | .")) % 2 % 3 % 4 % 6 % 8 % 11; -} - -TEST_XML(xpath_operators_union_order, "") -{ - xml_node n = doc.child(STR("node")); - - n.append_child(STR("c")); - n.prepend_child(STR("b")); - n.append_child(STR("d")); - n.prepend_child(STR("a")); - - xpath_node_set ns = n.select_nodes(STR("d | d | b | c | b | a | c | d | b")); - - CHECK(ns.size() == 4); - CHECK_STRING(ns[0].node().name(), STR("d")); - CHECK_STRING(ns[1].node().name(), STR("b")); - CHECK_STRING(ns[2].node().name(), STR("c")); - CHECK_STRING(ns[3].node().name(), STR("a")); -} - -TEST(xpath_operators_union_error) -{ - CHECK_XPATH_FAIL(STR(". | true()")); - CHECK_XPATH_FAIL(STR(". | 1")); - CHECK_XPATH_FAIL(STR(". | '1'")); - CHECK_XPATH_FAIL(STR(". | count(.)")); - CHECK_XPATH_FAIL(STR("true() | .")); - CHECK_XPATH_FAIL(STR("1 | .")); - CHECK_XPATH_FAIL(STR("'1' | .")); - CHECK_XPATH_FAIL(STR("count(.) | .")); -} - -TEST_XML(xpath_operators_union_minus, "34") -{ - CHECK_XPATH_FAIL(STR("(-node1) | node2")); - CHECK_XPATH_FAIL(STR("node1 | -node2")); - CHECK_XPATH_NUMBER(doc, STR("-(node1 | node2)"), -3); - CHECK_XPATH_NUMBER(doc, STR("-node1 | node2"), -3); - CHECK_XPATH_NUMBER(doc, STR("--node1 | node2"), 3); - CHECK_XPATH_NUMBER(doc, STR("-(-node1 | node2)"), 3); - CHECK_XPATH_NUMBER(doc, STR("--(-node1 | node2)"), -3); -} - -TEST(xpath_operators_associativity_boolean) -{ - xml_node c; - - CHECK_XPATH_BOOLEAN(c, STR("false() or true() and true() and false()"), false); - CHECK_XPATH_BOOLEAN(c, STR("3 > 2 > 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("4 > 3 > 2 > 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("5 > 4 > 3 > 2 > 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("1 < 2 < 3 < 4 < 5"), true); - CHECK_XPATH_BOOLEAN(c, STR("1 <= 2 <= 3 <= 4 <= 5"), true); - CHECK_XPATH_BOOLEAN(c, STR("5 >= 4 >= 3 >= 2 >= 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("3 >= 2 >= 1"), true); - CHECK_XPATH_BOOLEAN(c, STR("2 >= 1"), true); - CHECK_XPATH_BOOLEAN(c, STR("4 >= 3 >= 2 >= 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("((((5 > 4) > 3) > 2) > 1)"), false); - CHECK_XPATH_BOOLEAN(c, STR("2 != 3 != 1 != 4 != 0"), true); - CHECK_XPATH_BOOLEAN(c, STR("(((2 != 3) != 1) != 4) != 0"), true); - CHECK_XPATH_BOOLEAN(c, STR("2 != 3 != 1 != 4 != 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("(((2 != 3) != 1) != 4) != 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("2 = 3 = 1 = 4 = 0"), true); - CHECK_XPATH_BOOLEAN(c, STR("(((2 = 3) = 1) = 4) = 0"), true); - CHECK_XPATH_BOOLEAN(c, STR("2 = 3 = 1 = 4 = 1"), false); - CHECK_XPATH_BOOLEAN(c, STR("(((2 = 3) = 1) = 4) = 1"), false); -} - -TEST(xpath_operators_associativity_arithmetic) -{ - xml_node c; - - CHECK_XPATH_NUMBER(c, STR("2+1-1+1"), 3); - CHECK_XPATH_NUMBER(c, STR("1+2+1-1+1"), 4); - CHECK_XPATH_NUMBER(c, STR("1+1+2+1-1+1"), 5); - CHECK_XPATH_NUMBER(c, STR("1-1+1"), 1); -} - -TEST(xpath_operators_mod) -{ - // Check that mod operator conforms to Java spec (since this is the only concrete source of information about XPath mod) - xml_node c; - - // Basic tests from spec - CHECK_XPATH_NUMBER(c, STR("5 mod 3"), 2); - CHECK_XPATH_NUMBER(c, STR("5 mod -3"), 2); - CHECK_XPATH_NUMBER(c, STR("-5 mod 3"), -2); - CHECK_XPATH_NUMBER(c, STR("-5 mod -3"), -2); - -#if !defined(__BORLANDC__) - // If either operand is NaN, the result is NaN - CHECK_XPATH_NUMBER_NAN(c, STR("(0 div 0) mod 3")); - CHECK_XPATH_NUMBER_NAN(c, STR("3 mod (0 div 0)")); - CHECK_XPATH_NUMBER_NAN(c, STR("(0 div 0) mod (0 div 0)")); - - // If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN - CHECK_XPATH_NUMBER_NAN(c, STR("(1 div 0) mod 3")); - CHECK_XPATH_NUMBER_NAN(c, STR("(1 div 0) mod -3")); - CHECK_XPATH_NUMBER_NAN(c, STR("(-1 div 0) mod 3")); - CHECK_XPATH_NUMBER_NAN(c, STR("1 mod 0")); - CHECK_XPATH_NUMBER_NAN(c, STR("-1 mod 0")); - CHECK_XPATH_NUMBER_NAN(c, STR("(1 div 0) mod 0")); - CHECK_XPATH_NUMBER_NAN(c, STR("(-1 div 0) mod 0")); -#endif - - // If the dividend is finite and the divisor is an infinity, the result equals the dividend -#if !defined(_MSC_VER) && !defined(__MINGW32__) - CHECK_XPATH_NUMBER(c, STR("1 mod (1 div 0)"), 1); - CHECK_XPATH_NUMBER(c, STR("1 mod (-1 div 0)"), 1); - CHECK_XPATH_NUMBER(c, STR("-1 mod (1 div 0)"), -1); - CHECK_XPATH_NUMBER(c, STR("0 mod (1 div 0)"), 0); - CHECK_XPATH_NUMBER(c, STR("0 mod (-1 div 0)"), 0); - CHECK_XPATH_NUMBER(c, STR("100000 mod (1 div 0)"), 100000); -#endif - - // If the dividend is a zero and the divisor is finite, the result equals the dividend. - CHECK_XPATH_NUMBER(c, STR("0 mod 1000000"), 0); - CHECK_XPATH_NUMBER(c, STR("0 mod -1000000"), 0); - - // In the remaining cases ... the floating-point remainder r from the division of a dividend n by a divisor d - // is defined by the mathematical relation r = n - (d * q) where q is an integer that is negative only if n/d is - // negative and positive only if n/d is positive, and whose magnitude is as large as possible without exceeding the magnitude of the true - // mathematical quotient of n and d. - CHECK_XPATH_NUMBER(c, STR("9007199254740991 mod 2"), 1); - CHECK_XPATH_NUMBER(c, STR("9007199254740991 mod 3"), 1); - CHECK_XPATH_NUMBER(c, STR("18446744073709551615 mod 2"), 0); - CHECK_XPATH_NUMBER(c, STR("18446744073709551615 mod 3"), 1); - CHECK_XPATH_NUMBER(c, STR("115792089237316195423570985008687907853269984665640564039457584007913129639935 mod 2"), 0); - CHECK_XPATH_NUMBER(c, STR("115792089237316195423570985008687907853269984665640564039457584007913129639935 mod 3"), 1); -} -#endif diff --git a/external/pugixml/tests/test_xpath_parse.cpp b/external/pugixml/tests/test_xpath_parse.cpp deleted file mode 100644 index daa12bf2f..000000000 --- a/external/pugixml/tests/test_xpath_parse.cpp +++ /dev/null @@ -1,392 +0,0 @@ -#ifndef PUGIXML_NO_XPATH - -#include "test.hpp" - -#include - -using namespace pugi; - -TEST(xpath_literal_parse) -{ - xml_node c; - CHECK_XPATH_STRING(c, STR("'a\"b'"), STR("a\"b")); - CHECK_XPATH_STRING(c, STR("\"a'b\""), STR("a'b")); - CHECK_XPATH_STRING(c, STR("\"\""), STR("")); - CHECK_XPATH_STRING(c, STR("\'\'"), STR("")); -} - -TEST(xpath_literal_error) -{ - CHECK_XPATH_FAIL(STR("\"")); - CHECK_XPATH_FAIL(STR("\"foo")); - CHECK_XPATH_FAIL(STR("\'")); - CHECK_XPATH_FAIL(STR("\'bar")); -} - -TEST(xpath_number_parse) -{ - xml_node c; - CHECK_XPATH_NUMBER(c, STR("0"), 0); - CHECK_XPATH_NUMBER(c, STR("123"), 123); - CHECK_XPATH_NUMBER(c, STR("123.456"), 123.456); - CHECK_XPATH_NUMBER(c, STR(".123"), 0.123); - CHECK_XPATH_NUMBER(c, STR("123.4567890123456789012345"), 123.4567890123456789012345); - CHECK_XPATH_NUMBER(c, STR("123."), 123); -} - -TEST(xpath_number_error) -{ - CHECK_XPATH_FAIL(STR("123a")); - CHECK_XPATH_FAIL(STR("123.a")); - CHECK_XPATH_FAIL(STR(".123a")); -} - -TEST(xpath_variables) -{ - CHECK_XPATH_FAIL(STR("$var")); // no variable var - CHECK_XPATH_FAIL(STR("$1")); - CHECK_XPATH_FAIL(STR("$")); -} - -TEST(xpath_empty_expression) -{ - CHECK_XPATH_FAIL(STR("")); -} - -TEST(xpath_lexer_error) -{ - CHECK_XPATH_FAIL(STR("!")); - CHECK_XPATH_FAIL(STR("&")); -} - -TEST(xpath_unmatched_braces) -{ - CHECK_XPATH_FAIL(STR("node[")); - CHECK_XPATH_FAIL(STR("node[1")); - CHECK_XPATH_FAIL(STR("node[]]")); - CHECK_XPATH_FAIL(STR("node(")); - CHECK_XPATH_FAIL(STR("node(()")); - CHECK_XPATH_FAIL(STR("(node)[1")); - CHECK_XPATH_FAIL(STR("(1")); -} - -TEST(xpath_incorrect_step) -{ - CHECK_XPATH_FAIL(STR("child::1")); - CHECK_XPATH_FAIL(STR("something::*")); - CHECK_XPATH_FAIL(STR("a::*")); - CHECK_XPATH_FAIL(STR("c::*")); - CHECK_XPATH_FAIL(STR("d::*")); - CHECK_XPATH_FAIL(STR("f::*")); - CHECK_XPATH_FAIL(STR("n::*")); - CHECK_XPATH_FAIL(STR("p::*")); -} - -TEST(xpath_semantics_error) -{ - CHECK_XPATH_FAIL(STR("1[1]")); - CHECK_XPATH_FAIL(STR("1 | 1")); -} - -TEST(xpath_semantics_posinv) // coverage for contains() -{ - xpath_query(STR("(node)[substring(1, 2, 3)]")); - xpath_query(STR("(node)[concat(1, 2, 3, 4)]")); - xpath_query(STR("(node)[count(foo)]")); - xpath_query(STR("(node)[local-name()]")); - xpath_query(STR("(node)[(node)[1]]")); -} - -TEST(xpath_parse_paths_valid) -{ - const char_t* paths[] = - { - // From Jaxen tests - STR("foo[.='bar']"), STR("foo[.!='bar']"), STR("/"), STR("*"), STR("//foo"), STR("/*"), STR("/."), STR("/foo[/bar[/baz]]"), - STR("/foo/bar/baz[(1 or 2) + 3 * 4 + 8 and 9]"), STR("/foo/bar/baz"), STR("(.)[1]"), STR("self::node()"), STR("."), STR("count(/)"), - STR("foo[1]"), STR("/baz[(1 or 2) + 3 * 4 + 8 and 9]"), STR("foo/bar[/baz[(1 or 2) - 3 mod 4 + 8 and 9 div 8]]"), - STR("foo/bar/yeah:baz[a/b/c and toast]"), STR("/foo/bar[../x='123']"), STR("/foo[@bar='1234']"), STR("foo|bar"), - STR("/foo|/bar[@id='1234']"), STR("count(//author/attribute::*)"), STR("/child::node()/child::node()[@id='_13563275']"), - STR("10 + (count(descendant::author) * 5)"), STR("10 + count(descendant::author) * 5"), STR("2 + (2 * 5)"), STR("//foo:bar"), - STR("count(//author)+5"), STR("count(//author)+count(//author/attribute::*)"), STR("/foo/bar[@a='1' and @c!='2']"), - STR("12 + (count(//author)+count(//author/attribute::*)) div 2"), STR("text()[.='foo']"), STR("/*/*[@id='123']") - STR("/foo/bar[@a='1' and @b='2']"), STR("/foo/bar[@a='1' and @b!='2']"), STR("//attribute::*[.!='crunchy']"), - STR("'//*[contains(string(text()),\"yada yada\")]'"), - - // From ajaxslt tests - STR("@*"), STR("@*|node()"), STR("/descendant-or-self::div"), STR("/div"), STR("//div"), STR("/descendant-or-self::node()/child::para"), - STR("substring('12345', 0, 3)"), STR("//title | //link"), STR("x//title"), STR("x/title"), STR("id('a')//title"), STR("//*[@about]"), - STR("count(descendant::*)"), STR("count(descendant::*) + count(ancestor::*)"), STR("@*|text()"), STR("*|/"), STR("source|destination"), - STR("page != 'to' and page != 'from'"), STR("substring-after(icon/@image, '/mapfiles/marker')"), STR("substring-before(str, c)"), STR("page = 'from'"), - STR("segments/@time"), STR("child::para"), STR("child::*"), STR("child::text()"), STR("child::node()"), STR("attribute::name"), STR("attribute::*"), - STR("descendant::para"), STR("ancestor::div"), STR("ancestor-or-self::div"), STR("descendant-or-self::para"), STR("self::para"), STR("child::*/child::para"), - STR("concat(substring-before(@image,'marker'),'icon',substring-after(@image,'marker'))"), STR("/"), STR("/descendant::para"), STR("/descendant::olist/child::item"), - STR("child::para[position()=1]"), STR("child::para[position()=last()]"), STR("child::para[position()=last()-1]"), STR("child::para[position()>1]"), - STR("following-sibling::chapter[position()=1]"), STR("preceding-sibling::chapter[position()=1]"), STR("/descendant::figure[position()=42]"), - STR("/child::doc/child::chapter[position()=5]/child::section[position()=2]"), STR("child::chapter/descendant::para"), STR("child::para[attribute::type='warning']"), - STR("child::para[attribute::type='warning'][position()=5]"), STR("child::para[position()=5][attribute::type='warning']"), STR("child::chapter[child::title='Introduction']"), - STR("child::chapter[child::title]"), STR("child::*[self::chapter or self::appendix]"), STR("child::*[self::chapter or self::appendix][position()=last()]"), - STR("count(//*[id='u1']|//*[id='u2'])"), STR("count(//*[id='u1']|//*[class='u'])"), STR("count(//*[class='u']|//*[class='u'])"), STR("count(//*[class='u']|//*[id='u1'])"), - STR("count(//*[@id='self']/ancestor-or-self::*)"), STR("count(//*[@id='self']/ancestor::*)"), STR("count(//*[@id='self']/attribute::*)"), STR("count(//*[@id='self']/child::*)"), - STR("count(//*[@id='self']/descendant-or-self::*)"), STR("count(//*[@id='self']/descendant::*)"), STR("count(//*[@id='self']/following-sibling::*)"), - STR("count(//*[@id='self']/following::*)"), STR("//*[@id='self']/parent::*/@id"), STR("count(//*[@id='self']/preceding-sibling::*)"), - STR("count(//*[@id='self']/preceding::*)"), STR("//*[@id='self']/self::*/@id"), STR("id('nested1')/div[1]//input[2]"), STR("id('foo')//div[contains(@id, 'useful')]//input"), - STR("(//table[@class='stylee'])//th[text()='theHeaderText']/../td"), STR("address"), STR("address=string(/page/user/defaultlocation)"), STR("count-of-snippet-of-url = 0"), - STR("daddr"), STR("form"), STR("form = 'from'"), STR("form = 'to'"), STR("form='near'"), STR("home"), STR("i"), STR("i > page and i < page + range"), - STR("i < page and i >= page - range"), STR("i < @max"), STR("i <= page"), STR("i + 1"), STR("i = page"), STR("i = 1"), STR("info = position() or (not(info) and position() = 1)"), - STR("is-first-order"), STR("is-first-order and snippets-exist"), STR("more"), STR("more > 0"), STR("near-point"), STR("page"), STR("page != 'from'"), STR("page != 'to'"), - STR("page != 'to' and page != 'from'"), STR("page > 1"), STR("page = 'basics'"), STR("page = 'details'"), STR("page = 'from'"), STR("page = 'to'"), STR("page='from'"), - STR("page='to'"), STR("r >= 0.5"), STR("r >= 1"), STR("r - 0"), STR("r - 1"), STR("r - 2"), STR("r - 3"), STR("r - 4"), STR("saddr"), STR("sources"), STR("sources[position() < details]"), - STR("src"), STR("str"), STR("\"'\""), STR("(//location[string(info/references/reference[1]/url)=string(current-url)]/info/references/reference[1])[1]"), - STR("(not(count-of-snippet-of-url = 0) and (position() = 1) or not(current-url = //locations/location[position() = last-pos]//reference[1]/url))"), - STR("(not(info) and position() = 1) or info = position()"), STR("."), STR("../@arg0"), STR("../@filterpng"), STR("/page/@filterpng"), STR("4"), STR("@attribution"), - STR("@id"), STR("@max > @num"), STR("@meters > 16093"), STR("@name"), STR("@start div @num + 1"), STR("@url"), STR("ad"), STR("address/line"), STR("adsmessage"), - STR("attr"), STR("boolean(location[@id='near'][icon/@image])"), STR("bubble/node()"), STR("calltoaction/node()"), STR("category"), STR("contains(str, c)"), - STR("count(//location[string(info/references/reference[1]/url)=string(current-url)]//snippet)"), STR("count(//snippet)"), STR("count(attr)"), STR("count(location)"), - STR("count(structured/source) > 1"), STR("description/node()"), STR("destination"), STR("destinationAddress"), STR("domain"), STR("false()"), STR("icon/@class != 'noicon'"), - STR("icon/@image"), STR("info"), STR("info/address/line"), STR("info/distance"), STR("info/distance and near-point"), STR("info/distance and info/phone and near-point"), - STR("info/distance or info/phone"), STR("info/panel/node()"), STR("info/phone"), STR("info/references/reference[1]"), STR("info/references/reference[1]/snippet"), - STR("info/references/reference[1]/url"), STR("info/title"), STR("info/title/node()"), STR("line"), STR("location"), STR("location[@id!='near']"), STR("location[@id='near'][icon/@image]"), - STR("location[position() > umlocations div 2]"), STR("location[position() <= numlocations div 2]"), STR("locations"), STR("locations/location"), STR("near"), STR("node()"), - STR("not(count-of-snippets = 0)"), STR("not(form = 'from')"), STR("not(form = 'near')"), STR("not(form = 'to')"), STR("not(../@page)"), STR("not(structured/source)"), STR("notice"), - STR("number(../@info)"), STR("number(../@items)"), STR("number(/page/@linewidth)"), STR("page/ads"), STR("page/directions"), STR("page/error"), STR("page/overlay"), - STR("page/overlay/locations/location"), STR("page/refinements"), STR("page/request/canonicalnear"), STR("page/request/near"), STR("page/request/query"), STR("page/spelling/suggestion"), - STR("page/user/defaultlocation"), STR("phone"), STR("position()"), STR("position() != 1"), STR("position() != last()"), STR("position() > 1"), STR("position() < details"), - STR("position()-1"), STR("query"), STR("references/@total"), STR("references/reference"), STR("references/reference/domain"), STR("references/reference/url"), - STR("reviews/@positive div (reviews/@positive + reviews/@negative) * 5"), STR("reviews/@positive div (reviews/@positive + reviews/@negative) * (5)"), STR("reviews/@total"), - STR("reviews/@total > 1"), STR("reviews/@total > 5"), STR("reviews/@total = 1"), STR("segments/@distance"), STR("segments/@time"), STR("segments/segment"), STR("shorttitle/node()"), - STR("snippet"), STR("snippet/node()"), STR("source"), STR("sourceAddress"), STR("sourceAddress and destinationAddress"), STR("string(../@daddr)"), STR("string(../@form)"), - STR("string(../@page)"), STR("string(../@saddr)"), STR("string(info/title)"), STR("string(page/request/canonicalnear) != ''"), STR("string(page/request/near) != ''"), - STR("string-length(address) > linewidth"), STR("structured/@total - details"), STR("structured/source"), STR("structured/source[@name]"), STR("substring(address, 1, linewidth - 3)"), - STR("substring-after(str, c)"), STR("substring-after(icon/@image, '/mapfiles/marker')"), STR("substring-before(str, c)"), STR("tagline/node()"), STR("targetedlocation"), - STR("title"), STR("title/node()"), STR("true()"), STR("url"), STR("visibleurl"), STR("id(\"level10\")/ancestor::SPAN"), STR("id(\"level10\")/ancestor-or-self::SPAN"), STR("//attribute::*"), - STR("child::HTML/child::BODY/child::H1"), STR("descendant::node()"), STR("descendant-or-self::SPAN"), STR("id(\"first\")/following::text()"), STR("id(\"first\")/following-sibling::node()"), - STR("id(\"level10\")/parent::node()"), STR("id(\"last\")/preceding::text()"), STR("id(\"last\")/preceding-sibling::node()"), STR("/HTML/BODY/H1/self::node()"), STR("//*[@name]"), - STR("id(\"pet\")/SELECT[@name=\"species\"]/OPTION[@selected]/@value"), STR("descendant::INPUT[@name=\"name\"]/@value"), STR("id(\"pet\")/INPUT[@name=\"gender\" and @checked]/@value"), - STR("//TEXTAREA[@name=\"description\"]/text()"), STR("id(\"div1\")|id(\"div2\")|id(\"div3 div4 div5\")"), STR("//LI[1]"), STR("//LI[last()]/text()"), STR("//LI[position() mod 2]/@class"), - STR("//text()[.=\"foo\"]"), STR("descendant-or-self::SPAN[position() > 2]"), STR("descendant::*[contains(@class,\" fruit \")]"), - - // ajaxslt considers this path invalid, however I believe it's valid as per spec - STR("***"), - - // Oasis MSFT considers this path invalid, however I believe it's valid as per spec - STR("**..**"), - - // Miscellaneous - STR("..***..***.***.***..***..***..") - }; - - for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); ++i) - { - xpath_query q(paths[i]); - } -} - -#if defined(PUGIXML_WCHAR_MODE) || !defined(PUGIXML_NO_STL) -TEST(xpath_parse_paths_valid_unicode) -{ - // From ajaxslt - const wchar_t* paths[] = - { - #ifdef U_LITERALS - L"/descendant-or-self::\u90e8\u5206", L"//\u90e8\u5206", L"substring('\uff11\uff12\uff13\uff14\uff15', 0, 3)", L"//\u30bf\u30a4\u30c8\u30eb | //\u30ea\u30f3\u30af", - L"\u8b0e//\u30bf\u30a4\u30c8\u30eb", L"//*[@\u30c7\u30b9\u30c6\u30a3\u30cd\u30a4\u30b7\u30e7\u30f3]", L"\u30da\u30fc\u30b8 = '\u304b\u3089'", - L"concat(substring-before(@\u30a4\u30e1\u30fc\u30b8,'\u76ee\u5370'),'\u30a2\u30a4\u30b3\u30f3',substring-after(@\u30a4\u30e1\u30fc\u30b8,'\u76ee\u5370'))", - L"\u30bd\u30fc\u30b9|\u30c7\u30b9\u30c6\u30a3\u30cd\u30a4\u30b7\u30e7\u30f3", L"\u30da\u30fc\u30b8 != '\u307e\u3067' and \u30da\u30fc\u30b8 != '\u304b\u3089'", - L"substring-after(\u30a2\u30a4\u30b3\u30f3/@\u30a4\u30e1\u30fc\u30b8, '/\u5730\u56f3\u30d5\u30a1\u30a4\u30eb/\u76ee\u5370')", L"child::\u6bb5\u843d", - L"substring-before(\u6587\u5b57\u5217, \u6587\u5b57)", L"\u30bb\u30b0\u30e1\u30f3\u30c8/@\u6642\u523b", L"attribute::\u540d\u524d", L"descendant::\u6bb5\u843d", - L"ancestor::\u90e8\u5206", L"ancestor-or-self::\u90e8\u5206", L"descendant-or-self::\u6bb5\u843d", L"self::\u6bb5\u843d", L"child::\u7ae0/descendant::\u6bb5\u843d", - L"child::*/child::\u6bb5\u843d", L"/descendant::\u6bb5\u843d", L"/descendant::\u9806\u5e8f\u30ea\u30b9\u30c8/child::\u9805\u76ee", L"child::\u6bb5\u843d[position()=1]", - L"child::\u6bb5\u843d[position()=last()]", L"child::\u6bb5\u843d[position()=last()-1]", L"child::\u6bb5\u843d[position()>1]", L"following-sibling::\u7ae0[position()=1]", - L"preceding-sibling::\u7ae0[position()=1]", L"/descendant::\u56f3\u8868[position()=42]", L"/child::\u6587\u66f8/child::\u7ae0[position()=5]/child::\u7bc0[position()=2]", - L"child::\u6bb5\u843d[attribute::\u30bf\u30a4\u30d7='\u8b66\u544a']", L"child::\u6bb5\u843d[attribute::\u30bf\u30a4\u30d7='\u8b66\u544a'][position()=5]", - L"child::\u6bb5\u843d[position()=5][attribute::\u30bf\u30a4\u30d7='\u8b66\u544a']", L"child::\u7ae0[child::\u30bf\u30a4\u30c8\u30eb='\u306f\u3058\u3081\u306b']", - L"child::\u7ae0[child::\u30bf\u30a4\u30c8\u30eb]", L"child::*[self::\u7ae0 or self::\u4ed8\u9332]", L"child::*[self::\u7ae0 or self::\u4ed8\u9332][position()=last()]", - #else - L"/descendant-or-self::\x90e8\x5206", L"//\x90e8\x5206", L"substring('\xff11\xff12\xff13\xff14\xff15', 0, 3)", L"//\x30bf\x30a4\x30c8\x30eb | //\x30ea\x30f3\x30af", - L"\x8b0e//\x30bf\x30a4\x30c8\x30eb", L"//*[@\x30c7\x30b9\x30c6\x30a3\x30cd\x30a4\x30b7\x30e7\x30f3]", L"\x30da\x30fc\x30b8 = '\x304b\x3089'", - L"concat(substring-before(@\x30a4\x30e1\x30fc\x30b8,'\x76ee\x5370'),'\x30a2\x30a4\x30b3\x30f3',substring-after(@\x30a4\x30e1\x30fc\x30b8,'\x76ee\x5370'))", - L"\x30bd\x30fc\x30b9|\x30c7\x30b9\x30c6\x30a3\x30cd\x30a4\x30b7\x30e7\x30f3", L"\x30da\x30fc\x30b8 != '\x307e\x3067' and \x30da\x30fc\x30b8 != '\x304b\x3089'", - L"substring-after(\x30a2\x30a4\x30b3\x30f3/@\x30a4\x30e1\x30fc\x30b8, '/\x5730\x56f3\x30d5\x30a1\x30a4\x30eb/\x76ee\x5370')", L"child::\x6bb5\x843d", - L"substring-before(\x6587\x5b57\x5217, \x6587\x5b57)", L"\x30bb\x30b0\x30e1\x30f3\x30c8/@\x6642\x523b", L"attribute::\x540d\x524d", L"descendant::\x6bb5\x843d", - L"ancestor::\x90e8\x5206", L"ancestor-or-self::\x90e8\x5206", L"descendant-or-self::\x6bb5\x843d", L"self::\x6bb5\x843d", L"child::\x7ae0/descendant::\x6bb5\x843d", - L"child::*/child::\x6bb5\x843d", L"/descendant::\x6bb5\x843d", L"/descendant::\x9806\x5e8f\x30ea\x30b9\x30c8/child::\x9805\x76ee", L"child::\x6bb5\x843d[position()=1]", - L"child::\x6bb5\x843d[position()=last()]", L"child::\x6bb5\x843d[position()=last()-1]", L"child::\x6bb5\x843d[position()>1]", L"following-sibling::\x7ae0[position()=1]", - L"preceding-sibling::\x7ae0[position()=1]", L"/descendant::\x56f3\x8868[position()=42]", L"/child::\x6587\x66f8/child::\x7ae0[position()=5]/child::\x7bc0[position()=2]", - L"child::\x6bb5\x843d[attribute::\x30bf\x30a4\x30d7='\x8b66\x544a']", L"child::\x6bb5\x843d[attribute::\x30bf\x30a4\x30d7='\x8b66\x544a'][position()=5]", - L"child::\x6bb5\x843d[position()=5][attribute::\x30bf\x30a4\x30d7='\x8b66\x544a']", L"child::\x7ae0[child::\x30bf\x30a4\x30c8\x30eb='\x306f\x3058\x3081\x306b']", - L"child::\x7ae0[child::\x30bf\x30a4\x30c8\x30eb]", L"child::*[self::\x7ae0 or self::\x4ed8\x9332]", L"child::*[self::\x7ae0 or self::\x4ed8\x9332][position()=last()]", - #endif - }; - - for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); ++i) - { - #if defined(PUGIXML_WCHAR_MODE) - xpath_query q(paths[i]); - #elif !defined(PUGIXML_NO_STL) - std::basic_string path_utf8 = as_utf8(paths[i]); - xpath_query q(path_utf8.c_str()); - #endif - } -} -#endif - -TEST(xpath_parse_invalid) -{ - const char_t* paths[] = - { - // From Jaxen tests - STR("//:p"), STR("/foo/bar/"), STR("12 + (count(//author)+count(//author/attribute::*)) / 2"), STR("id()/2"), STR("+"), - STR("///triple slash"), STR("/numbers numbers"), STR("/a/b[c > d]efg"), STR("/inv/child::"), STR("/invoice/@test[abcd"), - STR("/invoice/@test[abcd > x"), STR("string-length('a"), STR("/descendant::()"), STR("(1 + 1"), STR("!false()"), - STR("$author"), STR("10 + $foo"), STR("$foo:bar"), STR("$varname[@a='1']"), STR("foo/$variable/foo"), - STR(".[1]"), STR("chyld::foo"), STR("foo/tacos()"), STR("foo/tacos()"), STR("/foo/bar[baz"), STR("//"), STR("*:foo"), - STR("/cracker/cheese[(mold > 1) and (sense/taste"), - - // From xpath-as3 tests - STR("a b"), STR("//self::node())"), STR("/x/y[contains(self::node())"), STR("/x/y[contains(self::node()]"), STR("///"), STR("text::a"), - - // From haXe-xpath tests - STR("|/gjs"), STR("+3"), STR("/html/body/p != ---'div'/a"), STR(""), STR("@"), STR("#akf"), STR(",") - - // Miscellaneous - STR("..."), STR("...."), STR("**"), STR("****"), STR("******"), STR("..***..***.***.***..***..***..*"), STR("/[1]") - }; - - for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); ++i) - { - CHECK_XPATH_FAIL(paths[i]); - } -} - -TEST_XML(xpath_parse_absolute, "
") -{ - CHECK_XPATH_NODESET(doc, STR("/")) % 1; - - CHECK_XPATH_NODESET(doc, STR("/div/s")) % 3; - CHECK_XPATH_NODESET(doc, STR("/ div /s")) % 3; - CHECK_XPATH_FAIL(STR("/ div 5")); - - CHECK_XPATH_NODESET(doc, STR("/*/s")) % 3; - CHECK_XPATH_NODESET(doc, STR("/ * /s")) % 3; - CHECK_XPATH_FAIL(STR("/ * 5")); - - CHECK_XPATH_NODESET(doc, STR("/*[/]")) % 2; -} - -TEST(xpath_parse_out_of_memory_first_page) -{ - test_runner::_memory_fail_threshold = 128; - - CHECK_ALLOC_FAIL(CHECK_XPATH_FAIL(STR("1"))); -} - -TEST(xpath_parse_out_of_memory_second_page_node) -{ - test_runner::_memory_fail_threshold = 8192; - - CHECK_ALLOC_FAIL(CHECK_XPATH_FAIL(STR("1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1"))); -} - -TEST(xpath_parse_out_of_memory_string_to_number) -{ - test_runner::_memory_fail_threshold = 4096 + 128; - - CHECK_ALLOC_FAIL(CHECK_XPATH_FAIL(STR("0.11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"))); -} - -TEST(xpath_parse_out_of_memory_quoted_string) -{ - test_runner::_memory_fail_threshold = 4096 + 128; - - std::basic_string literal(5000, 'a'); - std::basic_string query = STR("'") + literal + STR("'"); - - CHECK_ALLOC_FAIL(CHECK_XPATH_FAIL(query.c_str())); -} - -TEST(xpath_parse_out_of_memory_variable) -{ - test_runner::_memory_fail_threshold = 4096 + 128; - - std::basic_string literal(5000, 'a'); - std::basic_string query = STR("$") + literal; - - xpath_variable_set vars; - CHECK_ALLOC_FAIL(CHECK_XPATH_FAIL_VAR(query.c_str(), &vars)); -} - -TEST(xpath_parse_qname_error) -{ - CHECK_XPATH_FAIL(STR("foo: bar")); - CHECK_XPATH_FAIL(STR("foo :bar")); - CHECK_XPATH_FAIL(STR("foo: *")); - CHECK_XPATH_FAIL(STR("foo :*")); - CHECK_XPATH_FAIL(STR(":*")); - CHECK_XPATH_FAIL(STR(":bar")); - CHECK_XPATH_FAIL(STR(":")); -} - -TEST(xpath_parse_result_default) -{ - xpath_parse_result result; - - CHECK(!result); - CHECK(result.error != 0); - CHECK(result.offset == 0); -} - -TEST(xpath_parse_error_propagation) -{ - char_t query[] = STR("(//foo[count(. | @*)] | ((a)//b)[1] | /foo | /foo/bar//more/ancestor-or-self::foobar | /text() | a[1 + 2 * 3 div (1+0) mod 2]//b[1]/c | a[$x])[true()]"); - - xpath_variable_set vars; - vars.set(STR("x"), 1.0); - - xpath_query q(query, &vars); - CHECK(q); - - for (size_t i = 0; i + 1 < sizeof(query) / sizeof(query[0]); ++i) - { - char_t ch = query[i]; - - query[i] = '%'; - - CHECK_XPATH_FAIL(query); - - query[i] = ch; - } -} - -TEST(xpath_parse_oom_propagation) -{ - const char_t* query_base = STR("(//foo[count(. | @*)] | ((a)//b)[1] | /foo | /foo/bar//more/ancestor-or-self::foobar | /text() | a[1 + 2 * 3 div (1+0) mod 2]//b[1]/c | a[$x])[true()]"); - - xpath_variable_set vars; - vars.set(STR("x"), 1.0); - - test_runner::_memory_fail_threshold = 4096 + 128; - - { - xpath_query q(query_base, &vars); - CHECK(q); - } - - for (size_t i = 3200; i < 4200; ++i) - { - std::basic_string literal(i, 'a'); - std::basic_string query = STR("processing-instruction('") + literal + STR("') | ") + query_base; - - CHECK_ALLOC_FAIL(CHECK_XPATH_FAIL(query.c_str())); - } -} - -TEST_XML(xpath_parse_location_path, "") -{ - CHECK_XPATH_NODESET(doc, STR("/node")) % 2; - CHECK_XPATH_NODESET(doc, STR("/@*")); - CHECK_XPATH_NODESET(doc, STR("/.")) % 1; - CHECK_XPATH_NODESET(doc, STR("/..")); - CHECK_XPATH_NODESET(doc, STR("/*")) % 2; -} -#endif diff --git a/external/pugixml/tests/test_xpath_paths.cpp b/external/pugixml/tests/test_xpath_paths.cpp deleted file mode 100644 index 54a47ae84..000000000 --- a/external/pugixml/tests/test_xpath_paths.cpp +++ /dev/null @@ -1,783 +0,0 @@ -#ifndef PUGIXML_NO_XPATH - -#include "test.hpp" - -using namespace pugi; - -TEST_XML(xpath_paths_axes_child, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - xpath_node na(n.attribute(STR("attr")), n); - - CHECK_XPATH_NODESET(c, STR("child:: node()")); - - CHECK_XPATH_NODESET(n, STR("child:: node()")) % 4 % 7 % 8; // child, another, last - CHECK_XPATH_NODESET(n, STR("another/child:: node()")); - - CHECK_XPATH_NODESET(n, STR("@attr/child::node()")); - CHECK_XPATH_NODESET(na, STR("child::node()")); -} - -TEST_XML(xpath_paths_axes_descendant, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - xpath_node na(n.attribute(STR("attr")), n); - - CHECK_XPATH_NODESET(c, STR("descendant:: node()")); - - CHECK_XPATH_NODESET(n, STR("descendant:: node()")) % 4 % 6 % 7 % 8 % 9; // child, subchild, another, subchild, last - CHECK_XPATH_NODESET(doc, STR("descendant:: node()")) % 2 % 4 % 6 % 7 % 8 % 9; // node, child, subchild, another, subchild, last - CHECK_XPATH_NODESET(n, STR("another/descendant:: node()")) % 8; // subchild - CHECK_XPATH_NODESET(n, STR("last/descendant:: node()")); - - CHECK_XPATH_NODESET(n, STR("@attr/descendant::node()")); - CHECK_XPATH_NODESET(na, STR("descendant::node()")); -} - -TEST_XML(xpath_paths_axes_parent, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - xpath_node na(n.attribute(STR("attr")), n); - - CHECK_XPATH_NODESET(c, STR("parent:: node()")); - - CHECK_XPATH_NODESET(n.child(STR("child")), STR("parent:: node()")) % 2; // node - CHECK_XPATH_NODESET(n, STR("child/subchild/parent:: node()")) % 4; // child - CHECK_XPATH_NODESET(n, STR("@attr/parent:: node()")) % 2; // node - CHECK_XPATH_NODESET(n, STR("parent:: node()")) % 1; // root - CHECK_XPATH_NODESET(doc, STR("parent:: node()")); - - CHECK_XPATH_NODESET(na, STR("parent:: node()")) % 2; // node -} - -TEST_XML(xpath_paths_axes_ancestor, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - xpath_node na(n.child(STR("child")).attribute(STR("attr")), n.child(STR("child"))); - - CHECK_XPATH_NODESET(c, STR("ancestor:: node()")); - - CHECK_XPATH_NODESET(n.child(STR("child")), STR("ancestor:: node()")) % 2 % 1; // node, root - CHECK_XPATH_NODESET(n, STR("child/subchild/ancestor:: node()")) % 4 % 2 % 1; // child, node, root - CHECK_XPATH_NODESET(n, STR("child/@attr/ancestor:: node()")) % 4 % 2 % 1; // child, node, root - CHECK_XPATH_NODESET(n, STR("ancestor:: node()")) % 1; // root - CHECK_XPATH_NODESET(doc, STR("ancestor:: node()")); - - CHECK_XPATH_NODESET(na, STR("ancestor:: node()")) % 4 % 2 % 1; // child, node, root -} - -TEST_XML(xpath_paths_axes_following_sibling, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - xpath_node na(n.attribute(STR("attr1")), n); - - CHECK_XPATH_NODESET(c, STR("following-sibling:: node()")); - - CHECK_XPATH_NODESET(n.child(STR("child")), STR("following-sibling:: node()")) % 8 % 10; // another, last - CHECK_XPATH_NODESET(n.child(STR("last")), STR("following-sibling:: node()")); - - CHECK_XPATH_NODESET(n, STR("@attr1/following-sibling:: node()")); // attributes are not siblings - CHECK_XPATH_NODESET(na, STR("following-sibling:: node()")); // attributes are not siblings -} - -TEST_XML(xpath_paths_axes_preceding_sibling, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - xpath_node na(n.attribute(STR("attr2")), n); - - CHECK_XPATH_NODESET(c, STR("preceding-sibling:: node()")); - - CHECK_XPATH_NODESET(n.child(STR("child")), STR("preceding-sibling:: node()")); - CHECK_XPATH_NODESET(n.child(STR("last")), STR("preceding-sibling:: node()")) % 8 % 5; // another, child - - CHECK_XPATH_NODESET(n, STR("@attr2/following-sibling:: node()")); // attributes are not siblings - CHECK_XPATH_NODESET(na, STR("following-sibling:: node()")); // attributes are not siblings -} - -TEST_XML(xpath_paths_axes_following, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - xpath_node na(n.attribute(STR("attr1")), n); - - CHECK_XPATH_NODESET(c, STR("following:: node()")); - - CHECK_XPATH_NODESET(n, STR("following:: node()")); // no descendants - CHECK_XPATH_NODESET(n.child(STR("child")), STR("following:: node()")) % 8 % 9 % 10 % 11; // another, subchild, almost, last - CHECK_XPATH_NODESET(n.child(STR("child")).child(STR("subchild")), STR("following:: node()")) % 8 % 9 % 10 % 11; // another, subchild, almost, last - CHECK_XPATH_NODESET(n.child(STR("last")), STR("following:: node()")); - - CHECK_XPATH_NODESET(n, STR("@attr1/following::node()")) % 5 % 7 % 8 % 9 % 10 % 11; // child, subchild, another, subchild, almost, last - because @/following - CHECK_XPATH_NODESET(n, STR("child/@attr/following::node()")) % 7 % 8 % 9 % 10 % 11; // subchild, another, subchild, almost, last - CHECK_XPATH_NODESET(na, STR("following::node()")) % 5 % 7 % 8 % 9 % 10 % 11; // child, subchild, another, subchild, almost, last - because @/following -} - -TEST_XML(xpath_paths_axes_preceding, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - xpath_node na(n.child(STR("child")).attribute(STR("attr")), n.child(STR("child"))); - - CHECK_XPATH_NODESET(c, STR("preceding:: node()")); - - CHECK_XPATH_NODESET(n.child(STR("child")), STR("preceding:: node()")); // no ancestors - CHECK_XPATH_NODESET(n.child(STR("last")), STR("preceding:: node()")) % 11 % 9 % 8 % 7 % 5; // almost, subchild, another, subchild, child - CHECK_XPATH_NODESET(n.child(STR("another")).child(STR("subchild")), STR("preceding:: node()")) % 7 % 5; // subchild, child - CHECK_XPATH_NODESET(n, STR("preceding:: node()")); - - CHECK_XPATH_NODESET(n, STR("child/@attr/preceding::node()")); // no ancestors - CHECK_XPATH_NODESET(n, STR("//subchild[@id]/@id/preceding::node()")) % 7 % 5; // subchild, child - CHECK_XPATH_NODESET(na, STR("preceding::node()")); // no ancestors -} - -TEST_XML(xpath_paths_axes_attribute, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - xpath_node na(n.attribute(STR("attr1")), n); - - CHECK_XPATH_NODESET(c, STR("attribute:: node()")); - - CHECK_XPATH_NODESET(n.child(STR("child")), STR("attribute:: node()")) % 6; // child/@attr - CHECK_XPATH_NODESET(n.child(STR("last")), STR("attribute:: node()")); - CHECK_XPATH_NODESET(n, STR("attribute:: node()")) % 3 % 4; // node/@attr1 node/@attr2 - CHECK_XPATH_NODESET(doc, STR("descendant-or-self:: node()/attribute:: node()")) % 3 % 4 % 6; // all attributes - CHECK_XPATH_NODESET(n.child(STR("another")), STR("attribute:: node()")); // namespace nodes are not attributes - - CHECK_XPATH_NODESET(n, STR("@attr1/attribute::node()")); - CHECK_XPATH_NODESET(na, STR("attribute::node()")); -} - -TEST_XML(xpath_paths_axes_namespace, "") -{ - xml_node n = doc.child(STR("node")); - xpath_node na(n.attribute(STR("attr")), n); - - // namespace nodes are not supported - CHECK_XPATH_NODESET(n, STR("namespace:: node()")); - CHECK_XPATH_NODESET(n, STR("@attr/attribute::node()")); - CHECK_XPATH_NODESET(na, STR("attribute::node()")); -} - -TEST_XML(xpath_paths_axes_self, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - xpath_node na(n.attribute(STR("attr")), n); - - CHECK_XPATH_NODESET(c, STR("self:: node()")); - - CHECK_XPATH_NODESET(n.child(STR("child")), STR("self:: node()")) % 4; // child - CHECK_XPATH_NODESET(n, STR("self:: node()")) % 2; // node - CHECK_XPATH_NODESET(n, STR("child/self:: node()")) % 4; // child - CHECK_XPATH_NODESET(n, STR("child/@attr/self:: node()")) % 5; // @attr - CHECK_XPATH_NODESET(doc, STR("self:: node()")) % 1; // root - CHECK_XPATH_NODESET(na, STR("self:: node()")) % 3; // @attr -} - -TEST_XML(xpath_paths_axes_descendant_or_self, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - xpath_node na(n.child(STR("child")).attribute(STR("attr")), n.child(STR("child"))); - - CHECK_XPATH_NODESET(c, STR("descendant-or-self:: node()")); - - CHECK_XPATH_NODESET(n, STR("descendant-or-self:: node()")) % 2 % 4 % 6 % 7 % 8 % 9; // node, child, subchild, another, subchild, last - CHECK_XPATH_NODESET(doc, STR("descendant-or-self:: node()")) % 1 % 2 % 4 % 6 % 7 % 8 % 9; // root, node, child, subchild, another, subchild, last - CHECK_XPATH_NODESET(n, STR("another/descendant-or-self:: node()")) % 7 % 8; // another, subchild - CHECK_XPATH_NODESET(n, STR("last/descendant-or-self:: node()")) % 9; // last - - CHECK_XPATH_NODESET(n, STR("child/@attr/descendant-or-self::node()")) % 5; // @attr - CHECK_XPATH_NODESET(na, STR("descendant-or-self::node()")) % 5; // @attr -} - -TEST_XML(xpath_paths_axes_ancestor_or_self, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - xpath_node na(n.child(STR("child")).attribute(STR("attr")), n.child(STR("child"))); - - CHECK_XPATH_NODESET(c, STR("ancestor-or-self:: node()")); - - CHECK_XPATH_NODESET(n.child(STR("child")), STR("ancestor-or-self:: node()")) % 4 % 2 % 1; // child, node, root - CHECK_XPATH_NODESET(n, STR("child/subchild/ancestor-or-self:: node()")) % 6 % 4 % 2 % 1; // subchild, child, node, root - CHECK_XPATH_NODESET(n, STR("child/@attr/ancestor-or-self:: node()")) % 5 % 4 % 2 % 1; // @attr, child, node, root - CHECK_XPATH_NODESET(n, STR("ancestor-or-self:: node()")) % 2 % 1; // root, node - CHECK_XPATH_NODESET(doc, STR("ancestor-or-self:: node()")) % 1; // root - CHECK_XPATH_NODESET(n, STR("ancestor-or-self:: node()")) % 2 % 1; // root, node - CHECK_XPATH_NODESET(n, STR("last/ancestor-or-self::node()")) % 9 % 2 % 1; // root, node, last - CHECK_XPATH_NODESET(na, STR("ancestor-or-self:: node()")) % 5 % 4 % 2 % 1; // @attr, child, node, root -} - -TEST_XML(xpath_paths_axes_abbrev, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // @ axis - CHECK_XPATH_NODESET(c, STR("@attr")); - CHECK_XPATH_NODESET(n, STR("@attr")) % 3; - - // no axis - child implied - CHECK_XPATH_NODESET(c, STR("foo")); - CHECK_XPATH_NODESET(n, STR("foo")) % 4; - CHECK_XPATH_NODESET(doc, STR("node()")) % 2; - - // @ axis should disable all other axis specifiers - CHECK_XPATH_FAIL(STR("@child::foo")); - CHECK_XPATH_FAIL(STR("@attribute::foo")); -} - -TEST_XML(xpath_paths_nodetest_all, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("*")); - CHECK_XPATH_NODESET(c, STR("child::*")); - - CHECK_XPATH_NODESET(n, STR("*")) % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(n, STR("child::*")) % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(n, STR("attribute::*")) % 3 % 4; -} - -TEST_XML_FLAGS(xpath_paths_nodetest_name, "", parse_default | parse_pi) -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("c1")); - CHECK_XPATH_NODESET(c, STR("child::c1")); - - CHECK_XPATH_NODESET(n, STR("c1")) % 5; - CHECK_XPATH_NODESET(n, STR("x:c2")) % 6; - - CHECK_XPATH_NODESET(n, STR("child::c1")) % 5; - CHECK_XPATH_NODESET(n, STR("child::x:c2")) % 6; - - CHECK_XPATH_NODESET(n, STR("attribute::a1")) % 3; - CHECK_XPATH_NODESET(n, STR("attribute::x:a2")) % 4; - CHECK_XPATH_NODESET(n, STR("@x:a2")) % 4; -} - -TEST_XML(xpath_paths_nodetest_all_in_namespace, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("x:*")); - CHECK_XPATH_NODESET(c, STR("child::x:*")); - - CHECK_XPATH_NODESET(n, STR("x:*")) % 6 % 8; - CHECK_XPATH_NODESET(n, STR("child::x:*")) % 6 % 8; - - CHECK_XPATH_NODESET(n, STR("attribute::x:*")) % 4; - CHECK_XPATH_NODESET(n, STR("@x:*")) % 4; - - CHECK_XPATH_FAIL(STR(":*")); - CHECK_XPATH_FAIL(STR("@:*")); -} - -TEST_XML_FLAGS(xpath_paths_nodetest_type, "pcdata", parse_default | parse_pi | parse_comments) -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - // check on empty nodes - CHECK_XPATH_NODESET(c, STR("node()")); - CHECK_XPATH_NODESET(c, STR("text()")); - CHECK_XPATH_NODESET(c, STR("comment()")); - CHECK_XPATH_NODESET(c, STR("processing-instruction()")); - CHECK_XPATH_NODESET(c, STR("processing-instruction('foobar')")); - - // child axis - CHECK_XPATH_NODESET(n, STR("node()")) % 4 % 5 % 6 % 7 % 8 % 9; - CHECK_XPATH_NODESET(n, STR("text()")) % 4 % 9; - CHECK_XPATH_NODESET(n, STR("comment()")) % 8; - CHECK_XPATH_NODESET(n, STR("processing-instruction()")) % 6 % 7; - CHECK_XPATH_NODESET(n, STR("processing-instruction('pi2')")) % 7; - - // attribute axis - CHECK_XPATH_NODESET(n, STR("@node()")) % 3; - CHECK_XPATH_NODESET(n, STR("@text()")); - CHECK_XPATH_NODESET(n, STR("@comment()")); - CHECK_XPATH_NODESET(n, STR("@processing-instruction()")); - CHECK_XPATH_NODESET(n, STR("@processing-instruction('pi2')")); - - // incorrect 'argument' number - CHECK_XPATH_FAIL(STR("node('')")); - CHECK_XPATH_FAIL(STR("text('')")); - CHECK_XPATH_FAIL(STR("comment('')")); - CHECK_XPATH_FAIL(STR("processing-instruction(1)")); - CHECK_XPATH_FAIL(STR("processing-instruction('', '')")); - CHECK_XPATH_FAIL(STR("processing-instruction(concat('a', 'b'))")); -} - -TEST_XML_FLAGS(xpath_paths_nodetest_principal, "pcdata", parse_default | parse_pi | parse_comments) -{ - // node() test is true for any node type - CHECK_XPATH_NODESET(doc, STR("//node()")) % 2 % 4 % 5 % 6 % 7 % 8 % 9 % 10; - CHECK_XPATH_NODESET(doc, STR("//attribute::node()")) % 3 % 11; - CHECK_XPATH_NODESET(doc, STR("//attribute::node()/ancestor-or-self::node()")) % 1 % 2 % 3 % 10 % 11; - - // name test is true only for node with principal node type (depends on axis) - CHECK_XPATH_NODESET(doc, STR("node/child::child")) % 5; - CHECK_XPATH_NODESET(doc, STR("node/attribute::attr")) % 3; - CHECK_XPATH_NODESET(doc, STR("node/child::pi1")); - CHECK_XPATH_NODESET(doc, STR("node/child::attr")); - CHECK_XPATH_NODESET(doc, STR("node/child::child/self::child")) % 5; - CHECK_XPATH_NODESET(doc, STR("node/attribute::attr/self::attr")); // attribute is not of element type - CHECK_XPATH_NODESET(doc, STR("node/child::child/ancestor-or-self::child")) % 5; - CHECK_XPATH_NODESET(doc, STR("node/attribute::attr/ancestor-or-self::attr")); // attribute is not of element type - CHECK_XPATH_NODESET(doc, STR("node/child::child/descendant-or-self::child")) % 5; - CHECK_XPATH_NODESET(doc, STR("node/attribute::attr/descendant-or-self::attr")); // attribute is not of element type - - // any name test is true only for node with principal node type (depends on axis) - CHECK_XPATH_NODESET(doc, STR("node/child::*")) % 5; - CHECK_XPATH_NODESET(doc, STR("node/attribute::*")) % 3; - CHECK_XPATH_NODESET(doc, STR("node/child::*/self::*")) % 5; - CHECK_XPATH_NODESET(doc, STR("node/attribute::*/self::*")); // attribute is not of element type - CHECK_XPATH_NODESET(doc, STR("node/child::*/ancestor-or-self::*")) % 5 % 2; - CHECK_XPATH_NODESET(doc, STR("node/attribute::*/ancestor-or-self::*")) % 2; // attribute is not of element type - CHECK_XPATH_NODESET(doc, STR("node/child::*/descendant-or-self::*")) % 5; - CHECK_XPATH_NODESET(doc, STR("node/attribute::*/descendant-or-self::*")); // attribute is not of element type - - // namespace test is true only for node with principal node type (depends on axis) - CHECK_XPATH_NODESET(doc, STR("child::abra:*")) % 10; - CHECK_XPATH_NODESET(doc, STR("child::abra:*/attribute::abra:*")) % 11; - CHECK_XPATH_NODESET(doc, STR("child::abra:*/self::abra:*")) % 10; - CHECK_XPATH_NODESET(doc, STR("child::abra:*/attribute::abra:*/self::abra:*")); // attribute is not of element type - CHECK_XPATH_NODESET(doc, STR("child::abra:*/ancestor-or-self::abra:*")) % 10; - CHECK_XPATH_NODESET(doc, STR("child::abra:*/attribute::abra:*/ancestor-or-self::abra:*")) % 10; // attribute is not of element type - CHECK_XPATH_NODESET(doc, STR("child::abra:*/descendant-or-self::abra:*")) % 10; - CHECK_XPATH_NODESET(doc, STR("child::abra:*/attribute::abra:*/descendant-or-self::abra:*")); // attribute is not of element type -} - -TEST_XML(xpath_paths_nodetest_attribute_namespace, "") -{ - CHECK_XPATH_NODESET(doc, STR("node/attribute::node()")) % 3; - CHECK_XPATH_NODESET(doc, STR("node/attribute::xmlns:x")); - CHECK_XPATH_NODESET(doc, STR("node/attribute::xmlns:*")); -} - -TEST_XML(xpath_paths_absolute, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - xpath_node na(n.attribute(STR("attr")), n); - - CHECK_XPATH_NODESET(c, STR("/foo")); - CHECK_XPATH_NODESET(n, STR("/foo")); - CHECK_XPATH_NODESET(n, STR("/node/foo")) % 4; - CHECK_XPATH_NODESET(n.child(STR("foo")), STR("/node/foo")) % 4; - CHECK_XPATH_NODESET(na, STR("/node/foo")) % 4; - - CHECK_XPATH_NODESET(c, STR("/")); - CHECK_XPATH_NODESET(n, STR("/")) % 1; - CHECK_XPATH_NODESET(n.child(STR("foo")), STR("/")) % 1; - CHECK_XPATH_NODESET(na, STR("/")) % 1; -} - -TEST_XML(xpath_paths_step_abbrev, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR(".")); - CHECK_XPATH_NODESET(c, STR("..")); - - CHECK_XPATH_NODESET(n, STR(".")) % 2; - CHECK_XPATH_NODESET(n, STR("..")) % 1; - CHECK_XPATH_NODESET(n, STR("../node")) % 2; - CHECK_XPATH_NODESET(n.child(STR("foo")), STR("..")) % 2; - - CHECK_XPATH_FAIL(STR(".node")); - CHECK_XPATH_FAIL(STR("..node")); -} - -TEST_XML(xpath_paths_relative_abbrev, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("foo//bar")); - - CHECK_XPATH_NODESET(n, STR("foo/foo")) % 4 % 5; - CHECK_XPATH_NODESET(n, STR("foo//foo")) % 4 % 5; - CHECK_XPATH_NODESET(n, STR(".//foo")) % 3 % 4 % 5; -} - -TEST_XML(xpath_paths_absolute_abbrev, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("//bar")); - - CHECK_XPATH_NODESET(n, STR("//foo")) % 3 % 4 % 5; - CHECK_XPATH_NODESET(n.child(STR("foo")), STR("//foo")) % 3 % 4 % 5; - CHECK_XPATH_NODESET(doc, STR("//foo")) % 3 % 4 % 5; -} - -TEST_XML(xpath_paths_predicate_boolean, "") -{ - xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling(); - - CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[position()=1]")) % 6; - CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[position()=2]")) % 7; - CHECK_XPATH_NODESET(n, STR("preceding-sibling::chapter[position()=1]")) % 4; - CHECK_XPATH_NODESET(n, STR("preceding-sibling::chapter[position()=2]")) % 3; -} - -TEST_XML(xpath_paths_predicate_number, "") -{ - xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling(); - - CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[1]")) % 6; - CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[2]")) % 7; - CHECK_XPATH_NODESET(n, STR("preceding-sibling::chapter[1]")) % 4; - CHECK_XPATH_NODESET(n, STR("preceding-sibling::chapter[2]")) % 3; -} - -TEST_XML(xpath_paths_predicate_number_boundary, "") -{ - CHECK_XPATH_NODESET(doc, STR("node/chapter[0.999999999999999]")); - CHECK_XPATH_NODESET(doc, STR("node/chapter[1]")) % 3; - CHECK_XPATH_NODESET(doc, STR("node/chapter[1.000000000000001]")); - CHECK_XPATH_NODESET(doc, STR("node/chapter[1.999999999999999]")); - CHECK_XPATH_NODESET(doc, STR("node/chapter[2]")) % 4; - CHECK_XPATH_NODESET(doc, STR("node/chapter[2.000000000000001]")); - CHECK_XPATH_NODESET(doc, STR("node/chapter[4.999999999999999]")); - CHECK_XPATH_NODESET(doc, STR("node/chapter[5]")) % 7; - CHECK_XPATH_NODESET(doc, STR("node/chapter[5.000000000000001]")); -} - -TEST_XML(xpath_paths_predicate_number_out_of_range, "") -{ - xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling(); - - CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[0]")); - CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[-1]")); - CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[-1000000000000]")); - CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[-1 div 0]")); - CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[1000000000000]")); - CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[1 div 0]")); - -#ifndef MSVC6_NAN_BUG - CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[0 div 0]")); -#endif -} - -TEST_XML(xpath_paths_predicate_constant_boolean, "") -{ - xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling(); - - xpath_variable_set set; - set.set(STR("true"), true); - set.set(STR("false"), false); - - CHECK_XPATH_NODESET_VAR(n, STR("following-sibling::chapter[$false]"), &set); - CHECK_XPATH_NODESET_VAR(n, STR("following-sibling::chapter[$true]"), &set) % 6 % 7; -} - -TEST_XML(xpath_paths_predicate_position_eq, "3") -{ - CHECK_XPATH_NODESET(doc, STR("node/chapter[position()=1]")) % 3; - CHECK_XPATH_NODESET(doc, STR("node/chapter[position()=2+2]")) % 7; - CHECK_XPATH_NODESET(doc, STR("node/chapter[position()=last()]")) % 8; - -#ifndef MSVC6_NAN_BUG - CHECK_XPATH_NODESET(doc, STR("node/chapter[position()=string()]")) % 5; -#endif -} - -TEST_XML(xpath_paths_predicate_several, "") -{ - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(n, STR("employee")) % 3 % 4 % 6 % 8 % 11; - CHECK_XPATH_NODESET(n, STR("employee[@secretary]")) % 4 % 8 % 11; - CHECK_XPATH_NODESET(n, STR("employee[@assistant]")) % 6 % 8 % 11; - CHECK_XPATH_NODESET(n, STR("employee[@secretary][@assistant]")) % 8 % 11; - CHECK_XPATH_NODESET(n, STR("employee[@assistant][@secretary]")) % 8 % 11; - CHECK_XPATH_NODESET(n, STR("employee[@secretary and @assistant]")) % 8 % 11; -} - -TEST_XML(xpath_paths_predicate_filter_boolean, "") -{ - xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling(); - - CHECK_XPATH_NODESET(n, STR("(following-sibling::chapter)[position()=1]")) % 6; - CHECK_XPATH_NODESET(n, STR("(following-sibling::chapter)[position()=2]")) % 7; - CHECK_XPATH_NODESET(n, STR("(preceding-sibling::chapter)[position()=1]")) % 3; - CHECK_XPATH_NODESET(n, STR("(preceding-sibling::chapter)[position()=2]")) % 4; -} - -TEST_XML(xpath_paths_predicate_filter_number, "") -{ - xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling(); - - CHECK_XPATH_NODESET(n, STR("(following-sibling::chapter)[1]")) % 6; - CHECK_XPATH_NODESET(n, STR("(following-sibling::chapter)[2]")) % 7; - CHECK_XPATH_NODESET(n, STR("(preceding-sibling::chapter)[1]")) % 3; - CHECK_XPATH_NODESET(n, STR("(preceding-sibling::chapter)[2]")) % 4; -} - -TEST_XML(xpath_paths_predicate_filter_posinv, "") -{ - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(n, STR("employee")) % 3 % 4 % 6 % 8 % 11; - CHECK_XPATH_NODESET(n, STR("(employee[@secretary])[@assistant]")) % 8 % 11; - CHECK_XPATH_NODESET(n, STR("((employee)[@assistant])[@secretary]")) % 8 % 11; -} - -TEST_XML(xpath_paths_step_compose, "") -{ - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(n, STR("(.)/foo")) % 3 % 6; - CHECK_XPATH_NODESET(n, STR("(.)//foo")) % 3 % 4 % 5 % 6; - CHECK_XPATH_NODESET(n, STR("(./..)//*")) % 2 % 3 % 4 % 5 % 6; - - CHECK_XPATH_FAIL(STR("(1)/foo")); - CHECK_XPATH_FAIL(STR("(1)//foo")); -} - -TEST_XML(xpath_paths_descendant_double_slash_w3c, "") -{ - CHECK_XPATH_NODESET(doc, STR("//para")) % 3 % 4 % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(doc, STR("/descendant::para")) % 3 % 4 % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(doc, STR("//para[1]")) % 3 % 4 % 7; - CHECK_XPATH_NODESET(doc, STR("/descendant::para[1]")) % 3; -} - -TEST_XML(xpath_paths_needs_sorting, "") -{ - CHECK_XPATH_NODESET(doc, STR("(node/child/subchild)[2]")) % 7; -} - -TEST_XML(xpath_paths_descendant_filters, "") -{ - CHECK_XPATH_NODESET(doc, STR("//para[1]")) % 3 % 4 % 7; - CHECK_XPATH_NODESET(doc, STR("/descendant::para[1]")) % 3; - CHECK_XPATH_NODESET(doc, STR("//para[true()][1]")) % 3 % 4 % 7; - CHECK_XPATH_NODESET(doc, STR("/descendant::para[true()][1]")) % 3; - CHECK_XPATH_NODESET(doc, STR("//para[1][true()]")) % 3 % 4 % 7; - CHECK_XPATH_NODESET(doc, STR("/descendant::para[1][true()]")) % 3; - CHECK_XPATH_NODESET(doc, STR("//para[1][2]")); - CHECK_XPATH_NODESET(doc, STR("/descendant::para[1][2]")); - CHECK_XPATH_NODESET(doc, STR("//para[true()]")) % 3 % 4 % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(doc, STR("/descendant::para[true()]")) % 3 % 4 % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(doc, STR("//para[position()=1][true()]")) % 3 % 4 % 7; - CHECK_XPATH_NODESET(doc, STR("/descendant::para[position()=1][true()]")) % 3; - CHECK_XPATH_NODESET(doc, STR("//para[true()][position()=1]")) % 3 % 4 % 7; - CHECK_XPATH_NODESET(doc, STR("/descendant::para[true()][position()=1]")) % 3; - CHECK_XPATH_NODESET(doc, STR("//node()[self::para]")) % 3 % 4 % 5 % 6 % 7 % 8; -} - -TEST_XML(xpath_paths_descendant_optimize, "") -{ - CHECK_XPATH_NODESET(doc, STR("//para")) % 3 % 4 % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(doc, STR("/descendant-or-self::node()/child::para")) % 3 % 4 % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(doc, STR("/descendant-or-self::node()[name()='para']/child::para")) % 4 % 5 % 6 % 7; - CHECK_XPATH_NODESET(doc, STR("/descendant-or-self::node()[name()='para']/child::para[1]")) % 4 % 7; - CHECK_XPATH_NODESET(doc, STR("/descendant-or-self::node()[3]/child::para")) % 4 % 5 % 6; -} - -TEST_XML(xpath_paths_descendant_optimize_axes, "") -{ - CHECK_XPATH_NODESET(doc, STR("//.")) % 1 % 2 % 3 % 4 % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(doc, STR("//descendant::*")) % 2 % 3 % 4 % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(doc, STR("//descendant-or-self::*")) % 2 % 3 % 4 % 5 % 6 % 7 % 8; - - CHECK_XPATH_NODESET(doc, STR("//..")) % 1 % 2 % 3 % 6; - CHECK_XPATH_NODESET(doc, STR("//ancestor::*")) % 2 % 3 % 6; - CHECK_XPATH_NODESET(doc, STR("//ancestor-or-self::*")) % 2 % 3 % 4 % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(doc, STR("//preceding-sibling::*")) % 3 % 4 % 5; - CHECK_XPATH_NODESET(doc, STR("//following-sibling::*")) % 5 % 6 % 8; - CHECK_XPATH_NODESET(doc, STR("//preceding::*")) % 3 % 4 % 5 % 6 % 7; - CHECK_XPATH_NODESET(doc, STR("//following::*")) % 5 % 6 % 7 % 8; -} - -TEST_XML(xpath_paths_descendant_optimize_last, "") -{ - CHECK_XPATH_NODESET(doc, STR("//para[last()]")) % 6 % 7 % 8; - CHECK_XPATH_NODESET(doc, STR("//para[last() = 1]")) % 7; -} - -TEST_XML(xpath_paths_precision, "") -{ - CHECK_XPATH_NODESET(doc, STR("//para[1]")) % 3; - CHECK_XPATH_NODESET(doc, STR("//para[3 div 3]")) % 3; - CHECK_XPATH_NODESET(doc, STR("//para[6 div 3 - 1]")) % 3; - CHECK_XPATH_NODESET(doc, STR("//para[6 * (1 div 3) - 1]")) % 3; -} - -TEST_XML(xpath_paths_unsorted_child, "") -{ - CHECK_XPATH_NODESET(doc, STR("//node/foo")) % 3 % 6 % 8; - CHECK_XPATH_NODESET(doc, STR("//node/foo/bar")) % 4 % 7 % 9; - - xpath_node_set ns = doc.select_nodes(STR("//node/foo/bar")); - CHECK(ns.type() == xpath_node_set::type_unsorted); - - xpath_node_set nss = ns; - nss.sort(); - - CHECK(ns[0] == nss[0]); - CHECK(ns[1] == nss[2]); - CHECK(ns[2] == nss[1]); -} - -TEST_XML(xpath_paths_optimize_compare_attribute, "") -{ - CHECK_XPATH_NODESET(doc, STR("node[@id = '1']")) % 2; - CHECK_XPATH_NODESET(doc, STR("node[@id = '2']")) % 4; - CHECK_XPATH_NODESET(doc, STR("node[@id = 2]")) % 4; - CHECK_XPATH_NODESET(doc, STR("node[@id[. > 3] = '2']")); - CHECK_XPATH_NODESET(doc, STR("node['1' = @id]")) % 2; - - xpath_variable_set set; - set.set(STR("var1"), STR("2")); - set.set(STR("var2"), 2.0); - - CHECK_XPATH_NODESET_VAR(doc, STR("node[@id = $var1]"), &set) % 4; - CHECK_XPATH_NODESET_VAR(doc, STR("node[@id = $var2]"), &set) % 4; - - CHECK_XPATH_NODESET(doc, STR("node[@xmlns = '3']")); -} - -TEST_XML(xpath_paths_optimize_step_once, "") -{ - CHECK_XPATH_BOOLEAN(doc, STR("node//para2/following::*"), true); - CHECK_XPATH_BOOLEAN(doc, STR("node//para6/following::*"), false); - - CHECK_XPATH_STRING(doc, STR("name(node//para2/following::*)"), STR("para3")); - CHECK_XPATH_STRING(doc, STR("name(node//para6/following::*)"), STR("")); - - CHECK_XPATH_BOOLEAN(doc, STR("node//para1/preceding::*"), false); - CHECK_XPATH_BOOLEAN(doc, STR("node//para6/preceding::*"), true); - - CHECK_XPATH_STRING(doc, STR("name(node//para1/preceding::*)"), STR("")); - CHECK_XPATH_STRING(doc, STR("name(node//para6/preceding::*)"), STR("para1")); - - CHECK_XPATH_BOOLEAN(doc, STR("node//para6/preceding::para4"), true); - - CHECK_XPATH_BOOLEAN(doc, STR("//@attr5/ancestor-or-self::*"), true); - CHECK_XPATH_BOOLEAN(doc, STR("//@attr5/ancestor::*"), true); - - CHECK_XPATH_BOOLEAN(doc, STR("//@attr5/following::para6"), true); - CHECK_XPATH_STRING(doc, STR("name(//@attr5/following::para6)"), STR("para6")); - - CHECK_XPATH_BOOLEAN(doc, STR("//para5/ancestor-or-self::*"), true); - CHECK_XPATH_BOOLEAN(doc, STR("//para5/ancestor::*"), true); - - CHECK_XPATH_BOOLEAN(doc, STR("//@attr5/ancestor-or-self::node()"), true); -} - -TEST_XML(xpath_paths_null_nodeset_entries, "") -{ - xpath_node nodes[] = - { - xpath_node(doc.first_child()), - xpath_node(xml_node()), - xpath_node(doc.first_child().first_attribute(), doc.first_child()), - xpath_node(xml_attribute(), doc.first_child()), - xpath_node(xml_attribute(), xml_node()), - }; - - xpath_node_set ns(nodes, nodes + sizeof(nodes) / sizeof(nodes[0])); - - xpath_variable_set vars; - vars.set(STR("x"), ns); - - xpath_node_set rs = xpath_query(STR("$x/."), &vars).evaluate_node_set(xml_node()); - - CHECK(rs.size() == 2); - CHECK(rs[0] == nodes[0]); - CHECK(rs[1] == nodes[2]); -} - -TEST_XML(xpath_paths_step_leaf_coverage, "") -{ - xml_node n = doc.child(STR("n")).child(STR("n2")); - - CHECK_XPATH_NODESET(n, STR("ancestor::node()")) % 2 % 1; - CHECK_XPATH_NODESET(n, STR("ancestor-or-self::node()")) % 4 % 2 % 1; - CHECK_XPATH_NODESET(n, STR("attribute::node()")) % 5; - CHECK_XPATH_NODESET(n, STR("child::node()")) % 6; - CHECK_XPATH_NODESET(n, STR("descendant::node()")) % 6; - CHECK_XPATH_NODESET(n, STR("descendant-or-self::node()")) % 4 % 6; - CHECK_XPATH_NODESET(n, STR("following::node()")) % 7; - CHECK_XPATH_NODESET(n, STR("following-sibling::node()")) % 7; - CHECK_XPATH_NODESET(n, STR("namespace::node()")); - CHECK_XPATH_NODESET(n, STR("parent::node()")) % 2; - CHECK_XPATH_NODESET(n, STR("preceding::node()")) % 3; - CHECK_XPATH_NODESET(n, STR("preceding-sibling::node()")) % 3; - CHECK_XPATH_NODESET(n, STR("self::node()")) % 4; -} -TEST_XML(xpath_paths_step_leaf_predicate_coverage, "") -{ - xml_node n = doc.child(STR("n")).child(STR("n2")); - - CHECK_XPATH_NODESET(n, STR("ancestor::node()[1]")) % 2; - CHECK_XPATH_NODESET(n, STR("ancestor-or-self::node()[1]")) % 4; - CHECK_XPATH_NODESET(n, STR("attribute::node()[1]")) % 5; - CHECK_XPATH_NODESET(n, STR("child::node()[1]")) % 6; - CHECK_XPATH_NODESET(n, STR("descendant::node()[1]")) % 6; - CHECK_XPATH_NODESET(n, STR("descendant-or-self::node()[1]")) % 4; - CHECK_XPATH_NODESET(n, STR("following::node()[1]")) % 7; - CHECK_XPATH_NODESET(n, STR("following-sibling::node()[1]")) % 7; - CHECK_XPATH_NODESET(n, STR("namespace::node()[1]")); - CHECK_XPATH_NODESET(n, STR("parent::node()[1]")) % 2; - CHECK_XPATH_NODESET(n, STR("preceding::node()[1]")) % 3; - CHECK_XPATH_NODESET(n, STR("preceding-sibling::node()[1]")) % 3; - CHECK_XPATH_NODESET(n, STR("self::node()[1]")) % 4; -} - -TEST_XML(xpath_paths_step_step_coverage, "") -{ - xml_node n = doc.child(STR("n")).child(STR("n2")); - - CHECK_XPATH_NODESET(n, STR("./ancestor::node()")) % 2 % 1; - CHECK_XPATH_NODESET(n, STR("./ancestor-or-self::node()")) % 4 % 2 % 1; - CHECK_XPATH_NODESET(n, STR("./attribute::node()")) % 5; - CHECK_XPATH_NODESET(n, STR("./child::node()")) % 6; - CHECK_XPATH_NODESET(n, STR("./descendant::node()")) % 6; - CHECK_XPATH_NODESET(n, STR("./descendant-or-self::node()")) % 4 % 6; - CHECK_XPATH_NODESET(n, STR("./following::node()")) % 7; - CHECK_XPATH_NODESET(n, STR("./following-sibling::node()")) % 7; - CHECK_XPATH_NODESET(n, STR("./namespace::node()")); - CHECK_XPATH_NODESET(n, STR("./parent::node()")) % 2; - CHECK_XPATH_NODESET(n, STR("./preceding::node()")) % 3; - CHECK_XPATH_NODESET(n, STR("./preceding-sibling::node()")) % 3; - CHECK_XPATH_NODESET(n, STR("./self::node()")) % 4; -} - -TEST_XML(xpath_paths_step_step_predicate_coverage, "") -{ - xml_node n = doc.child(STR("n")).child(STR("n2")); - - CHECK_XPATH_NODESET(n, STR("./ancestor::node()[1]")) % 2; - CHECK_XPATH_NODESET(n, STR("./ancestor-or-self::node()[1]")) % 4; - CHECK_XPATH_NODESET(n, STR("./attribute::node()[1]")) % 5; - CHECK_XPATH_NODESET(n, STR("./child::node()[1]")) % 6; - CHECK_XPATH_NODESET(n, STR("./descendant::node()[1]")) % 6; - CHECK_XPATH_NODESET(n, STR("./descendant-or-self::node()[1]")) % 4; - CHECK_XPATH_NODESET(n, STR("./following::node()[1]")) % 7; - CHECK_XPATH_NODESET(n, STR("./following-sibling::node()[1]")) % 7; - CHECK_XPATH_NODESET(n, STR("./namespace::node()[1]")); - CHECK_XPATH_NODESET(n, STR("./parent::node()[1]")) % 2; - CHECK_XPATH_NODESET(n, STR("./preceding::node()[1]")) % 3; - CHECK_XPATH_NODESET(n, STR("./preceding-sibling::node()[1]")) % 3; - CHECK_XPATH_NODESET(n, STR("./self::node()[1]")) % 4; -} -#endif diff --git a/external/pugixml/tests/test_xpath_paths_abbrev_w3c.cpp b/external/pugixml/tests/test_xpath_paths_abbrev_w3c.cpp deleted file mode 100644 index bd01e6583..000000000 --- a/external/pugixml/tests/test_xpath_paths_abbrev_w3c.cpp +++ /dev/null @@ -1,219 +0,0 @@ -#ifndef PUGIXML_NO_XPATH - -#include "test.hpp" - -using namespace pugi; - -TEST_XML(xpath_paths_abbrev_w3c_1, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("para")); - CHECK_XPATH_NODESET(n, STR("para")) % 3 % 5; -} - -TEST_XML(xpath_paths_abbrev_w3c_2, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("*")); - CHECK_XPATH_NODESET(n, STR("*")) % 3 % 4 % 5; -} - -TEST_XML(xpath_paths_abbrev_w3c_3, "pcdata") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("text()")); - CHECK_XPATH_NODESET(n, STR("text()")) % 3 % 5; -} - -TEST_XML(xpath_paths_abbrev_w3c_4, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("@name")); - CHECK_XPATH_NODESET(n, STR("@name")) % 3; -} - -TEST_XML(xpath_paths_abbrev_w3c_5, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("@*")); - CHECK_XPATH_NODESET(n, STR("@*")) % 3 % 4; -} - -TEST_XML(xpath_paths_abbrev_w3c_6, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("para[1]")); - CHECK_XPATH_NODESET(n, STR("para[1]")) % 3; -} - -TEST_XML(xpath_paths_abbrev_w3c_7, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("para[last()]")); - CHECK_XPATH_NODESET(n, STR("para[last()]")) % 6; -} - -TEST_XML(xpath_paths_abbrev_w3c_8, "") -{ - xml_node c; - - CHECK_XPATH_NODESET(c, STR("*/para")); - CHECK_XPATH_NODESET(doc, STR("*/para")) % 3 % 9; -} - -TEST_XML(xpath_paths_abbrev_w3c_9, "
") -{ - xml_node c; - xml_node n = doc.child(STR("doc")).child(STR("chapter")); - - CHECK_XPATH_NODESET(c, STR("/doc/chapter[5]/section[2]")); - CHECK_XPATH_NODESET(n, STR("/doc/chapter[5]/section[2]")) % 9; - CHECK_XPATH_NODESET(doc, STR("/doc/chapter[5]/section[2]")) % 9; -} - -TEST_XML(xpath_paths_abbrev_w3c_10, "") -{ - xml_node c; - - CHECK_XPATH_NODESET(c, STR("chapter//para")); - CHECK_XPATH_NODESET(doc, STR("chapter//para")) % 3 % 4 % 5 % 7 % 9; -} - -TEST_XML(xpath_paths_abbrev_w3c_11, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("//para")); - CHECK_XPATH_NODESET(n, STR("//para")) % 3 % 4 % 5 % 7 % 9; - CHECK_XPATH_NODESET(n.child(STR("para")), STR("//para")) % 3 % 4 % 5 % 7 % 9; -} - -TEST_XML(xpath_paths_abbrev_w3c_12, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("//olist/item")); - CHECK_XPATH_NODESET(n, STR("//olist/item")) % 4 % 8 % 9; - CHECK_XPATH_NODESET(n.child(STR("olist")), STR("//olist/item")) % 4 % 8 % 9; -} - -TEST_XML(xpath_paths_abbrev_w3c_13, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR(".")); - CHECK_XPATH_NODESET(n, STR(".")) % 2; - CHECK_XPATH_NODESET(n.child(STR("child")), STR(".")) % 3; -} - -TEST_XML(xpath_paths_abbrev_w3c_14, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR(".//para")); - CHECK_XPATH_NODESET(n, STR(".//para")) % 3 % 4 % 5 % 7 % 9; - CHECK_XPATH_NODESET(n.child(STR("para")), STR(".//para")) % 4 % 5 % 7; -} - -TEST_XML(xpath_paths_abbrev_w3c_15, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("..")); - CHECK_XPATH_NODESET(n, STR("..")) % 1; - CHECK_XPATH_NODESET(n.child(STR("child")), STR("..")) % 2; -} - -TEST_XML(xpath_paths_abbrev_w3c_16, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("../@lang")); - CHECK_XPATH_NODESET(n, STR("../@lang")); - CHECK_XPATH_NODESET(n.child(STR("child")), STR("../@lang")) % 3; -} - -TEST_XML(xpath_paths_abbrev_w3c_17, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("para[@type=\"warning\"]")); - CHECK_XPATH_NODESET(n, STR("para[@type=\"warning\"]")) % 4 % 6 % 11 % 13 % 15; -} - -TEST_XML(xpath_paths_abbrev_w3c_18, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("para[@type=\"warning\"][5]")); - CHECK_XPATH_NODESET(n, STR("para[@type=\"warning\"][5]")) % 15; -} - -TEST_XML(xpath_paths_abbrev_w3c_19a, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("para[5][@type=\"warning\"]")); - CHECK_XPATH_NODESET(n, STR("para[5][@type=\"warning\"]")); -} - -TEST_XML(xpath_paths_abbrev_w3c_19b, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("para[5][@type=\"warning\"]")); - CHECK_XPATH_NODESET(n, STR("para[5][@type=\"warning\"]")) % 9; -} - -TEST_XML(xpath_paths_abbrev_w3c_20, "fooIntroductionintroductionIntroductionfoo") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("chapter[title=\"Introduction\"]")); - CHECK_XPATH_NODESET(n, STR("chapter[title=\"Introduction\"]")) % 6 % 13; -} - -TEST_XML(xpath_paths_abbrev_w3c_21, "fooIntroductionintroductionIntroductionfoo") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("chapter[title]")); - CHECK_XPATH_NODESET(n, STR("chapter[title]")) % 3 % 6 % 9 % 13; -} - -TEST_XML(xpath_paths_abbrev_w3c_22, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("employee[@secretary and @assistant]")); - CHECK_XPATH_NODESET(n, STR("employee[@secretary and @assistant]")) % 8 % 11; -} - -#endif diff --git a/external/pugixml/tests/test_xpath_paths_w3c.cpp b/external/pugixml/tests/test_xpath_paths_w3c.cpp deleted file mode 100644 index 1bc21218c..000000000 --- a/external/pugixml/tests/test_xpath_paths_w3c.cpp +++ /dev/null @@ -1,312 +0,0 @@ -#ifndef PUGIXML_NO_XPATH - -#include "test.hpp" - -using namespace pugi; - -TEST_XML(xpath_paths_w3c_1, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::para")); - CHECK_XPATH_NODESET(n, STR("child::para")) % 3 % 5; -} - -TEST_XML(xpath_paths_w3c_2, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::*")); - CHECK_XPATH_NODESET(n, STR("child::*")) % 3 % 4 % 5; -} - -TEST_XML(xpath_paths_w3c_3, "pcdata") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::text()")); - CHECK_XPATH_NODESET(n, STR("child::text()")) % 3 % 5; -} - -TEST_XML(xpath_paths_w3c_4, "pcdata") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::node()")); - CHECK_XPATH_NODESET(n, STR("child::node()")) % 3 % 4 % 5; -} - -TEST_XML(xpath_paths_w3c_5, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("attribute::name")); - CHECK_XPATH_NODESET(n, STR("attribute::name")) % 3; -} - -TEST_XML(xpath_paths_w3c_6, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("attribute::*")); - CHECK_XPATH_NODESET(n, STR("attribute::*")) % 3 % 4; -} - -TEST_XML(xpath_paths_w3c_7, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("descendant::para")); - CHECK_XPATH_NODESET(n, STR("descendant::para")) % 3 % 4 % 5 % 7 % 9; - CHECK_XPATH_NODESET(n.child(STR("para")), STR("descendant::para")) % 4 % 5 % 7; -} - -TEST_XML(xpath_paths_w3c_8, "
") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("ancestor::div")); - CHECK_XPATH_NODESET(n.child(STR("div")).child(STR("font")).child(STR("div")).child(STR("div")), STR("ancestor::div")) % 5 % 3; -} - -TEST_XML(xpath_paths_w3c_9, "
") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("ancestor-or-self::div")); - CHECK_XPATH_NODESET(n.child(STR("div")).child(STR("font")).child(STR("div")).child(STR("div")), STR("ancestor-or-self::div")) % 6 % 5 % 3; -} - -TEST_XML(xpath_paths_w3c_10, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("descendant-or-self::para")); - CHECK_XPATH_NODESET(n, STR("descendant-or-self::para")) % 3 % 4 % 5 % 7 % 9; - CHECK_XPATH_NODESET(n.child(STR("para")), STR("descendant-or-self::para")) % 3 % 4 % 5 % 7; -} - -TEST_XML(xpath_paths_w3c_11, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("self::para")); - CHECK_XPATH_NODESET(n, STR("self::para")); - CHECK_XPATH_NODESET(n.child(STR("para")), STR("self::para")) % 3; -} - -TEST_XML(xpath_paths_w3c_12, "") -{ - xml_node c; - - CHECK_XPATH_NODESET(c, STR("child::chapter/descendant::para")); - CHECK_XPATH_NODESET(doc, STR("child::chapter/descendant::para")) % 3 % 4 % 5 % 7 % 9; -} - -TEST_XML(xpath_paths_w3c_13, "") -{ - xml_node c; - - CHECK_XPATH_NODESET(c, STR("child::*/child::para")); - CHECK_XPATH_NODESET(doc, STR("child::*/child::para")) % 3 % 9; -} - -TEST_XML(xpath_paths_w3c_14, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("/")); - - CHECK_XPATH_NODESET(doc, STR("/")) % 1; - CHECK_XPATH_NODESET(n, STR("/")) % 1; - CHECK_XPATH_NODESET(n.child(STR("para")), STR("/")) % 1; -} - -TEST_XML(xpath_paths_w3c_15, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("/descendant::para")); - CHECK_XPATH_NODESET(n, STR("/descendant::para")) % 3 % 4 % 5 % 7 % 9; - CHECK_XPATH_NODESET(n.child(STR("para")), STR("/descendant::para")) % 3 % 4 % 5 % 7 % 9; -} - -TEST_XML(xpath_paths_w3c_16, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("/descendant::olist/child::item")); - CHECK_XPATH_NODESET(n, STR("/descendant::olist/child::item")) % 4 % 8 % 9; - CHECK_XPATH_NODESET(n.child(STR("olist")), STR("/descendant::olist/child::item")) % 4 % 8 % 9; -} - -TEST_XML(xpath_paths_w3c_17, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::para[position()=1]")); - CHECK_XPATH_NODESET(n, STR("child::para[position()=1]")) % 3; -} - -TEST_XML(xpath_paths_w3c_18, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::para[position()=last()]")); - CHECK_XPATH_NODESET(n, STR("child::para[position()=last()]")) % 6; -} - -TEST_XML(xpath_paths_w3c_19, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::para[position()=last()-1]")); - CHECK_XPATH_NODESET(n, STR("child::para[position()=last()-1]")) % 5; -} - -TEST_XML(xpath_paths_w3c_20, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::para[position()>1]")); - CHECK_XPATH_NODESET(n, STR("child::para[position()>1]")) % 4 % 5 % 6; -} - -TEST_XML(xpath_paths_w3c_21, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling(); - - CHECK_XPATH_NODESET(c, STR("following-sibling::chapter[position()=1]")); - CHECK_XPATH_NODESET(n, STR("following-sibling::chapter[position()=1]")) % 6; -} - -TEST_XML(xpath_paths_w3c_22, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")).child(STR("chapter")).next_sibling().next_sibling(); - - CHECK_XPATH_NODESET(c, STR("preceding-sibling::chapter[position()=1]")); - CHECK_XPATH_NODESET(n, STR("preceding-sibling::chapter[position()=1]")) % 4; -} - -TEST_XML(xpath_paths_w3c_23, "
") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("/descendant::figure[position()=4]")); - CHECK_XPATH_NODESET(n, STR("/descendant::figure[position()=4]")) % 7; - CHECK_XPATH_NODESET(n.child(STR("figure")), STR("/descendant::figure[position()=4]")) % 7; -} - -TEST_XML(xpath_paths_w3c_24, "
") -{ - xml_node c; - xml_node n = doc.child(STR("doc")).child(STR("chapter")); - - CHECK_XPATH_NODESET(c, STR("/child::doc/child::chapter[position()=5]/child::section[position()=2]")); - CHECK_XPATH_NODESET(n, STR("/child::doc/child::chapter[position()=5]/child::section[position()=2]")) % 9; - CHECK_XPATH_NODESET(doc, STR("/child::doc/child::chapter[position()=5]/child::section[position()=2]")) % 9; -} - -TEST_XML(xpath_paths_w3c_25, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::para[attribute::type=\"warning\"]")); - CHECK_XPATH_NODESET(n, STR("child::para[attribute::type=\"warning\"]")) % 4 % 6 % 11 % 13 % 15; -} - -TEST_XML(xpath_paths_w3c_26, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::para[attribute::type=\"warning\"][position()=5]")); - CHECK_XPATH_NODESET(n, STR("child::para[attribute::type=\"warning\"][position()=5]")) % 15; -} - -TEST_XML(xpath_paths_w3c_27a, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::para[position()=5][attribute::type=\"warning\"]")); - CHECK_XPATH_NODESET(n, STR("child::para[position()=5][attribute::type=\"warning\"]")); -} - -TEST_XML(xpath_paths_w3c_27b, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::para[position()=5][attribute::type=\"warning\"]")); - CHECK_XPATH_NODESET(n, STR("child::para[position()=5][attribute::type=\"warning\"]")) % 9; -} - -TEST_XML(xpath_paths_w3c_28, "fooIntroductionintroductionIntroductionfoo") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::chapter[child::title='Introduction']")); - CHECK_XPATH_NODESET(n, STR("child::chapter[child::title='Introduction']")) % 6 % 13; -} - -TEST_XML(xpath_paths_w3c_29, "fooIntroductionintroductionIntroductionfoo") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::chapter[child::title]")); - CHECK_XPATH_NODESET(n, STR("child::chapter[child::title]")) % 3 % 6 % 9 % 13; -} - -TEST_XML(xpath_paths_w3c_30, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::*[self::chapter or self::appendix]")); - CHECK_XPATH_NODESET(n, STR("child::*[self::chapter or self::appendix]")) % 4 % 5 % 7; -} - -TEST_XML(xpath_paths_w3c_31a, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::*[self::chapter or self::appendix][position()=last()]")); - CHECK_XPATH_NODESET(n, STR("child::*[self::chapter or self::appendix][position()=last()]")) % 7; -} - -TEST_XML(xpath_paths_w3c_31b, "") -{ - xml_node c; - xml_node n = doc.child(STR("node")); - - CHECK_XPATH_NODESET(c, STR("child::*[self::chapter or self::appendix][position()=last()]")); - CHECK_XPATH_NODESET(n, STR("child::*[self::chapter or self::appendix][position()=last()]")) % 8; -} - -#endif diff --git a/external/pugixml/tests/test_xpath_variables.cpp b/external/pugixml/tests/test_xpath_variables.cpp deleted file mode 100644 index adc4464c9..000000000 --- a/external/pugixml/tests/test_xpath_variables.cpp +++ /dev/null @@ -1,671 +0,0 @@ -#ifndef PUGIXML_NO_XPATH - -#include "test.hpp" - -#include - -using namespace pugi; - -TEST(xpath_variables_type_none) -{ - xpath_variable_set set; - - xpath_variable* var = set.add(STR("target"), xpath_type_none); - CHECK(!var); -} - -TEST(xpath_variables_type_boolean) -{ - xpath_variable_set set; - - xpath_variable* var = set.add(STR("target"), xpath_type_boolean); - CHECK(var); - - CHECK(var->type() == xpath_type_boolean); - CHECK_STRING(var->name(), STR("target")); - - CHECK(var->get_boolean() == false); - CHECK_DOUBLE_NAN(var->get_number()); - CHECK_STRING(var->get_string(), STR("")); - CHECK(var->get_node_set().empty()); - - CHECK(var->set(true)); - CHECK(!var->set(1.0)); - CHECK(!var->set(STR("abc"))); - CHECK(!var->set(xpath_node_set())); - - CHECK(var->get_boolean() == true); - CHECK_DOUBLE_NAN(var->get_number()); - CHECK_STRING(var->get_string(), STR("")); - CHECK(var->get_node_set().empty()); -} - -TEST(xpath_variables_type_number) -{ - xpath_variable_set set; - - xpath_variable* var = set.add(STR("target"), xpath_type_number); - CHECK(var); - - CHECK(var->type() == xpath_type_number); - CHECK_STRING(var->name(), STR("target")); - - CHECK(var->get_boolean() == false); - CHECK_DOUBLE(var->get_number(), 0); - CHECK_STRING(var->get_string(), STR("")); - CHECK(var->get_node_set().empty()); - - CHECK(!var->set(true)); - CHECK(var->set(1.0)); - CHECK(!var->set(STR("abc"))); - CHECK(!var->set(xpath_node_set())); - - CHECK(var->get_boolean() == false); - CHECK_DOUBLE(var->get_number(), 1); - CHECK_STRING(var->get_string(), STR("")); - CHECK(var->get_node_set().empty()); -} - -TEST(xpath_variables_type_string) -{ - xpath_variable_set set; - - xpath_variable* var = set.add(STR("target"), xpath_type_string); - CHECK(var); - - CHECK(var->type() == xpath_type_string); - CHECK_STRING(var->name(), STR("target")); - - CHECK(var->get_boolean() == false); - CHECK_DOUBLE_NAN(var->get_number()); - CHECK_STRING(var->get_string(), STR("")); - CHECK(var->get_node_set().empty()); - - CHECK(!var->set(true)); - CHECK(!var->set(1.0)); - CHECK(var->set(STR("abc"))); - CHECK(!var->set(xpath_node_set())); - - CHECK(var->get_boolean() == false); - CHECK_DOUBLE_NAN(var->get_number()); - CHECK_STRING(var->get_string(), STR("abc")); - CHECK(var->get_node_set().empty()); - - CHECK(var->set(STR("abcdef"))); - CHECK_STRING(var->get_string(), STR("abcdef")); -} - -TEST_XML(xpath_variables_type_node_set, "") -{ - xpath_variable_set set; - - xpath_variable* var = set.add(STR("target"), xpath_type_node_set); - CHECK(var); - - CHECK(var->type() == xpath_type_node_set); - CHECK_STRING(var->name(), STR("target")); - - CHECK(var->get_boolean() == false); - CHECK_DOUBLE_NAN(var->get_number()); - CHECK_STRING(var->get_string(), STR("")); - CHECK(var->get_node_set().empty()); - - CHECK(!var->set(true)); - CHECK(!var->set(1.0)); - CHECK(!var->set(STR("abc"))); - CHECK(var->set(doc.select_nodes(STR("*")))); - - CHECK(var->get_boolean() == false); - CHECK_DOUBLE_NAN(var->get_number()); - CHECK_STRING(var->get_string(), STR("")); - CHECK(var->get_node_set().size() == 1 && var->get_node_set()[0] == doc.first_child()); -} - -TEST(xpath_variables_set_operations) -{ - xpath_variable_set set; - - xpath_variable* v1 = set.add(STR("var1"), xpath_type_number); - CHECK(v1); - - xpath_variable* v2 = set.add(STR("var2"), xpath_type_string); - CHECK(v2); - - CHECK(v1 != v2); - - CHECK(set.add(STR("var1"), xpath_type_number) == v1); - CHECK(set.add(STR("var2"), xpath_type_string) == v2); - CHECK(set.add(STR("var2"), xpath_type_node_set) == 0); - - CHECK(set.get(STR("var1")) == v1); - CHECK(set.get(STR("var2")) == v2); - CHECK(set.get(STR("var")) == 0); - CHECK(set.get(STR("var11")) == 0); - - CHECK(static_cast(set).get(STR("var1")) == v1); - CHECK(static_cast(set).get(STR("var3")) == 0); -} - -TEST_XML(xpath_variables_set_operations_set, "") -{ - xpath_variable_set set; - - xpath_variable* v1 = set.add(STR("var1"), xpath_type_number); - CHECK(v1); - - xpath_variable* v2 = set.add(STR("var2"), xpath_type_string); - CHECK(v2); - - CHECK(set.set(STR("var1"), 1.0)); - CHECK_DOUBLE(v1->get_number(), 1.0); - - CHECK(set.set(STR("var2"), STR("value"))); - CHECK_STRING(v2->get_string(), STR("value")); - - CHECK(!set.set(STR("var1"), true)); - - CHECK(set.set(STR("var3"), doc.select_nodes(STR("*")))); - - xpath_variable* v3 = set.get(STR("var3")); - - CHECK(v3); - CHECK(v3->type() == xpath_type_node_set); - CHECK(v3->get_node_set().size() == 1); -} - -TEST(xpath_variables_set_out_of_memory) -{ - test_runner::_memory_fail_threshold = 1; - - xpath_variable_set set; - - xpath_variable* var = 0; - CHECK_ALLOC_FAIL(var = set.add(STR("target"), xpath_type_number)); - CHECK(!var); -} - -TEST(xpath_variables_out_of_memory) -{ - test_runner::_memory_fail_threshold = 64; - - xpath_variable_set set; - - xpath_variable* var = set.add(STR("target"), xpath_type_string); - CHECK(var); - - CHECK_ALLOC_FAIL(CHECK(!var->set(STR("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")))); -} - -TEST_XML(xpath_variables_evaluate, "") -{ - xpath_variable_set set; - set.set(STR("var1"), true); - set.set(STR("var2"), 0.5); - set.set(STR("var3"), STR("value")); - set.set(STR("var4"), doc.select_nodes(STR("*"))); - - CHECK_XPATH_BOOLEAN_VAR(doc, STR("$var1"), &set, true); - CHECK_XPATH_NUMBER_VAR(doc, STR("$var2"), &set, 0.5); - CHECK_XPATH_STRING_VAR(doc, STR("$var3"), &set, STR("value")); - CHECK_XPATH_NODESET_VAR(doc, STR("$var4"), &set) % 2; -} - -TEST_XML(xpath_variables_evaluate_conversion, "3") -{ - xpath_variable_set set; - set.set(STR("var"), doc.select_nodes(STR("*"))); - - CHECK_XPATH_BOOLEAN_VAR(doc, STR("$var"), &set, true); - CHECK_XPATH_NUMBER_VAR(doc, STR("$var"), &set, 3); - CHECK_XPATH_STRING_VAR(doc, STR("$var"), &set, STR("3")); - CHECK_XPATH_NODESET_VAR(doc, STR("$var"), &set) % 2; -} - -TEST(xpath_variables_evaluate_node_set_fail) -{ - xpath_variable_set set; - set.set(STR("var"), false); - - xpath_query q(STR("$var"), &set); - -#ifdef PUGIXML_NO_EXCEPTIONS - CHECK(q.evaluate_node_set(xml_node()).empty()); -#else - try - { - q.evaluate_node_set(xml_node()); - - CHECK_FORCE_FAIL("Expected exception"); - } - catch (const xpath_exception&) - { - } -#endif -} - -TEST(xpath_variables_multiple_documents) -{ - xml_document doc; - doc.append_child().set_name(STR("node")); - - xml_document doc1; - doc1.append_child().set_name(STR("node")); - - xml_document doc2; - doc2.append_child().set_name(STR("node")); - - xpath_variable_set set; - set.set(STR("var1"), doc1.select_nodes(STR("*"))); - set.set(STR("var2"), doc2.select_nodes(STR("*"))); - - xpath_node_set ns = doc.select_nodes(STR("$var1 | $var2 | node"), &set); - ns.sort(); - - CHECK(ns.size() == 3); - CHECK(ns[0] != ns[1] && ns[0] != ns[2]); - - xml_node n0 = doc.child(STR("node")), n1 = doc1.child(STR("node")), n2 = doc2.child(STR("node")); - - CHECK(n0 == ns[0].node() || n0 == ns[1].node() || n0 == ns[2].node()); - CHECK(n1 == ns[0].node() || n1 == ns[1].node() || n1 == ns[2].node()); - CHECK(n2 == ns[0].node() || n2 == ns[1].node() || n2 == ns[2].node()); -} - -TEST(xpath_variables_long_name) -{ - xpath_variable_set set; - set.set(STR("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), true); - - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &set, true); -} - -TEST(xpath_variables_long_name_out_of_memory) -{ - xpath_variable_set set; - set.set(STR("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), true); - - test_runner::_memory_fail_threshold = 4096 + 64 + 52 * sizeof(char_t); - - CHECK_ALLOC_FAIL(CHECK(!xpath_query(STR("$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &set))); -} - -TEST_XML(xpath_variables_select, "") -{ - xpath_variable_set set; - set.set(STR("one"), 1.0); - - xpath_node_set ns = doc.select_nodes(STR("node[@attr=$one+1]"), &set); - CHECK(ns.size() == 1 && ns[0].node() == doc.last_child()); - - xpath_node n = doc.select_node(STR("node[@attr=$one+1]"), &set); - CHECK(n == ns[0]); -} - -TEST(xpath_variables_empty_name) -{ - xpath_variable_set set; - CHECK(!set.add(STR(""), xpath_type_node_set)); - CHECK(!set.add(STR(""), xpath_type_number)); - CHECK(!set.add(STR(""), xpath_type_string)); - CHECK(!set.add(STR(""), xpath_type_boolean)); -} - -TEST(xpath_variables_long_name_out_of_memory_add) -{ - std::basic_string name(1000, 'a'); - - test_runner::_memory_fail_threshold = 1000; - - xpath_variable_set set; - CHECK_ALLOC_FAIL(CHECK(!set.add(name.c_str(), xpath_type_node_set))); - CHECK_ALLOC_FAIL(CHECK(!set.add(name.c_str(), xpath_type_number))); - CHECK_ALLOC_FAIL(CHECK(!set.add(name.c_str(), xpath_type_string))); - CHECK_ALLOC_FAIL(CHECK(!set.add(name.c_str(), xpath_type_boolean))); -} - -TEST_XML(xpath_variables_inside_filter, "") -{ - xpath_variable_set set; - set.set(STR("one"), 1.0); - - xpath_node_set ns = doc.select_nodes(STR("(node[@key = $one])[@value = $one]"), &set); - CHECK(ns.size() == 1 && ns[0].node() == doc.last_child()); -} - -TEST_XML(xpath_variables_step, "") -{ - xpath_variable_set set; - set.set(STR("root"), doc.select_nodes(STR("node"))); - - CHECK_XPATH_NODESET_VAR(xml_node(), STR("$root/child"), &set) % 3 % 4 % 5; - CHECK_XPATH_NODESET_VAR(xml_node(), STR("$root//child"), &set) % 3 % 4 % 5 % 6; -} - -TEST_XML(xpath_variables_index, "") -{ - xpath_variable_set set; - set.set(STR("index"), 2.0); - - CHECK_XPATH_NODESET_VAR(doc, STR("node/child[$index]"), &set) % 4; - CHECK_XPATH_NODESET_VAR(doc, STR("node/child[position()=$index]"), &set) % 4; -} - -TEST(xpath_variables_qname) -{ - xpath_variable_set set; - set.set(STR("foo:bar"), true); - - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("$foo:bar"), &set, true); -} - -TEST(xpath_variables_name_error) -{ - xpath_variable_set set; - set.set(STR("foo:"), true); - set.set(STR(":bar"), true); - set.set(STR("foo:*"), true); - set.set(STR("foo"), true); - set.set(STR("3"), true); - - CHECK_XPATH_FAIL_VAR(STR("$foo:"), &set); - CHECK_XPATH_FAIL_VAR(STR("$:bar"), &set); - CHECK_XPATH_FAIL_VAR(STR("$foo:*"), &set); - CHECK_XPATH_FAIL_VAR(STR("$foo:bar:baz"), &set); - CHECK_XPATH_FAIL_VAR(STR("$ foo"), &set); - - CHECK_XPATH_FAIL_VAR(STR("$3"), &set); -} - -TEST(xpath_variables_empty_string) -{ - xpath_variable_set set; - set.add(STR("empty"), xpath_type_string); - - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("$empty = substring-before('a', 'z')"), &set, true); -} - -TEST(xpath_variables_name_underscore) -{ - xpath_variable_set set; - set.set(STR("_foo_bar"), true); - - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("$_foo_bar"), &set, true); -} - -TEST(xpath_variables_name_case) -{ - xpath_variable_set set; - set.set(STR("i"), 5.0); - set.set(STR("I"), 2.0); - - CHECK_XPATH_NUMBER_VAR(xml_node(), STR("$i div $I"), &set, 2.5); -} - -TEST(xpath_variables_name_unicode) -{ -#ifdef PUGIXML_WCHAR_MODE - #ifdef U_LITERALS - const char_t* name = L"\u0400\u203D"; - #else - const char_t* name = L"\x0400\x203D"; - #endif -#else - const char_t* name = "\xd0\x80\xe2\x80\xbd"; -#endif - - xpath_variable_set set; - set.set(name, STR("value")); - - std::basic_string var = STR("$"); - var += name; - - CHECK_XPATH_STRING_VAR(xml_node(), var.c_str(), &set, STR("value")); -} - -TEST_XML(xpath_variables_count_sum, "122334") -{ - xpath_variable_set set; - set.set(STR("c12"), doc.select_nodes(STR("node/c1 | node/c2"))); - set.set(STR("c3"), doc.select_nodes(STR("node/c3"))); - set.set(STR("c"), doc.select_nodes(STR("node/*"))); - - CHECK_XPATH_NUMBER_VAR(xml_node(), STR("sum($c12) * count($c) - sum($c3)"), &set, 71); -} - -TEST_XML(xpath_variables_copy, "") -{ - xpath_variable_set set1; - set1.set(STR("a"), true); - set1.set(STR("b"), 2.0); - set1.set(STR("c"), STR("string")); - set1.set(STR("d"), doc.select_nodes(STR("//*"))); - - CHECK_XPATH_STRING_VAR(xml_node(), STR("substring($c, count($d[$a]) + $b)"), &set1, STR("ring")); - - xpath_variable_set set2 = set1; - - CHECK_XPATH_STRING_VAR(xml_node(), STR("substring($c, count($d[$a]) + $b)"), &set2, STR("ring")); - - xpath_variable_set set3; - - CHECK(!set3.get(STR("a"))); - - set3 = set1; - - CHECK_XPATH_STRING_VAR(xml_node(), STR("substring($c, count($d[$a]) + $b)"), &set2, STR("ring")); - - set3 = xpath_variable_set(set3); - - CHECK_XPATH_STRING_VAR(xml_node(), STR("substring($c, count($d[$a]) + $b)"), &set2, STR("ring")); - - set3 = xpath_variable_set(); - - CHECK(!set3.get(STR("a"))); -} - -TEST_XML(xpath_variables_copy_out_of_memory, "") -{ - xpath_variable_set set1; - set1.set(STR("a"), true); - set1.set(STR("b"), 2.0); - set1.set(STR("c"), STR("string")); - set1.set(STR("d"), doc.select_nodes(STR("//*"))); - - xpath_variable_set set2 = set1; - - test_runner::_memory_fail_threshold = 32768 + 75 * sizeof(void*); - - CHECK_ALLOC_FAIL(xpath_variable_set set3 = set1); - - xpath_variable_set set4; - - CHECK_ALLOC_FAIL(set4 = set1); - CHECK(!set4.get(STR("a")) && !set4.get(STR("b")) && !set4.get(STR("c")) && !set4.get(STR("d"))); - - CHECK_ALLOC_FAIL(set2 = set1); - - CHECK(set2.get(STR("a")) && set2.get(STR("b")) && set2.get(STR("c")) && set2.get(STR("d"))); - - CHECK(set2.get(STR("a"))->get_boolean() == true); - CHECK(set2.get(STR("b"))->get_number() == 2.0); - CHECK_STRING(set2.get(STR("c"))->get_string(), STR("string")); - CHECK(set2.get(STR("d"))->get_node_set().size() == 2); -} - -TEST(xpath_variables_copy_out_of_memory_clone) -{ - xpath_variable_set set1; - set1.set(STR("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"), true); - - xpath_variable_set set2 = set1; - - test_runner::_memory_fail_threshold = 60; - - CHECK_ALLOC_FAIL(xpath_variable_set set3 = set1); -} - -#ifdef PUGIXML_HAS_MOVE -TEST_XML(xpath_variables_move, "") -{ - xpath_variable_set set; - set.set(STR("a"), true); - set.set(STR("b"), 2.0); - set.set(STR("c"), STR("string")); - set.set(STR("d"), doc.select_nodes(STR("//*"))); - - xpath_variable_set copy = set; - copy.set(STR("e"), 42.0); - - test_runner::_memory_fail_threshold = 1; - - xpath_variable_set move1 = std::move(set); - - CHECK(!set.get(STR("a")) && !set.get(STR("b")) && !set.get(STR("c")) && !set.get(STR("d"))); - CHECK(move1.get(STR("a")) && move1.get(STR("b")) && move1.get(STR("c")) && move1.get(STR("d"))); - - CHECK(move1.get(STR("a"))->get_boolean() == true); - CHECK(move1.get(STR("b"))->get_number() == 2.0); - CHECK_STRING(move1.get(STR("c"))->get_string(), STR("string")); - CHECK(move1.get(STR("d"))->get_node_set().size() == 1); - - xpath_variable_set move2; - move2 = std::move(move1); - - CHECK(!move1.get(STR("a")) && !move1.get(STR("b")) && !move1.get(STR("c")) && !move1.get(STR("d"))); - CHECK(move2.get(STR("a")) && move2.get(STR("b")) && move2.get(STR("c")) && move2.get(STR("d"))); - - CHECK(copy.get(STR("e"))); - - copy = std::move(move2); - - CHECK(!move2.get(STR("a")) && !move2.get(STR("b")) && !move2.get(STR("c")) && !move2.get(STR("d"))); - CHECK(copy.get(STR("a")) && copy.get(STR("b")) && copy.get(STR("c")) && copy.get(STR("d"))); - CHECK(!copy.get(STR("e"))); - - CHECK(copy.get(STR("a"))->get_boolean() == true); - CHECK(copy.get(STR("b"))->get_number() == 2.0); - CHECK_STRING(copy.get(STR("c"))->get_string(), STR("string")); - CHECK(copy.get(STR("d"))->get_node_set().size() == 1); -} -#endif - -TEST(xpath_variables_copy_big) -{ - xpath_variable_set set; - - for (int i = 0; i < 100; ++i) - { - char_t name[4]; - name[0] = 'a'; - name[1] = char_t('0' + i / 10); - name[2] = char_t('0' + i % 10); - name[3] = 0; - - set.set(name, double(i)); - } - - xpath_variable_set copy = set; - - for (int j = 0; j < 100; ++j) - { - char_t name[4]; - name[0] = 'a'; - name[1] = char_t('0' + j / 10); - name[2] = char_t('0' + j % 10); - name[3] = 0; - - CHECK(copy.get(name) && copy.get(name)->get_number() == j); - } -} - -TEST(xpath_variables_copy_big_out_of_memory) -{ - xpath_variable_set set; - - for (int i = 0; i < 100; ++i) - { - char_t name[4]; - name[0] = 'a'; - name[1] = char_t('0' + i / 10); - name[2] = char_t('0' + i % 10); - name[3] = 0; - - set.set(name, double(i)); - } - - test_runner::_memory_fail_threshold = 1; - - xpath_variable_set copy; - CHECK_ALLOC_FAIL(copy = set); - - for (int j = 0; j < 100; ++j) - { - char_t name[4]; - name[0] = 'a'; - name[1] = char_t('0' + j / 10); - name[2] = char_t('0' + j % 10); - name[3] = 0; - - CHECK(!copy.get(name)); - } -} - -TEST(xpath_variables_copy_big_value_out_of_memory) -{ - xpath_variable_set set; - - std::basic_string var(10000, 'a'); - set.set(STR("x"), var.c_str()); - - test_runner::_memory_fail_threshold = 15000; - - xpath_variable_set copy; - CHECK_ALLOC_FAIL(copy = set); - - CHECK(!copy.get(STR("x"))); -} - -TEST_XML(xpath_variables_evaluate_node_set_out_of_memory, "") -{ - for (size_t i = 0; i < 600; ++i) - doc.append_child(STR("node")); - - xpath_node_set ns = doc.select_nodes(STR("node")); - CHECK(ns.size() == 601); - - xpath_variable_set set; - set.set(STR("nodes"), ns); - - xpath_query q(STR("$nodes"), &set); - - test_runner::_memory_fail_threshold = 1; - - CHECK_ALLOC_FAIL(q.evaluate_node_set(xml_node()).empty()); -} - -TEST_XML(xpath_variables_type_conversion, "15") -{ - xpath_variable_set set; - - set.set(STR("a"), true); - set.set(STR("b"), 42.0); - set.set(STR("c"), STR("test")); - set.set(STR("d"), doc.select_nodes(STR("node"))); - - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("boolean($a) = true()"), &set, true); - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("number($a) = 1"), &set, true); - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("string($a) = 'true'"), &set, true); - - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("boolean($b) = true()"), &set, true); - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("number($b) = 42"), &set, true); - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("string($b) = '42'"), &set, true); - - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("boolean($c) = true()"), &set, true); - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("number($c) = 0"), &set, false); - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("string($c) = 'test'"), &set, true); - - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("boolean($d) = true()"), &set, true); - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("number($d) = 15"), &set, true); - CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("string($d) = '15'"), &set, true); -} -#endif diff --git a/external/pugixml/tests/test_xpath_xalan_1.cpp b/external/pugixml/tests/test_xpath_xalan_1.cpp deleted file mode 100644 index 0127ddd7b..000000000 --- a/external/pugixml/tests/test_xpath_xalan_1.cpp +++ /dev/null @@ -1,411 +0,0 @@ -#ifndef PUGIXML_NO_XPATH - -#include "test.hpp" - -using namespace pugi; - -TEST(xpath_xalan_boolean_1) -{ - xml_node c; - - CHECK_XPATH_BOOLEAN(c, STR("true()"), true); - CHECK_XPATH_BOOLEAN(c, STR("true() and true()"), true); - CHECK_XPATH_BOOLEAN(c, STR("true() or true()"), true); - CHECK_XPATH_BOOLEAN(c, STR("not(true())"), false); - CHECK_XPATH_BOOLEAN(c, STR("boolean('')"), false); - CHECK_XPATH_BOOLEAN(c, STR("1>2"), false); - CHECK_XPATH_BOOLEAN(c, STR("1>=2"), false); - CHECK_XPATH_BOOLEAN(c, STR("false()"), false); - CHECK_XPATH_BOOLEAN(c, STR("1=1"), true); - CHECK_XPATH_BOOLEAN(c, STR("1=2"), false); - CHECK_XPATH_BOOLEAN(c, STR("1 = 1.00"), true); - CHECK_XPATH_BOOLEAN(c, STR("0 = -0"), true); - CHECK_XPATH_BOOLEAN(c, STR("1 = '001'"), true); - CHECK_XPATH_BOOLEAN(c, STR("true()='0'"), true); - CHECK_XPATH_BOOLEAN(c, STR("false()=''"), true); - CHECK_XPATH_BOOLEAN(c, STR("true()=2"), true); - CHECK_XPATH_BOOLEAN(c, STR("false()=0"), true); - CHECK_XPATH_BOOLEAN(c, STR("false() and false()"), false); - CHECK_XPATH_BOOLEAN(c, STR("'foo' and 'fop'"), true); - CHECK_XPATH_BOOLEAN(c, STR("true() and false()"), false); - CHECK_XPATH_BOOLEAN(c, STR("false() and true()"), false); - CHECK_XPATH_BOOLEAN(c, STR("'1' and '0'"), true); - CHECK_XPATH_BOOLEAN(c, STR("true() or false()"), true); - CHECK_XPATH_BOOLEAN(c, STR("false() or true()"), true); - CHECK_XPATH_BOOLEAN(c, STR("false() or false()"), false); - CHECK_XPATH_BOOLEAN(c, STR("0 or ''"), false); - CHECK_XPATH_BOOLEAN(c, STR("not(false())"), true); - CHECK_XPATH_BOOLEAN(c, STR("not(false() = false())"), false); - CHECK_XPATH_BOOLEAN(c, STR("not(true() = false())"), true); - CHECK_XPATH_BOOLEAN(c, STR("not('')"), true); - CHECK_XPATH_BOOLEAN(c, STR("not('0')"), false); - CHECK_XPATH_BOOLEAN(c, STR("boolean('0')"), true); - CHECK_XPATH_BOOLEAN(c, STR("boolean(0)"), false); - CHECK_XPATH_BOOLEAN(c, STR("boolean(-0)"), false); - CHECK_XPATH_BOOLEAN(c, STR("boolean(1)"), true); - CHECK_XPATH_BOOLEAN(c, STR("boolean(1 div 0)"), true); - CHECK_XPATH_BOOLEAN(c, STR("boolean(0 div 0)"), false); -} - -TEST_XML(xpath_xalan_boolean_2, "") -{ - CHECK_XPATH_BOOLEAN(doc, STR("boolean(doc)"), true); - CHECK_XPATH_BOOLEAN(doc, STR("boolean(foo)"), false); -} - -TEST(xpath_xalan_boolean_3) -{ - xml_node c; - - CHECK_XPATH_BOOLEAN(c, STR("1>1"), false); - CHECK_XPATH_BOOLEAN(c, STR("2>1"), true); - CHECK_XPATH_BOOLEAN(c, STR("1<2"), true); - CHECK_XPATH_BOOLEAN(c, STR("1<1"), false); - CHECK_XPATH_BOOLEAN(c, STR("2<1"), false); - CHECK_XPATH_BOOLEAN(c, STR("'2'>'1'"), true); - CHECK_XPATH_BOOLEAN(c, STR("0 > -0"), false); - CHECK_XPATH_BOOLEAN(c, STR("2>=2"), true); - CHECK_XPATH_BOOLEAN(c, STR("2>=1"), true); - CHECK_XPATH_BOOLEAN(c, STR("1<=2"), true); - CHECK_XPATH_BOOLEAN(c, STR("1<=1"), true); - CHECK_XPATH_BOOLEAN(c, STR("2<=1"), false); - CHECK_XPATH_BOOLEAN(c, STR("false() and 1 div 0"), false); - CHECK_XPATH_BOOLEAN(c, STR("true() or 1 div 0"), true); - CHECK_XPATH_BOOLEAN(c, STR("1!=1"), false); - CHECK_XPATH_BOOLEAN(c, STR("1!=2"), true); - CHECK_XPATH_BOOLEAN(c, STR("1!=1.00"), false); - CHECK_XPATH_BOOLEAN(c, STR("false()!=true()"), true); - CHECK_XPATH_BOOLEAN(c, STR("true()!=false()"), true); - CHECK_XPATH_BOOLEAN(c, STR("false()!=false()"), false); - CHECK_XPATH_BOOLEAN(c, STR("'ace' != 'ace'"), false); - CHECK_XPATH_BOOLEAN(c, STR("'ace' != 'abc'"), true); - CHECK_XPATH_BOOLEAN(c, STR("'H' != ' H'"), true); - CHECK_XPATH_BOOLEAN(c, STR("'H' != 'H '"), true); - CHECK_XPATH_BOOLEAN(c, STR("1.9999999 < 2.0"), true); - CHECK_XPATH_BOOLEAN(c, STR("2.0000001 < 2.0"), false); - CHECK_XPATH_BOOLEAN(c, STR("1.9999999 < 2"), true); - CHECK_XPATH_BOOLEAN(c, STR("2 < 2.0"), false); - CHECK_XPATH_BOOLEAN(c, STR("'001' = 1"), true); - CHECK_XPATH_BOOLEAN(c, STR("0=false()"), true); - CHECK_XPATH_BOOLEAN(c, STR("'0'=true()"), true); -} - -TEST_XML(xpath_xalan_boolean_4, "foobarfoobarfoo") -{ - CHECK_XPATH_BOOLEAN(doc, STR("avj/*='foo'"), true); - CHECK_XPATH_BOOLEAN(doc, STR("not(avj/*='foo')"), false); - CHECK_XPATH_BOOLEAN(doc, STR("avj/*!='foo'"), true); - CHECK_XPATH_BOOLEAN(doc, STR("not(avj/*!='foo')"), false); - - CHECK_XPATH_BOOLEAN(doc, STR("avj/k='foo'"), false); - CHECK_XPATH_BOOLEAN(doc, STR("not(avj/k='foo')"), true); - CHECK_XPATH_BOOLEAN(doc, STR("avj/k!='foo'"), false); - CHECK_XPATH_BOOLEAN(doc, STR("not(avj/k!='foo')"), true); -} - -TEST_XML(xpath_xalan_boolean_5, "firstsecondthirdfourth") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_BOOLEAN(c, STR("j[@l='12'] = j[@w='33']"), true); - CHECK_XPATH_BOOLEAN(c, STR("j[@l='12'] = j[@l='17']"), false); - CHECK_XPATH_BOOLEAN(c, STR("j[@l='12'] = j[.='first' or @w='45']"), true); - - CHECK_XPATH_BOOLEAN(c, STR("j[@l='12'] != j[@w='33']"), true); - CHECK_XPATH_BOOLEAN(c, STR("j[@l='12'] != j[@l='17']"), true); - CHECK_XPATH_BOOLEAN(c, STR("j[@l='12'] != j[.='first' or @w='45']"), true); - CHECK_XPATH_BOOLEAN(c, STR("j[@l='16'] != j[@w='78']"), false); -} - -TEST_XML(xpath_xalan_boolean_6, "12345678") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_BOOLEAN(c, STR("avj/good/*=34"), true); - CHECK_XPATH_BOOLEAN(c, STR("not(avj/good/*=34)"), false); - CHECK_XPATH_BOOLEAN(c, STR("avj/good/*!=34"), true); - CHECK_XPATH_BOOLEAN(c, STR("not(avj/good/*!=34)"), false); - - CHECK_XPATH_BOOLEAN(c, STR("34=avj/good/*"), true); - CHECK_XPATH_BOOLEAN(c, STR("not(34=avj/good/*)"), false); - CHECK_XPATH_BOOLEAN(c, STR("34!=avj/good/*"), true); - CHECK_XPATH_BOOLEAN(c, STR("not(34!=avj/good/*)"), false); -} - -TEST_XML(xpath_xalan_boolean_7, "truefalse?10") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_BOOLEAN(c, STR("avj/bool/*=true()"), true); - CHECK_XPATH_BOOLEAN(c, STR("not(avj/bool/*=true())"), false); - CHECK_XPATH_BOOLEAN(c, STR("avj/bool/*!=true()"), false); - CHECK_XPATH_BOOLEAN(c, STR("not(avj/bool/*!=true())"), true); - - CHECK_XPATH_BOOLEAN(c, STR("true()=avj/bool/*"), true); - CHECK_XPATH_BOOLEAN(c, STR("not(true()=avj/bool/*)"), false); - CHECK_XPATH_BOOLEAN(c, STR("true()!=avj/bool/*"), false); - CHECK_XPATH_BOOLEAN(c, STR("not(true()!=avj/bool/*)"), true); - - CHECK_XPATH_BOOLEAN(c, STR("avj/none/*=true()"), false); - CHECK_XPATH_BOOLEAN(c, STR("not(avj/none/*=true())"), true); - CHECK_XPATH_BOOLEAN(c, STR("avj/none/*!=true()"), true); - CHECK_XPATH_BOOLEAN(c, STR("not(avj/none/*!=true())"), false); - - CHECK_XPATH_BOOLEAN(c, STR("true()=avj/none/*"), false); - CHECK_XPATH_BOOLEAN(c, STR("not(true()=avj/none/*)"), true); - CHECK_XPATH_BOOLEAN(c, STR("true()!=avj/none/*"), true); - CHECK_XPATH_BOOLEAN(c, STR("not(true()!=avj/none/*)"), false); -} - -TEST_XML(xpath_xalan_conditional, "b") -{ - xml_node c; - - CHECK_XPATH_BOOLEAN(c, STR("(round(3.7) > 3)"), true); - CHECK_XPATH_BOOLEAN(c, STR("2 > 1"), true); - CHECK_XPATH_BOOLEAN(c, STR("9 mod 3 = 0"), true); - CHECK_XPATH_BOOLEAN(c, STR("'a'='a'"), true); - CHECK_XPATH_BOOLEAN(c, STR("2+2=4"), true); - - xml_node b = doc.child(STR("letters")).first_child(); - - CHECK_XPATH_BOOLEAN(b, STR(".='b'"), true); - CHECK_XPATH_BOOLEAN(b, STR("name(..)='letters'"), true); -} - -TEST_XML(xpath_xalan_math_1, "3") -{ - xml_node c; - - CHECK_XPATH_NUMBER(c, STR("number('1')"), 1); - CHECK_XPATH_NUMBER(c, STR("floor(0.0)"), 0); - CHECK_XPATH_NUMBER(c, STR("ceiling(0.0)"), 0); - CHECK_XPATH_NUMBER(c, STR("round(0.0)"), 0); - CHECK_XPATH_NUMBER(c, STR("2*3"), 6); - CHECK_XPATH_NUMBER(c, STR("3+6"), 9); - CHECK_XPATH_NUMBER(c, STR("3-1"), 2); - CHECK_XPATH_NUMBER_NAN(doc, STR("a-1")); // a-1 is a name test, not arithmetic expression - CHECK_XPATH_NUMBER(doc, STR("a -1"), 2); - CHECK_XPATH_NUMBER(c, STR("6 div 2"), 3); - CHECK_XPATH_NUMBER(c, STR("5 mod 2"), 1); - CHECK_XPATH_NUMBER_NAN(c, STR("number(n)")); - CHECK_XPATH_NUMBER(c, STR("number(2)"), 2); - CHECK_XPATH_NUMBER(c, STR("number('3')"), 3); - CHECK_XPATH_NUMBER_NAN(c, STR("number('')")); - CHECK_XPATH_NUMBER_NAN(c, STR("number('abc')")); - CHECK_XPATH_BOOLEAN(c, STR("number(string(1.0))=1"), true); - CHECK_XPATH_BOOLEAN(c, STR("number(true())=1"), true); - CHECK_XPATH_BOOLEAN(c, STR("number(false())=0"), true); - -#ifndef MSVC6_NAN_BUG - CHECK_XPATH_BOOLEAN(c, STR("number('xxx')=number('xxx')"), false); - CHECK_XPATH_BOOLEAN(c, STR("number('xxx')=0"), false); -#endif - - CHECK_XPATH_NUMBER(doc, STR("floor(a)"), 3); - CHECK_XPATH_NUMBER(c, STR("floor(1.9)"), 1); - CHECK_XPATH_NUMBER(c, STR("floor(2.999999)"), 2); - CHECK_XPATH_NUMBER(c, STR("floor(-1.5)"), -2); - CHECK_XPATH_BOOLEAN(c, STR("floor(1)=1"), true); - CHECK_XPATH_BOOLEAN(c, STR("floor(1.9)=1"), true); - CHECK_XPATH_BOOLEAN(c, STR("floor(-1.5)=-2"), true); - CHECK_XPATH_NUMBER(doc, STR("ceiling(a)"), 3); - CHECK_XPATH_NUMBER(c, STR("ceiling(1.54)"), 2); - CHECK_XPATH_NUMBER(c, STR("ceiling(2.999999)"), 3); - CHECK_XPATH_NUMBER(c, STR("ceiling(3.000001)"), 4); - CHECK_XPATH_BOOLEAN(c, STR("ceiling(1)=1"), true); - CHECK_XPATH_BOOLEAN(c, STR("ceiling(1.1)=2"), true); - CHECK_XPATH_BOOLEAN(c, STR("ceiling(-1.5)=-1"), true); -} - -TEST_XML(xpath_xalan_math_2, "3") -{ - xml_node c; - - CHECK_XPATH_NUMBER(doc, STR("round(a)"), 3); - CHECK_XPATH_NUMBER(c, STR("round(1.24)"), 1); - CHECK_XPATH_NUMBER(c, STR("round(2.999999)"), 3); - CHECK_XPATH_NUMBER(c, STR("round(3.000001)"), 3); - CHECK_XPATH_NUMBER(c, STR("round(1.1)"), 1); - CHECK_XPATH_NUMBER(c, STR("round(-1.1)"), -1); - CHECK_XPATH_NUMBER(c, STR("round(1.9)"), 2); - CHECK_XPATH_NUMBER(c, STR("round(-1.9)"), -2); - CHECK_XPATH_NUMBER(c, STR("round(1.5)"), 2); - CHECK_XPATH_NUMBER(c, STR("round(-1.5)"), -1); - CHECK_XPATH_NUMBER(c, STR("round(1.4999999)"), 1); - CHECK_XPATH_NUMBER(c, STR("round(-1.4999999)"), -1); - CHECK_XPATH_NUMBER(c, STR("round(1.5000001)"), 2); - CHECK_XPATH_NUMBER(c, STR("round(-1.5000001)"), -2); -} - -TEST_XML(xpath_xalan_math_3, "24517-58-37") -{ - CHECK_XPATH_NUMBER(doc, STR("sum(doc/x)"), 0); - CHECK_XPATH_NUMBER_NAN(doc, STR("sum(doc/n)")); - CHECK_XPATH_NUMBER(doc, STR("sum(doc/n[text()])"), 11); - CHECK_XPATH_NUMBER(doc, STR("sum(doc/n/@v)"), 9); - CHECK_XPATH_NUMBER(doc, STR("sum(doc/e)"), -17); -} - -TEST_XML(xpath_xalan_math_4, "231237212
5
2
") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_NUMBER(c, STR("n1*n2"), 6); - CHECK_XPATH_NUMBER(c, STR("n1/@a*n2/@a"), 2); - CHECK_XPATH_NUMBER(c, STR("(n1/@a)*(n2/@a)"), 2); - CHECK_XPATH_NUMBER(c, STR("n1+n2"), 5); - CHECK_XPATH_NUMBER(c, STR("n1/@a+n2/@a"), 3); - CHECK_XPATH_NUMBER(c, STR("(n1/@a)+(n2/@a)"), 3); - CHECK_XPATH_NUMBER(c, STR("1-2"), -1); - CHECK_XPATH_NUMBER(c, STR("n1 - n2"), -1); - CHECK_XPATH_NUMBER(c, STR("n1-n2"), 123); - CHECK_XPATH_NUMBER(c, STR("n-1 - n-2"), 60); - CHECK_XPATH_NUMBER(c, STR("n-1 -n-2"), 60); - CHECK_XPATH_NUMBER(c, STR("7+-3"), 4); - CHECK_XPATH_NUMBER(c, STR("n-1+-n-2"), 60); - CHECK_XPATH_NUMBER(c, STR("7 - -3"), 10); - CHECK_XPATH_NUMBER(c, STR("n-1 - -n-2"), 84); - CHECK_XPATH_NUMBER(c, STR("-7 --3"), -4); - CHECK_XPATH_NUMBER(c, STR("-n-1 --n-2"), -60); - - CHECK_XPATH_FAIL(STR("+7")); - CHECK_XPATH_FAIL(STR("7++3")); - CHECK_XPATH_FAIL(STR("7-+3")); - - CHECK_XPATH_NUMBER(c, STR("6 div -2"), -3); - CHECK_XPATH_NUMBER(c, STR("n1 div n2"), 2.0 / 3.0); - CHECK_XPATH_NUMBER(c, STR("div div mod"), 2.5); - CHECK_XPATH_NUMBER(c, STR("div/@a div mod/@a"), 0.4); - - CHECK_XPATH_BOOLEAN(c, STR("1 div -0 = 2 div -0"), true); - CHECK_XPATH_BOOLEAN(c, STR("1 div -0 = 1 div 0"), false); - CHECK_XPATH_BOOLEAN(c, STR("1 div -0 = -1 div 0"), true); - -#ifndef MSVC6_NAN_BUG - CHECK_XPATH_BOOLEAN(c, STR("0 div 0 >= 0"), false); - CHECK_XPATH_BOOLEAN(c, STR("0 div 0 < 0"), false); -#endif - - CHECK_XPATH_NUMBER(c, STR("n1 mod n2"), 2); - CHECK_XPATH_NUMBER(c, STR("div mod mod"), 1); - CHECK_XPATH_NUMBER(c, STR("div/@a mod mod/@a"), 2); - - CHECK_XPATH_BOOLEAN(c, STR("(5 mod 2 = 1) and (5 mod -2 = 1) and (-5 mod 2 = -1) and (-5 mod -2 = -1)"), true); -} - -TEST(xpath_xalan_math_5) -{ - xml_node c; - - CHECK_XPATH_NUMBER(c, STR("(((((('3'+5)*(3)+((('2')+2)*('1' - 6)))-('4' - '2'))+(-(4-6)))))"), 4); - CHECK_XPATH_NUMBER(c, STR("1*1*2*2*2*3*3*1*1*1*0.5*0.5"), 18); - CHECK_XPATH_NUMBER(c, STR("1440 div 2 div 2 div 6"), 60); - CHECK_XPATH_NUMBER(c, STR("1440 div 2 div 2 div 6 div 10"), 6); - CHECK_XPATH_NUMBER(c, STR("1440 div 2 div 2 div 6 div 10 div 3"), 2); - CHECK_XPATH_NUMBER(c, STR("(1*2*3*4*5*6)div 2 div 6 div 10 div 3"), 2); - CHECK_XPATH_NUMBER_NAN(c, STR("(2 + number('xxx'))")); - CHECK_XPATH_NUMBER_NAN(c, STR("2 * -number('xxx')")); - CHECK_XPATH_NUMBER_NAN(c, STR("2 - number('xxx')")); - CHECK_XPATH_NUMBER_NAN(c, STR("number('xxx') - 3")); - CHECK_XPATH_NUMBER_NAN(c, STR("2 div number('xxx')")); - CHECK_XPATH_NUMBER_NAN(c, STR("number('xxx') div 3")); - -#ifndef __BORLANDC__ // BCC fmod does not propagate NaN correctly - CHECK_XPATH_NUMBER_NAN(c, STR("2 mod number('xxx')")); - CHECK_XPATH_NUMBER_NAN(c, STR("number('xxx') mod 3")); -#endif - - CHECK_XPATH_NUMBER_NAN(c, STR("floor(number('xxx'))")); - CHECK_XPATH_NUMBER_NAN(c, STR("ceiling(number('xxx'))")); - CHECK_XPATH_NUMBER_NAN(c, STR("round(number('xxx'))")); - CHECK_XPATH_NUMBER(c, STR("10+5+25+20+15+50+35+40"), 200); - CHECK_XPATH_NUMBER(c, STR("100-9-7-4-17-18-5"), 40); - CHECK_XPATH_NUMBER(c, STR("3*2+5*4-4*2-1"), 17); - CHECK_XPATH_NUMBER(c, STR("6*5-8*2+5*2"), 24); - CHECK_XPATH_NUMBER(c, STR("10*5-4*2+6*1 -3*3"), 39); - - CHECK_XPATH_NUMBER(c, STR("(24 div 3 +2) div (40 div 8 -3)"), 5); - CHECK_XPATH_NUMBER(c, STR("80 div 2 + 12 div 2 - 4 div 2"), 44); - CHECK_XPATH_NUMBER(c, STR("70 div 10 - 18 div 6 + 10 div 2"), 9); - - CHECK_XPATH_NUMBER(c, STR("48 mod 17 - 2 mod 9 + 13 mod 5"), 15); - CHECK_XPATH_NUMBER(c, STR("56 mod round(5*2+1.444) - 6 mod 4 + 7 mod 4"), 2); - CHECK_XPATH_NUMBER(c, STR("(77 mod 10 + 5 mod 8) mod 10"), 2); -} - -TEST_XML(xpath_xalan_math_6, "37x") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_NUMBER(c, STR("-(n1|n2)"), -3); - CHECK_XPATH_NUMBER(c, STR("-(n2|n1)"), -3); - CHECK_XPATH_BOOLEAN(c, STR("contains(number(n1), 'NaN')"), false); - CHECK_XPATH_BOOLEAN(c, STR("contains(number(n3), 'NaN')"), true); -} - -TEST_XML(xpath_xalan_math_7, "37x") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_NUMBER(c, STR("-(n1|n2)"), -3); - CHECK_XPATH_NUMBER(c, STR("-(n2|n1)"), -3); - CHECK_XPATH_BOOLEAN(c, STR("contains(number(n1), 'NaN')"), false); - CHECK_XPATH_BOOLEAN(c, STR("contains(number(n3), 'NaN')"), true); -} - -TEST_XML(xpath_xalan_math_8, "0.0004") -{ - CHECK_XPATH_NUMBER(doc, STR("number(1.75)"), 1.75); - CHECK_XPATH_NUMBER(doc, STR("number(7 div 4)"), 1.75); - CHECK_XPATH_BOOLEAN(doc, STR("(number(1.75) = (7 div 4))"), true); - CHECK_XPATH_NUMBER(doc, STR("number(0.109375 * 16)"), 1.75); - CHECK_XPATH_BOOLEAN(doc, STR("(number(1.75) = (0.109375 * 16))"), true); - CHECK_XPATH_NUMBER(doc, STR("number(k)"), 0.0004); - CHECK_XPATH_NUMBER(doc, STR("number(4 div 10000)"), 0.0004); - - // +0 works around extended precision in div on x86 (this is needed for some configurations in MinGW 3.4) - CHECK_XPATH_BOOLEAN(doc, STR("(number(k) = (4 div 10000 + 0))"), true); - CHECK_XPATH_NUMBER(doc, STR("number(0.0001 * 4)"), 0.0004); - CHECK_XPATH_BOOLEAN(doc, STR("(number(k) = (0.0001 * 4))"), true); -} - -TEST(xpath_xalan_math_9) -{ - xml_node c; - - CHECK_XPATH_STRING(c, STR("string(number('0.0'))"), STR("0")); - CHECK_XPATH_STRING(c, STR("string(-1 * number('0.0'))"), STR("0")); - - CHECK_XPATH_STRING(c, STR("string(number('0.4'))"), STR("0.4")); - CHECK_XPATH_STRING(c, STR("string(-1 * number('0.4'))"), STR("-0.4")); - - CHECK_XPATH_STRING(c, STR("string(number('4.0'))"), STR("4")); - CHECK_XPATH_STRING(c, STR("string(-1 * number('4.0'))"), STR("-4")); - - CHECK_XPATH_STRING(c, STR("string(number('0.04'))"), STR("0.04")); - CHECK_XPATH_STRING(c, STR("string(-1 * number('0.04'))"), STR("-0.04")); - - CHECK_XPATH_STRING(c, STR("string(number('0.004'))"), STR("0.004")); - CHECK_XPATH_STRING(c, STR("string(-1 * number('0.004'))"), STR("-0.004")); - - CHECK_XPATH_STRING(c, STR("string(number('0.0004'))"), STR("0.0004")); - CHECK_XPATH_STRING(c, STR("string(-1 * number('0.0004'))"), STR("-0.0004")); - - CHECK_XPATH_STRING(c, STR("string(number('0.0000000000001'))"), STR("0.0000000000001")); - CHECK_XPATH_STRING(c, STR("string(-1 * number('0.0000000000001'))"), STR("-0.0000000000001")); - - CHECK_XPATH_STRING(c, STR("string(number('0.0000000000000000000000000001'))"), STR("0.0000000000000000000000000001")); - CHECK_XPATH_STRING(c, STR("string(-1 * number('0.0000000000000000000000000001'))"), STR("-0.0000000000000000000000000001")); - - CHECK_XPATH_STRING(c, STR("string(number('0.0000000000001000000000000001'))"), STR("0.0000000000001000000000000001")); - CHECK_XPATH_STRING(c, STR("string(-1 * number('0.0000000000001000000000000001'))"), STR("-0.0000000000001000000000000001")); - - CHECK_XPATH_STRING(c, STR("string(number('0.0012'))"), STR("0.0012")); - CHECK_XPATH_STRING(c, STR("string(-1 * number('0.0012'))"), STR("-0.0012")); - - CHECK_XPATH_STRING(c, STR("string(number('0.012'))"), STR("0.012")); - CHECK_XPATH_STRING(c, STR("string(-1 * number('0.012'))"), STR("-0.012")); -} - -#endif diff --git a/external/pugixml/tests/test_xpath_xalan_2.cpp b/external/pugixml/tests/test_xpath_xalan_2.cpp deleted file mode 100644 index 4e8c10ea4..000000000 --- a/external/pugixml/tests/test_xpath_xalan_2.cpp +++ /dev/null @@ -1,417 +0,0 @@ -#define _CRT_SECURE_NO_WARNINGS - -#ifndef PUGIXML_NO_XPATH - -#include "test.hpp" - -#include -#include - -using namespace pugi; - -TEST_XML(xpath_xalan_string_1, "ENCYCLOPEDIA") -{ - xml_node c; - - CHECK_XPATH_NUMBER(c, STR("string-length('This is a test')"), 14); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('ENCYCLOPEDIA', 'ENCY')"), true); - CHECK_XPATH_BOOLEAN(c, STR("contains('ENCYCLOPEDIA', 'CYCL')"), true); - CHECK_XPATH_STRING(c, STR("substring-before('1999/04/01', '/')"), STR("1999")); - CHECK_XPATH_STRING(c, STR("substring-after('1999/04/01', '/')"), STR("04/01")); - CHECK_XPATH_STRING(c, STR("normalize-space('\t\n\r\n ab\n cd\t\n\r\n ef\t\n\r ')"), STR("ab cd ef")); - CHECK_XPATH_STRING(c, STR("translate(\"bar\",\"abc\",\"ABC\")"), STR("BAr")); - CHECK_XPATH_STRING(c, STR("concat(\"x\",\"yz\")"), STR("xyz")); - CHECK_XPATH_STRING(c, STR("substring('1999/04/01', 1, 4)"), STR("1999")); - CHECK_XPATH_STRING(c, STR("substring('12345', 1.5, 2.6)"), STR("234")); - CHECK_XPATH_STRING(c, STR("substring('12345', 0, 3)"), STR("12")); - CHECK_XPATH_STRING(c, STR("substring('12345', 0 div 0, 3)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('12345', 1, 0 div 0)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('12345', -42, 1 div 0)"), STR("12345")); - CHECK_XPATH_STRING(c, STR("substring('12345', -1 div 0, 1 div 0)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring(foo, 12, 3)"), STR("")); - CHECK_XPATH_STRING(c, STR("string(foo)"), STR("")); - CHECK_XPATH_STRING(c, STR("string(0)"), STR("0")); - CHECK_XPATH_STRING(c, STR("string(2)"), STR("2")); - CHECK_XPATH_STRING(c, STR("string('test')"), STR("test")); - CHECK_XPATH_STRING(c, STR("string('')"), STR("")); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('ENCYCLOPEDIA', 'EN')"), true); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('ENCYCLOPEDIA', 'en')"), false); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('ab', 'abc')"), false); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('abc', 'bc')"), false); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('abc', '')"), true); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('', '')"), true); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('', 'abc')"), false); - CHECK_XPATH_BOOLEAN(c, STR("starts-with('true()', 'tr')"), true); - CHECK_XPATH_BOOLEAN(c, STR("starts-with(foo, 'EN')"), false); - CHECK_XPATH_BOOLEAN(doc, STR("starts-with(doc, 'EN')"), true); - CHECK_XPATH_BOOLEAN(doc, STR("starts-with(doc/@a, 'EN')"), false); - CHECK_XPATH_BOOLEAN(doc, STR("starts-with(doc/@a, 'te')"), true); -} - -TEST_XML_FLAGS(xpath_xalan_string_2, "\n \n \n b\n c\n d\n e\n \n \n w\n x\n y\n z\n \n \n", parse_default | parse_ws_pcdata) -{ - CHECK_XPATH_STRING(doc, STR("string(doc/av//*)"), STR("\n b\n c\n d\n e\n ")); - CHECK_XPATH_STRING(doc, STR("normalize-space(string(doc/av//*))"), STR("b c d e")); - CHECK_XPATH_STRING(doc, STR("normalize-space('This is a test')"), STR("This is a test")); -} - -TEST_XML(xpath_xalan_string_3, "ENCYCLOPEDIA") -{ - xml_node c; - - CHECK_XPATH_BOOLEAN(c, STR("contains('ENCYCLOPEDIA', 'TEST')"), false); - CHECK_XPATH_BOOLEAN(c, STR("contains('ENCYCLOPEDIA', 'CYCL')"), true); - CHECK_XPATH_BOOLEAN(c, STR("contains('ENCYCLOPEDIA', 'cycl')"), false); - CHECK_XPATH_BOOLEAN(doc, STR("contains(concat(.,'BC'),concat('A','B','C'))"), true); - CHECK_XPATH_BOOLEAN(c, STR("contains('ab', 'abc')"), false); - CHECK_XPATH_BOOLEAN(c, STR("contains('abc', 'bc')"), true); - CHECK_XPATH_BOOLEAN(c, STR("contains('abc', 'bcd')"), false); - CHECK_XPATH_BOOLEAN(c, STR("contains('abc', '')"), true); - CHECK_XPATH_BOOLEAN(c, STR("contains('', '')"), true); - CHECK_XPATH_BOOLEAN(c, STR("contains('', 'abc')"), false); - CHECK_XPATH_BOOLEAN(c, STR("contains('true()', 'e')"), true); - CHECK_XPATH_BOOLEAN(doc, STR("contains(., 'CYCL')"), true); - CHECK_XPATH_BOOLEAN(doc, STR("contains(., 'TEST')"), false); - CHECK_XPATH_BOOLEAN(doc, STR("contains(doc/@a, 'es')"), true); - CHECK_XPATH_BOOLEAN(doc, STR("contains(doc/@a, 'T')"), false); - CHECK_XPATH_STRING(c, STR("substring-before('ENCYCLOPEDIA', '/')"), STR("")); - CHECK_XPATH_STRING(c, STR("substring-before('ENCYCLOPEDIA', 'C')"), STR("EN")); - CHECK_XPATH_STRING(c, STR("substring-before('ENCYCLOPEDIA', 'c')"), STR("")); - CHECK_XPATH_STRING(c, STR("substring-before('ENCYCLOPEDIA', '')"), STR("")); - CHECK_XPATH_STRING(doc, STR("substring-before(., '/')"), STR("")); - CHECK_XPATH_STRING(doc, STR("substring-before(., 'C')"), STR("EN")); - CHECK_XPATH_STRING(doc, STR("substring-before(foo, '')"), STR("")); - CHECK_XPATH_STRING(doc, STR("substring-before(doc/@a, '/')"), STR("")); - CHECK_XPATH_STRING(doc, STR("substring-before(doc/@a, 'e')"), STR("t")); - CHECK_XPATH_STRING(doc, STR("substring-before(doc/@a, 't')"), STR("")); - CHECK_XPATH_STRING(c, STR("substring-after('ENCYCLOPEDIA', '/')"), STR("")); - CHECK_XPATH_STRING(c, STR("substring-after('ENCYCLOPEDIA', 'C')"), STR("YCLOPEDIA")); - CHECK_XPATH_STRING(c, STR("substring-after('ENCYCLOPEDIA', 'c')"), STR("")); - CHECK_XPATH_STRING(c, STR("substring-after('ENCYCLOPEDIA', '')"), STR("ENCYCLOPEDIA")); - CHECK_XPATH_STRING(doc, STR("substring-after(., '/')"), STR("")); - CHECK_XPATH_STRING(doc, STR("substring-after(., 'C')"), STR("YCLOPEDIA")); - CHECK_XPATH_STRING(doc, STR("substring-after(foo, '')"), STR("")); - CHECK_XPATH_STRING(doc, STR("substring-after(doc/@a, '/')"), STR("")); - CHECK_XPATH_STRING(doc, STR("substring-after(doc/@a, 'e')"), STR("st")); - CHECK_XPATH_STRING(doc, STR("substring-after(doc/@a, 't')"), STR("est")); - CHECK_XPATH_STRING(doc, STR("substring-after(doc/@a, 'st')"), STR("")); -} - -TEST_XML(xpath_xalan_string_4, "abcdefwhat's up") -{ - xml_node c; - - CHECK_XPATH_STRING(c, STR("translate('BAR','abc','ABC')"), STR("BAR")); - CHECK_XPATH_STRING(c, STR("translate('bar','RAB','xyz')"), STR("bar")); - CHECK_XPATH_STRING(c, STR("translate('BAR','Rab','TxX')"), STR("BAT")); - CHECK_XPATH_STRING(c, STR("translate('zzaaazzz','abcz','ABC')"), STR("AAA")); - CHECK_XPATH_STRING(c, STR("translate('ddaaadddd','abcd','ABCxy')"), STR("xxAAAxxxx")); - CHECK_XPATH_STRING(c, STR("concat('a','b','c','d','ef')"), STR("abcdef")); - CHECK_XPATH_STRING(c, STR("concat(a, b)"), STR("")); - CHECK_XPATH_STRING(doc.child(STR("doc")), STR("concat(a, b)"), STR("ab")); - CHECK_XPATH_STRING(doc.child(STR("doc")), STR("concat(a, b, c, d, e)"), STR("abcdef")); - CHECK_XPATH_STRING(c, STR("concat('cd','34')"), STR("cd34")); - CHECK_XPATH_STRING(c, STR("concat('cd',34)"), STR("cd34")); - CHECK_XPATH_STRING(c, STR("concat('bc',string(23))"), STR("bc23")); - CHECK_XPATH_STRING(c, STR("concat(a,34)"), STR("34")); - CHECK_XPATH_STRING(doc.child(STR("doc")), STR("concat(a,34)"), STR("a34")); - CHECK_XPATH_STRING(c, STR("concat(false(),'ly')"), STR("falsely")); - CHECK_XPATH_FAIL(STR("concat(/*)")); - CHECK_XPATH_STRING(doc.child(STR("doc")), STR("concat(/*, '')"), STR("abcdefwhat's up")); - CHECK_XPATH_STRING(doc.child(STR("doc")), STR("concat(/*, /*[@attr='whatsup'])"), STR("abcdefwhat's up")); - CHECK_XPATH_STRING(doc.child(STR("doc")), STR("concat(/*, //*[@attr='whatsup'])"), STR("abcdefwhat's upwhat's up")); - CHECK_XPATH_STRING(c, STR("substring('ENCYCLOPEDIA', 8, 3)"), STR("PED")); - CHECK_XPATH_STRING(c, STR("substring('ENCYCLOPEDIA', 8)"), STR("PEDIA")); - CHECK_XPATH_STRING(c, STR("substring('abcdefghijk',0 div 0, 5)"), STR("")); - CHECK_XPATH_STRING(c, STR("substring('abcdefghijk',4, 6)"), STR("defghi")); - CHECK_XPATH_STRING(c, STR("substring('1999/04/01', 1, 0)"), STR("")); - CHECK_XPATH_STRING(c, STR("translate(normalize-space(' bar fly '), ' ', '_')"), STR("bar_fly")); - CHECK_XPATH_STRING(c, STR("translate('barter','abe','bao')"), STR("abrtor")); - CHECK_XPATH_STRING(c, STR("translate('barbarity', 'aeiouy', '******')"), STR("b*rb*r*t*")); - CHECK_XPATH_STRING(doc, STR("translate(cd, concat(\"aqu'\", '\"eos'), 'AQU-+EOS')"), STR("QUA-lit+y")); - CHECK_XPATH_STRING(c, STR("translate('quan+ti-ty', 'AQU-+EOS', concat(\"aqu'\", '\"eos'))"), STR("quan\"ti'ty")); -} - -static const char_t* number_to_string_unsafe(int number) -{ - static char_t buffer[16]; - - // construct number in reverse - char_t* it = buffer; - - while (number) - { - *it++ = static_cast('0' + number % 10); - number /= 10; - } - - // zero terminate - *it = 0; - - // reverse to get final result - std::reverse(buffer, it); - - return buffer; -} - -TEST(xpath_xalan_string_5) -{ - const int count = 1000; - - std::basic_string query; - query.reserve(17 * count); - - query += STR("concat("); - - for (int i = 1; i < count; ++i) - { - query += STR("concat('t',"); - query += number_to_string_unsafe(i); - query += STR("), "); - } - - query += STR("'')"); - - std::basic_string expected; - expected.reserve(4 * count); - - for (int j = 1; j < count; ++j) - { - expected += STR("t"); - expected += number_to_string_unsafe(j); - } - - CHECK_XPATH_STRING(xml_node(), query.c_str(), expected.c_str()); -} - -TEST(xpath_xalan_string_6) -{ - xml_node c; - - CHECK_XPATH_STRING(c, STR("string(1)"), STR("1")); - CHECK_XPATH_STRING(c, STR("string(12)"), STR("12")); - CHECK_XPATH_STRING(c, STR("string(123)"), STR("123")); - CHECK_XPATH_STRING(c, STR("string(1234)"), STR("1234")); - CHECK_XPATH_STRING(c, STR("string(12345)"), STR("12345")); - CHECK_XPATH_STRING(c, STR("string(123456)"), STR("123456")); - CHECK_XPATH_STRING(c, STR("string(1234567)"), STR("1234567")); - CHECK_XPATH_STRING(c, STR("string(12345678)"), STR("12345678")); - CHECK_XPATH_STRING(c, STR("string(123456789)"), STR("123456789")); - CHECK_XPATH_STRING(c, STR("string(1234567890)"), STR("1234567890")); - CHECK_XPATH_STRING(c, STR("string(12345678901)"), STR("12345678901")); - CHECK_XPATH_STRING(c, STR("string(123456789012)"), STR("123456789012")); - CHECK_XPATH_STRING(c, STR("string(1234567890123)"), STR("1234567890123")); - CHECK_XPATH_STRING(c, STR("string(12345678901234)"), STR("12345678901234")); - CHECK_XPATH_STRING(c, STR("string(123456789012345)"), STR("123456789012345")); - CHECK_XPATH_STRING(c, STR("string(1234567890123456)"), STR("1234567890123456")); - CHECK_XPATH_STRING(c, STR("string(-1)"), STR("-1")); - CHECK_XPATH_STRING(c, STR("string(-12)"), STR("-12")); - CHECK_XPATH_STRING(c, STR("string(-123)"), STR("-123")); - CHECK_XPATH_STRING(c, STR("string(-1234)"), STR("-1234")); - CHECK_XPATH_STRING(c, STR("string(-12345)"), STR("-12345")); - CHECK_XPATH_STRING(c, STR("string(-123456)"), STR("-123456")); - CHECK_XPATH_STRING(c, STR("string(-1234567)"), STR("-1234567")); - CHECK_XPATH_STRING(c, STR("string(-12345678)"), STR("-12345678")); - CHECK_XPATH_STRING(c, STR("string(-123456789)"), STR("-123456789")); - CHECK_XPATH_STRING(c, STR("string(-1234567890)"), STR("-1234567890")); - CHECK_XPATH_STRING(c, STR("string(-12345678901)"), STR("-12345678901")); - CHECK_XPATH_STRING(c, STR("string(-123456789012)"), STR("-123456789012")); - CHECK_XPATH_STRING(c, STR("string(-1234567890123)"), STR("-1234567890123")); - CHECK_XPATH_STRING(c, STR("string(-12345678901234)"), STR("-12345678901234")); - CHECK_XPATH_STRING(c, STR("string(-123456789012345)"), STR("-123456789012345")); - CHECK_XPATH_STRING(c, STR("string(-1234567890123456)"), STR("-1234567890123456")); -} - -#if 0 // $ this test requires round-to-nearest behavior in string->number conversion during parsing; atof gives us truncation -TEST(xpath_xalan_string_6_rounding) -{ - xml_node c; - - CHECK_XPATH_STRING(c, STR("string(12345678901234567)"), STR("12345678901234568")); - CHECK_XPATH_STRING(c, STR("string(123456789012345678)"), STR("123456789012345680")); - CHECK_XPATH_STRING(c, STR("string(-12345678901234567)"), STR("-12345678901234568")); - CHECK_XPATH_STRING(c, STR("string(-123456789012345678)"), STR("-123456789012345680")); -} -#endif - -TEST(xpath_xalan_string_7) -{ - xml_node c; - - CHECK_XPATH_STRING(c, STR("string(.1)"), STR("0.1")); - CHECK_XPATH_STRING(c, STR("string(.01)"), STR("0.01")); - CHECK_XPATH_STRING(c, STR("string(.012)"), STR("0.012")); - CHECK_XPATH_STRING(c, STR("string(.0123)"), STR("0.0123")); - CHECK_XPATH_STRING(c, STR("string(.01234)"), STR("0.01234")); - CHECK_XPATH_STRING(c, STR("string(.012345)"), STR("0.012345")); - CHECK_XPATH_STRING(c, STR("string(.0123456)"), STR("0.0123456")); - CHECK_XPATH_STRING(c, STR("string(.01234567)"), STR("0.01234567")); - CHECK_XPATH_STRING(c, STR("string(.012345678)"), STR("0.012345678")); - CHECK_XPATH_STRING(c, STR("string(.0123456789)"), STR("0.0123456789")); - CHECK_XPATH_STRING(c, STR("string(.10123456789)"), STR("0.10123456789")); - CHECK_XPATH_STRING(c, STR("string(.101234567892)"), STR("0.101234567892")); - CHECK_XPATH_STRING(c, STR("string(.1012345678923)"), STR("0.1012345678923")); - CHECK_XPATH_STRING(c, STR("string(.10123456789234)"), STR("0.10123456789234")); - CHECK_XPATH_STRING(c, STR("string(.101234567892345)"), STR("0.101234567892345")); - CHECK_XPATH_STRING(c, STR("string(.1012345678923456)"), STR("0.1012345678923456")); - CHECK_XPATH_STRING(c, STR("string(-.1)"), STR("-0.1")); - CHECK_XPATH_STRING(c, STR("string(-.01)"), STR("-0.01")); - CHECK_XPATH_STRING(c, STR("string(-.012)"), STR("-0.012")); - CHECK_XPATH_STRING(c, STR("string(-.0123)"), STR("-0.0123")); - CHECK_XPATH_STRING(c, STR("string(-.01234)"), STR("-0.01234")); - CHECK_XPATH_STRING(c, STR("string(-.012345)"), STR("-0.012345")); - CHECK_XPATH_STRING(c, STR("string(-.0123456)"), STR("-0.0123456")); - CHECK_XPATH_STRING(c, STR("string(-.01234567)"), STR("-0.01234567")); - CHECK_XPATH_STRING(c, STR("string(-.012345678)"), STR("-0.012345678")); - CHECK_XPATH_STRING(c, STR("string(-.0123456789)"), STR("-0.0123456789")); - CHECK_XPATH_STRING(c, STR("string(-.10123456789)"), STR("-0.10123456789")); - CHECK_XPATH_STRING(c, STR("string(-.101234567892)"), STR("-0.101234567892")); - CHECK_XPATH_STRING(c, STR("string(-.1012345678923)"), STR("-0.1012345678923")); - CHECK_XPATH_STRING(c, STR("string(-.10123456789234)"), STR("-0.10123456789234")); - CHECK_XPATH_STRING(c, STR("string(-.101234567892345)"), STR("-0.101234567892345")); - CHECK_XPATH_STRING(c, STR("string(-.1012345678923456)"), STR("-0.1012345678923456")); -} - -#if 0 // $ this test requires 16 decimal digits of mantissa in number->string conversion; we have 15 since only 15 is guaranteed, and 16 introduces 'garbage' digits in common cases like 0.4 -TEST(xpath_xalan_string_7_precision) -{ - xml_node c; - - CHECK_XPATH_STRING(c, STR("string(.10123456789234567)"), STR("0.10123456789234567")); - CHECK_XPATH_STRING(c, STR("string(.101234567892345678)"), STR("0.10123456789234568")); - CHECK_XPATH_STRING(c, STR("string(.1012345678923456789)"), STR("0.10123456789234568")); - CHECK_XPATH_STRING(c, STR("string(.10123456789234567893)"), STR("0.10123456789234568")); - CHECK_XPATH_STRING(c, STR("string(-.10123456789234567)"), STR("-0.10123456789234567")); - CHECK_XPATH_STRING(c, STR("string(-.101234567892345678)"), STR("-0.10123456789234568")); - CHECK_XPATH_STRING(c, STR("string(-.1012345678923456789)"), STR("-0.10123456789234568")); - CHECK_XPATH_STRING(c, STR("string(-.10123456789234567893)"), STR("-0.10123456789234568")); -} -#endif - -TEST(xpath_xalan_string_8) -{ - xml_node c; - - // $ originally all last digits were 5's; a fully compliant implementation should correctly convert those as well, - // however some of these failed because of atof truncation - CHECK_XPATH_STRING(c, STR("string(9.87654321012344)"), STR("9.87654321012344")); - CHECK_XPATH_STRING(c, STR("string(98.7654321012345)"), STR("98.7654321012345")); - CHECK_XPATH_STRING(c, STR("string(987.654321012345)"), STR("987.654321012345")); - CHECK_XPATH_STRING(c, STR("string(9876.54321012344)"), STR("9876.54321012344")); - CHECK_XPATH_STRING(c, STR("string(98765.4321012345)"), STR("98765.4321012345")); - CHECK_XPATH_STRING(c, STR("string(987654.321012345)"), STR("987654.321012345")); - CHECK_XPATH_STRING(c, STR("string(9876543.21012345)"), STR("9876543.21012345")); - CHECK_XPATH_STRING(c, STR("string(98765432.1012345)"), STR("98765432.1012345")); - CHECK_XPATH_STRING(c, STR("string(987654321.012345)"), STR("987654321.012345")); - CHECK_XPATH_STRING(c, STR("string(9876543210.12344)"), STR("9876543210.12344")); - CHECK_XPATH_STRING(c, STR("string(98765432101.2345)"), STR("98765432101.2345")); - CHECK_XPATH_STRING(c, STR("string(987654321012.345)"), STR("987654321012.345")); - CHECK_XPATH_STRING(c, STR("string(9876543210123.43)"), STR("9876543210123.43")); - CHECK_XPATH_STRING(c, STR("string(98765432101234.5)"), STR("98765432101234.5")); - - CHECK_XPATH_STRING(c, STR("string(-9.87654321012344)"), STR("-9.87654321012344")); - CHECK_XPATH_STRING(c, STR("string(-98.7654321012345)"), STR("-98.7654321012345")); - CHECK_XPATH_STRING(c, STR("string(-987.654321012345)"), STR("-987.654321012345")); - CHECK_XPATH_STRING(c, STR("string(-9876.54321012344)"), STR("-9876.54321012344")); - CHECK_XPATH_STRING(c, STR("string(-98765.4321012345)"), STR("-98765.4321012345")); - CHECK_XPATH_STRING(c, STR("string(-987654.321012345)"), STR("-987654.321012345")); - CHECK_XPATH_STRING(c, STR("string(-9876543.21012345)"), STR("-9876543.21012345")); - CHECK_XPATH_STRING(c, STR("string(-98765432.1012345)"), STR("-98765432.1012345")); - CHECK_XPATH_STRING(c, STR("string(-987654321.012345)"), STR("-987654321.012345")); - CHECK_XPATH_STRING(c, STR("string(-9876543210.12344)"), STR("-9876543210.12344")); - CHECK_XPATH_STRING(c, STR("string(-98765432101.2345)"), STR("-98765432101.2345")); - CHECK_XPATH_STRING(c, STR("string(-987654321012.345)"), STR("-987654321012.345")); - CHECK_XPATH_STRING(c, STR("string(-9876543210123.43)"), STR("-9876543210123.43")); - CHECK_XPATH_STRING(c, STR("string(-98765432101234.5)"), STR("-98765432101234.5")); -} - -TEST(xpath_xalan_string_9) -{ - xml_node c; - - CHECK_XPATH_STRING(c, STR("string(.123456789)"), STR("0.123456789")); - CHECK_XPATH_STRING(c, STR("string(.0123456789)"), STR("0.0123456789")); - CHECK_XPATH_STRING(c, STR("string(.00123456789)"), STR("0.00123456789")); - CHECK_XPATH_STRING(c, STR("string(.000123456789)"), STR("0.000123456789")); - CHECK_XPATH_STRING(c, STR("string(.0000123456789)"), STR("0.0000123456789")); - CHECK_XPATH_STRING(c, STR("string(.00000123456789)"), STR("0.00000123456789")); - CHECK_XPATH_STRING(c, STR("string(.000000123456789)"), STR("0.000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.0000000123456789)"), STR("0.0000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.00000000123456789)"), STR("0.00000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.000000000123456789)"), STR("0.000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.0000000000123456789)"), STR("0.0000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.00000000000123456789)"), STR("0.00000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.000000000000123456789)"), STR("0.000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.0000000000000123456789)"), STR("0.0000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.00000000000000123456789)"), STR("0.00000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.000000000000000123456789)"), STR("0.000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.0000000000000000123456789)"), STR("0.0000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.00000000000000000123456789)"), STR("0.00000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.000000000000000000123456789)"), STR("0.000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.0000000000000000000123456789)"), STR("0.0000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.00000000000000000000123456789)"), STR("0.00000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.000000000000000000000123456789)"), STR("0.000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.0000000000000000000000123456789)"), STR("0.0000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.00000000000000000000000123456789)"), STR("0.00000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.000000000000000000000000123456789)"), STR("0.000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.0000000000000000000000000123456789)"), STR("0.0000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.00000000000000000000000000123456789)"), STR("0.00000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.000000000000000000000000000123456789)"), STR("0.000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.0000000000000000000000000000123456789)"), STR("0.0000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.00000000000000000000000000000123456789)"), STR("0.00000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.000000000000000000000000000000123456789)"), STR("0.000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.0000000000000000000000000000000123456789)"), STR("0.0000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.00000000000000000000000000000000123456789)"), STR("0.00000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.000000000000000000000000000000000123456789)"), STR("0.000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.0000000000000000000000000000000000123456789)"), STR("0.0000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.00000000000000000000000000000000000123456789)"), STR("0.00000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.000000000000000000000000000000000000123456789)"), STR("0.000000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.0000000000000000000000000000000000000123456789)"), STR("0.0000000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.00000000000000000000000000000000000000123456789)"), STR("0.00000000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.000000000000000000000000000000000000000123456789)"), STR("0.000000000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(.0000000000000000000000000000000000000000123456789)"), STR("0.0000000000000000000000000000000000000000123456789")); - - CHECK_XPATH_STRING(c, STR("string(-.123456789)"), STR("-0.123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0123456789)"), STR("-0.0123456789")); - CHECK_XPATH_STRING(c, STR("string(-.00123456789)"), STR("-0.00123456789")); - CHECK_XPATH_STRING(c, STR("string(-.000123456789)"), STR("-0.000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0000123456789)"), STR("-0.0000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.00000123456789)"), STR("-0.00000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.000000123456789)"), STR("-0.000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0000000123456789)"), STR("-0.0000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.00000000123456789)"), STR("-0.00000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.000000000123456789)"), STR("-0.000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0000000000123456789)"), STR("-0.0000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.00000000000123456789)"), STR("-0.00000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.000000000000123456789)"), STR("-0.000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0000000000000123456789)"), STR("-0.0000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.00000000000000123456789)"), STR("-0.00000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.000000000000000123456789)"), STR("-0.000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0000000000000000123456789)"), STR("-0.0000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.00000000000000000123456789)"), STR("-0.00000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.000000000000000000123456789)"), STR("-0.000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0000000000000000000123456789)"), STR("-0.0000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.00000000000000000000123456789)"), STR("-0.00000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.000000000000000000000123456789)"), STR("-0.000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0000000000000000000000123456789)"), STR("-0.0000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.00000000000000000000000123456789)"), STR("-0.00000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.000000000000000000000000123456789)"), STR("-0.000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0000000000000000000000000123456789)"), STR("-0.0000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.00000000000000000000000000123456789)"), STR("-0.00000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.000000000000000000000000000123456789)"), STR("-0.000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0000000000000000000000000000123456789)"), STR("-0.0000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.00000000000000000000000000000123456789)"), STR("-0.00000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.000000000000000000000000000000123456789)"), STR("-0.000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0000000000000000000000000000000123456789)"), STR("-0.0000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.00000000000000000000000000000000123456789)"), STR("-0.00000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.000000000000000000000000000000000123456789)"), STR("-0.000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0000000000000000000000000000000000123456789)"), STR("-0.0000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.00000000000000000000000000000000000123456789)"), STR("-0.00000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.000000000000000000000000000000000000123456789)"), STR("-0.000000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0000000000000000000000000000000000000123456789)"), STR("-0.0000000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.00000000000000000000000000000000000000123456789)"), STR("-0.00000000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.000000000000000000000000000000000000000123456789)"), STR("-0.000000000000000000000000000000000000000123456789")); - CHECK_XPATH_STRING(c, STR("string(-.0000000000000000000000000000000000000000123456789)"), STR("-0.0000000000000000000000000000000000000000123456789")); -} - -#endif diff --git a/external/pugixml/tests/test_xpath_xalan_3.cpp b/external/pugixml/tests/test_xpath_xalan_3.cpp deleted file mode 100644 index 5228cde18..000000000 --- a/external/pugixml/tests/test_xpath_xalan_3.cpp +++ /dev/null @@ -1,321 +0,0 @@ -#ifndef PUGIXML_NO_XPATH - -#include "test.hpp" - -using namespace pugi; - -TEST_XML(xpath_xalan_axes_1, "
") -{ - xml_node center = doc.select_node(STR("//center")).node(); - - CHECK_XPATH_NODESET(center, STR("self::*[near-south]")) % 10; - CHECK_XPATH_NODESET(center, STR("self::*[@center-attr-2]")) % 10; - CHECK_XPATH_NODESET(center, STR("preceding-sibling::*")) % 9 % 8 % 7; - CHECK_XPATH_NODESET(center, STR("preceding-sibling::*/following-sibling::*")) % 8 % 9 % 10 % 19 % 20 % 21; - CHECK_XPATH_NODESET(center, STR("preceding-sibling::*[2]/following-sibling::*")) % 9 % 10 % 19 % 20 % 21; - CHECK_XPATH_NODESET(center, STR("preceding-sibling::*[2]/following-sibling::*[4]")) % 20; - CHECK_XPATH_NODESET(center, STR("preceding-sibling::*[2]/following-sibling::*[4]/preceding-sibling::*[5]/following-sibling::*[4]/following-sibling::*[2]")) % 21; - CHECK_XPATH_NODESET(center, STR("following-sibling::*")) % 19 % 20 % 21; - CHECK_XPATH_NODESET(center, STR("following-sibling::*/preceding-sibling::*")) % 7 % 8 % 9 % 10 % 19 % 20; - CHECK_XPATH_NODESET(center, STR("following-sibling::*[2]/preceding-sibling::*")) % 19 % 10 % 9 % 8 % 7; - CHECK_XPATH_NODESET(center, STR("following-sibling::*[2]/preceding-sibling::*[4]")) % 8; - CHECK_XPATH_NODESET(center, STR("following-sibling::*[2]/preceding-sibling::*[4]/following-sibling::*[5]/preceding-sibling::*[4]/preceding-sibling::*[2]")) % 7; - CHECK_XPATH_NODESET(center, STR("following::*[4]/../*[2]")) % 4; - CHECK_XPATH_NODESET(center, STR("preceding::*[2]/../following::*")) % 22 % 23; - CHECK_XPATH_NODESET(center, STR("preceding::*[2]/../descendant::*[10]/following-sibling::east")) % 20; - CHECK_XPATH_NODESET(center, STR("//*")) % 2 % 3 % 4 % 5 % 6 % 7 % 8 % 9 % 10 % 14 % 15 % 16 % 17 % 18 % 19 % 20 % 21 % 22 % 23; - CHECK_XPATH_NODESET(center, STR("//ancestor::*")) % 2 % 5 % 6 % 10 % 15 % 16; - CHECK_XPATH_NODESET(center, STR("//*[count(ancestor::*) >= 2]/../parent::*")) % 2 % 5 % 6 % 10 % 15; - CHECK_XPATH_NODESET(center, STR("//*[count(./*/*) > 0]")) % 2 % 5 % 6 % 10 % 15; - CHECK_XPATH_NODESET(center, STR("@*/ancestor::*")) % 2 % 5 % 6 % 10; - CHECK_XPATH_NODESET(center, STR("@*/following::*")) % 14 % 15 % 16 % 17 % 18 % 19 % 20 % 21 % 22 % 23; - CHECK_XPATH_NODESET(center, STR("@*/preceding::*")) % 3 % 4 % 7 % 8 % 9; - CHECK_XPATH_NODESET(center, STR("preceding-sibling::*|following-sibling::*")) % 7 % 8 % 9 % 19 % 20 % 21; - CHECK_XPATH_NODESET(center, STR("(preceding-sibling::*|following-sibling::*)/ancestor::*[last()]/*[last()]")) % 23; - CHECK_XPATH_NODESET(center, STR(".//near-south/preceding-sibling::*|following-sibling::east/ancestor-or-self::*[2]")) % 6 % 14; -} - -TEST_XML_FLAGS(xpath_xalan_axes_2, " Level-1 Level-2 Level-3 Level-4
Level-5 Level-6
", parse_default | parse_comments | parse_pi) -{ - xml_node center = doc.select_node(STR("//center")).node(); - - CHECK_XPATH_NODESET(center, STR("@*")) % 21 % 22 % 23; - CHECK_XPATH_NODESET(center, STR("@*/child::*")); - CHECK_XPATH_NODESET(center, STR("@*/descendant::node()")); - CHECK_XPATH_NODESET(center, STR("@*/parent::node()")) % 20; - CHECK_XPATH_NODESET(center, STR("@*/ancestor::node()")) % 1 % 2 % 9 % 13 % 20; - CHECK_XPATH_NODESET(center, STR("@*/self::node()")) % 21 % 22 % 23; - CHECK_XPATH_NODESET(center, STR("@*/.")) % 21 % 22 % 23; - CHECK_XPATH_NODESET(center, STR("@*/descendant-or-self::node()")) % 21 % 22 % 23; - CHECK_XPATH_NODESET(center, STR("@*/ancestor-or-self::node()")) % 1 % 2 % 9 % 13 % 20 % 21 % 22 % 23; - CHECK_XPATH_NODESET(center, STR("@*/ancestor-or-self::*")) % 2 % 9 % 13 % 20; - CHECK_XPATH_NODESET(center, STR("@*/preceding-sibling::node()")); - CHECK_XPATH_NODESET(center, STR("@*/following-sibling::*")); - CHECK_XPATH_NODESET(center, STR("@*/ancestor::*/near-north/*[4]/@*/preceding::*")) % 4 % 5 % 14 % 15 % 16; - CHECK_XPATH_NODESET(center, STR("@*/ancestor::*/near-north/*[4]/@*/preceding::comment()")) % 6 % 10 % 17; - CHECK_XPATH_NODESET(center, STR("@*/ancestor::*/near-north/*[4]/@*/preceding::text()")) % 3 % 7 % 11 % 18; - CHECK_XPATH_NODESET(center, STR("@*/ancestor::*/near-north/*[4]/@*/preceding::processing-instruction()")) % 8 % 12 % 19; - CHECK_XPATH_NODESET(center, STR("@*/following::comment()")) % 25 % 29; - CHECK_XPATH_NODESET(center, STR("@*/following::processing-instruction()")) % 27 % 31; - CHECK_XPATH_NODESET(center, STR("@*/following::text()")) % 26 % 30; - CHECK_XPATH_NODESET(center, STR("@*/ancestor::*/near-north/*[4]/@*/preceding::node()")) % 3 % 4 % 5 % 6 % 7 % 8 % 10 % 11 % 12 % 14 % 15 % 16 % 17 % 18 % 19; - CHECK_XPATH_NODESET(center, STR("@*/ancestor::*/near-north/*[4]/@*/following::node()")) % 24 % 25 % 26 % 27 % 28 % 29 % 30 % 31 % 32 % 35 % 36 % 37 % 38 % 39 % 40 % 41; - - CHECK_XPATH_NODESET(center, STR("(//comment())[1]/..")) % 2; - CHECK_XPATH_NODESET(center, STR("(//attribute::*)[1]/../..")) % 13; -} - -TEST_XML(xpath_xalan_axes_3, "
") -{ - xml_node center = doc.select_node(STR("//center")).node(); - - CHECK_XPATH_NODESET(center, STR("ancestor-or-self::*")) % 8 % 4 % 3 % 2; - CHECK_XPATH_NODESET(center, STR("ancestor::*[3]")) % 2; - CHECK_XPATH_NODESET(center, STR("ancestor-or-self::*[1]")) % 8; - CHECK_XPATH_NODESET(center, STR("@*[2]")); - CHECK_XPATH_NODESET(center, STR("child::*[2]")); - CHECK_XPATH_NODESET(center, STR("child::near-south-west")); - CHECK_XPATH_NODESET(center, STR("descendant::*[3]")) % 11; - CHECK_XPATH_NODESET(center, STR("descendant::far-south")) % 11; - CHECK_XPATH_NODESET(center, STR("descendant-or-self::*[3]")) % 10; - CHECK_XPATH_NODESET(center, STR("descendant-or-self::far-south")) % 11; - CHECK_XPATH_NODESET(center, STR("descendant-or-self::center")) % 8; - CHECK_XPATH_NODESET(center, STR("following::*[4]")); - CHECK_XPATH_NODESET(center, STR("following::out-yonder-east")); - CHECK_XPATH_NODESET(center, STR("preceding::*[4]")); - CHECK_XPATH_NODESET(center, STR("preceding::out-yonder-west")); - CHECK_XPATH_NODESET(center, STR("following-sibling::*[2]")) % 13; - CHECK_XPATH_NODESET(center, STR("following-sibling::east")) % 13; - CHECK_XPATH_NODESET(center, STR("preceding-sibling::*[2]")) % 6; - CHECK_XPATH_NODESET(center, STR("preceding-sibling::west")) % 6; - CHECK_XPATH_NODESET(center, STR("parent::near-north")) % 4; - CHECK_XPATH_NODESET(center, STR("parent::*[1]")) % 4; - CHECK_XPATH_NODESET(center, STR("parent::foo")); - CHECK_XPATH_NODESET(center, STR("..")) % 4; - CHECK_XPATH_NODESET(center, STR("self::center")) % 8; - CHECK_XPATH_NODESET(center, STR("self::*[1]")) % 8; - CHECK_XPATH_NODESET(center, STR("self::foo")); - CHECK_XPATH_NODESET(center, STR(".")) % 8; - CHECK_XPATH_NODESET(center, STR("/far-north/north/near-north/center/ancestor-or-self::*")) % 8 % 4 % 3 % 2; -} - -TEST_XML(xpath_xalan_axes_4, "
") -{ - xml_node north = doc.select_node(STR("//north")).node(); - - CHECK_XPATH_STRING(north, STR("name(/descendant-or-self::north)"), STR("north")); - CHECK_XPATH_STRING(north, STR("name(/descendant::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(self::node()/descendant-or-self::north)"), STR("north")); - CHECK_XPATH_STRING(north, STR("name(self::node()/descendant::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::north/descendant-or-self::north)"), STR("north")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::north/descendant::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::north/child::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant::near-north/descendant-or-self::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant::near-north/descendant::far-west)"), STR("far-west")); - - CHECK_XPATH_STRING(north, STR("name(/descendant-or-self::north/descendant-or-self::north)"), STR("north")); - CHECK_XPATH_STRING(north, STR("name(/descendant-or-self::north/child::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(/descendant::near-north/descendant-or-self::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(self::node()/descendant-or-self::north/descendant-or-self::north)"), STR("north")); - CHECK_XPATH_STRING(north, STR("name(self::node()/descendant-or-self::north/child::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(self::node()/descendant::near-north/descendant-or-self::far-west)"), STR("far-west")); - CHECK_XPATH_STRING(north, STR("name(self::node()/descendant::near-north/child::far-west)"), STR("far-west")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::north/descendant-or-self::north/descendant-or-self::north)"), STR("north")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::north/descendant-or-self::north/child::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::north/descendant::near-north/descendant-or-self::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::north/descendant::near-north/child::far-west)"), STR("far-west")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::north/child::near-north/descendant-or-self::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::north/child::near-north/child::far-west)"), STR("far-west")); - CHECK_XPATH_STRING(north, STR("name(descendant::near-north/descendant-or-self::near-north/descendant-or-self::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant::near-north/descendant-or-self::near-north/child::far-west)"), STR("far-west")); - CHECK_XPATH_STRING(north, STR("name(descendant::near-north/descendant::far-west/descendant-or-self::far-west)"), STR("far-west")); - - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::node()/descendant-or-self::north)"), STR("north")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::node()/descendant::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::node()/child::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant::node()/descendant-or-self::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant::node()/descendant::far-west)"), STR("far-west")); - - CHECK_XPATH_STRING(north, STR("name(/descendant-or-self::node()/descendant-or-self::north)"), STR("north")); - CHECK_XPATH_STRING(north, STR("name(/descendant-or-self::node()/child::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(/descendant::node()/descendant-or-self::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(self::node()/descendant-or-self::node()/descendant-or-self::north)"), STR("north")); - CHECK_XPATH_STRING(north, STR("name(self::node()/descendant-or-self::node()/child::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(self::node()/descendant::node()/descendant-or-self::far-west)"), STR("far-west")); - CHECK_XPATH_STRING(north, STR("name(self::node()/descendant::node()/child::far-west)"), STR("far-west")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::node()/descendant-or-self::node()/descendant-or-self::north)"), STR("north")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::node()/descendant-or-self::node()/child::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::node()/descendant::node()/descendant-or-self::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::node()/descendant::node()/child::far-west)"), STR("far-west")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::node()/child::node()/descendant-or-self::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant-or-self::node()/child::node()/child::far-west)"), STR("far-west")); - CHECK_XPATH_STRING(north, STR("name(descendant::node()/descendant-or-self::node()/descendant-or-self::near-north)"), STR("near-north")); - CHECK_XPATH_STRING(north, STR("name(descendant::node()/descendant-or-self::node()/child::far-west)"), STR("far-west")); - CHECK_XPATH_STRING(north, STR("name(descendant::node()/descendant::node()/descendant-or-self::far-west)"), STR("far-west")); -} - -TEST_XML_FLAGS(xpath_xalan_axes_5, "text", parse_default | parse_comments | parse_pi) -{ - CHECK_XPATH_NODESET(doc, STR("text/self::text()")); - CHECK_XPATH_NODESET(doc, STR("comment/self::comment()")); - CHECK_XPATH_NODESET(doc, STR("pi/self::processing-instruction()")); -} - -TEST_XML(xpath_xalan_axes_6, "Test for source tree depthABCDEFGHIJKLMNO") -{ - CHECK_XPATH_NODESET(doc, STR("//T")) % 3 % 6 % 9 % 12 % 15 % 18 % 21 % 24 % 27 % 30 % 33 % 36 % 39 % 42 % 45 % 48; -} - -TEST_XML(xpath_xalan_axes_7, "
") -{ - xml_node center = doc.select_node(STR("//center")).node(); - - CHECK_XPATH_NODESET(center, STR("attribute::*[2]")) % 10; - CHECK_XPATH_NODESET(center, STR("@*")) % 9 % 10 % 11; - CHECK_XPATH_NODESET(center, STR("child::*/child::*")) % 13; - CHECK_XPATH_NODESET(center, STR("child::*/descendant::*")) % 13 % 14; - CHECK_XPATH_NODESET(center, STR("descendant::*/child::*")) % 13 % 14; -} - -TEST_XML(xpath_xalan_axes_8, "
") -{ - xml_node near_north = doc.select_node(STR("//near-north")).node(); - - CHECK_XPATH_NODESET(near_north, STR("center//child::*")) % 12 % 13 % 14 % 15 % 16; - CHECK_XPATH_NODESET(near_north, STR("center//descendant::*")) % 12 % 13 % 14 % 15 % 16; - CHECK_XPATH_NODESET(near_north, STR("center/descendant::*")) % 12 % 13 % 14 % 15 % 16; - CHECK_XPATH_NODESET(near_north, STR("center/child::*")) % 12 % 13 % 16; - CHECK_XPATH_NODESET(near_north, STR("center//*")) % 12 % 13 % 14 % 15 % 16; -} - -TEST_XML(xpath_xalan_axes_9, "") -{ - xml_node baz = doc.select_node(STR("//baz")).node(); - - CHECK_XPATH_NODESET(baz, STR("ancestor-or-self::*[@att1][1]/@att1")) % 8; - CHECK_XPATH_NODESET(baz, STR("(ancestor-or-self::*)[@att1][1]/@att1")) % 4; - - CHECK_XPATH_NODESET(baz, STR("ancestor::foo[1]/@att1")) % 8; - CHECK_XPATH_NODESET(baz, STR("(ancestor::foo[1])/@att1")) % 8; - CHECK_XPATH_NODESET(baz, STR("(ancestor::foo)[1]/@att1")) % 4; - CHECK_XPATH_NODESET(baz, STR("((ancestor::foo))[1]/@att1")) % 4; - CHECK_XPATH_NODESET(baz, STR("(((ancestor::foo)[1])/@att1)")) % 4; - - xml_node bar = doc.child(STR("doc")).child(STR("bar")); - - CHECK_XPATH_NODESET(bar, STR("preceding::foo[1]/@att1")) % 8; - CHECK_XPATH_NODESET(bar, STR("(preceding::foo)[1]/@att1")) % 4; -} - -TEST_XML(xpath_xalan_axes_10, "") -{ - xml_node baz = doc.child(STR("doc")).child(STR("baz")); - - CHECK_XPATH_NODESET(baz, STR("preceding-sibling::foo[1]/@att1")) % 8; - CHECK_XPATH_NODESET(baz, STR("(preceding-sibling::foo)[1]/@att1")) % 4; -} - -TEST_XML(xpath_xalan_axes_11, "
helloahoy
goodbyesayonaraadios
alohaA3b-1A3b-2shalom
") -{ - xml_node chapter = doc.child(STR("chapter")); - - CHECK_XPATH_NUMBER(doc, STR("count(//@*)"), 16); - CHECK_XPATH_NUMBER(doc, STR("count(//@title)"), 12); - CHECK_XPATH_NUMBER(doc, STR("count(//section//@*)"), 14); - CHECK_XPATH_NUMBER(doc, STR("count(//section//@title)"), 11); - - CHECK_XPATH_NUMBER(chapter, STR("count(.//@*)"), 16); - CHECK_XPATH_NUMBER(chapter, STR("count(.//@title)"), 12); - CHECK_XPATH_NUMBER(chapter, STR("count(section[1]//@*)"), 5); - CHECK_XPATH_NUMBER(chapter, STR("count(section[1]//@title)"), 3); - CHECK_XPATH_NUMBER(chapter, STR("count(section[2]//@*)"), 4); - CHECK_XPATH_NUMBER(chapter, STR("count(section[2]//@title)"), 4); - CHECK_XPATH_NUMBER(chapter, STR("count(section[3]//@*)"), 5); - CHECK_XPATH_NUMBER(chapter, STR("count(section[3]//@title)"), 4); -} - -TEST_XML_FLAGS(xpath_xalan_axes_12, "north-text1
center-text1south-textcenter-text2
north-text2
", parse_default | parse_comments) -{ - CHECK_XPATH_NODESET(doc, STR("/descendant::*")) % 2 % 3 % 5 % 6 % 7 % 9 % 10 % 12 % 13 % 15 % 17 % 18 % 20; - CHECK_XPATH_NODESET(doc, STR("far-north/..//*")) % 2 % 3 % 5 % 6 % 7 % 9 % 10 % 12 % 13 % 15 % 17 % 18 % 20; - CHECK_XPATH_NODESET(doc, STR("far-north/north/..//*")) % 3 % 5 % 6 % 7 % 9 % 10 % 12 % 13 % 15 % 17 % 18 % 20; - CHECK_XPATH_NODESET(doc, STR("far-north/north-yonder/..//*")); -} - -TEST_XML(xpath_xalan_axes_13, "") -{ - xml_node d = doc.child(STR("doc")); - xml_node baz = doc.select_node(STR("//baz")).node(); - - CHECK_XPATH_NUMBER(d, STR("count(descendant-or-self::*/@att1)"), 5); - CHECK_XPATH_NODESET(d, STR("descendant-or-self::*/@att1[last()]")) % 3 % 5 % 7 % 9 % 11; - CHECK_XPATH_STRING(d, STR("string(descendant-or-self::*/@att1[last()])"), STR("e")); - CHECK_XPATH_NODESET(d, STR("descendant-or-self::*[last()]/@att1")) % 11; - CHECK_XPATH_NODESET(d, STR("(descendant-or-self::*/@att1)[last()]")) % 11; - - CHECK_XPATH_NUMBER(baz, STR("count(ancestor-or-self::*/@att1)"), 5); - CHECK_XPATH_NODESET(baz, STR("ancestor-or-self::*/@att1[last()]")) % 3 % 5 % 7 % 9 % 11; - CHECK_XPATH_STRING(baz, STR("string(ancestor-or-self::*/@att1[last()])"), STR("e")); - CHECK_XPATH_NODESET(baz, STR("(ancestor-or-self::*)/@att1[last()]")) % 3 % 5 % 7 % 9 % 11; - CHECK_XPATH_STRING(baz, STR("string((ancestor-or-self::*)/@att1[last()])"), STR("e")); - CHECK_XPATH_NODESET(baz, STR("(ancestor-or-self::*/@att1)[last()]")) % 11; - CHECK_XPATH_NODESET(baz, STR("(ancestor::*|self::*)/@att1[last()]")) % 3 % 5 % 7 % 9 % 11; - CHECK_XPATH_STRING(baz, STR("string((ancestor::*|self::*)/@att1[last()])"), STR("e")); - CHECK_XPATH_NODESET(baz, STR("((ancestor::*|self::*)/@att1)[last()]")) % 11; -} - -TEST_XML_FLAGS(xpath_xalan_axes_14, "text
text", parse_default | parse_comments | parse_pi) -{ - CHECK_XPATH_NODESET(doc, STR("//center/preceding::node()")) % 7 % 6 % 5 % 3; - CHECK_XPATH_NODESET(doc, STR("//center/following::node()")) % 9 % 10 % 11 % 12; -} - -TEST_XML(xpath_xalan_axes_15, "is newxyzis new but has textis not new") -{ - CHECK_XPATH_NODESET(doc, STR("//text()[ancestor::*[@new='true'][not(text())]]")) % 6; - CHECK_XPATH_NODESET(doc, STR("//text()[ancestor::*[2][@new]]")) % 6 % 11 % 15; - - xml_node foo = doc.child(STR("doc")).child(STR("foo")).child(STR("baz")).first_child(); - - CHECK_XPATH_STRING(foo, STR("name(ancestor::*[3])"), STR("doc")); - CHECK_XPATH_STRING(foo, STR("name(ancestor::*[2])"), STR("foo")); - CHECK_XPATH_STRING(foo, STR("name(ancestor::*[1])"), STR("baz")); -} - -TEST_XML(xpath_xalan_axes_16, "") -{ - xml_node c1 = doc.child(STR("doc")).child(STR("child")), c2 = c1.next_sibling(), c3 = c2.next_sibling(), c4 = c3.next_sibling(), c5 = c4.next_sibling(), c6 = c5.next_sibling(); - - CHECK_XPATH_STRING(c1.first_child(), STR("concat(count(descendant::*), ',', count(descendant-or-self::*))"), STR("1,2")); - CHECK_XPATH_STRING(c1.last_child(), STR("concat(count(descendant::*), ',', count(descendant-or-self::*))"), STR("3,4")); - - CHECK_XPATH_STRING(c2.first_child(), STR("concat(count(descendant::*), ',', count(descendant-or-self::*))"), STR("3,4")); - - CHECK_XPATH_STRING(c3.first_child(), STR("concat(count(descendant::*), ',', count(descendant-or-self::*))"), STR("1,2")); - - CHECK_XPATH_STRING(c4.first_child(), STR("concat(count(descendant::*), ',', count(descendant-or-self::*))"), STR("0,1")); - - CHECK_XPATH_STRING(c5.first_child(), STR("concat(count(descendant::*), ',', count(descendant-or-self::*))"), STR("0,1")); - CHECK_XPATH_STRING(c5.last_child(), STR("concat(count(descendant::*), ',', count(descendant-or-self::*))"), STR("0,1")); - - CHECK_XPATH_STRING(c6, STR("concat(count(descendant::*), ',', count(descendant-or-self::*))"), STR("0,1")); - - CHECK_XPATH_STRING(xml_node(), STR("concat(count(descendant::*), ',', count(descendant-or-self::*))"), STR("0,0")); -} - -TEST_XML(xpath_xalan_axes_17, "here") -{ - CHECK_XPATH_NODESET(doc, STR("//xx/descendant::*")) % 10 % 20 % 24 % 26 % 27; -} - -TEST_XML(xpath_xalan_axes_18, "
") -{ - xml_node center = doc.child(STR("north")).child(STR("center")); - - CHECK_XPATH_NODESET(center, STR("@*/self::node()")) % 4; - CHECK_XPATH_NODESET(center, STR("@*/self::*")); // * tests for principal node type - CHECK_XPATH_NODESET(center, STR("@*/self::text()")); - CHECK_XPATH_NODESET(center, STR("@*/self::center-attr")); // * tests for principal node type -} - -#endif diff --git a/external/pugixml/tests/test_xpath_xalan_4.cpp b/external/pugixml/tests/test_xpath_xalan_4.cpp deleted file mode 100644 index 997ffb491..000000000 --- a/external/pugixml/tests/test_xpath_xalan_4.cpp +++ /dev/null @@ -1,300 +0,0 @@ -#ifndef PUGIXML_NO_XPATH - -#include "test.hpp" - -using namespace pugi; - -TEST_XML(xpath_xalan_position_1, "1234") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_BOOLEAN(c, STR("position()=1"), true); - CHECK_XPATH_NODESET(c, STR("*[position()=4]")) % 9; -} - -TEST_XML_FLAGS(xpath_xalan_position_2, "111912632827256345", parse_default | parse_comments | parse_pi) -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_NODESET(c, STR("*[@test and position()=8]")) % 27; - CHECK_XPATH_NODESET(c, STR("*[@test][position()=4]/num")) % 29; - CHECK_XPATH_NUMBER(c, STR("count(*)"), 8); - CHECK_XPATH_NODESET(c, STR("*[last()=position()]")) % 27; - CHECK_XPATH_NODESET(c, STR("a[position()=2]")) % 7; - CHECK_XPATH_NODESET(c, STR("a[3]/../a[position()=4]/num/../@test")) % 14; - CHECK_XPATH_BOOLEAN(c, STR("not(position()=last())"), false); - CHECK_XPATH_BOOLEAN(c, STR("position()=2"), false); - CHECK_XPATH_BOOLEAN(c, STR("last()=1"), true); - CHECK_XPATH_BOOLEAN(c, STR("last()+2=3"), true); - CHECK_XPATH_NODESET(c, STR("a[position()=5 mod 3]")) % 7; - CHECK_XPATH_NODESET(c, STR("a/num/text()[position()=1]")) % 6 % 9 % 12 % 16 % 19 % 22 % 26 % 30; - CHECK_XPATH_NODESET(c, STR("a/num/text()[position()=2]")) % 32; - CHECK_XPATH_NODESET(c, STR("a/num/text()[position()=last()]")) % 6 % 9 % 12 % 16 % 19 % 22 % 26 % 32; - CHECK_XPATH_NODESET(c, STR("a/num/text()[1]")) % 6 % 9 % 12 % 16 % 19 % 22 % 26 % 30; - CHECK_XPATH_NODESET(c, STR("a/num/text()[2]")) % 32; - CHECK_XPATH_NODESET(c, STR("a/num/text()[last()]")) % 6 % 9 % 12 % 16 % 19 % 22 % 26 % 32; - CHECK_XPATH_NODESET(c, STR("a[floor(last() div 3)]")) % 7; - CHECK_XPATH_NODESET(c, STR("a[ceiling(last() div 3)]")) % 10; - CHECK_XPATH_NODESET(c, STR("a[round(last() div 3)]")) % 10; - CHECK_XPATH_NODESET(c, STR("a[last() div 3]")); - CHECK_XPATH_NODESET(c, STR("a[last() div 2]")) % 13; - CHECK_XPATH_NODESET(c, STR("a[3]/../a[position()>=2 and position()<=4]")) % 7 % 10 % 13; - CHECK_XPATH_NUMBER(c, STR("count(a[position()>=2 and position()<=4]/num)"), 3); - CHECK_XPATH_NUMBER(c, STR("count(a/@*)"), 4); - CHECK_XPATH_NUMBER(c, STR("count(a/attribute::*)"), 4); - CHECK_XPATH_NODESET(c, STR("*[not(@test)][position()=last()]")) % 20; - CHECK_XPATH_NODESET(c, STR("*[not(@test)][last()]")) % 20; - CHECK_XPATH_NODESET(c, STR("a[3-2]")) % 3; - CHECK_XPATH_NODESET(c, STR("a[0]")); - CHECK_XPATH_NODESET(c, STR("a[9]")); - CHECK_XPATH_NODESET(c, STR("a['3']")) % 3 % 7 % 10 % 13 % 17 % 20 % 23 % 27; - CHECK_XPATH_NODESET(c, STR("a[number('3')]")) % 10; - CHECK_XPATH_NODESET(c, STR("processing-instruction()[2]")) % 34; - CHECK_XPATH_NODESET(c, STR("processing-instruction('pi')[2]")) % 34; - CHECK_XPATH_NODESET(c, STR("comment()[2]")) % 36; - CHECK_XPATH_NODESET(c, STR("a/*[last()]")) % 5 % 8 % 11 % 15 % 18 % 21 % 25 % 29; - CHECK_XPATH_NODESET(c, STR("a/child::*[last()]")) % 5 % 8 % 11 % 15 % 18 % 21 % 25 % 29; - CHECK_XPATH_NODESET(c, STR("a/descendant::*[last()]")) % 5 % 8 % 11 % 15 % 18 % 21 % 25 % 31; - CHECK_XPATH_NODESET(c, STR("a/child::node()[last()]")) % 5 % 8 % 11 % 15 % 18 % 21 % 25 % 29; - CHECK_XPATH_NODESET(c, STR("a/descendant::text()[last()]")) % 6 % 9 % 12 % 16 % 19 % 22 % 26 % 32; - CHECK_XPATH_NODESET(c, STR("child::comment()[last()]")) % 36; -} - -TEST_XML(xpath_xalan_position_3, "
AAA
BBBAbout this article
CCCThis is the section titled 'ZZZ'.DDDDon't worry.
EEEThis is the deep subsection.
") -{ - CHECK_XPATH_NODESET(doc, STR("(article//section/title|/articleinfo/title|article/section/para)[last()]")) % 28; - CHECK_XPATH_NODESET(doc, STR("(article//section/title|/articleinfo/title|article/section/para)[1]")) % 10; - CHECK_XPATH_NUMBER(doc, STR("count(article/articleinfo/section[last()])"), 1); - CHECK_XPATH_NUMBER(doc, STR("count(article/articleinfo/section[last()][title='BBB'])"), 1); -} - -TEST_XML(xpath_xalan_position_4, "
hello
goodbyesayonara
aloha
") -{ - CHECK_XPATH_NODESET(doc, STR("chapter//footnote[1]")) % 4 % 7 % 12; -} - -TEST_XML(xpath_xalan_position_5, "
helloahoy
goodbyesayonaraadios
alohashalomyociao
") -{ - CHECK_XPATH_NODESET(doc, STR("chapter//footnote[2]")) % 6 % 11 % 21 % 23; - CHECK_XPATH_NODESET(doc, STR("(chapter//footnote)[2]")) % 6; - CHECK_XPATH_NODESET(doc, STR("(child::chapter/descendant-or-self::node())/footnote[2]")) % 6 % 11 % 21 % 23; - CHECK_XPATH_NODESET(doc, STR("chapter/descendant::footnote[6]")) % 16; - CHECK_XPATH_NODESET(doc, STR("chapter/descendant::footnote[6][1][last()]")) % 16; -} - -TEST_XML_FLAGS(xpath_xalan_position_6, "pcdata", parse_default | parse_pi | parse_comments) -{ - CHECK_XPATH_NUMBER(doc, STR("count(/node/@attr/ancestor-or-self::node())"), 3); - CHECK_XPATH_NUMBER(doc, STR("count(/node/text()/ancestor-or-self::node())"), 4); - CHECK_XPATH_NUMBER(doc, STR("count(/node/processing-instruction()/ancestor-or-self::node())"), 4); - CHECK_XPATH_NUMBER(doc, STR("count(/node/processing-instruction('pi1')/ancestor-or-self::node())"), 3); - CHECK_XPATH_NUMBER(doc, STR("count(/node/comment()/ancestor-or-self::node())"), 3); -} - -TEST_XML(xpath_xalan_position_7, "
helloahoy
goodbyesayonaraadios
alohaA3b-1A3b-2shalom
") -{ - CHECK_XPATH_NODESET(doc, STR("chapter/section//@title[7]")); - CHECK_XPATH_NODESET(doc, STR("(chapter/section//@title)[7]")) % 21; -} - -TEST_XML(xpath_xalan_match_1, "") -{ - xml_node c = doc.child(STR("root")); - - CHECK_XPATH_NODESET(c, STR("x[(position() mod 2)=1][position() > 3]")) % 21 % 27 % 33; - CHECK_XPATH_NODESET(c, STR("x[(position() mod 2)=1][position() > 3][position()=2]")) % 27; - CHECK_XPATH_NODESET(c, STR("x[(position() mod 2) > 0][position() > 3][2]")) % 27; - CHECK_XPATH_NODESET(c, STR("x[(position() mod 2)=1][position() > 3][last()]")) % 33; - CHECK_XPATH_NODESET(c, STR("x[(position() mod 2)=1][@num > 5][last()]")) % 33; - CHECK_XPATH_NODESET(c, STR("x[(@num mod 3)=2][position() > 2][last()]")) % 33; - CHECK_XPATH_NODESET(c, STR("x[(position() mod 2)=1][2][@num < 10]")) % 9; - CHECK_XPATH_NODESET(c, STR("x[(((((2*10)-4)+9) div 5) mod 3)]")) % 6; -} - - -TEST_XML(xpath_xalan_match_2, "doc-l1-v2doc-l1-x2doc-l1-l2-v3doc-l1-l2-w3doc-l1-l2-x3doc-l1-l2-y3doc-l1-l2-l3-v4doc-l1-l2-l3-x4") -{ - CHECK_XPATH_STRING(doc, STR("doc/l1/v2"), STR("doc-l1-v2")); - CHECK_XPATH_STRING(doc, STR("doc/child::l1/x2"), STR("doc-l1-x2")); - CHECK_XPATH_STRING(doc, STR("doc/l1//v3"), STR("doc-l1-l2-v3")); - CHECK_XPATH_STRING(doc, STR("doc//l2/w3"), STR("doc-l1-l2-w3")); - CHECK_XPATH_STRING(doc, STR("doc/child::l1//x3"), STR("doc-l1-l2-x3")); - CHECK_XPATH_STRING(doc, STR("doc//child::l2/y3"), STR("doc-l1-l2-y3")); - CHECK_XPATH_STRING(doc, STR("doc//l2//v4"), STR("doc-l1-l2-l3-v4")); - CHECK_XPATH_STRING(doc, STR("doc//child::l2//x4"), STR("doc-l1-l2-l3-x4")); - - CHECK_XPATH_STRING(doc, STR("doc/l1/v2"), STR("doc-l1-v2")); - CHECK_XPATH_STRING(doc, STR("doc/l1/child::x2"), STR("doc-l1-x2")); - CHECK_XPATH_STRING(doc, STR("doc/l1//v3"), STR("doc-l1-l2-v3")); - CHECK_XPATH_STRING(doc, STR("doc//l2/w3"), STR("doc-l1-l2-w3")); - CHECK_XPATH_STRING(doc, STR("doc/l1//child::x3"), STR("doc-l1-l2-x3")); - CHECK_XPATH_STRING(doc, STR("doc//l2/child::y3"), STR("doc-l1-l2-y3")); - CHECK_XPATH_STRING(doc, STR("doc//l2//v4"), STR("doc-l1-l2-l3-v4")); - CHECK_XPATH_STRING(doc, STR("doc//l2//child::x4"), STR("doc-l1-l2-l3-x4")); - - CHECK_XPATH_STRING(doc, STR("doc/l1/v2"), STR("doc-l1-v2")); - CHECK_XPATH_STRING(doc, STR("doc/child::l1/child::x2"), STR("doc-l1-x2")); - CHECK_XPATH_STRING(doc, STR("doc/l1//v3"), STR("doc-l1-l2-v3")); - CHECK_XPATH_STRING(doc, STR("doc//l2/w3"), STR("doc-l1-l2-w3")); - CHECK_XPATH_STRING(doc, STR("doc/child::l1//child::x3"), STR("doc-l1-l2-x3")); - CHECK_XPATH_STRING(doc, STR("doc//child::l2/child::y3"), STR("doc-l1-l2-y3")); - CHECK_XPATH_STRING(doc, STR("doc//l2//v4"), STR("doc-l1-l2-l3-v4")); - CHECK_XPATH_STRING(doc, STR("doc//child::l2//child::x4"), STR("doc-l1-l2-l3-x4")); -} - -TEST_XML(xpath_xalan_match_3, "John DoeJane Doe") -{ - CHECK_XPATH_NODESET(doc, STR("doc/child/*[starts-with(name(),'child-')]//name")) % 5 % 9; - CHECK_XPATH_NODESET(doc, STR("//@*")) % 6 % 10; -} - -TEST_XML(xpath_xalan_expression_1, "en
en
ENen-us
") -{ - CHECK_XPATH_NODESET(doc, STR("doc/para[@id='1' and lang('en')]")) % 3; - CHECK_XPATH_NODESET(doc, STR("doc/para[@id='4' and lang('en')]")) % 15; - CHECK_XPATH_NODESET(doc, STR("doc/div/para[lang('en')]")) % 9; - CHECK_XPATH_NODESET(doc, STR("doc/para[@id='3' and lang('en')]")) % 11; - CHECK_XPATH_NODESET(doc, STR("//para[lang('en')]/ancestor-or-self::*[@xml:lang]/@xml:lang")) % 5 % 8 % 13 % 17; -} - -TEST_XML(xpath_xalan_predicate_1, "1234") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_NODESET(c, STR("a[true()=4]")) % 3 % 5 % 7 % 9; - CHECK_XPATH_NODESET(c, STR("a[true()='stringwithchars']")) % 3 % 5 % 7 % 9; - CHECK_XPATH_NODESET(c, STR("a[true()=following-sibling::*]")) % 3 % 5 % 7; - CHECK_XPATH_NODESET(c, STR("a[true()=preceding-sibling::*]")) % 5 % 7 % 9; - CHECK_XPATH_NODESET(c, STR("a[3=following-sibling::*]")) % 3 % 5; - CHECK_XPATH_NODESET(c, STR("a[0 < true()]")) % 3 % 5 % 7 % 9; - CHECK_XPATH_NODESET(c, STR("a['3.5' < 4]")) % 3 % 5 % 7 % 9; - CHECK_XPATH_NODESET(c, STR("a[3 < following-sibling::*]")) % 3 % 5 % 7; - CHECK_XPATH_NODESET(c, STR("a[following-sibling::*>3]")) % 3 % 5 % 7; - CHECK_XPATH_NODESET(c, STR("a[3 > following-sibling::*]")) % 3; - CHECK_XPATH_NODESET(c, STR("a[following-sibling::*<3]")) % 3; - CHECK_XPATH_NODESET(c, STR("a[1 < 2 < 3]")) % 3 % 5 % 7 % 9; - CHECK_XPATH_NODESET(c, STR("a[1 < 3 < 2]")) % 3 % 5 % 7 % 9; - CHECK_XPATH_NODESET(c, STR("a[following-sibling::*=true()]")) % 3 % 5 % 7; - CHECK_XPATH_NODESET(c, STR("a[false()!=following-sibling::*]")) % 3 % 5 % 7; - CHECK_XPATH_NODESET(c, STR("a[following-sibling::*!=false()]")) % 3 % 5 % 7; - CHECK_XPATH_NODESET(c, STR("a[following-sibling::*=3]")) % 3 % 5; - CHECK_XPATH_NODESET(c, STR("a[3=following-sibling::*]")) % 3 % 5; - CHECK_XPATH_NODESET(c, STR("a[4!=following-sibling::*]")) % 3 % 5; - CHECK_XPATH_NODESET(c, STR("a[following-sibling::*!=4]")) % 3 % 5; - CHECK_XPATH_NODESET(c, STR("a[3>=following-sibling::*]")) % 3 % 5; - CHECK_XPATH_NODESET(c, STR("a[3<=following-sibling::*]")) % 3 % 5 % 7; - CHECK_XPATH_NODESET(c, STR("a[following-sibling::*<=3]")) % 3 % 5; - CHECK_XPATH_NODESET(c, STR("a[following-sibling::*>=3]")) % 3 % 5 % 7; -} - -TEST_XML(xpath_xalan_predicate_2, "") -{ - xml_node c = doc.child(STR("foo")); - - CHECK_XPATH_NODESET(c, STR("bar[@a='1' and @b='1']")) % 75 % 81 % 87 % 93; - CHECK_XPATH_NODESET(c, STR("bar[(@a='1' or @b='1') and @c='1']")) % 39 % 45 % 63 % 69 % 87 % 93; - CHECK_XPATH_NODESET(c, STR("bar[@a='1' and (@b='1' or @c='1') and @d='1']")) % 69 % 81 % 93; - CHECK_XPATH_NODESET(c, STR("bar[@a='1' and @b='1' or @c='1' and @d='1']")) % 21 % 45 % 69 % 75 % 81 % 87 % 93; - CHECK_XPATH_NODESET(c, STR("bar[(@a='1' and @b='1') or (@c='1' and @d='1')]")) % 21 % 45 % 69 % 75 % 81 % 87 % 93; - CHECK_XPATH_NODESET(c, STR("bar[@a='1' or (@b='1' and @c='1') or @d='1']")) % 9 % 21 % 33 % 39 % 45 % 51 % 57 % 63 % 69 % 75 % 81 % 87 % 93; - CHECK_XPATH_NODESET(c, STR("bar[(@a='1' or @b='1') and (@c='1' or @d='1')]")) % 33 % 39 % 45 % 57 % 63 % 69 % 81 % 87 % 93; - CHECK_XPATH_NODESET(c, STR("bar[@a='1' or @b='1' and @c='1' or @d='1']")) % 9 % 21 % 33 % 39 % 45 % 51 % 57 % 63 % 69 % 75 % 81 % 87 % 93; - CHECK_XPATH_NODESET(c, STR("bar[@a='1' or @b='1' or @c='1']")) % 15 % 21 % 27 % 33 % 39 % 45 % 51 % 57 % 63 % 69 % 75 % 81 % 87 % 93; -} - -TEST_XML(xpath_xalan_predicate_3, "12345") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_NUMBER(c, STR("count(a[@ex])"), 2); - CHECK_XPATH_NUMBER(c, STR("count(a[@ex=''])"), 1); - CHECK_XPATH_NUMBER(c, STR("count(a[string-length(@ex)=0])"), 4); - CHECK_XPATH_NUMBER(c, STR("count(a[@ex!=''])"), 1); - CHECK_XPATH_NUMBER(c, STR("count(a[string-length(@ex) > 0])"), 1); - CHECK_XPATH_NUMBER(c, STR("count(a[not(@ex)])"), 3); - CHECK_XPATH_NUMBER(c, STR("count(a[not(@ex='')])"), 4); - CHECK_XPATH_NUMBER(c, STR("count(a[not(string-length(@ex)=0)])"), 1); - CHECK_XPATH_NUMBER(c, STR("count(a[@why='value'])"), 1); - CHECK_XPATH_NUMBER(c, STR("count(a[@why!='value'])"), 1); -} - -TEST_XML(xpath_xalan_predicate_4, "
1.11.2
2.12.22.3
3.13.23.2.1
44.14.1.1
5.15.25.35.4
6.16.2
7.17.27.3
8.18.28.38.4
") -{ - CHECK_XPATH_NUMBER(doc, STR("count(//tr)"), 8); - CHECK_XPATH_NUMBER(doc, STR("count(//tr[count(./td)=3])"), 2); -} - -TEST_XML(xpath_xalan_predicate_5, "Wrong node selected!!Test executed successfullyWrong node selected!!") -{ - CHECK_XPATH_STRING(doc, STR("doc/element1[(((((2*10)-4)+9) div 5) mod 3 )]"), STR("Test executed successfully")); - CHECK_XPATH_STRING(doc, STR("doc/element1[(((((2*10)-4)+9) div 5) mod floor(3))]"), STR("Test executed successfully")); - CHECK_XPATH_STRING(doc, STR("doc/element1[floor(2)]"), STR("Test executed successfully")); -} - -TEST_XML(xpath_xalan_predicate_6, "12target34") -{ - CHECK_XPATH_STRING(doc, STR("doc/a['target'=descendant::*]"), STR("2target")); - CHECK_XPATH_STRING(doc, STR("doc/a[descendant::*='target']"), STR("2target")); -} - -TEST_XML(xpath_xalan_predicate_7, "12target34missed") -{ - CHECK_XPATH_STRING(doc, STR("doc/a['target'!=descendant::*]"), STR("4missed")); - CHECK_XPATH_STRING(doc, STR("doc/a[descendant::*!='target']"), STR("4missed")); -} - -TEST_XML(xpath_xalan_predicate_8, "this23thisthisthathellogoodbyethisthatthishellogoodbyeother") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_NODESET(c, STR("foo[(bar[2])='this']")) % 13; - CHECK_XPATH_NODESET(c, STR("foo[(bar[(baz[2])='goodbye'])]")) % 23 % 38; - CHECK_XPATH_NODESET(c, STR("foo[(bar[2][(baz[2])='goodbye'])]")) % 38; -} - -TEST_XML(xpath_xalan_predicate_9, "f-insidef-insidef-insidef-insidef-inside") -{ - CHECK_XPATH_NODESET(doc, STR("doc/*[starts-with(name(.),'f')]")) % 23; - CHECK_XPATH_NODESET(doc, STR("//*[starts-with(name(.),'f')]")) % 8 % 15 % 23 % 24; -} - -TEST_XML(xpath_xalan_predicate_10, "Text from first elementText from child1 of first elementText from child2 of first elementText from second elementText from child1 of second elementText from child2 of second element (correct execution)") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_STRING(c, STR("//child2[ancestor::element2]"), STR("Text from child2 of second element (correct execution)")); - CHECK_XPATH_STRING(c, STR("//child2[ancestor-or-self::element2]"), STR("Text from child2 of second element (correct execution)")); - CHECK_XPATH_STRING(c, STR("//child2[attribute::attr1]"), STR("Text from child2 of second element (correct execution)")); -} - -TEST_XML(xpath_xalan_predicate_11, "123456") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_NODESET(c, STR("a[@squeesh or (@squish and @squash)]")) % 3 % 7 % 11 % 18; - CHECK_XPATH_NODESET(c, STR("a[(@squeesh or @squish) and @squash]")) % 3 % 11; - CHECK_XPATH_NODESET(c, STR("a[@squeesh or @squish and @squash]")) % 3 % 7 % 11 % 18; -} - -TEST_XML(xpath_xalan_predicate_12, "12target3target") -{ - CHECK_XPATH_STRING(doc, STR("doc/a[following-sibling::*=descendant::*]"), STR("2target")); -} - -TEST_XML(xpath_xalan_predicate_13, "12target3") -{ - CHECK_XPATH_NODESET(doc, STR("doc/a[('target'=descendant::*) or @squish]")) % 3 % 6; - CHECK_XPATH_NODESET(doc, STR("doc/a[not(('target'=descendant::*) or @squish)]")) % 10; -} - -TEST_XML(xpath_xalan_predicate_14, "12child234child4") -{ - CHECK_XPATH_NODESET(doc, STR("doc/a[not(@*)]")) % 6 % 11; -} - -TEST_XML(xpath_xalan_predicate_15, "xinside") -{ - CHECK_XPATH_NODESET(doc, STR("doc/descendant::*[string-length(name(.))=1]")) % 3 % 6 % 9 % 11 % 13; -} - -#endif diff --git a/external/pugixml/tests/test_xpath_xalan_5.cpp b/external/pugixml/tests/test_xpath_xalan_5.cpp deleted file mode 100644 index 6daa234d2..000000000 --- a/external/pugixml/tests/test_xpath_xalan_5.cpp +++ /dev/null @@ -1,295 +0,0 @@ -#ifndef PUGIXML_NO_XPATH - -#include "test.hpp" - -using namespace pugi; - -TEST_XML(xpath_xalan_select_1, "") -{ - CHECK_XPATH_STRING(doc, STR("/doc/a/b/@attr"), STR("test")); -} - -TEST_XML(xpath_xalan_select_2, "doremifasolatidoG#AAbBbCC#D") -{ - xml_node c = doc.child(STR("doc")); - - // This should come out fasolatido: - CHECK_XPATH_NODESET(c, STR("fa")) % 12; - // This should come out doremifasolatido: - CHECK_XPATH_NODESET(c, STR("mi | do | fa | re")) % 3 % 6 % 8 % 12; - // This should come out do-do-remi-mi1-mi2fasolatido-fa--so-: - CHECK_XPATH_NODESET(c, STR("mi[@mi2='mi2'] | do | fa/so/@so | fa | mi/@* | re | fa/@fa | do/@do")) % 3 % 4 % 6 % 8 % 9 % 10 % 12 % 13 % 16; - // This should come out solatidoG#: - CHECK_XPATH_NODESET(c, STR(".//*[@so]")) % 15 % 23; - // This should come out relatidoABb: - CHECK_XPATH_NODESET(c, STR("*//la | //Bflat | re")) % 6 % 18 % 28 % 31; - // This should come out domitiACD: - CHECK_XPATH_NODESET(c, STR("fa/../mi | Aflat/natural/la | Csharp//* | /doc/do | *//ti")) % 3 % 8 % 20 % 28 % 34 % 37; -} - -TEST_XML(xpath_xalan_select_3, "preceding sibling number 1current nodefollowing sibling number 3cousin 1cousin 2cousin 3") -{ - CHECK_XPATH_NODESET(doc.child(STR("doc")).child(STR("sub1")).child(STR("child2")), STR("preceding-sibling::child1|//child3")) % 4 % 8 % 15; -} - -TEST_XML(xpath_xalan_select_4, "bad1bad2bad3bad4OKbad5") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_NODESET(c, STR("child::sub")) % 11; - CHECK_XPATH_NODESET(c, STR("child ::sub")) % 11; - CHECK_XPATH_NODESET(c, STR("child:: sub")) % 11; - CHECK_XPATH_NODESET(c, STR("child :: sub")) % 11; -} - -TEST_XML_FLAGS(xpath_xalan_select_5, "bad0bad1bad2", parse_default | parse_comments) -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_NODESET(c, STR("comment()")) % 4; - CHECK_XPATH_NODESET(c, STR("comment ()")) % 4; - CHECK_XPATH_NODESET(c, STR("comment ( ) ")) % 4; - CHECK_XPATH_NUMBER(c, STR("string-length()"), 12); - CHECK_XPATH_NUMBER(c, STR("string-length ()"), 12); - CHECK_XPATH_NUMBER(c, STR("string-length ( ) "), 12); -} - -TEST_XML(xpath_xalan_select_6, "
9
") -{ - xml_node c = doc.child(STR("div")); - - CHECK_XPATH_NUMBER(doc, STR("div +3"), 12); - CHECK_XPATH_NUMBER(doc, STR("* +3"), 12); - CHECK_XPATH_NUMBER(c, STR("@div - 5"), 15); - CHECK_XPATH_NUMBER(c, STR("@div -5"), 15); - CHECK_XPATH_NUMBER(c, STR("@div-5"), 12); - CHECK_XPATH_NUMBER(c, STR("@*-5"), 15); - CHECK_XPATH_NUMBER(doc, STR("16-div"), 7); - CHECK_XPATH_NUMBER(doc, STR("25-*"), 16); - CHECK_XPATH_NUMBER(doc, STR("54 div*"), 6); - CHECK_XPATH_NUMBER(doc, STR("(* - 4) div 2"), 2.5); - CHECK_XPATH_NUMBER(doc, STR("' 6 ' div 2"), 3); - CHECK_XPATH_NUMBER(doc, STR("' 6 '*div"), 54); - CHECK_XPATH_NUMBER(doc, STR("5.*."), 45); - CHECK_XPATH_NUMBER(doc, STR("5.+."), 14); -} - -TEST_XML(xpath_xalan_select_7, "
9
8
") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_NUMBER(c, STR("attribute :: div"), 20); - CHECK_XPATH_NUMBER(c, STR("attribute :: *"), 20); - CHECK_XPATH_NUMBER(c, STR("attribute*(div - 4)"), 40); - CHECK_XPATH_NUMBER(c, STR("(* - 4)**"), 45); -} - -TEST_XML(xpath_xalan_select_8, "x
7
y
9
z
5
") -{ - CHECK_XPATH_NODESET(doc, STR("doc/a[div=9]")) % 7; -} - -TEST_XML(xpath_xalan_select_9, "7379929920") -{ - CHECK_XPATH_NODESET(doc, STR("doc/a[*=9]")) % 9 % 15 % 21; -} - -TEST_XML(xpath_xalan_select_10, "child1child2") -{ - CHECK_XPATH_NODESET(doc, STR("/doc/sub1/child1|/doc/sub2/child2")) % 4 % 7; - CHECK_XPATH_NODESET(doc.child(STR("doc")), STR("sub1/child1|/doc/sub2/child2")) % 4 % 7; - CHECK_XPATH_NODESET(doc.child(STR("doc")), STR("sub1/child1|sub2/child2")) % 4 % 7; - CHECK_XPATH_NODESET(doc, STR("//self::child1|//self::child2")) % 4 % 7; - CHECK_XPATH_NODESET(doc, STR("//child1|//child2")) % 4 % 7; - CHECK_XPATH_NODESET(doc, STR("//child1|//child2|//child3")) % 4 % 7 % 10; -} - -TEST_XML(xpath_xalan_select_11, "descendant number 1descendant number 2") -{ - CHECK_XPATH_NODESET(doc, STR("//child1/ancestor::sub1|//child1/ancestor::sub2")) % 3 % 7; -} - -TEST_XML(xpath_xalan_select_12, "child number 1grandchild number 1child number 2grandchild number 2child number 3grandchild number 3child number 4grandchild number 4") -{ - CHECK_XPATH_NODESET(doc, STR("//child/ancestor-or-self::sub | //child/ancestor-or-self::sub-sub")) % 3 % 7 % 15 % 19 % 31; -} - -TEST_XML(xpath_xalan_select_13, "Carmelo MontanezNineDavid MarstonSevenMary BradyTenLynne RosenthalFive") -{ - CHECK_XPATH_NODESET(doc, STR("doc/book/author[name/@real='no']|doc/book/author[name/@real='yes']")) % 4 % 20; - CHECK_XPATH_NODESET(doc, STR("doc/book/author[(name/@real='no' and position()=1)]|doc/book/author[(name/@real='yes' and position()=last())]")) % 4 % 20; - CHECK_XPATH_NODESET(doc, STR("doc/book/author[name='Mary Brady']|doc/book/author[name/@real='no']")) % 4 % 20; - CHECK_XPATH_NODESET(doc, STR("doc/book/author/name|doc/book/author/bibliography/author/name")) % 5 % 13 % 21 % 28; - CHECK_XPATH_NODESET(doc, STR("doc/book/author/name|doc/book/author/bibliography/author/chapters")) % 5 % 13 % 21 % 30; - CHECK_XPATH_NODESET(doc, STR("doc/book/author/name|doc/book/author/noElement")) % 5 % 13 % 21; - CHECK_XPATH_NODESET(doc, STR("//noChild1|//noChild2")); -} - -TEST_XML(xpath_xalan_select_14, "child number 1child number 2") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_NODESET(c, STR("child::sub1|child::sub2")) % 3 % 7; - CHECK_XPATH_NODESET(c, STR("descendant::child1|descendant::child2")) % 5 % 9; - CHECK_XPATH_NODESET(c, STR("descendant-or-self::sub1|descendant-or-self::sub2")) % 3 % 7; - CHECK_XPATH_NODESET(c.child(STR("sub2")), STR("preceding-sibling::sub1|following-sibling::sub3")) % 3 % 11; -} - -TEST_XML(xpath_xalan_select_15, "Selection of this child is an error.Selection of this child is an error.Selection of this child is an error.Selection of this child is an error.EFGSelection of this child is an error.Selection of this child is an error.JKSelection of this child is an error.Selection of this child is an error.NOP") -{ - xml_node c = doc.child(STR("doc")); - - CHECK_XPATH_NODESET(c, STR("child[@wide='3']|child[@deep='3']")) % 15 % 18 % 22 % 35 % 39 % 51 % 54 % 58; - CHECK_XPATH_NODESET(c, STR("child[@deep='3']|child[@wide='3']")) % 15 % 18 % 22 % 35 % 39 % 51 % 54 % 58; -} - -TEST_XML(xpath_xalan_select_16, "1234") -{ - CHECK_XPATH_NUMBER(doc, STR("count(doc/a/attribute::*)"), 9); - CHECK_XPATH_NUMBER(doc, STR("count(//@*)"), 9); - CHECK_XPATH_NUMBER(doc, STR("count(//@squish)"), 3); -} - -TEST_XML(xpath_xalan_select_17, "") -{ - xml_node c = doc.child(STR("directions")); - - CHECK_XPATH_NODESET(c, STR("north/* | north/dup1 | north/dup2")) % 4 % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(c, STR("north/dup2 | north/dup1 | north/*")) % 4 % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(c, STR("//north/dup2 | south/preceding-sibling::*[4]/* | north/dup1 | north/*")) % 4 % 5 % 6 % 7 % 8; - CHECK_XPATH_NODESET(c, STR("north/dup2 | south/preceding-sibling::*[4]/* | north/*")) % 4 % 5 % 6 % 7 % 8; -} - -TEST_XML(xpath_xalan_select_18, "HelloThereWorld") -{ - CHECK_XPATH_NODESET(doc, STR("/para/font[@color='green']")) % 6; - CHECK_XPATH_NODESET(doc.child(STR("para")), STR("/para/font[@color='green']")) % 6; - CHECK_XPATH_NODESET(doc.child(STR("para")).last_child(), STR("/para/font[@color='green']")) % 6; -} - -TEST_XML_FLAGS(xpath_xalan_select_19, "1in-a2345678in-c9", parse_default | parse_comments | parse_pi) -{ - CHECK_XPATH_NODESET(doc, STR("//*")) % 2 % 4 % 8 % 10 % 12 % 18; - CHECK_XPATH_NODESET(doc, STR("//node()")) % 2 % 3 % 4 % 5 % 6 % 7 % 8 % 9 % 10 % 11 % 12 % 13 % 14 % 15 % 16 % 17 % 18 % 19 % 20 % 21; - CHECK_XPATH_NODESET(doc, STR("//text()")) % 3 % 5 % 6 % 9 % 11 % 13 % 14 % 15 % 17 % 19 % 20; - CHECK_XPATH_NODESET(doc, STR("//comment()")) % 7 % 16; - CHECK_XPATH_NODESET(doc, STR("//processing-instruction()")) % 21; -} - -TEST_XML(xpath_xalan_bugzilla_1, "15152252") -{ - CHECK_XPATH_NODESET(doc, STR("/report/colData[@colId='F' and not(.=preceding::colData)]")) % 3; -} - -TEST(xpath_xalan_error_boolean) -{ - CHECK_XPATH_FAIL(STR("nt(true())")); - CHECK_XPATH_FAIL(STR("not(troo())")); - CHECK_XPATH_FAIL(STR("troo() and (2 = 2)")); - CHECK_XPATH_FAIL(STR("troo() or (2 = 2)")); - CHECK_XPATH_FAIL(STR("2 = troo()")); - CHECK_XPATH_FAIL(STR("boolean(troo())")); - CHECK_XPATH_FAIL(STR("true(doc)")); - CHECK_XPATH_FAIL(STR("false(doc)")); - CHECK_XPATH_FAIL(STR("not()")); - CHECK_XPATH_FAIL(STR("not(false(), doc)")); - CHECK_XPATH_FAIL(STR("boolean()")); - CHECK_XPATH_FAIL(STR("boolean(false(), doc)")); - CHECK_XPATH_FAIL(STR("lang()")); - CHECK_XPATH_FAIL(STR("lang('en','us')")); -} - -TEST(xpath_xalan_error_conditional) -{ - CHECK_XPATH_FAIL(STR("")); - CHECK_XPATH_FAIL(STR("@name='John' | @name='Joe'")); - CHECK_XPATH_FAIL(STR("\x95not(name(.)='')")); -} - -TEST(xpath_xalan_error_match) -{ - CHECK_XPATH_FAIL(STR("//")); - CHECK_XPATH_FAIL(STR("section1|")); - CHECK_XPATH_FAIL(STR("|section1")); -} - -TEST(xpath_xalan_error_math) -{ - CHECK_XPATH_FAIL(STR("6 quo 4")); - CHECK_XPATH_FAIL(STR("-troo()")); - CHECK_XPATH_FAIL(STR("number(troo())")); - CHECK_XPATH_FAIL(STR("5 * troo()")); - CHECK_XPATH_FAIL(STR("12 div troo()")); - CHECK_XPATH_FAIL(STR("number(8,doc)")); - CHECK_XPATH_FAIL(STR("sum(doc, 8)")); - CHECK_XPATH_FAIL(STR("sum()")); - CHECK_XPATH_FAIL(STR("floor(8,7)")); - CHECK_XPATH_FAIL(STR("floor()")); - CHECK_XPATH_FAIL(STR("ceiling(8,7)")); - CHECK_XPATH_FAIL(STR("ceiling()")); - CHECK_XPATH_FAIL(STR("round(8,7)")); - CHECK_XPATH_FAIL(STR("round()")); -} - -TEST(xpath_xalan_error_namespace) -{ - CHECK_XPATH_FAIL(STR("local-name(baz2:b,..)")); - CHECK_XPATH_FAIL(STR("namespace-uri(baz2:b,..)")); - CHECK_XPATH_FAIL(STR("name(a,b)")); - CHECK_XPATH_FAIL(STR(":foo")); - CHECK_XPATH_FAIL(STR("*:foo")); -} - -TEST(xpath_xalan_error_position) -{ - CHECK_XPATH_FAIL(STR("*[last(*,2)]")); - CHECK_XPATH_FAIL(STR("position(b)=1")); - CHECK_XPATH_FAIL(STR("count()")); - CHECK_XPATH_FAIL(STR("count(*,4)")); - CHECK_XPATH_FAIL(STR("position()=last(a)")); -} - -TEST(xpath_xalan_error_select) -{ - CHECK_XPATH_FAIL(STR("")); - CHECK_XPATH_FAIL(STR("count(troo())")); - CHECK_XPATH_FAIL(STR("c::sub")); - CHECK_XPATH_FAIL(STR("c()")); - CHECK_XPATH_FAIL(STR("(* - 4) foo 2")); - CHECK_XPATH_FAIL(STR("5 . + *")); - CHECK_XPATH_FAIL(STR("4/.")); - CHECK_XPATH_FAIL(STR("true()/.")); - CHECK_XPATH_FAIL(STR("item//[@type='x']")); - CHECK_XPATH_FAIL(STR("//")); - CHECK_XPATH_FAIL(STR("item//")); - CHECK_XPATH_FAIL(STR("count(//)")); - CHECK_XPATH_FAIL(STR("substring-after(//,'0')")); - CHECK_XPATH_FAIL(STR("//+17")); - CHECK_XPATH_FAIL(STR("//|subitem")); - CHECK_XPATH_FAIL(STR("..[near-north]")); -} - -TEST(xpath_xalan_error_string) -{ - CHECK_XPATH_FAIL(STR("string(troo())")); - CHECK_XPATH_FAIL(STR("string-length(troo())")); - CHECK_XPATH_FAIL(STR("normalize-space(a,'\t\r\n ab cd ')")); - CHECK_XPATH_FAIL(STR("contains('ENCYCLOPEDIA')")); - CHECK_XPATH_FAIL(STR("contains('ENCYCLOPEDIA','LOPE',doc)")); - CHECK_XPATH_FAIL(STR("starts-with('ENCYCLOPEDIA')")); - CHECK_XPATH_FAIL(STR("starts-with('ENCYCLOPEDIA','LOPE',doc)")); - CHECK_XPATH_FAIL(STR("substring-before('ENCYCLOPEDIA')")); - CHECK_XPATH_FAIL(STR("substring-before('ENCYCLOPEDIA','LOPE',doc)")); - CHECK_XPATH_FAIL(STR("substring-after('ENCYCLOPEDIA')")); - CHECK_XPATH_FAIL(STR("substring-after('ENCYCLOPEDIA','LOPE',doc)")); - CHECK_XPATH_FAIL(STR("substring('ENCYCLOPEDIA')")); - CHECK_XPATH_FAIL(STR("substring('ENCYCLOPEDIA',4,5,2)")); - CHECK_XPATH_FAIL(STR("concat('x')")); - CHECK_XPATH_FAIL(STR("string-length('ENCYCLOPEDIA','PEDI')")); - CHECK_XPATH_FAIL(STR("translate('bar','abc')")); - CHECK_XPATH_FAIL(STR("translate('bar','abc','ABC','output')")); - CHECK_XPATH_FAIL(STR("string(22,44)")); - CHECK_XPATH_FAIL(STR("concat(/*)")); -} - -#endif diff --git a/external/pugixml/tests/writer_string.cpp b/external/pugixml/tests/writer_string.cpp deleted file mode 100644 index 26bca8dd0..000000000 --- a/external/pugixml/tests/writer_string.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "writer_string.hpp" - -#include "test.hpp" - -static bool test_narrow(const std::string& result, const char* expected, size_t length) -{ - // check result - if (result != std::string(expected, expected + length)) return false; - - // check comparison operator (incorrect implementation can theoretically early-out on zero terminators...) - if (length > 0 && result == std::string(expected, expected + length - 1) + "?") return false; - - return true; -} - -void xml_writer_string::write(const void* data, size_t size) -{ - contents.append(static_cast(data), size); -} - -std::string xml_writer_string::as_narrow() const -{ - return contents; -} - -std::basic_string xml_writer_string::as_wide() const -{ - CHECK(contents.size() % sizeof(wchar_t) == 0); - - // round-trip pointer through void* to avoid pointer alignment warnings; contents data should be heap allocated => safe to cast - return std::basic_string(static_cast(static_cast(contents.data())), contents.size() / sizeof(wchar_t)); -} - -std::basic_string xml_writer_string::as_string() const -{ -#ifdef PUGIXML_WCHAR_MODE // to avoid "condition is always true" warning in BCC - CHECK(contents.size() % sizeof(pugi::char_t) == 0); -#endif - - // round-trip pointer through void* to avoid pointer alignment warnings; contents data should be heap allocated => safe to cast - return std::basic_string(static_cast(static_cast(contents.data())), contents.size() / sizeof(pugi::char_t)); -} - -std::string save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding) -{ - xml_writer_string writer; - - doc.save(writer, STR("\t"), flags, encoding); - - return writer.as_narrow(); -} - -bool test_save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding, const char* expected, size_t length) -{ - return test_narrow(save_narrow(doc, flags, encoding), expected, length); -} - -std::string write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding) -{ - xml_writer_string writer; - - node.print(writer, STR("\t"), flags, encoding); - - return writer.as_narrow(); -} - -bool test_write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding, const char* expected, size_t length) -{ - return test_narrow(write_narrow(node, flags, encoding), expected, length); -} - -std::basic_string write_wide(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding) -{ - xml_writer_string writer; - - node.print(writer, STR("\t"), flags, encoding); - - return writer.as_wide(); -} diff --git a/external/pugixml/tests/writer_string.hpp b/external/pugixml/tests/writer_string.hpp deleted file mode 100644 index 539377c93..000000000 --- a/external/pugixml/tests/writer_string.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef HEADER_TEST_WRITER_STRING_HPP -#define HEADER_TEST_WRITER_STRING_HPP - -#include "../src/pugixml.hpp" - -#include - -struct xml_writer_string: public pugi::xml_writer -{ - std::string contents; - - virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE; - - std::string as_narrow() const; - std::basic_string as_wide() const; - std::basic_string as_string() const; -}; - -std::string save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding); -bool test_save_narrow(const pugi::xml_document& doc, unsigned int flags, pugi::xml_encoding encoding, const char* expected, size_t length); - -std::string write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding); -bool test_write_narrow(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding, const char* expected, size_t length); - -std::basic_string write_wide(pugi::xml_node node, unsigned int flags, pugi::xml_encoding encoding); - -#endif