Compare commits

..

4 Commits

Author SHA1 Message Date
Arseny Kapoulkine
c237489a6c Fix access modifier offset 2018-10-17 21:14:43 -07:00
Arseny Kapoulkine
3c75d4d612 Fix compilation by setting clang-format standard to C++03 2018-10-17 20:57:34 -07:00
Arseny Kapoulkine
e61dbc5e88 Reformat 2018-10-17 20:53:02 -07:00
Arseny Kapoulkine
7d6901bff2 Add .clang-format and Makefile rule for formatting 2018-10-17 20:52:58 -07:00
78 changed files with 17321 additions and 19393 deletions

12
.clang-format Normal file
View File

@ -0,0 +1,12 @@
Standard: Cpp03
UseTab: ForIndentation
TabWidth: 4
IndentWidth: 4
AccessModifierOffset: -4
BreakBeforeBraces: Allman
IndentCaseLabels: false
ColumnLimit: 0
PointerAlignment: Left
BreakConstructorInitializersBeforeComma: true
NamespaceIndentation: None
AlignEscapedNewlines: DontAlign

View File

@ -1,7 +1,2 @@
comment: false comment: false
coverage:
status:
project:
default:
informational: true
patch: off

View File

@ -1,8 +0,0 @@
---
name: Bug report
about: Create a report if you believe you've found a bug in this project; please use GitHub Discussions instead if you think the bug may be in your code.
title: ''
labels: bug
assignees: ''
---

View File

@ -1,5 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: Help and support
url: https://github.com/zeux/pugixml/discussions
about: Please use GitHub Discussions if you have questions or need help.

View File

@ -1,8 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---

View File

