summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.codespellrc2
-rw-r--r--.gitlab-ci.yml19
-rw-r--r--.gitlab/ci/configure_debian10_makefiles_clang.cmake1
-rw-r--r--.gitlab/ci/configure_fedora34_clang_analyzer.cmake1
-rwxr-xr-x.gitlab/ci/docker/fedora34/install_deps.sh1
-rw-r--r--.gitlab/ci/env_debian10_makefiles_clang.sh2
-rw-r--r--.gitlab/ci/env_fedora34_clang_analyzer.sh2
-rwxr-xr-x.gitlab/ci/sccache.sh51
-rw-r--r--.gitlab/os-linux.yml20
-rw-r--r--CTestCustom.cmake.in31
-rw-r--r--Help/cpack_gen/freebsd.rst4
-rw-r--r--Help/envvar/CMAKE_TOOLCHAIN_FILE.rst12
-rw-r--r--Help/manual/cmake-env-variables.7.rst1
-rw-r--r--Help/prop_sf/COMPILE_FLAGS.rst7
-rw-r--r--Help/prop_sf/COMPILE_OPTIONS.rst7
-rw-r--r--Help/prop_tgt/COMPILE_OPTIONS.rst10
-rw-r--r--Help/prop_tgt/IMPORTED_OBJECTS.rst22
-rw-r--r--Help/release/dev/compile-options-order.rst7
-rw-r--r--Help/release/dev/env-toolchain-file.rst5
-rw-r--r--Help/variable/CMAKE_CONFIGURATION_TYPES.rst6
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS.rst5
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst7
-rw-r--r--Help/variable/CMAKE_TOOLCHAIN_FILE.rst3
-rw-r--r--Modules/CMakeParseImplicitLinkInfo.cmake32
-rw-r--r--Modules/FindBoost.cmake1
-rw-r--r--Modules/FindOpenSSL.cmake4
-rw-r--r--Modules/FindPkgConfig.cmake4
-rw-r--r--Modules/Internal/CPack/CPackDeb.cmake2
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/LexerParser/cmCTestResourceGroupsLexer.cxx2
-rw-r--r--Source/LexerParser/cmCTestResourceGroupsLexer.in.l2
-rw-r--r--Source/LexerParser/cmCommandArgumentLexer.cxx2
-rw-r--r--Source/LexerParser/cmCommandArgumentLexer.in.l2
-rw-r--r--Source/LexerParser/cmDependsJavaLexer.cxx2
-rw-r--r--Source/LexerParser/cmDependsJavaLexer.in.l2
-rw-r--r--Source/LexerParser/cmExprLexer.cxx2
-rw-r--r--Source/LexerParser/cmExprLexer.in.l2
-rw-r--r--Source/LexerParser/cmFortranLexer.cxx2
-rw-r--r--Source/LexerParser/cmFortranLexer.in.l2
-rw-r--r--Source/LexerParser/cmGccDepfileLexer.cxx2
-rw-r--r--Source/LexerParser/cmGccDepfileLexer.in.l2
-rw-r--r--Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx5
-rw-r--r--Source/cmFileAPICodemodel.cxx1
-rw-r--r--Source/cmStandardLevelResolver.cxx2
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx10
-rw-r--r--Source/cmake.cxx10
-rw-r--r--Templates/MSBuild/FlagTables/v141_CL.json53
-rw-r--r--Templates/MSBuild/FlagTables/v142_CL.json238
-rw-r--r--Tests/CMakeLib/testOptional.cxx2
-rw-r--r--Tests/CMakeLib/testString.cxx4
-rw-r--r--Tests/CMakeLists.txt5
-rw-r--r--Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in3
-rw-r--r--Tests/CompileOptions/CMakeLists.txt28
-rw-r--r--Tests/CompileOptions/main.cpp18
-rw-r--r--Tests/RunCMake/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/CommandLine/EnvToolchain-toolchain.cmake1
-rw-r--r--Tests/RunCMake/CommandLine/EnvToolchain.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/EnvToolchainAbsolute-stdout.txt5
-rw-r--r--Tests/RunCMake/CommandLine/EnvToolchainAbsolute.cmake1
-rw-r--r--Tests/RunCMake/CommandLine/EnvToolchainIgnore-stdout.txt4
-rw-r--r--Tests/RunCMake/CommandLine/EnvToolchainIgnore.cmake1
-rw-r--r--Tests/RunCMake/CommandLine/EnvToolchainNone-stdout.txt3
-rw-r--r--Tests/RunCMake/CommandLine/EnvToolchainNone.cmake1
-rw-r--r--Tests/RunCMake/CommandLine/EnvToolchainNoneExisting-stdout.txt4
-rw-r--r--Tests/RunCMake/CommandLine/EnvToolchainRelative-stdout.txt4
-rw-r--r--Tests/RunCMake/CommandLine/EnvToolchainRelative.cmake1
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake27
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_empty_target.cmake17
-rw-r--r--Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/FindPkgConfig/pc-empty/lib/pkgconfig/empty.pc5
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-C-GNU-10.2.1-static-libgcc.input74
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-CXX-GNU-10.2.1-static-libstdc++.input79
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-Fortran-GNU-10.2.1-static-libgfortran.input79
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake3
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-GNU-10.2.1-static-libgcc.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-GNU-10.2.1-static-libstdc++.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-GNU-10.2.1-static-libgfortran.output1
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake17
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/aix-CXX-XLClang-16.1.0.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-8.7.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-9.0-hlist-ad.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Intel-18.0.2.20180210.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-8.7.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-9.0-hlist-ad.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-GNU-7.3.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Intel-18.0.2.20180210.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-8.7.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-9.0-hlist-ad.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/darwin-CXX-AppleClang-8.0.0.8000042.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-CXX-Clang-3.3.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-GNU-10.2.1-static-libgcc.output3
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-Intel-18.0.0.20170811.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-CLANG.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-XLClang-v.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-9.2.148-GCC.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-GNU-10.2.1-static-libstdc++.output3
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-GNU-7.3.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-Intel-18.0.0.20170811.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-NVHPC-21.1.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-PGI-18.10.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-12.1.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-16.1.0.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-GNU-10.2.1-static-libgfortran.output3
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-PGI-18.10.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-XL-12.1.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/mingw.org-CXX-GNU-4.9.3.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd-CXX-GNU-4.8.5.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd_nostdinc-CXX-GNU-4.8.5.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/openbsd-CXX-Clang-5.0.1.output2
-rw-r--r--Tests/RunCMake/target_compile_options/Order-build-stdout.txt3
-rw-r--r--Tests/RunCMake/target_compile_options/Order.cmake19
-rw-r--r--Tests/RunCMake/target_compile_options/RunCMakeTest.cmake13
-rw-r--r--Tests/RunCMake/target_compile_options/order.c7
-rw-r--r--Utilities/cmjsoncpp/src/lib_json/json_reader.cpp2029
-rw-r--r--Utilities/cmjsoncpp/src/lib_json/json_value.cpp1847
-rw-r--r--Utilities/cmjsoncpp/src/lib_json/json_writer.cpp1420
117 files changed, 3360 insertions, 3057 deletions
diff --git a/.codespellrc b/.codespellrc
index ba0fba6..a8be487 100644
--- a/.codespellrc
+++ b/.codespellrc
@@ -5,5 +5,5 @@ count =
# Disable warnings about binary files
quiet-level = 2
builtin = clear,rare,en-GB_to_en-US
-skip = */.git,*/build,*/Copyright.txt,*/doxygen.config,*/Modules/Internal/CPack/NSIS.template.in,*/Source/CursesDialog/form/*,*/Source/kwsys/*,*/Tests/RunCMake/CPack/tests/DMG_SLA/German.*,*/Utilities/cm*
+skip = */.git,*/build,*/Copyright.txt,*/doxygen.config,*/Modules/Internal/CPack/NSIS.template.in,*/Source/CursesDialog/form/*,*/Source/kwsys/*,*/Tests/RunCMake/CPack/tests/DMG_SLA/German.*,*/Tests/RunCMake/ParseImplicitData/*.input,*/Utilities/cm*
ignore-words-list = aci,ake,ans,ba,cconfiguration,conly,dependees,dne,dum,earch,ect,filetest,fo,helpfull,hiden,isnt,keypair,nd,ned,nin,nknown,ot,pard,seh,ser,te,upto,varn,vas,wee
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index aac1d9c..236eac9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -129,6 +129,15 @@ lint:fedora34-sphinx:
CMAKE_CI_JOB_CONTINUOUS: "true"
CMAKE_CI_JOB_HELP: "true"
+lint:fedora34-clang-analyzer:
+ extends:
+ - .fedora34_clang_analyzer
+ - .cmake_build_linux
+ - .linux_builder_tags_qt
+ - .run_automatically
+ variables:
+ CMAKE_CI_JOB_NIGHTLY: "true"
+
# Linux builds
build:centos6-x86_64:
@@ -167,6 +176,16 @@ test:debian10-aarch64-ninja:
variables:
CMAKE_CI_NO_MR: "true"
+test:debian10-makefiles-clang:
+ extends:
+ - .debian10_makefiles_clang
+ - .cmake_test_linux_release
+ - .linux_builder_tags_qt
+ - .run_manually
+ - .needs_centos6_x86_64
+ variables:
+ CMAKE_CI_JOB_NIGHTLY: "true"
+
test:fedora34-makefiles:
extends:
- .fedora34_makefiles
diff --git a/.gitlab/ci/configure_debian10_makefiles_clang.cmake b/.gitlab/ci/configure_debian10_makefiles_clang.cmake
new file mode 100644
index 0000000..20863a2
--- /dev/null
+++ b/.gitlab/ci/configure_debian10_makefiles_clang.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")
diff --git a/.gitlab/ci/configure_fedora34_clang_analyzer.cmake b/.gitlab/ci/configure_fedora34_clang_analyzer.cmake
new file mode 100644
index 0000000..e00f8a7
--- /dev/null
+++ b/.gitlab/ci/configure_fedora34_clang_analyzer.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora34_common.cmake")
diff --git a/.gitlab/ci/docker/fedora34/install_deps.sh b/.gitlab/ci/docker/fedora34/install_deps.sh
index dfd7db8..7d099fe 100755
--- a/.gitlab/ci/docker/fedora34/install_deps.sh
+++ b/.gitlab/ci/docker/fedora34/install_deps.sh
@@ -25,6 +25,7 @@ dnf install --setopt=install_weak_deps=False -y \
# Install lint tools.
dnf install --setopt=install_weak_deps=False -y \
+ clang-analyzer \
codespell
# Tools needed for the test suite.
diff --git a/.gitlab/ci/env_debian10_makefiles_clang.sh b/.gitlab/ci/env_debian10_makefiles_clang.sh
new file mode 100644
index 0000000..e0d5d61
--- /dev/null
+++ b/.gitlab/ci/env_debian10_makefiles_clang.sh
@@ -0,0 +1,2 @@
+export CC=/usr/bin/clang-7
+export CXX=/usr/bin/clang++-7
diff --git a/.gitlab/ci/env_fedora34_clang_analyzer.sh b/.gitlab/ci/env_fedora34_clang_analyzer.sh
new file mode 100644
index 0000000..d732c0b
--- /dev/null
+++ b/.gitlab/ci/env_fedora34_clang_analyzer.sh
@@ -0,0 +1,2 @@
+export CC=/usr/libexec/ccc-analyzer
+export CXX=/usr/libexec/c++-analyzer
diff --git a/.gitlab/ci/sccache.sh b/.gitlab/ci/sccache.sh
index 12b8f9d..b6b3751 100755
--- a/.gitlab/ci/sccache.sh
+++ b/.gitlab/ci/sccache.sh
@@ -2,57 +2,42 @@
set -e
-readonly kernel="$(uname -s)-$(uname -m)"
-case $kernel in
- Linux-x86_64)
- version="v0.2.15"
- shatool="sha256sum"
- sha256sum="e5d03a9aa3b9fac7e490391bbe22d4f42c840d31ef9eaf127a03101930cbb7ca"
- platform="x86_64-unknown-linux-musl"
- ;;
+readonly version="0.2.15-background-init"
+readonly build_date="20210602.0"
+
+case "$( uname -s )-$(uname -m)" in
Linux-aarch64)
- version="v0.2.15"
shatool="sha256sum"
- sha256sum="90d91d21a767e3f558196dbd52395f6475c08de5c4951a4c8049575fa6894489"
+ sha256sum="28b9ad3f591874551a3f4c5c1ff32456d3328c15d7bd8bc63b4e5948a94f1def"
platform="aarch64-unknown-linux-musl"
;;
- Darwin-x86_64)
- version="gfe63078"
- shatool="shasum -a 256"
- sha256sum="60a0302b1d7227f7ef56abd82266353f570d27c6e850c56c6448bf62def38888"
- platform="x86_64-apple-darwin"
- url="https://paraview.org/files/dependencies"
+ Linux-x86_64)
+ shatool="sha256sum"
+ sha256sum="34d62d30eae1a4145f00d62b01ad21c3456e28f11f8246c936b00cccf4855016"
+ platform="x86_64-unknown-linux-musl"
;;
- Darwin-arm64)
- version="0.2.15-1-disk_cache_init"
+ Darwin-x86_64|Darwin-arm64)
shatool="shasum -a 256"
- sha256sum="f7c9ff78e701810b8b1dbc2a163c7fda1177fc3f69c71f46e7a38242657a99fd"
- platform="aarch64-apple-darwin"
- url="https://cmake.org/files/dependencies/sccache"
+ sha256sum="2fa396e98cc8d07e39429b187a77386db63d35409902251d462080bdd0087c22"
+ platform="universal-apple-darwin"
;;
*)
- echo "Unrecognized platform $kernel"
+ echo "Unrecognized platform $( uname -s )-$( uname -m )"
exit 1
;;
esac
-readonly version
readonly shatool
readonly sha256sum
readonly platform
-readonly filename="sccache-$version-$platform"
-readonly tarball="$filename.tar.gz"
+readonly filename="sccache-v$version-$platform"
-if [ -z "$url" ]; then
- url="https://github.com/mozilla/sccache/releases/download/$version"
-fi
-readonly url
+readonly url="https://gitlab.kitware.com/api/v4/projects/6955/packages/generic/sccache/v$version-$build_date/"
cd .gitlab
-echo "$sha256sum $tarball" > sccache.sha256sum
-curl -OL "$url/$tarball"
+echo "$sha256sum $filename" > sccache.sha256sum
+curl -OL "$url/$filename"
$shatool --check sccache.sha256sum
-tar xf "$tarball"
-mv "$filename/sccache" .
+mv "$filename" sccache
chmod +x sccache
diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml
index dcaa643..015df4f 100644
--- a/.gitlab/os-linux.yml
+++ b/.gitlab/os-linux.yml
@@ -69,7 +69,7 @@
### Fedora
.fedora34:
- image: "kitware/cmake:ci-fedora34-x86_64-2021-05-21"
+ image: "kitware/cmake:ci-fedora34-x86_64-2021-06-03"
variables:
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci/long file name for testing purposes"
@@ -85,6 +85,15 @@
CTEST_NO_WARNINGS_ALLOWED: 1
CMake_SKIP_INSTALL: 1
+.fedora34_clang_analyzer:
+ extends: .fedora34
+
+ variables:
+ CMAKE_CONFIGURATION: fedora34_clang_analyzer
+ CMAKE_BUILD_TYPE: Debug
+ CTEST_NO_WARNINGS_ALLOWED: 1
+ CMake_SKIP_INSTALL: 1
+
.fedora34_sphinx:
extends: .fedora34
@@ -140,6 +149,15 @@
CTEST_NO_WARNINGS_ALLOWED: 1
CMAKE_GENERATOR: "Unix Makefiles"
+### Clang Compiler
+
+.debian10_makefiles_clang:
+ extends: .debian10
+
+ variables:
+ CMAKE_CONFIGURATION: debian10_makefiles_clang
+ CMAKE_GENERATOR: "Unix Makefiles"
+
### Intel Compiler
.intelcompiler:
diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in
index 238ca15..093c1d8 100644
--- a/CTestCustom.cmake.in
+++ b/CTestCustom.cmake.in
@@ -83,28 +83,21 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
"compilation completed with warnings" # PGI
"[0-9]+ Warning\\(s\\) detected" # SunPro
- # scanbuild exceptions
- "char_traits.h:.*: warning: Null pointer argument in call to string length function"
- "stl_construct.h:.*: warning: Forming reference to null pointer"
- ".*stl_uninitialized.h:75:19: warning: Forming reference to null pointer.*"
- ".*stl_vector.h:.*: warning: Returning null reference.*"
- "warning: Value stored to 'yymsg' is never read"
- "warning: Value stored to 'yytoken' is never read"
- "index_encoder.c.241.2. warning: Value stored to .out_start. is never read"
- "index.c.*warning: Access to field.*results in a dereference of a null pointer.*loaded from variable.*"
- "cmCommandArgumentLexer.cxx:[0-9]+:[0-9]+: warning: Call to 'realloc' has an allocation size of 0 bytes"
- "cmDependsJavaLexer.cxx:[0-9]+:[0-9]+: warning: Call to 'realloc' has an allocation size of 0 bytes"
- "cmExprLexer.cxx:[0-9]+:[0-9]+: warning: Call to 'realloc' has an allocation size of 0 bytes"
- "cmListFileLexer.c:[0-9]+:[0-9]+: warning: Call to 'realloc' has an allocation size of 0 bytes"
- "cmFortranLexer.cxx:[0-9]+:[0-9]+: warning: Call to 'realloc' has an allocation size of 0 bytes"
- "testProcess.*warning: Dereference of null pointer .loaded from variable .invalidAddress.."
+ # clang-analyzer exceptions
+ "cmListFileLexer.c:[0-9]+:[0-9]+: warning: Array subscript is undefined"
+ "jsoncpp/src/.*:[0-9]+:[0-9]+: warning: Value stored to .* is never read"
+ "liblzma/common/index_encoder.c:[0-9]+:[0-9]+: warning: Value stored to '[^']+' during its initialization is never read"
+ "liblzma/liblzma/common/index.c:[0-9]+:[0-9]+: warning: Access to field '[^']+' results in a dereference of a null pointer"
"liblzma/simple/x86.c:[0-9]+:[0-9]+: warning: The result of the '<<' expression is undefined"
- "liblzma/common/index_encoder.c:[0-9]+:[0-9]+: warning: Value stored to .* during its initialization is never read"
- "libuv/src/.*:[0-9]+:[0-9]+: warning: Dereference of null pointer"
- "libuv/src/.*:[0-9]+:[0-9]+: warning: The left operand of '==' is a garbage value"
+ "librhash/librhash/.*:[0-9]+:[0-9]+: warning: The left operand of '[^']+' is a garbage value"
"libuv/src/.*:[0-9]+:[0-9]+: warning: 1st function call argument is an uninitialized value"
+ "libuv/src/.*:[0-9]+:[0-9]+: warning: Dereference of null pointer"
+ "libuv/src/.*:[0-9]+:[0-9]+: warning: The left operand of '[^']+' is a garbage value"
+ "nghttp2/lib/.*:[0-9]+:[0-9]+: warning: Access to field '[^']+' results in a dereference of a null pointer"
"nghttp2/lib/.*:[0-9]+:[0-9]+: warning: Dereference of null pointer"
- "nghttp2/lib/.*:[0-9]+:[0-9]+: warning: Value stored to .* is never read"
+ "nghttp2/lib/.*:[0-9]+:[0-9]+: warning: Value stored to '[^']+' is never read"
+ "zstd/lib/.*:[0-9]+:[0-9]+: warning: Assigned value is garbage or undefined"
+ "zstd/lib/.*:[0-9]+:[0-9]+: warning: Dereference of null pointer"
)
if(NOT "@CMAKE_GENERATOR@" MATCHES "Xcode")
diff --git a/Help/cpack_gen/freebsd.rst b/Help/cpack_gen/freebsd.rst
index 2c93569..f429bc5 100644
--- a/Help/cpack_gen/freebsd.rst
+++ b/Help/cpack_gen/freebsd.rst
@@ -74,7 +74,7 @@ the RPM information (e.g. package license).
* Default:
- :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` (this may be set already
- for Debian packaging, so we may as well re-use it).
+ for Debian packaging, so it is used as a fallback).
.. variable:: CPACK_FREEBSD_PACKAGE_WWW
@@ -87,7 +87,7 @@ the RPM information (e.g. package license).
- :variable:`CMAKE_PROJECT_HOMEPAGE_URL`, or if that is not set,
:variable:`CPACK_DEBIAN_PACKAGE_HOMEPAGE` (this may be set already
- for Debian packaging, so we may as well re-use it).
+ for Debian packaging, so it is used as a fallback).
.. versionadded:: 3.12
The ``CMAKE_PROJECT_HOMEPAGE_URL`` variable.
diff --git a/Help/envvar/CMAKE_TOOLCHAIN_FILE.rst b/Help/envvar/CMAKE_TOOLCHAIN_FILE.rst
new file mode 100644
index 0000000..7ea9cea
--- /dev/null
+++ b/Help/envvar/CMAKE_TOOLCHAIN_FILE.rst
@@ -0,0 +1,12 @@
+CMAKE_TOOLCHAIN_FILE
+--------------------
+
+.. versionadded:: 3.21
+
+.. include:: ENV_VAR.txt
+
+The ``CMAKE_TOOLCHAIN_FILE`` environment variable specifies a default value
+for the :variable:`CMAKE_TOOLCHAIN_FILE` variable when there is no explicit
+configuration given on the first run while creating a new build tree.
+On later runs in an existing build tree the value persists in the cache
+as :variable:`CMAKE_TOOLCHAIN_FILE`.
diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst
index 8932abf..bfdc841 100644
--- a/Help/manual/cmake-env-variables.7.rst
+++ b/Help/manual/cmake-env-variables.7.rst
@@ -41,6 +41,7 @@ Environment Variables that Control the Build
/envvar/CMAKE_MSVCIDE_RUN_PATH
/envvar/CMAKE_NO_VERBOSE
/envvar/CMAKE_OSX_ARCHITECTURES
+ /envvar/CMAKE_TOOLCHAIN_FILE
/envvar/DESTDIR
/envvar/LDFLAGS
/envvar/MACOSX_DEPLOYMENT_TARGET
diff --git a/Help/prop_sf/COMPILE_FLAGS.rst b/Help/prop_sf/COMPILE_FLAGS.rst
index c211b89..eefe7bf 100644
--- a/Help/prop_sf/COMPILE_FLAGS.rst
+++ b/Help/prop_sf/COMPILE_FLAGS.rst
@@ -4,8 +4,11 @@ COMPILE_FLAGS
Additional flags to be added when compiling this source file.
The ``COMPILE_FLAGS`` property, managed as a string, sets additional compiler
-flags used to build source files. Use :prop_sf:`COMPILE_DEFINITIONS` to pass
-additional preprocessor definitions.
+flags used that will be added to the list of compile flags when this source
+file builds. The flags will be added after target-wide flags (except in
+some cases not supported by the :generator:`Visual Studio 9 2008` generator).
+
+Use :prop_sf:`COMPILE_DEFINITIONS` to pass additional preprocessor definitions.
Contents of ``COMPILE_FLAGS`` may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
diff --git a/Help/prop_sf/COMPILE_OPTIONS.rst b/Help/prop_sf/COMPILE_OPTIONS.rst
index a694c3e..84c543a 100644
--- a/Help/prop_sf/COMPILE_OPTIONS.rst
+++ b/Help/prop_sf/COMPILE_OPTIONS.rst
@@ -5,9 +5,10 @@ COMPILE_OPTIONS
List of additional options to pass to the compiler.
-This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of options
-and will be added to the list of compile flags when this
-source file builds.
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>`
+of options and will be added to the list of compile flags when this source
+file builds. The options will be added after target-wide options (except in
+some cases not supported by the :generator:`Visual Studio 9 2008` generator).
Contents of ``COMPILE_OPTIONS`` may use "generator expressions" with the
syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual
diff --git a/Help/prop_tgt/COMPILE_OPTIONS.rst b/Help/prop_tgt/COMPILE_OPTIONS.rst
index 4bc190a..0fd6aac 100644
--- a/Help/prop_tgt/COMPILE_OPTIONS.rst
+++ b/Help/prop_tgt/COMPILE_OPTIONS.rst
@@ -3,9 +3,13 @@ COMPILE_OPTIONS
List of options to pass to the compiler.
-This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of options
-specified so far for its target. Use the :command:`target_compile_options`
-command to append more options.
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>`
+of options specified so far for its target. Use the
+:command:`target_compile_options` command to append more options.
+The options will be added after after flags in the
+:variable:`CMAKE_<LANG>_FLAGS` and :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>`
+variables, but before those propagated from dependencies by the
+:prop_tgt:`INTERFACE_COMPILE_OPTIONS` property.
This property is initialized by the :prop_dir:`COMPILE_OPTIONS` directory
property when a target is created, and is used by the generators to set
diff --git a/Help/prop_tgt/IMPORTED_OBJECTS.rst b/Help/prop_tgt/IMPORTED_OBJECTS.rst
index f3577eb..d71c219 100644
--- a/Help/prop_tgt/IMPORTED_OBJECTS.rst
+++ b/Help/prop_tgt/IMPORTED_OBJECTS.rst
@@ -68,26 +68,24 @@ architecture:
# /path/to/somewhere/objects-iphonesimulator/x86_64/func.o
In some cases, you may want to have configuration-specific object files
-as well. The :variable:`CMAKE_CFG_INTDIR` variable can be a convenient
-way of capturing this in combination with the SDK:
+as well. The ``$(CONFIGURATION)`` Xcode variable is often used for this and
+can be used in conjunction with the others mentioned above:
.. code-block:: cmake
add_library(someObjs OBJECT IMPORTED)
set_property(TARGET someObjs PROPERTY IMPORTED_OBJECTS
- "/path/to/somewhere/${CMAKE_CFG_INTDIR}/$(CURRENT_ARCH)/func.o"
+ "/path/to/somewhere/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/$(CURRENT_ARCH)/func.o"
)
# Example paths:
# /path/to/somewhere/Release-iphoneos/arm64/func.o
# /path/to/somewhere/Debug-iphonesimulator/x86_64/func.o
-When any Xcode variable or :variable:`CMAKE_CFG_INTDIR` is used, CMake is
-not able to fully evaluate the path(s) at configure time. One consequence
-of this is that the configuration-specific
-:prop_tgt:`IMPORTED_OBJECTS_<CONFIG>` properties cannot be used, since
-CMake cannot determine whether an object file exists at a particular
-``<CONFIG>`` location. The ``IMPORTED_OBJECTS`` property must be used for
-these situations and the configuration-specific aspects of the path must be
-handled by using :variable:`CMAKE_CFG_INTDIR` or with another Xcode variable
-``$(CONFIGURATION)``.
+When any Xcode variable is used, CMake is not able to fully evaluate the
+path(s) at configure time. One consequence of this is that the
+configuration-specific :prop_tgt:`IMPORTED_OBJECTS_<CONFIG>` properties cannot
+be used, since CMake cannot determine whether an object file exists at a
+particular ``<CONFIG>`` location. The ``IMPORTED_OBJECTS`` property must be
+used for these situations and the configuration-specific aspects of the path
+should be handled by the ``$(CONFIGURATION)`` Xcode variable.
diff --git a/Help/release/dev/compile-options-order.rst b/Help/release/dev/compile-options-order.rst
new file mode 100644
index 0000000..2e182cd
--- /dev/null
+++ b/Help/release/dev/compile-options-order.rst
@@ -0,0 +1,7 @@
+compile-options-order
+---------------------
+
+* The :ref:`Visual Studio Generators` for VS 2010 and above now place
+ per-source preprocessor definitions after target-wide preprocssor
+ definitions. This makes VS consistent with the :ref:`Ninja Generators`
+ and the :ref:`Makefile Generators`.
diff --git a/Help/release/dev/env-toolchain-file.rst b/Help/release/dev/env-toolchain-file.rst
new file mode 100644
index 0000000..0bcd493
--- /dev/null
+++ b/Help/release/dev/env-toolchain-file.rst
@@ -0,0 +1,5 @@
+env-toolchain-file
+------------------
+
+* The :envvar:`CMAKE_TOOLCHAIN_FILE` environment variable was added to
+ provide a default value for the :variable:`CMAKE_TOOLCHAIN_FILE` variable.
diff --git a/Help/variable/CMAKE_CONFIGURATION_TYPES.rst b/Help/variable/CMAKE_CONFIGURATION_TYPES.rst
index 34e99eb..8fcc798 100644
--- a/Help/variable/CMAKE_CONFIGURATION_TYPES.rst
+++ b/Help/variable/CMAKE_CONFIGURATION_TYPES.rst
@@ -6,5 +6,7 @@ Specifies the available build types on multi-config generators.
This specifies what build types (configurations) will be available
such as ``Debug``, ``Release``, ``RelWithDebInfo`` etc. This has reasonable
defaults on most platforms, but can be extended to provide other build
-types. See also :variable:`CMAKE_BUILD_TYPE` for details of managing
-configuration data, and :variable:`CMAKE_CFG_INTDIR`.
+types.
+
+See :variable:`CMAKE_BUILD_TYPE` for specifying the configuration with
+single-config generators.
diff --git a/Help/variable/CMAKE_LANG_FLAGS.rst b/Help/variable/CMAKE_LANG_FLAGS.rst
index 11864f8..2784397 100644
--- a/Help/variable/CMAKE_LANG_FLAGS.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS.rst
@@ -18,3 +18,8 @@ This is initialized for each language from environment variables:
This value is a command-line string fragment. Therefore, multiple options
should be separated by spaces, and options with spaces should be quoted.
+
+The flags in this variable will be passed to the compiler before those
+in the per-configuration :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variant,
+and before flags added by the :command:`add_compile_options` or
+:command:`target_compile_options` commands.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst
index 628b62b..f0900fd 100644
--- a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst
@@ -1,6 +1,9 @@
CMAKE_<LANG>_FLAGS_<CONFIG>
---------------------------
-.. versionadded:: 3.11
-
Flags for language ``<LANG>`` when building for the ``<CONFIG>`` configuration.
+
+The flags in this variable will be passed to the compiler after those
+in the :variable:`CMAKE_<LANG>_FLAGS` variable, but before flags added
+by the :command:`add_compile_options` or :command:`target_compile_options`
+commands.
diff --git a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst
index e462c5e..ff8d59a 100644
--- a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst
+++ b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst
@@ -10,3 +10,6 @@ platform and compiler related information.
Relative paths are allowed and are interpreted first as relative to the
build directory, and if not found, relative to the source directory.
+
+This is initialized by the :envvar:`CMAKE_TOOLCHAIN_FILE` environment
+variable if it is set when a new build tree is first created.
diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake
index e848b55..a61f71b 100644
--- a/Modules/CMakeParseImplicitLinkInfo.cmake
+++ b/Modules/CMakeParseImplicitLinkInfo.cmake
@@ -72,6 +72,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
endif()
endif()
set(is_msvc 0)
+ set(search_static 0)
if("${cmd}" MATCHES "${linker_regex}")
string(APPEND log " link line: [${line}]\n")
string(REGEX REPLACE ";-([LYz]);" ";-\\1" args "${args}")
@@ -103,6 +104,10 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
elseif("${arg}" MATCHES "^-l([^:].*)$")
# Unix library.
set(lib "${CMAKE_MATCH_1}")
+ if(search_static AND lib MATCHES "^(gfortran|stdc\\+\\+)$")
+ # Search for the static library later, once all link dirs are known.
+ set(lib "SEARCH_STATIC:${lib}")
+ endif()
list(APPEND implicit_libs_tmp ${lib})
string(APPEND log " arg [${arg}] ==> lib [${lib}]\n")
elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.a$")
@@ -129,6 +134,12 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
string(REPLACE ":" ";" dirs "${dirs}")
list(APPEND implicit_dirs_tmp ${dirs})
string(APPEND log " arg [${arg}] ==> dirs [${dirs}]\n")
+ elseif("${arg}" STREQUAL "-Bstatic")
+ set(search_static 1)
+ string(APPEND log " arg [${arg}] ==> search static\n" )
+ elseif("${arg}" STREQUAL "-Bdynamic")
+ set(search_static 0)
+ string(APPEND log " arg [${arg}] ==> search dynamic\n" )
elseif("${arg}" MATCHES "^-l:")
# HP named library.
list(APPEND implicit_libs_tmp ${arg})
@@ -172,8 +183,29 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
# We remove items that are not language-specific.
set(implicit_libs "")
foreach(lib IN LISTS implicit_libs_tmp)
+ if("x${lib}" MATCHES "^xSEARCH_STATIC:(.*)")
+ set(search_static 1)
+ set(lib "${CMAKE_MATCH_1}")
+ else()
+ set(search_static 0)
+ endif()
if("x${lib}" MATCHES "^x(crt.*\\.o|gcc_eh.*|.*libgcc_eh.*|System.*|.*libclang_rt.*|msvcrt.*|libvcruntime.*|libucrt.*|libcmt.*)$")
string(APPEND log " remove lib [${lib}]\n")
+ elseif(search_static)
+ # This library appears after a -Bstatic flag. Due to ordering
+ # and filtering for mixed-language link lines, we do not preserve
+ # the -Bstatic flag itself. Instead, use an absolute path.
+ # Search using a temporary variable with a distinct name
+ # so that our test suite does not depend on disk content.
+ find_library("CMAKE_${lang}_IMPLICIT_LINK_LIBRARY_${lib}" NO_CACHE NAMES "lib${lib}.a" NO_DEFAULT_PATH PATHS ${implicit_dirs_tmp})
+ set(_lib_static "${CMAKE_${lang}_IMPLICIT_LINK_LIBRARY_${lib}}")
+ if(_lib_static)
+ string(APPEND log " search lib [SEARCH_STATIC:${lib}] ==> [${_lib_static}]\n")
+ list(APPEND implicit_libs "${_lib_static}")
+ else()
+ string(APPEND log " search lib [SEARCH_STATIC:${lib}] ==> [${lib}]\n")
+ list(APPEND implicit_libs "${lib}")
+ endif()
elseif(IS_ABSOLUTE "${lib}")
get_filename_component(abs "${lib}" ABSOLUTE)
if(NOT "x${lib}" STREQUAL "x${abs}")
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index 324ae27..f7605c4 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -1405,6 +1405,7 @@ function(_Boost_COMPONENT_HEADERS component _hdrs)
set(_Boost_LOCALE_HEADERS "boost/locale.hpp")
set(_Boost_LOG_HEADERS "boost/log/core.hpp")
set(_Boost_LOG_SETUP_HEADERS "boost/log/detail/setup_config.hpp")
+ set(_Boost_JSON_HEADERS "boost/json.hpp")
set(_Boost_MATH_HEADERS "boost/math_fwd.hpp")
set(_Boost_MATH_C99_HEADERS "boost/math/tr1.hpp")
set(_Boost_MATH_C99F_HEADERS "boost/math/tr1.hpp")
diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake
index b1afa5f..8474e05 100644
--- a/Modules/FindOpenSSL.cmake
+++ b/Modules/FindOpenSSL.cmake
@@ -123,6 +123,10 @@ function(_OpenSSL_target_add_dependencies target)
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads )
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} )
endif()
+ if(WIN32 AND OPENSSL_USE_STATIC_LIBS)
+ set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ws2_32 )
+ set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES crypt32 )
+ endif()
endfunction()
if (UNIX)
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index 38c8da7..3bc9dba 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -265,9 +265,7 @@ endfunction()
# create an imported target from all the information returned by pkg-config
function(_pkg_create_imp_target _prefix _imp_target_global)
- # only create the target if it is linkable, i.e. no executables
- if (NOT TARGET PkgConfig::${_prefix}
- AND ( ${_prefix}_INCLUDE_DIRS OR ${_prefix}_LINK_LIBRARIES OR ${_prefix}_LDFLAGS_OTHER OR ${_prefix}_CFLAGS_OTHER ))
+ if (NOT TARGET PkgConfig::${_prefix})
if(${_imp_target_global})
set(_global_opt "GLOBAL")
else()
diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake
index 2ef0489..2ceab10 100644
--- a/Modules/Internal/CPack/CPackDeb.cmake
+++ b/Modules/Internal/CPack/CPackDeb.cmake
@@ -557,7 +557,7 @@ function(cpack_deb_prepare_package_vars)
string(APPEND _description_failure_message
" or CPACK_DEBIAN_${_local_component_name}_DESCRIPTION")
endif()
- message(FATAL_ERROR _description_failure_message)
+ message(FATAL_ERROR "${_description_failure_message}")
endif()
# Ok, description has set. According to the `Debian Policy Manual`_ the first
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 7be1b9e..7915a9c 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 20)
-set(CMake_VERSION_PATCH 20210603)
+set(CMake_VERSION_PATCH 20210608)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/LexerParser/cmCTestResourceGroupsLexer.cxx b/Source/LexerParser/cmCTestResourceGroupsLexer.cxx
index de07c46..85b379b 100644
--- a/Source/LexerParser/cmCTestResourceGroupsLexer.cxx
+++ b/Source/LexerParser/cmCTestResourceGroupsLexer.cxx
@@ -659,7 +659,7 @@ Modify cmCTestResourceGroupsLexer.cxx:
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
#include "cmCTestResourceGroupsLexerHelper.h"
diff --git a/Source/LexerParser/cmCTestResourceGroupsLexer.in.l b/Source/LexerParser/cmCTestResourceGroupsLexer.in.l
index 2aabea4..2befa85 100644
--- a/Source/LexerParser/cmCTestResourceGroupsLexer.in.l
+++ b/Source/LexerParser/cmCTestResourceGroupsLexer.in.l
@@ -18,7 +18,7 @@ Modify cmCTestResourceGroupsLexer.cxx:
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
#include "cmCTestResourceGroupsLexerHelper.h"
diff --git a/Source/LexerParser/cmCommandArgumentLexer.cxx b/Source/LexerParser/cmCommandArgumentLexer.cxx
index 46220ff..4b7eb79 100644
--- a/Source/LexerParser/cmCommandArgumentLexer.cxx
+++ b/Source/LexerParser/cmCommandArgumentLexer.cxx
@@ -664,7 +664,7 @@ Modify cmCommandArgumentLexer.cxx:
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
#include "cmCommandArgumentParserHelper.h"
diff --git a/Source/LexerParser/cmCommandArgumentLexer.in.l b/Source/LexerParser/cmCommandArgumentLexer.in.l
index 8ad2335..6b4f9a9 100644
--- a/Source/LexerParser/cmCommandArgumentLexer.in.l
+++ b/Source/LexerParser/cmCommandArgumentLexer.in.l
@@ -18,7 +18,7 @@ Modify cmCommandArgumentLexer.cxx:
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
#include "cmCommandArgumentParserHelper.h"
diff --git a/Source/LexerParser/cmDependsJavaLexer.cxx b/Source/LexerParser/cmDependsJavaLexer.cxx
index d703e3c..bfe7e64 100644
--- a/Source/LexerParser/cmDependsJavaLexer.cxx
+++ b/Source/LexerParser/cmDependsJavaLexer.cxx
@@ -860,7 +860,7 @@ Modify cmDependsJavaLexer.cxx:
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
#include <iostream>
diff --git a/Source/LexerParser/cmDependsJavaLexer.in.l b/Source/LexerParser/cmDependsJavaLexer.in.l
index 3dd3c22..942e007 100644
--- a/Source/LexerParser/cmDependsJavaLexer.in.l
+++ b/Source/LexerParser/cmDependsJavaLexer.in.l
@@ -18,7 +18,7 @@ Modify cmDependsJavaLexer.cxx:
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
#include <iostream>
diff --git a/Source/LexerParser/cmExprLexer.cxx b/Source/LexerParser/cmExprLexer.cxx
index 72e59b6..5a76590 100644
--- a/Source/LexerParser/cmExprLexer.cxx
+++ b/Source/LexerParser/cmExprLexer.cxx
@@ -664,7 +664,7 @@ Modify cmExprLexer.cxx:
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
#include "cmExprParserHelper.h"
diff --git a/Source/LexerParser/cmExprLexer.in.l b/Source/LexerParser/cmExprLexer.in.l
index f8a4224..90c1cc3 100644
--- a/Source/LexerParser/cmExprLexer.in.l
+++ b/Source/LexerParser/cmExprLexer.in.l
@@ -18,7 +18,7 @@ Modify cmExprLexer.cxx:
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
#include "cmExprParserHelper.h"
diff --git a/Source/LexerParser/cmFortranLexer.cxx b/Source/LexerParser/cmFortranLexer.cxx
index bcda77c..c3d0000 100644
--- a/Source/LexerParser/cmFortranLexer.cxx
+++ b/Source/LexerParser/cmFortranLexer.cxx
@@ -838,7 +838,7 @@ Modify cmFortranLexer.cxx:
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
#undef YY_NO_UNPUT
diff --git a/Source/LexerParser/cmFortranLexer.in.l b/Source/LexerParser/cmFortranLexer.in.l
index 3d38a7d..05769a1 100644
--- a/Source/LexerParser/cmFortranLexer.in.l
+++ b/Source/LexerParser/cmFortranLexer.in.l
@@ -27,7 +27,7 @@ Modify cmFortranLexer.cxx:
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
#undef YY_NO_UNPUT
diff --git a/Source/LexerParser/cmGccDepfileLexer.cxx b/Source/LexerParser/cmGccDepfileLexer.cxx
index 3630f4e..194ae0c 100644
--- a/Source/LexerParser/cmGccDepfileLexer.cxx
+++ b/Source/LexerParser/cmGccDepfileLexer.cxx
@@ -645,7 +645,7 @@ static const flex_int16_t yy_chk[46] =
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
#include <cmGccDepfileLexerHelper.h>
#include <string>
diff --git a/Source/LexerParser/cmGccDepfileLexer.in.l b/Source/LexerParser/cmGccDepfileLexer.in.l
index c83cb75..aa2351e 100644
--- a/Source/LexerParser/cmGccDepfileLexer.in.l
+++ b/Source/LexerParser/cmGccDepfileLexer.in.l
@@ -4,7 +4,7 @@
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+#ifndef __clang_analyzer__ /* Suppress clang-analyzer warnings */
#include <cmGccDepfileLexerHelper.h>
#include <string>
diff --git a/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx b/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx
index 1effda0..f14de55 100644
--- a/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx
+++ b/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx
@@ -8,6 +8,7 @@
#include <cmsys/RegularExpression.hxx>
#include "cmRuntimeDependencyArchive.h"
+#include "cmSystemTools.h"
#include "cmUVProcessChain.h"
cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool::
@@ -42,8 +43,8 @@ bool cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool::GetFileInfo(
std::string line;
static const cmsys::RegularExpression regex(
- "^\t*DLL Name: ([^\n]*\\.[Dd][Ll][Ll])\r$");
- while (std::getline(*process.OutputStream(), line)) {
+ "^\t*DLL Name: ([^\n]*\\.[Dd][Ll][Ll])$");
+ while (cmSystemTools::GetLineFromStream(*process.OutputStream(), line)) {
cmsys::RegularExpressionMatch match;
if (regex.find(line.c_str(), match)) {
needed.push_back(match.match(1));
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index 2c15c25..2d6745c 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -878,6 +878,7 @@ Json::Value DirectoryObject::DumpInstallers()
Json::Value DirectoryObject::DumpInstaller(cmInstallGenerator* gen)
{
+ assert(gen);
Json::Value installer = Json::objectValue;
// Exclude subdirectory installers and file(GET_RUNTIME_DEPENDENCIES)
diff --git a/Source/cmStandardLevelResolver.cxx b/Source/cmStandardLevelResolver.cxx
index 85411e6..b198a00 100644
--- a/Source/cmStandardLevelResolver.cxx
+++ b/Source/cmStandardLevelResolver.cxx
@@ -62,7 +62,7 @@ struct StanardLevelComputer
, Levels(std::move(levels))
, LevelsAsStrings(std::move(levelsStr))
{
- assert(levels.size() == levelsStr.size());
+ assert(this->Levels.size() == this->LevelsAsStrings.size());
}
std::string GetCompileOptionDef(cmMakefile* makefile,
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 937b4ce..505d58a 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -418,7 +418,9 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
}
std::ostringstream oss;
- const char* sep = "";
+ if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
+ oss << "%(" << tag << ")";
+ }
std::vector<std::string>::const_iterator de =
cmRemoveDuplicates(this->Defines);
for (std::string const& di : cmMakeRange(this->Defines.cbegin(), de)) {
@@ -437,11 +439,7 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
}
}
// Store the flag in the project file.
- oss << sep << define;
- sep = ";";
- }
- if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
- oss << ";%(" << tag << ")";
+ oss << ';' << define;
}
this->OutputFlag(fout, indent, tag, oss.str());
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 840a9d9..9a866ab 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2040,6 +2040,16 @@ int cmake::ActualConfigure()
this->GlobalGenerator->GetExtraGeneratorName().c_str(),
"Name of external makefile project generator.",
cmStateEnums::INTERNAL);
+
+ if (!this->State->GetInitializedCacheValue("CMAKE_TOOLCHAIN_FILE")) {
+ std::string envToolchain;
+ if (cmSystemTools::GetEnv("CMAKE_TOOLCHAIN_FILE", envToolchain) &&
+ !envToolchain.empty()) {
+ this->AddCacheEntry("CMAKE_TOOLCHAIN_FILE", envToolchain.c_str(),
+ "The CMake toolchain file",
+ cmStateEnums::FILEPATH);
+ }
+ }
}
if (cmProp instance =
diff --git a/Templates/MSBuild/FlagTables/v141_CL.json b/Templates/MSBuild/FlagTables/v141_CL.json
index 01fafe4..5b18e32 100644
--- a/Templates/MSBuild/FlagTables/v141_CL.json
+++ b/Templates/MSBuild/FlagTables/v141_CL.json
@@ -421,8 +421,29 @@
},
{
"name": "SpectreMitigation",
+ "switch": "Qspectre-load-cf",
+ "comment": "All Control Flow Loads",
+ "value": "SpectreLoadCF",
+ "flags": []
+ },
+ {
+ "name": "SpectreMitigation",
+ "switch": "Qspectre-load",
+ "comment": "All Loads",
+ "value": "SpectreLoad",
+ "flags": []
+ },
+ {
+ "name": "SpectreMitigation",
+ "switch": "Qspectre-",
+ "comment": "Disabled",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "SpectreMitigation",
"switch": "Qspectre",
- "comment": "Spectre mitigations",
+ "comment": "Enabled",
"value": "Spectre",
"flags": []
},
@@ -589,6 +610,20 @@
"flags": []
},
{
+ "name": "SupportJustMyCode",
+ "switch": "JMC-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "SupportJustMyCode",
+ "switch": "JMC",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
"name": "CompileAsWinRT",
"switch": "ZW",
"comment": "Consume Windows Runtime Extension",
@@ -812,7 +847,7 @@
{
"name": "ConformanceMode",
"switch": "permissive-",
- "comment": "Conformance mode enabled",
+ "comment": "Conformance mode",
"value": "true",
"flags": []
},
@@ -1250,19 +1285,5 @@
"comment": "C++14 (GNU Dialect)",
"value": "gnu++1y",
"flags": []
- },
- {
- "name": "SupportJustMyCode",
- "switch": "JMC-",
- "comment": "",
- "value": "false",
- "flags": []
- },
- {
- "name": "SupportJustMyCode",
- "switch": "JMC",
- "comment": "",
- "value": "true",
- "flags": []
}
]
diff --git a/Templates/MSBuild/FlagTables/v142_CL.json b/Templates/MSBuild/FlagTables/v142_CL.json
index 3305e56..650ff6c 100644
--- a/Templates/MSBuild/FlagTables/v142_CL.json
+++ b/Templates/MSBuild/FlagTables/v142_CL.json
@@ -386,6 +386,13 @@
},
{
"name": "EnableEnhancedInstructionSet",
+ "switch": "arch:AVX512",
+ "comment": "Advanced Vector Extensions 512",
+ "value": "AdvancedVectorExtensions512",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
"switch": "arch:IA32",
"comment": "No Enhanced Instructions",
"value": "NoExtensions",
@@ -421,19 +428,47 @@
},
{
"name": "SpectreMitigation",
+ "switch": "Qspectre-load-cf",
+ "comment": "All Control Flow Loads",
+ "value": "SpectreLoadCF",
+ "flags": []
+ },
+ {
+ "name": "SpectreMitigation",
+ "switch": "Qspectre-load",
+ "comment": "All Loads",
+ "value": "SpectreLoad",
+ "flags": []
+ },
+ {
+ "name": "SpectreMitigation",
"switch": "Qspectre-",
- "comment": "Spectre mitigations disabled",
+ "comment": "Disabled",
"value": "false",
"flags": []
},
{
"name": "SpectreMitigation",
"switch": "Qspectre",
- "comment": "Spectre mitigations enabled",
+ "comment": "Enabled",
"value": "Spectre",
"flags": []
},
{
+ "name": "ConformanceMode",
+ "switch": "permissive-",
+ "comment": "Yes",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ConformanceMode",
+ "switch": "permissive",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
"name": "LanguageStandard",
"switch": "std:c++14",
"comment": "ISO C++14 Standard",
@@ -617,6 +652,27 @@
"flags": []
},
{
+ "name": "CompileAs",
+ "switch": "interface",
+ "comment": "Compile as C++ Module Code",
+ "value": "CompileAsCppModule",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "internalPartition",
+ "comment": "Compile as C++ Module Internal Partition",
+ "value": "CompileAsCppModuleInternalPartition",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "exportHeader",
+ "comment": "Compile as C++ Header Unit",
+ "value": "CompileAsHeaderUnit",
+ "flags": []
+ },
+ {
"name": "ErrorReporting",
"switch": "errorReport:none",
"comment": "Do Not Send Report",
@@ -719,6 +775,13 @@
]
},
{
+ "name": "ForceSynchronousPDBWrites",
+ "switch": "FS",
+ "comment": "Force Synchronous PDB Writes",
+ "value": "true",
+ "flags": []
+ },
+ {
"name": "IntrinsicFunctions",
"switch": "Oi",
"comment": "Enable Intrinsic Functions",
@@ -789,6 +852,20 @@
"flags": []
},
{
+ "name": "UseStandardPreprocessor",
+ "switch": "Zc:preprocessor-",
+ "comment": "Use Standard Conforming Preprocessor",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "UseStandardPreprocessor",
+ "switch": "Zc:preprocessor",
+ "comment": "Use Standard Conforming Preprocessor",
+ "value": "true",
+ "flags": []
+ },
+ {
"name": "StringPooling",
"switch": "GF-",
"comment": "Enable String Pooling",
@@ -873,27 +950,48 @@
"flags": []
},
{
- "name": "DisableLanguageExtensions",
- "switch": "Za",
- "comment": "Disable Language Extensions",
+ "name": "IntelJCCErratum",
+ "switch": "QIntel-jcc-erratum",
+ "comment": "Enable Intel JCC Erratum Mitigation",
"value": "true",
"flags": []
},
{
- "name": "ConformanceMode",
- "switch": "permissive-",
- "comment": "Conformance mode enabled",
+ "name": "GuardEHContMetadata",
+ "switch": "guard:ehcont-",
+ "comment": "Enable EH Continuation Metadata",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "GuardEHContMetadata",
+ "switch": "guard:ehcont",
+ "comment": "Enable EH Continuation Metadata",
"value": "true",
"flags": []
},
{
- "name": "ConformanceMode",
- "switch": "permissive",
- "comment": "Conformance mode disabled",
+ "name": "GuardSignedReturns",
+ "switch": "guard:signret-",
+ "comment": "Enable Signed Returns",
"value": "false",
"flags": []
},
{
+ "name": "GuardSignedReturns",
+ "switch": "guard:signret",
+ "comment": "Enable Signed Returns",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DisableLanguageExtensions",
+ "switch": "Za",
+ "comment": "Disable Language Extensions",
+ "value": "true",
+ "flags": []
+ },
+ {
"name": "TreatWChar_tAsBuiltInType",
"switch": "Zc:wchar_t-",
"comment": "Treat WChar_t As Built in Type",
@@ -980,7 +1078,7 @@
{
"name": "EnableModules",
"switch": "experimental:module",
- "comment": "Enable C++ Modules (experimental)",
+ "comment": "Enable Experimental C++ Standard Library Modules",
"value": "true",
"flags": []
},
@@ -999,6 +1097,15 @@
"flags": []
},
{
+ "name": "GenerateModuleDependencies",
+ "switch": "sourceDependencies:directives",
+ "comment": "Generate Module Dependenices File",
+ "value": "true",
+ "flags": [
+ "Continue"
+ ]
+ },
+ {
"name": "GenerateXMLDocumentationFiles",
"switch": "doc",
"comment": "Generate XML Documentation Files",
@@ -1010,6 +1117,15 @@
]
},
{
+ "name": "GenerateSourceDependencies",
+ "switch": "sourceDependencies",
+ "comment": "Generate Source Dependencies File",
+ "value": "true",
+ "flags": [
+ "Continue"
+ ]
+ },
+ {
"name": "BrowseInformation",
"switch": "FR",
"comment": "Enable Browse Information",
@@ -1021,6 +1137,27 @@
]
},
{
+ "name": "TreatAngleIncludeAsExternal",
+ "switch": "external:anglebrackets",
+ "comment": "Treat Files Included with Angle Brackets as External",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ExternalTemplatesDiagnostics",
+ "switch": "external:templates-",
+ "comment": "Template Diagnostics in External Headers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DisableAnalyzeExternal",
+ "switch": "analyze:external-",
+ "comment": "Disable Code Analysis for External Headers",
+ "value": "true",
+ "flags": []
+ },
+ {
"name": "ShowIncludes",
"switch": "showIncludes",
"comment": "Show Includes",
@@ -1076,6 +1213,36 @@
]
},
{
+ "name": "AdditionalBMIDirectories",
+ "switch": "ifcSearchDir",
+ "comment": "Additional BMI Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalModuleDependencies",
+ "switch": "reference",
+ "comment": "Additional Module Dependencies",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalHeaderUnitDependencies",
+ "switch": "headerUnit",
+ "comment": "Additional Header Unit Dependencies",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
"name": "PreprocessorDefinitions",
"switch": "D",
"comment": "Preprocessor Definitions",
@@ -1096,6 +1263,26 @@
]
},
{
+ "name": "StdIfcDirectory",
+ "switch": "stdIfcDir",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ExternalDirectoriesEnv",
+ "switch": "external:env:",
+ "comment": "External Directories Environment Variables",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
"name": "DisableSpecificWarnings",
"switch": "wd",
"comment": "Disable Specific Warnings",
@@ -1211,6 +1398,24 @@
]
},
{
+ "name": "ModuleOutputFile",
+ "switch": "ifcOutput",
+ "comment": "Module Output File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ModuleDependenciesFile",
+ "switch": "sourceDependencies:directives",
+ "comment": "Module Dependencies File Name",
+ "value": "",
+ "flags": [
+ "UserFollowing"
+ ]
+ },
+ {
"name": "ObjectFileName",
"switch": "Fo",
"comment": "Object File Name",
@@ -1239,6 +1444,15 @@
]
},
{
+ "name": "SourceDependenciesFile",
+ "switch": "sourceDependencies",
+ "comment": "Source Dependencies File Name",
+ "value": "",
+ "flags": [
+ "UserFollowing"
+ ]
+ },
+ {
"name": "BrowseInformationFile",
"switch": "FR",
"comment": "Browse Information File",
diff --git a/Tests/CMakeLib/testOptional.cxx b/Tests/CMakeLib/testOptional.cxx
index 2d7dd7c..9d4b72a 100644
--- a/Tests/CMakeLib/testOptional.cxx
+++ b/Tests/CMakeLib/testOptional.cxx
@@ -301,12 +301,14 @@ static bool testMoveConstruct(std::vector<Event>& expected)
cm::optional<EventLogger> o3{};
const cm::optional<EventLogger> o4{ std::move(o3) };
+#ifndef __clang_analyzer__ /* cplusplus.Move */
expected = {
{ Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
{ Event::MOVE_CONSTRUCT, &*o2, &*o1, 4 },
{ Event::DESTRUCT, &*o2, nullptr, 4 },
{ Event::DESTRUCT, &*o1, nullptr, 4 },
};
+#endif
return true;
}
diff --git a/Tests/CMakeLib/testString.cxx b/Tests/CMakeLib/testString.cxx
index ad800cf..5a9cad1 100644
--- a/Tests/CMakeLib/testString.cxx
+++ b/Tests/CMakeLib/testString.cxx
@@ -326,12 +326,14 @@ static bool testConstructMove()
std::cout << "testConstructMove()\n";
cm::String s1 = std::string("abc");
cm::String s2 = std::move(s1);
+#ifndef __clang_analyzer__ /* cplusplus.Move */
ASSERT_TRUE(s1.data() == nullptr);
ASSERT_TRUE(s1.size() == 0);
ASSERT_TRUE(s2.size() == 3);
ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
ASSERT_TRUE(s1.is_stable());
ASSERT_TRUE(s2.is_stable());
+#endif
return true;
}
@@ -356,12 +358,14 @@ static bool testAssignMove()
cm::String s1 = std::string("abc");
cm::String s2;
s2 = std::move(s1);
+#ifndef __clang_analyzer__ /* cplusplus.Move */
ASSERT_TRUE(s1.data() == nullptr);
ASSERT_TRUE(s1.size() == 0);
ASSERT_TRUE(s2.size() == 3);
ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
ASSERT_TRUE(s1.is_stable());
ASSERT_TRUE(s2.is_stable());
+#endif
return true;
}
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 1005016..fccf15b 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -490,6 +490,11 @@ if(BUILD_TESTING)
if(CMAKE_Fortran_COMPILER)
set(CompileOptions_BUILD_OPTIONS -DTEST_FORTRAN=1)
endif()
+ if(_isMultiConfig)
+ set(CompileOptions_CTEST_OPTIONS --build-config $<CONFIGURATION>)
+ else()
+ set(CompileOptions_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=$<CONFIGURATION>)
+ endif()
ADD_TEST_MACRO(CompileOptions CompileOptions)
ADD_TEST_MACRO(CompatibleInterface CompatibleInterface)
ADD_TEST_MACRO(AliasTarget AliasTarget)
diff --git a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in
index 1254ff9..63c234a 100644
--- a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in
+++ b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in
@@ -2,6 +2,9 @@
# test it.
include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake)
+set(CMAKE_FIND_LIBRARY_PREFIXES "disabled-for-test-")
+set(CMAKE_FIND_LIBRARY_SUFFIXES "-disabled-for-test")
+
#-----------------------------------------------------------------------------
# Linux
diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt
index cd6cacd..96bafea 100644
--- a/Tests/CompileOptions/CMakeLists.txt
+++ b/Tests/CompileOptions/CMakeLists.txt
@@ -1,5 +1,11 @@
-cmake_minimum_required(VERSION 2.8.12)
-
+cmake_minimum_required(VERSION 3.0)
+if(POLICY CMP0092)
+ cmake_policy(SET CMP0092 NEW)
+endif()
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(NOT _isMultiConfig AND NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build" FORCE)
+endif()
project(CompileOptions)
add_library(testlib other.cpp)
@@ -49,6 +55,24 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland|Embarcadero" AND NOT "${CMAK
)
endif()
+if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|AppleClang|MSVC)$")
+ target_compile_definitions(CompileOptions PRIVATE "DO_FLAG_TESTS")
+ if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|AppleClang)$")
+ string(APPEND CMAKE_CXX_FLAGS " -w")
+ endif()
+ string(APPEND CMAKE_CXX_FLAGS " -DFLAG_A=1 -DFLAG_B=1")
+ string(APPEND CMAKE_CXX_FLAGS_DEBUG " -DFLAG_A=2 -DFLAG_C=1")
+ string(APPEND CMAKE_CXX_FLAGS_RELEASE " -DFLAG_A=2 -DFLAG_C=1")
+ string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -DFLAG_A=2 -DFLAG_C=1")
+ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL " -DFLAG_A=2 -DFLAG_C=1")
+ set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS "-DFLAG_B=2" "-DFLAG_C=2" "-DFLAG_D=1")
+ set_property(TARGET testlib APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "-DFLAG_D=2")
+ if(NOT CMAKE_GENERATOR MATCHES "^Visual Studio 9")
+ set_property(TARGET testlib APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "-DFLAG_E=1")
+ set_property(SOURCE main.cpp PROPERTY COMPILE_OPTIONS "-DFLAG_E=2")
+ endif()
+endif()
+
target_link_libraries(CompileOptions testlib)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp
index ebc1017..23ce197 100644
--- a/Tests/CompileOptions/main.cpp
+++ b/Tests/CompileOptions/main.cpp
@@ -37,6 +37,24 @@
# endif
#endif
+#ifdef DO_FLAG_TESTS
+# if FLAG_A != 2
+# error "FLAG_A is not 2"
+# endif
+# if FLAG_B != 2
+# error "FLAG_B is not 2"
+# endif
+# if FLAG_C != 2
+# error "FLAG_C is not 2"
+# endif
+# if FLAG_D != 2
+# error "FLAG_D is not 2"
+# endif
+# if defined(FLAG_E) && FLAG_E != 2
+# error "FLAG_E is not 2"
+# endif
+#endif
+
#include <string.h>
int main()
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index d02d7a2..670abbc 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -595,7 +595,10 @@ set_property(TEST RunCMake.target_link_options APPEND
add_RunCMake_test(target_compile_definitions)
add_RunCMake_test(target_compile_features)
-add_RunCMake_test(target_compile_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
+add_RunCMake_test(target_compile_options
+ -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
+ -DCMAKE_C_SIMULATE_ID=${CMAKE_C_SIMULATE_ID}
+ )
add_RunCMake_test(target_include_directories)
add_RunCMake_test(target_sources)
add_RunCMake_test(CheckCompilerFlag -DCMake_TEST_CUDA=${CMake_TEST_CUDA}
diff --git a/Tests/RunCMake/CommandLine/EnvToolchain-toolchain.cmake b/Tests/RunCMake/CommandLine/EnvToolchain-toolchain.cmake
new file mode 100644
index 0000000..d9fbd58
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvToolchain-toolchain.cmake
@@ -0,0 +1 @@
+set(ENV_TOOLCHAIN 1)
diff --git a/Tests/RunCMake/CommandLine/EnvToolchain.cmake b/Tests/RunCMake/CommandLine/EnvToolchain.cmake
new file mode 100644
index 0000000..230051d
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvToolchain.cmake
@@ -0,0 +1,3 @@
+message(STATUS "ENV{CMAKE_TOOLCHAIN_FILE}='$ENV{CMAKE_TOOLCHAIN_FILE}'")
+message(STATUS "CMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}'")
+message(STATUS "ENV_TOOLCHAIN='${ENV_TOOLCHAIN}'")
diff --git a/Tests/RunCMake/CommandLine/EnvToolchainAbsolute-stdout.txt b/Tests/RunCMake/CommandLine/EnvToolchainAbsolute-stdout.txt
new file mode 100644
index 0000000..ab4bbde
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvToolchainAbsolute-stdout.txt
@@ -0,0 +1,5 @@
+-- ENV{CMAKE_TOOLCHAIN_FILE}='[^
+]*/Tests/RunCMake/CommandLine/EnvToolchain-toolchain.cmake'
+-- CMAKE_TOOLCHAIN_FILE='[^
+]*/Tests/RunCMake/CommandLine/EnvToolchain-toolchain.cmake'
+-- ENV_TOOLCHAIN='1'
diff --git a/Tests/RunCMake/CommandLine/EnvToolchainAbsolute.cmake b/Tests/RunCMake/CommandLine/EnvToolchainAbsolute.cmake
new file mode 100644
index 0000000..0f91b5e
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvToolchainAbsolute.cmake
@@ -0,0 +1 @@
+include(EnvToolchain.cmake)
diff --git a/Tests/RunCMake/CommandLine/EnvToolchainIgnore-stdout.txt b/Tests/RunCMake/CommandLine/EnvToolchainIgnore-stdout.txt
new file mode 100644
index 0000000..4de9505
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvToolchainIgnore-stdout.txt
@@ -0,0 +1,4 @@
+-- ENV{CMAKE_TOOLCHAIN_FILE}='[^
+]*/Tests/RunCMake/CommandLine/EnvToolchain-toolchain.cmake'
+-- CMAKE_TOOLCHAIN_FILE=''
+-- ENV_TOOLCHAIN=''
diff --git a/Tests/RunCMake/CommandLine/EnvToolchainIgnore.cmake b/Tests/RunCMake/CommandLine/EnvToolchainIgnore.cmake
new file mode 100644
index 0000000..0f91b5e
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvToolchainIgnore.cmake
@@ -0,0 +1 @@
+include(EnvToolchain.cmake)
diff --git a/Tests/RunCMake/CommandLine/EnvToolchainNone-stdout.txt b/Tests/RunCMake/CommandLine/EnvToolchainNone-stdout.txt
new file mode 100644
index 0000000..cfe655d
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvToolchainNone-stdout.txt
@@ -0,0 +1,3 @@
+-- ENV{CMAKE_TOOLCHAIN_FILE}=''
+-- CMAKE_TOOLCHAIN_FILE=''
+-- ENV_TOOLCHAIN=''
diff --git a/Tests/RunCMake/CommandLine/EnvToolchainNone.cmake b/Tests/RunCMake/CommandLine/EnvToolchainNone.cmake
new file mode 100644
index 0000000..0f91b5e
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvToolchainNone.cmake
@@ -0,0 +1 @@
+include(EnvToolchain.cmake)
diff --git a/Tests/RunCMake/CommandLine/EnvToolchainNoneExisting-stdout.txt b/Tests/RunCMake/CommandLine/EnvToolchainNoneExisting-stdout.txt
new file mode 100644
index 0000000..4de9505
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvToolchainNoneExisting-stdout.txt
@@ -0,0 +1,4 @@
+-- ENV{CMAKE_TOOLCHAIN_FILE}='[^
+]*/Tests/RunCMake/CommandLine/EnvToolchain-toolchain.cmake'
+-- CMAKE_TOOLCHAIN_FILE=''
+-- ENV_TOOLCHAIN=''
diff --git a/Tests/RunCMake/CommandLine/EnvToolchainRelative-stdout.txt b/Tests/RunCMake/CommandLine/EnvToolchainRelative-stdout.txt
new file mode 100644
index 0000000..4bafbba
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvToolchainRelative-stdout.txt
@@ -0,0 +1,4 @@
+-- ENV{CMAKE_TOOLCHAIN_FILE}='EnvToolchain-toolchain.cmake'
+-- CMAKE_TOOLCHAIN_FILE='[^
+]*/Tests/RunCMake/CommandLine/EnvToolchainRelative-build/EnvToolchain-toolchain.cmake'
+-- ENV_TOOLCHAIN='1'
diff --git a/Tests/RunCMake/CommandLine/EnvToolchainRelative.cmake b/Tests/RunCMake/CommandLine/EnvToolchainRelative.cmake
new file mode 100644
index 0000000..0f91b5e
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvToolchainRelative.cmake
@@ -0,0 +1 @@
+include(EnvToolchain.cmake)
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index 2eb8784..c4d3e4a 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -344,6 +344,33 @@ if(RunCMake_GENERATOR MATCHES "Unix Makefiles" OR RunCMake_GENERATOR MATCHES "Ni
run_EnvironmentExportCompileCommands()
endif()
+function(run_EnvironmentToolchain)
+ set(ENV{CMAKE_TOOLCHAIN_FILE} "${RunCMake_SOURCE_DIR}/EnvToolchain-toolchain.cmake")
+ run_cmake(EnvToolchainAbsolute)
+ run_cmake_with_options(EnvToolchainIgnore -DCMAKE_TOOLCHAIN_FILE=)
+ unset(ENV{CMAKE_TOOLCHAIN_FILE})
+
+ set(ENV{CMAKE_TOOLCHAIN_FILE} "EnvToolchain-toolchain.cmake")
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/EnvToolchainRelative-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ configure_file("${RunCMake_SOURCE_DIR}/EnvToolchain-toolchain.cmake" "${RunCMake_TEST_BINARY_DIR}/EnvToolchain-toolchain.cmake" COPYONLY)
+ run_cmake(EnvToolchainRelative)
+ unset(ENV{CMAKE_TOOLCHAIN_FILE})
+ unset(RunCMake_TEST_NO_CLEAN)
+
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/EnvToolchainNone-build)
+ run_cmake(EnvToolchainNone)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/CMakeFiles")
+ set(ENV{CMAKE_TOOLCHAIN_FILE} "${RunCMake_SOURCE_DIR}/EnvToolchain-toolchain.cmake")
+ run_cmake_command(EnvToolchainNoneExisting ${CMAKE_COMMAND} .)
+ unset(ENV{CMAKE_TOOLCHAIN_FILE})
+ unset(RunCMake_TEST_NO_CLEAN)
+endfunction()
+run_EnvironmentToolchain()
+
if(RunCMake_GENERATOR STREQUAL "Ninja")
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Build-build)
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_empty_target.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_empty_target.cmake
new file mode 100644
index 0000000..cb3dd69
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_empty_target.cmake
@@ -0,0 +1,17 @@
+# Prepare environment to reuse empty.pc
+file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-empty/lib/pkgconfig" PC_PATH)
+if(UNIX)
+ string(REPLACE "\\ " " " PC_PATH "${PC_PATH}")
+endif()
+set(ENV{PKG_CONFIG_PATH} "${PC_PATH}")
+
+find_package(PkgConfig REQUIRED)
+pkg_search_module(Empty REQUIRED empty IMPORTED_TARGET)
+
+if(NOT Empty_MODULE_NAME STREQUAL "empty")
+ message(FATAL_ERROR "Wrong value for Empty_MODULE_NAME. Expected: empty, got: ${Empty_MODULE_NAME}")
+endif()
+
+if(NOT TARGET PkgConfig::Empty)
+ message(FATAL_ERROR "PkgConfig::Empty target not created")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
index 4e6eef6..e7f008c 100644
--- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
@@ -29,4 +29,5 @@ if (PKG_CONFIG_FOUND)
run_cmake(FindPkgConfig_IMPORTED_TARGET)
run_cmake(FindPkgConfig_VERSION_OPERATORS)
run_cmake(FindPkgConfig_GET_MATCHING_MODULE_NAME)
+ run_cmake(FindPkgConfig_empty_target)
endif ()
diff --git a/Tests/RunCMake/FindPkgConfig/pc-empty/lib/pkgconfig/empty.pc b/Tests/RunCMake/FindPkgConfig/pc-empty/lib/pkgconfig/empty.pc
new file mode 100644
index 0000000..954c5f8
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-empty/lib/pkgconfig/empty.pc
@@ -0,0 +1,5 @@
+Name: Empty
+Description: Dummy package to test empty target
+Version: 1.0
+Libs:
+Cflags:
diff --git a/Tests/RunCMake/ParseImplicitData/linux-C-GNU-10.2.1-static-libgcc.input b/Tests/RunCMake/ParseImplicitData/linux-C-GNU-10.2.1-static-libgcc.input
new file mode 100644
index 0000000..0aaf05e
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-C-GNU-10.2.1-static-libgcc.input
@@ -0,0 +1,74 @@
+CMAKE_LANG=C
+CMAKE_LINKER=/usr/bin/ld
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=/usr/bin/gcc-ar-10
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=GNU
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=/usr/bin/gcc-ranlib-10
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=10.2.1
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_2fff5/fast && /usr/bin/gmake -f CMakeFiles/cmTC_2fff5.dir/build.make CMakeFiles/cmTC_2fff5.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_2fff5.dir/CMakeCCompilerABI.c.o
+/usr/bin/gcc -static-libgcc -v -o CMakeFiles/cmTC_2fff5.dir/CMakeCCompilerABI.c.o -c "/tmp/CMake/Modules/CMakeCCompilerABI.c"
+Using built-in specs.
+COLLECT_GCC=/usr/bin/gcc
+OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
+Thread model: posix
+Supported LTO compression algorithms: zlib zstd
+gcc version 10.2.1 20210110 (Debian 10.2.1-6)
+COLLECT_GCC_OPTIONS='-static-libgcc' '-v' '-o' 'CMakeFiles/cmTC_2fff5.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/10/cc1 -quiet -v -imultiarch x86_64-linux-gnu /tmp/CMake/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_2fff5.dir/CMakeCCompilerABI.c.o -version -fasynchronous-unwind-tables -o /tmp/cc1V18pC.s
+GNU C17 (Debian 10.2.1-6) version 10.2.1 20210110 (x86_64-linux-gnu)
+ compiled by GNU C version 10.2.1 20210110, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.23-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/10/include-fixed"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/lib/gcc/x86_64-linux-gnu/10/include
+ /usr/local/include
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+GNU C17 (Debian 10.2.1-6) version 10.2.1 20210110 (x86_64-linux-gnu)
+ compiled by GNU C version 10.2.1 20210110, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.23-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+Compiler executable checksum: 1f803793fa2e3418c492b25e7d3eac2f
+COLLECT_GCC_OPTIONS='-static-libgcc' '-v' '-o' 'CMakeFiles/cmTC_2fff5.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64'
+ as -v --64 -o CMakeFiles/cmTC_2fff5.dir/CMakeCCompilerABI.c.o /tmp/cc1V18pC.s
+GNU assembler version 2.35.2 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.35.2
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-static-libgcc' '-v' '-o' 'CMakeFiles/cmTC_2fff5.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64'
+Linking C executable cmTC_2fff5
+"/tmp/CMake/bin/cmake" -E cmake_link_script CMakeFiles/cmTC_2fff5.dir/link.txt --verbose=1
+/usr/bin/gcc -static-libgcc -v -rdynamic CMakeFiles/cmTC_2fff5.dir/CMakeCCompilerABI.c.o -o cmTC_2fff5
+Using built-in specs.
+COLLECT_GCC=/usr/bin/gcc
+COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
+OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
+Thread model: posix
+Supported LTO compression algorithms: zlib zstd
+gcc version 10.2.1 20210110 (Debian 10.2.1-6)
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-static-libgcc' '-v' '-rdynamic' '-o' 'cmTC_2fff5' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/10/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/10/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper -plugin-opt=-fresolution=/tmp/cc0iqkvc.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -o cmTC_2fff5 /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/10/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/10 -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/10/../../.. CMakeFiles/cmTC_2fff5.dir/CMakeCCompilerABI.c.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/gcc/x86_64-linux-gnu/10/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crtn.o
+COLLECT_GCC_OPTIONS='-static-libgcc' '-v' '-rdynamic' '-o' 'cmTC_2fff5' '-mtune=generic' '-march=x86-64'
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-CXX-GNU-10.2.1-static-libstdc++.input b/Tests/RunCMake/ParseImplicitData/linux-CXX-GNU-10.2.1-static-libstdc++.input
new file mode 100644
index 0000000..387f149
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-CXX-GNU-10.2.1-static-libstdc++.input
@@ -0,0 +1,79 @@
+CMAKE_LANG=CXX
+CMAKE_LINKER=/usr/bin/ld
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=/usr/bin/gcc-ar-10
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=GNU
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=/usr/bin/gcc-ranlib-10
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=10.2.1
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+CMAKE_CXX_IMPLICIT_LINK_LIBRARY_stdc++=/usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_339dd/fast && /usr/bin/gmake -f CMakeFiles/cmTC_339dd.dir/build.make CMakeFiles/cmTC_339dd.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_339dd.dir/CMakeCXXCompilerABI.cpp.o
+/usr/bin/g++ -static-libstdc++ -v -o CMakeFiles/cmTC_339dd.dir/CMakeCXXCompilerABI.cpp.o -c "/tmp/CMake/Modules/CMakeCXXCompilerABI.cpp"
+Using built-in specs.
+COLLECT_GCC=/usr/bin/g++
+OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
+Thread model: posix
+Supported LTO compression algorithms: zlib zstd
+gcc version 10.2.1 20210110 (Debian 10.2.1-6)
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_339dd.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/10/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_339dd.dir/CMakeCXXCompilerABI.cpp.o -version -fasynchronous-unwind-tables -o /tmp/ccjKk4SK.s
+GNU C++14 (Debian 10.2.1-6) version 10.2.1 20210110 (x86_64-linux-gnu)
+ compiled by GNU C version 10.2.1 20210110, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.23-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/10"
+ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/10/include-fixed"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/include/c++/10
+ /usr/include/x86_64-linux-gnu/c++/10
+ /usr/include/c++/10/backward
+ /usr/lib/gcc/x86_64-linux-gnu/10/include
+ /usr/local/include
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+GNU C++14 (Debian 10.2.1-6) version 10.2.1 20210110 (x86_64-linux-gnu)
+ compiled by GNU C version 10.2.1 20210110, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.23-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+Compiler executable checksum: 048fcaee3460a99eb0d68522358720e1
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_339dd.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+ as -v --64 -o CMakeFiles/cmTC_339dd.dir/CMakeCXXCompilerABI.cpp.o /tmp/ccjKk4SK.s
+GNU assembler version 2.35.2 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.35.2
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_339dd.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+Linking CXX executable cmTC_339dd
+"/tmp/CMake/bin/cmake" -E cmake_link_script CMakeFiles/cmTC_339dd.dir/link.txt --verbose=1
+/usr/bin/g++ -static-libstdc++ -v -rdynamic CMakeFiles/cmTC_339dd.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_339dd
+Using built-in specs.
+COLLECT_GCC=/usr/bin/g++
+COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
+OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
+Thread model: posix
+Supported LTO compression algorithms: zlib zstd
+gcc version 10.2.1 20210110 (Debian 10.2.1-6)
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_339dd' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/10/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/10/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper -plugin-opt=-fresolution=/tmp/cc0slq0h.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -o cmTC_339dd /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/10/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/10 -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/10/../../.. CMakeFiles/cmTC_339dd.dir/CMakeCXXCompilerABI.cpp.o -Bstatic -lstdc++ -Bdynamic -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/10/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crtn.o
+COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_339dd' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-Fortran-GNU-10.2.1-static-libgfortran.input b/Tests/RunCMake/ParseImplicitData/linux-Fortran-GNU-10.2.1-static-libgfortran.input
new file mode 100644
index 0000000..16b38d2
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-Fortran-GNU-10.2.1-static-libgfortran.input
@@ -0,0 +1,79 @@
+CMAKE_LANG=Fortran
+CMAKE_LINKER=/usr/bin/ld
+CMAKE_Fortran_COMPILER_ABI=
+CMAKE_Fortran_COMPILER_AR=/usr/bin/gcc-ar-10
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=GNU
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=/usr/bin/gcc-ranlib-10
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=10.2.1
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+CMAKE_Fortran_IMPLICIT_LINK_LIBRARY_gfortran=/usr/lib/gcc/x86_64-linux-gnu/10/libgfortran.a
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_07a63/fast && /usr/bin/gmake -f CMakeFiles/cmTC_07a63.dir/build.make CMakeFiles/cmTC_07a63.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_07a63.dir/CMakeFortranCompilerABI.F.o
+/usr/bin/gfortran -static-libgfortran -v -c "/tmp/CMake/Modules/CMakeFortranCompilerABI.F" -o CMakeFiles/cmTC_07a63.dir/CMakeFortranCompilerABI.F.o
+Using built-in specs.
+COLLECT_GCC=/usr/bin/gfortran
+OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
+Thread model: posix
+Supported LTO compression algorithms: zlib zstd
+gcc version 10.2.1 20210110 (Debian 10.2.1-6)
+COLLECT_GCC_OPTIONS='-static-libgfortran' '-v' '-c' '-o' 'CMakeFiles/cmTC_07a63.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/10/f951 /tmp/CMake/Modules/CMakeFortranCompilerABI.F -ffixed-form -cpp=/tmp/ccA5jWwS.f90 -quiet -v -imultiarch x86_64-linux-gnu /tmp/CMake/Modules/CMakeFortranCompilerABI.F -quiet -dumpbase CMakeFortranCompilerABI.F -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_07a63.dir/CMakeFortranCompilerABI.F.o -version -fintrinsic-modules-path /usr/lib/gcc/x86_64-linux-gnu/10/finclude -fpre-include=/usr/include/finclude/x86_64-linux-gnu/math-vector-fortran.h -o /tmp/cclOgAvW.s
+GNU Fortran (Debian 10.2.1-6) version 10.2.1 20210110 (x86_64-linux-gnu)
+ compiled by GNU C version 10.2.1 20210110, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.23-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/10/include-fixed"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/lib/gcc/x86_64-linux-gnu/10/finclude
+ /usr/lib/gcc/x86_64-linux-gnu/10/include
+ /usr/local/include
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+GNU Fortran2008 (Debian 10.2.1-6) version 10.2.1 20210110 (x86_64-linux-gnu)
+ compiled by GNU C version 10.2.1 20210110, GMP version 6.2.1, MPFR version 4.1.0, MPC version 1.2.0, isl version isl-0.23-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+COLLECT_GCC_OPTIONS='-static-libgfortran' '-v' '-c' '-o' 'CMakeFiles/cmTC_07a63.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64'
+ as -v --64 -o CMakeFiles/cmTC_07a63.dir/CMakeFortranCompilerABI.F.o /tmp/cclOgAvW.s
+GNU assembler version 2.35.2 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.35.2
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-static-libgfortran' '-v' '-c' '-o' 'CMakeFiles/cmTC_07a63.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64'
+Linking Fortran executable cmTC_07a63
+"/tmp/CMake/bin/cmake" -E cmake_link_script CMakeFiles/cmTC_07a63.dir/link.txt --verbose=1
+/usr/bin/gfortran -v -static-libgfortran CMakeFiles/cmTC_07a63.dir/CMakeFortranCompilerABI.F.o -o cmTC_07a63
+Driving: /usr/bin/gfortran -v -static-libgfortran CMakeFiles/cmTC_07a63.dir/CMakeFortranCompilerABI.F.o -o cmTC_07a63 -Wl,-Bstatic -l gfortran -Wl,-Bdynamic -l m -shared-libgcc
+Using built-in specs.
+COLLECT_GCC=/usr/bin/gfortran
+COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
+OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
+Thread model: posix
+Supported LTO compression algorithms: zlib zstd
+gcc version 10.2.1 20210110 (Debian 10.2.1-6)
+Reading specs from /usr/lib/gcc/x86_64-linux-gnu/10/libgfortran.spec
+rename spec lib to liborig
+COLLECT_GCC_OPTIONS='-v' '-static-libgfortran' '-o' 'cmTC_07a63' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-static-libgfortran' '-o' 'cmTC_07a63' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/10/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/10/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper -plugin-opt=-fresolution=/tmp/ccbtSp3p.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lquadmath -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -o cmTC_07a63 /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/10/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/10 -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/10/../../.. CMakeFiles/cmTC_07a63.dir/CMakeFortranCompilerABI.F.o -Bstatic -lgfortran -Bdynamic -lm -lgcc_s -lgcc --as-needed -lquadmath --no-as-needed -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/10/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crtn.o
+COLLECT_GCC_OPTIONS='-v' '-static-libgfortran' '-o' 'cmTC_07a63' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake b/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake
index 2d3abcc..e501f12 100644
--- a/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake
@@ -23,6 +23,9 @@ set(targets
hand-C-empty hand-CXX-empty
hand-C-relative hand-CXX-relative
linux-C-GNU-7.3.0 linux-CXX-GNU-7.3.0 linux-Fortran-GNU-7.3.0
+ linux-C-GNU-10.2.1-static-libgcc
+ linux-CXX-GNU-10.2.1-static-libstdc++
+ linux-Fortran-GNU-10.2.1-static-libgfortran
linux-C-Intel-18.0.0.20170811 linux-CXX-Intel-18.0.0.20170811
linux-C-PGI-18.10.1 linux-CXX-PGI-18.10.1
linux-Fortran-PGI-18.10.1 linux_pgf77-Fortran-PGI-18.10.1
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-GNU-10.2.1-static-libgcc.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-GNU-10.2.1-static-libgcc.output
new file mode 100644
index 0000000..2f89e15
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-GNU-10.2.1-static-libgcc.output
@@ -0,0 +1 @@
+/usr/lib/gcc/x86_64-linux-gnu/10/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-GNU-10.2.1-static-libstdc++.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-GNU-10.2.1-static-libstdc++.output
new file mode 100644
index 0000000..b97cdc8
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-GNU-10.2.1-static-libstdc++.output
@@ -0,0 +1 @@
+/usr/include/c\+\+/10;/usr/include/x86_64-linux-gnu/c\+\+/10;/usr/include/c\+\+/10/backward;/usr/lib/gcc/x86_64-linux-gnu/10/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-GNU-10.2.1-static-libgfortran.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-GNU-10.2.1-static-libgfortran.output
new file mode 100644
index 0000000..34c33a7
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-GNU-10.2.1-static-libgfortran.output
@@ -0,0 +1 @@
+/usr/lib/gcc/x86_64-linux-gnu/10/finclude;/usr/lib/gcc/x86_64-linux-gnu/10/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake
index 1f3468b..dcdc7f1 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake
@@ -23,6 +23,9 @@ set(targets
hand-C-empty hand-CXX-empty
hand-C-relative hand-CXX-relative
linux-C-GNU-7.3.0 linux-CXX-GNU-7.3.0 linux-Fortran-GNU-7.3.0
+ linux-C-GNU-10.2.1-static-libgcc
+ linux-CXX-GNU-10.2.1-static-libstdc++
+ linux-Fortran-GNU-10.2.1-static-libgfortran
linux-C-Intel-18.0.0.20170811 linux-CXX-Intel-18.0.0.20170811
linux-C-PGI-18.10.1 linux-CXX-PGI-18.10.1
linux-Fortran-PGI-18.10.1 linux_pgf77-Fortran-PGI-18.10.1
@@ -67,7 +70,7 @@ function(load_compiler_info infile lang_var outcmvars_var outstr_var)
string(REGEX REPLACE "\r?\n" ";" in_lines "${in}")
foreach(line IN LISTS in_lines)
# check for special CMAKE variable lines and parse them if found
- if("${line}" MATCHES "^CMAKE_([_A-Za-z0-9]+)=(.*)$")
+ if("${line}" MATCHES "^CMAKE_([_A-Za-z0-9+]+)=(.*)$")
if("${CMAKE_MATCH_1}" STREQUAL "LANG") # handle CMAKE_LANG here
set(lang "${CMAKE_MATCH_2}")
else()
@@ -162,12 +165,12 @@ foreach(t ${targets})
if("${state}" STREQUAL "done")
message("empty parse failed: ${idirs}, log=${log}")
endif()
- elseif(NOT "${idirs}" STREQUAL "${idirs_output}")
- message("${t} parse failed: state=${state}, '${idirs}' does not match '${idirs_output}'")
- elseif(NOT "${implicit_libs}" STREQUAL "${implicit_lib_output}")
- message("${t} parse failed: state=${state}, '${implicit_libs}' does not match '${implicit_lib_output}'")
- elseif((library_arch OR library_arch_output) AND NOT "${library_arch}" STREQUAL "${library_arch_output}")
- message("${t} parse failed: state=${state}, '${library_arch}' does not match '${library_arch_output}'")
+ elseif(NOT "${idirs}" MATCHES "^${idirs_output}$")
+ message("${t} parse failed: state=${state}, '${idirs}' does not match '^${idirs_output}$'")
+ elseif(NOT "${implicit_libs}" MATCHES "^${implicit_lib_output}$")
+ message("${t} parse failed: state=${state}, '${implicit_libs}' does not match '^${implicit_lib_output}$'")
+ elseif((library_arch OR library_arch_output) AND NOT "${library_arch}" MATCHES "^${library_arch_output}$")
+ message("${t} parse failed: state=${state}, '${library_arch}' does not match '^${library_arch_output}$'")
endif()
unload_compiler_info("${cmvars}")
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-CXX-XLClang-16.1.0.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-CXX-XLClang-16.1.0.1.output
index 2dc5832..3a57464 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-CXX-XLClang-16.1.0.1.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-CXX-XLClang-16.1.0.1.output
@@ -1,2 +1,2 @@
-libs=xlopt;xlipa;xl;c++;Ccore;pthreads;m;c
+libs=xlopt;xlipa;xl;c\+\+;Ccore;pthreads;m;c
dirs=/opt/IBM/xlmass/9.1.0/lib/aix61;/opt/IBM/xlc/16.1.0/lib;/opt/IBM/xlC/16.1.0/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-8.7.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-8.7.output
index 674975c..0373d89 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-8.7.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-8.7.output
@@ -1,2 +1,2 @@
-libs=AtpSigHandler;AtpSigHCommData;pthread;sci_cray_mpi_mp;m;f;sci_cray_mp;craymp;m;pthread;f;hugetlbfs;mpich_cray;rt;pthread;ugni;pmi;pgas-dmapp;fi;u;rt;dmapp;ugni;udreg;pthread;m;cray-c++-rts;stdc++;xpmem;dmapp;pthread;pmi;pthread;alpslli;pthread;wlm_detect;ugni;pthread;alpsutil;pthread;rca;udreg;quadmath;m;omp;rt;craymp;pthread;rt;dl;cray-c++-rts;stdc++;m;modules;m;rt;fi;m;quadmath;rt;craymath;m;gfortran;quadmath;rt;f;m;pthread;rt;u;rt;dl;cray-c++-rts;stdc++;m;csup;rt;atomic;stdc++;pthread;c;csup;m;gcc
+libs=AtpSigHandler;AtpSigHCommData;pthread;sci_cray_mpi_mp;m;f;sci_cray_mp;craymp;m;pthread;f;hugetlbfs;mpich_cray;rt;pthread;ugni;pmi;pgas-dmapp;fi;u;rt;dmapp;ugni;udreg;pthread;m;cray-c\+\+-rts;stdc\+\+;xpmem;dmapp;pthread;pmi;pthread;alpslli;pthread;wlm_detect;ugni;pthread;alpsutil;pthread;rca;udreg;quadmath;m;omp;rt;craymp;pthread;rt;dl;cray-c\+\+-rts;stdc\+\+;m;modules;m;rt;fi;m;quadmath;rt;craymath;m;gfortran;quadmath;rt;f;m;pthread;rt;u;rt;dl;cray-c\+\+-rts;stdc\+\+;m;csup;rt;atomic;stdc\+\+;pthread;c;csup;m;gcc
dirs=/opt/gcc/6.1.0/snos/lib64;/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/lib;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64;/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/lib64;/opt/cray/pe/pmi/5.0.14/lib64;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/pe/cce/8.7.4/cce/x86_64/lib;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64;/usr/lib64;/lib64;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0;/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-unknown-linux-gnu/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-9.0-hlist-ad.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-9.0-hlist-ad.output
index 1bf2f6d..0f52e8b 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-9.0-hlist-ad.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-9.0-hlist-ad.output
@@ -1,2 +1,2 @@
-libs=AtpSigHandler;AtpSigHCommData;rca;mpich_cray_90;sci_cray_mpi;sci_cray;pgas-dmapp;quadmath;modules;fi;craymath;f;u;csup;atomic;tcmalloc_minimal;cray-c++-rts;stdc++;pthread;c;csup;m;clang_rt.craypgo-x86_64;gcc
+libs=AtpSigHandler;AtpSigHCommData;rca;mpich_cray_90;sci_cray_mpi;sci_cray;pgas-dmapp;quadmath;modules;fi;craymath;f;u;csup;atomic;tcmalloc_minimal;cray-c\+\+-rts;stdc\+\+;pthread;c;csup;m;clang_rt.craypgo-x86_64;gcc
dirs=/opt/gcc/8.1.0/snos/lib64;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/lib;/opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/lib;/opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/pe/cce/9.0.0/cce/x86_64/lib;/usr/lib64;/lib64;/opt/cray/pe/cce/9.0.0/cce-clang/x86_64/lib/clang/9.0.0/lib/linux;/opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0;/opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-unknown-linux-gnu/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Intel-18.0.2.20180210.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Intel-18.0.2.20180210.output
index e9e6739..5b8ae8d 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Intel-18.0.2.20180210.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Intel-18.0.2.20180210.output
@@ -1,2 +1,2 @@
-libs=imf;svml;irng;m;ipgo;decimal;cilkrts;stdc++;gcc;gcc_s;irc;svml;c;gcc;gcc_s;irc_s;dl;c
+libs=imf;svml;irng;m;ipgo;decimal;cilkrts;stdc\+\+;gcc;gcc_s;irc;svml;c;gcc;gcc_s;irc_s;dl;c
dirs=/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0;/opt/gcc/6.3.0/snos/lib64;/lib64;/usr/lib64;/opt/gcc/6.3.0/snos/lib;/lib;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-8.7.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-8.7.output
index 7daa29d..00281d5 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-8.7.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-8.7.output
@@ -1,2 +1,2 @@
-libs=AtpSigHandler;AtpSigHCommData;pthread;sci_cray_mpi_mp;m;f;sci_cray_mp;craymp;m;pthread;f;hugetlbfs;mpichcxx_cray;rt;pthread;ugni;pmi;mpich_cray;rt;pthread;ugni;pmi;pgas-dmapp;fi;u;rt;dmapp;ugni;udreg;pthread;m;cray-c++-rts;stdc++;xpmem;dmapp;pthread;pmi;pthread;alpslli;pthread;wlm_detect;ugni;pthread;alpsutil;pthread;rca;udreg;quadmath;m;omp;rt;craymp;pthread;rt;dl;cray-c++-rts;stdc++;m;modules;m;rt;fi;m;quadmath;rt;craymath;m;gfortran;quadmath;rt;f;m;pthread;rt;u;rt;dl;cray-c++-rts;stdc++;m;csup;rt;atomic;cray-c++-rts;stdc++;supc++;stdc++;pthread;c;csup;m;gcc
+libs=AtpSigHandler;AtpSigHCommData;pthread;sci_cray_mpi_mp;m;f;sci_cray_mp;craymp;m;pthread;f;hugetlbfs;mpichcxx_cray;rt;pthread;ugni;pmi;mpich_cray;rt;pthread;ugni;pmi;pgas-dmapp;fi;u;rt;dmapp;ugni;udreg;pthread;m;cray-c\+\+-rts;stdc\+\+;xpmem;dmapp;pthread;pmi;pthread;alpslli;pthread;wlm_detect;ugni;pthread;alpsutil;pthread;rca;udreg;quadmath;m;omp;rt;craymp;pthread;rt;dl;cray-c\+\+-rts;stdc\+\+;m;modules;m;rt;fi;m;quadmath;rt;craymath;m;gfortran;quadmath;rt;f;m;pthread;rt;u;rt;dl;cray-c\+\+-rts;stdc\+\+;m;csup;rt;atomic;cray-c\+\+-rts;stdc\+\+;supc\+\+;stdc\+\+;pthread;c;csup;m;gcc
dirs=/opt/gcc/6.1.0/snos/lib64;/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/lib;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64;/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/lib64;/opt/cray/pe/pmi/5.0.14/lib64;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/pe/cce/8.7.4/cce/x86_64/lib;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64;/usr/lib64;/lib64;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0;/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-unknown-linux-gnu/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-9.0-hlist-ad.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-9.0-hlist-ad.output
index 958a6b1..a7287d3 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-9.0-hlist-ad.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-9.0-hlist-ad.output
@@ -1,2 +1,2 @@
-libs=AtpSigHandler;AtpSigHCommData;rca;mpich_cray_90;mpichcxx_cray_90;sci_cray_mpi;sci_cray;pgas-dmapp;quadmath;modules;fi;craymath;f;u;csup;atomic;cray-c++-rts;cray-c++-rts;stdc++;supc++;tcmalloc_minimal;cray-c++-rts;stdc++;pthread;c;csup;m;clang_rt.craypgo-x86_64;gcc
+libs=AtpSigHandler;AtpSigHCommData;rca;mpich_cray_90;mpichcxx_cray_90;sci_cray_mpi;sci_cray;pgas-dmapp;quadmath;modules;fi;craymath;f;u;csup;atomic;cray-c\+\+-rts;cray-c\+\+-rts;stdc\+\+;supc\+\+;tcmalloc_minimal;cray-c\+\+-rts;stdc\+\+;pthread;c;csup;m;clang_rt.craypgo-x86_64;gcc
dirs=/opt/gcc/8.1.0/snos/lib64;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/lib;/opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/lib;/opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/pe/cce/9.0.0/cce/x86_64/lib;/usr/lib64;/lib64;/opt/cray/pe/cce/9.0.0/cce-clang/x86_64/lib/clang/9.0.0/lib/linux;/opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0;/opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-unknown-linux-gnu/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-GNU-7.3.0.output
index 40d0047..ead4804 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-GNU-7.3.0.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-GNU-7.3.0.output
@@ -1,2 +1,2 @@
-libs=AtpSigHandler;AtpSigHCommData;pthread;sci_gnu_71_mpi;sci_gnu_71;pthread;hugetlbfs;mpichcxx_gnu_71;rt;ugni;pthread;pmi;mpich_gnu_71;rt;ugni;pthread;pmi;pthread;alpslli;pthread;wlm_detect;alpsutil;pthread;rca;ugni;pthread;xpmem;udreg;gfortran;quadmath;mvec;m;pthread;stdc++;m;gcc;c
+libs=AtpSigHandler;AtpSigHCommData;pthread;sci_gnu_71_mpi;sci_gnu_71;pthread;hugetlbfs;mpichcxx_gnu_71;rt;ugni;pthread;pmi;mpich_gnu_71;rt;ugni;pthread;pmi;pthread;alpslli;pthread;wlm_detect;alpsutil;pthread;rca;ugni;pthread;xpmem;udreg;gfortran;quadmath;mvec;m;pthread;stdc\+\+;m;gcc;c
dirs=/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64;/opt/cray/pe/pmi/5.0.14/lib64;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0;/opt/gcc/7.3.0/snos/lib64;/lib64;/usr/lib64;/opt/gcc/7.3.0/snos/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Intel-18.0.2.20180210.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Intel-18.0.2.20180210.output
index 6212844..1a3b736 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Intel-18.0.2.20180210.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Intel-18.0.2.20180210.output
@@ -1,2 +1,2 @@
-libs=imf;svml;irng;stdc++;m;ipgo;decimal;cilkrts;stdc++;gcc;gcc_s;irc;svml;c;gcc;gcc_s;irc_s;dl;c
+libs=imf;svml;irng;stdc\+\+;m;ipgo;decimal;cilkrts;stdc\+\+;gcc;gcc_s;irc;svml;c;gcc;gcc_s;irc_s;dl;c
dirs=/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0;/opt/gcc/6.3.0/snos/lib64;/lib64;/usr/lib64;/opt/gcc/6.3.0/snos/lib;/lib;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-8.7.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-8.7.output
index 9828bf3..3b26f40 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-8.7.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-8.7.output
@@ -1,2 +1,2 @@
-libs=AtpSigHandler;AtpSigHCommData;rca;sci_cray_mpi_mp;sci_cray_mp;mpich_cray;mpichf90_cray;pgas-dmapp;quadmath;omp;craymp;modules;fi;craymath;f;u;csup;atomic;gfortran;tcmalloc_minimal;stdc++;pthread;c;csup;m;gcc
+libs=AtpSigHandler;AtpSigHCommData;rca;sci_cray_mpi_mp;sci_cray_mp;mpich_cray;mpichf90_cray;pgas-dmapp;quadmath;omp;craymp;modules;fi;craymath;f;u;csup;atomic;gfortran;tcmalloc_minimal;stdc\+\+;pthread;c;csup;m;gcc
dirs=/opt/gcc/6.1.0/snos/lib64;/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/lib;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/pe/cce/8.7.4/cce/x86_64/lib;/usr/lib64;/lib64;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0;/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-unknown-linux-gnu/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-9.0-hlist-ad.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-9.0-hlist-ad.output
index 4675408..d15e5a7 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-9.0-hlist-ad.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-9.0-hlist-ad.output
@@ -1,2 +1,2 @@
-libs=AtpSigHandler;AtpSigHCommData;rca;mpich_cray_90;mpichf90_cray_90;sci_cray_mpi;sci_cray;pgas-dmapp;quadmath;modules;fi;craymath;f;u;csup;gfortran;tcmalloc_minimal;cray-c++-rts;stdc++;pthread;c;csup;m;clang_rt.craypgo-x86_64;gcc
+libs=AtpSigHandler;AtpSigHCommData;rca;mpich_cray_90;mpichf90_cray_90;sci_cray_mpi;sci_cray;pgas-dmapp;quadmath;modules;fi;craymath;f;u;csup;gfortran;tcmalloc_minimal;cray-c\+\+-rts;stdc\+\+;pthread;c;csup;m;clang_rt.craypgo-x86_64;gcc
dirs=/opt/gcc/8.1.0/snos/lib64;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/lib;/opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/lib;/opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/pe/cce/9.0.0/cce/x86_64/lib;/usr/lib64;/lib64;/opt/cray/pe/cce/9.0.0/cce-clang/x86_64/lib/clang/9.0.0/lib/linux;/opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0;/opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-unknown-linux-gnu/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin-CXX-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin-CXX-AppleClang-8.0.0.8000042.output
index f75637c..47a362a 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin-CXX-AppleClang-8.0.0.8000042.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin-CXX-AppleClang-8.0.0.8000042.output
@@ -1,2 +1,2 @@
-libs=c++
+libs=c\+\+
dirs=/usr/lib;/usr/local/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output
index f75637c..47a362a 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output
@@ -1,2 +1,2 @@
-libs=c++
+libs=c\+\+
dirs=/usr/lib;/usr/local/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-CXX-Clang-3.3.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-CXX-Clang-3.3.0.output
index b0b8e25..18d7cd1 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-CXX-Clang-3.3.0.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-CXX-Clang-3.3.0.output
@@ -1,2 +1,2 @@
-libs=c++;m;gcc;gcc_s;c;gcc;gcc_s
+libs=c\+\+;m;gcc;gcc_s;c;gcc;gcc_s
dirs=/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-GNU-10.2.1-static-libgcc.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-GNU-10.2.1-static-libgcc.output
new file mode 100644
index 0000000..8bcd8b2
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-GNU-10.2.1-static-libgcc.output
@@ -0,0 +1,3 @@
+libs=gcc;c;gcc
+dirs=/usr/lib/gcc/x86_64-linux-gnu/10;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib
+library_arch=x86_64-linux-gnu
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-Intel-18.0.0.20170811.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-Intel-18.0.0.20170811.output
index e613290..d78c9f4 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-Intel-18.0.0.20170811.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-Intel-18.0.0.20170811.output
@@ -1,3 +1,3 @@
-libs=imf;svml;irng;m;ipgo;decimal;cilkrts;stdc++;gcc;gcc_s;irc;svml;c;gcc;gcc_s;irc_s;dl;c
+libs=imf;svml;irng;m;ipgo;decimal;cilkrts;stdc\+\+;gcc;gcc_s;irc;svml;c;gcc;gcc_s;irc_s;dl;c
dirs=/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin;/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin;/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7;/usr/lib/gcc/x86_64-redhat-linux/4.8.5;/usr/lib64;/lib64;/usr/lib;/lib
library_arch=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-CLANG.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-CLANG.output
index 813457a..be6b906 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-CLANG.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-CLANG.output
@@ -1,3 +1,3 @@
-libs=cudadevrt;cudart_static;rt;pthread;dl;stdc++;m;gcc_s;gcc;c;gcc_s;gcc
+libs=cudadevrt;cudart_static;rt;pthread;dl;stdc\+\+;m;gcc_s;gcc;c;gcc_s;gcc
dirs=/usr/local/cuda/targets/x86_64-linux/lib/stubs;/usr/local/cuda/targets/x86_64-linux/lib;/usr/lib/gcc/x86_64-linux-gnu/8;/usr/lib/x86_64-linux-gnu;/lib/x86_64-linux-gnu;/lib64;/usr/lib;/usr/lib/llvm-8/lib;/lib
library_arch=x86_64-linux-gnu
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-XLClang-v.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-XLClang-v.output
index 261785c..d3f3627 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-XLClang-v.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-XLClang-v.output
@@ -1,3 +1,3 @@
-libs=cudadevrt;cudart_static;rt;pthread;dl;xlopt;xl;ibmc++;stdc++;m;dl;gcc_s;gcc;pthread;m;c;gcc_s;gcc
+libs=cudadevrt;cudart_static;rt;pthread;dl;xlopt;xl;ibmc\+\+;stdc\+\+;m;dl;gcc_s;gcc;pthread;m;c;gcc_s;gcc
dirs=/sw/summit/cuda/10.1.168/targets/ppc64le-linux/lib/stubs;/sw/summit/cuda/10.1.168/targets/ppc64le-linux/lib;/autofs/nccs-svm1_sw/summit/.swci/1-compute/opt/spack/20180914/linux-rhel7-ppc64le/xl-16.1.1-3/spectrum-mpi-10.3.0.1-20190611-aqjt3jo53mogrrhcrd2iufr435azcaha/lib;/autofs/nccs-svm1_sw/summit/.swci/1-compute/opt/spack/20180914/linux-rhel7-ppc64le/gcc-4.8.5/darshan-runtime-3.1.7-csygoqyym3m3ysoaperhxlhoiluvpa2u/lib;/autofs/nccs-svm1_sw/summit/xl/16.1.1-3/xlsmp/5.1.1/lib;/autofs/nccs-svm1_sw/summit/xl/16.1.1-3/xlmass/9.1.1/lib;/autofs/nccs-svm1_sw/summit/xl/16.1.1-3/xlC/16.1.1/lib;/usr/lib/gcc/ppc64le-redhat-linux/4.8.5;/usr/lib64;/lib64;/autofs/nccs-svm1_sw/peak/.swci/1-compute/opt/spack/20180914/linux-rhel7-ppc64le/gcc-4.8.5/darshan-runtime-3.1.7-ytwv7xbkub6mqnpvygdthwqa7mhjqbc5/lib;/usr/lib
library_arch=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-9.2.148-GCC.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-9.2.148-GCC.output
index 275fe40..958f41d 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-9.2.148-GCC.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-9.2.148-GCC.output
@@ -1,3 +1,3 @@
-libs=cudadevrt;cudart_static;rt;pthread;dl;stdc++;m;gcc_s;gcc;c;gcc_s;gcc
+libs=cudadevrt;cudart_static;rt;pthread;dl;stdc\+\+;m;gcc_s;gcc;c;gcc_s;gcc
dirs=/usr/lib/x86_64-linux-gnu/stubs;/usr/lib/gcc/x86_64-linux-gnu/5;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib
library_arch=x86_64-linux-gnu
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-GNU-10.2.1-static-libstdc++.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-GNU-10.2.1-static-libstdc++.output
new file mode 100644
index 0000000..d38dfee
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-GNU-10.2.1-static-libstdc++.output
@@ -0,0 +1,3 @@
+libs=/usr/lib/gcc/x86_64-linux-gnu/10/libstdc\+\+.a;m;gcc_s;gcc;c;gcc_s;gcc
+dirs=/usr/lib/gcc/x86_64-linux-gnu/10;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib
+library_arch=x86_64-linux-gnu
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-GNU-7.3.0.output
index 4957f5c..f87ecff 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-GNU-7.3.0.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-GNU-7.3.0.output
@@ -1,3 +1,3 @@
-libs=stdc++;m;gcc_s;gcc;c;gcc_s;gcc
+libs=stdc\+\+;m;gcc_s;gcc;c;gcc_s;gcc
dirs=/usr/lib/gcc/x86_64-linux-gnu/7;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib
library_arch=x86_64-linux-gnu
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-Intel-18.0.0.20170811.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-Intel-18.0.0.20170811.output
index 678a196..832f218 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-Intel-18.0.0.20170811.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-Intel-18.0.0.20170811.output
@@ -1,3 +1,3 @@
-libs=imf;svml;irng;stdc++;m;ipgo;decimal;cilkrts;stdc++;gcc;gcc_s;irc;svml;c;gcc;gcc_s;irc_s;dl;c
+libs=imf;svml;irng;stdc\+\+;m;ipgo;decimal;cilkrts;stdc\+\+;gcc;gcc_s;irc;svml;c;gcc;gcc_s;irc_s;dl;c
dirs=/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin;/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin;/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7;/usr/lib/gcc/x86_64-redhat-linux/4.8.5;/usr/lib64;/lib64;/usr/lib;/lib
library_arch=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-NVHPC-21.1.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-NVHPC-21.1.0.output
index e7f7d05..5e93f6d 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-NVHPC-21.1.0.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-NVHPC-21.1.0.output
@@ -1,3 +1,3 @@
-libs=atomic;nvhpcatm;stdc++;nvomp;dl;nvhpcatm;atomic;pthread;nvcpumath;nsnvc;nvc;m;gcc;c;gcc;gcc_s
+libs=atomic;nvhpcatm;stdc\+\+;nvomp;dl;nvhpcatm;atomic;pthread;nvcpumath;nsnvc;nvc;m;gcc;c;gcc;gcc_s
dirs=/opt/nvidia/hpc_sdk/Linux_x86_64/21.1/compilers/lib;/usr/lib64;/usr/lib/gcc/x86_64-linux-gnu/9
library_arch=x86_64-linux-gnu
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-PGI-18.10.1.output
index cd15054..0e95961 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-PGI-18.10.1.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-PGI-18.10.1.output
@@ -1,3 +1,3 @@
-libs=atomic;pgatm;stdc++;pgmp;numa;pthread;pgmath;nspgc;pgc;m;gcc;c;gcc;gcc_s
+libs=atomic;pgatm;stdc\+\+;pgmp;numa;pthread;pgmath;nspgc;pgc;m;gcc;c;gcc;gcc_s
dirs=/mnt/pgi/linux86-64/18.10/lib;/usr/lib64;/usr/lib/gcc/x86_64-linux-gnu/7
library_arch=x86_64-linux-gnu
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-12.1.0.output
index 45c5565..34cab2e 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-12.1.0.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-12.1.0.output
@@ -1,3 +1,3 @@
-libs=xlopt;xl;ibmc++;xlopt;xl;stdc++;m;dl;gcc_s;gcc;m;c;gcc_s;gcc;dl;gcc_s;gcc;m;c;gcc_s;gcc
+libs=xlopt;xl;ibmc\+\+;xlopt;xl;stdc\+\+;m;dl;gcc_s;gcc;m;c;gcc_s;gcc;dl;gcc_s;gcc;m;c;gcc_s;gcc
dirs=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64;/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64;/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64;/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64;/usr/lib/gcc/ppc64-redhat-linux/4.4.7;/usr/lib64;/lib64;/usr/lib
library_arch=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-16.1.0.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-16.1.0.0.output
index 9d649ec..c754bda 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-16.1.0.0.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-16.1.0.0.output
@@ -1,3 +1,3 @@
-libs=xlopt;xl;ibmc++;stdc++;m;dl;gcc_s;gcc;pthread;m;c;gcc_s;gcc
+libs=xlopt;xl;ibmc\+\+;stdc\+\+;m;dl;gcc_s;gcc;pthread;m;c;gcc_s;gcc
dirs=/opt/ibm/xlsmp/5.1.0/lib;/opt/ibm/xlmass/9.1.0/lib;/opt/ibm/xlC/16.1.0/lib;/usr/lib/gcc/ppc64le-redhat-linux/4.8.5;/usr/lib64;/lib64;/usr/lib
library_arch=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-GNU-10.2.1-static-libgfortran.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-GNU-10.2.1-static-libgfortran.output
new file mode 100644
index 0000000..edeb20c
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-GNU-10.2.1-static-libgfortran.output
@@ -0,0 +1,3 @@
+libs=/usr/lib/gcc/x86_64-linux-gnu/10/libgfortran.a;m;gcc_s;gcc;quadmath;m;gcc_s;gcc;c;gcc_s;gcc
+dirs=/usr/lib/gcc/x86_64-linux-gnu/10;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib
+library_arch=x86_64-linux-gnu
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-PGI-18.10.1.output
index a7c14d2..848e8c0 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-PGI-18.10.1.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-PGI-18.10.1.output
@@ -1,3 +1,3 @@
-libs=atomic;pgatm;stdc++;pgmp;numa;pthread;pgmath;nspgc;pgc;m;gcc;c;gcc;gcc_s
+libs=atomic;pgatm;stdc\+\+;pgmp;numa;pthread;pgmath;nspgc;pgc;m;gcc;c;gcc;gcc_s
dirs=/mnt/pgi/linux86-64/18.10/lib;/usr/lib64;/usr/lib/gcc/x86_64-linux-gnu/7
library_arch=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-XL-12.1.0.output
index 45c5565..34cab2e 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-XL-12.1.0.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-XL-12.1.0.output
@@ -1,3 +1,3 @@
-libs=xlopt;xl;ibmc++;xlopt;xl;stdc++;m;dl;gcc_s;gcc;m;c;gcc_s;gcc;dl;gcc_s;gcc;m;c;gcc_s;gcc
+libs=xlopt;xl;ibmc\+\+;xlopt;xl;stdc\+\+;m;dl;gcc_s;gcc;m;c;gcc_s;gcc;dl;gcc_s;gcc;m;c;gcc_s;gcc
dirs=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64;/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64;/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64;/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64;/usr/lib/gcc/ppc64-redhat-linux/4.4.7;/usr/lib64;/lib64;/usr/lib
library_arch=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/mingw.org-CXX-GNU-4.9.3.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/mingw.org-CXX-GNU-4.9.3.output
index 5e79cc1..7852bfd 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/mingw.org-CXX-GNU-4.9.3.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/mingw.org-CXX-GNU-4.9.3.output
@@ -1,2 +1,2 @@
-libs=stdc++;mingw32;gcc_s;gcc;moldname;mingwex;advapi32;shell32;user32;kernel32;mingw32;gcc_s;gcc;moldname;mingwex
+libs=stdc\+\+;mingw32;gcc_s;gcc;moldname;mingwex;advapi32;shell32;user32;kernel32;mingw32;gcc_s;gcc;moldname;mingwex
dirs=C:/DoesNotExist/mingw/lib/gcc/mingw32/4.9.3;C:/DoesNotExist/mingw/lib/gcc;C:/DoesNotExist/mingw/mingw32/lib;C:/DoesNotExist/mingw/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd-CXX-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd-CXX-GNU-4.8.5.output
index d747e5b..c6a098e 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd-CXX-GNU-4.8.5.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd-CXX-GNU-4.8.5.output
@@ -1,2 +1,2 @@
-libs=stdc++;m;gcc_s;gcc;c;gcc_s;gcc
+libs=stdc\+\+;m;gcc_s;gcc;c;gcc_s;gcc
dirs=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd_nostdinc-CXX-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd_nostdinc-CXX-GNU-4.8.5.output
index d747e5b..c6a098e 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd_nostdinc-CXX-GNU-4.8.5.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd_nostdinc-CXX-GNU-4.8.5.output
@@ -1,2 +1,2 @@
-libs=stdc++;m;gcc_s;gcc;c;gcc_s;gcc
+libs=stdc\+\+;m;gcc_s;gcc;c;gcc_s;gcc
dirs=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/openbsd-CXX-Clang-5.0.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/openbsd-CXX-Clang-5.0.1.output
index 4158973..711225c 100644
--- a/Tests/RunCMake/ParseImplicitLinkInfo/results/openbsd-CXX-Clang-5.0.1.output
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/openbsd-CXX-Clang-5.0.1.output
@@ -1,2 +1,2 @@
-libs=c++;c++abi;pthread;m;compiler_rt;c;compiler_rt
+libs=c\+\+;c\+\+abi;pthread;m;compiler_rt;c;compiler_rt
dirs=/usr/lib
diff --git a/Tests/RunCMake/target_compile_options/Order-build-stdout.txt b/Tests/RunCMake/target_compile_options/Order-build-stdout.txt
new file mode 100644
index 0000000..c210ff2
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/Order-build-stdout.txt
@@ -0,0 +1,3 @@
+-w +-O +-O0 [^
+]*-O1 +-O2 +-O3 [^
+]*CMakeFiles[\/]order\.dir[\/](Custom[\/])?order\.c\.o
diff --git a/Tests/RunCMake/target_compile_options/Order.cmake b/Tests/RunCMake/target_compile_options/Order.cmake
new file mode 100644
index 0000000..3d59b16
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/Order.cmake
@@ -0,0 +1,19 @@
+get_property (isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(isMultiConfig)
+ set(CMAKE_CONFIGURATION_TYPES "Custom" CACHE STRING "" FORCE)
+else()
+ set(CMAKE_BUILD_TYPE "Custom" CACHE STRING "" FORCE)
+endif()
+enable_language(C)
+
+string(APPEND CMAKE_C_FLAGS " -w -O")
+set(CMAKE_C_FLAGS_CUSTOM "-O0")
+
+add_executable(order order.c)
+set_property(TARGET order APPEND PROPERTY COMPILE_OPTIONS -O1)
+
+add_library(iface INTERFACE)
+set_property(TARGET iface APPEND PROPERTY INTERFACE_COMPILE_OPTIONS -O2)
+target_link_libraries(order PRIVATE iface)
+
+set_property(SOURCE order.c PROPERTY COMPILE_OPTIONS -O3)
diff --git a/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake
index 9f51a9a..806ae79 100644
--- a/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake
@@ -19,3 +19,16 @@ if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
run_cmake_target(CMP0101-BEFORE_keyword OLD CMP0101_OLD)
run_cmake_target(CMP0101-BEFORE_keyword NEW CMP0101_NEW)
endif()
+
+function(run_Order)
+ run_cmake_with_options(Order)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Order-build)
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
+ run_cmake_command(Order-build ${CMAKE_COMMAND} --build . --verbose --config Custom)
+endfunction()
+if(RunCMake_GENERATOR MATCHES "Ninja|Make" AND
+ CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$" AND
+ NOT CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
+ run_Order()
+endif()
diff --git a/Tests/RunCMake/target_compile_options/order.c b/Tests/RunCMake/target_compile_options/order.c
new file mode 100644
index 0000000..1bd81ea
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/order.c
@@ -0,0 +1,7 @@
+#ifndef __OPTIMIZE__
+# error "Optimizations not enabled!"
+#endif
+int main(void)
+{
+ return 0;
+}
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp b/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp
index 8362fc4..8291cc6 100644
--- a/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp
+++ b/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp
@@ -2,88 +2,74 @@
// Copyright (C) 2016 InfoTeCS JSC. All rights reserved.
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at
-// http://jsoncpp.sourceforge.net/LICENSE
+// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#if !defined(JSON_IS_AMALGAMATION)
-# include <json/assertions.h>
-# include <json/reader.h>
-# include <json/value.h>
-
-# include "json_tool.h"
+#include <json/assertions.h>
+#include <json/reader.h>
+#include <json/value.h>
+#include "json_tool.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <istream>
-#include <limits>
-#include <memory>
-#include <set>
-#include <sstream>
#include <utility>
-
-#include <assert.h>
#include <stdio.h>
+#include <assert.h>
#include <string.h>
+#include <istream>
+#include <sstream>
+#include <memory>
+#include <set>
+#include <limits>
#if defined(_MSC_VER)
-# if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && \
- _MSC_VER >= 1500 // VC++ 9.0 and above
-# define snprintf sprintf_s
-# elif _MSC_VER >= 1900 // VC++ 14.0 and above
-# define snprintf std::snprintf
-# else
-# define snprintf _snprintf
-# endif
+#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
+#define snprintf sprintf_s
+#elif _MSC_VER >= 1900 // VC++ 14.0 and above
+#define snprintf std::snprintf
+#else
+#define snprintf _snprintf
+#endif
#elif defined(__ANDROID__) || defined(__QNXNTO__)
-# define snprintf snprintf
+#define snprintf snprintf
#elif __cplusplus >= 201103L
-# if !defined(__MINGW32__) && !defined(__CYGWIN__)
-# define snprintf std::snprintf
-# endif
+#if !defined(__MINGW32__) && !defined(__CYGWIN__)
+#define snprintf std::snprintf
+#endif
#endif
#if defined(__QNXNTO__)
-# define sscanf std::sscanf
+#define sscanf std::sscanf
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
// Disable warning about strdup being deprecated.
-# pragma warning(disable : 4996)
+#pragma warning(disable : 4996)
#endif
-// Define JSONCPP_DEPRECATED_STACK_LIMIT as an appropriate integer at compile
-// time to change the stack limit
+// Define JSONCPP_DEPRECATED_STACK_LIMIT as an appropriate integer at compile time to change the stack limit
#if !defined(JSONCPP_DEPRECATED_STACK_LIMIT)
-# define JSONCPP_DEPRECATED_STACK_LIMIT 1000
+#define JSONCPP_DEPRECATED_STACK_LIMIT 1000
#endif
-static size_t const stackLimit_g =
- JSONCPP_DEPRECATED_STACK_LIMIT; // see readValue()
+static size_t const stackLimit_g = JSONCPP_DEPRECATED_STACK_LIMIT; // see readValue()
namespace Json {
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
typedef std::unique_ptr<CharReader> CharReaderPtr;
#else
-typedef std::auto_ptr<CharReader> CharReaderPtr;
+typedef std::auto_ptr<CharReader> CharReaderPtr;
#endif
// Implementation of class Features
// ////////////////////////////////
Features::Features()
- : allowComments_(true)
- , strictRoot_(false)
- , allowDroppedNullPlaceholders_(false)
- , allowNumericKeys_(false)
-{
-}
+ : allowComments_(true), strictRoot_(false),
+ allowDroppedNullPlaceholders_(false), allowNumericKeys_(false) {}
-Features Features::all()
-{
- return Features();
-}
+Features Features::all() { return Features(); }
-Features Features::strictMode()
-{
+Features Features::strictMode() {
Features features;
features.allowComments_ = false;
features.strictRoot_ = true;
@@ -95,8 +81,7 @@ Features Features::strictMode()
// Implementation of class Reader
// ////////////////////////////////
-bool Reader::containsNewLine(Reader::Location begin, Reader::Location end)
-{
+bool Reader::containsNewLine(Reader::Location begin, Reader::Location end) {
for (; begin < end; ++begin)
if (*begin == '\n' || *begin == '\r')
return true;
@@ -107,44 +92,24 @@ bool Reader::containsNewLine(Reader::Location begin, Reader::Location end)
// //////////////////////////////////////////////////////////////////
Reader::Reader()
- : errors_()
- , document_()
- , begin_()
- , end_()
- , current_()
- , lastValueEnd_()
- , lastValue_()
- , commentsBefore_()
- , features_(Features::all())
- , collectComments_()
-{
-}
+ : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
+ lastValue_(), commentsBefore_(), features_(Features::all()),
+ collectComments_() {}
Reader::Reader(const Features& features)
- : errors_()
- , document_()
- , begin_()
- , end_()
- , current_()
- , lastValueEnd_()
- , lastValue_()
- , commentsBefore_()
- , features_(features)
- , collectComments_()
-{
+ : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
+ lastValue_(), commentsBefore_(), features_(features), collectComments_() {
}
-bool Reader::parse(const std::string& document, Value& root,
- bool collectComments)
-{
- this->document_.assign(document.begin(), document.end());
- const char* begin = this->document_.c_str();
- const char* end = begin + this->document_.length();
- return this->parse(begin, end, root, collectComments);
+bool
+Reader::parse(const std::string& document, Value& root, bool collectComments) {
+ document_.assign(document.begin(), document.end());
+ const char* begin = document_.c_str();
+ const char* end = begin + document_.length();
+ return parse(begin, end, root, collectComments);
}
-bool Reader::parse(std::istream& sin, Value& root, bool collectComments)
-{
+bool Reader::parse(std::istream& sin, Value& root, bool collectComments) {
// std::istream_iterator<char> begin(sin);
// std::istream_iterator<char> end;
// Those would allow streamed input from a file, if parse() were a
@@ -154,263 +119,257 @@ bool Reader::parse(std::istream& sin, Value& root, bool collectComments)
// create an extra copy.
JSONCPP_STRING doc;
std::getline(sin, doc, (char)EOF);
- return this->parse(doc.data(), doc.data() + doc.size(), root,
- collectComments);
+ return parse(doc.data(), doc.data() + doc.size(), root, collectComments);
}
-bool Reader::parse(const char* beginDoc, const char* endDoc, Value& root,
- bool collectComments)
-{
- if (!this->features_.allowComments_) {
+bool Reader::parse(const char* beginDoc,
+ const char* endDoc,
+ Value& root,
+ bool collectComments) {
+ if (!features_.allowComments_) {
collectComments = false;
}
- this->begin_ = beginDoc;
- this->end_ = endDoc;
- this->collectComments_ = collectComments;
- this->current_ = this->begin_;
- this->lastValueEnd_ = 0;
- this->lastValue_ = 0;
- this->commentsBefore_.clear();
- this->errors_.clear();
- while (!this->nodes_.empty())
- this->nodes_.pop();
- this->nodes_.push(&root);
-
- bool successful = this->readValue();
+ begin_ = beginDoc;
+ end_ = endDoc;
+ collectComments_ = collectComments;
+ current_ = begin_;
+ lastValueEnd_ = 0;
+ lastValue_ = 0;
+ commentsBefore_.clear();
+ errors_.clear();
+ while (!nodes_.empty())
+ nodes_.pop();
+ nodes_.push(&root);
+
+ bool successful = readValue();
Token token;
- this->skipCommentTokens(token);
- if (this->collectComments_ && !this->commentsBefore_.empty())
- root.setComment(this->commentsBefore_, commentAfter);
- if (this->features_.strictRoot_) {
+ skipCommentTokens(token);
+ if (collectComments_ && !commentsBefore_.empty())
+ root.setComment(commentsBefore_, commentAfter);
+ if (features_.strictRoot_) {
if (!root.isArray() && !root.isObject()) {
- // Set error location to start of doc, ideally should be first token
- // found in doc
+ // Set error location to start of doc, ideally should be first token found
+ // in doc
token.type_ = tokenError;
token.start_ = beginDoc;
token.end_ = endDoc;
- this->addError(
- "A valid JSON document must be either an array or an object value.",
- token);
+ addError(
+ "A valid JSON document must be either an array or an object value.",
+ token);
return false;
}
}
return successful;
}
-bool Reader::readValue()
-{
+bool Reader::readValue() {
// readValue() may call itself only if it calls readObject() or ReadArray().
- // These methods execute nodes_.push() just before and nodes_.pop)() just
- // after calling readValue(). parse() executes one nodes_.push(), so >
- // instead of >=.
- if (this->nodes_.size() > stackLimit_g)
- throwRuntimeError("Exceeded stackLimit in readValue().");
+ // These methods execute nodes_.push() just before and nodes_.pop)() just after calling readValue().
+ // parse() executes one nodes_.push(), so > instead of >=.
+ if (nodes_.size() > stackLimit_g) throwRuntimeError("Exceeded stackLimit in readValue().");
Token token;
- this->skipCommentTokens(token);
+ skipCommentTokens(token);
bool successful = true;
- if (this->collectComments_ && !this->commentsBefore_.empty()) {
- this->currentValue().setComment(this->commentsBefore_, commentBefore);
- this->commentsBefore_.clear();
+ if (collectComments_ && !commentsBefore_.empty()) {
+ currentValue().setComment(commentsBefore_, commentBefore);
+ commentsBefore_.clear();
}
switch (token.type_) {
- case tokenObjectBegin:
- successful = this->readObject(token);
- this->currentValue().setOffsetLimit(this->current_ - this->begin_);
- break;
- case tokenArrayBegin:
- successful = this->readArray(token);
- this->currentValue().setOffsetLimit(this->current_ - this->begin_);
- break;
- case tokenNumber:
- successful = this->decodeNumber(token);
- break;
- case tokenString:
- successful = this->decodeString(token);
- break;
- case tokenTrue: {
- Value v(true);
- this->currentValue().swapPayload(v);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
- } break;
- case tokenFalse: {
- Value v(false);
- this->currentValue().swapPayload(v);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
- } break;
- case tokenNull: {
+ case tokenObjectBegin:
+ successful = readObject(token);
+ currentValue().setOffsetLimit(current_ - begin_);
+ break;
+ case tokenArrayBegin:
+ successful = readArray(token);
+ currentValue().setOffsetLimit(current_ - begin_);
+ break;
+ case tokenNumber:
+ successful = decodeNumber(token);
+ break;
+ case tokenString:
+ successful = decodeString(token);
+ break;
+ case tokenTrue:
+ {
+ Value v(true);
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenFalse:
+ {
+ Value v(false);
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenNull:
+ {
+ Value v;
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenArraySeparator:
+ case tokenObjectEnd:
+ case tokenArrayEnd:
+ if (features_.allowDroppedNullPlaceholders_) {
+ // "Un-read" the current token and mark the current value as a null
+ // token.
+ current_--;
Value v;
- this->currentValue().swapPayload(v);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
- } break;
- case tokenArraySeparator:
- case tokenObjectEnd:
- case tokenArrayEnd:
- if (this->features_.allowDroppedNullPlaceholders_) {
- // "Un-read" the current token and mark the current value as a null
- // token.
- this->current_--;
- Value v;
- this->currentValue().swapPayload(v);
- this->currentValue().setOffsetStart(this->current_ - this->begin_ - 1);
- this->currentValue().setOffsetLimit(this->current_ - this->begin_);
- break;
- } // Else, fall through...
- default:
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
- return this->addError("Syntax error: value, object or array expected.",
- token);
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(current_ - begin_ - 1);
+ currentValue().setOffsetLimit(current_ - begin_);
+ break;
+ } // Else, fall through...
+ default:
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ return addError("Syntax error: value, object or array expected.", token);
}
- if (this->collectComments_) {
- this->lastValueEnd_ = this->current_;
- this->lastValue_ = &this->currentValue();
+ if (collectComments_) {
+ lastValueEnd_ = current_;
+ lastValue_ = &currentValue();
}
return successful;
}
-void Reader::skipCommentTokens(Token& token)
-{
- if (this->features_.allowComments_) {
+void Reader::skipCommentTokens(Token& token) {
+ if (features_.allowComments_) {
do {
- this->readToken(token);
+ readToken(token);
} while (token.type_ == tokenComment);
} else {
- this->readToken(token);
+ readToken(token);
}
}
-bool Reader::readToken(Token& token)
-{
- this->skipSpaces();
- token.start_ = this->current_;
- Char c = this->getNextChar();
+bool Reader::readToken(Token& token) {
+ skipSpaces();
+ token.start_ = current_;
+ Char c = getNextChar();
bool ok = true;
switch (c) {
- case '{':
- token.type_ = tokenObjectBegin;
- break;
- case '}':
- token.type_ = tokenObjectEnd;
- break;
- case '[':
- token.type_ = tokenArrayBegin;
- break;
- case ']':
- token.type_ = tokenArrayEnd;
- break;
- case '"':
- token.type_ = tokenString;
- ok = this->readString();
- break;
- case '/':
- token.type_ = tokenComment;
- ok = this->readComment();
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case '-':
- token.type_ = tokenNumber;
- this->readNumber();
- break;
- case 't':
- token.type_ = tokenTrue;
- ok = this->match("rue", 3);
- break;
- case 'f':
- token.type_ = tokenFalse;
- ok = this->match("alse", 4);
- break;
- case 'n':
- token.type_ = tokenNull;
- ok = this->match("ull", 3);
- break;
- case ',':
- token.type_ = tokenArraySeparator;
- break;
- case ':':
- token.type_ = tokenMemberSeparator;
- break;
- case 0:
- token.type_ = tokenEndOfStream;
- break;
- default:
- ok = false;
- break;
+ case '{':
+ token.type_ = tokenObjectBegin;
+ break;
+ case '}':
+ token.type_ = tokenObjectEnd;
+ break;
+ case '[':
+ token.type_ = tokenArrayBegin;
+ break;
+ case ']':
+ token.type_ = tokenArrayEnd;
+ break;
+ case '"':
+ token.type_ = tokenString;
+ ok = readString();
+ break;
+ case '/':
+ token.type_ = tokenComment;
+ ok = readComment();
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case '-':
+ token.type_ = tokenNumber;
+ readNumber();
+ break;
+ case 't':
+ token.type_ = tokenTrue;
+ ok = match("rue", 3);
+ break;
+ case 'f':
+ token.type_ = tokenFalse;
+ ok = match("alse", 4);
+ break;
+ case 'n':
+ token.type_ = tokenNull;
+ ok = match("ull", 3);
+ break;
+ case ',':
+ token.type_ = tokenArraySeparator;
+ break;
+ case ':':
+ token.type_ = tokenMemberSeparator;
+ break;
+ case 0:
+ token.type_ = tokenEndOfStream;
+ break;
+ default:
+ ok = false;
+ break;
}
if (!ok)
token.type_ = tokenError;
- token.end_ = this->current_;
+ token.end_ = current_;
return true;
}
-void Reader::skipSpaces()
-{
- while (this->current_ != this->end_) {
- Char c = *this->current_;
+void Reader::skipSpaces() {
+ while (current_ != end_) {
+ Char c = *current_;
if (c == ' ' || c == '\t' || c == '\r' || c == '\n')
- ++this->current_;
+ ++current_;
else
break;
}
}
-bool Reader::match(Location pattern, int patternLength)
-{
- if (this->end_ - this->current_ < patternLength)
+bool Reader::match(Location pattern, int patternLength) {
+ if (end_ - current_ < patternLength)
return false;
int index = patternLength;
while (index--)
- if (this->current_[index] != pattern[index])
+ if (current_[index] != pattern[index])
return false;
- this->current_ += patternLength;
+ current_ += patternLength;
return true;
}
-bool Reader::readComment()
-{
- Location commentBegin = this->current_ - 1;
- Char c = this->getNextChar();
+bool Reader::readComment() {
+ Location commentBegin = current_ - 1;
+ Char c = getNextChar();
bool successful = false;
if (c == '*')
- successful = this->readCStyleComment();
+ successful = readCStyleComment();
else if (c == '/')
- successful = this->readCppStyleComment();
+ successful = readCppStyleComment();
if (!successful)
return false;
- if (this->collectComments_) {
+ if (collectComments_) {
CommentPlacement placement = commentBefore;
- if (this->lastValueEnd_ &&
- !containsNewLine(this->lastValueEnd_, commentBegin)) {
- if (c != '*' || !containsNewLine(commentBegin, this->current_))
+ if (lastValueEnd_ && !containsNewLine(lastValueEnd_, commentBegin)) {
+ if (c != '*' || !containsNewLine(commentBegin, current_))
placement = commentAfterOnSameLine;
}
- this->addComment(commentBegin, this->current_, placement);
+ addComment(commentBegin, current_, placement);
}
return true;
}
-JSONCPP_STRING Reader::normalizeEOL(Reader::Location begin,
- Reader::Location end)
-{
+JSONCPP_STRING Reader::normalizeEOL(Reader::Location begin, Reader::Location end) {
JSONCPP_STRING normalized;
normalized.reserve(static_cast<size_t>(end - begin));
Reader::Location current = begin;
@@ -418,8 +377,8 @@ JSONCPP_STRING Reader::normalizeEOL(Reader::Location begin,
char c = *current++;
if (c == '\r') {
if (current != end && *current == '\n')
- // convert dos EOL
- ++current;
+ // convert dos EOL
+ ++current;
// convert Mac EOL
normalized += '\n';
} else {
@@ -429,39 +388,36 @@ JSONCPP_STRING Reader::normalizeEOL(Reader::Location begin,
return normalized;
}
-void Reader::addComment(Location begin, Location end,
- CommentPlacement placement)
-{
- assert(this->collectComments_);
+void
+Reader::addComment(Location begin, Location end, CommentPlacement placement) {
+ assert(collectComments_);
const JSONCPP_STRING& normalized = normalizeEOL(begin, end);
if (placement == commentAfterOnSameLine) {
- assert(this->lastValue_ != 0);
- this->lastValue_->setComment(normalized, placement);
+ assert(lastValue_ != 0);
+ lastValue_->setComment(normalized, placement);
} else {
- this->commentsBefore_ += normalized;
+ commentsBefore_ += normalized;
}
}
-bool Reader::readCStyleComment()
-{
- while ((this->current_ + 1) < this->end_) {
- Char c = this->getNextChar();
- if (c == '*' && *this->current_ == '/')
+bool Reader::readCStyleComment() {
+ while ((current_ + 1) < end_) {
+ Char c = getNextChar();
+ if (c == '*' && *current_ == '/')
break;
}
- return this->getNextChar() == '/';
+ return getNextChar() == '/';
}
-bool Reader::readCppStyleComment()
-{
- while (this->current_ != this->end_) {
- Char c = this->getNextChar();
+bool Reader::readCppStyleComment() {
+ while (current_ != end_) {
+ Char c = getNextChar();
if (c == '\n')
break;
if (c == '\r') {
// Consume DOS EOL. It will be normalized in addComment.
- if (this->current_ != this->end_ && *this->current_ == '\n')
- this->getNextChar();
+ if (current_ != end_ && *current_ == '\n')
+ getNextChar();
// Break on Moc OS 9 EOL.
break;
}
@@ -469,132 +425,127 @@ bool Reader::readCppStyleComment()
return true;
}
-void Reader::readNumber()
-{
- const char* p = this->current_;
+void Reader::readNumber() {
+ const char *p = current_;
char c = '0'; // stopgap for already consumed character
// integral part
while (c >= '0' && c <= '9')
- c = (this->current_ = p) < this->end_ ? *p++ : '\0';
+ c = (current_ = p) < end_ ? *p++ : '\0';
// fractional part
if (c == '.') {
- c = (this->current_ = p) < this->end_ ? *p++ : '\0';
+ c = (current_ = p) < end_ ? *p++ : '\0';
while (c >= '0' && c <= '9')
- c = (this->current_ = p) < this->end_ ? *p++ : '\0';
+ c = (current_ = p) < end_ ? *p++ : '\0';
}
// exponential part
if (c == 'e' || c == 'E') {
- c = (this->current_ = p) < this->end_ ? *p++ : '\0';
+ c = (current_ = p) < end_ ? *p++ : '\0';
if (c == '+' || c == '-')
- c = (this->current_ = p) < this->end_ ? *p++ : '\0';
+ c = (current_ = p) < end_ ? *p++ : '\0';
while (c >= '0' && c <= '9')
- c = (this->current_ = p) < this->end_ ? *p++ : '\0';
+ c = (current_ = p) < end_ ? *p++ : '\0';
}
}
-bool Reader::readString()
-{
+bool Reader::readString() {
Char c = '\0';
- while (this->current_ != this->end_) {
- c = this->getNextChar();
+ while (current_ != end_) {
+ c = getNextChar();
if (c == '\\')
- this->getNextChar();
+ getNextChar();
else if (c == '"')
break;
}
return c == '"';
}
-bool Reader::readObject(Token& tokenStart)
-{
+bool Reader::readObject(Token& tokenStart) {
Token tokenName;
JSONCPP_STRING name;
Value init(objectValue);
- this->currentValue().swapPayload(init);
- this->currentValue().setOffsetStart(tokenStart.start_ - this->begin_);
- while (this->readToken(tokenName)) {
+ currentValue().swapPayload(init);
+ currentValue().setOffsetStart(tokenStart.start_ - begin_);
+ while (readToken(tokenName)) {
bool initialTokenOk = true;
while (tokenName.type_ == tokenComment && initialTokenOk)
- initialTokenOk = this->readToken(tokenName);
+ initialTokenOk = readToken(tokenName);
if (!initialTokenOk)
break;
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
return true;
name.clear();
if (tokenName.type_ == tokenString) {
- if (!this->decodeString(tokenName, name))
- return this->recoverFromError(tokenObjectEnd);
- } else if (tokenName.type_ == tokenNumber &&
- this->features_.allowNumericKeys_) {
+ if (!decodeString(tokenName, name))
+ return recoverFromError(tokenObjectEnd);
+ } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
Value numberName;
- if (!this->decodeNumber(tokenName, numberName))
- return this->recoverFromError(tokenObjectEnd);
+ if (!decodeNumber(tokenName, numberName))
+ return recoverFromError(tokenObjectEnd);
name = JSONCPP_STRING(numberName.asCString());
} else {
break;
}
Token colon;
- if (!this->readToken(colon) || colon.type_ != tokenMemberSeparator) {
- return this->addErrorAndRecover("Missing ':' after object member name",
- colon, tokenObjectEnd);
+ if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {
+ return addErrorAndRecover(
+ "Missing ':' after object member name", colon, tokenObjectEnd);
}
- Value& value = this->currentValue()[name];
- this->nodes_.push(&value);
- bool ok = this->readValue();
- this->nodes_.pop();
+ Value& value = currentValue()[name];
+ nodes_.push(&value);
+ bool ok = readValue();
+ nodes_.pop();
if (!ok) // error already set
- return this->recoverFromError(tokenObjectEnd);
+ return recoverFromError(tokenObjectEnd);
Token comma;
- if (!this->readToken(comma) ||
+ if (!readToken(comma) ||
(comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&
comma.type_ != tokenComment)) {
- return this->addErrorAndRecover(
- "Missing ',' or '}' in object declaration", comma, tokenObjectEnd);
+ return addErrorAndRecover(
+ "Missing ',' or '}' in object declaration", comma, tokenObjectEnd);
}
bool finalizeTokenOk = true;
while (comma.type_ == tokenComment && finalizeTokenOk)
- finalizeTokenOk = this->readToken(comma);
+ finalizeTokenOk = readToken(comma);
if (comma.type_ == tokenObjectEnd)
return true;
}
- return this->addErrorAndRecover("Missing '}' or object member name",
- tokenName, tokenObjectEnd);
+ return addErrorAndRecover(
+ "Missing '}' or object member name", tokenName, tokenObjectEnd);
}
-bool Reader::readArray(Token& tokenStart)
-{
+bool Reader::readArray(Token& tokenStart) {
Value init(arrayValue);
- this->currentValue().swapPayload(init);
- this->currentValue().setOffsetStart(tokenStart.start_ - this->begin_);
- this->skipSpaces();
- if (this->current_ != this->end_ && *this->current_ == ']') // empty array
+ currentValue().swapPayload(init);
+ currentValue().setOffsetStart(tokenStart.start_ - begin_);
+ skipSpaces();
+ if (current_ != end_ && *current_ == ']') // empty array
{
Token endArray;
- this->readToken(endArray);
+ readToken(endArray);
return true;
}
int index = 0;
for (;;) {
- Value& value = this->currentValue()[index++];
- this->nodes_.push(&value);
- bool ok = this->readValue();
- this->nodes_.pop();
+ Value& value = currentValue()[index++];
+ nodes_.push(&value);
+ bool ok = readValue();
+ nodes_.pop();
if (!ok) // error already set
- return this->recoverFromError(tokenArrayEnd);
+ return recoverFromError(tokenArrayEnd);
Token token;
// Accept Comment after last item in the array.
- ok = this->readToken(token);
+ ok = readToken(token);
while (token.type_ == tokenComment && ok) {
- ok = this->readToken(token);
+ ok = readToken(token);
}
bool badTokenType =
- (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);
+ (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);
if (!ok || badTokenType) {
- return this->addErrorAndRecover(
- "Missing ',' or ']' in array declaration", token, tokenArrayEnd);
+ return addErrorAndRecover(
+ "Missing ',' or ']' in array declaration", token, tokenArrayEnd);
}
if (token.type_ == tokenArrayEnd)
break;
@@ -602,19 +553,17 @@ bool Reader::readArray(Token& tokenStart)
return true;
}
-bool Reader::decodeNumber(Token& token)
-{
+bool Reader::decodeNumber(Token& token) {
Value decoded;
- if (!this->decodeNumber(token, decoded))
+ if (!decodeNumber(token, decoded))
return false;
- this->currentValue().swapPayload(decoded);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
+ currentValue().swapPayload(decoded);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
return true;
}
-bool Reader::decodeNumber(Token& token, Value& decoded)
-{
+bool Reader::decodeNumber(Token& token, Value& decoded) {
// Attempts to parse the number as an integer. If the number is
// larger than the maximum supported value of an integer then
// we decode the number as a double.
@@ -622,17 +571,16 @@ bool Reader::decodeNumber(Token& token, Value& decoded)
bool isNegative = *current == '-';
if (isNegative)
++current;
- // TODO: Help the compiler do the div and mod at compile time or get rid of
- // them.
- Value::LargestUInt maxIntegerValue = isNegative
- ? Value::LargestUInt(Value::maxLargestInt) + 1
- : Value::maxLargestUInt;
+ // TODO: Help the compiler do the div and mod at compile time or get rid of them.
+ Value::LargestUInt maxIntegerValue =
+ isNegative ? Value::LargestUInt(Value::maxLargestInt) + 1
+ : Value::maxLargestUInt;
Value::LargestUInt threshold = maxIntegerValue / 10;
Value::LargestUInt value = 0;
while (current < token.end_) {
Char c = *current++;
if (c < '0' || c > '9')
- return this->decodeDouble(token, decoded);
+ return decodeDouble(token, decoded);
Value::UInt digit(static_cast<Value::UInt>(c - '0'));
if (value >= threshold) {
// We've hit or exceeded the max value divided by 10 (rounded down). If
@@ -641,7 +589,7 @@ bool Reader::decodeNumber(Token& token, Value& decoded)
// Otherwise treat this number as a double to avoid overflow.
if (value > threshold || current != token.end_ ||
digit > maxIntegerValue % 10) {
- return this->decodeDouble(token, decoded);
+ return decodeDouble(token, decoded);
}
}
value = value * 10 + digit;
@@ -657,44 +605,40 @@ bool Reader::decodeNumber(Token& token, Value& decoded)
return true;
}
-bool Reader::decodeDouble(Token& token)
-{
+bool Reader::decodeDouble(Token& token) {
Value decoded;
- if (!this->decodeDouble(token, decoded))
+ if (!decodeDouble(token, decoded))
return false;
- this->currentValue().swapPayload(decoded);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
+ currentValue().swapPayload(decoded);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
return true;
}
-bool Reader::decodeDouble(Token& token, Value& decoded)
-{
+bool Reader::decodeDouble(Token& token, Value& decoded) {
double value = 0;
JSONCPP_STRING buffer(token.start_, token.end_);
JSONCPP_ISTRINGSTREAM is(buffer);
if (!(is >> value))
- return this->addError("'" + JSONCPP_STRING(token.start_, token.end_) +
- "' is not a number.",
- token);
+ return addError("'" + JSONCPP_STRING(token.start_, token.end_) +
+ "' is not a number.",
+ token);
decoded = value;
return true;
}
-bool Reader::decodeString(Token& token)
-{
+bool Reader::decodeString(Token& token) {
JSONCPP_STRING decoded_string;
- if (!this->decodeString(token, decoded_string))
+ if (!decodeString(token, decoded_string))
return false;
Value decoded(decoded_string);
- this->currentValue().swapPayload(decoded);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
+ currentValue().swapPayload(decoded);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
return true;
}
-bool Reader::decodeString(Token& token, JSONCPP_STRING& decoded)
-{
+bool Reader::decodeString(Token& token, JSONCPP_STRING& decoded) {
decoded.reserve(static_cast<size_t>(token.end_ - token.start_ - 2));
Location current = token.start_ + 1; // skip '"'
Location end = token.end_ - 1; // do not include '"'
@@ -704,43 +648,41 @@ bool Reader::decodeString(Token& token, JSONCPP_STRING& decoded)
break;
else if (c == '\\') {
if (current == end)
- return this->addError("Empty escape sequence in string", token,
- current);
+ return addError("Empty escape sequence in string", token, current);
Char escape = *current++;
switch (escape) {
- case '"':
- decoded += '"';
- break;
- case '/':
- decoded += '/';
- break;
- case '\\':
- decoded += '\\';
- break;
- case 'b':
- decoded += '\b';
- break;
- case 'f':
- decoded += '\f';
- break;
- case 'n':
- decoded += '\n';
- break;
- case 'r':
- decoded += '\r';
- break;
- case 't':
- decoded += '\t';
- break;
- case 'u': {
- unsigned int unicode;
- if (!this->decodeUnicodeCodePoint(token, current, end, unicode))
- return false;
- decoded += codePointToUTF8(unicode);
- } break;
- default:
- return this->addError("Bad escape sequence in string", token,
- current);
+ case '"':
+ decoded += '"';
+ break;
+ case '/':
+ decoded += '/';
+ break;
+ case '\\':
+ decoded += '\\';
+ break;
+ case 'b':
+ decoded += '\b';
+ break;
+ case 'f':
+ decoded += '\f';
+ break;
+ case 'n':
+ decoded += '\n';
+ break;
+ case 'r':
+ decoded += '\r';
+ break;
+ case 't':
+ decoded += '\t';
+ break;
+ case 'u': {
+ unsigned int unicode;
+ if (!decodeUnicodeCodePoint(token, current, end, unicode))
+ return false;
+ decoded += codePointToUTF8(unicode);
+ } break;
+ default:
+ return addError("Bad escape sequence in string", token, current);
}
} else {
decoded += c;
@@ -749,43 +691,44 @@ bool Reader::decodeString(Token& token, JSONCPP_STRING& decoded)
return true;
}
-bool Reader::decodeUnicodeCodePoint(Token& token, Location& current,
- Location end, unsigned int& unicode)
-{
+bool Reader::decodeUnicodeCodePoint(Token& token,
+ Location& current,
+ Location end,
+ unsigned int& unicode) {
- if (!this->decodeUnicodeEscapeSequence(token, current, end, unicode))
+ if (!decodeUnicodeEscapeSequence(token, current, end, unicode))
return false;
if (unicode >= 0xD800 && unicode <= 0xDBFF) {
// surrogate pairs
if (end - current < 6)
- return this->addError(
- "additional six characters expected to parse unicode surrogate pair.",
- token, current);
+ return addError(
+ "additional six characters expected to parse unicode surrogate pair.",
+ token,
+ current);
unsigned int surrogatePair;
if (*(current++) == '\\' && *(current++) == 'u') {
- if (this->decodeUnicodeEscapeSequence(token, current, end,
- surrogatePair)) {
- unicode =
- 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF);
+ if (decodeUnicodeEscapeSequence(token, current, end, surrogatePair)) {
+ unicode = 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF);
} else
return false;
} else
- return this->addError(
- "expecting another \\u token to begin the second half of "
- "a unicode surrogate pair",
- token, current);
+ return addError("expecting another \\u token to begin the second half of "
+ "a unicode surrogate pair",
+ token,
+ current);
}
return true;
}
-bool Reader::decodeUnicodeEscapeSequence(Token& token, Location& current,
+bool Reader::decodeUnicodeEscapeSequence(Token& token,
+ Location& current,
Location end,
- unsigned int& ret_unicode)
-{
+ unsigned int& ret_unicode) {
if (end - current < 4)
- return this->addError(
- "Bad unicode escape sequence in string: four digits expected.", token,
- current);
+ return addError(
+ "Bad unicode escape sequence in string: four digits expected.",
+ token,
+ current);
int unicode = 0;
for (int index = 0; index < 4; ++index) {
Char c = *current++;
@@ -797,65 +740,60 @@ bool Reader::decodeUnicodeEscapeSequence(Token& token, Location& current,
else if (c >= 'A' && c <= 'F')
unicode += c - 'A' + 10;
else
- return this->addError(
- "Bad unicode escape sequence in string: hexadecimal digit expected.",
- token, current);
+ return addError(
+ "Bad unicode escape sequence in string: hexadecimal digit expected.",
+ token,
+ current);
}
ret_unicode = static_cast<unsigned int>(unicode);
return true;
}
-bool Reader::addError(const JSONCPP_STRING& message, Token& token,
- Location extra)
-{
+bool
+Reader::addError(const JSONCPP_STRING& message, Token& token, Location extra) {
ErrorInfo info;
info.token_ = token;
info.message_ = message;
info.extra_ = extra;
- this->errors_.push_back(info);
+ errors_.push_back(info);
return false;
}
-bool Reader::recoverFromError(TokenType skipUntilToken)
-{
- size_t const errorCount = this->errors_.size();
+bool Reader::recoverFromError(TokenType skipUntilToken) {
+ size_t const errorCount = errors_.size();
Token skip;
for (;;) {
- if (!this->readToken(skip))
- this->errors_.resize(errorCount); // discard errors caused by recovery
+ if (!readToken(skip))
+ errors_.resize(errorCount); // discard errors caused by recovery
if (skip.type_ == skipUntilToken || skip.type_ == tokenEndOfStream)
break;
}
- this->errors_.resize(errorCount);
+ errors_.resize(errorCount);
return false;
}
-bool Reader::addErrorAndRecover(const JSONCPP_STRING& message, Token& token,
- TokenType skipUntilToken)
-{
- this->addError(message, token);
- return this->recoverFromError(skipUntilToken);
+bool Reader::addErrorAndRecover(const JSONCPP_STRING& message,
+ Token& token,
+ TokenType skipUntilToken) {
+ addError(message, token);
+ return recoverFromError(skipUntilToken);
}
-Value& Reader::currentValue()
-{
- return *(this->nodes_.top());
-}
+Value& Reader::currentValue() { return *(nodes_.top()); }
-Reader::Char Reader::getNextChar()
-{
- if (this->current_ == this->end_)
+Reader::Char Reader::getNextChar() {
+ if (current_ == end_)
return 0;
- return *this->current_++;
+ return *current_++;
}
-void Reader::getLocationLineAndColumn(Location location, int& line,
- int& column) const
-{
- Location current = this->begin_;
+void Reader::getLocationLineAndColumn(Location location,
+ int& line,
+ int& column) const {
+ Location current = begin_;
Location lastLineStart = current;
line = 0;
- while (current < location && current != this->end_) {
+ while (current < location && current != end_) {
Char c = *current++;
if (c == '\r') {
if (*current == '\n')
@@ -872,96 +810,91 @@ void Reader::getLocationLineAndColumn(Location location, int& line,
++line;
}
-JSONCPP_STRING Reader::getLocationLineAndColumn(Location location) const
-{
+JSONCPP_STRING Reader::getLocationLineAndColumn(Location location) const {
int line, column;
- this->getLocationLineAndColumn(location, line, column);
+ getLocationLineAndColumn(location, line, column);
char buffer[18 + 16 + 16 + 1];
snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
return buffer;
}
// Deprecated. Preserved for backward compatibility
-JSONCPP_STRING Reader::getFormatedErrorMessages() const
-{
- return this->getFormattedErrorMessages();
+JSONCPP_STRING Reader::getFormatedErrorMessages() const {
+ return getFormattedErrorMessages();
}
-JSONCPP_STRING Reader::getFormattedErrorMessages() const
-{
+JSONCPP_STRING Reader::getFormattedErrorMessages() const {
JSONCPP_STRING formattedMessage;
- for (Errors::const_iterator itError = this->errors_.begin();
- itError != this->errors_.end(); ++itError) {
+ for (Errors::const_iterator itError = errors_.begin();
+ itError != errors_.end();
+ ++itError) {
const ErrorInfo& error = *itError;
formattedMessage +=
- "* " + this->getLocationLineAndColumn(error.token_.start_) + "\n";
+ "* " + getLocationLineAndColumn(error.token_.start_) + "\n";
formattedMessage += " " + error.message_ + "\n";
if (error.extra_)
- formattedMessage += "See " +
- this->getLocationLineAndColumn(error.extra_) + " for detail.\n";
+ formattedMessage +=
+ "See " + getLocationLineAndColumn(error.extra_) + " for detail.\n";
}
return formattedMessage;
}
-std::vector<Reader::StructuredError> Reader::getStructuredErrors() const
-{
+std::vector<Reader::StructuredError> Reader::getStructuredErrors() const {
std::vector<Reader::StructuredError> allErrors;
- for (Errors::const_iterator itError = this->errors_.begin();
- itError != this->errors_.end(); ++itError) {
+ for (Errors::const_iterator itError = errors_.begin();
+ itError != errors_.end();
+ ++itError) {
const ErrorInfo& error = *itError;
Reader::StructuredError structured;
- structured.offset_start = error.token_.start_ - this->begin_;
- structured.offset_limit = error.token_.end_ - this->begin_;
+ structured.offset_start = error.token_.start_ - begin_;
+ structured.offset_limit = error.token_.end_ - begin_;
structured.message = error.message_;
allErrors.push_back(structured);
}
return allErrors;
}
-bool Reader::pushError(const Value& value, const JSONCPP_STRING& message)
-{
- ptrdiff_t const length = this->end_ - this->begin_;
- if (value.getOffsetStart() > length || value.getOffsetLimit() > length)
+bool Reader::pushError(const Value& value, const JSONCPP_STRING& message) {
+ ptrdiff_t const length = end_ - begin_;
+ if(value.getOffsetStart() > length
+ || value.getOffsetLimit() > length)
return false;
Token token;
token.type_ = tokenError;
- token.start_ = this->begin_ + value.getOffsetStart();
- token.end_ = this->end_ + value.getOffsetLimit();
+ token.start_ = begin_ + value.getOffsetStart();
+ token.end_ = end_ + value.getOffsetLimit();
ErrorInfo info;
info.token_ = token;
info.message_ = message;
info.extra_ = 0;
- this->errors_.push_back(info);
+ errors_.push_back(info);
return true;
}
-bool Reader::pushError(const Value& value, const JSONCPP_STRING& message,
- const Value& extra)
-{
- ptrdiff_t const length = this->end_ - this->begin_;
- if (value.getOffsetStart() > length || value.getOffsetLimit() > length ||
- extra.getOffsetLimit() > length)
+bool Reader::pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra) {
+ ptrdiff_t const length = end_ - begin_;
+ if(value.getOffsetStart() > length
+ || value.getOffsetLimit() > length
+ || extra.getOffsetLimit() > length)
return false;
Token token;
token.type_ = tokenError;
- token.start_ = this->begin_ + value.getOffsetStart();
- token.end_ = this->begin_ + value.getOffsetLimit();
+ token.start_ = begin_ + value.getOffsetStart();
+ token.end_ = begin_ + value.getOffsetLimit();
ErrorInfo info;
info.token_ = token;
info.message_ = message;
- info.extra_ = this->begin_ + extra.getOffsetStart();
- this->errors_.push_back(info);
+ info.extra_ = begin_ + extra.getOffsetStart();
+ errors_.push_back(info);
return true;
}
-bool Reader::good() const
-{
- return !this->errors_.size();
+bool Reader::good() const {
+ return !errors_.size();
}
// exact copy of Features
-class OurFeatures
-{
+class OurFeatures {
public:
static OurFeatures all();
bool allowComments_;
@@ -973,48 +906,43 @@ public:
bool rejectDupKeys_;
bool allowSpecialFloats_;
int stackLimit_;
-}; // OurFeatures
+}; // OurFeatures
// exact copy of Implementation of class Features
// ////////////////////////////////
-OurFeatures OurFeatures::all()
-{
- return OurFeatures();
-}
+OurFeatures OurFeatures::all() { return OurFeatures(); }
// Implementation of class Reader
// ////////////////////////////////
// exact copy of Reader, renamed to OurReader
-class OurReader
-{
+class OurReader {
public:
typedef char Char;
typedef const Char* Location;
- struct StructuredError
- {
+ struct StructuredError {
ptrdiff_t offset_start;
ptrdiff_t offset_limit;
JSONCPP_STRING message;
};
OurReader(OurFeatures const& features);
- bool parse(const char* beginDoc, const char* endDoc, Value& root,
+ bool parse(const char* beginDoc,
+ const char* endDoc,
+ Value& root,
bool collectComments = true);
JSONCPP_STRING getFormattedErrorMessages() const;
std::vector<StructuredError> getStructuredErrors() const;
bool pushError(const Value& value, const JSONCPP_STRING& message);
- bool pushError(const Value& value, const JSONCPP_STRING& message,
- const Value& extra);
+ bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra);
bool good() const;
private:
- OurReader(OurReader const&); // no impl
- void operator=(OurReader const&); // no impl
+ OurReader(OurReader const&); // no impl
+ void operator=(OurReader const&); // no impl
- enum TokenType
- {
+ enum TokenType {
tokenEndOfStream = 0,
tokenObjectBegin,
tokenObjectEnd,
@@ -1034,16 +962,14 @@ private:
tokenError
};
- class Token
- {
+ class Token {
public:
TokenType type_;
Location start_;
Location end_;
};
- class ErrorInfo
- {
+ class ErrorInfo {
public:
Token token_;
JSONCPP_STRING message_;
@@ -1070,20 +996,24 @@ private:
bool decodeString(Token& token, JSONCPP_STRING& decoded);
bool decodeDouble(Token& token);
bool decodeDouble(Token& token, Value& decoded);
- bool decodeUnicodeCodePoint(Token& token, Location& current, Location end,
+ bool decodeUnicodeCodePoint(Token& token,
+ Location& current,
+ Location end,
unsigned int& unicode);
- bool decodeUnicodeEscapeSequence(Token& token, Location& current,
- Location end, unsigned int& unicode);
- bool addError(const JSONCPP_STRING& message, Token& token,
- Location extra = 0);
+ bool decodeUnicodeEscapeSequence(Token& token,
+ Location& current,
+ Location end,
+ unsigned int& unicode);
+ bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0);
bool recoverFromError(TokenType skipUntilToken);
- bool addErrorAndRecover(const JSONCPP_STRING& message, Token& token,
+ bool addErrorAndRecover(const JSONCPP_STRING& message,
+ Token& token,
TokenType skipUntilToken);
void skipUntilSpace();
Value& currentValue();
Char getNextChar();
- void getLocationLineAndColumn(Location location, int& line,
- int& column) const;
+ void
+ getLocationLineAndColumn(Location location, int& line, int& column) const;
JSONCPP_STRING getLocationLineAndColumn(Location location) const;
void addComment(Location begin, Location end, CommentPlacement placement);
void skipCommentTokens(Token& token);
@@ -1104,13 +1034,11 @@ private:
OurFeatures const features_;
bool collectComments_;
-}; // OurReader
+}; // OurReader
// complete copy of Read impl, for OurReader
-bool OurReader::containsNewLine(OurReader::Location begin,
- OurReader::Location end)
-{
+bool OurReader::containsNewLine(OurReader::Location begin, OurReader::Location end) {
for (; begin < end; ++begin)
if (*begin == '\n' || *begin == '\r')
return true;
@@ -1118,322 +1046,315 @@ bool OurReader::containsNewLine(OurReader::Location begin,
}
OurReader::OurReader(OurFeatures const& features)
- : errors_()
- , document_()
- , begin_()
- , end_()
- , current_()
- , lastValueEnd_()
- , lastValue_()
- , commentsBefore_()
- , features_(features)
- , collectComments_()
-{
+ : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
+ lastValue_(), commentsBefore_(),
+ features_(features), collectComments_() {
}
-bool OurReader::parse(const char* beginDoc, const char* endDoc, Value& root,
- bool collectComments)
-{
- if (!this->features_.allowComments_) {
+bool OurReader::parse(const char* beginDoc,
+ const char* endDoc,
+ Value& root,
+ bool collectComments) {
+ if (!features_.allowComments_) {
collectComments = false;
}
- this->begin_ = beginDoc;
- this->end_ = endDoc;
- this->collectComments_ = collectComments;
- this->current_ = this->begin_;
- this->lastValueEnd_ = 0;
- this->lastValue_ = 0;
- this->commentsBefore_.clear();
- this->errors_.clear();
- while (!this->nodes_.empty())
- this->nodes_.pop();
- this->nodes_.push(&root);
-
- bool successful = this->readValue();
+ begin_ = beginDoc;
+ end_ = endDoc;
+ collectComments_ = collectComments;
+ current_ = begin_;
+ lastValueEnd_ = 0;
+ lastValue_ = 0;
+ commentsBefore_.clear();
+ errors_.clear();
+ while (!nodes_.empty())
+ nodes_.pop();
+ nodes_.push(&root);
+
+ bool successful = readValue();
Token token;
- this->skipCommentTokens(token);
- if (this->features_.failIfExtra_) {
- if ((this->features_.strictRoot_ || token.type_ != tokenError) &&
- token.type_ != tokenEndOfStream) {
- this->addError("Extra non-whitespace after JSON value.", token);
+ skipCommentTokens(token);
+ if (features_.failIfExtra_) {
+ if ((features_.strictRoot_ || token.type_ != tokenError) && token.type_ != tokenEndOfStream) {
+ addError("Extra non-whitespace after JSON value.", token);
return false;
}
}
- if (this->collectComments_ && !this->commentsBefore_.empty())
- root.setComment(this->commentsBefore_, commentAfter);
- if (this->features_.strictRoot_) {
+ if (collectComments_ && !commentsBefore_.empty())
+ root.setComment(commentsBefore_, commentAfter);
+ if (features_.strictRoot_) {
if (!root.isArray() && !root.isObject()) {
- // Set error location to start of doc, ideally should be first token
- // found in doc
+ // Set error location to start of doc, ideally should be first token found
+ // in doc
token.type_ = tokenError;
token.start_ = beginDoc;
token.end_ = endDoc;
- this->addError(
- "A valid JSON document must be either an array or an object value.",
- token);
+ addError(
+ "A valid JSON document must be either an array or an object value.",
+ token);
return false;
}
}
return successful;
}
-bool OurReader::readValue()
-{
+bool OurReader::readValue() {
// To preserve the old behaviour we cast size_t to int.
- if (static_cast<int>(this->nodes_.size()) > this->features_.stackLimit_)
- throwRuntimeError("Exceeded stackLimit in readValue().");
+ if (static_cast<int>(nodes_.size()) > features_.stackLimit_) throwRuntimeError("Exceeded stackLimit in readValue().");
Token token;
- this->skipCommentTokens(token);
+ skipCommentTokens(token);
bool successful = true;
- if (this->collectComments_ && !this->commentsBefore_.empty()) {
- this->currentValue().setComment(this->commentsBefore_, commentBefore);
- this->commentsBefore_.clear();
+ if (collectComments_ && !commentsBefore_.empty()) {
+ currentValue().setComment(commentsBefore_, commentBefore);
+ commentsBefore_.clear();
}
switch (token.type_) {
- case tokenObjectBegin:
- successful = this->readObject(token);
- this->currentValue().setOffsetLimit(this->current_ - this->begin_);
- break;
- case tokenArrayBegin:
- successful = this->readArray(token);
- this->currentValue().setOffsetLimit(this->current_ - this->begin_);
- break;
- case tokenNumber:
- successful = this->decodeNumber(token);
- break;
- case tokenString:
- successful = this->decodeString(token);
- break;
- case tokenTrue: {
- Value v(true);
- this->currentValue().swapPayload(v);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
- } break;
- case tokenFalse: {
- Value v(false);
- this->currentValue().swapPayload(v);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
- } break;
- case tokenNull: {
+ case tokenObjectBegin:
+ successful = readObject(token);
+ currentValue().setOffsetLimit(current_ - begin_);
+ break;
+ case tokenArrayBegin:
+ successful = readArray(token);
+ currentValue().setOffsetLimit(current_ - begin_);
+ break;
+ case tokenNumber:
+ successful = decodeNumber(token);
+ break;
+ case tokenString:
+ successful = decodeString(token);
+ break;
+ case tokenTrue:
+ {
+ Value v(true);
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenFalse:
+ {
+ Value v(false);
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenNull:
+ {
+ Value v;
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenNaN:
+ {
+ Value v(std::numeric_limits<double>::quiet_NaN());
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenPosInf:
+ {
+ Value v(std::numeric_limits<double>::infinity());
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenNegInf:
+ {
+ Value v(-std::numeric_limits<double>::infinity());
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenArraySeparator:
+ case tokenObjectEnd:
+ case tokenArrayEnd:
+ if (features_.allowDroppedNullPlaceholders_) {
+ // "Un-read" the current token and mark the current value as a null
+ // token.
+ current_--;
Value v;
- this->currentValue().swapPayload(v);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
- } break;
- case tokenNaN: {
- Value v(std::numeric_limits<double>::quiet_NaN());
- this->currentValue().swapPayload(v);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
- } break;
- case tokenPosInf: {
- Value v(std::numeric_limits<double>::infinity());
- this->currentValue().swapPayload(v);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
- } break;
- case tokenNegInf: {
- Value v(-std::numeric_limits<double>::infinity());
- this->currentValue().swapPayload(v);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
- } break;
- case tokenArraySeparator:
- case tokenObjectEnd:
- case tokenArrayEnd:
- if (this->features_.allowDroppedNullPlaceholders_) {
- // "Un-read" the current token and mark the current value as a null
- // token.
- this->current_--;
- Value v;
- this->currentValue().swapPayload(v);
- this->currentValue().setOffsetStart(this->current_ - this->begin_ - 1);
- this->currentValue().setOffsetLimit(this->current_ - this->begin_);
- break;
- } // else, fall through ...
- default:
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
- return this->addError("Syntax error: value, object or array expected.",
- token);
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(current_ - begin_ - 1);
+ currentValue().setOffsetLimit(current_ - begin_);
+ break;
+ } // else, fall through ...
+ default:
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ return addError("Syntax error: value, object or array expected.", token);
}
- if (this->collectComments_) {
- this->lastValueEnd_ = this->current_;
- this->lastValue_ = &this->currentValue();
+ if (collectComments_) {
+ lastValueEnd_ = current_;
+ lastValue_ = &currentValue();
}
return successful;
}
-void OurReader::skipCommentTokens(Token& token)
-{
- if (this->features_.allowComments_) {
+void OurReader::skipCommentTokens(Token& token) {
+ if (features_.allowComments_) {
do {
- this->readToken(token);
+ readToken(token);
} while (token.type_ == tokenComment);
} else {
- this->readToken(token);
+ readToken(token);
}
}
-bool OurReader::readToken(Token& token)
-{
- this->skipSpaces();
- token.start_ = this->current_;
- Char c = this->getNextChar();
+bool OurReader::readToken(Token& token) {
+ skipSpaces();
+ token.start_ = current_;
+ Char c = getNextChar();
bool ok = true;
switch (c) {
- case '{':
- token.type_ = tokenObjectBegin;
- break;
- case '}':
- token.type_ = tokenObjectEnd;
- break;
- case '[':
- token.type_ = tokenArrayBegin;
- break;
- case ']':
- token.type_ = tokenArrayEnd;
- break;
- case '"':
- token.type_ = tokenString;
- ok = this->readString();
- break;
- case '\'':
- if (this->features_.allowSingleQuotes_) {
- token.type_ = tokenString;
- ok = this->readStringSingleQuote();
- break;
- } // else continue
- case '/':
- token.type_ = tokenComment;
- ok = this->readComment();
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
+ case '{':
+ token.type_ = tokenObjectBegin;
+ break;
+ case '}':
+ token.type_ = tokenObjectEnd;
+ break;
+ case '[':
+ token.type_ = tokenArrayBegin;
+ break;
+ case ']':
+ token.type_ = tokenArrayEnd;
+ break;
+ case '"':
+ token.type_ = tokenString;
+ ok = readString();
+ break;
+ case '\'':
+ if (features_.allowSingleQuotes_) {
+ token.type_ = tokenString;
+ ok = readStringSingleQuote();
+ break;
+ } // else continue
+ case '/':
+ token.type_ = tokenComment;
+ ok = readComment();
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ token.type_ = tokenNumber;
+ readNumber(false);
+ break;
+ case '-':
+ if (readNumber(true)) {
token.type_ = tokenNumber;
- this->readNumber(false);
- break;
- case '-':
- if (this->readNumber(true)) {
- token.type_ = tokenNumber;
- } else {
- token.type_ = tokenNegInf;
- ok = this->features_.allowSpecialFloats_ && this->match("nfinity", 7);
- }
- break;
- case 't':
- token.type_ = tokenTrue;
- ok = this->match("rue", 3);
- break;
- case 'f':
- token.type_ = tokenFalse;
- ok = this->match("alse", 4);
- break;
- case 'n':
- token.type_ = tokenNull;
- ok = this->match("ull", 3);
- break;
- case 'N':
- if (this->features_.allowSpecialFloats_) {
- token.type_ = tokenNaN;
- ok = this->match("aN", 2);
- } else {
- ok = false;
- }
- break;
- case 'I':
- if (this->features_.allowSpecialFloats_) {
- token.type_ = tokenPosInf;
- ok = this->match("nfinity", 7);
- } else {
- ok = false;
- }
- break;
- case ',':
- token.type_ = tokenArraySeparator;
- break;
- case ':':
- token.type_ = tokenMemberSeparator;
- break;
- case 0:
- token.type_ = tokenEndOfStream;
- break;
- default:
+ } else {
+ token.type_ = tokenNegInf;
+ ok = features_.allowSpecialFloats_ && match("nfinity", 7);
+ }
+ break;
+ case 't':
+ token.type_ = tokenTrue;
+ ok = match("rue", 3);
+ break;
+ case 'f':
+ token.type_ = tokenFalse;
+ ok = match("alse", 4);
+ break;
+ case 'n':
+ token.type_ = tokenNull;
+ ok = match("ull", 3);
+ break;
+ case 'N':
+ if (features_.allowSpecialFloats_) {
+ token.type_ = tokenNaN;
+ ok = match("aN", 2);
+ } else {
ok = false;
- break;
+ }
+ break;
+ case 'I':
+ if (features_.allowSpecialFloats_) {
+ token.type_ = tokenPosInf;
+ ok = match("nfinity", 7);
+ } else {
+ ok = false;
+ }
+ break;
+ case ',':
+ token.type_ = tokenArraySeparator;
+ break;
+ case ':':
+ token.type_ = tokenMemberSeparator;
+ break;
+ case 0:
+ token.type_ = tokenEndOfStream;
+ break;
+ default:
+ ok = false;
+ break;
}
if (!ok)
token.type_ = tokenError;
- token.end_ = this->current_;
+ token.end_ = current_;
return true;
}
-void OurReader::skipSpaces()
-{
- while (this->current_ != this->end_) {
- Char c = *this->current_;
+void OurReader::skipSpaces() {
+ while (current_ != end_) {
+ Char c = *current_;
if (c == ' ' || c == '\t' || c == '\r' || c == '\n')
- ++this->current_;
+ ++current_;
else
break;
}
}
-bool OurReader::match(Location pattern, int patternLength)
-{
- if (this->end_ - this->current_ < patternLength)
+bool OurReader::match(Location pattern, int patternLength) {
+ if (end_ - current_ < patternLength)
return false;
int index = patternLength;
while (index--)
- if (this->current_[index] != pattern[index])
+ if (current_[index] != pattern[index])
return false;
- this->current_ += patternLength;
+ current_ += patternLength;
return true;
}
-bool OurReader::readComment()
-{
- Location commentBegin = this->current_ - 1;
- Char c = this->getNextChar();
+bool OurReader::readComment() {
+ Location commentBegin = current_ - 1;
+ Char c = getNextChar();
bool successful = false;
if (c == '*')
- successful = this->readCStyleComment();
+ successful = readCStyleComment();
else if (c == '/')
- successful = this->readCppStyleComment();
+ successful = readCppStyleComment();
if (!successful)
return false;
- if (this->collectComments_) {
+ if (collectComments_) {
CommentPlacement placement = commentBefore;
- if (this->lastValueEnd_ &&
- !containsNewLine(this->lastValueEnd_, commentBegin)) {
- if (c != '*' || !containsNewLine(commentBegin, this->current_))
+ if (lastValueEnd_ && !containsNewLine(lastValueEnd_, commentBegin)) {
+ if (c != '*' || !containsNewLine(commentBegin, current_))
placement = commentAfterOnSameLine;
}
- this->addComment(commentBegin, this->current_, placement);
+ addComment(commentBegin, current_, placement);
}
return true;
}
-JSONCPP_STRING OurReader::normalizeEOL(OurReader::Location begin,
- OurReader::Location end)
-{
+JSONCPP_STRING OurReader::normalizeEOL(OurReader::Location begin, OurReader::Location end) {
JSONCPP_STRING normalized;
normalized.reserve(static_cast<size_t>(end - begin));
OurReader::Location current = begin;
@@ -1441,8 +1362,8 @@ JSONCPP_STRING OurReader::normalizeEOL(OurReader::Location begin,
char c = *current++;
if (c == '\r') {
if (current != end && *current == '\n')
- // convert dos EOL
- ++current;
+ // convert dos EOL
+ ++current;
// convert Mac EOL
normalized += '\n';
} else {
@@ -1452,39 +1373,36 @@ JSONCPP_STRING OurReader::normalizeEOL(OurReader::Location begin,
return normalized;
}
-void OurReader::addComment(Location begin, Location end,
- CommentPlacement placement)
-{
- assert(this->collectComments_);
+void
+OurReader::addComment(Location begin, Location end, CommentPlacement placement) {
+ assert(collectComments_);
const JSONCPP_STRING& normalized = normalizeEOL(begin, end);
if (placement == commentAfterOnSameLine) {
- assert(this->lastValue_ != 0);
- this->lastValue_->setComment(normalized, placement);
+ assert(lastValue_ != 0);
+ lastValue_->setComment(normalized, placement);
} else {
- this->commentsBefore_ += normalized;
+ commentsBefore_ += normalized;
}
}
-bool OurReader::readCStyleComment()
-{
- while ((this->current_ + 1) < this->end_) {
- Char c = this->getNextChar();
- if (c == '*' && *this->current_ == '/')
+bool OurReader::readCStyleComment() {
+ while ((current_ + 1) < end_) {
+ Char c = getNextChar();
+ if (c == '*' && *current_ == '/')
break;
}
- return this->getNextChar() == '/';
+ return getNextChar() == '/';
}
-bool OurReader::readCppStyleComment()
-{
- while (this->current_ != this->end_) {
- Char c = this->getNextChar();
+bool OurReader::readCppStyleComment() {
+ while (current_ != end_) {
+ Char c = getNextChar();
if (c == '\n')
break;
if (c == '\r') {
// Consume DOS EOL. It will be normalized in addComment.
- if (this->current_ != this->end_ && *this->current_ == '\n')
- this->getNextChar();
+ if (current_ != end_ && *current_ == '\n')
+ getNextChar();
// Break on Moc OS 9 EOL.
break;
}
@@ -1492,156 +1410,150 @@ bool OurReader::readCppStyleComment()
return true;
}
-bool OurReader::readNumber(bool checkInf)
-{
- const char* p = this->current_;
- if (checkInf && p != this->end_ && *p == 'I') {
- this->current_ = ++p;
+bool OurReader::readNumber(bool checkInf) {
+ const char *p = current_;
+ if (checkInf && p != end_ && *p == 'I') {
+ current_ = ++p;
return false;
}
char c = '0'; // stopgap for already consumed character
// integral part
while (c >= '0' && c <= '9')
- c = (this->current_ = p) < this->end_ ? *p++ : '\0';
+ c = (current_ = p) < end_ ? *p++ : '\0';
// fractional part
if (c == '.') {
- c = (this->current_ = p) < this->end_ ? *p++ : '\0';
+ c = (current_ = p) < end_ ? *p++ : '\0';
while (c >= '0' && c <= '9')
- c = (this->current_ = p) < this->end_ ? *p++ : '\0';
+ c = (current_ = p) < end_ ? *p++ : '\0';
}
// exponential part
if (c == 'e' || c == 'E') {
- c = (this->current_ = p) < this->end_ ? *p++ : '\0';
+ c = (current_ = p) < end_ ? *p++ : '\0';
if (c == '+' || c == '-')
- c = (this->current_ = p) < this->end_ ? *p++ : '\0';
+ c = (current_ = p) < end_ ? *p++ : '\0';
while (c >= '0' && c <= '9')
- c = (this->current_ = p) < this->end_ ? *p++ : '\0';
+ c = (current_ = p) < end_ ? *p++ : '\0';
}
return true;
}
-bool OurReader::readString()
-{
+bool OurReader::readString() {
Char c = 0;
- while (this->current_ != this->end_) {
- c = this->getNextChar();
+ while (current_ != end_) {
+ c = getNextChar();
if (c == '\\')
- this->getNextChar();
+ getNextChar();
else if (c == '"')
break;
}
return c == '"';
}
-bool OurReader::readStringSingleQuote()
-{
+
+bool OurReader::readStringSingleQuote() {
Char c = 0;
- while (this->current_ != this->end_) {
- c = this->getNextChar();
+ while (current_ != end_) {
+ c = getNextChar();
if (c == '\\')
- this->getNextChar();
+ getNextChar();
else if (c == '\'')
break;
}
return c == '\'';
}
-bool OurReader::readObject(Token& tokenStart)
-{
+bool OurReader::readObject(Token& tokenStart) {
Token tokenName;
JSONCPP_STRING name;
Value init(objectValue);
- this->currentValue().swapPayload(init);
- this->currentValue().setOffsetStart(tokenStart.start_ - this->begin_);
- while (this->readToken(tokenName)) {
+ currentValue().swapPayload(init);
+ currentValue().setOffsetStart(tokenStart.start_ - begin_);
+ while (readToken(tokenName)) {
bool initialTokenOk = true;
while (tokenName.type_ == tokenComment && initialTokenOk)
- initialTokenOk = this->readToken(tokenName);
+ initialTokenOk = readToken(tokenName);
if (!initialTokenOk)
break;
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
return true;
name.clear();
if (tokenName.type_ == tokenString) {
- if (!this->decodeString(tokenName, name))
- return this->recoverFromError(tokenObjectEnd);
- } else if (tokenName.type_ == tokenNumber &&
- this->features_.allowNumericKeys_) {
+ if (!decodeString(tokenName, name))
+ return recoverFromError(tokenObjectEnd);
+ } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
Value numberName;
- if (!this->decodeNumber(tokenName, numberName))
- return this->recoverFromError(tokenObjectEnd);
+ if (!decodeNumber(tokenName, numberName))
+ return recoverFromError(tokenObjectEnd);
name = numberName.asString();
} else {
break;
}
Token colon;
- if (!this->readToken(colon) || colon.type_ != tokenMemberSeparator) {
- return this->addErrorAndRecover("Missing ':' after object member name",
- colon, tokenObjectEnd);
+ if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {
+ return addErrorAndRecover(
+ "Missing ':' after object member name", colon, tokenObjectEnd);
}
- if (name.length() >= (1U << 30))
- throwRuntimeError("keylength >= 2^30");
- if (this->features_.rejectDupKeys_ &&
- this->currentValue().isMember(name)) {
+ if (name.length() >= (1U<<30)) throwRuntimeError("keylength >= 2^30");
+ if (features_.rejectDupKeys_ && currentValue().isMember(name)) {
JSONCPP_STRING msg = "Duplicate key: '" + name + "'";
- return this->addErrorAndRecover(msg, tokenName, tokenObjectEnd);
+ return addErrorAndRecover(
+ msg, tokenName, tokenObjectEnd);
}
- Value& value = this->currentValue()[name];
- this->nodes_.push(&value);
- bool ok = this->readValue();
- this->nodes_.pop();
+ Value& value = currentValue()[name];
+ nodes_.push(&value);
+ bool ok = readValue();
+ nodes_.pop();
if (!ok) // error already set
- return this->recoverFromError(tokenObjectEnd);
+ return recoverFromError(tokenObjectEnd);
Token comma;
- if (!this->readToken(comma) ||
+ if (!readToken(comma) ||
(comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&
comma.type_ != tokenComment)) {
- return this->addErrorAndRecover(
- "Missing ',' or '}' in object declaration", comma, tokenObjectEnd);
+ return addErrorAndRecover(
+ "Missing ',' or '}' in object declaration", comma, tokenObjectEnd);
}
bool finalizeTokenOk = true;
while (comma.type_ == tokenComment && finalizeTokenOk)
- finalizeTokenOk = this->readToken(comma);
+ finalizeTokenOk = readToken(comma);
if (comma.type_ == tokenObjectEnd)
return true;
}
- return this->addErrorAndRecover("Missing '}' or object member name",
- tokenName, tokenObjectEnd);
+ return addErrorAndRecover(
+ "Missing '}' or object member name", tokenName, tokenObjectEnd);
}
-bool OurReader::readArray(Token& tokenStart)
-{
+bool OurReader::readArray(Token& tokenStart) {
Value init(arrayValue);
- this->currentValue().swapPayload(init);
- this->currentValue().setOffsetStart(tokenStart.start_ - this->begin_);
- this->skipSpaces();
- if (this->current_ != this->end_ && *this->current_ == ']') // empty array
+ currentValue().swapPayload(init);
+ currentValue().setOffsetStart(tokenStart.start_ - begin_);
+ skipSpaces();
+ if (current_ != end_ && *current_ == ']') // empty array
{
Token endArray;
- this->readToken(endArray);
+ readToken(endArray);
return true;
}
int index = 0;
for (;;) {
- Value& value = this->currentValue()[index++];
- this->nodes_.push(&value);
- bool ok = this->readValue();
- this->nodes_.pop();
+ Value& value = currentValue()[index++];
+ nodes_.push(&value);
+ bool ok = readValue();
+ nodes_.pop();
if (!ok) // error already set
- return this->recoverFromError(tokenArrayEnd);
+ return recoverFromError(tokenArrayEnd);
Token token;
// Accept Comment after last item in the array.
- ok = this->readToken(token);
+ ok = readToken(token);
while (token.type_ == tokenComment && ok) {
- ok = this->readToken(token);
+ ok = readToken(token);
}
bool badTokenType =
- (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);
+ (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);
if (!ok || badTokenType) {
- return this->addErrorAndRecover(
- "Missing ',' or ']' in array declaration", token, tokenArrayEnd);
+ return addErrorAndRecover(
+ "Missing ',' or ']' in array declaration", token, tokenArrayEnd);
}
if (token.type_ == tokenArrayEnd)
break;
@@ -1649,19 +1561,17 @@ bool OurReader::readArray(Token& tokenStart)
return true;
}
-bool OurReader::decodeNumber(Token& token)
-{
+bool OurReader::decodeNumber(Token& token) {
Value decoded;
- if (!this->decodeNumber(token, decoded))
+ if (!decodeNumber(token, decoded))
return false;
- this->currentValue().swapPayload(decoded);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
+ currentValue().swapPayload(decoded);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
return true;
}
-bool OurReader::decodeNumber(Token& token, Value& decoded)
-{
+bool OurReader::decodeNumber(Token& token, Value& decoded) {
// Attempts to parse the number as an integer. If the number is
// larger than the maximum supported value of an integer then
// we decode the number as a double.
@@ -1669,17 +1579,16 @@ bool OurReader::decodeNumber(Token& token, Value& decoded)
bool isNegative = *current == '-';
if (isNegative)
++current;
- // TODO: Help the compiler do the div and mod at compile time or get rid of
- // them.
- Value::LargestUInt maxIntegerValue = isNegative
- ? Value::LargestUInt(Value::minLargestInt)
- : Value::maxLargestUInt;
+ // TODO: Help the compiler do the div and mod at compile time or get rid of them.
+ Value::LargestUInt maxIntegerValue =
+ isNegative ? Value::LargestUInt(Value::minLargestInt)
+ : Value::maxLargestUInt;
Value::LargestUInt threshold = maxIntegerValue / 10;
Value::LargestUInt value = 0;
while (current < token.end_) {
Char c = *current++;
if (c < '0' || c > '9')
- return this->decodeDouble(token, decoded);
+ return decodeDouble(token, decoded);
Value::UInt digit(static_cast<Value::UInt>(c - '0'));
if (value >= threshold) {
// We've hit or exceeded the max value divided by 10 (rounded down). If
@@ -1688,7 +1597,7 @@ bool OurReader::decodeNumber(Token& token, Value& decoded)
// Otherwise treat this number as a double to avoid overflow.
if (value > threshold || current != token.end_ ||
digit > maxIntegerValue % 10) {
- return this->decodeDouble(token, decoded);
+ return decodeDouble(token, decoded);
}
}
value = value * 10 + digit;
@@ -1702,19 +1611,17 @@ bool OurReader::decodeNumber(Token& token, Value& decoded)
return true;
}
-bool OurReader::decodeDouble(Token& token)
-{
+bool OurReader::decodeDouble(Token& token) {
Value decoded;
- if (!this->decodeDouble(token, decoded))
+ if (!decodeDouble(token, decoded))
return false;
- this->currentValue().swapPayload(decoded);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
+ currentValue().swapPayload(decoded);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
return true;
}
-bool OurReader::decodeDouble(Token& token, Value& decoded)
-{
+bool OurReader::decodeDouble(Token& token, Value& decoded) {
double value = 0;
const int bufferSize = 32;
int count;
@@ -1722,7 +1629,7 @@ bool OurReader::decodeDouble(Token& token, Value& decoded)
// Sanity check to avoid buffer overflow exploits.
if (length < 0) {
- return this->addError("Unable to parse token length", token);
+ return addError("Unable to parse token length", token);
}
size_t const ulength = static_cast<size_t>(length);
@@ -1745,27 +1652,25 @@ bool OurReader::decodeDouble(Token& token, Value& decoded)
}
if (count != 1)
- return this->addError("'" + JSONCPP_STRING(token.start_, token.end_) +
- "' is not a number.",
- token);
+ return addError("'" + JSONCPP_STRING(token.start_, token.end_) +
+ "' is not a number.",
+ token);
decoded = value;
return true;
}
-bool OurReader::decodeString(Token& token)
-{
+bool OurReader::decodeString(Token& token) {
JSONCPP_STRING decoded_string;
- if (!this->decodeString(token, decoded_string))
+ if (!decodeString(token, decoded_string))
return false;
Value decoded(decoded_string);
- this->currentValue().swapPayload(decoded);
- this->currentValue().setOffsetStart(token.start_ - this->begin_);
- this->currentValue().setOffsetLimit(token.end_ - this->begin_);
+ currentValue().swapPayload(decoded);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
return true;
}
-bool OurReader::decodeString(Token& token, JSONCPP_STRING& decoded)
-{
+bool OurReader::decodeString(Token& token, JSONCPP_STRING& decoded) {
decoded.reserve(static_cast<size_t>(token.end_ - token.start_ - 2));
Location current = token.start_ + 1; // skip '"'
Location end = token.end_ - 1; // do not include '"'
@@ -1775,43 +1680,41 @@ bool OurReader::decodeString(Token& token, JSONCPP_STRING& decoded)
break;
else if (c == '\\') {
if (current == end)
- return this->addError("Empty escape sequence in string", token,
- current);
+ return addError("Empty escape sequence in string", token, current);
Char escape = *current++;
switch (escape) {
- case '"':
- decoded += '"';
- break;
- case '/':
- decoded += '/';
- break;
- case '\\':
- decoded += '\\';
- break;
- case 'b':
- decoded += '\b';
- break;
- case 'f':
- decoded += '\f';
- break;
- case 'n':
- decoded += '\n';
- break;
- case 'r':
- decoded += '\r';
- break;
- case 't':
- decoded += '\t';
- break;
- case 'u': {
- unsigned int unicode;
- if (!this->decodeUnicodeCodePoint(token, current, end, unicode))
- return false;
- decoded += codePointToUTF8(unicode);
- } break;
- default:
- return this->addError("Bad escape sequence in string", token,
- current);
+ case '"':
+ decoded += '"';
+ break;
+ case '/':
+ decoded += '/';
+ break;
+ case '\\':
+ decoded += '\\';
+ break;
+ case 'b':
+ decoded += '\b';
+ break;
+ case 'f':
+ decoded += '\f';
+ break;
+ case 'n':
+ decoded += '\n';
+ break;
+ case 'r':
+ decoded += '\r';
+ break;
+ case 't':
+ decoded += '\t';
+ break;
+ case 'u': {
+ unsigned int unicode;
+ if (!decodeUnicodeCodePoint(token, current, end, unicode))
+ return false;
+ decoded += codePointToUTF8(unicode);
+ } break;
+ default:
+ return addError("Bad escape sequence in string", token, current);
}
} else {
decoded += c;
@@ -1820,44 +1723,45 @@ bool OurReader::decodeString(Token& token, JSONCPP_STRING& decoded)
return true;
}
-bool OurReader::decodeUnicodeCodePoint(Token& token, Location& current,
- Location end, unsigned int& unicode)
-{
+bool OurReader::decodeUnicodeCodePoint(Token& token,
+ Location& current,
+ Location end,
+ unsigned int& unicode) {
- unicode = 0; // Convince scanbuild this is always initialized before use.
- if (!this->decodeUnicodeEscapeSequence(token, current, end, unicode))
+ unicode = 0; // Convince clang-analyzer that this is initialized before use.
+ if (!decodeUnicodeEscapeSequence(token, current, end, unicode))
return false;
if (unicode >= 0xD800 && unicode <= 0xDBFF) {
// surrogate pairs
if (end - current < 6)
- return this->addError(
- "additional six characters expected to parse unicode surrogate pair.",
- token, current);
+ return addError(
+ "additional six characters expected to parse unicode surrogate pair.",
+ token,
+ current);
unsigned int surrogatePair;
if (*(current++) == '\\' && *(current++) == 'u') {
- if (this->decodeUnicodeEscapeSequence(token, current, end,
- surrogatePair)) {
- unicode =
- 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF);
+ if (decodeUnicodeEscapeSequence(token, current, end, surrogatePair)) {
+ unicode = 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF);
} else
return false;
} else
- return this->addError(
- "expecting another \\u token to begin the second half of "
- "a unicode surrogate pair",
- token, current);
+ return addError("expecting another \\u token to begin the second half of "
+ "a unicode surrogate pair",
+ token,
+ current);
}
return true;
}
-bool OurReader::decodeUnicodeEscapeSequence(Token& token, Location& current,
- Location end,
- unsigned int& ret_unicode)
-{
+bool OurReader::decodeUnicodeEscapeSequence(Token& token,
+ Location& current,
+ Location end,
+ unsigned int& ret_unicode) {
if (end - current < 4)
- return this->addError(
- "Bad unicode escape sequence in string: four digits expected.", token,
- current);
+ return addError(
+ "Bad unicode escape sequence in string: four digits expected.",
+ token,
+ current);
int unicode = 0;
for (int index = 0; index < 4; ++index) {
Char c = *current++;
@@ -1869,65 +1773,60 @@ bool OurReader::decodeUnicodeEscapeSequence(Token& token, Location& current,
else if (c >= 'A' && c <= 'F')
unicode += c - 'A' + 10;
else
- return this->addError(
- "Bad unicode escape sequence in string: hexadecimal digit expected.",
- token, current);
+ return addError(
+ "Bad unicode escape sequence in string: hexadecimal digit expected.",
+ token,
+ current);
}
ret_unicode = static_cast<unsigned int>(unicode);
return true;
}
-bool OurReader::addError(const JSONCPP_STRING& message, Token& token,
- Location extra)
-{
+bool
+OurReader::addError(const JSONCPP_STRING& message, Token& token, Location extra) {
ErrorInfo info;
info.token_ = token;
info.message_ = message;
info.extra_ = extra;
- this->errors_.push_back(info);
+ errors_.push_back(info);
return false;
}
-bool OurReader::recoverFromError(TokenType skipUntilToken)
-{
- size_t errorCount = this->errors_.size();
+bool OurReader::recoverFromError(TokenType skipUntilToken) {
+ size_t errorCount = errors_.size();
Token skip;
for (;;) {
- if (!this->readToken(skip))
- this->errors_.resize(errorCount); // discard errors caused by recovery
+ if (!readToken(skip))
+ errors_.resize(errorCount); // discard errors caused by recovery
if (skip.type_ == skipUntilToken || skip.type_ == tokenEndOfStream)
break;
}
- this->errors_.resize(errorCount);
+ errors_.resize(errorCount);
return false;
}
-bool OurReader::addErrorAndRecover(const JSONCPP_STRING& message, Token& token,
- TokenType skipUntilToken)
-{
- this->addError(message, token);
- return this->recoverFromError(skipUntilToken);
+bool OurReader::addErrorAndRecover(const JSONCPP_STRING& message,
+ Token& token,
+ TokenType skipUntilToken) {
+ addError(message, token);
+ return recoverFromError(skipUntilToken);
}
-Value& OurReader::currentValue()
-{
- return *(this->nodes_.top());
-}
+Value& OurReader::currentValue() { return *(nodes_.top()); }
-OurReader::Char OurReader::getNextChar()
-{
- if (this->current_ == this->end_)
+OurReader::Char OurReader::getNextChar() {
+ if (current_ == end_)
return 0;
- return *this->current_++;
+ return *current_++;
}
-void OurReader::getLocationLineAndColumn(Location location, int& line,
- int& column) const
-{
- Location current = this->begin_;
+void OurReader::getLocationLineAndColumn(Location location,
+ int& line,
+ int& column) const {
+ Location current = begin_;
Location lastLineStart = current;
line = 0;
- while (current < location && current != this->end_) {
+ while (current < location && current != end_) {
Char c = *current++;
if (c == '\r') {
if (*current == '\n')
@@ -1944,105 +1843,101 @@ void OurReader::getLocationLineAndColumn(Location location, int& line,
++line;
}
-JSONCPP_STRING OurReader::getLocationLineAndColumn(Location location) const
-{
+JSONCPP_STRING OurReader::getLocationLineAndColumn(Location location) const {
int line, column;
- this->getLocationLineAndColumn(location, line, column);
+ getLocationLineAndColumn(location, line, column);
char buffer[18 + 16 + 16 + 1];
snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
return buffer;
}
-JSONCPP_STRING OurReader::getFormattedErrorMessages() const
-{
+JSONCPP_STRING OurReader::getFormattedErrorMessages() const {
JSONCPP_STRING formattedMessage;
- for (Errors::const_iterator itError = this->errors_.begin();
- itError != this->errors_.end(); ++itError) {
+ for (Errors::const_iterator itError = errors_.begin();
+ itError != errors_.end();
+ ++itError) {
const ErrorInfo& error = *itError;
formattedMessage +=
- "* " + this->getLocationLineAndColumn(error.token_.start_) + "\n";
+ "* " + getLocationLineAndColumn(error.token_.start_) + "\n";
formattedMessage += " " + error.message_ + "\n";
if (error.extra_)
- formattedMessage += "See " +
- this->getLocationLineAndColumn(error.extra_) + " for detail.\n";
+ formattedMessage +=
+ "See " + getLocationLineAndColumn(error.extra_) + " for detail.\n";
}
return formattedMessage;
}
-std::vector<OurReader::StructuredError> OurReader::getStructuredErrors() const
-{
+std::vector<OurReader::StructuredError> OurReader::getStructuredErrors() const {
std::vector<OurReader::StructuredError> allErrors;
- for (Errors::const_iterator itError = this->errors_.begin();
- itError != this->errors_.end(); ++itError) {
+ for (Errors::const_iterator itError = errors_.begin();
+ itError != errors_.end();
+ ++itError) {
const ErrorInfo& error = *itError;
OurReader::StructuredError structured;
- structured.offset_start = error.token_.start_ - this->begin_;
- structured.offset_limit = error.token_.end_ - this->begin_;
+ structured.offset_start = error.token_.start_ - begin_;
+ structured.offset_limit = error.token_.end_ - begin_;
structured.message = error.message_;
allErrors.push_back(structured);
}
return allErrors;
}
-bool OurReader::pushError(const Value& value, const JSONCPP_STRING& message)
-{
- ptrdiff_t length = this->end_ - this->begin_;
- if (value.getOffsetStart() > length || value.getOffsetLimit() > length)
+bool OurReader::pushError(const Value& value, const JSONCPP_STRING& message) {
+ ptrdiff_t length = end_ - begin_;
+ if(value.getOffsetStart() > length
+ || value.getOffsetLimit() > length)
return false;
Token token;
token.type_ = tokenError;
- token.start_ = this->begin_ + value.getOffsetStart();
- token.end_ = this->end_ + value.getOffsetLimit();
+ token.start_ = begin_ + value.getOffsetStart();
+ token.end_ = end_ + value.getOffsetLimit();
ErrorInfo info;
info.token_ = token;
info.message_ = message;
info.extra_ = 0;
- this->errors_.push_back(info);
+ errors_.push_back(info);
return true;
}
-bool OurReader::pushError(const Value& value, const JSONCPP_STRING& message,
- const Value& extra)
-{
- ptrdiff_t length = this->end_ - this->begin_;
- if (value.getOffsetStart() > length || value.getOffsetLimit() > length ||
- extra.getOffsetLimit() > length)
+bool OurReader::pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra) {
+ ptrdiff_t length = end_ - begin_;
+ if(value.getOffsetStart() > length
+ || value.getOffsetLimit() > length
+ || extra.getOffsetLimit() > length)
return false;
Token token;
token.type_ = tokenError;
- token.start_ = this->begin_ + value.getOffsetStart();
- token.end_ = this->begin_ + value.getOffsetLimit();
+ token.start_ = begin_ + value.getOffsetStart();
+ token.end_ = begin_ + value.getOffsetLimit();
ErrorInfo info;
info.token_ = token;
info.message_ = message;
- info.extra_ = this->begin_ + extra.getOffsetStart();
- this->errors_.push_back(info);
+ info.extra_ = begin_ + extra.getOffsetStart();
+ errors_.push_back(info);
return true;
}
-bool OurReader::good() const
-{
- return !this->errors_.size();
+bool OurReader::good() const {
+ return !errors_.size();
}
-class OurCharReader : public CharReader
-{
+
+class OurCharReader : public CharReader {
bool const collectComments_;
OurReader reader_;
-
public:
- OurCharReader(bool collectComments, OurFeatures const& features)
- : collectComments_(collectComments)
- , reader_(features)
- {
- }
- bool parse(char const* beginDoc, char const* endDoc, Value* root,
- JSONCPP_STRING* errs) JSONCPP_OVERRIDE
- {
- bool ok =
- this->reader_.parse(beginDoc, endDoc, *root, this->collectComments_);
+ OurCharReader(
+ bool collectComments,
+ OurFeatures const& features)
+ : collectComments_(collectComments)
+ , reader_(features)
+ {}
+ bool parse(
+ char const* beginDoc, char const* endDoc,
+ Value* root, JSONCPP_STRING* errs) JSONCPP_OVERRIDE {
+ bool ok = reader_.parse(beginDoc, endDoc, *root, collectComments_);
if (errs) {
- *errs = this->reader_.getFormattedErrorMessages();
+ *errs = reader_.getFormattedErrorMessages();
}
return ok;
}
@@ -2050,26 +1945,23 @@ public:
CharReaderBuilder::CharReaderBuilder()
{
- setDefaults(&this->settings_);
+ setDefaults(&settings_);
}
CharReaderBuilder::~CharReaderBuilder()
-{
-}
+{}
CharReader* CharReaderBuilder::newCharReader() const
{
- bool collectComments = this->settings_["collectComments"].asBool();
+ bool collectComments = settings_["collectComments"].asBool();
OurFeatures features = OurFeatures::all();
- features.allowComments_ = this->settings_["allowComments"].asBool();
- features.strictRoot_ = this->settings_["strictRoot"].asBool();
- features.allowDroppedNullPlaceholders_ =
- this->settings_["allowDroppedNullPlaceholders"].asBool();
- features.allowNumericKeys_ = this->settings_["allowNumericKeys"].asBool();
- features.allowSingleQuotes_ = this->settings_["allowSingleQuotes"].asBool();
- features.stackLimit_ = this->settings_["stackLimit"].asInt();
- features.failIfExtra_ = this->settings_["failIfExtra"].asBool();
- features.rejectDupKeys_ = this->settings_["rejectDupKeys"].asBool();
- features.allowSpecialFloats_ =
- this->settings_["allowSpecialFloats"].asBool();
+ features.allowComments_ = settings_["allowComments"].asBool();
+ features.strictRoot_ = settings_["strictRoot"].asBool();
+ features.allowDroppedNullPlaceholders_ = settings_["allowDroppedNullPlaceholders"].asBool();
+ features.allowNumericKeys_ = settings_["allowNumericKeys"].asBool();
+ features.allowSingleQuotes_ = settings_["allowSingleQuotes"].asBool();
+ features.stackLimit_ = settings_["stackLimit"].asInt();
+ features.failIfExtra_ = settings_["failIfExtra"].asBool();
+ features.rejectDupKeys_ = settings_["rejectDupKeys"].asBool();
+ features.allowSpecialFloats_ = settings_["allowSpecialFloats"].asBool();
return new OurCharReader(collectComments, features);
}
static void getValidReaderKeys(std::set<JSONCPP_STRING>* valid_keys)
@@ -2089,29 +1981,28 @@ static void getValidReaderKeys(std::set<JSONCPP_STRING>* valid_keys)
bool CharReaderBuilder::validate(Json::Value* invalid) const
{
Json::Value my_invalid;
- if (!invalid)
- invalid = &my_invalid; // so we do not need to test for NULL
+ if (!invalid) invalid = &my_invalid; // so we do not need to test for NULL
Json::Value& inv = *invalid;
std::set<JSONCPP_STRING> valid_keys;
getValidReaderKeys(&valid_keys);
- Value::Members keys = this->settings_.getMemberNames();
+ Value::Members keys = settings_.getMemberNames();
size_t n = keys.size();
for (size_t i = 0; i < n; ++i) {
JSONCPP_STRING const& key = keys[i];
if (valid_keys.find(key) == valid_keys.end()) {
- inv[key] = this->settings_[key];
+ inv[key] = settings_[key];
}
}
return 0u == inv.size();
}
Value& CharReaderBuilder::operator[](JSONCPP_STRING key)
{
- return this->settings_[key];
+ return settings_[key];
}
// static
void CharReaderBuilder::strictMode(Json::Value* settings)
{
- //! [CharReaderBuilderStrictMode]
+//! [CharReaderBuilderStrictMode]
(*settings)["allowComments"] = false;
(*settings)["strictRoot"] = true;
(*settings)["allowDroppedNullPlaceholders"] = false;
@@ -2121,12 +2012,12 @@ void CharReaderBuilder::strictMode(Json::Value* settings)
(*settings)["failIfExtra"] = true;
(*settings)["rejectDupKeys"] = true;
(*settings)["allowSpecialFloats"] = false;
- //! [CharReaderBuilderStrictMode]
+//! [CharReaderBuilderStrictMode]
}
// static
void CharReaderBuilder::setDefaults(Json::Value* settings)
{
- //! [CharReaderBuilderDefaults]
+//! [CharReaderBuilderDefaults]
(*settings)["collectComments"] = true;
(*settings)["allowComments"] = true;
(*settings)["strictRoot"] = false;
@@ -2137,14 +2028,15 @@ void CharReaderBuilder::setDefaults(Json::Value* settings)
(*settings)["failIfExtra"] = false;
(*settings)["rejectDupKeys"] = false;
(*settings)["allowSpecialFloats"] = false;
- //! [CharReaderBuilderDefaults]
+//! [CharReaderBuilderDefaults]
}
//////////////////////////////////
// global functions
-bool parseFromStream(CharReader::Factory const& fact, JSONCPP_ISTREAM& sin,
- Value* root, JSONCPP_STRING* errs)
+bool parseFromStream(
+ CharReader::Factory const& fact, JSONCPP_ISTREAM& sin,
+ Value* root, JSONCPP_STRING* errs)
{
JSONCPP_OSTRINGSTREAM ssin;
ssin << sin.rdbuf();
@@ -2156,13 +2048,14 @@ bool parseFromStream(CharReader::Factory const& fact, JSONCPP_ISTREAM& sin,
return reader->parse(begin, end, root, errs);
}
-JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM& sin, Value& root)
-{
+JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM& sin, Value& root) {
CharReaderBuilder b;
JSONCPP_STRING errs;
bool ok = parseFromStream(b, sin, &root, &errs);
if (!ok) {
- fprintf(stderr, "Error from reader: %s", errs.c_str());
+ fprintf(stderr,
+ "Error from reader: %s",
+ errs.c_str());
throwRuntimeError(errs);
}
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_value.cpp b/Utilities/cmjsoncpp/src/lib_json/json_value.cpp
index eadb1c3..f271e57 100644
--- a/Utilities/cmjsoncpp/src/lib_json/json_value.cpp
+++ b/Utilities/cmjsoncpp/src/lib_json/json_value.cpp
@@ -1,25 +1,23 @@
// Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at
-// http://jsoncpp.sourceforge.net/LICENSE
+// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#if !defined(JSON_IS_AMALGAMATION)
-# include <json/assertions.h>
-# include <json/value.h>
-# include <json/writer.h>
+#include <json/assertions.h>
+#include <json/value.h>
+#include <json/writer.h>
#endif // if !defined(JSON_IS_AMALGAMATION)
+#include <math.h>
#include <sstream>
#include <utility>
-
-#include <assert.h>
-#include <math.h>
#include <string.h>
+#include <assert.h>
#ifdef JSON_USE_CPPTL
-# include <cpptl/conststring.h>
+#include <cpptl/conststring.h>
#endif
+#include <cstddef> // size_t
#include <algorithm> // min()
-#include <cstddef> // size_t
#define JSON_ASSERT_UNREACHABLE assert(false)
@@ -29,24 +27,24 @@ namespace Json {
// kNull must be word-aligned to avoid crashing on ARM. We use an alignment of
// 8 (instead of 4) as a bit of future-proofing.
#if defined(__ARMEL__)
-# define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
+#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
#else
-# define ALIGNAS(byte_alignment)
+#define ALIGNAS(byte_alignment)
#endif
-// static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
-// const unsigned char& kNullRef = kNull[0];
-// const Value& Value::null = reinterpret_cast<const Value&>(kNullRef);
-// const Value& Value::nullRef = null;
+//static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
+//const unsigned char& kNullRef = kNull[0];
+//const Value& Value::null = reinterpret_cast<const Value&>(kNullRef);
+//const Value& Value::nullRef = null;
// static
Value const& Value::nullSingleton()
{
- static Value const nullStatic;
- return nullStatic;
+ static Value const nullStatic;
+ return nullStatic;
}
-// for backwards compatibility, we'll leave these global references around, but
-// DO NOT use them in JSONCPP library code any more!
+// for backwards compatibility, we'll leave these global references around, but DO NOT
+// use them in JSONCPP library code any more!
Value const& Value::null = Value::nullSingleton();
Value const& Value::nullRef = Value::nullSingleton();
@@ -68,29 +66,23 @@ const LargestUInt Value::maxLargestUInt = LargestUInt(-1);
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
template <typename T, typename U>
-static inline bool InRange(double d, T min, U max)
-{
+static inline bool InRange(double d, T min, U max) {
// The casts can lose precision, but we are looking only for
// an approximate range. Might fail on edge cases though. ~cdunn
- // return d >= static_cast<double>(min) && d <= static_cast<double>(max);
+ //return d >= static_cast<double>(min) && d <= static_cast<double>(max);
return d >= min && d <= max;
}
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-static inline double integerToDouble(Json::UInt64 value)
-{
- return static_cast<double>(Int64(value / 2)) * 2.0 +
- static_cast<double>(Int64(value & 1));
+static inline double integerToDouble(Json::UInt64 value) {
+ return static_cast<double>(Int64(value / 2)) * 2.0 + static_cast<double>(Int64(value & 1));
}
-template <typename T>
-static inline double integerToDouble(T value)
-{
+template <typename T> static inline double integerToDouble(T value) {
return static_cast<double>(value);
}
template <typename T, typename U>
-static inline bool InRange(double d, T min, U max)
-{
+static inline bool InRange(double d, T min, U max) {
return d >= integerToDouble(min) && d <= integerToDouble(max);
}
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
@@ -102,7 +94,8 @@ static inline bool InRange(double d, T min, U max)
* computed using strlen(value).
* @return Pointer on the duplicate instance of string.
*/
-static inline char* duplicateStringValue(const char* value, size_t length)
+static inline char* duplicateStringValue(const char* value,
+ size_t length)
{
// Avoid an integer overflow in the call to malloc below by limiting length
// to a sane value.
@@ -111,8 +104,9 @@ static inline char* duplicateStringValue(const char* value, size_t length)
char* newString = static_cast<char*>(malloc(length + 1));
if (newString == NULL) {
- throwRuntimeError("in Json::Value::duplicateStringValue(): "
- "Failed to allocate string value buffer");
+ throwRuntimeError(
+ "in Json::Value::duplicateStringValue(): "
+ "Failed to allocate string value buffer");
}
memcpy(newString, value, length);
newString[length] = 0;
@@ -121,30 +115,30 @@ static inline char* duplicateStringValue(const char* value, size_t length)
/* Record the length as a prefix.
*/
-static inline char* duplicateAndPrefixStringValue(const char* value,
- unsigned int length)
+static inline char* duplicateAndPrefixStringValue(
+ const char* value,
+ unsigned int length)
{
// Avoid an integer overflow in the call to malloc below by limiting length
// to a sane value.
- JSON_ASSERT_MESSAGE(length <= static_cast<unsigned>(Value::maxInt) -
- sizeof(unsigned) - 1U,
+ JSON_ASSERT_MESSAGE(length <= static_cast<unsigned>(Value::maxInt) - sizeof(unsigned) - 1U,
"in Json::Value::duplicateAndPrefixStringValue(): "
"length too big for prefixing");
- unsigned actualLength =
- length + static_cast<unsigned>(sizeof(unsigned)) + 1U;
+ unsigned actualLength = length + static_cast<unsigned>(sizeof(unsigned)) + 1U;
char* newString = static_cast<char*>(malloc(actualLength));
if (newString == 0) {
- throwRuntimeError("in Json::Value::duplicateAndPrefixStringValue(): "
- "Failed to allocate string value buffer");
+ throwRuntimeError(
+ "in Json::Value::duplicateAndPrefixStringValue(): "
+ "Failed to allocate string value buffer");
}
*reinterpret_cast<unsigned*>(newString) = length;
memcpy(newString + sizeof(unsigned), value, length);
- newString[actualLength - 1U] =
- 0; // to avoid buffer over-run accidents by users later
+ newString[actualLength - 1U] = 0; // to avoid buffer over-run accidents by users later
return newString;
}
-inline static void decodePrefixedString(bool isPrefixed, char const* prefixed,
- unsigned* length, char const** value)
+inline static void decodePrefixedString(
+ bool isPrefixed, char const* prefixed,
+ unsigned* length, char const** value)
{
if (!isPrefixed) {
*length = static_cast<unsigned>(strlen(prefixed));
@@ -154,12 +148,10 @@ inline static void decodePrefixedString(bool isPrefixed, char const* prefixed,
*value = prefixed + sizeof(unsigned);
}
}
-/** Free the string duplicated by
- * duplicateStringValue()/duplicateAndPrefixStringValue().
+/** Free the string duplicated by duplicateStringValue()/duplicateAndPrefixStringValue().
*/
#if JSONCPP_USING_SECURE_MEMORY
-static inline void releasePrefixedStringValue(char* value)
-{
+static inline void releasePrefixedStringValue(char* value) {
unsigned length = 0;
char const* valueDecoded;
decodePrefixedString(true, value, &length, &valueDecoded);
@@ -167,20 +159,17 @@ static inline void releasePrefixedStringValue(char* value)
memset(value, 0, size);
free(value);
}
-static inline void releaseStringValue(char* value, unsigned length)
-{
+static inline void releaseStringValue(char* value, unsigned length) {
// length==0 => we allocated the strings memory
- size_t size = (length == 0) ? strlen(value) : length;
+ size_t size = (length==0) ? strlen(value) : length;
memset(value, 0, size);
free(value);
}
-#else // !JSONCPP_USING_SECURE_MEMORY
-static inline void releasePrefixedStringValue(char* value)
-{
+#else // !JSONCPP_USING_SECURE_MEMORY
+static inline void releasePrefixedStringValue(char* value) {
free(value);
}
-static inline void releaseStringValue(char* value, unsigned)
-{
+static inline void releaseStringValue(char* value, unsigned) {
free(value);
}
#endif // JSONCPP_USING_SECURE_MEMORY
@@ -196,30 +185,26 @@ static inline void releaseStringValue(char* value, unsigned)
// //////////////////////////////////////////////////////////////////
#if !defined(JSON_IS_AMALGAMATION)
-# include "json_valueiterator.inl"
+#include "json_valueiterator.inl"
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
Exception::Exception(JSONCPP_STRING const& msg)
: msg_(msg)
-{
-}
+{}
Exception::~Exception() JSONCPP_NOEXCEPT
-{
-}
+{}
char const* Exception::what() const JSONCPP_NOEXCEPT
{
- return this->msg_.c_str();
+ return msg_.c_str();
}
RuntimeError::RuntimeError(JSONCPP_STRING const& msg)
: Exception(msg)
-{
-}
+{}
LogicError::LogicError(JSONCPP_STRING const& msg)
: Exception(msg)
-{
-}
+{}
JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg)
{
throw RuntimeError(msg);
@@ -237,29 +222,25 @@ JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg)
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
-Value::CommentInfo::CommentInfo()
- : comment_(0)
-{
-}
+Value::CommentInfo::CommentInfo() : comment_(0)
+{}
-Value::CommentInfo::~CommentInfo()
-{
- if (this->comment_)
- releaseStringValue(this->comment_, 0u);
+Value::CommentInfo::~CommentInfo() {
+ if (comment_)
+ releaseStringValue(comment_, 0u);
}
-void Value::CommentInfo::setComment(const char* text, size_t len)
-{
- if (this->comment_) {
- releaseStringValue(this->comment_, 0u);
- this->comment_ = 0;
+void Value::CommentInfo::setComment(const char* text, size_t len) {
+ if (comment_) {
+ releaseStringValue(comment_, 0u);
+ comment_ = 0;
}
JSON_ASSERT(text != 0);
JSON_ASSERT_MESSAGE(
- text[0] == '\0' || text[0] == '/',
- "in Json::Value::setComment(): Comments must start with /");
+ text[0] == '\0' || text[0] == '/',
+ "in Json::Value::setComment(): Comments must start with /");
// It seems that /**/ style comments are acceptable as well.
- this->comment_ = duplicateStringValue(text, len);
+ comment_ = duplicateStringValue(text, len);
}
// //////////////////////////////////////////////////////////////////
@@ -273,130 +254,91 @@ void Value::CommentInfo::setComment(const char* text, size_t len)
// Notes: policy_ indicates if the string was allocated when
// a string is stored.
-Value::CZString::CZString(ArrayIndex aindex)
- : cstr_(0)
- , index_(aindex)
-{
-}
+Value::CZString::CZString(ArrayIndex aindex) : cstr_(0), index_(aindex) {}
-Value::CZString::CZString(char const* str, unsigned ulength,
- DuplicationPolicy allocate)
- : cstr_(str)
-{
+Value::CZString::CZString(char const* str, unsigned ulength, DuplicationPolicy allocate)
+ : cstr_(str) {
// allocate != duplicate
- this->storage_.policy_ = allocate & 0x3;
- this->storage_.length_ = ulength & 0x3FFFFFFF;
+ storage_.policy_ = allocate & 0x3;
+ storage_.length_ = ulength & 0x3FFFFFFF;
}
-Value::CZString::CZString(const CZString& other)
-{
- this->cstr_ = (other.storage_.policy_ != noDuplication && other.cstr_ != 0
- ? duplicateStringValue(other.cstr_, other.storage_.length_)
- : other.cstr_);
- this->storage_.policy_ =
- static_cast<unsigned>(
- other.cstr_ ? (static_cast<DuplicationPolicy>(other.storage_.policy_) ==
- noDuplication
- ? noDuplication
- : duplicate)
- : static_cast<DuplicationPolicy>(other.storage_.policy_)) &
- 3U;
- this->storage_.length_ = other.storage_.length_;
+Value::CZString::CZString(const CZString& other) {
+ cstr_ = (other.storage_.policy_ != noDuplication && other.cstr_ != 0
+ ? duplicateStringValue(other.cstr_, other.storage_.length_)
+ : other.cstr_);
+ storage_.policy_ = static_cast<unsigned>(other.cstr_
+ ? (static_cast<DuplicationPolicy>(other.storage_.policy_) == noDuplication
+ ? noDuplication : duplicate)
+ : static_cast<DuplicationPolicy>(other.storage_.policy_)) & 3U;
+ storage_.length_ = other.storage_.length_;
}
#if JSON_HAS_RVALUE_REFERENCES
Value::CZString::CZString(CZString&& other)
- : cstr_(other.cstr_)
- , index_(other.index_)
-{
+ : cstr_(other.cstr_), index_(other.index_) {
other.cstr_ = nullptr;
}
#endif
-Value::CZString::~CZString()
-{
- if (this->cstr_ && this->storage_.policy_ == duplicate) {
- releaseStringValue(const_cast<char*>(this->cstr_),
- this->storage_.length_ +
- 1u); //+1 for null terminating character for sake of
- //completeness but not actually necessary
+Value::CZString::~CZString() {
+ if (cstr_ && storage_.policy_ == duplicate) {
+ releaseStringValue(const_cast<char*>(cstr_), storage_.length_ + 1u); //+1 for null terminating character for sake of completeness but not actually necessary
}
}
-void Value::CZString::swap(CZString& other)
-{
- std::swap(this->cstr_, other.cstr_);
- std::swap(this->index_, other.index_);
+void Value::CZString::swap(CZString& other) {
+ std::swap(cstr_, other.cstr_);
+ std::swap(index_, other.index_);
}
-Value::CZString& Value::CZString::operator=(const CZString& other)
-{
- this->cstr_ = other.cstr_;
- this->index_ = other.index_;
+Value::CZString& Value::CZString::operator=(const CZString& other) {
+ cstr_ = other.cstr_;
+ index_ = other.index_;
return *this;
}
#if JSON_HAS_RVALUE_REFERENCES
-Value::CZString& Value::CZString::operator=(CZString&& other)
-{
- this->cstr_ = other.cstr_;
- this->index_ = other.index_;
+Value::CZString& Value::CZString::operator=(CZString&& other) {
+ cstr_ = other.cstr_;
+ index_ = other.index_;
other.cstr_ = nullptr;
return *this;
}
#endif
-bool Value::CZString::operator<(const CZString& other) const
-{
- if (!this->cstr_)
- return this->index_ < other.index_;
- // return strcmp(cstr_, other.cstr_) < 0;
+bool Value::CZString::operator<(const CZString& other) const {
+ if (!cstr_) return index_ < other.index_;
+ //return strcmp(cstr_, other.cstr_) < 0;
// Assume both are strings.
unsigned this_len = this->storage_.length_;
unsigned other_len = other.storage_.length_;
unsigned min_len = std::min<unsigned>(this_len, other_len);
JSON_ASSERT(this->cstr_ && other.cstr_);
int comp = memcmp(this->cstr_, other.cstr_, min_len);
- if (comp < 0)
- return true;
- if (comp > 0)
- return false;
+ if (comp < 0) return true;
+ if (comp > 0) return false;
return (this_len < other_len);
}
-bool Value::CZString::operator==(const CZString& other) const
-{
- if (!this->cstr_)
- return this->index_ == other.index_;
- // return strcmp(cstr_, other.cstr_) == 0;
+bool Value::CZString::operator==(const CZString& other) const {
+ if (!cstr_) return index_ == other.index_;
+ //return strcmp(cstr_, other.cstr_) == 0;
// Assume both are strings.
unsigned this_len = this->storage_.length_;
unsigned other_len = other.storage_.length_;
- if (this_len != other_len)
- return false;
+ if (this_len != other_len) return false;
JSON_ASSERT(this->cstr_ && other.cstr_);
int comp = memcmp(this->cstr_, other.cstr_, this_len);
return comp == 0;
}
-ArrayIndex Value::CZString::index() const
-{
- return this->index_;
-}
+ArrayIndex Value::CZString::index() const { return index_; }
-// const char* Value::CZString::c_str() const { return cstr_; }
-const char* Value::CZString::data() const
-{
- return this->cstr_;
-}
-unsigned Value::CZString::length() const
-{
- return this->storage_.length_;
-}
-bool Value::CZString::isStaticString() const
-{
- return this->storage_.policy_ == noDuplication;
-}
+//const char* Value::CZString::c_str() const { return cstr_; }
+const char* Value::CZString::data() const { return cstr_; }
+unsigned Value::CZString::length() const { return storage_.length_; }
+bool Value::CZString::isStaticString() const { return storage_.policy_ == noDuplication; }
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
@@ -410,238 +352,210 @@ bool Value::CZString::isStaticString() const
* memset( this, 0, sizeof(Value) )
* This optimization is used in ValueInternalMap fast allocator.
*/
-Value::Value(ValueType vtype)
-{
+Value::Value(ValueType vtype) {
static char const emptyString[] = "";
- this->initBasic(vtype);
+ initBasic(vtype);
switch (vtype) {
- case nullValue:
- break;
- case intValue:
- case uintValue:
- this->value_.int_ = 0;
- break;
- case realValue:
- this->value_.real_ = 0.0;
- break;
- case stringValue:
- // allocated_ == false, so this is safe.
- this->value_.string_ =
- const_cast<char*>(static_cast<char const*>(emptyString));
- break;
- case arrayValue:
- case objectValue:
- this->value_.map_ = new ObjectValues();
- break;
- case booleanValue:
- this->value_.bool_ = false;
- break;
- default:
- JSON_ASSERT_UNREACHABLE;
+ case nullValue:
+ break;
+ case intValue:
+ case uintValue:
+ value_.int_ = 0;
+ break;
+ case realValue:
+ value_.real_ = 0.0;
+ break;
+ case stringValue:
+ // allocated_ == false, so this is safe.
+ value_.string_ = const_cast<char*>(static_cast<char const*>(emptyString));
+ break;
+ case arrayValue:
+ case objectValue:
+ value_.map_ = new ObjectValues();
+ break;
+ case booleanValue:
+ value_.bool_ = false;
+ break;
+ default:
+ JSON_ASSERT_UNREACHABLE;
}
}
-Value::Value(Int value)
-{
- this->initBasic(intValue);
- this->value_.int_ = value;
+Value::Value(Int value) {
+ initBasic(intValue);
+ value_.int_ = value;
}
-Value::Value(UInt value)
-{
- this->initBasic(uintValue);
- this->value_.uint_ = value;
+Value::Value(UInt value) {
+ initBasic(uintValue);
+ value_.uint_ = value;
}
#if defined(JSON_HAS_INT64)
-Value::Value(Int64 value)
-{
- this->initBasic(intValue);
- this->value_.int_ = value;
+Value::Value(Int64 value) {
+ initBasic(intValue);
+ value_.int_ = value;
}
-Value::Value(UInt64 value)
-{
- this->initBasic(uintValue);
- this->value_.uint_ = value;
+Value::Value(UInt64 value) {
+ initBasic(uintValue);
+ value_.uint_ = value;
}
#endif // defined(JSON_HAS_INT64)
-Value::Value(double value)
-{
- this->initBasic(realValue);
- this->value_.real_ = value;
+Value::Value(double value) {
+ initBasic(realValue);
+ value_.real_ = value;
}
-Value::Value(const char* value)
-{
- this->initBasic(stringValue, true);
+Value::Value(const char* value) {
+ initBasic(stringValue, true);
JSON_ASSERT_MESSAGE(value != NULL, "Null Value Passed to Value Constructor");
- this->value_.string_ =
- duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));
+ value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));
}
-Value::Value(const char* beginValue, const char* endValue)
-{
- this->initBasic(stringValue, true);
- this->value_.string_ = duplicateAndPrefixStringValue(
- beginValue, static_cast<unsigned>(endValue - beginValue));
+Value::Value(const char* beginValue, const char* endValue) {
+ initBasic(stringValue, true);
+ value_.string_ =
+ duplicateAndPrefixStringValue(beginValue, static_cast<unsigned>(endValue - beginValue));
}
-Value::Value(const JSONCPP_STRING& value)
-{
- this->initBasic(stringValue, true);
- this->value_.string_ = duplicateAndPrefixStringValue(
- value.data(), static_cast<unsigned>(value.length()));
+Value::Value(const JSONCPP_STRING& value) {
+ initBasic(stringValue, true);
+ value_.string_ =
+ duplicateAndPrefixStringValue(value.data(), static_cast<unsigned>(value.length()));
}
-Value::Value(const StaticString& value)
-{
- this->initBasic(stringValue);
- this->value_.string_ = const_cast<char*>(value.c_str());
+Value::Value(const StaticString& value) {
+ initBasic(stringValue);
+ value_.string_ = const_cast<char*>(value.c_str());
}
#ifdef JSON_USE_CPPTL
-Value::Value(const CppTL::ConstString& value)
-{
+Value::Value(const CppTL::ConstString& value) {
initBasic(stringValue, true);
- value_.string_ = duplicateAndPrefixStringValue(
- value, static_cast<unsigned>(value.length()));
+ value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(value.length()));
}
#endif
-Value::Value(bool value)
-{
- this->initBasic(booleanValue);
- this->value_.bool_ = value;
+Value::Value(bool value) {
+ initBasic(booleanValue);
+ value_.bool_ = value;
}
Value::Value(Value const& other)
- : type_(other.type_)
- , allocated_(false)
- , comments_(0)
- , start_(other.start_)
- , limit_(other.limit_)
-{
- switch (this->type_) {
- case nullValue:
- case intValue:
- case uintValue:
- case realValue:
- case booleanValue:
- this->value_ = other.value_;
- break;
- case stringValue:
- if (other.value_.string_ && other.allocated_) {
- unsigned len;
- char const* str;
- decodePrefixedString(other.allocated_, other.value_.string_, &len,
- &str);
- this->value_.string_ = duplicateAndPrefixStringValue(str, len);
- this->allocated_ = true;
- } else {
- this->value_.string_ = other.value_.string_;
- this->allocated_ = false;
- }
- break;
- case arrayValue:
- case objectValue:
- this->value_.map_ = new ObjectValues(*other.value_.map_);
- break;
- default:
- JSON_ASSERT_UNREACHABLE;
+ : type_(other.type_), allocated_(false)
+ ,
+ comments_(0), start_(other.start_), limit_(other.limit_)
+{
+ switch (type_) {
+ case nullValue:
+ case intValue:
+ case uintValue:
+ case realValue:
+ case booleanValue:
+ value_ = other.value_;
+ break;
+ case stringValue:
+ if (other.value_.string_ && other.allocated_) {
+ unsigned len;
+ char const* str;
+ decodePrefixedString(other.allocated_, other.value_.string_,
+ &len, &str);
+ value_.string_ = duplicateAndPrefixStringValue(str, len);
+ allocated_ = true;
+ } else {
+ value_.string_ = other.value_.string_;
+ allocated_ = false;
+ }
+ break;
+ case arrayValue:
+ case objectValue:
+ value_.map_ = new ObjectValues(*other.value_.map_);
+ break;
+ default:
+ JSON_ASSERT_UNREACHABLE;
}
if (other.comments_) {
- this->comments_ = new CommentInfo[numberOfCommentPlacement];
+ comments_ = new CommentInfo[numberOfCommentPlacement];
for (int comment = 0; comment < numberOfCommentPlacement; ++comment) {
const CommentInfo& otherComment = other.comments_[comment];
if (otherComment.comment_)
- this->comments_[comment].setComment(otherComment.comment_,
- strlen(otherComment.comment_));
+ comments_[comment].setComment(
+ otherComment.comment_, strlen(otherComment.comment_));
}
}
}
#if JSON_HAS_RVALUE_REFERENCES
// Move constructor
-Value::Value(Value&& other)
-{
- this->initBasic(nullValue);
- this->swap(other);
+Value::Value(Value&& other) {
+ initBasic(nullValue);
+ swap(other);
}
#endif
-Value::~Value()
-{
- switch (this->type_) {
- case nullValue:
- case intValue:
- case uintValue:
- case realValue:
- case booleanValue:
- break;
- case stringValue:
- if (this->allocated_)
- releasePrefixedStringValue(this->value_.string_);
- break;
- case arrayValue:
- case objectValue:
- delete this->value_.map_;
- break;
- default:
- JSON_ASSERT_UNREACHABLE;
+Value::~Value() {
+ switch (type_) {
+ case nullValue:
+ case intValue:
+ case uintValue:
+ case realValue:
+ case booleanValue:
+ break;
+ case stringValue:
+ if (allocated_)
+ releasePrefixedStringValue(value_.string_);
+ break;
+ case arrayValue:
+ case objectValue:
+ delete value_.map_;
+ break;
+ default:
+ JSON_ASSERT_UNREACHABLE;
}
- delete[] this->comments_;
+ delete[] comments_;
- this->value_.uint_ = 0;
+ value_.uint_ = 0;
}
-Value& Value::operator=(Value other)
-{
- this->swap(other);
+Value& Value::operator=(Value other) {
+ swap(other);
return *this;
}
-void Value::swapPayload(Value& other)
-{
- ValueType temp = this->type_;
- this->type_ = other.type_;
+void Value::swapPayload(Value& other) {
+ ValueType temp = type_;
+ type_ = other.type_;
other.type_ = temp;
- std::swap(this->value_, other.value_);
- int temp2 = this->allocated_;
- this->allocated_ = other.allocated_;
+ std::swap(value_, other.value_);
+ int temp2 = allocated_;
+ allocated_ = other.allocated_;
other.allocated_ = temp2 & 0x1;
}
-void Value::copyPayload(const Value& other)
-{
- this->type_ = other.type_;
- this->value_ = other.value_;
- this->allocated_ = other.allocated_;
+void Value::copyPayload(const Value& other) {
+ type_ = other.type_;
+ value_ = other.value_;
+ allocated_ = other.allocated_;
}
-void Value::swap(Value& other)
-{
- this->swapPayload(other);
- std::swap(this->comments_, other.comments_);
- std::swap(this->start_, other.start_);
- std::swap(this->limit_, other.limit_);
+void Value::swap(Value& other) {
+ swapPayload(other);
+ std::swap(comments_, other.comments_);
+ std::swap(start_, other.start_);
+ std::swap(limit_, other.limit_);
}
-void Value::copy(const Value& other)
-{
- this->copyPayload(other);
- this->comments_ = other.comments_;
- this->start_ = other.start_;
- this->limit_ = other.limit_;
+void Value::copy(const Value& other) {
+ copyPayload(other);
+ comments_ = other.comments_;
+ start_ = other.start_;
+ limit_ = other.limit_;
}
-ValueType Value::type() const
-{
- return this->type_;
-}
+ValueType Value::type() const { return type_; }
-int Value::compare(const Value& other) const
-{
+int Value::compare(const Value& other) const {
if (*this < other)
return -1;
if (*this > other)
@@ -649,568 +563,509 @@ int Value::compare(const Value& other) const
return 0;
}
-bool Value::operator<(const Value& other) const
-{
- int typeDelta = this->type_ - other.type_;
+bool Value::operator<(const Value& other) const {
+ int typeDelta = type_ - other.type_;
if (typeDelta)
return typeDelta < 0 ? true : false;
- switch (this->type_) {
- case nullValue:
- return false;
- case intValue:
- return this->value_.int_ < other.value_.int_;
- case uintValue:
- return this->value_.uint_ < other.value_.uint_;
- case realValue:
- return this->value_.real_ < other.value_.real_;
- case booleanValue:
- return this->value_.bool_ < other.value_.bool_;
- case stringValue: {
- if ((this->value_.string_ == 0) || (other.value_.string_ == 0)) {
- if (other.value_.string_)
- return true;
- else
- return false;
- }
- unsigned this_len;
- unsigned other_len;
- char const* this_str;
- char const* other_str;
- decodePrefixedString(this->allocated_, this->value_.string_, &this_len,
- &this_str);
- decodePrefixedString(other.allocated_, other.value_.string_, &other_len,
- &other_str);
- unsigned min_len = std::min<unsigned>(this_len, other_len);
- JSON_ASSERT(this_str && other_str);
- int comp = memcmp(this_str, other_str, min_len);
- if (comp < 0)
- return true;
- if (comp > 0)
- return false;
- return (this_len < other_len);
- }
- case arrayValue:
- case objectValue: {
- int delta = int(this->value_.map_->size() - other.value_.map_->size());
- if (delta)
- return delta < 0;
- return (*this->value_.map_) < (*other.value_.map_);
+ switch (type_) {
+ case nullValue:
+ return false;
+ case intValue:
+ return value_.int_ < other.value_.int_;
+ case uintValue:
+ return value_.uint_ < other.value_.uint_;
+ case realValue:
+ return value_.real_ < other.value_.real_;
+ case booleanValue:
+ return value_.bool_ < other.value_.bool_;
+ case stringValue:
+ {
+ if ((value_.string_ == 0) || (other.value_.string_ == 0)) {
+ if (other.value_.string_) return true;
+ else return false;
}
- default:
- JSON_ASSERT_UNREACHABLE;
+ unsigned this_len;
+ unsigned other_len;
+ char const* this_str;
+ char const* other_str;
+ decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
+ decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str);
+ unsigned min_len = std::min<unsigned>(this_len, other_len);
+ JSON_ASSERT(this_str && other_str);
+ int comp = memcmp(this_str, other_str, min_len);
+ if (comp < 0) return true;
+ if (comp > 0) return false;
+ return (this_len < other_len);
+ }
+ case arrayValue:
+ case objectValue: {
+ int delta = int(value_.map_->size() - other.value_.map_->size());
+ if (delta)
+ return delta < 0;
+ return (*value_.map_) < (*other.value_.map_);
+ }
+ default:
+ JSON_ASSERT_UNREACHABLE;
}
return false; // unreachable
}
-bool Value::operator<=(const Value& other) const
-{
- return !(other < *this);
-}
+bool Value::operator<=(const Value& other) const { return !(other < *this); }
-bool Value::operator>=(const Value& other) const
-{
- return !(*this < other);
-}
+bool Value::operator>=(const Value& other) const { return !(*this < other); }
-bool Value::operator>(const Value& other) const
-{
- return other < *this;
-}
+bool Value::operator>(const Value& other) const { return other < *this; }
-bool Value::operator==(const Value& other) const
-{
+bool Value::operator==(const Value& other) const {
// if ( type_ != other.type_ )
// GCC 2.95.3 says:
// attempt to take address of bit-field structure member `Json::Value::type_'
// Beats me, but a temp solves the problem.
int temp = other.type_;
- if (this->type_ != temp)
+ if (type_ != temp)
return false;
- switch (this->type_) {
- case nullValue:
- return true;
- case intValue:
- return this->value_.int_ == other.value_.int_;
- case uintValue:
- return this->value_.uint_ == other.value_.uint_;
- case realValue:
- return this->value_.real_ == other.value_.real_;
- case booleanValue:
- return this->value_.bool_ == other.value_.bool_;
- case stringValue: {
- if ((this->value_.string_ == 0) || (other.value_.string_ == 0)) {
- return (this->value_.string_ == other.value_.string_);
- }
- unsigned this_len;
- unsigned other_len;
- char const* this_str;
- char const* other_str;
- decodePrefixedString(this->allocated_, this->value_.string_, &this_len,
- &this_str);
- decodePrefixedString(other.allocated_, other.value_.string_, &other_len,
- &other_str);
- if (this_len != other_len)
- return false;
- JSON_ASSERT(this_str && other_str);
- int comp = memcmp(this_str, other_str, this_len);
- return comp == 0;
+ switch (type_) {
+ case nullValue:
+ return true;
+ case intValue:
+ return value_.int_ == other.value_.int_;
+ case uintValue:
+ return value_.uint_ == other.value_.uint_;
+ case realValue:
+ return value_.real_ == other.value_.real_;
+ case booleanValue:
+ return value_.bool_ == other.value_.bool_;
+ case stringValue:
+ {
+ if ((value_.string_ == 0) || (other.value_.string_ == 0)) {
+ return (value_.string_ == other.value_.string_);
}
- case arrayValue:
- case objectValue:
- return this->value_.map_->size() == other.value_.map_->size() &&
- (*this->value_.map_) == (*other.value_.map_);
- default:
- JSON_ASSERT_UNREACHABLE;
+ unsigned this_len;
+ unsigned other_len;
+ char const* this_str;
+ char const* other_str;
+ decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
+ decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str);
+ if (this_len != other_len) return false;
+ JSON_ASSERT(this_str && other_str);
+ int comp = memcmp(this_str, other_str, this_len);
+ return comp == 0;
+ }
+ case arrayValue:
+ case objectValue:
+ return value_.map_->size() == other.value_.map_->size() &&
+ (*value_.map_) == (*other.value_.map_);
+ default:
+ JSON_ASSERT_UNREACHABLE;
}
return false; // unreachable
}
-bool Value::operator!=(const Value& other) const
-{
- return !(*this == other);
-}
+bool Value::operator!=(const Value& other) const { return !(*this == other); }
-const char* Value::asCString() const
-{
+const char* Value::asCString() const {
JSON_ASSERT_MESSAGE(type_ == stringValue,
"in Json::Value::asCString(): requires stringValue");
- if (this->value_.string_ == 0)
- return 0;
+ if (value_.string_ == 0) return 0;
unsigned this_len;
char const* this_str;
- decodePrefixedString(this->allocated_, this->value_.string_, &this_len,
- &this_str);
+ decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
return this_str;
}
#if JSONCPP_USING_SECURE_MEMORY
-unsigned Value::getCStringLength() const
-{
+unsigned Value::getCStringLength() const {
JSON_ASSERT_MESSAGE(type_ == stringValue,
- "in Json::Value::asCString(): requires stringValue");
- if (value_.string_ == 0)
- return 0;
+ "in Json::Value::asCString(): requires stringValue");
+ if (value_.string_ == 0) return 0;
unsigned this_len;
char const* this_str;
- decodePrefixedString(this->allocated_, this->value_.string_, &this_len,
- &this_str);
+ decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
return this_len;
}
#endif
-bool Value::getString(char const** str, char const** cend) const
-{
- if (this->type_ != stringValue)
- return false;
- if (this->value_.string_ == 0)
- return false;
+bool Value::getString(char const** str, char const** cend) const {
+ if (type_ != stringValue) return false;
+ if (value_.string_ == 0) return false;
unsigned length;
decodePrefixedString(this->allocated_, this->value_.string_, &length, str);
*cend = *str + length;
return true;
}
-JSONCPP_STRING Value::asString() const
-{
- switch (this->type_) {
- case nullValue:
- return "";
- case stringValue: {
- if (this->value_.string_ == 0)
- return "";
- unsigned this_len;
- char const* this_str;
- decodePrefixedString(this->allocated_, this->value_.string_, &this_len,
- &this_str);
- return JSONCPP_STRING(this_str, this_len);
- }
- case booleanValue:
- return this->value_.bool_ ? "true" : "false";
- case intValue:
- return valueToString(this->value_.int_);
- case uintValue:
- return valueToString(this->value_.uint_);
- case realValue:
- return valueToString(this->value_.real_);
- default:
- JSON_FAIL_MESSAGE("Type is not convertible to string");
+JSONCPP_STRING Value::asString() const {
+ switch (type_) {
+ case nullValue:
+ return "";
+ case stringValue:
+ {
+ if (value_.string_ == 0) return "";
+ unsigned this_len;
+ char const* this_str;
+ decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
+ return JSONCPP_STRING(this_str, this_len);
+ }
+ case booleanValue:
+ return value_.bool_ ? "true" : "false";
+ case intValue:
+ return valueToString(value_.int_);
+ case uintValue:
+ return valueToString(value_.uint_);
+ case realValue:
+ return valueToString(value_.real_);
+ default:
+ JSON_FAIL_MESSAGE("Type is not convertible to string");
}
}
#ifdef JSON_USE_CPPTL
-CppTL::ConstString Value::asConstString() const
-{
+CppTL::ConstString Value::asConstString() const {
unsigned len;
char const* str;
- decodePrefixedString(allocated_, value_.string_, &len, &str);
+ decodePrefixedString(allocated_, value_.string_,
+ &len, &str);
return CppTL::ConstString(str, len);
}
#endif
-Value::Int Value::asInt() const
-{
- switch (this->type_) {
- case intValue:
- JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range");
- return Int(this->value_.int_);
- case uintValue:
- JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range");
- return Int(this->value_.uint_);
- case realValue:
- JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt),
- "double out of Int range");
- return Int(this->value_.real_);
- case nullValue:
- return 0;
- case booleanValue:
- return this->value_.bool_ ? 1 : 0;
- default:
- break;
+Value::Int Value::asInt() const {
+ switch (type_) {
+ case intValue:
+ JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range");
+ return Int(value_.int_);
+ case uintValue:
+ JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range");
+ return Int(value_.uint_);
+ case realValue:
+ JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt),
+ "double out of Int range");
+ return Int(value_.real_);
+ case nullValue:
+ return 0;
+ case booleanValue:
+ return value_.bool_ ? 1 : 0;
+ default:
+ break;
}
JSON_FAIL_MESSAGE("Value is not convertible to Int.");
}
-Value::UInt Value::asUInt() const
-{
- switch (this->type_) {
- case intValue:
- JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range");
- return UInt(this->value_.int_);
- case uintValue:
- JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range");
- return UInt(this->value_.uint_);
- case realValue:
- JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt),
- "double out of UInt range");
- return UInt(this->value_.real_);
- case nullValue:
- return 0;
- case booleanValue:
- return this->value_.bool_ ? 1 : 0;
- default:
- break;
+Value::UInt Value::asUInt() const {
+ switch (type_) {
+ case intValue:
+ JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range");
+ return UInt(value_.int_);
+ case uintValue:
+ JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range");
+ return UInt(value_.uint_);
+ case realValue:
+ JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt),
+ "double out of UInt range");
+ return UInt(value_.real_);
+ case nullValue:
+ return 0;
+ case booleanValue:
+ return value_.bool_ ? 1 : 0;
+ default:
+ break;
}
JSON_FAIL_MESSAGE("Value is not convertible to UInt.");
}
#if defined(JSON_HAS_INT64)
-Value::Int64 Value::asInt64() const
-{
- switch (this->type_) {
- case intValue:
- return Int64(this->value_.int_);
- case uintValue:
- JSON_ASSERT_MESSAGE(isInt64(), "LargestUInt out of Int64 range");
- return Int64(this->value_.uint_);
- case realValue:
- JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt64, maxInt64),
- "double out of Int64 range");
- return Int64(this->value_.real_);
- case nullValue:
- return 0;
- case booleanValue:
- return this->value_.bool_ ? 1 : 0;
- default:
- break;
+Value::Int64 Value::asInt64() const {
+ switch (type_) {
+ case intValue:
+ return Int64(value_.int_);
+ case uintValue:
+ JSON_ASSERT_MESSAGE(isInt64(), "LargestUInt out of Int64 range");
+ return Int64(value_.uint_);
+ case realValue:
+ JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt64, maxInt64),
+ "double out of Int64 range");
+ return Int64(value_.real_);
+ case nullValue:
+ return 0;
+ case booleanValue:
+ return value_.bool_ ? 1 : 0;
+ default:
+ break;
}
JSON_FAIL_MESSAGE("Value is not convertible to Int64.");
}
-Value::UInt64 Value::asUInt64() const
-{
- switch (this->type_) {
- case intValue:
- JSON_ASSERT_MESSAGE(isUInt64(), "LargestInt out of UInt64 range");
- return UInt64(this->value_.int_);
- case uintValue:
- return UInt64(this->value_.uint_);
- case realValue:
- JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt64),
- "double out of UInt64 range");
- return UInt64(this->value_.real_);
- case nullValue:
- return 0;
- case booleanValue:
- return this->value_.bool_ ? 1 : 0;
- default:
- break;
+Value::UInt64 Value::asUInt64() const {
+ switch (type_) {
+ case intValue:
+ JSON_ASSERT_MESSAGE(isUInt64(), "LargestInt out of UInt64 range");
+ return UInt64(value_.int_);
+ case uintValue:
+ return UInt64(value_.uint_);
+ case realValue:
+ JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt64),
+ "double out of UInt64 range");
+ return UInt64(value_.real_);
+ case nullValue:
+ return 0;
+ case booleanValue:
+ return value_.bool_ ? 1 : 0;
+ default:
+ break;
}
JSON_FAIL_MESSAGE("Value is not convertible to UInt64.");
}
#endif // if defined(JSON_HAS_INT64)
-LargestInt Value::asLargestInt() const
-{
+LargestInt Value::asLargestInt() const {
#if defined(JSON_NO_INT64)
return asInt();
#else
- return this->asInt64();
+ return asInt64();
#endif
}
-LargestUInt Value::asLargestUInt() const
-{
+LargestUInt Value::asLargestUInt() const {
#if defined(JSON_NO_INT64)
return asUInt();
#else
- return this->asUInt64();
+ return asUInt64();
#endif
}
-double Value::asDouble() const
-{
- switch (this->type_) {
- case intValue:
- return static_cast<double>(this->value_.int_);
- case uintValue:
+double Value::asDouble() const {
+ switch (type_) {
+ case intValue:
+ return static_cast<double>(value_.int_);
+ case uintValue:
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
- return static_cast<double>(this->value_.uint_);
+ return static_cast<double>(value_.uint_);
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
- return integerToDouble(value_.uint_);
+ return integerToDouble(value_.uint_);
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
- case realValue:
- return this->value_.real_;
- case nullValue:
- return 0.0;
- case booleanValue:
- return this->value_.bool_ ? 1.0 : 0.0;
- default:
- break;
+ case realValue:
+ return value_.real_;
+ case nullValue:
+ return 0.0;
+ case booleanValue:
+ return value_.bool_ ? 1.0 : 0.0;
+ default:
+ break;
}
JSON_FAIL_MESSAGE("Value is not convertible to double.");
}
-float Value::asFloat() const
-{
- switch (this->type_) {
- case intValue:
- return static_cast<float>(this->value_.int_);
- case uintValue:
+float Value::asFloat() const {
+ switch (type_) {
+ case intValue:
+ return static_cast<float>(value_.int_);
+ case uintValue:
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
- return static_cast<float>(this->value_.uint_);
+ return static_cast<float>(value_.uint_);
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
- // This can fail (silently?) if the value is bigger than MAX_FLOAT.
- return static_cast<float>(integerToDouble(value_.uint_));
+ // This can fail (silently?) if the value is bigger than MAX_FLOAT.
+ return static_cast<float>(integerToDouble(value_.uint_));
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
- case realValue:
- return static_cast<float>(this->value_.real_);
- case nullValue:
- return 0.0;
- case booleanValue:
- return this->value_.bool_ ? 1.0f : 0.0f;
- default:
- break;
+ case realValue:
+ return static_cast<float>(value_.real_);
+ case nullValue:
+ return 0.0;
+ case booleanValue:
+ return value_.bool_ ? 1.0f : 0.0f;
+ default:
+ break;
}
JSON_FAIL_MESSAGE("Value is not convertible to float.");
}
-bool Value::asBool() const
-{
- switch (this->type_) {
- case booleanValue:
- return this->value_.bool_;
- case nullValue:
- return false;
- case intValue:
- return this->value_.int_ ? true : false;
- case uintValue:
- return this->value_.uint_ ? true : false;
- case realValue:
- // This is kind of strange. Not recommended.
- return (this->value_.real_ != 0.0) ? true : false;
- default:
- break;
+bool Value::asBool() const {
+ switch (type_) {
+ case booleanValue:
+ return value_.bool_;
+ case nullValue:
+ return false;
+ case intValue:
+ return value_.int_ ? true : false;
+ case uintValue:
+ return value_.uint_ ? true : false;
+ case realValue:
+ // This is kind of strange. Not recommended.
+ return (value_.real_ != 0.0) ? true : false;
+ default:
+ break;
}
JSON_FAIL_MESSAGE("Value is not convertible to bool.");
}
-bool Value::isConvertibleTo(ValueType other) const
-{
+bool Value::isConvertibleTo(ValueType other) const {
switch (other) {
- case nullValue:
- return (this->isNumeric() && this->asDouble() == 0.0) ||
- (this->type_ == booleanValue && this->value_.bool_ == false) ||
- (this->type_ == stringValue && this->asString().empty()) ||
- (this->type_ == arrayValue && this->value_.map_->size() == 0) ||
- (this->type_ == objectValue && this->value_.map_->size() == 0) ||
- this->type_ == nullValue;
- case intValue:
- return this->isInt() ||
- (this->type_ == realValue &&
- InRange(this->value_.real_, minInt, maxInt)) ||
- this->type_ == booleanValue || this->type_ == nullValue;
- case uintValue:
- return this->isUInt() ||
- (this->type_ == realValue &&
- InRange(this->value_.real_, 0, maxUInt)) ||
- this->type_ == booleanValue || this->type_ == nullValue;
- case realValue:
- return this->isNumeric() || this->type_ == booleanValue ||
- this->type_ == nullValue;
- case booleanValue:
- return this->isNumeric() || this->type_ == booleanValue ||
- this->type_ == nullValue;
- case stringValue:
- return this->isNumeric() || this->type_ == booleanValue ||
- this->type_ == stringValue || this->type_ == nullValue;
- case arrayValue:
- return this->type_ == arrayValue || this->type_ == nullValue;
- case objectValue:
- return this->type_ == objectValue || this->type_ == nullValue;
+ case nullValue:
+ return (isNumeric() && asDouble() == 0.0) ||
+ (type_ == booleanValue && value_.bool_ == false) ||
+ (type_ == stringValue && asString().empty()) ||
+ (type_ == arrayValue && value_.map_->size() == 0) ||
+ (type_ == objectValue && value_.map_->size() == 0) ||
+ type_ == nullValue;
+ case intValue:
+ return isInt() ||
+ (type_ == realValue && InRange(value_.real_, minInt, maxInt)) ||
+ type_ == booleanValue || type_ == nullValue;
+ case uintValue:
+ return isUInt() ||
+ (type_ == realValue && InRange(value_.real_, 0, maxUInt)) ||
+ type_ == booleanValue || type_ == nullValue;
+ case realValue:
+ return isNumeric() || type_ == booleanValue || type_ == nullValue;
+ case booleanValue:
+ return isNumeric() || type_ == booleanValue || type_ == nullValue;
+ case stringValue:
+ return isNumeric() || type_ == booleanValue || type_ == stringValue ||
+ type_ == nullValue;
+ case arrayValue:
+ return type_ == arrayValue || type_ == nullValue;
+ case objectValue:
+ return type_ == objectValue || type_ == nullValue;
}
JSON_ASSERT_UNREACHABLE;
return false;
}
/// Number of values in array or object
-ArrayIndex Value::size() const
-{
- switch (this->type_) {
- case nullValue:
- case intValue:
- case uintValue:
- case realValue:
- case booleanValue:
- case stringValue:
- return 0;
- case arrayValue: // size of the array is highest index + 1
- if (!this->value_.map_->empty()) {
- ObjectValues::const_iterator itLast = this->value_.map_->end();
- --itLast;
- return (*itLast).first.index() + 1;
- }
- return 0;
- case objectValue:
- return ArrayIndex(this->value_.map_->size());
+ArrayIndex Value::size() const {
+ switch (type_) {
+ case nullValue:
+ case intValue:
+ case uintValue:
+ case realValue:
+ case booleanValue:
+ case stringValue:
+ return 0;
+ case arrayValue: // size of the array is highest index + 1
+ if (!value_.map_->empty()) {
+ ObjectValues::const_iterator itLast = value_.map_->end();
+ --itLast;
+ return (*itLast).first.index() + 1;
+ }
+ return 0;
+ case objectValue:
+ return ArrayIndex(value_.map_->size());
}
JSON_ASSERT_UNREACHABLE;
return 0; // unreachable;
}
-bool Value::empty() const
-{
- if (this->isNull() || this->isArray() || this->isObject())
- return this->size() == 0u;
+bool Value::empty() const {
+ if (isNull() || isArray() || isObject())
+ return size() == 0u;
else
return false;
}
-bool Value::operator!() const
-{
- return this->isNull();
-}
+bool Value::operator!() const { return isNull(); }
-void Value::clear()
-{
+void Value::clear() {
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue ||
- type_ == objectValue,
+ type_ == objectValue,
"in Json::Value::clear(): requires complex value");
- this->start_ = 0;
- this->limit_ = 0;
- switch (this->type_) {
- case arrayValue:
- case objectValue:
- this->value_.map_->clear();
- break;
- default:
- break;
+ start_ = 0;
+ limit_ = 0;
+ switch (type_) {
+ case arrayValue:
+ case objectValue:
+ value_.map_->clear();
+ break;
+ default:
+ break;
}
}
-void Value::resize(ArrayIndex newSize)
-{
+void Value::resize(ArrayIndex newSize) {
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue,
"in Json::Value::resize(): requires arrayValue");
- if (this->type_ == nullValue)
+ if (type_ == nullValue)
*this = Value(arrayValue);
- ArrayIndex oldSize = this->size();
+ ArrayIndex oldSize = size();
if (newSize == 0)
- this->clear();
+ clear();
else if (newSize > oldSize)
(*this)[newSize - 1];
else {
for (ArrayIndex index = newSize; index < oldSize; ++index) {
- this->value_.map_->erase(index);
+ value_.map_->erase(index);
}
JSON_ASSERT(size() == newSize);
}
}
-Value& Value::operator[](ArrayIndex index)
-{
+Value& Value::operator[](ArrayIndex index) {
JSON_ASSERT_MESSAGE(
- type_ == nullValue || type_ == arrayValue,
- "in Json::Value::operator[](ArrayIndex): requires arrayValue");
- if (this->type_ == nullValue)
+ type_ == nullValue || type_ == arrayValue,
+ "in Json::Value::operator[](ArrayIndex): requires arrayValue");
+ if (type_ == nullValue)
*this = Value(arrayValue);
CZString key(index);
- ObjectValues::iterator it = this->value_.map_->lower_bound(key);
- if (it != this->value_.map_->end() && (*it).first == key)
+ ObjectValues::iterator it = value_.map_->lower_bound(key);
+ if (it != value_.map_->end() && (*it).first == key)
return (*it).second;
ObjectValues::value_type defaultValue(key, nullSingleton());
- it = this->value_.map_->insert(it, defaultValue);
+ it = value_.map_->insert(it, defaultValue);
return (*it).second;
}
-Value& Value::operator[](int index)
-{
+Value& Value::operator[](int index) {
JSON_ASSERT_MESSAGE(
- index >= 0,
- "in Json::Value::operator[](int index): index cannot be negative");
+ index >= 0,
+ "in Json::Value::operator[](int index): index cannot be negative");
return (*this)[ArrayIndex(index)];
}
-const Value& Value::operator[](ArrayIndex index) const
-{
+const Value& Value::operator[](ArrayIndex index) const {
JSON_ASSERT_MESSAGE(
- type_ == nullValue || type_ == arrayValue,
- "in Json::Value::operator[](ArrayIndex)const: requires arrayValue");
- if (this->type_ == nullValue)
+ type_ == nullValue || type_ == arrayValue,
+ "in Json::Value::operator[](ArrayIndex)const: requires arrayValue");
+ if (type_ == nullValue)
return nullSingleton();
CZString key(index);
- ObjectValues::const_iterator it = this->value_.map_->find(key);
- if (it == this->value_.map_->end())
+ ObjectValues::const_iterator it = value_.map_->find(key);
+ if (it == value_.map_->end())
return nullSingleton();
return (*it).second;
}
-const Value& Value::operator[](int index) const
-{
+const Value& Value::operator[](int index) const {
JSON_ASSERT_MESSAGE(
- index >= 0,
- "in Json::Value::operator[](int index) const: index cannot be negative");
+ index >= 0,
+ "in Json::Value::operator[](int index) const: index cannot be negative");
return (*this)[ArrayIndex(index)];
}
-void Value::initBasic(ValueType vtype, bool allocated)
-{
- this->type_ = vtype;
- this->allocated_ = allocated;
- this->comments_ = 0;
- this->start_ = 0;
- this->limit_ = 0;
+void Value::initBasic(ValueType vtype, bool allocated) {
+ type_ = vtype;
+ allocated_ = allocated;
+ comments_ = 0;
+ start_ = 0;
+ limit_ = 0;
}
// Access an object value by name, create a null member if it does not exist.
// @pre Type of '*this' is object or null.
// @param key is null-terminated.
-Value& Value::resolveReference(const char* key)
-{
+Value& Value::resolveReference(const char* key) {
JSON_ASSERT_MESSAGE(
- type_ == nullValue || type_ == objectValue,
- "in Json::Value::resolveReference(): requires objectValue");
- if (this->type_ == nullValue)
+ type_ == nullValue || type_ == objectValue,
+ "in Json::Value::resolveReference(): requires objectValue");
+ if (type_ == nullValue)
*this = Value(objectValue);
- CZString actualKey(key, static_cast<unsigned>(strlen(key)),
- CZString::noDuplication); // NOTE!
- ObjectValues::iterator it = this->value_.map_->lower_bound(actualKey);
- if (it != this->value_.map_->end() && (*it).first == actualKey)
+ CZString actualKey(
+ key, static_cast<unsigned>(strlen(key)), CZString::noDuplication); // NOTE!
+ ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
+ if (it != value_.map_->end() && (*it).first == actualKey)
return (*it).second;
ObjectValues::value_type defaultValue(actualKey, nullSingleton());
- it = this->value_.map_->insert(it, defaultValue);
+ it = value_.map_->insert(it, defaultValue);
Value& value = (*it).second;
return value;
}
@@ -1219,223 +1074,198 @@ Value& Value::resolveReference(const char* key)
Value& Value::resolveReference(char const* key, char const* cend)
{
JSON_ASSERT_MESSAGE(
- type_ == nullValue || type_ == objectValue,
- "in Json::Value::resolveReference(key, end): requires objectValue");
- if (this->type_ == nullValue)
+ type_ == nullValue || type_ == objectValue,
+ "in Json::Value::resolveReference(key, end): requires objectValue");
+ if (type_ == nullValue)
*this = Value(objectValue);
- CZString actualKey(key, static_cast<unsigned>(cend - key),
- CZString::duplicateOnCopy);
- ObjectValues::iterator it = this->value_.map_->lower_bound(actualKey);
- if (it != this->value_.map_->end() && (*it).first == actualKey)
+ CZString actualKey(
+ key, static_cast<unsigned>(cend-key), CZString::duplicateOnCopy);
+ ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
+ if (it != value_.map_->end() && (*it).first == actualKey)
return (*it).second;
ObjectValues::value_type defaultValue(actualKey, nullSingleton());
- it = this->value_.map_->insert(it, defaultValue);
+ it = value_.map_->insert(it, defaultValue);
Value& value = (*it).second;
return value;
}
-Value Value::get(ArrayIndex index, const Value& defaultValue) const
-{
+Value Value::get(ArrayIndex index, const Value& defaultValue) const {
const Value* value = &((*this)[index]);
return value == &nullSingleton() ? defaultValue : *value;
}
-bool Value::isValidIndex(ArrayIndex index) const
-{
- return index < this->size();
-}
+bool Value::isValidIndex(ArrayIndex index) const { return index < size(); }
Value const* Value::find(char const* key, char const* cend) const
{
- JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
- "in Json::Value::find(key, end, found): requires "
- "objectValue or nullValue");
- if (this->type_ == nullValue)
- return NULL;
- CZString actualKey(key, static_cast<unsigned>(cend - key),
- CZString::noDuplication);
- ObjectValues::const_iterator it = this->value_.map_->find(actualKey);
- if (it == this->value_.map_->end())
- return NULL;
+ JSON_ASSERT_MESSAGE(
+ type_ == nullValue || type_ == objectValue,
+ "in Json::Value::find(key, end, found): requires objectValue or nullValue");
+ if (type_ == nullValue) return NULL;
+ CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
+ ObjectValues::const_iterator it = value_.map_->find(actualKey);
+ if (it == value_.map_->end()) return NULL;
return &(*it).second;
}
const Value& Value::operator[](const char* key) const
{
- Value const* found = this->find(key, key + strlen(key));
- if (!found)
- return nullSingleton();
+ Value const* found = find(key, key + strlen(key));
+ if (!found) return nullSingleton();
return *found;
}
Value const& Value::operator[](JSONCPP_STRING const& key) const
{
- Value const* found = this->find(key.data(), key.data() + key.length());
- if (!found)
- return nullSingleton();
+ Value const* found = find(key.data(), key.data() + key.length());
+ if (!found) return nullSingleton();
return *found;
}
-Value& Value::operator[](const char* key)
-{
- return this->resolveReference(key, key + strlen(key));
+Value& Value::operator[](const char* key) {
+ return resolveReference(key, key + strlen(key));
}
-Value& Value::operator[](const JSONCPP_STRING& key)
-{
- return this->resolveReference(key.data(), key.data() + key.length());
+Value& Value::operator[](const JSONCPP_STRING& key) {
+ return resolveReference(key.data(), key.data() + key.length());
}
-Value& Value::operator[](const StaticString& key)
-{
- return this->resolveReference(key.c_str());
+Value& Value::operator[](const StaticString& key) {
+ return resolveReference(key.c_str());
}
#ifdef JSON_USE_CPPTL
-Value& Value::operator[](const CppTL::ConstString& key)
-{
+Value& Value::operator[](const CppTL::ConstString& key) {
return resolveReference(key.c_str(), key.end_c_str());
}
Value const& Value::operator[](CppTL::ConstString const& key) const
{
Value const* found = find(key.c_str(), key.end_c_str());
- if (!found)
- return nullSingleton();
+ if (!found) return nullSingleton();
return *found;
}
#endif
-Value& Value::append(const Value& value)
-{
- return (*this)[this->size()] = value;
-}
+Value& Value::append(const Value& value) { return (*this)[size()] = value; }
#if JSON_HAS_RVALUE_REFERENCES
-Value& Value::append(Value&& value)
-{
- return (*this)[this->size()] = value;
-}
+ Value& Value::append(Value&& value) { return (*this)[size()] = value; }
#endif
-Value Value::get(char const* key, char const* cend,
- Value const& defaultValue) const
+Value Value::get(char const* key, char const* cend, Value const& defaultValue) const
{
- Value const* found = this->find(key, cend);
+ Value const* found = find(key, cend);
return !found ? defaultValue : *found;
}
Value Value::get(char const* key, Value const& defaultValue) const
{
- return this->get(key, key + strlen(key), defaultValue);
+ return get(key, key + strlen(key), defaultValue);
}
Value Value::get(JSONCPP_STRING const& key, Value const& defaultValue) const
{
- return this->get(key.data(), key.data() + key.length(), defaultValue);
+ return get(key.data(), key.data() + key.length(), defaultValue);
}
+
bool Value::removeMember(const char* key, const char* cend, Value* removed)
{
- if (this->type_ != objectValue) {
+ if (type_ != objectValue) {
return false;
}
- CZString actualKey(key, static_cast<unsigned>(cend - key),
- CZString::noDuplication);
- ObjectValues::iterator it = this->value_.map_->find(actualKey);
- if (it == this->value_.map_->end())
+ CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
+ ObjectValues::iterator it = value_.map_->find(actualKey);
+ if (it == value_.map_->end())
return false;
*removed = it->second;
- this->value_.map_->erase(it);
+ value_.map_->erase(it);
return true;
}
bool Value::removeMember(const char* key, Value* removed)
{
- return this->removeMember(key, key + strlen(key), removed);
+ return removeMember(key, key + strlen(key), removed);
}
bool Value::removeMember(JSONCPP_STRING const& key, Value* removed)
{
- return this->removeMember(key.data(), key.data() + key.length(), removed);
+ return removeMember(key.data(), key.data() + key.length(), removed);
}
Value Value::removeMember(const char* key)
{
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
"in Json::Value::removeMember(): requires objectValue");
- if (this->type_ == nullValue)
+ if (type_ == nullValue)
return nullSingleton();
- Value removed; // null
- this->removeMember(key, key + strlen(key), &removed);
+ Value removed; // null
+ removeMember(key, key + strlen(key), &removed);
return removed; // still null if removeMember() did nothing
}
Value Value::removeMember(const JSONCPP_STRING& key)
{
- return this->removeMember(key.c_str());
+ return removeMember(key.c_str());
}
-bool Value::removeIndex(ArrayIndex index, Value* removed)
-{
- if (this->type_ != arrayValue) {
+bool Value::removeIndex(ArrayIndex index, Value* removed) {
+ if (type_ != arrayValue) {
return false;
}
CZString key(index);
- ObjectValues::iterator it = this->value_.map_->find(key);
- if (it == this->value_.map_->end()) {
+ ObjectValues::iterator it = value_.map_->find(key);
+ if (it == value_.map_->end()) {
return false;
}
*removed = it->second;
- ArrayIndex oldSize = this->size();
+ ArrayIndex oldSize = size();
// shift left all items left, into the place of the "removed"
- for (ArrayIndex i = index; i < (oldSize - 1); ++i) {
+ for (ArrayIndex i = index; i < (oldSize - 1); ++i){
CZString keey(i);
- (*this->value_.map_)[keey] = (*this)[i + 1];
+ (*value_.map_)[keey] = (*this)[i + 1];
}
// erase the last one ("leftover")
CZString keyLast(oldSize - 1);
- ObjectValues::iterator itLast = this->value_.map_->find(keyLast);
- this->value_.map_->erase(itLast);
+ ObjectValues::iterator itLast = value_.map_->find(keyLast);
+ value_.map_->erase(itLast);
return true;
}
#ifdef JSON_USE_CPPTL
Value Value::get(const CppTL::ConstString& key,
- const Value& defaultValue) const
-{
+ const Value& defaultValue) const {
return get(key.c_str(), key.end_c_str(), defaultValue);
}
#endif
bool Value::isMember(char const* key, char const* cend) const
{
- Value const* value = this->find(key, cend);
+ Value const* value = find(key, cend);
return NULL != value;
}
bool Value::isMember(char const* key) const
{
- return this->isMember(key, key + strlen(key));
+ return isMember(key, key + strlen(key));
}
bool Value::isMember(JSONCPP_STRING const& key) const
{
- return this->isMember(key.data(), key.data() + key.length());
+ return isMember(key.data(), key.data() + key.length());
}
#ifdef JSON_USE_CPPTL
-bool Value::isMember(const CppTL::ConstString& key) const
-{
+bool Value::isMember(const CppTL::ConstString& key) const {
return isMember(key.c_str(), key.end_c_str());
}
#endif
-Value::Members Value::getMemberNames() const
-{
+Value::Members Value::getMemberNames() const {
JSON_ASSERT_MESSAGE(
- type_ == nullValue || type_ == objectValue,
- "in Json::Value::getMemberNames(), value must be objectValue");
- if (this->type_ == nullValue)
+ type_ == nullValue || type_ == objectValue,
+ "in Json::Value::getMemberNames(), value must be objectValue");
+ if (type_ == nullValue)
return Value::Members();
Members members;
- members.reserve(this->value_.map_->size());
- ObjectValues::const_iterator it = this->value_.map_->begin();
- ObjectValues::const_iterator itEnd = this->value_.map_->end();
+ members.reserve(value_.map_->size());
+ ObjectValues::const_iterator it = value_.map_->begin();
+ ObjectValues::const_iterator itEnd = value_.map_->end();
for (; it != itEnd; ++it) {
- members.push_back(
- JSONCPP_STRING((*it).first.data(), (*it).first.length()));
+ members.push_back(JSONCPP_STRING((*it).first.data(),
+ (*it).first.length()));
}
return members;
}
@@ -1447,8 +1277,8 @@ Value::Members Value::getMemberNames() const
// if ( type_ == objectValue )
// {
// return CppTL::Enum::any( CppTL::Enum::transform(
-// CppTL::Enum::keys( *(value_.map_), CppTL::Type<const CZString &>()
-// ), MemberNamesTransform() ) );
+// CppTL::Enum::keys( *(value_.map_), CppTL::Type<const CZString &>() ),
+// MemberNamesTransform() ) );
// }
// return EnumMemberNames();
//}
@@ -1465,114 +1295,99 @@ Value::Members Value::getMemberNames() const
//
//# endif
-static bool IsIntegral(double d)
-{
+static bool IsIntegral(double d) {
double integral_part;
return modf(d, &integral_part) == 0.0;
}
-bool Value::isNull() const
-{
- return this->type_ == nullValue;
-}
+bool Value::isNull() const { return type_ == nullValue; }
-bool Value::isBool() const
-{
- return this->type_ == booleanValue;
-}
+bool Value::isBool() const { return type_ == booleanValue; }
-bool Value::isInt() const
-{
- switch (this->type_) {
- case intValue:
+bool Value::isInt() const {
+ switch (type_) {
+ case intValue:
#if defined(JSON_HAS_INT64)
- return this->value_.int_ >= minInt && this->value_.int_ <= maxInt;
+ return value_.int_ >= minInt && value_.int_ <= maxInt;
#else
- return true;
+ return true;
#endif
- case uintValue:
- return this->value_.uint_ <= UInt(maxInt);
- case realValue:
- return this->value_.real_ >= minInt && this->value_.real_ <= maxInt &&
- IsIntegral(this->value_.real_);
- default:
- break;
+ case uintValue:
+ return value_.uint_ <= UInt(maxInt);
+ case realValue:
+ return value_.real_ >= minInt && value_.real_ <= maxInt &&
+ IsIntegral(value_.real_);
+ default:
+ break;
}
return false;
}
-bool Value::isUInt() const
-{
- switch (this->type_) {
- case intValue:
+bool Value::isUInt() const {
+ switch (type_) {
+ case intValue:
#if defined(JSON_HAS_INT64)
- return this->value_.int_ >= 0 &&
- LargestUInt(this->value_.int_) <= LargestUInt(maxUInt);
+ return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);
#else
- return value_.int_ >= 0;
+ return value_.int_ >= 0;
#endif
- case uintValue:
+ case uintValue:
#if defined(JSON_HAS_INT64)
- return this->value_.uint_ <= maxUInt;
+ return value_.uint_ <= maxUInt;
#else
- return true;
+ return true;
#endif
- case realValue:
- return this->value_.real_ >= 0 && this->value_.real_ <= maxUInt &&
- IsIntegral(this->value_.real_);
- default:
- break;
+ case realValue:
+ return value_.real_ >= 0 && value_.real_ <= maxUInt &&
+ IsIntegral(value_.real_);
+ default:
+ break;
}
return false;
}
-bool Value::isInt64() const
-{
+bool Value::isInt64() const {
#if defined(JSON_HAS_INT64)
- switch (this->type_) {
- case intValue:
- return true;
- case uintValue:
- return this->value_.uint_ <= UInt64(maxInt64);
- case realValue:
- // Note that maxInt64 (= 2^63 - 1) is not exactly representable as a
- // double, so double(maxInt64) will be rounded up to 2^63. Therefore we
- // require the value to be strictly less than the limit.
- return this->value_.real_ >= double(minInt64) &&
- this->value_.real_ < double(maxInt64) &&
- IsIntegral(this->value_.real_);
- default:
- break;
+ switch (type_) {
+ case intValue:
+ return true;
+ case uintValue:
+ return value_.uint_ <= UInt64(maxInt64);
+ case realValue:
+ // Note that maxInt64 (= 2^63 - 1) is not exactly representable as a
+ // double, so double(maxInt64) will be rounded up to 2^63. Therefore we
+ // require the value to be strictly less than the limit.
+ return value_.real_ >= double(minInt64) &&
+ value_.real_ < double(maxInt64) && IsIntegral(value_.real_);
+ default:
+ break;
}
#endif // JSON_HAS_INT64
return false;
}
-bool Value::isUInt64() const
-{
+bool Value::isUInt64() const {
#if defined(JSON_HAS_INT64)
- switch (this->type_) {
- case intValue:
- return this->value_.int_ >= 0;
- case uintValue:
- return true;
- case realValue:
- // Note that maxUInt64 (= 2^64 - 1) is not exactly representable as a
- // double, so double(maxUInt64) will be rounded up to 2^64. Therefore we
- // require the value to be strictly less than the limit.
- return this->value_.real_ >= 0 &&
- this->value_.real_ < maxUInt64AsDouble &&
- IsIntegral(this->value_.real_);
- default:
- break;
+ switch (type_) {
+ case intValue:
+ return value_.int_ >= 0;
+ case uintValue:
+ return true;
+ case realValue:
+ // Note that maxUInt64 (= 2^64 - 1) is not exactly representable as a
+ // double, so double(maxUInt64) will be rounded up to 2^64. Therefore we
+ // require the value to be strictly less than the limit.
+ return value_.real_ >= 0 && value_.real_ < maxUInt64AsDouble &&
+ IsIntegral(value_.real_);
+ default:
+ break;
}
#endif // JSON_HAS_INT64
return false;
}
-bool Value::isIntegral() const
-{
- switch (this->type_) {
+bool Value::isIntegral() const {
+ switch (type_) {
case intValue:
case uintValue:
return true;
@@ -1581,12 +1396,9 @@ bool Value::isIntegral() const
// Note that maxUInt64 (= 2^64 - 1) is not exactly representable as a
// double, so double(maxUInt64) will be rounded up to 2^64. Therefore we
// require the value to be strictly less than the limit.
- return this->value_.real_ >= double(minInt64) &&
- this->value_.real_ < maxUInt64AsDouble &&
- IsIntegral(this->value_.real_);
+ return value_.real_ >= double(minInt64) && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_);
#else
- return value_.real_ >= minInt && value_.real_ <= maxUInt &&
- IsIntegral(value_.real_);
+ return value_.real_ >= minInt && value_.real_ <= maxUInt && IsIntegral(value_.real_);
#endif // JSON_HAS_INT64
default:
break;
@@ -1594,89 +1406,53 @@ bool Value::isIntegral() const
return false;
}
-bool Value::isDouble() const
-{
- return this->type_ == intValue || this->type_ == uintValue ||
- this->type_ == realValue;
-}
+bool Value::isDouble() const { return type_ == intValue || type_ == uintValue || type_ == realValue; }
-bool Value::isNumeric() const
-{
- return this->isDouble();
-}
+bool Value::isNumeric() const { return isDouble(); }
-bool Value::isString() const
-{
- return this->type_ == stringValue;
-}
+bool Value::isString() const { return type_ == stringValue; }
-bool Value::isArray() const
-{
- return this->type_ == arrayValue;
-}
+bool Value::isArray() const { return type_ == arrayValue; }
-bool Value::isObject() const
-{
- return this->type_ == objectValue;
-}
+bool Value::isObject() const { return type_ == objectValue; }
-void Value::setComment(const char* comment, size_t len,
- CommentPlacement placement)
-{
- if (!this->comments_)
- this->comments_ = new CommentInfo[numberOfCommentPlacement];
- if ((len > 0) && (comment[len - 1] == '\n')) {
+void Value::setComment(const char* comment, size_t len, CommentPlacement placement) {
+ if (!comments_)
+ comments_ = new CommentInfo[numberOfCommentPlacement];
+ if ((len > 0) && (comment[len-1] == '\n')) {
// Always discard trailing newline, to aid indentation.
len -= 1;
}
- this->comments_[placement].setComment(comment, len);
+ comments_[placement].setComment(comment, len);
}
-void Value::setComment(const char* comment, CommentPlacement placement)
-{
- this->setComment(comment, strlen(comment), placement);
+void Value::setComment(const char* comment, CommentPlacement placement) {
+ setComment(comment, strlen(comment), placement);
}
-void Value::setComment(const JSONCPP_STRING& comment,
- CommentPlacement placement)
-{
- this->setComment(comment.c_str(), comment.length(), placement);
+void Value::setComment(const JSONCPP_STRING& comment, CommentPlacement placement) {
+ setComment(comment.c_str(), comment.length(), placement);
}
-bool Value::hasComment(CommentPlacement placement) const
-{
- return this->comments_ != 0 && this->comments_[placement].comment_ != 0;
+bool Value::hasComment(CommentPlacement placement) const {
+ return comments_ != 0 && comments_[placement].comment_ != 0;
}
-JSONCPP_STRING Value::getComment(CommentPlacement placement) const
-{
- if (this->hasComment(placement))
- return this->comments_[placement].comment_;
+JSONCPP_STRING Value::getComment(CommentPlacement placement) const {
+ if (hasComment(placement))
+ return comments_[placement].comment_;
return "";
}
-void Value::setOffsetStart(ptrdiff_t start)
-{
- this->start_ = start;
-}
+void Value::setOffsetStart(ptrdiff_t start) { start_ = start; }
-void Value::setOffsetLimit(ptrdiff_t limit)
-{
- this->limit_ = limit;
-}
+void Value::setOffsetLimit(ptrdiff_t limit) { limit_ = limit; }
-ptrdiff_t Value::getOffsetStart() const
-{
- return this->start_;
-}
+ptrdiff_t Value::getOffsetStart() const { return start_; }
-ptrdiff_t Value::getOffsetLimit() const
-{
- return this->limit_;
-}
+ptrdiff_t Value::getOffsetLimit() const { return limit_; }
-JSONCPP_STRING Value::toStyledString() const
-{
+JSONCPP_STRING Value::toStyledString() const {
StreamWriterBuilder builder;
JSONCPP_STRING out = this->hasComment(commentBefore) ? "\n" : "";
@@ -1686,58 +1462,54 @@ JSONCPP_STRING Value::toStyledString() const
return out;
}
-Value::const_iterator Value::begin() const
-{
- switch (this->type_) {
- case arrayValue:
- case objectValue:
- if (this->value_.map_)
- return const_iterator(this->value_.map_->begin());
- break;
- default:
- break;
+Value::const_iterator Value::begin() const {
+ switch (type_) {
+ case arrayValue:
+ case objectValue:
+ if (value_.map_)
+ return const_iterator(value_.map_->begin());
+ break;
+ default:
+ break;
}
return const_iterator();
}
-Value::const_iterator Value::end() const
-{
- switch (this->type_) {
- case arrayValue:
- case objectValue:
- if (this->value_.map_)
- return const_iterator(this->value_.map_->end());
- break;
- default:
- break;
+Value::const_iterator Value::end() const {
+ switch (type_) {
+ case arrayValue:
+ case objectValue:
+ if (value_.map_)
+ return const_iterator(value_.map_->end());
+ break;
+ default:
+ break;
}
return const_iterator();
}
-Value::iterator Value::begin()
-{
- switch (this->type_) {
- case arrayValue:
- case objectValue:
- if (this->value_.map_)
- return iterator(this->value_.map_->begin());
- break;
- default:
- break;
+Value::iterator Value::begin() {
+ switch (type_) {
+ case arrayValue:
+ case objectValue:
+ if (value_.map_)
+ return iterator(value_.map_->begin());
+ break;
+ default:
+ break;
}
return iterator();
}
-Value::iterator Value::end()
-{
- switch (this->type_) {
- case arrayValue:
- case objectValue:
- if (this->value_.map_)
- return iterator(this->value_.map_->end());
- break;
- default:
- break;
+Value::iterator Value::end() {
+ switch (type_) {
+ case arrayValue:
+ case objectValue:
+ if (value_.map_)
+ return iterator(value_.map_->end());
+ break;
+ default:
+ break;
}
return iterator();
}
@@ -1745,41 +1517,26 @@ Value::iterator Value::end()
// class PathArgument
// //////////////////////////////////////////////////////////////////
-PathArgument::PathArgument()
- : key_()
- , index_()
- , kind_(kindNone)
-{
-}
+PathArgument::PathArgument() : key_(), index_(), kind_(kindNone) {}
PathArgument::PathArgument(ArrayIndex index)
- : key_()
- , index_(index)
- , kind_(kindIndex)
-{
-}
+ : key_(), index_(index), kind_(kindIndex) {}
PathArgument::PathArgument(const char* key)
- : key_(key)
- , index_()
- , kind_(kindKey)
-{
-}
+ : key_(key), index_(), kind_(kindKey) {}
PathArgument::PathArgument(const JSONCPP_STRING& key)
- : key_(key.c_str())
- , index_()
- , kind_(kindKey)
-{
-}
+ : key_(key.c_str()), index_(), kind_(kindKey) {}
// class Path
// //////////////////////////////////////////////////////////////////
-Path::Path(const JSONCPP_STRING& path, const PathArgument& a1,
- const PathArgument& a2, const PathArgument& a3,
- const PathArgument& a4, const PathArgument& a5)
-{
+Path::Path(const JSONCPP_STRING& path,
+ const PathArgument& a1,
+ const PathArgument& a2,
+ const PathArgument& a3,
+ const PathArgument& a4,
+ const PathArgument& a5) {
InArgs in;
in.reserve(5);
in.push_back(&a1);
@@ -1787,11 +1544,10 @@ Path::Path(const JSONCPP_STRING& path, const PathArgument& a1,
in.push_back(&a3);
in.push_back(&a4);
in.push_back(&a5);
- this->makePath(path, in);
+ makePath(path, in);
}
-void Path::makePath(const JSONCPP_STRING& path, const InArgs& in)
-{
+void Path::makePath(const JSONCPP_STRING& path, const InArgs& in) {
const char* current = path.c_str();
const char* end = current + path.length();
InArgs::const_iterator itInArg = in.begin();
@@ -1799,17 +1555,17 @@ void Path::makePath(const JSONCPP_STRING& path, const InArgs& in)
if (*current == '[') {
++current;
if (*current == '%')
- this->addPathInArg(path, in, itInArg, PathArgument::kindIndex);
+ addPathInArg(path, in, itInArg, PathArgument::kindIndex);
else {
ArrayIndex index = 0;
for (; current != end && *current >= '0' && *current <= '9'; ++current)
index = index * 10 + ArrayIndex(*current - '0');
- this->args_.push_back(index);
+ args_.push_back(index);
}
if (current == end || *++current != ']')
- this->invalidPath(path, int(current - path.c_str()));
+ invalidPath(path, int(current - path.c_str()));
} else if (*current == '%') {
- this->addPathInArg(path, in, itInArg, PathArgument::kindKey);
+ addPathInArg(path, in, itInArg, PathArgument::kindKey);
++current;
} else if (*current == '.' || *current == ']') {
++current;
@@ -1817,34 +1573,31 @@ void Path::makePath(const JSONCPP_STRING& path, const InArgs& in)
const char* beginName = current;
while (current != end && !strchr("[.", *current))
++current;
- this->args_.push_back(JSONCPP_STRING(beginName, current));
+ args_.push_back(JSONCPP_STRING(beginName, current));
}
}
}
-void Path::addPathInArg(const JSONCPP_STRING& /*path*/, const InArgs& in,
+void Path::addPathInArg(const JSONCPP_STRING& /*path*/,
+ const InArgs& in,
InArgs::const_iterator& itInArg,
- PathArgument::Kind kind)
-{
+ PathArgument::Kind kind) {
if (itInArg == in.end()) {
// Error: missing argument %d
} else if ((*itInArg)->kind_ != kind) {
// Error: bad argument type
} else {
- this->args_.push_back(**itInArg++);
+ args_.push_back(**itInArg++);
}
}
-void Path::invalidPath(const JSONCPP_STRING& /*path*/, int /*location*/)
-{
+void Path::invalidPath(const JSONCPP_STRING& /*path*/, int /*location*/) {
// Error: invalid path.
}
-const Value& Path::resolve(const Value& root) const
-{
+const Value& Path::resolve(const Value& root) const {
const Value* node = &root;
- for (Args::const_iterator it = this->args_.begin(); it != this->args_.end();
- ++it) {
+ for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) {
const PathArgument& arg = *it;
if (arg.kind_ == PathArgument::kindIndex) {
if (!node->isArray() || !node->isValidIndex(arg.index_)) {
@@ -1868,11 +1621,9 @@ const Value& Path::resolve(const Value& root) const
return *node;
}
-Value Path::resolve(const Value& root, const Value& defaultValue) const
-{
+Value Path::resolve(const Value& root, const Value& defaultValue) const {
const Value* node = &root;
- for (Args::const_iterator it = this->args_.begin(); it != this->args_.end();
- ++it) {
+ for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) {
const PathArgument& arg = *it;
if (arg.kind_ == PathArgument::kindIndex) {
if (!node->isArray() || !node->isValidIndex(arg.index_))
@@ -1889,11 +1640,9 @@ Value Path::resolve(const Value& root, const Value& defaultValue) const
return *node;
}
-Value& Path::make(Value& root) const
-{
+Value& Path::make(Value& root) const {
Value* node = &root;
- for (Args::const_iterator it = this->args_.begin(); it != this->args_.end();
- ++it) {
+ for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) {
const PathArgument& arg = *it;
if (arg.kind_ == PathArgument::kindIndex) {
if (!node->isArray()) {
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp b/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp
index 803cfab..fc86505 100644
--- a/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp
+++ b/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp
@@ -1,115 +1,111 @@
// Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at
-// http://jsoncpp.sourceforge.net/LICENSE
+// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
#if !defined(JSON_IS_AMALGAMATION)
-# include <json/writer.h>
-
-# include "json_tool.h"
+#include <json/writer.h>
+#include "json_tool.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <cassert>
-#include <cstdio>
-#include <cstring>
#include <iomanip>
#include <memory>
-#include <set>
#include <sstream>
#include <utility>
+#include <set>
+#include <cassert>
+#include <cstring>
+#include <cstdio>
-#if defined(_MSC_VER) && _MSC_VER >= 1200 && \
- _MSC_VER < 1800 // Between VC++ 6.0 and VC++ 11.0
-# include <float.h>
-# define isfinite _finite
-#elif defined(__sun) && defined(__SVR4) // Solaris
-# if !defined(isfinite)
-# include <ieeefp.h>
-# define isfinite finite
-# endif
+#if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1800 // Between VC++ 6.0 and VC++ 11.0
+#include <float.h>
+#define isfinite _finite
+#elif defined(__sun) && defined(__SVR4) //Solaris
+#if !defined(isfinite)
+#include <ieeefp.h>
+#define isfinite finite
+#endif
#elif defined(_AIX)
-# if !defined(isfinite)
-# include <math.h>
-# define isfinite finite
-# endif
+#if !defined(isfinite)
+#include <math.h>
+#define isfinite finite
+#endif
#elif defined(__hpux)
-# if !defined(isfinite) && !defined(__GNUC__)
-# if defined(__ia64) && !defined(finite)
-# define isfinite(x) \
- ((sizeof(x) == sizeof(float) ? _Isfinitef(x) : _IsFinite(x)))
-# else
-# include <math.h>
-# define isfinite finite
-# endif
-# endif
+#if !defined(isfinite) && !defined(__GNUC__)
+#if defined(__ia64) && !defined(finite)
+#define isfinite(x) ((sizeof(x) == sizeof(float) ? \
+ _Isfinitef(x) : _IsFinite(x)))
#else
-# include <cmath>
-# if !(defined(__QNXNTO__)) // QNX already defines isfinite
-# define isfinite std::isfinite
-# endif
+#include <math.h>
+#define isfinite finite
+#endif
+#endif
+#else
+#include <cmath>
+#if !(defined(__QNXNTO__)) // QNX already defines isfinite
+#define isfinite std::isfinite
+#endif
#endif
#if defined(_MSC_VER)
-# if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && \
- _MSC_VER >= 1500 // VC++ 9.0 and above
-# define snprintf sprintf_s
-# elif _MSC_VER >= 1900 // VC++ 14.0 and above
-# define snprintf std::snprintf
-# else
-# define snprintf _snprintf
-# endif
+#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
+#define snprintf sprintf_s
+#elif _MSC_VER >= 1900 // VC++ 14.0 and above
+#define snprintf std::snprintf
+#else
+#define snprintf _snprintf
+#endif
#elif defined(__ANDROID__) || defined(__QNXNTO__)
-# define snprintf snprintf
+#define snprintf snprintf
#elif __cplusplus >= 201103L
-# if !defined(__MINGW32__) && !defined(__CYGWIN__)
-# define snprintf std::snprintf
-# endif
+#if !defined(__MINGW32__) && !defined(__CYGWIN__)
+#define snprintf std::snprintf
+#endif
#endif
-#if defined(__BORLANDC__)
-# include <float.h>
-# define isfinite _finite
-# define snprintf _snprintf
+#if defined(__BORLANDC__)
+#include <float.h>
+#define isfinite _finite
+#define snprintf _snprintf
#endif
// Solaris
#if defined(__sun)
-# include <ieeefp.h>
-# if !defined(isfinite)
-# define isfinite finite
-# endif
+# include <ieeefp.h>
+# if !defined(isfinite)
+# define isfinite finite
+# endif
#endif
// AIX
#if defined(_AIX)
-# if !defined(isfinite)
-# define isfinite finite
-# endif
+# if !defined(isfinite)
+# define isfinite finite
+# endif
#endif
// HP-UX
#if defined(__hpux)
-# if !defined(isfinite)
-# if defined(__ia64) && !defined(finite) && !defined(__GNUC__)
-# define isfinite(x) \
- ((sizeof(x) == sizeof(float) ? _Isfinitef(x) : _Isfinite(x)))
-# else
-# include <math.h>
-# define isfinite finite
-# endif
+# if !defined(isfinite)
+# if defined(__ia64) && !defined(finite) && !defined(__GNUC__)
+# define isfinite(x) ((sizeof(x) == sizeof(float) ? \
+ _Isfinitef(x) : _Isfinite(x)))
+# else
+# include <math.h>
+# define isfinite finite
# endif
+# endif
#endif
// Ancient glibc
#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 2
-# if !defined(isfinite)
-# define isfinite __finite
-# endif
+# if !defined(isfinite)
+# define isfinite __finite
+# endif
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
// Disable warning about strdup being deprecated.
-# pragma warning(disable : 4996)
+#pragma warning(disable : 4996)
#endif
namespace Json {
@@ -117,11 +113,10 @@ namespace Json {
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
#else
-typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
+typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
#endif
-static bool containsControlCharacter(const char* str)
-{
+static bool containsControlCharacter(const char* str) {
while (*str) {
if (isControlCharacter(*(str++)))
return true;
@@ -129,19 +124,17 @@ static bool containsControlCharacter(const char* str)
return false;
}
-static bool containsControlCharacter0(const char* str, unsigned len)
-{
+static bool containsControlCharacter0(const char* str, unsigned len) {
char const* end = str + len;
while (end != str) {
- if (isControlCharacter(*str) || 0 == *str)
+ if (isControlCharacter(*str) || 0==*str)
return true;
++str;
}
return false;
}
-JSONCPP_STRING valueToString(LargestInt value)
-{
+JSONCPP_STRING valueToString(LargestInt value) {
UIntToStringBuffer buffer;
char* current = buffer + sizeof(buffer);
if (value == Value::minLargestInt) {
@@ -157,8 +150,7 @@ JSONCPP_STRING valueToString(LargestInt value)
return current;
}
-JSONCPP_STRING valueToString(LargestUInt value)
-{
+JSONCPP_STRING valueToString(LargestUInt value) {
UIntToStringBuffer buffer;
char* current = buffer + sizeof(buffer);
uintToString(value, current);
@@ -168,22 +160,18 @@ JSONCPP_STRING valueToString(LargestUInt value)
#if defined(JSON_HAS_INT64)
-JSONCPP_STRING valueToString(Int value)
-{
+JSONCPP_STRING valueToString(Int value) {
return valueToString(LargestInt(value));
}
-JSONCPP_STRING valueToString(UInt value)
-{
+JSONCPP_STRING valueToString(UInt value) {
return valueToString(LargestUInt(value));
}
#endif // # if defined(JSON_HAS_INT64)
namespace {
-JSONCPP_STRING valueToString(double value, bool useSpecialFloats,
- unsigned int precision)
-{
+JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int precision) {
// Allocate a buffer that is more than large enough to store the 16 digits of
// precision requested below.
char buffer[36];
@@ -199,8 +187,7 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats,
len = snprintf(buffer, sizeof(buffer), formatString, value);
fixNumericLocale(buffer, buffer + len);
- // try to ensure we preserve the fact that this was given to us as a double
- // on input
+ // try to ensure we preserve the fact that this was given to us as a double on input
if (!strchr(buffer, '.') && !strchr(buffer, 'e')) {
strcat(buffer, ".0");
}
@@ -208,14 +195,11 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats,
} else {
// IEEE standard states that NaN values will not compare to themselves
if (value != value) {
- len =
- snprintf(buffer, sizeof(buffer), useSpecialFloats ? "NaN" : "null");
+ len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "NaN" : "null");
} else if (value < 0) {
- len = snprintf(buffer, sizeof(buffer),
- useSpecialFloats ? "-Infinity" : "-1e+9999");
+ len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "-Infinity" : "-1e+9999");
} else {
- len = snprintf(buffer, sizeof(buffer),
- useSpecialFloats ? "Infinity" : "1e+9999");
+ len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "Infinity" : "1e+9999");
}
}
assert(len >= 0);
@@ -223,18 +207,11 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats,
}
}
-JSONCPP_STRING valueToString(double value)
-{
- return valueToString(value, false, 17);
-}
+JSONCPP_STRING valueToString(double value) { return valueToString(value, false, 17); }
-JSONCPP_STRING valueToString(bool value)
-{
- return value ? "true" : "false";
-}
+JSONCPP_STRING valueToString(bool value) { return value ? "true" : "false"; }
-JSONCPP_STRING valueToQuotedString(const char* value)
-{
+JSONCPP_STRING valueToQuotedString(const char* value) {
if (value == NULL)
return "";
// Not sure how to handle unicode...
@@ -245,50 +222,51 @@ JSONCPP_STRING valueToQuotedString(const char* value)
// Appending to JSONCPP_STRING is not efficient, but this should be rare.
// (Note: forward slashes are *not* rare, but I am not escaping them.)
JSONCPP_STRING::size_type maxsize =
- strlen(value) * 2 + 3; // allescaped+quotes+NULL
+ strlen(value) * 2 + 3; // allescaped+quotes+NULL
JSONCPP_STRING result;
result.reserve(maxsize); // to avoid lots of mallocs
result += "\"";
for (const char* c = value; *c != 0; ++c) {
switch (*c) {
- case '\"':
- result += "\\\"";
- break;
- case '\\':
- result += "\\\\";
- break;
- case '\b':
- result += "\\b";
- break;
- case '\f':
- result += "\\f";
- break;
- case '\n':
- result += "\\n";
- break;
- case '\r':
- result += "\\r";
- break;
- case '\t':
- result += "\\t";
- break;
- // case '/':
- // Even though \/ is considered a legal escape in JSON, a bare
- // slash is also legal, so I see no reason to escape it.
- // (I hope I am not misunderstanding something.
- // blep notes: actually escaping \/ may be useful in javascript to avoid
- // </ sequence. Should add a flag to allow this compatibility mode and
- // prevent this sequence from occurring.
- default:
- if (isControlCharacter(*c)) {
- JSONCPP_OSTRINGSTREAM oss;
- oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
- << std::setw(4) << static_cast<int>(*c);
- result += oss.str();
- } else {
- result += *c;
- }
- break;
+ case '\"':
+ result += "\\\"";
+ break;
+ case '\\':
+ result += "\\\\";
+ break;
+ case '\b':
+ result += "\\b";
+ break;
+ case '\f':
+ result += "\\f";
+ break;
+ case '\n':
+ result += "\\n";
+ break;
+ case '\r':
+ result += "\\r";
+ break;
+ case '\t':
+ result += "\\t";
+ break;
+ // case '/':
+ // Even though \/ is considered a legal escape in JSON, a bare
+ // slash is also legal, so I see no reason to escape it.
+ // (I hope I am not misunderstanding something.
+ // blep notes: actually escaping \/ may be useful in javascript to avoid </
+ // sequence.
+ // Should add a flag to allow this compatibility mode and prevent this
+ // sequence from occurring.
+ default:
+ if (isControlCharacter(*c)) {
+ JSONCPP_OSTRINGSTREAM oss;
+ oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
+ << std::setw(4) << static_cast<int>(*c);
+ result += oss.str();
+ } else {
+ result += *c;
+ }
+ break;
}
}
result += "\"";
@@ -296,8 +274,7 @@ JSONCPP_STRING valueToQuotedString(const char* value)
}
// https://github.com/upcaste/upcaste/blob/master/src/upcore/src/cstring/strnpbrk.cpp
-static char const* strnpbrk(char const* s, char const* accept, size_t n)
-{
+static char const* strnpbrk(char const* s, char const* accept, size_t n) {
assert((s || !n) && accept);
char const* const end = s + n;
@@ -311,8 +288,7 @@ static char const* strnpbrk(char const* s, char const* accept, size_t n)
}
return NULL;
}
-static JSONCPP_STRING valueToQuotedStringN(const char* value, unsigned length)
-{
+static JSONCPP_STRING valueToQuotedStringN(const char* value, unsigned length) {
if (value == NULL)
return "";
// Not sure how to handle unicode...
@@ -322,51 +298,53 @@ static JSONCPP_STRING valueToQuotedStringN(const char* value, unsigned length)
// We have to walk value and escape any special characters.
// Appending to JSONCPP_STRING is not efficient, but this should be rare.
// (Note: forward slashes are *not* rare, but I am not escaping them.)
- JSONCPP_STRING::size_type maxsize = length * 2 + 3; // allescaped+quotes+NULL
+ JSONCPP_STRING::size_type maxsize =
+ length * 2 + 3; // allescaped+quotes+NULL
JSONCPP_STRING result;
result.reserve(maxsize); // to avoid lots of mallocs
result += "\"";
char const* end = value + length;
for (const char* c = value; c != end; ++c) {
switch (*c) {
- case '\"':
- result += "\\\"";
- break;
- case '\\':
- result += "\\\\";
- break;
- case '\b':
- result += "\\b";
- break;
- case '\f':
- result += "\\f";
- break;
- case '\n':
- result += "\\n";
- break;
- case '\r':
- result += "\\r";
- break;
- case '\t':
- result += "\\t";
- break;
- // case '/':
- // Even though \/ is considered a legal escape in JSON, a bare
- // slash is also legal, so I see no reason to escape it.
- // (I hope I am not misunderstanding something.)
- // blep notes: actually escaping \/ may be useful in javascript to avoid
- // </ sequence. Should add a flag to allow this compatibility mode and
- // prevent this sequence from occurring.
- default:
- if ((isControlCharacter(*c)) || (*c == 0)) {
- JSONCPP_OSTRINGSTREAM oss;
- oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
- << std::setw(4) << static_cast<int>(*c);
- result += oss.str();
- } else {
- result += *c;
- }
- break;
+ case '\"':
+ result += "\\\"";
+ break;
+ case '\\':
+ result += "\\\\";
+ break;
+ case '\b':
+ result += "\\b";
+ break;
+ case '\f':
+ result += "\\f";
+ break;
+ case '\n':
+ result += "\\n";
+ break;
+ case '\r':
+ result += "\\r";
+ break;
+ case '\t':
+ result += "\\t";
+ break;
+ // case '/':
+ // Even though \/ is considered a legal escape in JSON, a bare
+ // slash is also legal, so I see no reason to escape it.
+ // (I hope I am not misunderstanding something.)
+ // blep notes: actually escaping \/ may be useful in javascript to avoid </
+ // sequence.
+ // Should add a flag to allow this compatibility mode and prevent this
+ // sequence from occurring.
+ default:
+ if ((isControlCharacter(*c)) || (*c == 0)) {
+ JSONCPP_OSTRINGSTREAM oss;
+ oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
+ << std::setw(4) << static_cast<int>(*c);
+ result += oss.str();
+ } else {
+ result += *c;
+ }
+ break;
}
}
result += "\"";
@@ -375,98 +353,80 @@ static JSONCPP_STRING valueToQuotedStringN(const char* value, unsigned length)
// Class Writer
// //////////////////////////////////////////////////////////////////
-Writer::~Writer()
-{
-}
+Writer::~Writer() {}
// Class FastWriter
// //////////////////////////////////////////////////////////////////
FastWriter::FastWriter()
- : yamlCompatiblityEnabled_(false)
- , dropNullPlaceholders_(false)
- , omitEndingLineFeed_(false)
-{
-}
+ : yamlCompatiblityEnabled_(false), dropNullPlaceholders_(false),
+ omitEndingLineFeed_(false) {}
-void FastWriter::enableYAMLCompatibility()
-{
- this->yamlCompatiblityEnabled_ = true;
-}
+void FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; }
-void FastWriter::dropNullPlaceholders()
-{
- this->dropNullPlaceholders_ = true;
-}
+void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
-void FastWriter::omitEndingLineFeed()
-{
- this->omitEndingLineFeed_ = true;
-}
+void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
-JSONCPP_STRING FastWriter::write(const Value& root)
-{
- this->document_.clear();
- this->writeValue(root);
- if (!this->omitEndingLineFeed_)
- this->document_ += "\n";
- return this->document_;
+JSONCPP_STRING FastWriter::write(const Value& root) {
+ document_.clear();
+ writeValue(root);
+ if (!omitEndingLineFeed_)
+ document_ += "\n";
+ return document_;
}
-void FastWriter::writeValue(const Value& value)
-{
+void FastWriter::writeValue(const Value& value) {
switch (value.type()) {
- case nullValue:
- if (!this->dropNullPlaceholders_)
- this->document_ += "null";
- break;
- case intValue:
- this->document_ += valueToString(value.asLargestInt());
- break;
- case uintValue:
- this->document_ += valueToString(value.asLargestUInt());
- break;
- case realValue:
- this->document_ += valueToString(value.asDouble());
- break;
- case stringValue: {
- // Is NULL possible for value.string_? No.
- char const* str;
- char const* end;
- bool ok = value.getString(&str, &end);
- if (ok)
- this->document_ +=
- valueToQuotedStringN(str, static_cast<unsigned>(end - str));
- break;
+ case nullValue:
+ if (!dropNullPlaceholders_)
+ document_ += "null";
+ break;
+ case intValue:
+ document_ += valueToString(value.asLargestInt());
+ break;
+ case uintValue:
+ document_ += valueToString(value.asLargestUInt());
+ break;
+ case realValue:
+ document_ += valueToString(value.asDouble());
+ break;
+ case stringValue:
+ {
+ // Is NULL possible for value.string_? No.
+ char const* str;
+ char const* end;
+ bool ok = value.getString(&str, &end);
+ if (ok) document_ += valueToQuotedStringN(str, static_cast<unsigned>(end-str));
+ break;
+ }
+ case booleanValue:
+ document_ += valueToString(value.asBool());
+ break;
+ case arrayValue: {
+ document_ += '[';
+ ArrayIndex size = value.size();
+ for (ArrayIndex index = 0; index < size; ++index) {
+ if (index > 0)
+ document_ += ',';
+ writeValue(value[index]);
}
- case booleanValue:
- this->document_ += valueToString(value.asBool());
- break;
- case arrayValue: {
- this->document_ += '[';
- ArrayIndex size = value.size();
- for (ArrayIndex index = 0; index < size; ++index) {
- if (index > 0)
- this->document_ += ',';
- this->writeValue(value[index]);
- }
- this->document_ += ']';
- } break;
- case objectValue: {
- Value::Members members(value.getMemberNames());
- this->document_ += '{';
- for (Value::Members::iterator it = members.begin(); it != members.end();
- ++it) {
- const JSONCPP_STRING& name = *it;
- if (it != members.begin())
- this->document_ += ',';
- this->document_ += valueToQuotedStringN(
- name.data(), static_cast<unsigned>(name.length()));
- this->document_ += this->yamlCompatiblityEnabled_ ? ": " : ":";
- this->writeValue(value[name]);
- }
- this->document_ += '}';
- } break;
+ document_ += ']';
+ } break;
+ case objectValue: {
+ Value::Members members(value.getMemberNames());
+ document_ += '{';
+ for (Value::Members::iterator it = members.begin(); it != members.end();
+ ++it) {
+ const JSONCPP_STRING& name = *it;
+ if (it != members.begin())
+ document_ += ',';
+ document_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length()));
+ document_ += yamlCompatiblityEnabled_ ? ": " : ":";
+ writeValue(value[name]);
+ }
+ document_ += '}';
+ } break;
}
}
@@ -474,498 +434,454 @@ void FastWriter::writeValue(const Value& value)
// //////////////////////////////////////////////////////////////////
StyledWriter::StyledWriter()
- : rightMargin_(74)
- , indentSize_(3)
- , addChildValues_()
-{
-}
+ : rightMargin_(74), indentSize_(3), addChildValues_() {}
-JSONCPP_STRING StyledWriter::write(const Value& root)
-{
- this->document_.clear();
- this->addChildValues_ = false;
- this->indentString_.clear();
- this->writeCommentBeforeValue(root);
- this->writeValue(root);
- this->writeCommentAfterValueOnSameLine(root);
- this->document_ += "\n";
- return this->document_;
+JSONCPP_STRING StyledWriter::write(const Value& root) {
+ document_.clear();
+ addChildValues_ = false;
+ indentString_.clear();
+ writeCommentBeforeValue(root);
+ writeValue(root);
+ writeCommentAfterValueOnSameLine(root);
+ document_ += "\n";
+ return document_;
}
-void StyledWriter::writeValue(const Value& value)
-{
+void StyledWriter::writeValue(const Value& value) {
switch (value.type()) {
- case nullValue:
- this->pushValue("null");
- break;
- case intValue:
- this->pushValue(valueToString(value.asLargestInt()));
- break;
- case uintValue:
- this->pushValue(valueToString(value.asLargestUInt()));
- break;
- case realValue:
- this->pushValue(valueToString(value.asDouble()));
- break;
- case stringValue: {
- // Is NULL possible for value.string_? No.
- char const* str;
- char const* end;
- bool ok = value.getString(&str, &end);
- if (ok)
- this->pushValue(
- valueToQuotedStringN(str, static_cast<unsigned>(end - str)));
- else
- this->pushValue("");
- break;
- }
- case booleanValue:
- this->pushValue(valueToString(value.asBool()));
- break;
- case arrayValue:
- this->writeArrayValue(value);
- break;
- case objectValue: {
- Value::Members members(value.getMemberNames());
- if (members.empty())
- this->pushValue("{}");
- else {
- this->writeWithIndent("{");
- this->indent();
- Value::Members::iterator it = members.begin();
- for (;;) {
- const JSONCPP_STRING& name = *it;
- const Value& childValue = value[name];
- this->writeCommentBeforeValue(childValue);
- this->writeWithIndent(valueToQuotedString(name.c_str()));
- this->document_ += " : ";
- this->writeValue(childValue);
- if (++it == members.end()) {
- this->writeCommentAfterValueOnSameLine(childValue);
- break;
- }
- this->document_ += ',';
- this->writeCommentAfterValueOnSameLine(childValue);
+ case nullValue:
+ pushValue("null");
+ break;
+ case intValue:
+ pushValue(valueToString(value.asLargestInt()));
+ break;
+ case uintValue:
+ pushValue(valueToString(value.asLargestUInt()));
+ break;
+ case realValue:
+ pushValue(valueToString(value.asDouble()));
+ break;
+ case stringValue:
+ {
+ // Is NULL possible for value.string_? No.
+ char const* str;
+ char const* end;
+ bool ok = value.getString(&str, &end);
+ if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
+ else pushValue("");
+ break;
+ }
+ case booleanValue:
+ pushValue(valueToString(value.asBool()));
+ break;
+ case arrayValue:
+ writeArrayValue(value);
+ break;
+ case objectValue: {
+ Value::Members members(value.getMemberNames());
+ if (members.empty())
+ pushValue("{}");
+ else {
+ writeWithIndent("{");
+ indent();
+ Value::Members::iterator it = members.begin();
+ for (;;) {
+ const JSONCPP_STRING& name = *it;
+ const Value& childValue = value[name];
+ writeCommentBeforeValue(childValue);
+ writeWithIndent(valueToQuotedString(name.c_str()));
+ document_ += " : ";
+ writeValue(childValue);
+ if (++it == members.end()) {
+ writeCommentAfterValueOnSameLine(childValue);
+ break;
}
- this->unindent();
- this->writeWithIndent("}");
+ document_ += ',';
+ writeCommentAfterValueOnSameLine(childValue);
}
- } break;
+ unindent();
+ writeWithIndent("}");
+ }
+ } break;
}
}
-void StyledWriter::writeArrayValue(const Value& value)
-{
+void StyledWriter::writeArrayValue(const Value& value) {
unsigned size = value.size();
if (size == 0)
- this->pushValue("[]");
+ pushValue("[]");
else {
- bool isArrayMultiLine = this->isMultineArray(value);
+ bool isArrayMultiLine = isMultineArray(value);
if (isArrayMultiLine) {
- this->writeWithIndent("[");
- this->indent();
- bool hasChildValue = !this->childValues_.empty();
+ writeWithIndent("[");
+ indent();
+ bool hasChildValue = !childValues_.empty();
unsigned index = 0;
for (;;) {
const Value& childValue = value[index];
- this->writeCommentBeforeValue(childValue);
+ writeCommentBeforeValue(childValue);
if (hasChildValue)
- this->writeWithIndent(this->childValues_[index]);
+ writeWithIndent(childValues_[index]);
else {
- this->writeIndent();
- this->writeValue(childValue);
+ writeIndent();
+ writeValue(childValue);
}
if (++index == size) {
- this->writeCommentAfterValueOnSameLine(childValue);
+ writeCommentAfterValueOnSameLine(childValue);
break;
}
- this->document_ += ',';
- this->writeCommentAfterValueOnSameLine(childValue);
+ document_ += ',';
+ writeCommentAfterValueOnSameLine(childValue);
}
- this->unindent();
- this->writeWithIndent("]");
+ unindent();
+ writeWithIndent("]");
} else // output on a single line
{
- assert(this->childValues_.size() == size);
- this->document_ += "[ ";
+ assert(childValues_.size() == size);
+ document_ += "[ ";
for (unsigned index = 0; index < size; ++index) {
if (index > 0)
- this->document_ += ", ";
- this->document_ += this->childValues_[index];
+ document_ += ", ";
+ document_ += childValues_[index];
}
- this->document_ += " ]";
+ document_ += " ]";
}
}
}
-bool StyledWriter::isMultineArray(const Value& value)
-{
+bool StyledWriter::isMultineArray(const Value& value) {
ArrayIndex const size = value.size();
- bool isMultiLine = size * 3 >= this->rightMargin_;
- this->childValues_.clear();
+ bool isMultiLine = size * 3 >= rightMargin_;
+ childValues_.clear();
for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
const Value& childValue = value[index];
isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
- childValue.size() > 0);
+ childValue.size() > 0);
}
if (!isMultiLine) // check if line length > max line length
{
- this->childValues_.reserve(size);
- this->addChildValues_ = true;
+ childValues_.reserve(size);
+ addChildValues_ = true;
ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
for (ArrayIndex index = 0; index < size; ++index) {
- if (this->hasCommentForValue(value[index])) {
+ if (hasCommentForValue(value[index])) {
isMultiLine = true;
}
- this->writeValue(value[index]);
- lineLength +=
- static_cast<ArrayIndex>(this->childValues_[index].length());
+ writeValue(value[index]);
+ lineLength += static_cast<ArrayIndex>(childValues_[index].length());
}
- this->addChildValues_ = false;
- isMultiLine = isMultiLine || lineLength >= this->rightMargin_;
+ addChildValues_ = false;
+ isMultiLine = isMultiLine || lineLength >= rightMargin_;
}
return isMultiLine;
}
-void StyledWriter::pushValue(const JSONCPP_STRING& value)
-{
- if (this->addChildValues_)
- this->childValues_.push_back(value);
+void StyledWriter::pushValue(const JSONCPP_STRING& value) {
+ if (addChildValues_)
+ childValues_.push_back(value);
else
- this->document_ += value;
+ document_ += value;
}
-void StyledWriter::writeIndent()
-{
- if (!this->document_.empty()) {
- char last = this->document_[this->document_.length() - 1];
+void StyledWriter::writeIndent() {
+ if (!document_.empty()) {
+ char last = document_[document_.length() - 1];
if (last == ' ') // already indented
return;
if (last != '\n') // Comments may add new-line
- this->document_ += '\n';
+ document_ += '\n';
}
- this->document_ += this->indentString_;
+ document_ += indentString_;
}
-void StyledWriter::writeWithIndent(const JSONCPP_STRING& value)
-{
- this->writeIndent();
- this->document_ += value;
+void StyledWriter::writeWithIndent(const JSONCPP_STRING& value) {
+ writeIndent();
+ document_ += value;
}
-void StyledWriter::indent()
-{
- this->indentString_ += JSONCPP_STRING(this->indentSize_, ' ');
-}
+void StyledWriter::indent() { indentString_ += JSONCPP_STRING(indentSize_, ' '); }
-void StyledWriter::unindent()
-{
- assert(this->indentString_.size() >= this->indentSize_);
- this->indentString_.resize(this->indentString_.size() - this->indentSize_);
+void StyledWriter::unindent() {
+ assert(indentString_.size() >= indentSize_);
+ indentString_.resize(indentString_.size() - indentSize_);
}
-void StyledWriter::writeCommentBeforeValue(const Value& root)
-{
+void StyledWriter::writeCommentBeforeValue(const Value& root) {
if (!root.hasComment(commentBefore))
return;
- this->document_ += "\n";
- this->writeIndent();
+ document_ += "\n";
+ writeIndent();
const JSONCPP_STRING& comment = root.getComment(commentBefore);
JSONCPP_STRING::const_iterator iter = comment.begin();
while (iter != comment.end()) {
- this->document_ += *iter;
- if (*iter == '\n' && (iter != comment.end() && *(iter + 1) == '/'))
- this->writeIndent();
+ document_ += *iter;
+ if (*iter == '\n' &&
+ (iter != comment.end() && *(iter + 1) == '/'))
+ writeIndent();
++iter;
}
// Comments are stripped of trailing newlines, so add one here
- this->document_ += "\n";
+ document_ += "\n";
}
-void StyledWriter::writeCommentAfterValueOnSameLine(const Value& root)
-{
+void StyledWriter::writeCommentAfterValueOnSameLine(const Value& root) {
if (root.hasComment(commentAfterOnSameLine))
- this->document_ += " " + root.getComment(commentAfterOnSameLine);
+ document_ += " " + root.getComment(commentAfterOnSameLine);
if (root.hasComment(commentAfter)) {
- this->document_ += "\n";
- this->document_ += root.getComment(commentAfter);
- this->document_ += "\n";
+ document_ += "\n";
+ document_ += root.getComment(commentAfter);
+ document_ += "\n";
}
}
-bool StyledWriter::hasCommentForValue(const Value& value)
-{
+bool StyledWriter::hasCommentForValue(const Value& value) {
return value.hasComment(commentBefore) ||
- value.hasComment(commentAfterOnSameLine) || value.hasComment(commentAfter);
+ value.hasComment(commentAfterOnSameLine) ||
+ value.hasComment(commentAfter);
}
// Class StyledStreamWriter
// //////////////////////////////////////////////////////////////////
StyledStreamWriter::StyledStreamWriter(JSONCPP_STRING indentation)
- : document_(NULL)
- , rightMargin_(74)
- , indentation_(indentation)
- , addChildValues_()
-{
-}
-
-void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root)
-{
- this->document_ = &out;
- this->addChildValues_ = false;
- this->indentString_.clear();
- this->indented_ = true;
- this->writeCommentBeforeValue(root);
- if (!this->indented_)
- this->writeIndent();
- this->indented_ = true;
- this->writeValue(root);
- this->writeCommentAfterValueOnSameLine(root);
- *this->document_ << "\n";
- this->document_ = NULL; // Forget the stream, for safety.
-}
-
-void StyledStreamWriter::writeValue(const Value& value)
-{
+ : document_(NULL), rightMargin_(74), indentation_(indentation),
+ addChildValues_() {}
+
+void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
+ document_ = &out;
+ addChildValues_ = false;
+ indentString_.clear();
+ indented_ = true;
+ writeCommentBeforeValue(root);
+ if (!indented_) writeIndent();
+ indented_ = true;
+ writeValue(root);
+ writeCommentAfterValueOnSameLine(root);
+ *document_ << "\n";
+ document_ = NULL; // Forget the stream, for safety.
+}
+
+void StyledStreamWriter::writeValue(const Value& value) {
switch (value.type()) {
- case nullValue:
- this->pushValue("null");
- break;
- case intValue:
- this->pushValue(valueToString(value.asLargestInt()));
- break;
- case uintValue:
- this->pushValue(valueToString(value.asLargestUInt()));
- break;
- case realValue:
- this->pushValue(valueToString(value.asDouble()));
- break;
- case stringValue: {
- // Is NULL possible for value.string_? No.
- char const* str;
- char const* end;
- bool ok = value.getString(&str, &end);
- if (ok)
- this->pushValue(
- valueToQuotedStringN(str, static_cast<unsigned>(end - str)));
- else
- this->pushValue("");
- break;
- }
- case booleanValue:
- this->pushValue(valueToString(value.asBool()));
- break;
- case arrayValue:
- this->writeArrayValue(value);
- break;
- case objectValue: {
- Value::Members members(value.getMemberNames());
- if (members.empty())
- this->pushValue("{}");
- else {
- this->writeWithIndent("{");
- this->indent();
- Value::Members::iterator it = members.begin();
- for (;;) {
- const JSONCPP_STRING& name = *it;
- const Value& childValue = value[name];
- this->writeCommentBeforeValue(childValue);
- this->writeWithIndent(valueToQuotedString(name.c_str()));
- *this->document_ << " : ";
- this->writeValue(childValue);
- if (++it == members.end()) {
- this->writeCommentAfterValueOnSameLine(childValue);
- break;
- }
- *this->document_ << ",";
- this->writeCommentAfterValueOnSameLine(childValue);
+ case nullValue:
+ pushValue("null");
+ break;
+ case intValue:
+ pushValue(valueToString(value.asLargestInt()));
+ break;
+ case uintValue:
+ pushValue(valueToString(value.asLargestUInt()));
+ break;
+ case realValue:
+ pushValue(valueToString(value.asDouble()));
+ break;
+ case stringValue:
+ {
+ // Is NULL possible for value.string_? No.
+ char const* str;
+ char const* end;
+ bool ok = value.getString(&str, &end);
+ if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
+ else pushValue("");
+ break;
+ }
+ case booleanValue:
+ pushValue(valueToString(value.asBool()));
+ break;
+ case arrayValue:
+ writeArrayValue(value);
+ break;
+ case objectValue: {
+ Value::Members members(value.getMemberNames());
+ if (members.empty())
+ pushValue("{}");
+ else {
+ writeWithIndent("{");
+ indent();
+ Value::Members::iterator it = members.begin();
+ for (;;) {
+ const JSONCPP_STRING& name = *it;
+ const Value& childValue = value[name];
+ writeCommentBeforeValue(childValue);
+ writeWithIndent(valueToQuotedString(name.c_str()));
+ *document_ << " : ";
+ writeValue(childValue);
+ if (++it == members.end()) {
+ writeCommentAfterValueOnSameLine(childValue);
+ break;
}
- this->unindent();
- this->writeWithIndent("}");
+ *document_ << ",";
+ writeCommentAfterValueOnSameLine(childValue);
}
- } break;
+ unindent();
+ writeWithIndent("}");
+ }
+ } break;
}
}
-void StyledStreamWriter::writeArrayValue(const Value& value)
-{
+void StyledStreamWriter::writeArrayValue(const Value& value) {
unsigned size = value.size();
if (size == 0)
- this->pushValue("[]");
+ pushValue("[]");
else {
- bool isArrayMultiLine = this->isMultineArray(value);
+ bool isArrayMultiLine = isMultineArray(value);
if (isArrayMultiLine) {
- this->writeWithIndent("[");
- this->indent();
- bool hasChildValue = !this->childValues_.empty();
+ writeWithIndent("[");
+ indent();
+ bool hasChildValue = !childValues_.empty();
unsigned index = 0;
for (;;) {
const Value& childValue = value[index];
- this->writeCommentBeforeValue(childValue);
+ writeCommentBeforeValue(childValue);
if (hasChildValue)
- this->writeWithIndent(this->childValues_[index]);
+ writeWithIndent(childValues_[index]);
else {
- if (!this->indented_)
- this->writeIndent();
- this->indented_ = true;
- this->writeValue(childValue);
- this->indented_ = false;
+ if (!indented_) writeIndent();
+ indented_ = true;
+ writeValue(childValue);
+ indented_ = false;
}
if (++index == size) {
- this->writeCommentAfterValueOnSameLine(childValue);
+ writeCommentAfterValueOnSameLine(childValue);
break;
}
- *this->document_ << ",";
- this->writeCommentAfterValueOnSameLine(childValue);
+ *document_ << ",";
+ writeCommentAfterValueOnSameLine(childValue);
}
- this->unindent();
- this->writeWithIndent("]");
+ unindent();
+ writeWithIndent("]");
} else // output on a single line
{
- assert(this->childValues_.size() == size);
- *this->document_ << "[ ";
+ assert(childValues_.size() == size);
+ *document_ << "[ ";
for (unsigned index = 0; index < size; ++index) {
if (index > 0)
- *this->document_ << ", ";
- *this->document_ << this->childValues_[index];
+ *document_ << ", ";
+ *document_ << childValues_[index];
}
- *this->document_ << " ]";
+ *document_ << " ]";
}
}
}
-bool StyledStreamWriter::isMultineArray(const Value& value)
-{
+bool StyledStreamWriter::isMultineArray(const Value& value) {
ArrayIndex const size = value.size();
- bool isMultiLine = size * 3 >= this->rightMargin_;
- this->childValues_.clear();
+ bool isMultiLine = size * 3 >= rightMargin_;
+ childValues_.clear();
for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
const Value& childValue = value[index];
isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
- childValue.size() > 0);
+ childValue.size() > 0);
}
if (!isMultiLine) // check if line length > max line length
{
- this->childValues_.reserve(size);
- this->addChildValues_ = true;
+ childValues_.reserve(size);
+ addChildValues_ = true;
ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
for (ArrayIndex index = 0; index < size; ++index) {
- if (this->hasCommentForValue(value[index])) {
+ if (hasCommentForValue(value[index])) {
isMultiLine = true;
}
- this->writeValue(value[index]);
- lineLength +=
- static_cast<ArrayIndex>(this->childValues_[index].length());
+ writeValue(value[index]);
+ lineLength += static_cast<ArrayIndex>(childValues_[index].length());
}
- this->addChildValues_ = false;
- isMultiLine = isMultiLine || lineLength >= this->rightMargin_;
+ addChildValues_ = false;
+ isMultiLine = isMultiLine || lineLength >= rightMargin_;
}
return isMultiLine;
}
-void StyledStreamWriter::pushValue(const JSONCPP_STRING& value)
-{
- if (this->addChildValues_)
- this->childValues_.push_back(value);
+void StyledStreamWriter::pushValue(const JSONCPP_STRING& value) {
+ if (addChildValues_)
+ childValues_.push_back(value);
else
- *this->document_ << value;
+ *document_ << value;
}
-void StyledStreamWriter::writeIndent()
-{
+void StyledStreamWriter::writeIndent() {
// blep intended this to look at the so-far-written string
// to determine whether we are already indented, but
// with a stream we cannot do that. So we rely on some saved state.
// The caller checks indented_.
- *this->document_ << '\n' << this->indentString_;
+ *document_ << '\n' << indentString_;
}
-void StyledStreamWriter::writeWithIndent(const JSONCPP_STRING& value)
-{
- if (!this->indented_)
- this->writeIndent();
- *this->document_ << value;
- this->indented_ = false;
+void StyledStreamWriter::writeWithIndent(const JSONCPP_STRING& value) {
+ if (!indented_) writeIndent();
+ *document_ << value;
+ indented_ = false;
}
-void StyledStreamWriter::indent()
-{
- this->indentString_ += this->indentation_;
-}
+void StyledStreamWriter::indent() { indentString_ += indentation_; }
-void StyledStreamWriter::unindent()
-{
- assert(this->indentString_.size() >= this->indentation_.size());
- this->indentString_.resize(this->indentString_.size() -
- this->indentation_.size());
+void StyledStreamWriter::unindent() {
+ assert(indentString_.size() >= indentation_.size());
+ indentString_.resize(indentString_.size() - indentation_.size());
}
-void StyledStreamWriter::writeCommentBeforeValue(const Value& root)
-{
+void StyledStreamWriter::writeCommentBeforeValue(const Value& root) {
if (!root.hasComment(commentBefore))
return;
- if (!this->indented_)
- this->writeIndent();
+ if (!indented_) writeIndent();
const JSONCPP_STRING& comment = root.getComment(commentBefore);
JSONCPP_STRING::const_iterator iter = comment.begin();
while (iter != comment.end()) {
- *this->document_ << *iter;
- if (*iter == '\n' && (iter != comment.end() && *(iter + 1) == '/'))
+ *document_ << *iter;
+ if (*iter == '\n' &&
+ (iter != comment.end() && *(iter + 1) == '/'))
// writeIndent(); // would include newline
- *this->document_ << this->indentString_;
+ *document_ << indentString_;
++iter;
}
- this->indented_ = false;
+ indented_ = false;
}
-void StyledStreamWriter::writeCommentAfterValueOnSameLine(const Value& root)
-{
+void StyledStreamWriter::writeCommentAfterValueOnSameLine(const Value& root) {
if (root.hasComment(commentAfterOnSameLine))
- *this->document_ << ' ' << root.getComment(commentAfterOnSameLine);
+ *document_ << ' ' << root.getComment(commentAfterOnSameLine);
if (root.hasComment(commentAfter)) {
- this->writeIndent();
- *this->document_ << root.getComment(commentAfter);
+ writeIndent();
+ *document_ << root.getComment(commentAfter);
}
- this->indented_ = false;
+ indented_ = false;
}
-bool StyledStreamWriter::hasCommentForValue(const Value& value)
-{
+bool StyledStreamWriter::hasCommentForValue(const Value& value) {
return value.hasComment(commentBefore) ||
- value.hasComment(commentAfterOnSameLine) || value.hasComment(commentAfter);
+ value.hasComment(commentAfterOnSameLine) ||
+ value.hasComment(commentAfter);
}
//////////////////////////
// BuiltStyledStreamWriter
/// Scoped enums are not available until C++11.
-struct CommentStyle
-{
+struct CommentStyle {
/// Decide whether to write comments.
- enum Enum
- {
- None, ///< Drop all comments.
- Most, ///< Recover odd behavior of previous versions (not implemented yet).
- All ///< Keep all comments.
+ enum Enum {
+ None, ///< Drop all comments.
+ Most, ///< Recover odd behavior of previous versions (not implemented yet).
+ All ///< Keep all comments.
};
};
struct BuiltStyledStreamWriter : public StreamWriter
{
- BuiltStyledStreamWriter(JSONCPP_STRING const& indentation,
- CommentStyle::Enum cs,
- JSONCPP_STRING const& colonSymbol,
- JSONCPP_STRING const& nullSymbol,
- JSONCPP_STRING const& endingLineFeedSymbol,
- bool useSpecialFloats, unsigned int precision);
+ BuiltStyledStreamWriter(
+ JSONCPP_STRING const& indentation,
+ CommentStyle::Enum cs,
+ JSONCPP_STRING const& colonSymbol,
+ JSONCPP_STRING const& nullSymbol,
+ JSONCPP_STRING const& endingLineFeedSymbol,
+ bool useSpecialFloats,
+ unsigned int precision);
int write(Value const& root, JSONCPP_OSTREAM* sout) JSONCPP_OVERRIDE;
-
private:
void writeValue(Value const& value);
void writeArrayValue(Value const& value);
@@ -995,10 +911,13 @@ private:
unsigned int precision_;
};
BuiltStyledStreamWriter::BuiltStyledStreamWriter(
- JSONCPP_STRING const& indentation, CommentStyle::Enum cs,
- JSONCPP_STRING const& colonSymbol, JSONCPP_STRING const& nullSymbol,
- JSONCPP_STRING const& endingLineFeedSymbol, bool useSpecialFloats,
- unsigned int precision)
+ JSONCPP_STRING const& indentation,
+ CommentStyle::Enum cs,
+ JSONCPP_STRING const& colonSymbol,
+ JSONCPP_STRING const& nullSymbol,
+ JSONCPP_STRING const& endingLineFeedSymbol,
+ bool useSpecialFloats,
+ unsigned int precision)
: rightMargin_(74)
, indentation_(indentation)
, cs_(cs)
@@ -1013,276 +932,247 @@ BuiltStyledStreamWriter::BuiltStyledStreamWriter(
}
int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout)
{
- this->sout_ = sout;
- this->addChildValues_ = false;
- this->indented_ = true;
- this->indentString_.clear();
- this->writeCommentBeforeValue(root);
- if (!this->indented_)
- this->writeIndent();
- this->indented_ = true;
- this->writeValue(root);
- this->writeCommentAfterValueOnSameLine(root);
- *this->sout_ << this->endingLineFeedSymbol_;
- this->sout_ = NULL;
+ sout_ = sout;
+ addChildValues_ = false;
+ indented_ = true;
+ indentString_.clear();
+ writeCommentBeforeValue(root);
+ if (!indented_) writeIndent();
+ indented_ = true;
+ writeValue(root);
+ writeCommentAfterValueOnSameLine(root);
+ *sout_ << endingLineFeedSymbol_;
+ sout_ = NULL;
return 0;
}
-void BuiltStyledStreamWriter::writeValue(Value const& value)
-{
+void BuiltStyledStreamWriter::writeValue(Value const& value) {
switch (value.type()) {
- case nullValue:
- this->pushValue(this->nullSymbol_);
- break;
- case intValue:
- this->pushValue(valueToString(value.asLargestInt()));
- break;
- case uintValue:
- this->pushValue(valueToString(value.asLargestUInt()));
- break;
- case realValue:
- this->pushValue(valueToString(value.asDouble(), this->useSpecialFloats_,
- this->precision_));
- break;
- case stringValue: {
- // Is NULL is possible for value.string_? No.
- char const* str;
- char const* end;
- bool ok = value.getString(&str, &end);
- if (ok)
- this->pushValue(
- valueToQuotedStringN(str, static_cast<unsigned>(end - str)));
- else
- this->pushValue("");
- break;
- }
- case booleanValue:
- this->pushValue(valueToString(value.asBool()));
- break;
- case arrayValue:
- this->writeArrayValue(value);
- break;
- case objectValue: {
- Value::Members members(value.getMemberNames());
- if (members.empty())
- this->pushValue("{}");
- else {
- this->writeWithIndent("{");
- this->indent();
- Value::Members::iterator it = members.begin();
- for (;;) {
- JSONCPP_STRING const& name = *it;
- Value const& childValue = value[name];
- this->writeCommentBeforeValue(childValue);
- this->writeWithIndent(valueToQuotedStringN(
- name.data(), static_cast<unsigned>(name.length())));
- *this->sout_ << this->colonSymbol_;
- this->writeValue(childValue);
- if (++it == members.end()) {
- this->writeCommentAfterValueOnSameLine(childValue);
- break;
- }
- *this->sout_ << ",";
- this->writeCommentAfterValueOnSameLine(childValue);
+ case nullValue:
+ pushValue(nullSymbol_);
+ break;
+ case intValue:
+ pushValue(valueToString(value.asLargestInt()));
+ break;
+ case uintValue:
+ pushValue(valueToString(value.asLargestUInt()));
+ break;
+ case realValue:
+ pushValue(valueToString(value.asDouble(), useSpecialFloats_, precision_));
+ break;
+ case stringValue:
+ {
+ // Is NULL is possible for value.string_? No.
+ char const* str;
+ char const* end;
+ bool ok = value.getString(&str, &end);
+ if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
+ else pushValue("");
+ break;
+ }
+ case booleanValue:
+ pushValue(valueToString(value.asBool()));
+ break;
+ case arrayValue:
+ writeArrayValue(value);
+ break;
+ case objectValue: {
+ Value::Members members(value.getMemberNames());
+ if (members.empty())
+ pushValue("{}");
+ else {
+ writeWithIndent("{");
+ indent();
+ Value::Members::iterator it = members.begin();
+ for (;;) {
+ JSONCPP_STRING const& name = *it;
+ Value const& childValue = value[name];
+ writeCommentBeforeValue(childValue);
+ writeWithIndent(valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length())));
+ *sout_ << colonSymbol_;
+ writeValue(childValue);
+ if (++it == members.end()) {
+ writeCommentAfterValueOnSameLine(childValue);
+ break;
}
- this->unindent();
- this->writeWithIndent("}");
+ *sout_ << ",";
+ writeCommentAfterValueOnSameLine(childValue);
}
- } break;
+ unindent();
+ writeWithIndent("}");
+ }
+ } break;
}
}
-void BuiltStyledStreamWriter::writeArrayValue(Value const& value)
-{
+void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
unsigned size = value.size();
if (size == 0)
- this->pushValue("[]");
+ pushValue("[]");
else {
- bool isMultiLine =
- (this->cs_ == CommentStyle::All) || this->isMultineArray(value);
+ bool isMultiLine = (cs_ == CommentStyle::All) || isMultineArray(value);
if (isMultiLine) {
- this->writeWithIndent("[");
- this->indent();
- bool hasChildValue = !this->childValues_.empty();
+ writeWithIndent("[");
+ indent();
+ bool hasChildValue = !childValues_.empty();
unsigned index = 0;
for (;;) {
Value const& childValue = value[index];
- this->writeCommentBeforeValue(childValue);
+ writeCommentBeforeValue(childValue);
if (hasChildValue)
- this->writeWithIndent(this->childValues_[index]);
+ writeWithIndent(childValues_[index]);
else {
- if (!this->indented_)
- this->writeIndent();
- this->indented_ = true;
- this->writeValue(childValue);
- this->indented_ = false;
+ if (!indented_) writeIndent();
+ indented_ = true;
+ writeValue(childValue);
+ indented_ = false;
}
if (++index == size) {
- this->writeCommentAfterValueOnSameLine(childValue);
+ writeCommentAfterValueOnSameLine(childValue);
break;
}
- *this->sout_ << ",";
- this->writeCommentAfterValueOnSameLine(childValue);
+ *sout_ << ",";
+ writeCommentAfterValueOnSameLine(childValue);
}
- this->unindent();
- this->writeWithIndent("]");
+ unindent();
+ writeWithIndent("]");
} else // output on a single line
{
- assert(this->childValues_.size() == size);
- *this->sout_ << "[";
- if (!this->indentation_.empty())
- *this->sout_ << " ";
+ assert(childValues_.size() == size);
+ *sout_ << "[";
+ if (!indentation_.empty()) *sout_ << " ";
for (unsigned index = 0; index < size; ++index) {
if (index > 0)
- *this->sout_ << ((!this->indentation_.empty()) ? ", " : ",");
- *this->sout_ << this->childValues_[index];
+ *sout_ << ((!indentation_.empty()) ? ", " : ",");
+ *sout_ << childValues_[index];
}
- if (!this->indentation_.empty())
- *this->sout_ << " ";
- *this->sout_ << "]";
+ if (!indentation_.empty()) *sout_ << " ";
+ *sout_ << "]";
}
}
}
-bool BuiltStyledStreamWriter::isMultineArray(Value const& value)
-{
+bool BuiltStyledStreamWriter::isMultineArray(Value const& value) {
ArrayIndex const size = value.size();
- bool isMultiLine = size * 3 >= this->rightMargin_;
- this->childValues_.clear();
+ bool isMultiLine = size * 3 >= rightMargin_;
+ childValues_.clear();
for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
Value const& childValue = value[index];
isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
- childValue.size() > 0);
+ childValue.size() > 0);
}
if (!isMultiLine) // check if line length > max line length
{
- this->childValues_.reserve(size);
- this->addChildValues_ = true;
+ childValues_.reserve(size);
+ addChildValues_ = true;
ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
for (ArrayIndex index = 0; index < size; ++index) {
if (hasCommentForValue(value[index])) {
isMultiLine = true;
}
- this->writeValue(value[index]);
- lineLength +=
- static_cast<ArrayIndex>(this->childValues_[index].length());
+ writeValue(value[index]);
+ lineLength += static_cast<ArrayIndex>(childValues_[index].length());
}
- this->addChildValues_ = false;
- isMultiLine = isMultiLine || lineLength >= this->rightMargin_;
+ addChildValues_ = false;
+ isMultiLine = isMultiLine || lineLength >= rightMargin_;
}
return isMultiLine;
}
-void BuiltStyledStreamWriter::pushValue(JSONCPP_STRING const& value)
-{
- if (this->addChildValues_)
- this->childValues_.push_back(value);
+void BuiltStyledStreamWriter::pushValue(JSONCPP_STRING const& value) {
+ if (addChildValues_)
+ childValues_.push_back(value);
else
- *this->sout_ << value;
+ *sout_ << value;
}
-void BuiltStyledStreamWriter::writeIndent()
-{
+void BuiltStyledStreamWriter::writeIndent() {
// blep intended this to look at the so-far-written string
// to determine whether we are already indented, but
// with a stream we cannot do that. So we rely on some saved state.
// The caller checks indented_.
- if (!this->indentation_.empty()) {
+ if (!indentation_.empty()) {
// In this case, drop newlines too.
- *this->sout_ << '\n' << this->indentString_;
+ *sout_ << '\n' << indentString_;
}
}
-void BuiltStyledStreamWriter::writeWithIndent(JSONCPP_STRING const& value)
-{
- if (!this->indented_)
- this->writeIndent();
- *this->sout_ << value;
- this->indented_ = false;
+void BuiltStyledStreamWriter::writeWithIndent(JSONCPP_STRING const& value) {
+ if (!indented_) writeIndent();
+ *sout_ << value;
+ indented_ = false;
}
-void BuiltStyledStreamWriter::indent()
-{
- this->indentString_ += this->indentation_;
-}
+void BuiltStyledStreamWriter::indent() { indentString_ += indentation_; }
-void BuiltStyledStreamWriter::unindent()
-{
- assert(this->indentString_.size() >= this->indentation_.size());
- this->indentString_.resize(this->indentString_.size() -
- this->indentation_.size());
+void BuiltStyledStreamWriter::unindent() {
+ assert(indentString_.size() >= indentation_.size());
+ indentString_.resize(indentString_.size() - indentation_.size());
}
-void BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root)
-{
- if (this->cs_ == CommentStyle::None)
- return;
+void BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root) {
+ if (cs_ == CommentStyle::None) return;
if (!root.hasComment(commentBefore))
return;
- if (!this->indented_)
- this->writeIndent();
+ if (!indented_) writeIndent();
const JSONCPP_STRING& comment = root.getComment(commentBefore);
JSONCPP_STRING::const_iterator iter = comment.begin();
while (iter != comment.end()) {
- *this->sout_ << *iter;
- if (*iter == '\n' && (iter != comment.end() && *(iter + 1) == '/'))
+ *sout_ << *iter;
+ if (*iter == '\n' &&
+ (iter != comment.end() && *(iter + 1) == '/'))
// writeIndent(); // would write extra newline
- *this->sout_ << this->indentString_;
+ *sout_ << indentString_;
++iter;
}
- this->indented_ = false;
+ indented_ = false;
}
-void BuiltStyledStreamWriter::writeCommentAfterValueOnSameLine(
- Value const& root)
-{
- if (this->cs_ == CommentStyle::None)
- return;
+void BuiltStyledStreamWriter::writeCommentAfterValueOnSameLine(Value const& root) {
+ if (cs_ == CommentStyle::None) return;
if (root.hasComment(commentAfterOnSameLine))
- *this->sout_ << " " + root.getComment(commentAfterOnSameLine);
+ *sout_ << " " + root.getComment(commentAfterOnSameLine);
if (root.hasComment(commentAfter)) {
- this->writeIndent();
- *this->sout_ << root.getComment(commentAfter);
+ writeIndent();
+ *sout_ << root.getComment(commentAfter);
}
}
// static
-bool BuiltStyledStreamWriter::hasCommentForValue(const Value& value)
-{
+bool BuiltStyledStreamWriter::hasCommentForValue(const Value& value) {
return value.hasComment(commentBefore) ||
- value.hasComment(commentAfterOnSameLine) || value.hasComment(commentAfter);
+ value.hasComment(commentAfterOnSameLine) ||
+ value.hasComment(commentAfter);
}
///////////////
// StreamWriter
StreamWriter::StreamWriter()
- : sout_(NULL)
+ : sout_(NULL)
{
}
StreamWriter::~StreamWriter()
{
}
StreamWriter::Factory::~Factory()
-{
-}
+{}
StreamWriterBuilder::StreamWriterBuilder()
{
- setDefaults(&this->settings_);
+ setDefaults(&settings_);
}
StreamWriterBuilder::~StreamWriterBuilder()
-{
-}
+{}
StreamWriter* StreamWriterBuilder::newStreamWriter() const
{
- JSONCPP_STRING indentation = this->settings_["indentation"].asString();
- JSONCPP_STRING cs_str = this->settings_["commentStyle"].asString();
- bool eyc = this->settings_["enableYAMLCompatibility"].asBool();
- bool dnp = this->settings_["dropNullPlaceholders"].asBool();
- bool usf = this->settings_["useSpecialFloats"].asBool();
- unsigned int pre = this->settings_["precision"].asUInt();
+ JSONCPP_STRING indentation = settings_["indentation"].asString();
+ JSONCPP_STRING cs_str = settings_["commentStyle"].asString();
+ bool eyc = settings_["enableYAMLCompatibility"].asBool();
+ bool dnp = settings_["dropNullPlaceholders"].asBool();
+ bool usf = settings_["useSpecialFloats"].asBool();
+ unsigned int pre = settings_["precision"].asUInt();
CommentStyle::Enum cs = CommentStyle::All;
if (cs_str == "All") {
cs = CommentStyle::All;
@@ -1301,11 +1191,11 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
if (dnp) {
nullSymbol.clear();
}
- if (pre > 17)
- pre = 17;
+ if (pre > 17) pre = 17;
JSONCPP_STRING endingLineFeedSymbol;
- return new BuiltStyledStreamWriter(indentation, cs, colonSymbol, nullSymbol,
- endingLineFeedSymbol, usf, pre);
+ return new BuiltStyledStreamWriter(
+ indentation, cs,
+ colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);
}
static void getValidWriterKeys(std::set<JSONCPP_STRING>* valid_keys)
{
@@ -1320,24 +1210,23 @@ static void getValidWriterKeys(std::set<JSONCPP_STRING>* valid_keys)
bool StreamWriterBuilder::validate(Json::Value* invalid) const
{
Json::Value my_invalid;
- if (!invalid)
- invalid = &my_invalid; // so we do not need to test for NULL
+ if (!invalid) invalid = &my_invalid; // so we do not need to test for NULL
Json::Value& inv = *invalid;
std::set<JSONCPP_STRING> valid_keys;
getValidWriterKeys(&valid_keys);
- Value::Members keys = this->settings_.getMemberNames();
+ Value::Members keys = settings_.getMemberNames();
size_t n = keys.size();
for (size_t i = 0; i < n; ++i) {
JSONCPP_STRING const& key = keys[i];
if (valid_keys.find(key) == valid_keys.end()) {
- inv[key] = this->settings_[key];
+ inv[key] = settings_[key];
}
}
return 0u == inv.size();
}
Value& StreamWriterBuilder::operator[](JSONCPP_STRING key)
{
- return this->settings_[key];
+ return settings_[key];
}
// static
void StreamWriterBuilder::setDefaults(Json::Value* settings)
@@ -1352,17 +1241,14 @@ void StreamWriterBuilder::setDefaults(Json::Value* settings)
//! [StreamWriterBuilderDefaults]
}
-JSONCPP_STRING writeString(StreamWriter::Factory const& builder,
- Value const& root)
-{
+JSONCPP_STRING writeString(StreamWriter::Factory const& builder, Value const& root) {
JSONCPP_OSTRINGSTREAM sout;
StreamWriterPtr const writer(builder.newStreamWriter());
writer->write(root, &sout);
return sout.str();
}
-JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM& sout, Value const& root)
-{
+JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM& sout, Value const& root) {
StreamWriterBuilder builder;
StreamWriterPtr const writer(builder.newStreamWriter());
writer->write(root, &sout);