@ -1,52 +0,0 @@
name: build
on:
push:
branches:
- 'master'
pull_request:
jobs:
unix:
strategy:
matrix:
os: [ubuntu, macos]
compiler: [g++, clang++]
defines: [standard, PUGIXML_WCHAR_MODE, PUGIXML_COMPACT, PUGIXML_NO_EXCEPTIONS]
exclude:
- os: macos
compiler: g++
name: ${{matrix.os}} (${{matrix.compiler}}, ${{matrix.defines}})
runs-on: ${{matrix.os}}-latest
steps:
- uses: actions/checkout@v1
- name: make test
run: |
export CXX=${{matrix.compiler}}
make test cxxstd=c++11 defines=${{matrix.defines}} config=release -j2
make test cxxstd=c++98 defines=${{matrix.defines}} config=debug -j2
make test defines=${{matrix.defines}} config=sanitize -j2
- name: make coverage
if: ${{!(matrix.os == 'ubuntu' && matrix.compiler == 'clang++')}} # linux/clang produces coverage info gcov can't parse
run: |
export CXX=${{matrix.compiler}}
make test defines=${{matrix.defines}} config=coverage -j2
bash <(curl -s https://codecov.io/bash) -f pugixml.cpp.gcov -X search -t ${{secrets.CODECOV_TOKEN}} -B ${{github.ref}}
windows:
runs-on: windows-latest
strategy:
matrix:
arch: [Win32, x64]
defines: [standard, PUGIXML_WCHAR_MODE, PUGIXML_COMPACT, PUGIXML_NO_EXCEPTIONS]
steps:
- uses: actions/checkout@v1
- name: cmake configure
run: cmake . -DPUGIXML_BUILD_TESTS=ON -D${{matrix.defines}}=ON -A ${{matrix.arch}}
- name: cmake test
shell: bash # necessary for fail-fast
run: |
cmake --build . -- -property:Configuration=Debug -verbosity:minimal
Debug/pugixml-check.exe
cmake --build . -- -property:Configuration=Release -verbosity:minimal
Release/pugixml-check.exe

View File

@ -1,24 +0,0 @@
name: CIFuzz
on: [pull_request]
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
id: build
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'pugixml'
dry-run: false
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'pugixml'
fuzz-seconds: 30
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@v3
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
path: ./out/artifacts

26
.travis.yml Normal file
View File

@ -0,0 +1,26 @@
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:
- make test cxxstd=c++11 defines=$DEFINES config=coverage -j2
- make test cxxstd=c++11 defines=$DEFINES config=release -j2
- make test cxxstd=c++98 defines=$DEFINES config=debug -j2
after_success:
- sed -e "s/#####\(.*\)\(\/\/ unreachable.*\)/ 1\1\2/" -i pugixml.cpp.gcov
- bash <(curl -s https://codecov.io/bash) -f pugixml.cpp.gcov

View File

@ -1,268 +1,89 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.0)
# Policy configuration; this *MUST* be specified before project is defined project(pugixml VERSION 1.9)
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW) # Enables use of MSVC_RUNTIME_LIBRARY
endif()
project(pugixml VERSION 1.14 LANGUAGES CXX)
include(CMakePackageConfigHelpers)
include(CMakeDependentOption)
include(GNUInstallDirs)
cmake_dependent_option(PUGIXML_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(PUGIXML_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(PUGIXML_STATIC_CRT
"Use static MSVC RT libraries" OFF
"MSVC" OFF)
cmake_dependent_option(PUGIXML_BUILD_TESTS
"Build pugixml tests" OFF
"CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
# Custom build defines
set(PUGIXML_BUILD_DEFINES CACHE STRING "Build defines for custom options")
separate_arguments(PUGIXML_BUILD_DEFINES)
# Technically not needed for this file. This is builtin CMAKE global variable.
option(BUILD_SHARED_LIBS "Build shared instead of static library" OFF) option(BUILD_SHARED_LIBS "Build shared instead of static library" OFF)
option(BUILD_TESTS "Build tests" OFF)
option(USE_VERSIONED_LIBDIR "Use a private subdirectory to install the headers and libs" OFF)
option(USE_POSTFIX "Use separate postfix for each configuration to make sure you can install multiple build outputs" OFF)
# Expose option to build PUGIXML as static as well when the global BUILD_SHARED_LIBS variable is set set(BUILD_DEFINES "" CACHE STRING "Build defines")
cmake_dependent_option(PUGIXML_BUILD_SHARED_AND_STATIC_LIBS
"Build both shared and static libraries" OFF
"BUILD_SHARED_LIBS" OFF)
# Expose options from the pugiconfig.hpp if(MSVC)
option(PUGIXML_WCHAR_MODE "Enable wchar_t mode" OFF) option(STATIC_CRT "Use static CRT libraries" OFF)
option(PUGIXML_COMPACT "Enable compact mode" OFF)
option(PUGIXML_INSTALL "Enable installation rules" ON)
# Advanced options from pugiconfig.hpp # Rewrite command line flags to use /MT if necessary
option(PUGIXML_NO_XPATH "Disable XPath" OFF) if(STATIC_CRT)
option(PUGIXML_NO_STL "Disable STL" OFF) foreach(flag_var
option(PUGIXML_NO_EXCEPTIONS "Disable Exceptions" OFF) CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
mark_as_advanced(PUGIXML_NO_XPATH PUGIXML_NO_STL PUGIXML_NO_EXCEPTIONS) CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
set(PUGIXML_PUBLIC_DEFINITIONS string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
$<$<BOOL:${PUGIXML_WCHAR_MODE}>:PUGIXML_WCHAR_MODE> endif(${flag_var} MATCHES "/MD")
$<$<BOOL:${PUGIXML_COMPACT}>:PUGIXML_COMPACT> endforeach(flag_var)
$<$<BOOL:${PUGIXML_NO_XPATH}>:PUGIXML_NO_XPATH> endif()
$<$<BOOL:${PUGIXML_NO_STL}>:PUGIXML_NO_STL>
$<$<BOOL:${PUGIXML_NO_EXCEPTIONS}>:PUGIXML_NO_EXCEPTIONS>)
# 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$<$<CONFIG:Debug>:Debug>$<$<NOT:$<BOOL:${PUGIXML_STATIC_CRT}>>:DLL>)
endif() endif()
if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) # Pre-defines standard install locations on *nix systems.
set(CMAKE_CXX_STANDARD_REQUIRED ON) include(GNUInstallDirs)
endif() mark_as_advanced(CLEAR CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR)
if (NOT DEFINED CMAKE_CXX_STANDARD) set(HEADERS src/pugixml.hpp src/pugiconfig.hpp)
set(CMAKE_CXX_STANDARD 11) set(SOURCES src/pugixml.cpp)
endif()
if (PUGIXML_USE_POSTFIX) if(DEFINED BUILD_DEFINES)
set(CMAKE_RELWITHDEBINFO_POSTFIX _r) foreach(DEFINE ${BUILD_DEFINES})
set(CMAKE_MINSIZEREL_POSTFIX _m) add_definitions("-D" ${DEFINE})
set(CMAKE_DEBUG_POSTFIX _d) endforeach()
endif()
if (CMAKE_VERSION VERSION_LESS 3.15)
set(msvc-rt $<TARGET_PROPERTY:MSVC_RUNTIME_LIBRARY>)
set(msvc-rt-mtd-shared $<STREQUAL:${msvc-rt},MultiThreadedDebugDLL>)
set(msvc-rt-mtd-static $<STREQUAL:${msvc-rt},MultiThreadedDebug>)
set(msvc-rt-mt-shared $<STREQUAL:${msvc-rt},MultiThreadedDLL>)
set(msvc-rt-mt-static $<STREQUAL:${msvc-rt},MultiThreaded>)
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 $<$<BOOL:${PUGIXML_USE_VERSIONED_LIBDIR}>:/pugixml-${PROJECT_VERSION}>)
set(libs)
if (BUILD_SHARED_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)
string(CONCAT pugixml.msvc $<OR:
$<STREQUAL:${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},MSVC>,
$<CXX_COMPILER_ID:MSVC>
>)
set_property(TARGET pugixml-shared PROPERTY EXPORT_NAME shared)
target_include_directories(pugixml-shared
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
target_compile_definitions(pugixml-shared
PUBLIC
${PUGIXML_BUILD_DEFINES}
${PUGIXML_PUBLIC_DEFINITIONS}
PRIVATE
PUGIXML_API=$<IF:${pugixml.msvc},__declspec\(dllexport\),__attribute__\(\(visibility\("default"\)\)\)>
)
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 PUGIXML_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
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
target_compile_definitions(pugixml-static
PUBLIC
${PUGIXML_BUILD_DEFINES}
${PUGIXML_PUBLIC_DEFINITIONS})
target_compile_options(pugixml-static
PRIVATE
${msvc-rt-mtd-shared}
${msvc-rt-mtd-static}
${msvc-rt-mt-shared}
${msvc-rt-mt-static})
endif() endif()
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
set(pugixml-alias pugixml-shared) add_library(pugixml SHARED ${HEADERS} ${SOURCES})
else() else()
set(pugixml-alias pugixml-static) add_library(pugixml STATIC ${HEADERS} ${SOURCES})
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)
if (PUGIXML_USE_POSTFIX)
if(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
set(LIB_POSTFIX ${CMAKE_RELWITHDEBINFO_POSTFIX})
elseif(CMAKE_BUILD_TYPE MATCHES MinSizeRel)
set(LIB_POSTFIX ${CMAKE_MINSIZEREL_POSTFIX})
elseif(CMAKE_BUILD_TYPE MATCHES Debug)
set(LIB_POSTFIX ${CMAKE_DEBUG_POSTFIX})
endif()
endif() endif()
configure_file(scripts/pugixml.pc.in pugixml.pc @ONLY) # Export symbols for shared library builds
if(BUILD_SHARED_LIBS AND MSVC)
export(TARGETS ${install-targets} target_compile_definitions(pugixml PRIVATE "PUGIXML_API=__declspec(dllexport)")
NAMESPACE pugixml::
FILE pugixml-targets.cmake)
if(PUGIXML_INSTALL)
if (NOT DEFINED PUGIXML_RUNTIME_COMPONENT)
set(PUGIXML_RUNTIME_COMPONENT Runtime)
endif() endif()
if (NOT DEFINED PUGIXML_LIBRARY_COMPONENT) # Enable C++11 long long for compilers that are capable of it
set(PUGIXML_LIBRARY_COMPONENT Library) if(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} STRLESS 3.1 AND ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_long_long_type;")
target_compile_features(pugixml PUBLIC cxx_long_long_type)
endif() endif()
if (NOT DEFINED PUGIXML_DEVELOPMENT_COMPONENT) set_target_properties(pugixml PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
set(PUGIXML_DEVELOPMENT_COMPONENT Development)
if(USE_VERSIONED_LIBDIR)
# Install library into its own directory under LIBDIR
set(INSTALL_SUFFIX /pugixml-${pugixml_VERSION})
endif() endif()
set(namelink-component) target_include_directories(pugixml PUBLIC
if (NOT CMAKE_VERSION VERSION_LESS 3.12) $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>
set(namelink-component NAMELINK_COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT}) $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}${INSTALL_SUFFIX}>)
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 if(USE_POSTFIX AND CMAKE_CONFIGURATION_TYPES)
NAMESPACE pugixml:: set_target_properties(pugixml PROPERTIES DEBUG_POSTFIX "_d" MINSIZEREL_POSTFIX "_m" RELWITHDEBINFO_POSTFIX "_r")
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pugixml COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT})
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})
endif() endif()
if (PUGIXML_BUILD_TESTS) install(TARGETS pugixml EXPORT pugixml-config
include(CTest) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${INSTALL_SUFFIX}
set(fuzz-pattern "tests/fuzz_*.cpp") LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${INSTALL_SUFFIX}
set(test-pattern "tests/*.cpp") RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if (CMAKE_VERSION VERSION_GREATER 3.11) install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}${INSTALL_SUFFIX})
list(INSERT fuzz-pattern 0 CONFIGURE_DEPENDS) install(EXPORT pugixml-config DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pugixml)
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 configure_file(scripts/pugixml.pc.in ${PROJECT_BINARY_DIR}/pugixml.pc @ONLY)
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure) install(FILES ${PROJECT_BINARY_DIR}/pugixml.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig)
add_executable(pugixml-check ${test-sources}) if(BUILD_TESTS)
add_test(NAME pugixml::test file(GLOB TEST_SOURCES tests/*.cpp)
COMMAND pugixml-check file(GLOB FUZZ_SOURCES tests/fuzz_*.cpp)
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) list(REMOVE_ITEM TEST_SOURCES ${FUZZ_SOURCES})
add_dependencies(check pugixml-check)
target_link_libraries(pugixml-check add_executable(check ${TEST_SOURCES})
PRIVATE target_link_libraries(check pugixml)
pugixml::pugixml) add_custom_command(TARGET check POST_BUILD COMMAND check WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif() endif()

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2006-2024 Arseny Kapoulkine Copyright (c) 2006-2018 Arseny Kapoulkine
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation

View File

@ -6,15 +6,15 @@ defines=standard
cxxstd=c++11 cxxstd=c++11
# set cxxstd=any to disable use of -std=... # set cxxstd=any to disable use of -std=...
BUILD=build/make-$(firstword $(CXX))-$(config)-$(defines)-$(cxxstd) BUILD=build/make-$(CXX)-$(config)-$(defines)-$(cxxstd)
SOURCES=src/pugixml.cpp $(filter-out tests/fuzz_%,$(wildcard tests/*.cpp)) SOURCES=src/pugixml.cpp $(filter-out tests/fuzz_%,$(wildcard tests/*.cpp))
EXECUTABLE=$(BUILD)/test EXECUTABLE=$(BUILD)/test
VERSION=$(shell sed -n 's/.*version \(.*\).*/\1/p' src/pugiconfig.hpp) VERSION=$(shell sed -n 's/.*version \(.*\).*/\1/p' src/pugiconfig.hpp)
RELEASE=$(filter-out scripts/archive.py docs/%.adoc,$(shell git ls-files docs scripts src CMakeLists.txt LICENSE.md readme.txt)) RELEASE=$(filter-out scripts/archive.py docs/%.adoc,$(shell git ls-files contrib docs scripts src CMakeLists.txt readme.txt))
CXXFLAGS=-g -Wall -Wextra -Werror -pedantic -Wundef -Wshadow -Wcast-align -Wcast-qual -Wold-style-cast -Wdouble-promotion CXXFLAGS=-g -Wall -Wextra -Werror -pedantic -Wundef -Wshadow -Wcast-align -Wcast-qual -Wold-style-cast
LDFLAGS= LDFLAGS=
ifeq ($(config),release) ifeq ($(config),release)
@ -27,7 +27,7 @@ ifeq ($(config),coverage)
endif endif
ifeq ($(config),sanitize) ifeq ($(config),sanitize)
CXXFLAGS+=-fsanitize=address,undefined -fno-sanitize-recover=all CXXFLAGS+=-fsanitize=address,undefined
LDFLAGS+=-fsanitize=address,undefined LDFLAGS+=-fsanitize=address,undefined
endif endif
@ -58,7 +58,6 @@ test: $(EXECUTABLE)
./$(EXECUTABLE) ./$(EXECUTABLE)
@gcov -b -o $(BUILD)/src/ pugixml.cpp.gcda | sed -e '/./{H;$!d;}' -e 'x;/pugixml.cpp/!d;' @gcov -b -o $(BUILD)/src/ pugixml.cpp.gcda | sed -e '/./{H;$!d;}' -e 'x;/pugixml.cpp/!d;'
@find . -name '*.gcov' -and -not -name 'pugixml.cpp.gcov' -exec rm {} + @find . -name '*.gcov' -and -not -name 'pugixml.cpp.gcov' -exec rm {} +
@sed -i -e "s/#####\(.*\)\(\/\/ unreachable.*\)/ 1\1\2/" pugixml.cpp.gcov
else else
test: $(EXECUTABLE) test: $(EXECUTABLE)
./$(EXECUTABLE) ./$(EXECUTABLE)
@ -66,7 +65,7 @@ endif
fuzz_%: $(BUILD)/fuzz_% fuzz_%: $(BUILD)/fuzz_%
@mkdir -p build/$@ @mkdir -p build/$@
$< build/$@ tests/data_fuzz_$* -max_len=1024 -dict=tests/fuzz_$*.dict -fork=16 $< build/$@ tests/data_fuzz_$* -max_len=1024 -dict=tests/fuzz_$*.dict
clean: clean:
rm -rf $(BUILD) rm -rf $(BUILD)
@ -75,9 +74,12 @@ release: build/pugixml-$(VERSION).tar.gz build/pugixml-$(VERSION).zip
docs: docs/quickstart.html docs/manual.html docs: docs/quickstart.html docs/manual.html
format:
clang-format -i src/*.cpp src/*.hpp tests/*.cpp tests/*.hpp
build/pugixml-%: .FORCE | $(RELEASE) build/pugixml-%: .FORCE | $(RELEASE)
@mkdir -p $(BUILD) @mkdir -p $(BUILD)
TIMESTAMP=`git show v$(VERSION) -s --format=%ct` && python3 scripts/archive.py $@ pugixml-$(VERSION) $$TIMESTAMP $| TIMESTAMP=`git show v$(VERSION) -s --format=%ct` && python scripts/archive.py $@ pugixml-$(VERSION) $$TIMESTAMP $|
$(EXECUTABLE): $(OBJECTS) $(EXECUTABLE): $(OBJECTS)
$(CXX) $(OBJECTS) $(LDFLAGS) -o $@ $(CXX) $(OBJECTS) $(LDFLAGS) -o $@

View File

@ -1,4 +1,4 @@
pugixml [![Actions Status](https://github.com/zeux/pugixml/workflows/build/badge.svg)](https://github.com/zeux/pugixml/actions) [![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 [![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 pugixml is a C++ XML processing library, which consists of a DOM-like interface with rich traversal/modification

View File

@ -1,9 +0,0 @@
# Security Policy
## Supported Versions
Please verify that the vulnerabilities reported can be reproduced on the [latest released version](https://github.com/zeux/pugixml/releases).
## Reporting a Vulnerability
Vulnerabilities can be reported via e-mail to the [project maintainer](https://github.com/zeux).

View File

@ -1,29 +1,15 @@
branches:
only:
- master
image: image:
- Visual Studio 2022
- Visual Studio 2019
- Visual Studio 2017
- Visual Studio 2015 - Visual Studio 2015
- Visual Studio 2017
version: "{branch}-{build}" version: "{branch}-{build}"
build_script: 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 2017") { .\scripts\nuget_build.ps1 }
- 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}
- ps: if ($env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2022") { .\scripts\nuget_build.ps1 2022}
test_script: 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 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 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 2022") { .\tests\autotest-appveyor.ps1 22 }
- 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 -j2 config=coverage test && bash <(curl -s https://codecov.io/bash) -f pugixml.cpp.gcov 2>&1" }
- 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 -j2 config=coverage defines=PUGIXML_WCHAR_MODE test && bash <(curl -s https://codecov.io/bash) -f pugixml.cpp.gcov 2>&1" }
artifacts: artifacts:
- path: .\scripts\*.nupkg - path: .\scripts\*.nupkg

63
contrib/foreach.hpp Normal file
View File

@ -0,0 +1,63 @@
/*
* Boost.Foreach support for pugixml classes.
* This file is provided to the public domain.
* Written by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
*/
#ifndef HEADER_PUGIXML_FOREACH_HPP
#define HEADER_PUGIXML_FOREACH_HPP
#include <boost/range/iterator.hpp>
#include "pugixml.hpp"
/*
* These types add support for BOOST_FOREACH macro to xml_node and xml_document classes (child iteration only).
* Example usage:
* BOOST_FOREACH(xml_node n, doc) {}
*/
namespace boost
{
template<> struct range_mutable_iterator<pugi::xml_node>
{
typedef pugi::xml_node::iterator type;
};
template<> struct range_const_iterator<pugi::xml_node>
{
typedef pugi::xml_node::iterator type;
};
template<> struct range_mutable_iterator<pugi::xml_document>
{
typedef pugi::xml_document::iterator type;
};
template<> struct range_const_iterator<pugi::xml_document>
{
typedef pugi::xml_document::iterator type;
};
}
/*
* These types add support for BOOST_FOREACH macro to xml_node and xml_document classes (child/attribute iteration).
* Example usage:
* BOOST_FOREACH(xml_node n, children(doc)) {}
* BOOST_FOREACH(xml_node n, attributes(doc)) {}
*/
namespace pugi
{
inline xml_object_range<xml_node_iterator> children(const pugi::xml_node& node)
{
return node.children();
}
inline xml_object_range<xml_attribute_iterator> attributes(const pugi::xml_node& node)
{
return node.attributes();
}
}
#endif

View File

@ -1,4 +1,4 @@
website <https://pugixml.org>; repository <https://github.com/zeux/pugixml> website <http://pugixml.org>; repository <http://github.com/zeux/pugixml>
:toc: right :toc: right
:source-highlighter: pygments :source-highlighter: pygments
:source-language: c++ :source-language: c++

View File

@ -8,7 +8,7 @@ include::config.adoc[]
[[overview.introduction]] [[overview.introduction]]
=== 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,XPath 1.0 implementation>> for complex data-driven tree queries. Full Unicode support is also available, with <<dom.unicode,two Unicode interface variants>> and conversions between different Unicode encodings (which happen automatically during parsing/saving). The library is <<install.portability,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 <<overview.license,MIT license>>, making it completely free to use in both open-source and proprietary applications. http://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,XPath 1.0 implementation>> for complex data-driven tree queries. Full Unicode support is also available, with <<dom.unicode,two Unicode interface variants>> and conversions between different Unicode encodings (which happen automatically during parsing/saving). The library is <<install.portability,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 <<overview.license,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. 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.
@ -46,7 +46,7 @@ Thanks to *Vyacheslav Egorov* for documentation proofreading and fuzz testing.
The pugixml library is distributed under the MIT license: The pugixml library is distributed under the MIT license:
.... ....
Copyright (c) 2006-2024 Arseny Kapoulkine Copyright (c) 2006-2018 Arseny Kapoulkine
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation
@ -73,8 +73,8 @@ 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 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). This software is based on pugixml library (http://pugixml.org).
pugixml is Copyright (C) 2006-2024 Arseny Kapoulkine. pugixml is Copyright (C) 2006-2018 Arseny Kapoulkine.
.... ....
[[install]] [[install]]
@ -148,7 +148,7 @@ The complete pugixml source consists of three files - one source file, `pugixml.
[[install.building.embed]] [[install.building.embed]]
==== Building pugixml as a part of another static library/executable ==== 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*. 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: If you're using Microsoft Visual Studio and the project has precompiled headers turned on, you'll see the following error messages:
@ -270,7 +270,7 @@ The XML document is represented with a tree data structure. The root of the tree
[[xml_node_type]] [[xml_node_type]]
The tree nodes can be of one of the following types (which together form the enumeration `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 <<xml_document,xml_document>> class; note that <<xml_document,xml_document>> is a sub-class of <<xml_node,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. 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. * Document node ([[node_document]]`node_document`) - this is the root of the tree, which consists of several child nodes. This node corresponds to <<xml_document,xml_document>> class; note that <<xml_document,xml_document>> is a sub-class of <<xml_node,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]]`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: * 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:
+ +
@ -380,7 +380,7 @@ There is a special value of `xml_node` type, known as null node or empty node (s
Both `xml_node` and `xml_attribute` have the default constructor which initializes them to null objects. Both `xml_node` and `xml_attribute` have the default constructor which initializes them to null objects.
[[xml_attribute::comparison]][[xml_node::comparison]] [[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_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 themselves. 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]] [[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. 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.
@ -749,9 +749,7 @@ These flags control the resulting tree contents:
* [[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. * [[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. 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_merge_pcdata]]`parse_merge_pcdata` determines if PCDATA contents is to be merged with the previous PCDATA node when no intermediary nodes are present between them. If the PCDATA contains CDATA sections, PI nodes, or comments in between, and either of the flags <<parse_cdata,parse_cdata>> ,<<parse_pi,parse_pi>> ,<<parse_comments,parse_comments>> is not set, the contents of the PCDATA node will be merged with the previous one. This flag is *off* by default. Note that this flag is not compatible with `parse_embed_pcdata`. * [[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. 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 (currently multiple top-level element nodes are also permitted when the flag is off, but that behavior should not be relied on). This flag is *off* by default.
CAUTION: Using in-place parsing (<<xml_document::load_buffer_inplace,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)`. CAUTION: Using in-place parsing (<<xml_document::load_buffer_inplace,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)`.
@ -820,7 +818,6 @@ As for rejecting invalid XML documents, there are a number of incompatibilities
* XML data is not required to begin with document declaration; additionally, document declaration can appear after comments and other nodes. * 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. * Invalid document type declarations are silently ignored in some cases.
* Unicode validation is not performed so invalid UTF sequences are not rejected. * Unicode validation is not performed so invalid UTF sequences are not rejected.
* Document can contain multiple top-level element nodes.
[[access]] [[access]]
== Accessing document data == Accessing document data
@ -971,28 +968,6 @@ xml_node xml_node::previous_sibling(const char_t* name) const;
for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool")) for (pugi::xml_node tool = tools.child("Tool"); tool; tool = tool.next_sibling("Tool"))
---- ----
[[xml_node::attribute_hinted]]
`attribute` function needs to look for the target attribute by name. If a node has many attributes, finding each by name can be time consuming. If you have an idea of how attributes are ordered in the node, you can use a faster function:
[source]
----
xml_attribute xml_node::attribute(const char_t* name, xml_attribute& hint) const;
----
The extra `hint` argument is used to guess where the attribute might be, and is updated to the location of the next attribute so that if you search for multiple attributes in the right order, the performance is maximized. Note that `hint` has to be either null or has to belong to the node, otherwise the behavior is undefined.
You can use this function as follows:
[source]
----
xml_attribute hint;
xml_attribute id = node.attribute("id", hint);
xml_attribute name = node.attribute("name", hint);
xml_attribute version = node.attribute("version", hint);
----
This code is correct regardless of the order of the attributes, but it's faster if `"id"`, `"name"` and `"version"` occur in that order.
[[xml_node::find_child_by_attribute]] [[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: `<group><item id="1"/> <item id="2"/></group>`. There are two functions for finding child nodes based on the attribute values: 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:
@ -1277,9 +1252,7 @@ As discussed before, nodes can have name and value, both of which are strings. D
[source] [source]
---- ----
bool xml_node::set_name(const char_t* rhs); bool xml_node::set_name(const char_t* rhs);
bool xml_node::set_name(const char_t* rhs, size_t sz)
bool xml_node::set_value(const char_t* rhs); bool xml_node::set_value(const char_t* rhs);
bool xml_node::set_value(const char_t* rhs, size_t size);
---- ----
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_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. 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_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.
@ -1300,9 +1273,7 @@ All attributes have name and value, both of which are strings (value may be empt
[source] [source]
---- ----
bool xml_attribute::set_name(const char_t* rhs); bool xml_attribute::set_name(const char_t* rhs);
bool xml_attribute::set_name(const char_t* rhs, size_t sz)
bool xml_attribute::set_value(const char_t* rhs); bool xml_attribute::set_value(const char_t* rhs);
bool xml_attribute::set_value(const char_t* rhs, size_t size);
---- ----
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. 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.
@ -1316,9 +1287,7 @@ bool xml_attribute::set_value(unsigned int rhs);
bool xml_attribute::set_value(long rhs); bool xml_attribute::set_value(long rhs);
bool xml_attribute::set_value(unsigned long rhs); bool xml_attribute::set_value(unsigned long rhs);
bool xml_attribute::set_value(double 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);
bool xml_attribute::set_value(float rhs, int precision);
bool xml_attribute::set_value(bool rhs); bool xml_attribute::set_value(bool rhs);
bool xml_attribute::set_value(long long rhs); bool xml_attribute::set_value(long long rhs);
bool xml_attribute::set_value(unsigned long long rhs); bool xml_attribute::set_value(unsigned long long rhs);
@ -1409,18 +1378,16 @@ include::samples/modify_add.cpp[tags=code]
[[modify.remove]] [[modify.remove]]
=== Removing nodes/attributes === Removing nodes/attributes
[[xml_node::remove_attribute]][[xml_node::remove_attributes]][[xml_node::remove_child]][[xml_node::remove_children]] [[xml_node::remove_attribute]][[xml_node::remove_child]]
If you do not want your document to contain some node or attribute, you can remove it with one of the following functions: If you do not want your document to contain some node or attribute, you can remove it with one of the following functions:
[source] [source]
---- ----
bool xml_node::remove_attribute(const xml_attribute& a); 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_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: `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 node the function is called on is null;
* The attribute/node to be removed is null; * The attribute/node to be removed is null;
@ -1456,7 +1423,6 @@ Once you have an `xml_text` object, you can set the text contents using the foll
[source] [source]
---- ----
bool xml_text::set(const char_t* rhs); bool xml_text::set(const char_t* rhs);
bool xml_text::set(const char_t* rhs, size_t size);
---- ----
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_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). 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_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).
@ -1471,9 +1437,7 @@ bool xml_text::set(unsigned int rhs);
bool xml_text::set(long rhs); bool xml_text::set(long rhs);
bool xml_text::set(unsigned long rhs); bool xml_text::set(unsigned long rhs);
bool xml_text::set(double 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);
bool xml_text::set(float rhs, int precision);
bool xml_text::set(bool rhs); bool xml_text::set(bool rhs);
bool xml_text::set(long long rhs); bool xml_text::set(long long rhs);
bool xml_text::set(unsigned long long rhs); bool xml_text::set(unsigned long long rhs);
@ -1633,12 +1597,12 @@ bool xml_document::save_file(const char* path, const char_t* indent = "\t", unsi
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; 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 <<saving.options>>) and output data encoding (see <<saving.encoding>>). 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. The functions return `true` on success and `false` if the file could not be opened or written to. These functions accept file path as its first argument, and also three optional arguments, which specify indentation and other output options (see <<saving.options>>) and output data encoding (see <<saving.encoding>>). 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. 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]] [[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. 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.writer>> for writer interface details. `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.writer>> for writer interface details.
This is a simple example of saving XML document to file (link:samples/save_file.cpp[]): This is a simple example of saving XML document to file (link:samples/save_file.cpp[]):
@ -1740,10 +1704,6 @@ These flags control the resulting tree contents:
* [[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_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: 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_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.
@ -1794,7 +1754,7 @@ include::samples/save_declaration.cpp[tags=code]
[[xpath]] [[xpath]]
== 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 <<xpath.w3c>>. 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 https://www.w3schools.com/xml/xpath_intro.asp[W3Schools XPath tutorial] or https://www.w3.org/TR/xpath-10/[the XPath 1.0 specification]. 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 <<xpath.w3c>>. 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 types === XPath types
@ -2167,110 +2127,6 @@ Because of the differences in document object models, performance considerations
:!numbered: :!numbered:
[[v1.14]]
=== v1.14 ^2023-10-01^
Maintenance release. Changes:
* Improvements:
. `xml_attribute::set_name` and `xml_node::set_name` now have overloads that accept pointer to non-null-terminated string and size
. Implement `parse_merge_pcdata` parsing mode in which PCDATA contents is merged into a single node when original document had comments that were skipped during parsing
. `xml_document::load_file` now returns a more consistent error status when given a path to a folder
* Bug fixes:
. Fix assertion in XPath number->string conversion when using non-English locales
. Fix PUGIXML_STATIC_CRT CMake option to correctly select static CRT when using MSVC and recent CMake
* Compatibility improvements:
. Fix GCC 2.95/3.3 builds
. Fix CMake 3.27 deprecation warnings
. Fix XCode 14 sprintf deprecation warning when compiling in C++03 mode
. Fix clang/gcc warnings `-Wweak-vtables`, `-Wreserved-macro-identifier`
[[v1.13]]
=== v1.13 ^2022-11-01^
Maintenance release. Changes:
* Improvements:
. `xml_attribute::set_value`, `xml_node::set_value` and `xml_text::set` now have overloads that accept pointer to non-null-terminated string and size
. Improve performance of tree traversal when using compact mode (`PUGIXML_COMPACT`)
* Bug fixes:
. Fix error handling in `xml_document::save_file` that could result in the function succeeding while running out of disk space
. Fix memory leak during error handling of some out-of-memory conditions during `xml_document::load`
* Compatibility improvements:
. Fix exported symbols in CMake DLL builds when using CMake
. Fix exported symbols in CMake shared object builds when using -fvisibility=hidden
[[v1.12]]
=== v1.12 ^2022-02-09^
Maintenance release. Changes:
* Bug fixes:
. Fix a bug in xml_document move construction when the source of the move is empty
. Fix const-correctness issues with iterator objects to support C++20 ranges
* XPath improvements:
. Improved detection of overly complex queries that may result in stack overflow during parsing
* Compatibility improvements:
. Fix Cygwin support for DLL builds
. Fix Windows CE support
. Add NuGet builds and project files for VS2022
* Build system changes
. All CMake options now have the prefix `PUGIXML_`. This may require changing dependent build configurations.
. Many build settings are now exposed via CMake settings, most notably `PUGIXML_COMPACT` and `PUGIXML_WCHAR_MODE` can be set without changing `pugiconfig.hpp`
[[v1.11]]
=== v1.11 ^2020-11-26^
Maintenance release. Changes:
* New features:
. Add xml_node::remove_attributes and xml_node::remove_children
. Add a way to customize floating point precision via xml_attribute::set and xml_text::set overloads
* XPath improvements:
. XPath parser now limits recursion depth which prevents stack overflow on malicious queries
* Compatibility improvements:
. Fix Visual Studio warnings when built using clang-cl compiler
. Fix Wconversion warnings in gcc
. Fix Wzero-as-null-pointer-constant warnings in pugixml.hpp
. Work around several static analysis false positives
* Build system changes
. The CMake package for pugixml now provides a `pugixml::pugixml` target rather than a `pugixml` target. A compatibility `pugixml` target is provided if at least version 1.11 is not requested.
[[v1.10]]
=== v1.10 ^2019-09-15^
Maintenance release. Changes:
* Behavior changes:
. Tab characters (ASCII 9) in attribute values are now encoded as '&#9;' 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]]
=== v1.9 ^2018-04-04^ === v1.9 ^2018-04-04^
@ -2795,7 +2651,6 @@ enum +++<a href="#xpath_value_type">xpath_value_type</a>+++
[source,subs="+macros"] [source,subs="+macros"]
---- ----
// Formatting options bit flags: // Formatting options bit flags:
const unsigned int +++<a href="#format_attribute_single_quote">format_attribute_single_quote</a>+++
const unsigned int +++<a href="#format_default">format_default</a>+++ const unsigned int +++<a href="#format_default">format_default</a>+++
const unsigned int +++<a href="#format_indent">format_indent</a>+++ const unsigned int +++<a href="#format_indent">format_indent</a>+++
const unsigned int +++<a href="#format_indent_attributes">format_indent_attributes</a>+++ const unsigned int +++<a href="#format_indent_attributes">format_indent_attributes</a>+++
@ -2804,7 +2659,6 @@ const unsigned int +++<a href="#format_no_empty_element_tags">format_no_empty_el
const unsigned int +++<a href="#format_no_escapes">format_no_escapes</a>+++ const unsigned int +++<a href="#format_no_escapes">format_no_escapes</a>+++
const unsigned int +++<a href="#format_raw">format_raw</a>+++ const unsigned int +++<a href="#format_raw">format_raw</a>+++
const unsigned int +++<a href="#format_save_file_text">format_save_file_text</a>+++ const unsigned int +++<a href="#format_save_file_text">format_save_file_text</a>+++
const unsigned int +++<a href="#format_skip_control_chars">format_skip_control_chars</a>+++
const unsigned int +++<a href="#format_write_bom">format_write_bom</a>+++ const unsigned int +++<a href="#format_write_bom">format_write_bom</a>+++
// Parsing options bit flags: // Parsing options bit flags:
@ -2823,7 +2677,6 @@ const unsigned int +++<a href="#parse_trim_pcdata">parse_trim_pcdata</a>+++
const unsigned int +++<a href="#parse_ws_pcdata">parse_ws_pcdata</a>+++ const unsigned int +++<a href="#parse_ws_pcdata">parse_ws_pcdata</a>+++
const unsigned int +++<a href="#parse_ws_pcdata_single">parse_ws_pcdata_single</a>+++ const unsigned int +++<a href="#parse_ws_pcdata_single">parse_ws_pcdata_single</a>+++
const unsigned int +++<a href="#parse_embed_pcdata">parse_embed_pcdata</a>+++ const unsigned int +++<a href="#parse_embed_pcdata">parse_embed_pcdata</a>+++
const unsigned int +++<a href="#parse_merge_pcdata">parse_merge_pcdata</a>+++
const unsigned int +++<a href="#parse_wconv_attribute">parse_wconv_attribute</a>+++ const unsigned int +++<a href="#parse_wconv_attribute">parse_wconv_attribute</a>+++
const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>+++ const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>+++
---- ----
@ -2864,9 +2717,7 @@ const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>
unsigned long long +++<a href="#xml_attribute::as_ullong">as_ullong</a>+++(unsigned long long def = 0) const; unsigned long long +++<a href="#xml_attribute::as_ullong">as_ullong</a>+++(unsigned long long def = 0) const;
bool +++<a href="#xml_attribute::set_name">set_name</a>+++(const char_t* rhs); bool +++<a href="#xml_attribute::set_name">set_name</a>+++(const char_t* rhs);
bool +++<a href="#xml_attribute::set_name">set_name</a>+++(const char_t* rhs, size_t size);
bool +++<a href="#xml_attribute::set_value">set_value</a>+++(const char_t* rhs); bool +++<a href="#xml_attribute::set_value">set_value</a>+++(const char_t* rhs);
bool +++<a href="#xml_attribute::set_value">set_value</a>+++(const char_t* rhs, size_t size);
bool +++<a href="#xml_attribute::set_value">set_value</a>+++(int rhs); bool +++<a href="#xml_attribute::set_value">set_value</a>+++(int rhs);
bool +++<a href="#xml_attribute::set_value">set_value</a>+++(unsigned int rhs); bool +++<a href="#xml_attribute::set_value">set_value</a>+++(unsigned int rhs);
bool +++<a href="#xml_attribute::set_value">set_value</a>+++(long rhs); bool +++<a href="#xml_attribute::set_value">set_value</a>+++(long rhs);
@ -2925,9 +2776,6 @@ const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>
xml_attribute +++<a href="#xml_node::attribute">attribute</a>+++(const char_t* name) const; xml_attribute +++<a href="#xml_node::attribute">attribute</a>+++(const char_t* name) const;
xml_node +++<a href="#xml_node::next_sibling_name">next_sibling</a>+++(const char_t* name) const; xml_node +++<a href="#xml_node::next_sibling_name">next_sibling</a>+++(const char_t* name) const;
xml_node +++<a href="#xml_node::previous_sibling_name">previous_sibling</a>+++(const char_t* name) const; xml_node +++<a href="#xml_node::previous_sibling_name">previous_sibling</a>+++(const char_t* name) const;
xml_attribute +++<a href="#xml_node::attribute_hinted">attribute</a>+++(const char_t* name, xml_attribute& hint) const;
xml_node +++<a href="#xml_node::find_child_by_attribute">find_child_by_attribute</a>+++(const char_t* name, const char_t* attr_name, const char_t* attr_value) const; xml_node +++<a href="#xml_node::find_child_by_attribute">find_child_by_attribute</a>+++(const char_t* name, const char_t* attr_name, const char_t* attr_value) const;
xml_node +++<a href="#xml_node::find_child_by_attribute">find_child_by_attribute</a>+++(const char_t* attr_name, const char_t* attr_value) const; xml_node +++<a href="#xml_node::find_child_by_attribute">find_child_by_attribute</a>+++(const char_t* attr_name, const char_t* attr_value) const;
@ -2955,9 +2803,7 @@ const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>
ptrdiff_t +++<a href="#xml_node::offset_debug">offset_debug</a>+++() const; ptrdiff_t +++<a href="#xml_node::offset_debug">offset_debug</a>+++() const;
bool +++<a href="#xml_node::set_name">set_name</a>+++(const char_t* rhs); bool +++<a href="#xml_node::set_name">set_name</a>+++(const char_t* rhs);
bool +++<a href="#xml_node::set_name">set_name</a>+++(const char_t* rhs, size_t size);
bool +++<a href="#xml_node::set_value">set_value</a>+++(const char_t* rhs); bool +++<a href="#xml_node::set_value">set_value</a>+++(const char_t* rhs);
bool +++<a href="#xml_node::set_value">set_value</a>+++(const char_t* rhs, size_t size);
xml_attribute +++<a href="#xml_node::append_attribute">append_attribute</a>+++(const char_t* name); xml_attribute +++<a href="#xml_node::append_attribute">append_attribute</a>+++(const char_t* name);
xml_attribute +++<a href="#xml_node::prepend_attribute">prepend_attribute</a>+++(const char_t* name); xml_attribute +++<a href="#xml_node::prepend_attribute">prepend_attribute</a>+++(const char_t* name);
@ -2991,10 +2837,8 @@ const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>
bool +++<a href="#xml_node::remove_attribute">remove_attribute</a>+++(const xml_attribute& a); bool +++<a href="#xml_node::remove_attribute">remove_attribute</a>+++(const xml_attribute& a);
bool +++<a href="#xml_node::remove_attribute">remove_attribute</a>+++(const char_t* name); bool +++<a href="#xml_node::remove_attribute">remove_attribute</a>+++(const char_t* name);
bool +++<a href="#xml_node::remove_attributes">remove_attributes</a>+++();
bool +++<a href="#xml_node::remove_child">remove_child</a>+++(const xml_node& n); bool +++<a href="#xml_node::remove_child">remove_child</a>+++(const xml_node& n);
bool +++<a href="#xml_node::remove_child">remove_child</a>+++(const char_t* name); bool +++<a href="#xml_node::remove_child">remove_child</a>+++(const char_t* name);
bool +++<a href="#xml_node::remove_children">remove_children</a>+++();
xml_parse_result +++<a href="#xml_node::append_buffer">append_buffer</a>+++(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); xml_parse_result +++<a href="#xml_node::append_buffer">append_buffer</a>+++(const void* contents, size_t size, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
@ -3070,17 +2914,16 @@ const unsigned int +++<a href="#parse_wnorm_attribute">parse_wnorm_attribute</a>
unsigned long long +++<a href="#xml_text::as_ullong">as_ullong</a>+++(unsigned long long def = 0) const; unsigned long long +++<a href="#xml_text::as_ullong">as_ullong</a>+++(unsigned long long def = 0) const;
bool +++<a href="#xml_text::set">set</a>+++(const char_t* rhs); bool +++<a href="#xml_text::set">set</a>+++(const char_t* rhs);
bool +++<a href="#xml_text::set">set</a>+++(const char_t* rhs, size_t size);
bool +++<a href="#xml_text::set_value">set</a>+++(int rhs); bool +++<a href="#xml_text::set">set</a>+++(int rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(unsigned int rhs); bool +++<a href="#xml_text::set">set</a>+++(unsigned int rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(long rhs); bool +++<a href="#xml_text::set">set</a>+++(long rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(unsigned long rhs); bool +++<a href="#xml_text::set">set</a>+++(unsigned long rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(double rhs); bool +++<a href="#xml_text::set">set</a>+++(double rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(float rhs); bool +++<a href="#xml_text::set">set</a>+++(float rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(bool rhs); bool +++<a href="#xml_text::set">set</a>+++(bool rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(long long rhs); bool +++<a href="#xml_text::set">set</a>+++(long long rhs);
bool +++<a href="#xml_text::set_value">set</a>+++(unsigned long long rhs); bool +++<a href="#xml_text::set">set</a>+++(unsigned long long rhs);
xml_text& +++<a href="#xml_text::assign">operator=</a>+++(const char_t* rhs); xml_text& +++<a href="#xml_text::assign">operator=</a>+++(const char_t* rhs);
xml_text& +++<a href="#xml_text::assign">operator=</a>+++(int rhs); xml_text& +++<a href="#xml_text::assign">operator=</a>+++(int rhs);

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@ include::config.adoc[]
[[introduction]] [[introduction]]
== 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 <<license,MIT license>>, making it completely free to use in both open-source and proprietary applications. http://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 <<license,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. 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.
@ -25,7 +25,7 @@ The distribution contains library source, documentation (the guide you're readin
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 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 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. 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]] [[dom]]
== Document object model == Document object model
@ -255,7 +255,7 @@ If filing an issue is not possible due to privacy or other concerns, you can con
The pugixml library is distributed under the MIT license: The pugixml library is distributed under the MIT license:
.... ....
Copyright (c) 2006-2024 Arseny Kapoulkine Copyright (c) 2006-2018 Arseny Kapoulkine
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation
@ -282,6 +282,6 @@ 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 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). This software is based on pugixml library (http://pugixml.org).
pugixml is Copyright (C) 2006-2024 Arseny Kapoulkine. pugixml is Copyright (C) 2006-2018 Arseny Kapoulkine.
.... ....

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
pugixml 1.14 - an XML processing library pugixml 1.9 - an XML processing library
Copyright (C) 2006-2024, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
Report bugs and download new versions at https://pugixml.org/ Report bugs and download new versions at http://pugixml.org/
This is the distribution of pugixml, which is a C++ XML processing library, This is the distribution of pugixml, which is a C++ XML processing library,
which consists of a DOM-like interface with rich traversal/modification which consists of a DOM-like interface with rich traversal/modification
@ -13,6 +13,8 @@ automatically during parsing/saving).
The distribution contains the following folders: The distribution contains the following folders:
contrib/ - various contributions to pugixml
docs/ - documentation docs/ - documentation
docs/samples - pugixml usage examples docs/samples - pugixml usage examples
docs/quickstart.html - quick start guide docs/quickstart.html - quick start guide
@ -26,7 +28,7 @@ The distribution contains the following folders:
This library is distributed under the MIT License: This library is distributed under the MIT License:
Copyright (c) 2006-2024 Arseny Kapoulkine Copyright (c) 2006-2018 Arseny Kapoulkine
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation

View File

@ -1,18 +1,18 @@
import io
import os.path import os.path
import sys import sys
import tarfile import tarfile
import time import time
import zipfile import zipfile
import StringIO
def read_file(path, use_crlf): def read_file(path, use_crlf):
with open(path, 'rb') as file: with open(path, 'rb') as file:
data = file.read() data = file.read()
if b'\0' not in data: if '\0' not in data:
data = data.replace(b'\r', b'') data = data.replace('\r', '')
if use_crlf: if use_crlf:
data = data.replace(b'\n', b'\r\n') data = data.replace('\n', '\r\n')
return data return data
@ -24,7 +24,7 @@ def write_zip(target, arcprefix, timestamp, sources):
info = zipfile.ZipInfo(path) info = zipfile.ZipInfo(path)
info.date_time = time.localtime(timestamp) info.date_time = time.localtime(timestamp)
info.compress_type = zipfile.ZIP_DEFLATED info.compress_type = zipfile.ZIP_DEFLATED
info.external_attr = 0o644 << 16 info.external_attr = 0644 << 16L
archive.writestr(info, data) archive.writestr(info, data)
def write_tar(target, arcprefix, timestamp, sources, compression): def write_tar(target, arcprefix, timestamp, sources, compression):
@ -35,7 +35,7 @@ def write_tar(target, arcprefix, timestamp, sources, compression):
info = tarfile.TarInfo(path) info = tarfile.TarInfo(path)
info.size = len(data) info.size = len(data)
info.mtime = timestamp info.mtime = timestamp
archive.addfile(info, io.BytesIO(data)) archive.addfile(info, StringIO.StringIO(data))
if len(sys.argv) < 5: if len(sys.argv) < 5:
raise RuntimeError('Usage: python archive.py <target> <archive prefix> <timestamp> <source files>') raise RuntimeError('Usage: python archive.py <target> <archive prefix> <timestamp> <source files>')

View File

@ -1,506 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="pugi::xml_node">
<DisplayString Condition="_root">{_root}</DisplayString>
<DisplayString Condition="!_root">none</DisplayString>
<Expand>
<ExpandedItem Condition="_root">_root</ExpandedItem>
</Expand>
</Type>
<Type Name="pugi::xml_attribute">
<DisplayString Condition="_attr">{_attr}</DisplayString>
<DisplayString Condition="!_attr">none</DisplayString>
<Expand>
<ExpandedItem Condition="_attr">_attr</ExpandedItem>
</Expand>
</Type>
<Type Name="pugi::xml_node_struct">
<Expand>
<Item Name="type">(pugi::xml_node_type)(header._flags &amp; 15)</Item>
<Item Name="name" Condition="name._data">name,na</Item>
<Item Name="value" Condition="value._data">value,na</Item>
<Synthetic Name="attributes" Condition="first_attribute._data">
<DisplayString>...</DisplayString>
<Expand>
<CustomListItems>
<Variable Name="attribute_this" InitialValue="(size_t)&amp;first_attribute" />
<Variable Name="attribute_data" InitialValue="first_attribute._data" />
<Variable Name="attribute_data_copy" InitialValue="attribute_data" />
<!-- first_attribute struct template arguments -->
<Variable Name="attribute_T1" InitialValue="11" />
<Variable Name="attribute_T2" InitialValue="0" />
<Variable Name="compact_alignment_log2" InitialValue="2" />
<Variable Name="compact_alignment" InitialValue="1 &lt;&lt; compact_alignment_log2" />
<!-- compact_get_page() -->
<Variable Name="_page" InitialValue="*(char*)(attribute_this - attribute_T1)" />
<Variable Name="page" InitialValue="((attribute_this - attribute_T1 - (_page &lt;&lt; compact_alignment_log2)) - *(unsigned*)(attribute_this - attribute_T1 - (_page &lt;&lt; compact_alignment_log2)))" />
<!-- page->allocator->_hash -->
<Variable Name="allocator" InitialValue="*(size_t*)page" />
<Variable Name="_hash" InitialValue="*(size_t*)(allocator + 2 * sizeof(size_t))" /><!--2 pointer offsetof(allocator, _hash)-->
<Variable Name="_items" InitialValue="*(size_t*)_hash" />
<Variable Name="_capacity" InitialValue="*((size_t*)_hash + 1)" /><!--1 pointer offsetof(_hash, _capacity)-->
<Variable Name="_count" InitialValue="*((size_t*)_hash + 2)" /><!--2 pointer offsetof(_hash, _count)-->
<!-- find() prolog -->
<Variable Name="hashmod" InitialValue="_capacity - 1" />
<Variable Name="h" InitialValue="(unsigned)attribute_this" />
<Variable Name="bucket" InitialValue="0" />
<Variable Name="probe" InitialValue="0" />
<Variable Name="probe_item" InitialValue="(size_t*)0" />
<Variable Name="attribute_real" InitialValue="(pugi::xml_attribute_struct*)0" />
<!-- if _data < 255 -->
<Variable Name="attribute_short" InitialValue="(pugi::xml_attribute_struct*)(((size_t)attribute_this &amp; ~(compact_alignment - 1)) + (attribute_data - 1 + attribute_T2) * compact_alignment)" />
<Variable Name="number" InitialValue="0" />
<!-- Loop over all attributes -->
<Loop Condition="attribute_this &amp;&amp; attribute_data">
<!-- find() hash -->
<Exec>h = h ^ (h >> 16)</Exec>
<Exec>h = h * (0x85ebca6bu)</Exec>
<Exec>h = h ^ (h >> 13)</Exec>
<Exec>h = h * (0xc2b2ae35u)</Exec>
<Exec>h = h ^ (h >> 16)</Exec>
<Exec>bucket = h &amp; hashmod</Exec>
<!-- find() loop -->
<Loop Condition="probe &lt;= hashmod &amp;&amp;_capacity">
<Exec>probe_item = (size_t*)_items + bucket * 2</Exec><!--2 pointer sizeof(item_t)-->
<If Condition="*probe_item == attribute_this || *probe_item == 0">
<Exec>attribute_real = *(pugi::xml_attribute_struct**)(probe_item + 1)</Exec><!--1 pointer offsetof(item_t, value)-->
<Break/>
</If>
<Exec>bucket = (bucket + probe + 1) &amp; hashmod</Exec>
<Exec>probe++</Exec>
</Loop>
<Exec>attribute_data_copy = attribute_data</Exec>
<If Condition="attribute_data_copy &gt;= 255 &amp;&amp; attribute_real">
<Item Name="[{number}]">*attribute_real,view(child)</Item>
<Exec>attribute_this = (size_t)&amp;(*attribute_real).next_attribute</Exec>
<Exec>attribute_data = (*attribute_real).next_attribute._data</Exec>
</If>
<If Condition="attribute_data_copy &lt; 255 &amp;&amp; attribute_short">
<Item Name="[{number}]">*attribute_short,view(child)</Item>
<Exec>attribute_this = (size_t)&amp;(*attribute_short).next_attribute</Exec>
<Exec>attribute_data = (*attribute_short).next_attribute._data</Exec>
</If>
<!-- next_attribute struct template arguments -->
<Exec>attribute_T1 = 7</Exec>
<Exec>attribute_T2 = 0</Exec>
<!-- find() prolog again -->
<Exec>h = (unsigned)attribute_this</Exec>
<Exec>bucket = 0</Exec>
<Exec>probe = 0</Exec>
<Exec>probe_item = (size_t*)0</Exec>
<Exec>attribute_real = (pugi::xml_attribute_struct*)0</Exec>
<Exec>attribute_short = (pugi::xml_attribute_struct*)(((size_t)attribute_this &amp; ~(compact_alignment - 1)) + (attribute_data - 1 + attribute_T2) * compact_alignment)</Exec>
<Exec>number++</Exec>
</Loop>
</CustomListItems>
</Expand>
</Synthetic>
<CustomListItems>
<Variable Name="child_this" InitialValue="&amp;first_child" />
<Variable Name="child_data" InitialValue="first_child._data" />
<Variable Name="child_data_copy" InitialValue="child_data" />
<!-- first_child struct template arguments -->
<Variable Name="child_T1" InitialValue="8" />
<Variable Name="child_T2" InitialValue="0" />
<Variable Name="compact_alignment_log2" InitialValue="2" />
<Variable Name="compact_alignment" InitialValue="1 &lt;&lt; compact_alignment_log2" />
<!-- compact_get_page() -->
<Variable Name="_page" InitialValue="*(char*)(child_this - child_T1)" />
<Variable Name="page" InitialValue="((child_this - child_T1 - (_page &lt;&lt; compact_alignment_log2)) - *(unsigned*)(child_this - child_T1 - (_page &lt;&lt; compact_alignment_log2)))" />
<!-- page->allocator->_hash -->
<Variable Name="allocator" InitialValue="*(size_t*)page" />
<Variable Name="_hash" InitialValue="*(size_t*)(allocator + 2 * sizeof(size_t))" /><!--2 pointer offsetof(allocator, _hash)-->
<Variable Name="_items" InitialValue="*(size_t*)_hash" />
<Variable Name="_capacity" InitialValue="*((size_t*)_hash + 1)" /><!--1 pointer offsetof(_hash, _capacity)-->
<Variable Name="_count" InitialValue="*((size_t*)_hash + 2)" /><!--2 pointer offsetof(_hash, _count)-->
<!-- find() prolog -->
<Variable Name="hashmod" InitialValue="_capacity - 1" />
<Variable Name="h" InitialValue="(unsigned)child_this" />
<Variable Name="bucket" InitialValue="0" />
<Variable Name="probe" InitialValue="0" />
<Variable Name="probe_item" InitialValue="(size_t*)0" />
<Variable Name="child_real" InitialValue="(pugi::xml_node_struct*)0" />
<!-- if _data < 255 -->
<Variable Name="child_short" InitialValue="(pugi::xml_node_struct*)(((size_t)child_this &amp; ~(compact_alignment - 1)) + (child_data - 1 + child_T2) * compact_alignment)" />
<Variable Name="number" InitialValue="0" />
<Loop Condition="child_this &amp;&amp; child_data">
<!-- find() hash -->
<Exec>h = h ^ (h >> 16)</Exec>
<Exec>h = h * (0x85ebca6bu)</Exec>
<Exec>h = h ^ (h >> 13)</Exec>
<Exec>h = h * (0xc2b2ae35u)</Exec>
<Exec>h = h ^ (h >> 16)</Exec>
<Exec>bucket = h &amp; hashmod</Exec>
<!-- find() loop -->
<Loop Condition="probe &lt;= hashmod &amp;&amp;_capacity">
<Exec>probe_item = (size_t*)_items + bucket * 2</Exec><!--2 pointer sizeof(item_t)-->
<If Condition="*probe_item == child_this || *probe_item == 0">
<Exec>child_real = *(pugi::xml_node_struct**)(probe_item + 1)</Exec><!--1 pointer offsetof(item_t, value)-->
<Break/>
</If>
<Exec>bucket = (bucket + probe + 1) &amp; hashmod</Exec>
<Exec>probe++</Exec>
</Loop>
<Exec>child_data_copy = child_data</Exec>
<If Condition="child_data_copy &gt;= 255 &amp;&amp; child_real">
<Item Name="[{number}]">*child_real,view(child)</Item>
<Exec>child_this = (size_t)&amp;(*child_real).next_sibling</Exec>
<Exec>child_data = (*child_real).next_sibling._data</Exec>
</If>
<If Condition="child_data_copy &lt; 255 &amp;&amp; child_short">
<Item Name="[{number}]">*child_short,view(child)</Item>
<Exec>child_this = (size_t)&amp;(*child_short).next_sibling</Exec>
<Exec>child_data = (*child_short).next_sibling._data</Exec>
</If>
<!-- next_sibling struct template arguments -->
<Exec>child_T1 = 10</Exec>
<Exec>child_T2 = 0</Exec>
<!-- find() prolog again -->
<Exec>h = (unsigned)child_this</Exec>
<Exec>bucket = 0</Exec>
<Exec>probe = 0</Exec>
<Exec>probe_item = (size_t*)0</Exec>
<Exec>child_real = (pugi::xml_node_struct*)0</Exec>
<Exec>child_short = (pugi::xml_node_struct*)(((size_t)child_this &amp; ~(compact_alignment - 1)) + (child_data - 1 + child_T2) * compact_alignment)</Exec>
<Exec>number++</Exec>
</Loop>
</CustomListItems>
<Item Name="next_sibling" ExcludeView="child">next_sibling</Item>
</Expand>
</Type>
<Type Name="pugi::xml_attribute_struct">
<Expand>
<Item Name="name">name,na</Item>
<Item Name="value">value,na</Item>
<CustomListItems ExcludeView="child">
<Variable Name="attribute_this" InitialValue="&amp;next_attribute" />
<Variable Name="attribute_data" InitialValue="next_attribute._data" />
<!-- next_attribute struct template arguments -->
<Variable Name="attribute_T1" InitialValue="7" />
<Variable Name="attribute_T2" InitialValue="0" />
<Variable Name="compact_alignment_log2" InitialValue="2" />
<Variable Name="compact_alignment" InitialValue="1 &lt;&lt; compact_alignment_log2" />
<!-- compact_get_page() -->
<Variable Name="_page" InitialValue="*(char*)(attribute_this - attribute_T1)" />
<Variable Name="page" InitialValue="((attribute_this - attribute_T1 - (_page &lt;&lt; compact_alignment_log2)) - *(unsigned*)(attribute_this - attribute_T1 - (_page &lt;&lt; compact_alignment_log2)))" />
<!-- page->allocator->_hash -->
<Variable Name="allocator" InitialValue="*(size_t*)page" />
<Variable Name="_hash" InitialValue="*(size_t*)(allocator + 2 * sizeof(size_t))" /><!--2 pointer offsetof(allocator, _hash)-->
<Variable Name="_items" InitialValue="*(size_t*)_hash" />
<Variable Name="_capacity" InitialValue="*((size_t*)_hash + 1)" /><!--1 pointer offsetof(_hash, _capacity)-->
<Variable Name="_count" InitialValue="*((size_t*)_hash + 2)" /><!--2 pointer offsetof(_hash, _count)-->
<!-- find() prolog -->
<Variable Name="hashmod" InitialValue="_capacity - 1" />
<Variable Name="h" InitialValue="(unsigned)attribute_this" />
<Variable Name="bucket" InitialValue="0" />
<Variable Name="probe" InitialValue="0" />
<Variable Name="probe_item" InitialValue="(size_t*)0" />
<Variable Name="attribute_real" InitialValue="(pugi::xml_attribute_struct*)0" />
<!-- if _data < 255 -->
<Variable Name="attribute_short" InitialValue="(pugi::xml_attribute_struct*)(((size_t)attribute_this &amp; ~(compact_alignment - 1)) + (attribute_data - 1 + attribute_T2) * compact_alignment)" />
<!-- find() hash -->
<Exec>h = h ^ (h >> 16)</Exec>
<Exec>h = h * (0x85ebca6bu)</Exec>
<Exec>h = h ^ (h >> 13)</Exec>
<Exec>h = h * (0xc2b2ae35u)</Exec>
<Exec>h = h ^ (h >> 16)</Exec>
<Exec>bucket = h &amp; hashmod</Exec>
<!-- find() loop -->
<Loop Condition="probe &lt;= hashmod &amp;&amp;_capacity">
<Exec>probe_item = (size_t*)_items + bucket * 2</Exec><!--2 pointer sizeof(item_t)-->
<If Condition="*probe_item == attribute_this || *probe_item == 0">
<Exec>attribute_real = *(pugi::xml_attribute_struct**)(probe_item + 1)</Exec><!--1 pointer offsetof(item_t, value)-->
<Break/>
</If>
<Exec>bucket = (bucket + probe + 1) &amp; hashmod</Exec>
<Exec>probe++</Exec>
</Loop>
<If Condition="attribute_data &gt;= 255 &amp;&amp; attribute_real">
<Item Name="next_attribute">*attribute_real</Item>
</If>
<If Condition="attribute_data != 0 &amp;&amp; attribute_data &lt; 255 &amp;&amp; attribute_short">
<Item Name="next_attribute">*attribute_short</Item>
</If>
</CustomListItems>
</Expand>
</Type>
<Type Name="pugi::impl::`anonymous-namespace'::compact_string&lt;*,*&gt;">
<Expand HideRawView="1">
<CustomListItems Condition="_data &amp;&amp; _data &lt; 255">
<Variable Name="compact_alignment_log2" InitialValue="2" />
<Variable Name="compact_alignment" InitialValue="1 &lt;&lt; compact_alignment_log2" />
<!-- compact_get_page() -->
<Variable Name="_page" InitialValue="*(char*)(this - $T1)" />
<Variable Name="page" InitialValue="((this - $T1 - (_page &lt;&lt; compact_alignment_log2)) - *(unsigned*)(this - $T1 - (_page &lt;&lt; compact_alignment_log2)))" />
<Variable Name="compact_string_base" InitialValue="*(size_t*)(page + 5 * sizeof(void*))" /><!-- 5 pointer offsetof(page, compact_string_base)-->
<Variable Name="base" InitialValue="this - $T2" />
<Variable Name="offset" InitialValue="((*(short*)base - 1) &lt;&lt; 7) + (_data - 1)" />
<Item Name="value">(pugi::char_t*)(compact_string_base + offset * sizeof(pugi::char_t)),na</Item>
</CustomListItems>
<CustomListItems Condition="_data &amp;&amp; _data &gt;= 255">
<Variable Name="compact_alignment_log2" InitialValue="2" />
<Variable Name="compact_alignment" InitialValue="1 &lt;&lt; compact_alignment_log2" />
<!-- compact_get_page() -->
<Variable Name="_page" InitialValue="*(char*)(this - $T1)" />
<Variable Name="page" InitialValue="((this - $T1 - (_page &lt;&lt; compact_alignment_log2)) - *(unsigned*)(this - $T1 - (_page &lt;&lt; compact_alignment_log2)))" />
<!-- page->allocator->_hash -->
<Variable Name="allocator" InitialValue="*(size_t*)page" />
<Variable Name="_hash" InitialValue="*(size_t*)(allocator + 2 * sizeof(size_t))" /><!--2 pointer offsetof(allocator, _hash)-->
<Variable Name="_items" InitialValue="*(size_t*)_hash" />
<Variable Name="_capacity" InitialValue="*((size_t*)_hash + 1)" /><!--1 pointer offsetof(_hash, _capacity)-->
<Variable Name="_count" InitialValue="*((size_t*)_hash + 2)" /><!--2 pointer offsetof(_hash, _count)-->
<!-- find() prolog -->
<Variable Name="hashmod" InitialValue="_capacity - 1" />
<Variable Name="h" InitialValue="(unsigned)this" />
<Variable Name="bucket" InitialValue="0" />
<Variable Name="probe" InitialValue="0" />
<Variable Name="probe_item" InitialValue="(size_t*)0" />
<!-- find() hash -->
<Exec>h = h ^ (h >> 16)</Exec>
<Exec>h = h * (0x85ebca6bu)</Exec>
<Exec>h = h ^ (h >> 13)</Exec>
<Exec>h = h * (0xc2b2ae35u)</Exec>
<Exec>h = h ^ (h >> 16)</Exec>
<Exec>bucket = h &amp; hashmod</Exec>
<!-- find() loop -->
<Loop Condition="probe &lt;= hashmod &amp;&amp;_capacity">
<Exec>probe_item = (size_t*)_items + bucket * 2</Exec><!--2 pointer sizeof(item_t)-->
<If Condition="*probe_item == this || *probe_item == 0">
<Item Name="value">*(pugi::char_t**)(probe_item + 1)</Item><!--1 pointer offsetof(item_t, value)-->
<Break/>
</If>
<Exec>bucket = (bucket + probe + 1) &amp; hashmod</Exec>
<Exec>probe++</Exec>
</Loop>
</CustomListItems>
</Expand>
</Type>
<Type Name="pugi::impl::`anonymous-namespace'::compact_pointer&lt;pugi::xml_node_struct,*,*&gt;">
<DisplayString Condition="!_data">nullptr</DisplayString>
<DisplayString Condition="_data">...</DisplayString>
<Expand HideRawView="1">
<CustomListItems Condition="_data &amp;&amp; _data &lt; 255">
<Variable Name="compact_alignment_log2" InitialValue="2" />
<Variable Name="compact_alignment" InitialValue="1 &lt;&lt; compact_alignment_log2" />
<Item Name="value">*(pugi::xml_node_struct*)(((size_t)this &amp; ~(compact_alignment - 1)) + (_data - 1 + $T2) * compact_alignment)</Item>
</CustomListItems>
<CustomListItems Condition="_data &amp;&amp; _data &gt;= 255">
<Variable Name="compact_alignment_log2" InitialValue="2" />
<Variable Name="compact_alignment" InitialValue="1 &lt;&lt; compact_alignment_log2" />
<!-- compact_get_page() -->
<Variable Name="_page" InitialValue="*(char*)(this - $T1)" />
<Variable Name="page" InitialValue="((this - $T1 - (_page &lt;&lt; compact_alignment_log2)) - *(unsigned*)(this - $T1 - (_page &lt;&lt; compact_alignment_log2)))" />
<!-- page->allocator->_hash -->
<Variable Name="allocator" InitialValue="*(size_t*)page" />
<Variable Name="_hash" InitialValue="*(size_t*)(allocator + 2 * sizeof(size_t))" /><!--2 pointer offsetof(allocator, _hash)-->
<Variable Name="_items" InitialValue="*(size_t*)_hash" />
<Variable Name="_capacity" InitialValue="*((size_t*)_hash + 1)" /><!--1 pointer offsetof(_hash, _capacity)-->
<Variable Name="_count" InitialValue="*((size_t*)_hash + 2)" /><!--2 pointer offsetof(_hash, _count)-->
<!-- find() prolog -->
<Variable Name="hashmod" InitialValue="_capacity - 1" />
<Variable Name="h" InitialValue="(unsigned)this" />
<Variable Name="bucket" InitialValue="0" />
<Variable Name="probe" InitialValue="0" />
<Variable Name="probe_item" InitialValue="(size_t*)0" />
<!-- find() hash -->
<Exec>h = h ^ (h >> 16)</Exec>
<Exec>h = h * (0x85ebca6bu)</Exec>
<Exec>h = h ^ (h >> 13)</Exec>
<Exec>h = h * (0xc2b2ae35u)</Exec>
<Exec>h = h ^ (h >> 16)</Exec>
<Exec>bucket = h &amp; hashmod</Exec>
<!-- find() loop -->
<Loop Condition="probe &lt;= hashmod &amp;&amp;_capacity">
<Exec>probe_item = (size_t*)_items + bucket * 2</Exec><!--2 pointer sizeof(item_t)-->
<If Condition="*probe_item == this || *probe_item == 0">
<Item Name="value">**(pugi::xml_node_struct**)(probe_item + 1)</Item><!--1 pointer offsetof(item_t, value)-->
<Break/>
</If>
<Exec>bucket = (bucket + probe + 1) &amp; hashmod</Exec>
<Exec>probe++</Exec>
</Loop>
</CustomListItems>
</Expand>
</Type>
<Type Name="pugi::impl::`anonymous-namespace'::compact_pointer&lt;pugi::xml_attribute_struct,*,*&gt;">
<DisplayString Condition="!_data">nullptr</DisplayString>
<DisplayString Condition="_data">...</DisplayString>
<Expand HideRawView="1">
<CustomListItems Condition="_data &amp;&amp; _data &lt; 255">
<Variable Name="compact_alignment_log2" InitialValue="2" />
<Variable Name="compact_alignment" InitialValue="1 &lt;&lt; compact_alignment_log2" />
<Item Name="value">*(pugi::xml_attribute_struct*)(((size_t)this &amp; ~(compact_alignment - 1)) + (_data - 1 + $T2) * compact_alignment)</Item>
</CustomListItems>
<CustomListItems Condition="_data &amp;&amp; _data &gt;= 255">
<Variable Name="compact_alignment_log2" InitialValue="2" />
<Variable Name="compact_alignment" InitialValue="1 &lt;&lt; compact_alignment_log2" />
<!-- compact_get_page() -->
<Variable Name="_page" InitialValue="*(char*)(this - $T1)" />
<Variable Name="page" InitialValue="((this - $T1 - (_page &lt;&lt; compact_alignment_log2)) - *(unsigned*)(this - $T1 - (_page &lt;&lt; compact_alignment_log2)))" />
<!-- page->allocator->_hash -->
<Variable Name="allocator" InitialValue="*(size_t*)page" />
<Variable Name="_hash" InitialValue="*(size_t*)(allocator + 2 * sizeof(size_t))" /><!--2 pointer offsetof(allocator, _hash)-->
<Variable Name="_items" InitialValue="*(size_t*)_hash" />
<Variable Name="_capacity" InitialValue="*((size_t*)_hash + 1)" /><!--1 pointer offsetof(_hash, _capacity)-->
<Variable Name="_count" InitialValue="*((size_t*)_hash + 2)" /><!--2 pointer offsetof(_hash, _count)-->
<!-- find() prolog -->
<Variable Name="hashmod" InitialValue="_capacity - 1" />
<Variable Name="h" InitialValue="(unsigned)this" />
<Variable Name="bucket" InitialValue="0" />
<Variable Name="probe" InitialValue="0" />
<Variable Name="probe_item" InitialValue="(size_t*)0" />
<!-- find() hash -->
<Exec>h = h ^ (h >> 16)</Exec>
<Exec>h = h * (0x85ebca6bu)</Exec>
<Exec>h = h ^ (h >> 13)</Exec>
<Exec>h = h * (0xc2b2ae35u)</Exec>
<Exec>h = h ^ (h >> 16)</Exec>
<Exec>bucket = h &amp; hashmod</Exec>
<!-- find() loop -->
<Loop Condition="probe &lt;= hashmod &amp;&amp;_capacity">
<Exec>probe_item = (size_t*)_items + bucket * 2</Exec><!--2 pointer sizeof(item_t)-->
<If Condition="*probe_item == this || *probe_item == 0">
<Item Name="value">**(pugi::xml_attribute_struct**)(probe_item + 1)</Item><!--1 pointer offsetof(item_t, value)-->
<Break/>
</If>
<Exec>bucket = (bucket + probe + 1) &amp; hashmod</Exec>
<Exec>probe++</Exec>
</Loop>
</CustomListItems>
</Expand>
</Type>
<Type Name="pugi::xpath_node">
<DisplayString Condition="_node._root &amp;&amp; _attribute._attr">{_node,na} {_attribute,na}</DisplayString>
<DisplayString Condition="_node._root">{_node,na}</DisplayString>
<DisplayString Condition="_attribute._attr">{_attribute}</DisplayString>
<DisplayString>empty</DisplayString>
<Expand HideRawView="1">
<ExpandedItem Condition="_node._root &amp;&amp; !_attribute._attr">_node</ExpandedItem>
<ExpandedItem Condition="!_node._root &amp;&amp; _attribute._attr">_attribute</ExpandedItem>
<Item Name="node" Condition="_node._root &amp;&amp; _attribute._attr">_node,na</Item>
<Item Name="attribute" Condition="_node._root &amp;&amp; _attribute._attr">_attribute,na</Item>
</Expand>
</Type>
<Type Name="pugi::xpath_node_set">
<Expand>
<Item Name="type">_type</Item>
<ArrayItems>
<Size>_end - _begin</Size>
<ValuePointer>_begin</ValuePointer>
</ArrayItems>
</Expand>
</Type>
</AutoVisualizer>

View File

@ -10,8 +10,6 @@
<EnumProperty Name="Linkage-pugixml" DisplayName="Linkage" Description="Which version of the runtime library to use for this library" Category="pugixml"> <EnumProperty Name="Linkage-pugixml" DisplayName="Linkage" Description="Which version of the runtime library to use for this library" Category="pugixml">
<EnumValue Name="dynamic" DisplayName="Dynamic CRT (/MD, /MDd)" /> <EnumValue Name="dynamic" DisplayName="Dynamic CRT (/MD, /MDd)" />
<EnumValue Name="static" DisplayName="Static CRT (/MT, /MTd)" /> <EnumValue Name="static" DisplayName="Static CRT (/MT, /MTd)" />
<EnumValue Name="source" DisplayName="Include pugixml.cpp" />
<EnumValue Name="header" DisplayName="Header Only" />
</EnumProperty> </EnumProperty>
</Rule> </Rule>
</ProjectSchemaDefinitions> </ProjectSchemaDefinitions>

View File

@ -2,27 +2,26 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Default initializers for properties"> <PropertyGroup Label="Default initializers for properties">
<Linkage-pugixml Condition="'$(Linkage-pugixml)' == ''">dynamic</Linkage-pugixml> <Linkage-pugixml Condition="'$(Linkage-pugixml)' == ''">dynamic</Linkage-pugixml>
<Configuration-pugixml Condition="$(Configuration.ToLower().IndexOf('debug')) != -1">Debug</Configuration-pugixml>
<Configuration-pugixml Condition="$(Configuration.ToLower().IndexOf('debug')) == -1">Release</Configuration-pugixml>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)\pugixml-propertiesui.xml" /> <PropertyPageSchema Include="$(MSBuildThisFileDirectory)\pugixml-propertiesui.xml" />
</ItemGroup> </ItemGroup>
<ItemDefinitionGroup> <ItemDefinitionGroup>
<ClCompile> <ClCompile>
<PreprocessorDefinitions Condition="'$(Linkage-pugixml)' == 'header'">PUGIXML_HEADER_ONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<ResourceCompile> <ResourceCompile>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile> </ResourceCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup Condition="'$(Linkage-pugixml)' == 'source'"> <ItemDefinitionGroup Condition="$(Configuration.ToLower().IndexOf('debug')) != -1">
<ClCompile Include="$(MSBuildThisFileDirectory)include\pugixml.cpp"/>
</ItemGroup>
<ItemDefinitionGroup Condition="'$(Linkage-pugixml)' != 'header' AND '$(Linkage-pugixml)' != 'source'">
<Link> <Link>
<AdditionalDependencies>$(MSBuildThisFileDirectory)lib/$(Platform)\$(PlatformToolset.Split('_')[0])\$(Linkage-pugixml)\$(Configuration-pugixml)\pugixml.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>$(MSBuildThisFileDirectory)lib/$(Platform)\$(PlatformToolset.Split('_')[0])\$(Linkage-pugixml)\Debug\pugixml.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="$(Configuration.ToLower().IndexOf('debug')) == -1">
<Link>
<AdditionalDependencies>$(MSBuildThisFileDirectory)lib/$(Platform)\$(PlatformToolset.Split('_')[0])\$(Linkage-pugixml)\Release\pugixml.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
</Project> </Project>

View File

@ -2,19 +2,20 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
<metadata> <metadata>
<id>pugixml</id> <id>pugixml</id>
<version>1.14.0-appveyor</version> <version>1.9.0-appveyor</version>
<title>pugixml</title> <title>pugixml</title>
<authors>Arseny Kapoulkine</authors> <authors>Arseny Kapoulkine</authors>
<owners>Arseny Kapoulkine</owners> <owners>Arseny Kapoulkine</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license> <licenseUrl>http://pugixml.org/license.html</licenseUrl>
<projectUrl>https://pugixml.org/</projectUrl> <projectUrl>http://pugixml.org/</projectUrl>
<iconUrl>https://github.com/zeux/pugixml/logo.svg</iconUrl>
<description>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). <description>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. 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, VS2019 and VS2022, for both statically linked and DLL CRT; you can switch the CRT linkage in Project -> Properties -> Referenced Packages -> pugixml.</description> This package contains builds for VS2013, VS2015 and VS2017, for both statically linked and DLL CRT; you can switch the CRT linkage in Project -> Properties -> Referenced Packages -> pugixml.</description>
<summary>Light-weight, simple and fast XML parser for C++ with XPath support</summary> <summary>Light-weight, simple and fast XML parser for C++ with XPath support</summary>
<releaseNotes>https://pugixml.org/docs/manual.html#changes</releaseNotes> <releaseNotes>http://pugixml.org/docs/manual.html#changes</releaseNotes>
<copyright>Copyright (c) 2006-2024 Arseny Kapoulkine</copyright> <copyright>Copyright (c) 2006-2018 Arseny Kapoulkine</copyright>
<tags>native nativepackage</tags> <tags>native nativepackage</tags>
</metadata> </metadata>
</package> </package>

View File

@ -33,38 +33,16 @@ cd $scriptdir
Force-Copy "../src/pugiconfig.hpp" "nuget/build/native/include/pugiconfig.hpp" 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.hpp" "nuget/build/native/include/pugixml.hpp"
Force-Copy "../src/pugixml.cpp" "nuget/build/native/include/pugixml.cpp"
if ($args[0] -eq 2022){ Build-Version "vs2013" "v120" "dynamic"
Build-Version "vs2022" "v143" "dynamic" Build-Version "vs2013" "v120" "static"
Build-Version "vs2022" "v143" "static"
} elseif ($args[0] -eq 2019){ Build-Version "vs2015" "v140" "dynamic"
Build-Version "vs2019" "v142" "dynamic" Build-Version "vs2015" "v140" "static"
Build-Version "vs2019" "v142" "static"
} elseif ($args[0] -eq 2017){
Build-Version "vs2017" "v141" "dynamic" Build-Version "vs2017" "v141" "dynamic"
Build-Version "vs2017" "v141" "static" 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" Run-Command "nuget pack nuget"
Pop-Location Pop-Location

View File

@ -1,12 +0,0 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/pugixml-targets.cmake")
# If the user is not requiring 1.11 (either by explicitly requesting an older
# version or not requesting one at all), provide the old imported target name
# for compatibility.
if (NOT TARGET pugixml AND (NOT DEFINED PACKAGE_FIND_VERSION OR PACKAGE_FIND_VERSION VERSION_LESS "1.11"))
add_library(pugixml INTERFACE IMPORTED)
# Equivalent to target_link_libraries INTERFACE, but compatible with CMake 3.10
set_target_properties(pugixml PROPERTIES INTERFACE_LINK_LIBRARIES pugixml::pugixml)
endif ()

View File

@ -1,11 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix} exec_prefix=${prefix}
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@@INSTALL_SUFFIX@ includedir=${prefix}/include@INSTALL_SUFFIX@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@@INSTALL_SUFFIX@ libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@@INSTALL_SUFFIX@
Name: pugixml Name: pugixml
Description: Light-weight, simple and fast XML parser for C++ with XPath support. Description: Light-weight, simple and fast XML parser for C++ with XPath support.
URL: https://pugixml.org/ URL: http://pugixml.org/
Version: @pugixml_VERSION@ Version: @pugixml_VERSION@
Cflags: -I${includedir} Cflags: -I${includedir}
Libs: -L${libdir} -lpugixml@LIB_POSTFIX@ Libs: -L${libdir} -lpugixml

View File

@ -1,8 +1,8 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "pugixml" s.name = "pugixml"
s.version = "1.14" s.version = "1.9"
s.summary = "C++ XML parser library." s.summary = "C++ XML parser library."
s.homepage = "https://pugixml.org" s.homepage = "http://pugixml.org"
s.license = "MIT" s.license = "MIT"
s.author = { "Arseny Kapoulkine" => "arseny.kapoulkine@gmail.com" } s.author = { "Arseny Kapoulkine" => "arseny.kapoulkine@gmail.com" }
s.platform = :ios, "7.0" s.platform = :ios, "7.0"

View File

@ -1,45 +0,0 @@
#include <winver.h>
#define PUGIXML_VERSION_MAJOR 1
#define PUGIXML_VERSION_MINOR 14
#define PUGIXML_VERSION_PATCH 0
#define PUGIXML_VERSION_NUMBER "1.14.0\0"
#if defined(GCC_WINDRES) || defined(__MINGW32__) || defined(__CYGWIN__)
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-2024, 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

View File

@ -1,172 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{07CF01C0-B887-499D-AD9C-799CB6A9FE64}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>pugixml</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>vs2019\$(Platform)_$(Configuration)\</OutDir>
<IntDir>vs2019\$(Platform)_$(Configuration)\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>vs2019\$(Platform)_$(Configuration)\</OutDir>
<IntDir>vs2019\$(Platform)_$(Configuration)\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>vs2019\$(Platform)_$(Configuration)\</OutDir>
<IntDir>vs2019\$(Platform)_$(Configuration)\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>vs2019\$(Platform)_$(Configuration)\</OutDir>
<IntDir>vs2019\$(Platform)_$(Configuration)\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\src\pugiconfig.hpp" />
<ClInclude Include="..\src\pugixml.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\pugixml.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,176 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{07CF01C0-B887-499D-AD9C-799CB6A9FE64}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>pugixml</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>vs2019\$(Platform)_$(Configuration)Static\</OutDir>
<IntDir>vs2019\$(Platform)_$(Configuration)Static\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>vs2019\$(Platform)_$(Configuration)Static\</OutDir>
<IntDir>vs2019\$(Platform)_$(Configuration)Static\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>vs2019\$(Platform)_$(Configuration)Static\</OutDir>
<IntDir>vs2019\$(Platform)_$(Configuration)Static\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>vs2019\$(Platform)_$(Configuration)Static\</OutDir>
<IntDir>vs2019\$(Platform)_$(Configuration)Static\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\src\pugiconfig.hpp" />
<ClInclude Include="..\src\pugixml.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\pugixml.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,172 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{07CF01C0-B887-499D-AD9C-799CB6A9FE64}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>pugixml</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>vs2022\$(Platform)_$(Configuration)\</OutDir>
<IntDir>vs2022\$(Platform)_$(Configuration)\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>vs2022\$(Platform)_$(Configuration)\</OutDir>
<IntDir>vs2022\$(Platform)_$(Configuration)\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>vs2022\$(Platform)_$(Configuration)\</OutDir>
<IntDir>vs2022\$(Platform)_$(Configuration)\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>vs2022\$(Platform)_$(Configuration)\</OutDir>
<IntDir>vs2022\$(Platform)_$(Configuration)\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\src\pugiconfig.hpp" />
<ClInclude Include="..\src\pugixml.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\pugixml.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,176 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{07CF01C0-B887-499D-AD9C-799CB6A9FE64}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>pugixml</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>vs2022\$(Platform)_$(Configuration)Static\</OutDir>
<IntDir>vs2022\$(Platform)_$(Configuration)Static\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>vs2022\$(Platform)_$(Configuration)Static\</OutDir>
<IntDir>vs2022\$(Platform)_$(Configuration)Static\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>vs2022\$(Platform)_$(Configuration)Static\</OutDir>
<IntDir>vs2022\$(Platform)_$(Configuration)Static\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>vs2022\$(Platform)_$(Configuration)Static\</OutDir>
<IntDir>vs2022\$(Platform)_$(Configuration)Static\</IntDir>
<TargetName>pugixml</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\src\pugiconfig.hpp" />
<ClInclude Include="..\src\pugixml.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\pugixml.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,8 +1,8 @@
/** /**
* pugixml parser - version 1.14 * pugixml parser - version 1.9
* -------------------------------------------------------- * --------------------------------------------------------
* Copyright (C) 2006-2024, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) * Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/ * Report bugs and download new versions at http://pugixml.org/
* *
* This library is distributed under the MIT License. See notice at the end * This library is distributed under the MIT License. See notice at the end
* of this file. * of this file.
@ -40,9 +40,6 @@
// #define PUGIXML_MEMORY_OUTPUT_STACK 10240 // #define PUGIXML_MEMORY_OUTPUT_STACK 10240
// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 // #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096
// Tune this constant to adjust max nesting for XPath queries
// #define PUGIXML_XPATH_DEPTH_LIMIT 1024
// Uncomment this to switch to header-only version // Uncomment this to switch to header-only version
// #define PUGIXML_HEADER_ONLY // #define PUGIXML_HEADER_ONLY
@ -52,7 +49,7 @@
#endif #endif
/** /**
* Copyright (c) 2006-2024 Arseny Kapoulkine * Copyright (c) 2006-2018 Arseny Kapoulkine
* *
* Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation * obtaining a copy of this software and associated documentation

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
/** /**
* pugixml parser - version 1.14 * pugixml parser - version 1.9
* -------------------------------------------------------- * --------------------------------------------------------
* Copyright (C) 2006-2024, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) * Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/ * Report bugs and download new versions at http://pugixml.org/
* *
* This library is distributed under the MIT License. See notice at the end * This library is distributed under the MIT License. See notice at the end
* of this file. * of this file.
@ -11,10 +11,9 @@
* Copyright (C) 2003, by Kristen Wegner (kristen@tima.net) * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
*/ */
// 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
#ifndef PUGIXML_VERSION #ifndef PUGIXML_VERSION
# define PUGIXML_VERSION 1140 // 1.14 // Define version macro; evaluates to major * 100 + minor * 10 + patch so that it's safe to use in less-than comparisons
#define PUGIXML_VERSION 190
#endif #endif
// Include user configuration file (this can define various configuration macros) // Include user configuration file (this can define various configuration macros)
@ -33,8 +32,8 @@
// Include STL headers // Include STL headers
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
# include <iterator>
#include <iosfwd> #include <iosfwd>
#include <iterator>
#include <string> #include <string>
#endif #endif
@ -111,17 +110,6 @@
#endif #endif
#endif #endif
// If C++ is 2011 or higher, use 'nullptr'
#ifndef PUGIXML_NULL
# if __cplusplus >= 201103
# define PUGIXML_NULL nullptr
# elif defined(_MSC_VER) && _MSC_VER >= 1600
# define PUGIXML_NULL nullptr
# else
# define PUGIXML_NULL 0
# endif
#endif
// Character interface macros // Character interface macros
#ifdef PUGIXML_WCHAR_MODE #ifdef PUGIXML_WCHAR_MODE
#define PUGIXML_TEXT(t) L##t #define PUGIXML_TEXT(t) L##t
@ -138,9 +126,9 @@ namespace pugi
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
// String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE // String type used for operations that work with STL string; depends on PUGIXML_WCHAR_MODE
typedef std::basic_string<PUGIXML_CHAR> string_t; typedef std::basic_string<PUGIXML_CHAR, std::char_traits<PUGIXML_CHAR>, std::allocator<PUGIXML_CHAR> > string_t;
#endif #endif
} } // namespace pugi
// The PugiXML namespace // The PugiXML namespace
namespace pugi namespace pugi
@ -213,10 +201,6 @@ namespace pugi
// This flag is off by default. // This flag is off by default.
const unsigned int parse_embed_pcdata = 0x2000; const unsigned int parse_embed_pcdata = 0x2000;
// This flag determines whether determines whether the the two pcdata should be merged or not, if no intermediatory data are parsed in the document.
// This flag is off by default.
const unsigned int parse_merge_pcdata = 0x4000;
// The default parsing mode. // The default parsing mode.
// Elements, PCDATA and CDATA sections are added to the DOM tree, character/reference entities are expanded, // 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. // End-of-Line characters are normalized, attribute values are normalized using CDATA normalization rules.
@ -268,19 +252,10 @@ namespace pugi
// Don't output empty element tags, instead writing an explicit start and end tag even if there are no children. This flag is off by default. // Don't output empty element tags, instead writing an explicit start and end tag even if there are no children. This flag is off by default.
const unsigned int format_no_empty_element_tags = 0x80; const unsigned int format_no_empty_element_tags = 0x80;
// Skip characters belonging to range [0; 32) instead of "&#xNN;" encoding. This flag is off by default.
const unsigned int format_skip_control_chars = 0x100;
// Use single quotes ' instead of double quotes " for enclosing attribute values. This flag is off by default.
const unsigned int format_attribute_single_quote = 0x200;
// The default set of formatting flags. // The default set of formatting flags.
// Nodes are indented depending on their depth in DOM tree, a default declaration is output if document has none. // Nodes are indented depending on their depth in DOM tree, a default declaration is output if document has none.
const unsigned int format_default = format_indent; const unsigned int format_default = format_indent;
const int default_double_precision = 17;
const int default_float_precision = 9;
// Forward declarations // Forward declarations
struct xml_attribute_struct; struct xml_attribute_struct;
struct xml_node_struct; struct xml_node_struct;
@ -305,21 +280,22 @@ namespace pugi
#endif #endif
// Range-based for loop support // Range-based for loop support
template <typename It> class xml_object_range template <typename It>
class xml_object_range
{ {
public: public:
typedef It const_iterator; typedef It const_iterator;
typedef It iterator; typedef It iterator;
xml_object_range(It b, It e): _begin(b), _end(e) xml_object_range(It b, It e)
: _begin(b)
, _end(e)
{ {
} }
It begin() const { return _begin; } It begin() const { return _begin; }
It end() const { return _end; } It end() const { return _end; }
bool empty() const { return _begin == _end; }
private: private:
It _begin, _end; It _begin, _end;
}; };
@ -328,7 +304,7 @@ namespace pugi
class PUGIXML_CLASS xml_writer class PUGIXML_CLASS xml_writer
{ {
public: public:
virtual ~xml_writer(); virtual ~xml_writer() {}
// Write memory chunk into stream/file/whatever // Write memory chunk into stream/file/whatever
virtual void write(const void* data, size_t size) = 0; virtual void write(const void* data, size_t size) = 0;
@ -353,14 +329,14 @@ namespace pugi
{ {
public: public:
// Construct writer from an output stream object // Construct writer from an output stream object
xml_writer_stream(std::basic_ostream<char>& stream); xml_writer_stream(std::basic_ostream<char, std::char_traits<char> >& stream);
xml_writer_stream(std::basic_ostream<wchar_t>& stream); xml_writer_stream(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream);
virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE; virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE;
private: private:
std::basic_ostream<char>* narrow_stream; std::basic_ostream<char, std::char_traits<char> >* narrow_stream;
std::basic_ostream<wchar_t>* wide_stream; std::basic_ostream<wchar_t, std::char_traits<wchar_t> >* wide_stream;
}; };
#endif #endif
@ -422,9 +398,7 @@ namespace pugi
// Set attribute name/value (returns false if attribute is empty or there is not enough memory) // 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_name(const char_t* rhs);
bool set_name(const char_t* rhs, size_t size);
bool set_value(const char_t* rhs); bool set_value(const char_t* rhs);
bool set_value(const char_t* rhs, size_t size);
// Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") // 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(int rhs);
@ -432,9 +406,7 @@ namespace pugi
bool set_value(long rhs); bool set_value(long rhs);
bool set_value(unsigned long rhs); bool set_value(unsigned long rhs);
bool set_value(double rhs); bool set_value(double rhs);
bool set_value(double rhs, int precision);
bool set_value(float rhs); bool set_value(float rhs);
bool set_value(float rhs, int precision);
bool set_value(bool rhs); bool set_value(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG #ifdef PUGIXML_HAS_LONG_LONG
@ -558,9 +530,7 @@ namespace pugi
// Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value) // 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_name(const char_t* rhs);
bool set_name(const char_t* rhs, size_t size);
bool set_value(const char_t* rhs); bool set_value(const char_t* rhs);
bool set_value(const char_t* rhs, size_t size);
// Add attribute with specified name. Returns added attribute, or empty attribute on errors. // Add attribute with specified name. Returns added attribute, or empty attribute on errors.
xml_attribute append_attribute(const char_t* name); xml_attribute append_attribute(const char_t* name);
@ -602,25 +572,21 @@ namespace pugi
bool remove_attribute(const xml_attribute& a); bool remove_attribute(const xml_attribute& a);
bool remove_attribute(const char_t* name); bool remove_attribute(const char_t* name);
// Remove all attributes
bool remove_attributes();
// Remove specified child // Remove specified child
bool remove_child(const xml_node& n); bool remove_child(const xml_node& n);
bool remove_child(const char_t* name); 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. // 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. // 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. // 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); 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. // Find attribute using predicate. Returns first attribute for which predicate returned true.
template <typename Predicate> xml_attribute find_attribute(Predicate pred) const template <typename Predicate>
xml_attribute find_attribute(Predicate pred) const
{ {
if (!_root) return xml_attribute(); if (!_root)
return xml_attribute();
for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute()) for (xml_attribute attrib = first_attribute(); attrib; attrib = attrib.next_attribute())
if (pred(attrib)) if (pred(attrib))
@ -630,9 +596,11 @@ namespace pugi
} }
// Find child node using predicate. Returns first child for which predicate returned true. // Find child node using predicate. Returns first child for which predicate returned true.
template <typename Predicate> xml_node find_child(Predicate pred) const template <typename Predicate>
xml_node find_child(Predicate pred) const
{ {
if (!_root) return xml_node(); if (!_root)
return xml_node();
for (xml_node node = first_child(); node; node = node.next_sibling()) for (xml_node node = first_child(); node; node = node.next_sibling())
if (pred(node)) if (pred(node))
@ -642,23 +610,30 @@ namespace pugi
} }
// Find node from subtree using predicate. Returns first node from subtree (depth-first), for which predicate returned true. // Find node from subtree using predicate. Returns first node from subtree (depth-first), for which predicate returned true.
template <typename Predicate> xml_node find_node(Predicate pred) const template <typename Predicate>
xml_node find_node(Predicate pred) const
{ {
if (!_root) return xml_node(); if (!_root)
return xml_node();
xml_node cur = first_child(); xml_node cur = first_child();
while (cur._root && cur._root != _root) while (cur._root && cur._root != _root)
{ {
if (pred(cur)) return cur; if (pred(cur))
return cur;
if (cur.first_child()) cur = cur.first_child(); if (cur.first_child())
else if (cur.next_sibling()) cur = cur.next_sibling(); cur = cur.first_child();
else if (cur.next_sibling())
cur = cur.next_sibling();
else else
{ {
while (!cur.next_sibling() && cur._root != _root) cur = cur.parent(); while (!cur.next_sibling() && cur._root != _root)
cur = cur.parent();
if (cur._root != _root) cur = cur.next_sibling(); if (cur._root != _root)
cur = cur.next_sibling();
} }
} }
@ -682,15 +657,15 @@ namespace pugi
#ifndef PUGIXML_NO_XPATH #ifndef PUGIXML_NO_XPATH
// Select single node by evaluating XPath query. Returns first node from the resulting node set. // 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 char_t* query, xpath_variable_set* variables = 0) const;
xpath_node select_node(const xpath_query& query) const; xpath_node select_node(const xpath_query& query) const;
// Select node set by evaluating XPath query // 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 char_t* query, xpath_variable_set* variables = 0) const;
xpath_node_set select_nodes(const xpath_query& query) const; xpath_node_set select_nodes(const xpath_query& query) const;
// (deprecated: use select_node instead) Select single node by evaluating XPath query. // (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 char_t* query, xpath_variable_set* variables = 0) const;
PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const; PUGIXML_DEPRECATED xpath_node select_single_node(const xpath_query& query) const;
#endif #endif
@ -700,8 +675,8 @@ namespace pugi
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
// Print subtree to stream // Print subtree to stream
void print(std::basic_ostream<char>& 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<char, std::char_traits<char> >& 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<wchar_t>& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const; void print(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& os, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, unsigned int depth = 0) const;
#endif #endif
// Child nodes iterators // Child nodes iterators
@ -718,11 +693,8 @@ namespace pugi
// Range-based for support // Range-based for support
xml_object_range<xml_node_iterator> children() const; xml_object_range<xml_node_iterator> children() const;
xml_object_range<xml_attribute_iterator> attributes() const;
// Range-based for support for all children with the specified name
// Note: name pointer must have a longer lifetime than the returned object; be careful with passing temporaries!
xml_object_range<xml_named_node_iterator> children(const char_t* name) const; xml_object_range<xml_named_node_iterator> children(const char_t* name) const;
xml_object_range<xml_attribute_iterator> attributes() const;
// Get node offset in parsed file/string (in char_t units) for debugging purposes // Get node offset in parsed file/string (in char_t units) for debugging purposes
ptrdiff_t offset_debug() const; ptrdiff_t offset_debug() const;
@ -789,7 +761,6 @@ namespace pugi
// Set text (returns false if object is empty or there is not enough memory) // Set text (returns false if object is empty or there is not enough memory)
bool set(const char_t* rhs); bool set(const char_t* rhs);
bool set(const char_t* rhs, size_t size);
// Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
bool set(int rhs); bool set(int rhs);
@ -797,9 +768,7 @@ namespace pugi
bool set(long rhs); bool set(long rhs);
bool set(unsigned long rhs); bool set(unsigned long rhs);
bool set(double rhs); bool set(double rhs);
bool set(double rhs, int precision);
bool set(float rhs); bool set(float rhs);
bool set(float rhs, int precision);
bool set(bool rhs); bool set(bool rhs);
#ifdef PUGIXML_HAS_LONG_LONG #ifdef PUGIXML_HAS_LONG_LONG
@ -867,10 +836,10 @@ namespace pugi
xml_node& operator*() const; xml_node& operator*() const;
xml_node* operator->() const; xml_node* operator->() const;
xml_node_iterator& operator++(); const xml_node_iterator& operator++();
xml_node_iterator operator++(int); xml_node_iterator operator++(int);
xml_node_iterator& operator--(); const xml_node_iterator& operator--();
xml_node_iterator operator--(int); xml_node_iterator operator--(int);
}; };
@ -909,10 +878,10 @@ namespace pugi
xml_attribute& operator*() const; xml_attribute& operator*() const;
xml_attribute* operator->() const; xml_attribute* operator->() const;
xml_attribute_iterator& operator++(); const xml_attribute_iterator& operator++();
xml_attribute_iterator operator++(int); xml_attribute_iterator operator++(int);
xml_attribute_iterator& operator--(); const xml_attribute_iterator& operator--();
xml_attribute_iterator operator--(int); xml_attribute_iterator operator--(int);
}; };
@ -936,7 +905,6 @@ namespace pugi
xml_named_node_iterator(); xml_named_node_iterator();
// Construct an iterator which points to the specified node // Construct an iterator which points to the specified node
// Note: name pointer is stored in the iterator and must have a longer lifetime than iterator itself
xml_named_node_iterator(const xml_node& node, const char_t* name); xml_named_node_iterator(const xml_node& node, const char_t* name);
// Iterator operators // Iterator operators
@ -946,10 +914,10 @@ namespace pugi
xml_node& operator*() const; xml_node& operator*() const;
xml_node* operator->() const; xml_node* operator->() const;
xml_named_node_iterator& operator++(); const xml_named_node_iterator& operator++();
xml_named_node_iterator operator++(int); xml_named_node_iterator operator++(int);
xml_named_node_iterator& operator--(); const xml_named_node_iterator& operator--();
xml_named_node_iterator operator--(int); xml_named_node_iterator operator--(int);
private: private:
@ -1072,8 +1040,8 @@ namespace pugi
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
// Load document from stream. // Load document from stream.
xml_parse_result load(std::basic_istream<char>& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto); xml_parse_result load(std::basic_istream<char, std::char_traits<char> >& stream, unsigned int options = parse_default, xml_encoding encoding = encoding_auto);
xml_parse_result load(std::basic_istream<wchar_t>& stream, unsigned int options = parse_default); xml_parse_result load(std::basic_istream<wchar_t, std::char_traits<wchar_t> >& stream, unsigned int options = parse_default);
#endif #endif
// (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied. // (deprecated: use load_string instead) Load document from zero-terminated string. No encoding conversions are applied.
@ -1102,8 +1070,8 @@ namespace pugi
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
// Save XML document to stream (semantics is slightly different from xml_node::print, see documentation for details). // Save XML document to stream (semantics is slightly different from xml_node::print, see documentation for details).
void save(std::basic_ostream<char>& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const; void save(std::basic_ostream<char, std::char_traits<char> >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default, xml_encoding encoding = encoding_auto) const;
void save(std::basic_ostream<wchar_t>& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const; void save(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream, const char_t* indent = PUGIXML_TEXT("\t"), unsigned int flags = format_default) const;
#endif #endif
// Save XML to file // Save XML to file
@ -1238,7 +1206,7 @@ namespace pugi
public: public:
// Construct a compiled object from XPath expression. // Construct a compiled object from XPath expression.
// If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on compilation errors. // 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); explicit xpath_query(const char_t* query, xpath_variable_set* variables = 0);
// Constructor // Constructor
xpath_query(); xpath_query();
@ -1439,12 +1407,12 @@ namespace pugi
#ifndef PUGIXML_NO_STL #ifndef PUGIXML_NO_STL
// Convert wide string to UTF8 // Convert wide string to UTF8
std::basic_string<char> PUGIXML_FUNCTION as_utf8(const wchar_t* str); std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const wchar_t* str);
std::basic_string<char> PUGIXML_FUNCTION as_utf8(const std::basic_string<wchar_t>& str); std::basic_string<char, std::char_traits<char>, std::allocator<char> > PUGIXML_FUNCTION as_utf8(const std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >& str);
// Convert UTF8 to wide string // Convert UTF8 to wide string
std::basic_string<wchar_t> PUGIXML_FUNCTION as_wide(const char* str); std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const char* str);
std::basic_string<wchar_t> PUGIXML_FUNCTION as_wide(const std::basic_string<char>& str); std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > PUGIXML_FUNCTION as_wide(const std::basic_string<char, std::char_traits<char>, std::allocator<char> >& str);
#endif #endif
// Memory allocation function interface; returns pointer to allocated memory or NULL on failure // Memory allocation function interface; returns pointer to allocated memory or NULL on failure
@ -1459,7 +1427,7 @@ namespace pugi
// Get current memory management functions // Get current memory management functions
allocation_function PUGIXML_FUNCTION get_memory_allocation_function(); allocation_function PUGIXML_FUNCTION get_memory_allocation_function();
deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function(); deallocation_function PUGIXML_FUNCTION get_memory_deallocation_function();
} } // namespace pugi
#if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC)) #if !defined(PUGIXML_NO_STL) && (defined(_MSC_VER) || defined(__ICC))
namespace std namespace std
@ -1468,7 +1436,7 @@ namespace std
std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_node_iterator&); 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_attribute_iterator&);
std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_named_node_iterator&); std::bidirectional_iterator_tag PUGIXML_FUNCTION _Iter_cat(const pugi::xml_named_node_iterator&);
} } // namespace std
#endif #endif
#if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC) #if !defined(PUGIXML_NO_STL) && defined(__SUNPRO_CC)
@ -1478,7 +1446,7 @@ namespace std
std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_node_iterator&); 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_attribute_iterator&);
std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_named_node_iterator&); std::bidirectional_iterator_tag PUGIXML_FUNCTION __iterator_category(const pugi::xml_named_node_iterator&);
} } // namespace std
#endif #endif
#endif #endif
@ -1491,7 +1459,7 @@ namespace std
#endif #endif
/** /**
* Copyright (c) 2006-2024 Arseny Kapoulkine * Copyright (c) 2006-2018 Arseny Kapoulkine
* *
* Permission is hereby granted, free of charge, to any person * Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation * obtaining a copy of this software and associated documentation

View File

@ -1,8 +1,8 @@
#include "allocator.hpp" #include "allocator.hpp"
#include <string.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
// Address sanitizer // Address sanitizer
#if defined(__has_feature) #if defined(__has_feature)
@ -58,7 +58,8 @@ namespace
size_t aligned_size = align_to_page(size); size_t aligned_size = align_to_page(size);
void* ptr = allocate_page_aligned(aligned_size + page_size); void* ptr = allocate_page_aligned(aligned_size + page_size);
if (!ptr) return 0; if (!ptr)
return 0;
char* end = static_cast<char*>(ptr) + aligned_size; char* end = static_cast<char*>(ptr) + aligned_size;
@ -77,7 +78,7 @@ namespace
DWORD old_flags; DWORD old_flags;
VirtualProtect(rptr, aligned_size + page_size, PAGE_NOACCESS, &old_flags); VirtualProtect(rptr, aligned_size + page_size, PAGE_NOACCESS, &old_flags);
} }
} } // namespace
#elif (defined(__APPLE__) || defined(__linux__)) && (defined(__i386) || defined(__x86_64)) && !ADDRESS_SANITIZER #elif (defined(__APPLE__) || defined(__linux__)) && (defined(__i386) || defined(__x86_64)) && !ADDRESS_SANITIZER
#include <sys/mman.h> #include <sys/mman.h>
@ -102,7 +103,8 @@ namespace
size_t aligned_size = align_to_page(size); size_t aligned_size = align_to_page(size);
void* ptr = allocate_page_aligned(aligned_size + page_size); void* ptr = allocate_page_aligned(aligned_size + page_size);
if (!ptr) return 0; if (!ptr)
return 0;
char* end = static_cast<char*>(ptr) + aligned_size; char* end = static_cast<char*>(ptr) + aligned_size;
@ -123,7 +125,7 @@ namespace
assert(res == 0); assert(res == 0);
(void)!res; (void)!res;
} }
} } // namespace
#else #else
namespace namespace
{ {
@ -138,7 +140,7 @@ namespace
free(ptr); free(ptr);
} }
} } // namespace
#endif #endif
// High-level allocation functions // High-level allocation functions
@ -147,7 +149,8 @@ const size_t memory_alignment = sizeof(double) > sizeof(void*) ? sizeof(double)
void* memory_allocate(size_t size) void* memory_allocate(size_t size)
{ {
void* result = allocate(size + memory_alignment); void* result = allocate(size + memory_alignment);
if (!result) return 0; if (!result)
return 0;
memcpy(result, &size, sizeof(size_t)); memcpy(result, &size, sizeof(size_t));
@ -166,10 +169,10 @@ size_t memory_size(void* ptr)
void memory_deallocate(void* ptr) void memory_deallocate(void* ptr)
{ {
if (!ptr) return; if (!ptr)
return;
size_t size = memory_size(ptr); size_t size = memory_size(ptr);
deallocate(static_cast<char*>(ptr) - memory_alignment, size + memory_alignment); deallocate(static_cast<char*>(ptr) - memory_alignment, size + memory_alignment);
} }

View File

@ -18,18 +18,11 @@ foreach ($vs in $args)
{ {
Write-Output "# Setting up VS$vs $arch" Write-Output "# Setting up VS$vs $arch"
if ($vs -eq 15) { if ($vs -eq 15)
{
$vsdevcmdarch = if ($arch -eq "x64") { "amd64" } else { "x86" } $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" 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"
}
elseif ($vs -eq 22) {
$vsdevcmdarch = if ($arch -eq "x64") { "amd64" } else { "x86" }
Invoke-CmdScript "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" "-arch=$vsdevcmdarch"
}
else else
{ {
Invoke-CmdScript "C:\Program Files (x86)\Microsoft Visual Studio $vs.0\VC\vcvarsall.bat" $arch Invoke-CmdScript "C:\Program Files (x86)\Microsoft Visual Studio $vs.0\VC\vcvarsall.bat" $arch
@ -45,7 +38,7 @@ foreach ($vs in $args)
Add-AppveyorTest $target -Outcome Running Add-AppveyorTest $target -Outcome Running
Write-Output "# Building $target.exe" Write-Output "# Building $target.exe"
& cmd /c "cl.exe /MP /Fe$target.exe /EHsc /W4 /WX $deflist $sources 2>&1" | Tee-Object -Variable buildOutput & cmd /c "cl.exe /Fe$target.exe /EHsc /W4 /WX $deflist $sources 2>&1" | Tee-Object -Variable buildOutput
if ($?) if ($?)
{ {

View File

@ -1,46 +1,26 @@
#include "../src/pugixml.hpp" #include "../src/pugixml.hpp"
#include "fuzzer/FuzzedDataProvider.h"
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <string>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size)
{ {
FuzzedDataProvider fdp(Data, Size); char* text = new char[Size + 1];
std::string text = fdp.ConsumeRandomLengthString(1024); memcpy(text, Data, Size);
text[Size] = 0;
#ifndef PUGIXML_NO_EXCEPTIONS #ifdef PUGIXML_NO_EXCEPTIONS
pugi::xpath_query q(text);
#else
try try
#endif
{ {
pugi::xpath_variable_set vars; pugi::xpath_query q(text);
size_t var_count = fdp.ConsumeIntegralInRange<size_t>(0, 50);
std::vector<std::string> var_name_storage;
for (size_t i = 0; i < var_count; ++i)
{
var_name_storage.push_back(fdp.ConsumeRandomLengthString(128));
const int xpath_value_type_count = pugi::xpath_type_boolean + 1;
pugi::xpath_value_type value_type = static_cast<pugi::xpath_value_type>(fdp.ConsumeIntegralInRange(0, xpath_value_type_count));
vars.add(var_name_storage.back().c_str(), value_type);
} }
pugi::xpath_query q(text.c_str(), &vars);
std::vector<uint8_t> xml_buffer = fdp.ConsumeBytes<uint8_t>(fdp.ConsumeIntegralInRange(0, 1024));
pugi::xml_document doc;
doc.load_buffer(xml_buffer.data(), xml_buffer.size(), pugi::parse_full);
q.evaluate_boolean(doc);
q.evaluate_number(doc);
q.evaluate_string(doc);
q.evaluate_node(doc);
q.evaluate_node_set(doc);
}
#ifndef PUGIXML_NO_EXCEPTIONS
catch (pugi::xpath_exception&) catch (pugi::xpath_exception&)
{ {
} }
#endif #endif
delete[] text;
return 0; return 0;
} }

View File

@ -5,7 +5,8 @@
#include <utility> #include <utility>
template <typename T> static void generic_bool_ops_test(const T& obj) template <typename T>
static void generic_bool_ops_test(const T& obj)
{ {
T null; T null;
@ -33,7 +34,8 @@ template <typename T> static void generic_bool_ops_test(const T& obj)
CHECK(obj || obj); CHECK(obj || obj);
} }
template <typename T> static void generic_eq_ops_test(const T& obj1, const T& obj2) template <typename T>
static void generic_eq_ops_test(const T& obj1, const T& obj2)
{ {
T null = T(); T null = T();
@ -54,7 +56,8 @@ template <typename T> static void generic_eq_ops_test(const T& obj1, const T& ob
CHECK(!(T(obj1) != obj1)); CHECK(!(T(obj1) != obj1));
} }
template <typename T> static void generic_rel_ops_test(T obj1, T obj2) template <typename T>
static void generic_rel_ops_test(T obj1, T obj2)
{ {
T null = T(); T null = T();
@ -103,7 +106,8 @@ template <typename T> static void generic_rel_ops_test(T obj1, T obj2)
CHECK(!(obj1 >= obj2)); CHECK(!(obj1 >= obj2));
} }
template <typename T> static void generic_empty_test(const T& obj) template <typename T>
static void generic_empty_test(const T& obj)
{ {
T null; T null;

View File

@ -1,10 +1,10 @@
#include "test.hpp"
#include "allocator.hpp" #include "allocator.hpp"
#include "test.hpp"
#include <assert.h>
#include <float.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <float.h>
#include <assert.h>
#include <string> #include <string>
@ -41,7 +41,8 @@ static void* custom_allocate(size_t size)
else else
{ {
void* ptr = memory_allocate(size); void* ptr = memory_allocate(size);
if (!ptr) return 0; if (!ptr)
return 0;
g_memory_total_size += memory_size(ptr); g_memory_total_size += memory_size(ptr);
g_memory_total_count++; g_memory_total_count++;
@ -91,7 +92,7 @@ namespace std
{ {
_CRTIMP2 _Prhand _Raise_handler; _CRTIMP2 _Prhand _Raise_handler;
_CRTIMP2 void __cdecl _Throw(const exception&) {} _CRTIMP2 void __cdecl _Throw(const exception&) {}
} } // namespace std
#endif #endif
static bool run_test(test_runner* test, const char* test_name, pugi::allocation_function allocate) static bool run_test(test_runner* test, const char* test_name, pugi::allocation_function allocate)

View File

@ -5,8 +5,8 @@
#include "writer_string.hpp" #include "writer_string.hpp"
#include <math.h>
#include <float.h> #include <float.h>
#include <math.h>
#include <string.h> #include <string.h>
#include <wchar.h> #include <wchar.h>
@ -33,10 +33,12 @@ static void build_document_order(std::vector<pugi::xpath_node>& result, pugi::xm
cur = cur.next_sibling(); cur = cur.next_sibling();
else else
{ {
while (cur && !cur.next_sibling()) cur = cur.parent(); while (cur && !cur.next_sibling())
cur = cur.parent();
cur = cur.next_sibling(); cur = cur.next_sibling();
if (!cur) break; if (!cur)
break;
} }
} }
} }
@ -83,7 +85,8 @@ static size_t strlength(const pugi::char_t* s)
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_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); pugi::xpath_query q(query, variables);
if (!q) return false; if (!q)
return false;
const size_t capacity = 64; const size_t capacity = 64;
pugi::char_t result[capacity]; pugi::char_t result[capacity];
@ -104,7 +107,8 @@ bool test_xpath_string(const pugi::xpath_node& node, const pugi::char_t* query,
bool test_xpath_boolean(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables, bool 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); pugi::xpath_query q(query, variables);
if (!q) return false; if (!q)
return false;
return q.evaluate_boolean(node) == expected; return q.evaluate_boolean(node) == expected;
} }
@ -112,19 +116,21 @@ bool test_xpath_boolean(const pugi::xpath_node& node, const pugi::char_t* query,
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(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables, double expected)
{ {
pugi::xpath_query q(query, variables); pugi::xpath_query q(query, variables);
if (!q) return false; if (!q)
return false;
double value = q.evaluate_number(node); double value = q.evaluate_number(node);
double absolute_error = fabs(value - expected); double absolute_error = fabs(value - expected);
const double tolerance = 1e-15; const double tolerance = 1e-15f;
return absolute_error < tolerance || absolute_error < fabs(expected) * tolerance; 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) 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); pugi::xpath_query q(query, variables);
if (!q) return false; if (!q)
return false;
return test_double_nan(q.evaluate_number(node)); return test_double_nan(q.evaluate_number(node));
} }
@ -155,12 +161,15 @@ void xpath_node_set_tester::check(bool condition)
} }
} }
xpath_node_set_tester::xpath_node_set_tester(const pugi::xpath_node_set& set, const char* message_): last(0), message(message_) xpath_node_set_tester::xpath_node_set_tester(const pugi::xpath_node_set& set, const char* message_)
: last(0)
, message(message_)
{ {
result = set; result = set;
// only sort unsorted sets so that we're able to verify reverse order for some axes // 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.type() == pugi::xpath_node_set::type_unsorted)
result.sort();
if (result.empty()) if (result.empty())
{ {

View File

@ -36,7 +36,8 @@ struct test_runner
bool test_string_equal(const pugi::char_t* lhs, const pugi::char_t* rhs); bool test_string_equal(const pugi::char_t* lhs, const pugi::char_t* rhs);
template <typename Node> inline bool test_node_name_value(const Node& node, const pugi::char_t* name, const pugi::char_t* value) template <typename Node>
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); return test_string_equal(node.name(), name) && test_string_equal(node.value(), value);
} }
@ -71,7 +72,9 @@ struct xpath_node_set_tester
#endif #endif
struct dummy_fixture {}; struct dummy_fixture
{
};
#define TEST_FIXTURE(name, fixture) \ #define TEST_FIXTURE(name, fixture) \
struct test_runner_helper_##name : fixture \ struct test_runner_helper_##name : fixture \
@ -80,7 +83,10 @@ struct dummy_fixture {};
}; \ }; \
static struct test_runner_##name : test_runner \ static struct test_runner_##name : test_runner \
{ \ { \
test_runner_##name(): test_runner(#name) {} \ test_runner_##name() \
: test_runner(#name) \
{ \
} \
\ \
virtual void run() PUGIXML_OVERRIDE \ virtual void run() PUGIXML_OVERRIDE \
{ \ { \
@ -113,7 +119,11 @@ struct dummy_fixture {};
#define CHECK_JOIN(text, file, line) text " at " file ":" #line #define CHECK_JOIN(text, file, line) text " at " file ":" #line
#define CHECK_JOIN2(text, file, line) CHECK_JOIN(text, 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_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) #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) #if (defined(_MSC_VER) && _MSC_VER == 1200) || defined(__MWERKS__) || (defined(__BORLANDC__) && __BORLANDC__ <= 0x540)
@ -147,9 +157,29 @@ struct dummy_fixture {};
#endif #endif
#ifdef PUGIXML_NO_EXCEPTIONS #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) #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 #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) #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 #endif
#define STR(text) PUGIXML_TEXT(text) #define STR(text) PUGIXML_TEXT(text)

View File

@ -15,18 +15,19 @@
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <string>
#include <algorithm> #include <algorithm>
#include <string>
#ifndef PUGIXML_NO_EXCEPTIONS #ifndef PUGIXML_NO_EXCEPTIONS
#include <stdexcept> #include <stdexcept>
#endif #endif
// for unlink #ifdef __MINGW32__
#ifdef _WIN32 #include <io.h> // for unlink in C++0x mode
# include <io.h> #endif
#else
# include <unistd.h> #if defined(__CELLOS_LV2__) || defined(ANDROID) || defined(_GLIBCXX_HAVE_UNISTD_H) || defined(__APPLE__)
#include <unistd.h> // for unlink
#endif #endif
using namespace pugi; using namespace pugi;
@ -34,7 +35,8 @@ using namespace pugi;
static bool load_file_in_memory(const char* path, char*& data, size_t& size) static bool load_file_in_memory(const char* path, char*& data, size_t& size)
{ {
FILE* file = fopen(path, "rb"); FILE* file = fopen(path, "rb");
if (!file) return false; if (!file)
return false;
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
long length = ftell(file); long length = ftell(file);
@ -54,7 +56,8 @@ static bool test_file_contents(const char* path, const char* data, size_t size)
{ {
char* fdata; char* fdata;
size_t fsize; size_t fsize;
if (!load_file_in_memory(path, fdata, fsize)) return false; if (!load_file_in_memory(path, fdata, fsize))
return false;
bool result = (size == fsize && memcmp(data, fdata, size) == 0); bool result = (size == fsize && memcmp(data, fdata, size) == 0);
@ -198,7 +201,8 @@ TEST(document_load_stream_wide_error_previous)
CHECK(!doc.first_child()); CHECK(!doc.first_child());
} }
template <typename T> class char_array_buffer: public std::basic_streambuf<T> template <typename T>
class char_array_buffer : public std::basic_streambuf<T>
{ {
public: public:
char_array_buffer(T* begin, T* end) char_array_buffer(T* begin, T* end)
@ -233,7 +237,8 @@ TEST(document_load_stream_nonseekable_large)
{ {
std::basic_string<char_t> str; std::basic_string<char_t> str;
str += STR("<node>"); str += STR("<node>");
for (int i = 0; i < 10000; ++i) str += STR("<node/>"); for (int i = 0; i < 10000; ++i)
str += STR("<node/>");
str += STR("</node>"); str += STR("</node>");
char_array_buffer<char_t> buffer(&str[0], &str[0] + str.length()); char_array_buffer<char_t> buffer(&str[0], &str[0] + str.length());
@ -272,7 +277,8 @@ TEST(document_load_stream_nonseekable_out_of_memory_large)
{ {
std::basic_string<char> str; std::basic_string<char> str;
str += "<node>"; str += "<node>";
for (int i = 0; i < 10000; ++i) str += "<node />"; for (int i = 0; i < 10000; ++i)
str += "<node />";
str += "</node>"; str += "</node>";
char_array_buffer<char> buffer(&str[0], &str[0] + str.length()); char_array_buffer<char> buffer(&str[0], &str[0] + str.length());
@ -288,7 +294,8 @@ TEST(document_load_stream_wide_nonseekable_out_of_memory_large)
{ {
std::basic_string<wchar_t> str; std::basic_string<wchar_t> str;
str += L"<node>"; str += L"<node>";
for (int i = 0; i < 10000; ++i) str += L"<node />"; for (int i = 0; i < 10000; ++i)
str += L"<node />";
str += L"</node>"; str += L"</node>";
char_array_buffer<wchar_t> buffer(&str[0], &str[0] + str.length()); char_array_buffer<wchar_t> buffer(&str[0], &str[0] + str.length());
@ -300,12 +307,14 @@ TEST(document_load_stream_wide_nonseekable_out_of_memory_large)
CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory)); CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory));
} }
template <typename T> class seek_fail_buffer: public std::basic_streambuf<T> template <typename T>
class seek_fail_buffer : public std::basic_streambuf<T>
{ {
public: public:
int seeks; int seeks;
seek_fail_buffer(): seeks(0) seek_fail_buffer()
: seeks(0)
{ {
} }
@ -336,12 +345,14 @@ TEST(document_load_stream_wide_seekable_fail_seek)
CHECK(doc.load(in).status == status_io_error); CHECK(doc.load(in).status == status_io_error);
} }
template <typename T> class tell_fail_buffer: public std::basic_streambuf<T> template <typename T>
class tell_fail_buffer : public std::basic_streambuf<T>
{ {
public: public:
int seeks; int seeks;
tell_fail_buffer(): seeks(0) tell_fail_buffer()
: seeks(0)
{ {
} }
@ -377,7 +388,8 @@ TEST(document_load_stream_wide_seekable_fail_tell)
} }
#ifndef PUGIXML_NO_EXCEPTIONS #ifndef PUGIXML_NO_EXCEPTIONS
template <typename T> class read_fail_buffer: public std::basic_streambuf<T> template <typename T>
class read_fail_buffer : public std::basic_streambuf<T>
{ {
public: public:
typename std::basic_streambuf<T>::int_type underflow() PUGIXML_OVERRIDE typename std::basic_streambuf<T>::int_type underflow() PUGIXML_OVERRIDE
@ -408,12 +420,14 @@ TEST(document_load_stream_wide_nonseekable_fail_read)
CHECK(doc.load(in).status == status_io_error); CHECK(doc.load(in).status == status_io_error);
} }
template <typename T> class read_fail_seekable_buffer: public std::basic_streambuf<T> template <typename T>
class read_fail_seekable_buffer : public std::basic_streambuf<T>
{ {
public: public:
typename std::basic_streambuf<T>::pos_type offset; typename std::basic_streambuf<T>::pos_type offset;
read_fail_seekable_buffer(): offset(0) read_fail_seekable_buffer()
: offset(0)
{ {
} }
@ -430,9 +444,15 @@ public:
{ {
switch (dir) switch (dir)
{ {
case std::ios_base::beg: offset = off; break; case std::ios_base::beg:
case std::ios_base::cur: offset += off; break; offset = off;
case std::ios_base::end: offset = 16 + off; break; break;
case std::ios_base::cur:
offset += off;
break;
case std::ios_base::end:
offset = 16 + off;
break;
default:; default:;
} }
return offset; return offset;
@ -497,7 +517,8 @@ TEST(document_load_file_large)
std::basic_string<char_t> str; std::basic_string<char_t> str;
str += STR("<node>"); str += STR("<node>");
for (int i = 0; i < 10000; ++i) str += STR("<node/>"); for (int i = 0; i < 10000; ++i)
str += STR("<node/>");
str += STR("</node>"); str += STR("</node>");
CHECK_NODE(doc, str.c_str()); CHECK_NODE(doc, str.c_str());
@ -594,7 +615,9 @@ TEST(document_load_file_special_folder)
{ {
xml_document doc; xml_document doc;
xml_parse_result result = doc.load_file("."); xml_parse_result result = doc.load_file(".");
CHECK(result.status == status_io_error); // status_out_of_memory is somewhat counter-intuitive but on Linux ftell returns LONG_MAX for directories
// on some Debian systems the folder is also read as empty, hence status_no_document_element check
CHECK(result.status == status_file_not_found || result.status == status_io_error || result.status == status_out_of_memory || result.status == status_no_document_element);
} }
#endif #endif
@ -736,12 +759,7 @@ struct temp_file
temp_file() temp_file()
{ {
static int index = 0; static int index = 0;
#if __cplusplus >= 201103 || defined(__APPLE__) // Xcode 14 warns about use of sprintf in C++98 builds
snprintf(path, sizeof(path), "%stempfile%d", test_runner::_temp_path, index++);
#else
sprintf(path, "%stempfile%d", test_runner::_temp_path, index++); sprintf(path, "%stempfile%d", test_runner::_temp_path, index++);
#endif
} }
~temp_file() ~temp_file()
@ -943,8 +961,7 @@ TEST(document_load_file_convert_auto)
"tests/data/utftest_utf32_le_nodecl.xml", "tests/data/utftest_utf32_le_nodecl.xml",
"tests/data/utftest_utf8.xml", "tests/data/utftest_utf8.xml",
"tests/data/utftest_utf8_bom.xml", "tests/data/utftest_utf8_bom.xml",
"tests/data/utftest_utf8_nodecl.xml" "tests/data/utftest_utf8_nodecl.xml"};
};
xml_encoding encodings[] = xml_encoding encodings[] =
{ {
@ -952,8 +969,7 @@ TEST(document_load_file_convert_auto)
encoding_utf16_le, encoding_utf16_le, encoding_utf16_le, encoding_utf16_le, encoding_utf16_le, encoding_utf16_le,
encoding_utf32_be, encoding_utf32_be, encoding_utf32_be, encoding_utf32_be, encoding_utf32_be, encoding_utf32_be,
encoding_utf32_le, encoding_utf32_le, encoding_utf32_le, encoding_utf32_le, encoding_utf32_le, encoding_utf32_le,
encoding_utf8, encoding_utf8, encoding_utf8 encoding_utf8, encoding_utf8, encoding_utf8};
};
for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i) for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i)
{ {
@ -984,8 +1000,7 @@ TEST(document_load_file_convert_specific)
"tests/data/utftest_utf32_le_nodecl.xml", "tests/data/utftest_utf32_le_nodecl.xml",
"tests/data/utftest_utf8.xml", "tests/data/utftest_utf8.xml",
"tests/data/utftest_utf8_bom.xml", "tests/data/utftest_utf8_bom.xml",
"tests/data/utftest_utf8_nodecl.xml" "tests/data/utftest_utf8_nodecl.xml"};
};
xml_encoding encodings[] = xml_encoding encodings[] =
{ {
@ -993,8 +1008,7 @@ TEST(document_load_file_convert_specific)
encoding_utf16_le, encoding_utf16_le, encoding_utf16_le, encoding_utf16_le, encoding_utf16_le, encoding_utf16_le,
encoding_utf32_be, encoding_utf32_be, encoding_utf32_be, encoding_utf32_be, encoding_utf32_be, encoding_utf32_be,
encoding_utf32_le, encoding_utf32_le, encoding_utf32_le, encoding_utf32_le, encoding_utf32_le, encoding_utf32_le,
encoding_utf8, encoding_utf8, encoding_utf8 encoding_utf8, encoding_utf8, encoding_utf8};
};
for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i) for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i)
{ {
@ -1039,14 +1053,12 @@ TEST(document_load_file_convert_native_endianness)
"tests/data/utftest_utf32_le.xml", "tests/data/utftest_utf32_le.xml",
"tests/data/utftest_utf32_le_bom.xml", "tests/data/utftest_utf32_le_bom.xml",
"tests/data/utftest_utf32_le_nodecl.xml", "tests/data/utftest_utf32_le_nodecl.xml",
} }};
};
xml_encoding encodings[] = xml_encoding encodings[] =
{ {
encoding_utf16, encoding_utf16, encoding_utf16, encoding_utf16, encoding_utf16, encoding_utf16,
encoding_utf32, encoding_utf32, encoding_utf32 encoding_utf32, encoding_utf32, encoding_utf32};
};
for (unsigned int i = 0; i < sizeof(files[0]) / sizeof(files[0][0]); ++i) for (unsigned int i = 0; i < sizeof(files[0]) / sizeof(files[0][0]); ++i)
{ {
@ -1093,7 +1105,6 @@ struct file_data_t
size_t size; size_t size;
}; };
TEST(document_contents_preserve) TEST(document_contents_preserve)
{ {
file_data_t files[] = file_data_t files[] =
@ -1102,8 +1113,7 @@ TEST(document_contents_preserve)
{"tests/data/utftest_utf16_le_clean.xml", encoding_utf16_le, 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_be_clean.xml", encoding_utf32_be, 0, 0},
{"tests/data/utftest_utf32_le_clean.xml", encoding_utf32_le, 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/utftest_utf8_clean.xml", encoding_utf8, 0, 0}};
};
// load files in memory // load files in memory
for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i) for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i)
@ -1137,8 +1147,7 @@ TEST(document_contents_preserve_latin1)
file_data_t files[] = file_data_t files[] =
{ {
{"tests/data/latintest_utf8.xml", encoding_utf8, 0, 0}, {"tests/data/latintest_utf8.xml", encoding_utf8, 0, 0},
{"tests/data/latintest_latin1.xml", encoding_latin1, 0, 0} {"tests/data/latintest_latin1.xml", encoding_latin1, 0, 0}};
};
// load files in memory // load files in memory
for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i) for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i)
@ -1228,8 +1237,7 @@ TEST(document_load_buffer_empty)
encoding_utf32_be, encoding_utf32_be,
encoding_utf32, encoding_utf32,
encoding_wchar, encoding_wchar,
encoding_latin1 encoding_latin1};
};
char buffer[1]; char buffer[1];
@ -1264,8 +1272,7 @@ TEST(document_load_buffer_empty_fragment)
encoding_utf32_be, encoding_utf32_be,
encoding_utf32, encoding_utf32,
encoding_wchar, encoding_wchar,
encoding_latin1 encoding_latin1};
};
char buffer[1]; char buffer[1];
@ -1397,7 +1404,8 @@ TEST(document_load_exceptions)
try try
{ {
xml_document doc; xml_document doc;
if (!doc.load_string(STR("<node attribute='value"))) throw std::bad_alloc(); if (!doc.load_string(STR("<node attribute='value")))
throw std::bad_alloc();
CHECK_FORCE_FAIL("Expected parsing failure"); CHECK_FORCE_FAIL("Expected parsing failure");
} }
@ -1602,8 +1610,7 @@ TEST(document_convert_out_of_memory)
{"tests/data/utftest_utf32_be_clean.xml", encoding_utf32_be, 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_utf32_le_clean.xml", encoding_utf32_le, 0, 0},
{"tests/data/utftest_utf8_clean.xml", encoding_utf8, 0, 0}, {"tests/data/utftest_utf8_clean.xml", encoding_utf8, 0, 0},
{"tests/data/latintest_latin1.xml", encoding_latin1, 0, 0} {"tests/data/latintest_latin1.xml", encoding_latin1, 0, 0}};
};
// load files in memory // load files in memory
for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i) for (unsigned int i = 0; i < sizeof(files) / sizeof(files[0]); ++i)
@ -1810,51 +1817,4 @@ TEST(document_move_compact_fail)
CHECK(!docs[safe_count + 1].first_child()); CHECK(!docs[safe_count + 1].first_child());
} }
#endif #endif
TEST(document_move_assign_empty)
{
xml_document doc;
doc.append_child(STR("node"));
doc = xml_document();
doc.append_child(STR("node2"));
CHECK_NODE(doc, STR("<node2/>"));
}
#endif #endif
TEST(document_load_buffer_convert_out_of_memory)
{
const char* source = "<node>\xe7</node>";
size_t size = strlen(source);
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_buffer(source, size, pugi::parse_default, pugi::encoding_latin1));
CHECK(result.status == status_out_of_memory);
}
TEST(document_load_buffer_own_convert_out_of_memory)
{
const char* source = "<node>\xe7</node>";
size_t size = strlen(source);
void* buffer = pugi::get_memory_allocation_function()(size);
CHECK(buffer);
memcpy(buffer, source, size);
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_buffer_inplace_own(buffer, size, pugi::parse_default, pugi::encoding_latin1));
CHECK(result.status == status_out_of_memory);
}

View File

@ -3,9 +3,9 @@
#include <limits> #include <limits>
#include <string> #include <string>
#include <limits.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <limits.h>
using namespace pugi; using namespace pugi;
@ -46,16 +46,6 @@ TEST_XML(dom_attr_set_name, "<node attr='value' />")
CHECK_NODE(doc, STR("<node n=\"value\"/>")); CHECK_NODE(doc, STR("<node n=\"value\"/>"));
} }
TEST_XML(dom_attr_set_name_with_size, "<node attr='value' />")
{
xml_attribute attr = doc.child(STR("node")).attribute(STR("attr"));
CHECK(attr.set_name(STR("n1234"), 1));
CHECK(!xml_attribute().set_name(STR("nfail"), 1));
CHECK_NODE(doc, STR("<node n=\"value\"/>"));
}
TEST_XML(dom_attr_set_value, "<node/>") TEST_XML(dom_attr_set_value, "<node/>")
{ {
xml_node node = doc.child(STR("node")); xml_node node = doc.child(STR("node"));
@ -80,13 +70,7 @@ TEST_XML(dom_attr_set_value, "<node/>")
CHECK(node.append_attribute(STR("attr8")).set_value(true)); CHECK(node.append_attribute(STR("attr8")).set_value(true));
CHECK(!xml_attribute().set_value(true)); CHECK(!xml_attribute().set_value(true));
CHECK(node.append_attribute(STR("attr9")).set_value(STR("v2"), 2)); CHECK_NODE(node, STR("<node attr1=\"v1\" attr2=\"-2147483647\" attr3=\"-2147483648\" attr4=\"4294967295\" attr5=\"4294967294\" attr6=\"0.5\" attr7=\"0.25\" attr8=\"true\"/>"));
CHECK(!xml_attribute().set_value(STR("v2")));
CHECK(node.append_attribute(STR("attr10")).set_value(STR("v3foobar"), 2));
CHECK(!xml_attribute().set_value(STR("v3")));
CHECK_NODE(node, STR("<node attr1=\"v1\" attr2=\"-2147483647\" attr3=\"-2147483648\" attr4=\"4294967295\" attr5=\"4294967294\" attr6=\"0.5\" attr7=\"0.25\" attr8=\"true\" attr9=\"v2\" attr10=\"v3\"/>"));
} }
#if LONG_MAX > 2147483647 #if LONG_MAX > 2147483647
@ -216,15 +200,6 @@ TEST_XML(dom_node_set_name, "<node>text</node>")
CHECK_NODE(doc, STR("<n>text</n>")); CHECK_NODE(doc, STR("<n>text</n>"));
} }
TEST_XML(dom_node_set_name_with_size, "<node>text</node>")
{
CHECK(doc.child(STR("node")).set_name(STR("nlongname"), 1));
CHECK(!doc.child(STR("node")).first_child().set_name(STR("n42"), 1));
CHECK(!xml_node().set_name(STR("nanothername"), 1));
CHECK_NODE(doc, STR("<n>text</n>"));
}
TEST_XML(dom_node_set_value, "<node>text</node>") TEST_XML(dom_node_set_value, "<node>text</node>")
{ {
CHECK(doc.child(STR("node")).first_child().set_value(STR("no text"))); CHECK(doc.child(STR("node")).first_child().set_value(STR("no text")));
@ -234,24 +209,6 @@ TEST_XML(dom_node_set_value, "<node>text</node>")
CHECK_NODE(doc, STR("<node>no text</node>")); CHECK_NODE(doc, STR("<node>no text</node>"));
} }
TEST_XML(dom_node_set_value_partially_with_size, "<node>text</node>")
{
CHECK(doc.child(STR("node")).first_child().set_value(STR("no text"), 2));
CHECK(!doc.child(STR("node")).set_value(STR("no text"), 2));
CHECK(!xml_node().set_value(STR("no text"), 2));
CHECK_NODE(doc, STR("<node>no</node>"));
}
TEST_XML(dom_node_set_value_with_size, "<node>text</node>")
{
CHECK(doc.child(STR("node")).first_child().set_value(STR("no text"), 7));
CHECK(!doc.child(STR("node")).set_value(STR("no text"), 7));
CHECK(!xml_node().set_value(STR("no text"), 7));
CHECK_NODE(doc, STR("<node>no text</node>"));
}
TEST_XML(dom_node_set_value_allocated, "<node>text</node>") TEST_XML(dom_node_set_value_allocated, "<node>text</node>")
{ {
CHECK(doc.child(STR("node")).first_child().set_value(STR("no text"))); CHECK(doc.child(STR("node")).first_child().set_value(STR("no text")));
@ -535,36 +492,6 @@ TEST_XML(dom_node_remove_attribute, "<node a1='v1' a2='v2' a3='v3'><child a4='v4
CHECK_NODE(doc, STR("<node a2=\"v2\"><child/></node>")); CHECK_NODE(doc, STR("<node a2=\"v2\"><child/></node>"));
} }
TEST_XML(dom_node_remove_attributes, "<node a1='v1' a2='v2' a3='v3'><child a4='v4'/></node>")
{
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("<child/>"));
CHECK(node.remove_attributes());
CHECK_NODE(node, STR("<node><child/></node>"));
}
TEST_XML(dom_node_remove_attributes_lots, "<node/>")
{
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("<node/>"));
}
TEST_XML(dom_node_prepend_child, "<node>foo<child/></node>") TEST_XML(dom_node_prepend_child, "<node>foo<child/></node>")
{ {
CHECK(xml_node().prepend_child() == xml_node()); CHECK(xml_node().prepend_child() == xml_node());
@ -780,36 +707,6 @@ TEST_XML(dom_node_remove_child, "<node><n1/><n2/><n3/><child><n4/></child></node
CHECK_NODE(doc, STR("<node><n2/><child/></node>")); CHECK_NODE(doc, STR("<node><n2/><child/></node>"));
} }
TEST_XML(dom_node_remove_children, "<node><n1/><n2/><n3/><child><n4/></child></node>")
{
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("<child/>"));
CHECK(node.remove_children());
CHECK_NODE(node, STR("<node/>"));
}
TEST_XML(dom_node_remove_children_lots, "<node/>")
{
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("<node/>"));
}
TEST_XML(dom_node_remove_child_complex, "<node id='1'><n1 id1='1' id2='2'/><n2/><n3/><child><n4/></child></node>") TEST_XML(dom_node_remove_child_complex, "<node id='1'><n1 id1='1' id2='2'/><n2/><n3/><child><n4/></child></node>")
{ {
CHECK(doc.child(STR("node")).remove_child(STR("n1"))); CHECK(doc.child(STR("node")).remove_child(STR("n1")));
@ -1029,7 +926,8 @@ TEST(dom_string_out_of_memory)
const unsigned int length = 65536; const unsigned int length = 65536;
static char_t string[length + 1]; static char_t string[length + 1];
for (unsigned int i = 0; i < length; ++i) string[i] = 'a'; for (unsigned int i = 0; i < length; ++i)
string[i] = 'a';
string[length] = 0; string[length] = 0;
xml_document doc; xml_document doc;
@ -1108,7 +1006,8 @@ TEST(dom_node_memory_limit)
const unsigned int length = 65536; const unsigned int length = 65536;
static char_t string[length + 1]; static char_t string[length + 1];
for (unsigned int i = 0; i < length; ++i) string[i] = 'a'; for (unsigned int i = 0; i < length; ++i)
string[i] = 'a';
string[length] = 0; string[length] = 0;
test_runner::_memory_fail_threshold = 32768 * 2 + sizeof(string); test_runner::_memory_fail_threshold = 32768 * 2 + sizeof(string);
@ -1127,7 +1026,8 @@ TEST(dom_node_memory_limit_pi)
const unsigned int length = 65536; const unsigned int length = 65536;
static char_t string[length + 1]; static char_t string[length + 1];
for (unsigned int i = 0; i < length; ++i) string[i] = 'a'; for (unsigned int i = 0; i < length; ++i)
string[i] = 'a';
string[length] = 0; string[length] = 0;
test_runner::_memory_fail_threshold = 32768 * 2 + sizeof(string); test_runner::_memory_fail_threshold = 32768 * 2 + sizeof(string);
@ -1215,7 +1115,6 @@ TEST_XML(dom_node_append_buffer_convert, "<node>test</node>")
CHECK_NODE(doc, STR("<node>test<n/><n/></node>")); CHECK_NODE(doc, STR("<node>test<n/><n/></node>"));
} }
TEST_XML(dom_node_append_buffer_remove, "<node>test</node>") TEST_XML(dom_node_append_buffer_remove, "<node>test</node>")
{ {
xml_node node = doc.child(STR("node")); xml_node node = doc.child(STR("node"));
@ -1230,15 +1129,21 @@ TEST_XML(dom_node_append_buffer_remove, "<node>test</node>")
CHECK_NODE(doc, STR("<node>test<child1 id=\"1\"/><child2>text</child2><child3/><child1 id=\"1\"/><child2>text</child2><child3/></node>")); CHECK_NODE(doc, STR("<node>test<child1 id=\"1\"/><child2>text</child2><child3/><child1 id=\"1\"/><child2>text</child2><child3/></node>"));
while (node.remove_child(STR("child2"))) {} while (node.remove_child(STR("child2")))
{
}
CHECK_NODE(doc, STR("<node>test<child1 id=\"1\"/><child3/><child1 id=\"1\"/><child3/></node>")); CHECK_NODE(doc, STR("<node>test<child1 id=\"1\"/><child3/><child1 id=\"1\"/><child3/></node>"));
while (node.remove_child(STR("child1"))) {} while (node.remove_child(STR("child1")))
{
}
CHECK_NODE(doc, STR("<node>test<child3/><child3/></node>")); CHECK_NODE(doc, STR("<node>test<child3/><child3/></node>"));
while (node.remove_child(STR("child3"))) {} while (node.remove_child(STR("child3")))
{
}
CHECK_NODE(doc, STR("<node>test</node>")); CHECK_NODE(doc, STR("<node>test</node>"));
@ -1768,7 +1673,8 @@ TEST(dom_node_copy_declaration_empty_name)
CHECK_STRING(decl2.name(), STR("")); CHECK_STRING(decl2.name(), STR(""));
} }
template <typename T> bool fp_equal(T lhs, T rhs) template <typename T>
bool fp_equal(T lhs, T rhs)
{ {
// Several compilers compare float/double values on x87 stack without proper rounding // Several compilers compare float/double values on x87 stack without proper rounding
// This causes roundtrip tests to fail, although they correctly preserve the data. // This causes roundtrip tests to fail, although they correctly preserve the data.
@ -1805,31 +1711,6 @@ TEST(dom_fp_roundtrip_min_max_double)
CHECK(fp_equal(node.text().as_double(), std::numeric_limits<double>::max())); CHECK(fp_equal(node.text().as_double(), std::numeric_limits<double>::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<double>::min(), 20);
CHECK(fp_equal(attr.as_double(), std::numeric_limits<double>::min()));
attr.set_value(1.0f, 5);
CHECK(fp_equal(attr.as_double(), static_cast<double>(1.0f)));
attr.set_value(3.1415926f, 3);
CHECK(!fp_equal(attr.as_double(), static_cast<double>(3.1415926f)));
node.text().set(1.0f, 5);
CHECK(fp_equal(node.text().as_double(), static_cast<double>(1.0f)));
node.text().set(3.1415926f, 3);
CHECK(!fp_equal(node.text().as_double(), static_cast<double>(3.1415926f)));
node.text().set(std::numeric_limits<double>::max(), 20);
CHECK(fp_equal(node.text().as_double(), std::numeric_limits<double>::max()));
}
const double fp_roundtrip_base[] = const double fp_roundtrip_base[] =
{ {
0.31830988618379067154, 0.31830988618379067154,

View File

@ -124,12 +124,12 @@ TEST_XML(dom_text_as_float, "<node><text1>0</text1><text2>1</text2><text3>0.12</
xml_node node = doc.child(STR("node")); xml_node node = doc.child(STR("node"));
CHECK(xml_text().as_float() == 0); CHECK(xml_text().as_float() == 0);
CHECK_DOUBLE(double(node.child(STR("text1")).text().as_float()), 0); CHECK_DOUBLE(node.child(STR("text1")).text().as_float(), 0);
CHECK_DOUBLE(double(node.child(STR("text2")).text().as_float()), 1); CHECK_DOUBLE(node.child(STR("text2")).text().as_float(), 1);
CHECK_DOUBLE(double(node.child(STR("text3")).text().as_float()), 0.12); CHECK_DOUBLE(node.child(STR("text3")).text().as_float(), 0.12);
CHECK_DOUBLE(double(node.child(STR("text4")).text().as_float()), -5.1); CHECK_DOUBLE(node.child(STR("text4")).text().as_float(), -5.1);
CHECK_DOUBLE(double(node.child(STR("text5")).text().as_float()), 3e-4); CHECK_DOUBLE(node.child(STR("text5")).text().as_float(), 3e-4);
CHECK_DOUBLE(double(node.child(STR("text6")).text().as_float()), 3.14159265358979323846); CHECK_DOUBLE(node.child(STR("text6")).text().as_float(), 3.14159265358979323846);
} }
TEST_XML(dom_text_as_double, "<node><text1>0</text1><text2>1</text2><text3>0.12</text3><text4>-5.1</text4><text5>3e-4</text5><text6>3.14159265358979323846</text6></node>") TEST_XML(dom_text_as_double, "<node><text1>0</text1><text2>1</text2><text3>0.12</text3><text4>-5.1</text4><text5>3e-4</text5><text6>3.14159265358979323846</text6></node>")
@ -247,58 +247,6 @@ TEST_XML(dom_text_set, "<node/>")
CHECK(node.first_child().type() == node_pcdata); CHECK(node.first_child().type() == node_pcdata);
CHECK(node.first_child() == node.last_child()); CHECK(node.first_child() == node.last_child());
CHECK_NODE(node, STR("<node>foobarfoobar</node>")); CHECK_NODE(node, STR("<node>foobarfoobar</node>"));
t.set(STR(""));
CHECK(node.first_child().type() == node_pcdata);
CHECK_NODE(node, STR("<node></node>"));
}
TEST_XML(dom_text_set_with_size, "<node/>")
{
xml_node node = doc.child(STR("node"));
xml_text t = node.text();
t.set(STR(""), 0);
CHECK(node.first_child().type() == node_pcdata);
CHECK_NODE(node, STR("<node></node>"));
t.set(STR("boo"), 3);
CHECK(node.first_child().type() == node_pcdata);
CHECK(node.first_child() == node.last_child());
CHECK_NODE(node, STR("<node>boo</node>"));
t.set(STR("foobarfoobar"), 12);
CHECK(node.first_child().type() == node_pcdata);
CHECK(node.first_child() == node.last_child());
CHECK_NODE(node, STR("<node>foobarfoobar</node>"));
t.set(STR(""), 0);
CHECK(node.first_child().type() == node_pcdata);
CHECK_NODE(node, STR("<node></node>"));
}
TEST_XML(dom_text_set_partially_with_size, "<node/>")
{
xml_node node = doc.child(STR("node"));
xml_text t = node.text();
t.set(STR("foo"), 0);
CHECK(node.first_child().type() == node_pcdata);
CHECK_NODE(node, STR("<node></node>"));
t.set(STR("boofoo"), 3);
CHECK(node.first_child().type() == node_pcdata);
CHECK(node.first_child() == node.last_child());
CHECK_NODE(node, STR("<node>boo</node>"));
t.set(STR("foobarfoobar"), 3);
CHECK(node.first_child().type() == node_pcdata);
CHECK(node.first_child() == node.last_child());
CHECK_NODE(node, STR("<node>foo</node>"));
t.set(STR("foo"), 0);
CHECK(node.first_child().type() == node_pcdata);
CHECK_NODE(node, STR("<node></node>"));
} }
TEST_XML(dom_text_assign, "<node/>") TEST_XML(dom_text_assign, "<node/>")

View File

@ -4,28 +4,34 @@
#include "test.hpp" #include "test.hpp"
#include <string.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <wchar.h> #include <wchar.h>
#include <utility>
#include <vector>
#include <iterator> #include <iterator>
#include <string> #include <string>
#include <utility>
#include <vector>
#include "helpers.hpp" #include "helpers.hpp"
using namespace pugi; using namespace pugi;
#ifdef PUGIXML_NO_STL #ifdef PUGIXML_NO_STL
template <typename I> static I move_iter(I base, int n) template <typename I>
static I move_iter(I base, int n)
{ {
if (n > 0) while (n--) ++base; if (n > 0)
else while (n++) --base; while (n--)
++base;
else
while (n++)
--base;
return base; return base;
} }
#else #else
template <typename I> static I move_iter(I base, int n) template <typename I>
static I move_iter(I base, int n)
{ {
std::advance(base, n); std::advance(base, n);
return base; return base;
@ -150,12 +156,12 @@ TEST_XML(dom_attr_as_float, "<node attr1='0' attr2='1' attr3='0.12' attr4='-5.1'
xml_node node = doc.child(STR("node")); xml_node node = doc.child(STR("node"));
CHECK(xml_attribute().as_float() == 0); CHECK(xml_attribute().as_float() == 0);
CHECK_DOUBLE(double(node.attribute(STR("attr1")).as_float()), 0); CHECK_DOUBLE(node.attribute(STR("attr1")).as_float(), 0);
CHECK_DOUBLE(double(node.attribute(STR("attr2")).as_float()), 1); CHECK_DOUBLE(node.attribute(STR("attr2")).as_float(), 1);
CHECK_DOUBLE(double(node.attribute(STR("attr3")).as_float()), 0.12); CHECK_DOUBLE(node.attribute(STR("attr3")).as_float(), 0.12);
CHECK_DOUBLE(double(node.attribute(STR("attr4")).as_float()), -5.1); CHECK_DOUBLE(node.attribute(STR("attr4")).as_float(), -5.1);
CHECK_DOUBLE(double(node.attribute(STR("attr5")).as_float()), 3e-4); CHECK_DOUBLE(node.attribute(STR("attr5")).as_float(), 3e-4);
CHECK_DOUBLE(double(node.attribute(STR("attr6")).as_float()), 3.14159265358979323846); CHECK_DOUBLE(node.attribute(STR("attr6")).as_float(), 3.14159265358979323846);
} }
TEST_XML(dom_attr_as_double, "<node attr1='0' attr2='1' attr3='0.12' attr4='-5.1' attr5='3e-4' attr6='3.14159265358979323846'/>") TEST_XML(dom_attr_as_double, "<node attr1='0' attr2='1' attr3='0.12' attr4='-5.1' attr5='3e-4' attr6='3.14159265358979323846'/>")
@ -659,11 +665,13 @@ struct find_predicate_const
{ {
bool result; bool result;
find_predicate_const(bool result_): result(result_) find_predicate_const(bool result_)
: result(result_)
{ {
} }
template <typename T> bool operator()(const T&) const template <typename T>
bool operator()(const T&) const
{ {
return result; return result;
} }
@ -673,11 +681,13 @@ struct find_predicate_prefix
{ {
const char_t* prefix; const char_t* prefix;
find_predicate_prefix(const char_t* prefix_): prefix(prefix_) find_predicate_prefix(const char_t* prefix_)
: prefix(prefix_)
{ {
} }
template <typename T> bool operator()(const T& obj) const template <typename T>
bool operator()(const T& obj) const
{ {
#ifdef PUGIXML_WCHAR_MODE #ifdef PUGIXML_WCHAR_MODE
// can't use wcsncmp here because of a bug in DMC // can't use wcsncmp here because of a bug in DMC
@ -788,19 +798,16 @@ struct test_walker: xml_tree_walker
unsigned int call_count; unsigned int call_count;
unsigned int stop_count; unsigned int stop_count;
test_walker(unsigned int stop_count_ = 0): call_count(0), stop_count(stop_count_) test_walker(unsigned int stop_count_ = 0)
: call_count(0)
, stop_count(stop_count_)
{ {
} }
std::basic_string<char_t> depthstr() const std::basic_string<char_t> depthstr() const
{ {
char buf[32]; char buf[32];
#if __cplusplus >= 201103 || defined(__APPLE__) // Xcode 14 warns about use of sprintf in C++98 builds
snprintf(buf, sizeof(buf), "%d", depth());
#else
sprintf(buf, "%d", depth()); sprintf(buf, "%d", depth());
#endif
#ifdef PUGIXML_WCHAR_MODE #ifdef PUGIXML_WCHAR_MODE
wchar_t wbuf[32]; wchar_t wbuf[32];

View File

@ -1,3 +1,2 @@
// Tests header guards // Tests header guards
#include "../src/pugixml.hpp" #include "../src/pugixml.hpp"
#include "../src/pugixml.hpp"

View File

@ -1,3 +1,3 @@
// Tests compatibility with iosfwd // Tests compatibility with iosfwd
#include <iosfwd>
#include "../src/pugixml.hpp" #include "../src/pugixml.hpp"
#include <iosfwd>

View File

@ -1,3 +1,3 @@
// Tests compatibility with iostream // Tests compatibility with iostream
#include <iostream>
#include "../src/pugixml.hpp" #include "../src/pugixml.hpp"
#include <iostream>

View File

@ -5,7 +5,6 @@
// Check header guards // Check header guards
#include "../src/pugixml.hpp" #include "../src/pugixml.hpp"
#include "../src/pugixml.hpp"
using namespace pugi; using namespace pugi;

View File

@ -5,7 +5,6 @@
// Check header guards // Check header guards
#include "../src/pugixml.hpp" #include "../src/pugixml.hpp"
#include "../src/pugixml.hpp"
using namespace pugi; using namespace pugi;

View File

@ -1,3 +1,3 @@
// Tests compatibility with string // Tests compatibility with string
#include <string>
#include "../src/pugixml.hpp" #include "../src/pugixml.hpp"
#include <string>

View File

@ -1,5 +1,5 @@
// Tests compatibility with string/iostream // Tests compatibility with string/iostream
#include <string>
#include "../src/pugixml.hpp" #include "../src/pugixml.hpp"
#include <istream> #include <istream>
#include <ostream> #include <ostream>
#include <string>

View File

@ -1,7 +1,7 @@
#include "test.hpp" #include "test.hpp"
#include "writer_string.hpp"
#include "allocator.hpp" #include "allocator.hpp"
#include "writer_string.hpp"
#include <string> #include <string>
#include <vector> #include <vector>
@ -30,7 +30,7 @@ namespace
page_deallocs += is_page(memory_size(ptr)); page_deallocs += is_page(memory_size(ptr));
memory_deallocate(ptr); memory_deallocate(ptr);
} }
} } // namespace
TEST(memory_custom_memory_management) TEST(memory_custom_memory_management)
{ {
@ -229,7 +229,8 @@ TEST(memory_string_allocate_decreasing)
std::basic_string<char_t> s = STR("ab"); std::basic_string<char_t> s = STR("ab");
for (int i = 0; i < 17; ++i) s += s; for (int i = 0; i < 17; ++i)
s += s;
for (int j = 0; j < 17; ++j) for (int j = 0; j < 17; ++j)
{ {
@ -286,7 +287,8 @@ TEST(memory_string_allocate_decreasing_inplace)
std::basic_string<char_t> s = STR("ab"); std::basic_string<char_t> s = STR("ab");
for (int i = 0; i < 17; ++i) s += s; for (int i = 0; i < 17; ++i)
s += s;
for (int j = 0; j < 17; ++j) for (int j = 0; j < 17; ++j)
{ {

View File

@ -464,8 +464,7 @@ TEST(parse_pcdata_trim)
{STR("<node> test&amp;&amp;&amp;&amp;&amp;&amp;&amp; </node>"), STR("test&amp;&amp;&amp;&amp;&amp;&amp;&amp;"), 0}, {STR("<node> test&amp;&amp;&amp;&amp;&amp;&amp;&amp; </node>"), STR("test&amp;&amp;&amp;&amp;&amp;&amp;&amp;"), 0},
{STR("<node> test&amp;&amp;&amp;&amp;&amp;&amp;&amp; </node>"), STR("test&&&&&&&"), parse_escapes}, {STR("<node> test&amp;&amp;&amp;&amp;&amp;&amp;&amp; </node>"), STR("test&&&&&&&"), parse_escapes},
{STR(" test&amp;&amp;&amp;&amp;&amp;&amp;&amp; "), STR("test&&&&&&&"), parse_fragment | parse_escapes}, {STR(" test&amp;&amp;&amp;&amp;&amp;&amp;&amp; "), STR("test&&&&&&&"), parse_fragment | parse_escapes},
{ STR("<node>\r\n\t text \t\n\r m&amp;&amp;e \r\n\t</node>"), STR("text \t\n\n m&&e"), parse_eol | parse_escapes } {STR("<node>\r\n\t text \t\n\r m&amp;&amp;e \r\n\t</node>"), 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) for (size_t i = 0; i < sizeof(test_data) / sizeof(test_data[0]); ++i)
{ {
@ -696,7 +695,6 @@ TEST(parse_attribute_variations)
} }
} }
TEST(parse_attribute_error) TEST(parse_attribute_error)
{ {
xml_document doc; xml_document doc;
@ -1175,8 +1173,7 @@ TEST(parse_fuzz_doctype)
0x3b, 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0xef, 0xbb, 0xbf, 0x3c, 0x3f, 0x78, 0x3b, 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0xef, 0xbb, 0xbf, 0x3c, 0x3f, 0x78,
0x6d, 0x6c, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22, 0x6d, 0x6c, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x31, 0x2e, 0x30, 0x22,
0x3f, 0x3e, 0x3c, 0x21, 0x2d, 0x2d, 0x20, 0xe9, 0x80, 0xb1, 0xe5, 0xa0, 0xb1, 0xe3, 0x82, 0xb4, 0x3f, 0x3e, 0x3c, 0x21, 0x2d, 0x2d, 0x20, 0xe9, 0x80, 0xb1, 0xe5, 0xa0, 0xb1, 0xe3, 0x82, 0xb4,
0xe3, 0x83, 0xb3, 0x20, 0xef, 0x83, 0x97, 0xe3, 0xa9, 0x2a, 0x20, 0x2d, 0x2d, 0x3e 0xe3, 0x83, 0xb3, 0x20, 0xef, 0x83, 0x97, 0xe3, 0xa9, 0x2a, 0x20, 0x2d, 0x2d, 0x3e};
};
xml_document doc; xml_document doc;
CHECK(doc.load_buffer(data, sizeof(data)).status == status_bad_doctype); CHECK(doc.load_buffer(data, sizeof(data)).status == status_bad_doctype);
@ -1252,112 +1249,6 @@ TEST_XML_FLAGS(parse_embed_pcdata_comment, "<n>text1<!---->text2</n>", parse_emb
CHECK_STRING(n.last_child().value(), STR("text2")); CHECK_STRING(n.last_child().value(), STR("text2"));
} }
TEST(parse_merge_pcdata)
{
unsigned int flag_sets[] = {parse_cdata, parse_pi, parse_comments, parse_declaration};
for (unsigned int i = 0; i < sizeof(flag_sets) / sizeof(flag_sets[0]); ++i)
{
unsigned int flags = parse_merge_pcdata | flag_sets[i];
xml_document doc;
xml_parse_result res = doc.load_string(STR("<node>First text<!-- here is a mesh node -->Second text<![CDATA[someothertext]]>some more text<?include somedata?>Last text</node>"), flags);
CHECK(res);
xml_node child = doc.child(STR("node"));
if (flags & parse_comments)
{
CHECK_STRING(child.first_child().value(), STR("First text"));
CHECK(child.first_child().next_sibling().type() == node_comment);
CHECK_NODE(doc, STR("<node>First text<!-- here is a mesh node -->Second textsome more textLast text</node>"));
}
else if (flags & parse_cdata)
{
CHECK_STRING(child.first_child().value(), STR("First textSecond text"));
CHECK(child.first_child().next_sibling().type() == node_cdata);
CHECK_NODE(doc, STR("<node>First textSecond text<![CDATA[someothertext]]>some more textLast text</node>"));
}
else if (flags & parse_pi)
{
CHECK_STRING(child.first_child().value(), STR("First textSecond textsome more text"));
CHECK(child.first_child().next_sibling().type() == node_pi);
CHECK_NODE(doc, STR("<node>First textSecond textsome more text<?include somedata?>Last text</node>"));
}
else
{
CHECK(child.first_child() == child.last_child());
CHECK(child.first_child().type() == node_pcdata);
CHECK_NODE(doc, STR("<node>First textSecond textsome more textLast text</node>"));
}
CHECK(child.last_child().type() == node_pcdata);
}
}
TEST(parse_merge_pcdata_escape)
{
xml_document doc;
xml_parse_result res = doc.load_string(STR("<node>First &amp;lt; <!-- comment 1 --> Second &amp;gt; <!-- comment 2 --> Third &amp;quot;</node>"), parse_default | parse_merge_pcdata);
CHECK(res);
CHECK_STRING(doc.child(STR("node")).child_value(), STR("First &lt; Second &gt; Third &quot;"));
}
TEST(parse_merge_pcdata_whitespace)
{
unsigned int flag_sets[] = {0, parse_ws_pcdata, parse_ws_pcdata_single};
for (unsigned int i = 0; i < sizeof(flag_sets) / sizeof(flag_sets[0]); ++i)
{
unsigned int flags = parse_merge_pcdata | flag_sets[i];
xml_document doc;
xml_parse_result res = doc.load_string(STR("<node><child1> <!-- comment 1 -->\t<!-- comment 2 -->\n</child1><child2>text<!-- comment 1-->\t<!-- comment2 --> end</child2></node>"), flags);
CHECK(res);
if (flags & parse_ws_pcdata)
{
CHECK_STRING(doc.child(STR("node")).child(STR("child1")).child_value(), STR(" \t\n"));
CHECK_STRING(doc.child(STR("node")).child(STR("child2")).child_value(), STR("text\t end"));
}
else if (flags & parse_ws_pcdata_single)
{
CHECK_STRING(doc.child(STR("node")).child(STR("child1")).child_value(), STR("\n"));
CHECK_STRING(doc.child(STR("node")).child(STR("child2")).child_value(), STR("text end"));
}
else
{
CHECK(!doc.child(STR("node")).child(STR("child1")).first_child());
CHECK_STRING(doc.child(STR("node")).child(STR("child2")).child_value(), STR("text end"));
}
}
}
TEST(parse_merge_pcdata_append)
{
xml_document doc;
doc.append_child(STR("node")).append_child(node_pcdata);
xml_parse_result res = doc.child(STR("node")).append_buffer("hello <!--comment-->world", 25, parse_merge_pcdata | parse_fragment);
CHECK(res.status == status_append_invalid_root);
CHECK_STRING(doc.child(STR("node")).first_child().value(), STR(""));
doc.child(STR("node")).remove_children();
res = doc.child(STR("node")).append_buffer("hello <!--comment-->world", 25, parse_merge_pcdata | parse_fragment);
CHECK(res.status == status_ok);
CHECK_STRING(doc.child(STR("node")).first_child().value(), STR("hello world"));
}
TEST(parse_merge_pcdata_overlap)
{
xml_document doc;
xml_parse_result res = doc.load_string(STR("<node>short <!-- --> this string is very long so long that copying it will overlap itself</node>"), parse_merge_pcdata);
CHECK(res);
CHECK_STRING(doc.child_value(STR("node")), STR("short this string is very long so long that copying it will overlap itself"));
}
TEST(parse_encoding_detect) TEST(parse_encoding_detect)
{ {
char test[] = "<?xml version='1.0' encoding='utf-8'?><n/>"; char test[] = "<?xml version='1.0' encoding='utf-8'?><n/>";

View File

@ -3,8 +3,8 @@
#include "test.hpp" #include "test.hpp"
#include <string.h> #include <string.h>
#include <wchar.h>
#include <string> #include <string>
#include <wchar.h>
using namespace pugi; using namespace pugi;
@ -30,17 +30,24 @@ static bool test_doctype_wf(const char_t* decl)
xml_document doc; xml_document doc;
// standalone // standalone
if (!load_concat(doc, decl) || !doc.first_child().empty()) return false; if (!load_concat(doc, decl) || !doc.first_child().empty())
return false;
// pcdata pre/postfix // pcdata pre/postfix
if (!load_concat(doc, STR("a"), decl) || !test_node(doc, STR("a"), STR(""), format_raw)) return false; if (!load_concat(doc, STR("a"), decl) || !test_node(doc, STR("a"), STR(""), format_raw))
if (!load_concat(doc, decl, STR("b")) || !test_node(doc, STR("b"), STR(""), format_raw)) return false; return false;
if (!load_concat(doc, STR("a"), decl, STR("b")) || !test_node(doc, STR("ab"), 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 // node pre/postfix
if (!load_concat(doc, STR("<nodea/>"), decl) || !test_node(doc, STR("<nodea/>"), STR(""), format_raw)) return false; if (!load_concat(doc, STR("<nodea/>"), decl) || !test_node(doc, STR("<nodea/>"), STR(""), format_raw))
if (!load_concat(doc, decl, STR("<nodeb/>")) || !test_node(doc, STR("<nodeb/>"), STR(""), format_raw)) return false; return false;
if (!load_concat(doc, STR("<nodea/>"), decl, STR("<nodeb/>")) || !test_node(doc, STR("<nodea/><nodeb/>"), STR(""), format_raw)) return false; if (!load_concat(doc, decl, STR("<nodeb/>")) || !test_node(doc, STR("<nodeb/>"), STR(""), format_raw))
return false;
if (!load_concat(doc, STR("<nodea/>"), decl, STR("<nodeb/>")) || !test_node(doc, STR("<nodea/><nodeb/>"), STR(""), format_raw))
return false;
// check load-store contents preservation // check load-store contents preservation
CHECK(doc.load_string(decl, parse_doctype | parse_fragment)); CHECK(doc.load_string(decl, parse_doctype | parse_fragment));
@ -54,13 +61,16 @@ static bool test_doctype_nwf(const char_t* decl)
xml_document doc; xml_document doc;
// standalone // standalone
if (load_concat(doc, decl).status != status_bad_doctype) return false; if (load_concat(doc, decl).status != status_bad_doctype)
return false;
// pcdata postfix // pcdata postfix
if (load_concat(doc, decl, STR("b")).status != status_bad_doctype) return false; if (load_concat(doc, decl, STR("b")).status != status_bad_doctype)
return false;
// node postfix // node postfix
if (load_concat(doc, decl, STR("<nodeb/>")).status != status_bad_doctype) return false; if (load_concat(doc, decl, STR("<nodeb/>")).status != status_bad_doctype)
return false;
return true; return true;
} }
@ -221,7 +231,7 @@ TEST(parse_doctype_xmlconf_ibm_2)
TEST_DOCTYPE_NWF("<!DOCTYPE animal [ <!ELEMENT animal ANY> <!ENTITY % parameterE \"A music file ?>\"> <?music %parameterE; ]>"); TEST_DOCTYPE_NWF("<!DOCTYPE animal [ <!ELEMENT animal ANY> <!ENTITY % parameterE \"A music file ?>\"> <?music %parameterE; ]>");
TEST_DOCTYPE_NWF("<!DOCTYPE animal [ <!ELEMENT animal ANY> <!ENTITY % parameterE \"leopard EMPTY>\"> <!ELEMENT %parameterE; ]>"); TEST_DOCTYPE_NWF("<!DOCTYPE animal [ <!ELEMENT animal ANY> <!ENTITY % parameterE \"leopard EMPTY>\"> <!ELEMENT %parameterE; ]>");
TEST_DOCTYPE_WF("<!DOCTYPE root [ <!ELEMENT root ANY> <!ATTLIST root attr1 CDATA #IMPLIED> <!ATTLIST root attr2 CDATA #IMPLIED> <!ENTITY withlt \"have <lessthan> inside\"> <!ENTITY aIndirect \"&withlt;\"> ]>"); TEST_DOCTYPE_WF("<!DOCTYPE root [ <!ELEMENT root ANY> <!ATTLIST root attr1 CDATA #IMPLIED> <!ATTLIST root attr2 CDATA #IMPLIED> <!ENTITY withlt \"have <lessthan> inside\"> <!ENTITY aIndirect \"&withlt;\"> ]>");
TEST_DOCTYPE_WF("<!DOCTYPE root [ <!ELEMENT root (#PCDATA)> <!--* Missing Name S contentspec in elementdecl *--> <!ELEMENT > ]>"); TEST_DOCTYPE_WF("<!DOCTYPE root [ <!ELEMENT root (#PCDATA)> <!--* Mising Name S contentspec in elementdecl *--> <!ELEMENT > ]>");
TEST_DOCTYPE_WF("<!DOCTYPE root [ <!ELEMENT root (#PCDATA)> <!ELEMENT a ANY> <!ELEMENT b ANY> <!--* extra separator in seq *--> <!ELEMENT aElement ((a|b),,a)? > ]>"); TEST_DOCTYPE_WF("<!DOCTYPE root [ <!ELEMENT root (#PCDATA)> <!ELEMENT a ANY> <!ELEMENT b ANY> <!--* extra separator in seq *--> <!ELEMENT aElement ((a|b),,a)? > ]>");
TEST_DOCTYPE_WF("<!DOCTYPE root [ <!ELEMENT root (#PCDATA)> <!ELEMENT a ANY> <!--* Missing white space before Name in AttDef *--> <!ATTLIST a attr1 CDATA \"default\"attr2 ID #required> ]>"); TEST_DOCTYPE_WF("<!DOCTYPE root [ <!ELEMENT root (#PCDATA)> <!ELEMENT a ANY> <!--* Missing white space before Name in AttDef *--> <!ATTLIST a attr1 CDATA \"default\"attr2 ID #required> ]>");
TEST_DOCTYPE_WF("<!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT one EMPTY> <!ELEMENT two EMPTY> <!NOTATION this SYSTEM \"alpha\"> <!ATTLIST three attr NOTATION (\"this\") #IMPLIED> ]>"); TEST_DOCTYPE_WF("<!DOCTYPE test [ <!ELEMENT test ANY> <!ELEMENT one EMPTY> <!ELEMENT two EMPTY> <!NOTATION this SYSTEM \"alpha\"> <!ATTLIST three attr NOTATION (\"this\") #IMPLIED> ]>");

View File

@ -1,5 +1,5 @@
#include "../src/pugixml.hpp" #include "../src/pugixml.hpp"
#if PUGIXML_VERSION != 1140 // 1.14 #if PUGIXML_VERSION != 190
#error Unexpected pugixml version #error Unexpected pugixml version
#endif #endif

View File

@ -2,9 +2,9 @@
#include "writer_string.hpp" #include "writer_string.hpp"
#include <string>
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
#include <string>
using namespace pugi; using namespace pugi;
@ -193,23 +193,7 @@ TEST_XML(write_escape, "<node attr=''>text</node>")
doc.child(STR("node")).attribute(STR("attr")) = STR("<>'\"&\x04\r\n\t"); 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")); doc.child(STR("node")).first_child().set_value(STR("<>'\"&\x04\r\n\t"));
CHECK_NODE(doc, STR("<node attr=\"&lt;>'&quot;&amp;&#04;&#13;&#10;&#09;\">&lt;&gt;'\"&amp;&#04;\r\n\t</node>")); CHECK_NODE(doc, STR("<node attr=\"&lt;&gt;'&quot;&amp;&#04;&#13;&#10;\t\">&lt;&gt;'\"&amp;&#04;\r\n\t</node>"));
CHECK_NODE_EX(doc, STR("<node attr='&lt;>&apos;\"&amp;&#04;&#13;&#10;&#09;'>&lt;&gt;'\"&amp;&#04;\r\n\t</node>"), STR(""), format_raw | format_attribute_single_quote);
}
TEST_XML(write_escape_roundtrip, "<node attr=''>text</node>")
{
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("<node attr=\"&lt;>'&quot;&amp;&#04;&#13;&#10;&#09;\">&lt;&gt;'\"&amp;&#04;\n\t</node>"));
CHECK_NODE_EX(doc, STR("<node attr='&lt;>&apos;\"&amp;&#04;&#13;&#10;&#09;'>&lt;&gt;'\"&amp;&#04;\n\t</node>"), STR(""), format_raw | format_attribute_single_quote);
} }
TEST_XML(write_escape_unicode, "<node attr='&#x3c00;'/>") TEST_XML(write_escape_unicode, "<node attr='&#x3c00;'/>")
@ -329,7 +313,8 @@ TEST(write_encoding_huge)
// make a large utf16 name consisting of 6-byte char pairs (6 does not divide internal buffer size, so will need split correction) // 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); std::string s_utf16 = std::string("\x00<", 2);
for (unsigned int i = 0; i < N; ++i) s_utf16 += "\x20\xAC\xd8\x52\xdf\x62"; for (unsigned int i = 0; i < N; ++i)
s_utf16 += "\x20\xAC\xd8\x52\xdf\x62";
s_utf16 += std::string("\x00/\x00>", 4); s_utf16 += std::string("\x00/\x00>", 4);
@ -338,7 +323,8 @@ TEST(write_encoding_huge)
std::string s_utf8 = "<"; std::string s_utf8 = "<";
for (unsigned int j = 0; j < N; ++j) s_utf8 += "\xE2\x82\xAC\xF0\xA4\xAD\xA2"; for (unsigned int j = 0; j < N; ++j)
s_utf8 += "\xE2\x82\xAC\xF0\xA4\xAD\xA2";
s_utf8 += " />\n"; s_utf8 += " />\n";
@ -356,7 +342,8 @@ TEST(write_encoding_huge_invalid)
// make a large utf16 name consisting of leading surrogate chars // make a large utf16 name consisting of leading surrogate chars
std::basic_string<wchar_t> s_utf16; std::basic_string<wchar_t> s_utf16;
for (unsigned int i = 0; i < N; ++i) s_utf16 += static_cast<wchar_t>(0xd852); for (unsigned int i = 0; i < N; ++i)
s_utf16 += static_cast<wchar_t>(0xd852);
xml_document doc; xml_document doc;
doc.append_child().set_name(s_utf16.c_str()); doc.append_child().set_name(s_utf16.c_str());
@ -372,7 +359,8 @@ TEST(write_encoding_huge)
// make a large utf8 name consisting of 3-byte chars (3 does not divide internal buffer size, so will need split correction) // 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 = "<"; std::string s_utf8 = "<";
for (unsigned int i = 0; i < N; ++i) s_utf8 += "\xE2\x82\xAC"; for (unsigned int i = 0; i < N; ++i)
s_utf8 += "\xE2\x82\xAC";
s_utf8 += "/>"; s_utf8 += "/>";
@ -381,7 +369,8 @@ TEST(write_encoding_huge)
std::string s_utf16 = std::string("\x00<", 2); std::string s_utf16 = std::string("\x00<", 2);
for (unsigned int j = 0; j < N; ++j) s_utf16 += "\x20\xAC"; for (unsigned int j = 0; j < N; ++j)
s_utf16 += "\x20\xAC";
s_utf16 += std::string("\x00 \x00/\x00>\x00\n", 8); s_utf16 += std::string("\x00 \x00/\x00>\x00\n", 8);
@ -395,7 +384,8 @@ TEST(write_encoding_huge_invalid)
// make a large utf8 name consisting of non-leading chars // make a large utf8 name consisting of non-leading chars
std::string s_utf8; std::string s_utf8;
for (unsigned int i = 0; i < N; ++i) s_utf8 += "\x82"; for (unsigned int i = 0; i < N; ++i)
s_utf8 += "\x82";
xml_document doc; xml_document doc;
doc.append_child().set_name(s_utf8.c_str()); doc.append_child().set_name(s_utf8.c_str());
@ -589,15 +579,13 @@ TEST(write_pcdata_whitespace_fixedpoint)
0, 0,
parse_ws_pcdata, parse_ws_pcdata,
parse_ws_pcdata_single, parse_ws_pcdata_single,
parse_trim_pcdata parse_trim_pcdata};
};
static const unsigned int flags_format[] = static const unsigned int flags_format[] =
{ {
0, 0,
format_raw, format_raw,
format_indent format_indent};
};
for (unsigned int i = 0; i < sizeof(flags_parse) / sizeof(flags_parse[0]); ++i) for (unsigned int i = 0; i < sizeof(flags_parse) / sizeof(flags_parse[0]); ++i)
{ {
@ -634,7 +622,7 @@ TEST_XML(write_no_empty_element_tags, "<node><child1/><child2>text</child2><chil
TEST_XML_FLAGS(write_roundtrip, "<node><child1 attr1='value1' attr2='value2'/><child2 attr='value'>pre<![CDATA[data]]>mid&lt;text&amp;escape<!--comment--><test/>post<?pi value?>fin</child2><child3/></node>", parse_full) TEST_XML_FLAGS(write_roundtrip, "<node><child1 attr1='value1' attr2='value2'/><child2 attr='value'>pre<![CDATA[data]]>mid&lt;text&amp;escape<!--comment--><test/>post<?pi value?>fin</child2><child3/></node>", 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 }; const unsigned int flagset[] = {format_indent, format_raw, format_no_declaration, format_indent_attributes, format_no_empty_element_tags};
size_t flagcount = sizeof(flagset) / sizeof(flagset[0]); size_t flagcount = sizeof(flagset) / sizeof(flagset[0]);
for (size_t i = 0; i < (size_t(1) << flagcount); ++i) for (size_t i = 0; i < (size_t(1) << flagcount); ++i)
@ -721,13 +709,3 @@ TEST_XML(write_throw_encoding, "<node><child/></node>")
} }
} }
#endif #endif
TEST_XML(write_skip_control_chars, "<a>\f\t\n\x0F\x19</a>")
{
CHECK_NODE_EX(doc.first_child(), STR("<a>\t\n</a>\n"), STR(""), pugi::format_default | pugi::format_skip_control_chars);
}
TEST_XML(write_keep_control_chars, "<a>\f\t\n\x0F\x19</a>")
{
CHECK_NODE_EX(doc.first_child(), STR("<a>&#12;\t\n&#15;&#25;</a>\n"), STR(""), pugi::format_default);
}

View File

@ -5,10 +5,10 @@
#include <string.h> #include <string.h>
#include <wchar.h> #include <wchar.h>
#include <string>
#include <vector>
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
#include <string>
#include <vector>
using namespace pugi; using namespace pugi;
@ -20,27 +20,12 @@ static void load_document_copy(xml_document& doc, const char_t* text)
doc.append_copy(source.first_child()); doc.append_copy(source.first_child());
} }
template <typename T>
static void random_shuffle(std::vector<T>& v)
{
size_t rng = 2147483647;
for (size_t i = v.size() - 1; i > 0; --i)
{
// Fisher-Yates shuffle
size_t j = rng % (i + 1);
std::swap(v[j], v[i]);
// LCG RNG, constants from Numerical Recipes
rng = rng * 1664525 + 1013904223;
}
}
TEST(xpath_allocator_many_pages) TEST(xpath_allocator_many_pages)
{ {
std::basic_string<char_t> query = STR("0"); std::basic_string<char_t> query = STR("0");
for (int i = 0; i < 128; ++i) query += STR("+string-length('abcdefgh')"); for (int i = 0; i < 128; ++i)
query += STR("+string-length('abcdefgh')");
CHECK_XPATH_NUMBER(xml_node(), query.c_str(), 1024); CHECK_XPATH_NUMBER(xml_node(), query.c_str(), 1024);
} }
@ -49,7 +34,8 @@ TEST(xpath_allocator_large_page)
{ {
std::basic_string<char_t> query; std::basic_string<char_t> query;
for (int i = 0; i < 1024; ++i) query += STR("abcdefgh"); for (int i = 0; i < 1024; ++i)
query += STR("abcdefgh");
CHECK_XPATH_NUMBER(xml_node(), (STR("string-length('") + query + STR("')")).c_str(), 8192); CHECK_XPATH_NUMBER(xml_node(), (STR("string-length('") + query + STR("')")).c_str(), 8192);
} }
@ -171,14 +157,15 @@ TEST(xpath_sort_random_medium)
xpath_node_set ns = doc.select_nodes(STR("//node() | //@*")); xpath_node_set ns = doc.select_nodes(STR("//node() | //@*"));
std::vector<xpath_node> nsv(ns.begin(), ns.end()); std::vector<xpath_node> nsv(ns.begin(), ns.end());
random_shuffle(nsv); std::random_shuffle(nsv.begin(), nsv.end());
xpath_node_set copy(&nsv[0], &nsv[0] + nsv.size()); xpath_node_set copy(&nsv[0], &nsv[0] + nsv.size());
copy.sort(); copy.sort();
xpath_node_set_tester tester(copy, "sorted order failed"); xpath_node_set_tester tester(copy, "sorted order failed");
for (unsigned int i = 2; i < 39; ++i) tester % i; for (unsigned int i = 2; i < 39; ++i)
tester % i;
} }
TEST(xpath_sort_random_large) TEST(xpath_sort_random_large)
@ -200,14 +187,15 @@ TEST(xpath_sort_random_large)
xpath_node_set ns = doc.select_nodes(STR("//node() | //@*")); xpath_node_set ns = doc.select_nodes(STR("//node() | //@*"));
std::vector<xpath_node> nsv(ns.begin(), ns.end()); std::vector<xpath_node> nsv(ns.begin(), ns.end());
random_shuffle(nsv); std::random_shuffle(nsv.begin(), nsv.end());
xpath_node_set copy(&nsv[0], &nsv[0] + nsv.size()); xpath_node_set copy(&nsv[0], &nsv[0] + nsv.size());
copy.sort(); copy.sort();
xpath_node_set_tester tester(copy, "sorted order failed"); xpath_node_set_tester tester(copy, "sorted order failed");
for (unsigned int i = 2; i < 129; ++i) tester % i; for (unsigned int i = 2; i < 129; ++i)
tester % i;
} }
TEST(xpath_long_numbers_parse) TEST(xpath_long_numbers_parse)
@ -221,8 +209,8 @@ TEST(xpath_long_numbers_parse)
xml_node c; xml_node c;
// check parsing // check parsing
CHECK_XPATH_NUMBER(c, str_flt_max, double(std::numeric_limits<float>::max())); CHECK_XPATH_NUMBER(c, str_flt_max, std::numeric_limits<float>::max());
CHECK_XPATH_NUMBER(c, str_flt_max_dec, double(std::numeric_limits<float>::max())); CHECK_XPATH_NUMBER(c, str_flt_max_dec, std::numeric_limits<float>::max());
CHECK_XPATH_NUMBER(c, str_dbl_max, std::numeric_limits<double>::max()); CHECK_XPATH_NUMBER(c, str_dbl_max, std::numeric_limits<double>::max());
CHECK_XPATH_NUMBER(c, str_dbl_max_dec, std::numeric_limits<double>::max()); CHECK_XPATH_NUMBER(c, str_dbl_max_dec, std::numeric_limits<double>::max());
} }
@ -263,7 +251,8 @@ TEST(xpath_denorm_numbers)
// 10^-318 - double denormal // 10^-318 - double denormal
for (int i = 0; i < 106; ++i) for (int i = 0; i < 106; ++i)
{ {
if (i != 0) query += STR(" * "); if (i != 0)
query += STR(" * ");
query += STR("0.001"); query += STR("0.001");
} }
@ -465,42 +454,15 @@ TEST(xpath_out_of_memory_evaluate_substring)
CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, xml_node()) == 1)); CHECK_ALLOC_FAIL(CHECK(q.evaluate_string(0, 0, xml_node()) == 1));
} }
TEST_XML(xpath_out_of_memory_evaluate_union, "<node />") TEST_XML(xpath_out_of_memory_evaluate_union, "<node><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/></node>")
{ {
// left hand side: size * sizeof(xpath_node) (8 on 32-bit, 16 on 64-bit) test_runner::_memory_fail_threshold = 32768 + 4096 * 2;
// 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) xpath_query q(STR("a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|(a|a)))))))))))))))))))"));
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())); CHECK_ALLOC_FAIL(CHECK(q.evaluate_node_set(doc.child(STR("node"))).empty()));
} }
TEST_XML(xpath_out_of_memory_evaluate_union_hash, "<node />")
{
// 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, "<node><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/></node>") TEST_XML(xpath_out_of_memory_evaluate_predicate, "<node><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/><a/></node>")
{ {
test_runner::_memory_fail_threshold = 32768 + 4096 * 2; test_runner::_memory_fail_threshold = 32768 + 4096 * 2;
@ -771,7 +733,8 @@ TEST(xpath_allocate_string_out_of_memory)
{ {
std::basic_string<char_t> query; std::basic_string<char_t> query;
for (int i = 0; i < 1024; ++i) query += STR("abcdefgh"); for (int i = 0; i < 1024; ++i)
query += STR("abcdefgh");
test_runner::_memory_fail_threshold = 8 * 1024; test_runner::_memory_fail_threshold = 8 * 1024;

View File

@ -123,7 +123,7 @@ TEST_XML(xpath_api_nodeset_copy, "<node><foo/><foo/></node>")
xpath_node_set copy3; xpath_node_set copy3;
copy3 = set; copy3 = set;
copy3 = xpath_node_set(copy3); copy3 = copy3;
CHECK(copy3.size() == 2); CHECK(copy3.size() == 2);
CHECK_STRING(copy3[0].node().name(), STR("foo")); CHECK_STRING(copy3[0].node().name(), STR("foo"));
@ -430,7 +430,6 @@ TEST_XML(xpath_api_nodeset_move_ctor, "<node><foo/><foo/><bar/></node>")
CHECK(move[1] == doc.first_child().first_child()); CHECK(move[1] == doc.first_child().first_child());
} }
TEST_XML(xpath_api_nodeset_move_ctor_single, "<node><foo/><foo/><bar/></node>") TEST_XML(xpath_api_nodeset_move_ctor_single, "<node><foo/><foo/><bar/></node>")
{ {
xpath_node_set set = doc.select_nodes(STR("node/bar")); xpath_node_set set = doc.select_nodes(STR("node/bar"));
@ -573,8 +572,7 @@ TEST_XML(xpath_api_nodeset_move_assign_self, "<node><foo/><foo/><bar/></node>")
test_runner::_memory_fail_threshold = 1; test_runner::_memory_fail_threshold = 1;
xpath_node_set* self = &set; set = std::move(*&set);
set = std::move(*self);
} }
TEST(xpath_api_query_move) TEST(xpath_api_query_move)
@ -615,8 +613,7 @@ TEST(xpath_api_query_move)
CHECK(q4); CHECK(q4);
CHECK(q4.evaluate_boolean(c)); CHECK(q4.evaluate_boolean(c));
xpath_query* q4self = &q4; q4 = std::move(*&q4);
q4 = std::move(*q4self);
CHECK(q4); CHECK(q4);
CHECK(q4.evaluate_boolean(c)); CHECK(q4.evaluate_boolean(c));

View File

@ -829,7 +829,8 @@ TEST(xpath_string_translate_table_out_of_memory)
for (size_t i = 0; i < count; ++i) for (size_t i = 0; i < count; ++i)
{ {
if (i != 0) query += STR(","); if (i != 0)
query += STR(",");
query += STR("translate('a','a','A')"); query += STR("translate('a','a','A')");
} }

View File

@ -194,7 +194,7 @@ TEST_XML(xpath_operators_equality_node_set_node_set, "<node><c1><v>a</v><v>b</v>
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("c2/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 != 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("c1/v != c5/v"), true); // (a, b) != (a, b), since a != b, as per XPath spec (comparison operators are so not intutive)
CHECK_XPATH_BOOLEAN(n, STR("c3/v != c6/v"), false); CHECK_XPATH_BOOLEAN(n, STR("c3/v != c6/v"), 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);
@ -435,24 +435,6 @@ TEST_XML(xpath_operators_union, "<node><employee/><employee secretary=''/><emplo
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, "<node />")
{
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) TEST(xpath_operators_union_error)
{ {
CHECK_XPATH_FAIL(STR(". | true()")); CHECK_XPATH_FAIL(STR(". | true()"));

View File

@ -109,8 +109,7 @@ TEST(xpath_parse_paths_valid)
STR("/foo|/bar[@id='1234']"), STR("count(//author/attribute::*)"), STR("/child::node()/child::node()[@id='_13563275']"), 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("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("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("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("/foo/bar[@a='1' and @b='2']"), STR("/foo/bar[@a='1' and @b!='2']"), STR("//attribute::*[.!='crunchy']"),
STR("'//*[contains(string(text()),\"yada yada\")]'"), STR("'//*[contains(string(text()),\"yada yada\")]'"),
// From ajaxslt tests // From ajaxslt tests
@ -173,8 +172,7 @@ TEST(xpath_parse_paths_valid)
STR("**..**"), STR("**..**"),
// Miscellaneous // Miscellaneous
STR("..***..***.***.***..***..***..") STR("..***..***.***.***..***..***..")};
};
for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); ++i) for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); ++i)
{ {
@ -189,33 +187,85 @@ TEST(xpath_parse_paths_valid_unicode)
const wchar_t* paths[] = const wchar_t* paths[] =
{ {
#ifdef U_LITERALS #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"/descendant-or-self::\u90e8\u5206",
L"\u8b0e//\u30bf\u30a4\u30c8\u30eb", L"//*[@\u30c7\u30b9\u30c6\u30a3\u30cd\u30a4\u30b7\u30e7\u30f3]", L"\u30da\u30fc\u30b8 = '\u304b\u3089'", 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"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"\u30bd\u30fc\u30b9|\u30c7\u30b9\u30c6\u30a3\u30cd\u30a4\u30b7\u30e7\u30f3",
L"substring-after(\u30a2\u30a4\u30b3\u30f3/@\u30a4\u30e1\u30fc\u30b8, '/\u5730\u56f3\u30d5\u30a1\u30a4\u30eb/\u76ee\u5370')", L"child::\u6bb5\u843d", L"\u30da\u30fc\u30b8 != '\u307e\u3067' and \u30da\u30fc\u30b8 != '\u304b\u3089'",
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"substring-after(\u30a2\u30a4\u30b3\u30f3/@\u30a4\u30e1\u30fc\u30b8, '/\u5730\u56f3\u30d5\u30a1\u30a4\u30eb/\u76ee\u5370')",
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::\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"substring-before(\u6587\u5b57\u5217, \u6587\u5b57)",
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"\u30bb\u30b0\u30e1\u30f3\u30c8/@\u6642\u523b",
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"attribute::\u540d\u524d",
L"child::\u6bb5\u843d[attribute::\u30bf\u30a4\u30d7='\u8b66\u544a']", L"child::\u6bb5\u843d[attribute::\u30bf\u30a4\u30d7='\u8b66\u544a'][position()=5]", L"descendant::\u6bb5\u843d",
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"ancestor::\u90e8\u5206",
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()]", 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 #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"/descendant-or-self::\x90e8\x5206",
L"\x8b0e//\x30bf\x30a4\x30c8\x30eb", L"//*[@\x30c7\x30b9\x30c6\x30a3\x30cd\x30a4\x30b7\x30e7\x30f3]", L"\x30da\x30fc\x30b8 = '\x304b\x3089'", 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"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"\x30bd\x30fc\x30b9|\x30c7\x30b9\x30c6\x30a3\x30cd\x30a4\x30b7\x30e7\x30f3",
L"substring-after(\x30a2\x30a4\x30b3\x30f3/@\x30a4\x30e1\x30fc\x30b8, '/\x5730\x56f3\x30d5\x30a1\x30a4\x30eb/\x76ee\x5370')", L"child::\x6bb5\x843d", L"\x30da\x30fc\x30b8 != '\x307e\x3067' and \x30da\x30fc\x30b8 != '\x304b\x3089'",
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"substring-after(\x30a2\x30a4\x30b3\x30f3/@\x30a4\x30e1\x30fc\x30b8, '/\x5730\x56f3\x30d5\x30a1\x30a4\x30eb/\x76ee\x5370')",
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::\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"substring-before(\x6587\x5b57\x5217, \x6587\x5b57)",
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"\x30bb\x30b0\x30e1\x30f3\x30c8/@\x6642\x523b",
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"attribute::\x540d\x524d",
L"child::\x6bb5\x843d[attribute::\x30bf\x30a4\x30d7='\x8b66\x544a']", L"child::\x6bb5\x843d[attribute::\x30bf\x30a4\x30d7='\x8b66\x544a'][position()=5]", L"descendant::\x6bb5\x843d",
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"ancestor::\x90e8\x5206",
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()]", 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 #endif
}; };
@ -250,8 +300,8 @@ TEST(xpath_parse_invalid)
STR("|/gjs"), STR("+3"), STR("/html/body/p != ---'div'/a"), STR(""), STR("@"), STR("#akf"), STR(",") STR("|/gjs"), STR("+3"), STR("/html/body/p != ---'div'/a"), STR(""), STR("@"), STR("#akf"), STR(",")
// Miscellaneous // Miscellaneous
STR("..."), STR("...."), STR("**"), STR("****"), STR("******"), STR("..***..***.***.***..***..***..*"), STR("/[1]") STR("..."),
}; STR("...."), STR("**"), STR("****"), STR("******"), STR("..***..***.***.***..***..***..*"), STR("/[1]")};
for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); ++i) for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); ++i)
{ {
@ -381,30 +431,6 @@ TEST(xpath_parse_oom_propagation)
} }
} }
static std::basic_string<char_t> rep(const std::basic_string<char_t>& base, size_t count)
{
std::basic_string<char_t> result;
result.reserve(base.size() * count);
for (size_t i = 0; i < count; ++i)
result += base;
return result;
}
TEST(xpath_parse_depth_limit)
{
const size_t limit = 1500;
CHECK_XPATH_FAIL((rep(STR("("), limit) + STR("1") + rep(STR(")"), limit)).c_str());
CHECK_XPATH_FAIL((STR("(id('a'))") + rep(STR("[1]"), limit)).c_str());
CHECK_XPATH_FAIL((STR("/foo") + rep(STR("[1]"), limit)).c_str());
CHECK_XPATH_FAIL((STR("/foo") + rep(STR("/x"), limit)).c_str());
CHECK_XPATH_FAIL((STR("1") + rep(STR("+1"), limit)).c_str());
CHECK_XPATH_FAIL((STR("concat(") + rep(STR("1,"), limit) + STR("1)")).c_str());
CHECK_XPATH_FAIL((STR("/foo") + rep(STR("//x"), limit / 2)).c_str());
}
TEST_XML(xpath_parse_location_path, "<node><child/></node>") TEST_XML(xpath_parse_location_path, "<node><child/></node>")
{ {
CHECK_XPATH_NODESET(doc, STR("/node")) % 2; CHECK_XPATH_NODESET(doc, STR("/node")) % 2;

View File

@ -454,7 +454,7 @@ TEST_XML(xpath_variables_copy, "<node />")
CHECK_XPATH_STRING_VAR(xml_node(), STR("substring($c, count($d[$a]) + $b)"), &set2, STR("ring")); CHECK_XPATH_STRING_VAR(xml_node(), STR("substring($c, count($d[$a]) + $b)"), &set2, STR("ring"));
set3 = xpath_variable_set(set3); set3 = set3;
CHECK_XPATH_STRING_VAR(xml_node(), STR("substring($c, count($d[$a]) + $b)"), &set2, STR("ring")); CHECK_XPATH_STRING_VAR(xml_node(), STR("substring($c, count($d[$a]) + $b)"), &set2, STR("ring"));
@ -642,32 +642,4 @@ TEST_XML(xpath_variables_evaluate_node_set_out_of_memory, "<node />")
CHECK_ALLOC_FAIL(q.evaluate_node_set(xml_node()).empty()); CHECK_ALLOC_FAIL(q.evaluate_node_set(xml_node()).empty());
} }
TEST_XML(xpath_variables_type_conversion, "<node>15</node>")
{
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);
#ifndef MSVC6_NAN_BUG
CHECK_XPATH_BOOLEAN_VAR(xml_node(), STR("number($c) = 0"), &set, false);
#endif
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 #endif

View File

@ -4,8 +4,8 @@
#include "test.hpp" #include "test.hpp"
#include <string>
#include <algorithm> #include <algorithm>
#include <string>
using namespace pugi; using namespace pugi;

View File

@ -111,7 +111,6 @@ TEST_XML(xpath_xalan_match_1, "<root><x spot='a' num='1'/><x spot='b' num='2'/><
CHECK_XPATH_NODESET(c, STR("x[(((((2*10)-4)+9) div 5) mod 3)]")) % 6; CHECK_XPATH_NODESET(c, STR("x[(((((2*10)-4)+9) div 5) mod 3)]")) % 6;
} }
TEST_XML(xpath_xalan_match_2, "<doc><l1><v2>doc-l1-v2</v2><x2>doc-l1-x2</x2><l2><v3>doc-l1-l2-v3</v3><w3>doc-l1-l2-w3</w3><x3>doc-l1-l2-x3</x3><y3>doc-l1-l2-y3</y3><l3><v4>doc-l1-l2-l3-v4</v4><x4>doc-l1-l2-l3-x4</x4></l3></l2></l1></doc>") TEST_XML(xpath_xalan_match_2, "<doc><l1><v2>doc-l1-v2</v2><x2>doc-l1-x2</x2><l2><v3>doc-l1-l2-v3</v3><w3>doc-l1-l2-w3</w3><x3>doc-l1-l2-x3</x3><y3>doc-l1-l2-y3</y3><l3><v4>doc-l1-l2-l3-v4</v4><x4>doc-l1-l2-l3-x4</x4></l3></l2></l1></doc>")
{ {
CHECK_XPATH_STRING(doc, STR("doc/l1/v2"), STR("doc-l1-v2")); CHECK_XPATH_STRING(doc, STR("doc/l1/v2"), STR("doc-l1-v2"));

View File

@ -5,10 +5,12 @@
static bool test_narrow(const std::string& result, const char* expected, size_t length) static bool test_narrow(const std::string& result, const char* expected, size_t length)
{ {
// check result // check result
if (result != std::string(expected, expected + length)) return false; if (result != std::string(expected, expected + length))
return false;
// check comparison operator (incorrect implementation can theoretically early-out on zero terminators...) // check comparison operator (incorrect implementation can theoretically early-out on zero terminators...)
if (length > 0 && result == std::string(expected, expected + length - 1) + "?") return false; if (length > 0 && result == std::string(expected, expected + length - 1) + "?")
return false;
return true; return true;
} }