mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-15 15:16:47 +02:00
Compare commits
50 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5defb4ed1a | ||
![]() |
c4904b2c0d | ||
![]() |
54a5432c01 | ||
![]() |
b22302e560 | ||
![]() |
29f9853455 | ||
![]() |
fa747b1ae3 | ||
![]() |
94a6220f7c | ||
![]() |
c39fbdac0f | ||
![]() |
65bb1b1c1d | ||
![]() |
375a1119f8 | ||
![]() |
5fabc5e6d2 | ||
![]() |
ed1ab7ac45 | ||
![]() |
bb34617267 | ||
![]() |
993e4e2828 | ||
![]() |
2af4a4c6c8 | ||
![]() |
a3914b792f | ||
![]() |
cee42e0bd7 | ||
![]() |
62f3e03475 | ||
![]() |
b640795571 | ||
![]() |
94cda30dbd | ||
![]() |
1ee39a6752 | ||
![]() |
b1bd848241 | ||
![]() |
09c5ecd84f | ||
![]() |
fda274ddd2 | ||
![]() |
da9e17d257 | ||
![]() |
ac2870298e | ||
![]() |
c9a976238b | ||
![]() |
eab8ebe644 | ||
![]() |
fe9663e7ed | ||
![]() |
5c4219b8ae | ||
![]() |
be4a512887 | ||
![]() |
940982438d | ||
![]() |
8954092f0a | ||
![]() |
ceae0e3867 | ||
![]() |
30170d651c | ||
![]() |
5f4e10462f | ||
![]() |
bb9db78fe2 | ||
![]() |
1664b6bbf8 | ||
![]() |
5d1cb30e40 | ||
![]() |
c60ebf787a | ||
![]() |
72db276986 | ||
![]() |
9059f5cad0 | ||
![]() |
45733df96c | ||
![]() |
5be07bdc5e | ||
![]() |
bf0cfa5b46 | ||
![]() |
cfc1ad72ad | ||
![]() |
c8453d39d1 | ||
![]() |
632044ad95 | ||
![]() |
b3189a0800 | ||
![]() |
9be5895985 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -10,6 +10,7 @@
|
|||||||
/libs/
|
/libs/
|
||||||
/doc/doxyfile
|
/doc/doxyfile
|
||||||
/dist/
|
/dist/
|
||||||
|
/.cache/
|
||||||
|
|
||||||
# MSVC project files:
|
# MSVC project files:
|
||||||
*.sln
|
*.sln
|
||||||
@@ -28,9 +29,9 @@
|
|||||||
|
|
||||||
# CMake-generated files:
|
# CMake-generated files:
|
||||||
CMakeFiles/
|
CMakeFiles/
|
||||||
*.cmake
|
|
||||||
/pkg-config/jsoncpp.pc
|
/pkg-config/jsoncpp.pc
|
||||||
jsoncpp_lib_static.dir/
|
jsoncpp_lib_static.dir/
|
||||||
|
compile_commands.json
|
||||||
|
|
||||||
# In case someone runs cmake in the root-dir:
|
# In case someone runs cmake in the root-dir:
|
||||||
/CMakeCache.txt
|
/CMakeCache.txt
|
||||||
@@ -51,3 +52,6 @@ jsoncpp_lib_static.dir/
|
|||||||
|
|
||||||
# DS_Store
|
# DS_Store
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# temps
|
||||||
|
/version
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# Build matrix / environment variables are explained on:
|
# Build matrix / environment variables are explained on:
|
||||||
# http://about.travis-ci.org/docs/user/build-configuration/
|
# http://about.travis-ci.com/docs/user/build-configuration/
|
||||||
# This file can be validated on: http://www.yamllint.com/
|
# This file can be validated on: http://www.yamllint.com/
|
||||||
# Or using the Ruby based travel command line tool:
|
# Or using the Ruby based travel command line tool:
|
||||||
# gem install travis --no-rdoc --no-ri
|
# gem install travis --no-rdoc --no-ri
|
||||||
@@ -22,8 +22,6 @@ addons:
|
|||||||
- clang-8
|
- clang-8
|
||||||
- valgrind
|
- valgrind
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
|
||||||
- os: osx
|
|
||||||
include:
|
include:
|
||||||
- name: Mac clang meson static release testing
|
- name: Mac clang meson static release testing
|
||||||
os: osx
|
os: osx
|
||||||
@@ -44,6 +42,8 @@ matrix:
|
|||||||
CC="clang"
|
CC="clang"
|
||||||
LIB_TYPE=static
|
LIB_TYPE=static
|
||||||
BUILD_TYPE=release
|
BUILD_TYPE=release
|
||||||
|
PYTHONUSERBASE="$(pwd)/LOCAL"
|
||||||
|
PATH="$PYTHONUSERBASE/bin:$PATH"
|
||||||
# before_install and install steps only needed for linux meson builds
|
# before_install and install steps only needed for linux meson builds
|
||||||
before_install:
|
before_install:
|
||||||
- source ./.travis_scripts/travis.before_install.${TRAVIS_OS_NAME}.sh
|
- source ./.travis_scripts/travis.before_install.${TRAVIS_OS_NAME}.sh
|
||||||
|
@@ -66,7 +66,7 @@ cmake --version
|
|||||||
echo ${CXX}
|
echo ${CXX}
|
||||||
${CXX} --version
|
${CXX} --version
|
||||||
_COMPILER_NAME=`basename ${CXX}`
|
_COMPILER_NAME=`basename ${CXX}`
|
||||||
if [ "${BUILD_TYPE}" == "shared" ]; then
|
if [ "${LIB_TYPE}" = "shared" ]; then
|
||||||
_CMAKE_BUILD_SHARED_LIBS=ON
|
_CMAKE_BUILD_SHARED_LIBS=ON
|
||||||
else
|
else
|
||||||
_CMAKE_BUILD_SHARED_LIBS=OFF
|
_CMAKE_BUILD_SHARED_LIBS=OFF
|
||||||
|
@@ -64,7 +64,7 @@ ninja --version
|
|||||||
_COMPILER_NAME=`basename ${CXX}`
|
_COMPILER_NAME=`basename ${CXX}`
|
||||||
_BUILD_DIR_NAME="build-${BUILD_TYPE}_${LIB_TYPE}_${_COMPILER_NAME}"
|
_BUILD_DIR_NAME="build-${BUILD_TYPE}_${LIB_TYPE}_${_COMPILER_NAME}"
|
||||||
|
|
||||||
./.travis_scripts/run-clang-format.sh
|
#./.travis_scripts/run-clang-format.sh
|
||||||
meson --fatal-meson-warnings --werror --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . "${_BUILD_DIR_NAME}"
|
meson --fatal-meson-warnings --werror --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . "${_BUILD_DIR_NAME}"
|
||||||
ninja -v -j 2 -C "${_BUILD_DIR_NAME}"
|
ninja -v -j 2 -C "${_BUILD_DIR_NAME}"
|
||||||
|
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
# NOTHING TO DO HERE
|
|
||||||
|
@@ -1,10 +1,5 @@
|
|||||||
set -vex
|
set -vex
|
||||||
|
|
||||||
wget https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-linux.zip
|
pip3 install --user meson ninja
|
||||||
unzip -q ninja-linux.zip -d build
|
which meson
|
||||||
|
which ninja
|
||||||
pip3 install meson
|
|
||||||
echo ${PATH}
|
|
||||||
ls /usr/local
|
|
||||||
ls /usr/local/bin
|
|
||||||
export PATH="${PWD}"/build:/usr/local/bin:/usr/bin:${PATH}
|
|
||||||
|
37
BUILD.bazel
Normal file
37
BUILD.bazel
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
licenses(["unencumbered"]) # Public Domain or MIT
|
||||||
|
|
||||||
|
exports_files(["LICENSE"])
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "jsoncpp",
|
||||||
|
srcs = [
|
||||||
|
"src/lib_json/json_reader.cpp",
|
||||||
|
"src/lib_json/json_tool.h",
|
||||||
|
"src/lib_json/json_value.cpp",
|
||||||
|
"src/lib_json/json_writer.cpp",
|
||||||
|
],
|
||||||
|
hdrs = [
|
||||||
|
"include/json/allocator.h",
|
||||||
|
"include/json/assertions.h",
|
||||||
|
"include/json/config.h",
|
||||||
|
"include/json/json_features.h",
|
||||||
|
"include/json/forwards.h",
|
||||||
|
"include/json/json.h",
|
||||||
|
"include/json/reader.h",
|
||||||
|
"include/json/value.h",
|
||||||
|
"include/json/version.h",
|
||||||
|
"include/json/writer.h",
|
||||||
|
],
|
||||||
|
copts = [
|
||||||
|
"-DJSON_USE_EXCEPTION=0",
|
||||||
|
"-DJSON_HAS_INT64",
|
||||||
|
],
|
||||||
|
includes = ["include"],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
deps = [":private"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "private",
|
||||||
|
textual_hdrs = ["src/lib_json/json_valueiterator.inl"],
|
||||||
|
)
|
@@ -22,6 +22,9 @@ else()
|
|||||||
set(JSONCPP_CMAKE_POLICY_VERSION "${JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION}")
|
set(JSONCPP_CMAKE_POLICY_VERSION "${JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION}")
|
||||||
endif()
|
endif()
|
||||||
cmake_policy(VERSION ${JSONCPP_CMAKE_POLICY_VERSION})
|
cmake_policy(VERSION ${JSONCPP_CMAKE_POLICY_VERSION})
|
||||||
|
if(POLICY CMP0091)
|
||||||
|
cmake_policy(SET CMP0091 NEW)
|
||||||
|
endif()
|
||||||
#
|
#
|
||||||
# Now enumerate specific policies newer than JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION
|
# Now enumerate specific policies newer than JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION
|
||||||
# that may need to be individually set to NEW/OLD
|
# that may need to be individually set to NEW/OLD
|
||||||
@@ -49,6 +52,8 @@ if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
|
|||||||
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage.")
|
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# use ccache if found, has to be done before project()
|
# use ccache if found, has to be done before project()
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -59,19 +64,22 @@ if(CCACHE_EXECUTABLE)
|
|||||||
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}" CACHE PATH "ccache" FORCE)
|
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXECUTABLE}" CACHE PATH "ccache" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(JSONCPP
|
project(jsoncpp
|
||||||
# Note: version must be updated in three places when doing a release. This
|
# Note: version must be updated in three places when doing a release. This
|
||||||
# annoying process ensures that amalgamate, CMake, and meson all report the
|
# annoying process ensures that amalgamate, CMake, and meson all report the
|
||||||
# correct version.
|
# correct version.
|
||||||
# 1. ./meson.build
|
# 1. ./meson.build
|
||||||
# 2. ./include/json/version.h
|
# 2. ./include/json/version.h
|
||||||
# 3. ./CMakeLists.txt
|
# 3. ./CMakeLists.txt
|
||||||
# IMPORTANT: also update the JSONCPP_SOVERSION!!
|
# IMPORTANT: also update the PROJECT_SOVERSION!!
|
||||||
VERSION 1.9.3 # <major>[.<minor>[.<patch>[.<tweak>]]]
|
VERSION 1.9.5 # <major>[.<minor>[.<patch>[.<tweak>]]]
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
|
|
||||||
message(STATUS "JsonCpp Version: ${JSONCPP_VERSION_MAJOR}.${JSONCPP_VERSION_MINOR}.${JSONCPP_VERSION_PATCH}")
|
message(STATUS "JsonCpp Version: ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
||||||
set(JSONCPP_SOVERSION 24)
|
set(PROJECT_SOVERSION 25)
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInSourceBuilds.cmake)
|
||||||
|
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInBuildInstalls.cmake)
|
||||||
|
|
||||||
option(JSONCPP_WITH_TESTS "Compile and (for jsoncpp_check) run JsonCpp test executables" ON)
|
option(JSONCPP_WITH_TESTS "Compile and (for jsoncpp_check) run JsonCpp test executables" ON)
|
||||||
option(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON)
|
option(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON)
|
||||||
@@ -80,7 +88,10 @@ option(JSONCPP_WITH_STRICT_ISO "Issue all the warnings demanded by strict ISO C
|
|||||||
option(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON)
|
option(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON)
|
||||||
option(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" ON)
|
option(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" ON)
|
||||||
option(JSONCPP_WITH_EXAMPLE "Compile JsonCpp example" OFF)
|
option(JSONCPP_WITH_EXAMPLE "Compile JsonCpp example" OFF)
|
||||||
option(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." OFF)
|
option(JSONCPP_STATIC_WINDOWS_RUNTIME "Use static (MT/MTd) Windows runtime" OFF)
|
||||||
|
option(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." ON)
|
||||||
|
option(BUILD_STATIC_LIBS "Build jsoncpp_lib as a static library." ON)
|
||||||
|
option(BUILD_OBJECT_LIBS "Build jsoncpp_lib as a object library." ON)
|
||||||
|
|
||||||
# Adhere to GNU filesystem layout conventions
|
# Adhere to GNU filesystem layout conventions
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
@@ -116,11 +127,18 @@ if(MSVC)
|
|||||||
# Only enabled in debug because some old versions of VS STL generate
|
# Only enabled in debug because some old versions of VS STL generate
|
||||||
# unreachable code warning when compiled in release configuration.
|
# unreachable code warning when compiled in release configuration.
|
||||||
add_compile_options($<$<CONFIG:Debug>:/W4>)
|
add_compile_options($<$<CONFIG:Debug>:/W4>)
|
||||||
|
if (JSONCPP_STATIC_WINDOWS_RUNTIME)
|
||||||
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
# using regular Clang or AppleClang
|
# using regular Clang or AppleClang
|
||||||
add_compile_options(-Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare)
|
add_compile_options(-Wall -Wconversion -Wshadow)
|
||||||
|
|
||||||
|
if(JSONCPP_WITH_WARNING_AS_ERROR)
|
||||||
|
add_compile_options(-Werror=conversion -Werror=sign-compare)
|
||||||
|
endif()
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
# using GCC
|
# using GCC
|
||||||
add_compile_options(-Wall -Wconversion -Wshadow -Wextra)
|
add_compile_options(-Wall -Wconversion -Wshadow -Wextra)
|
||||||
@@ -134,9 +152,11 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|||||||
endif()
|
endif()
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||||
# using Intel compiler
|
# using Intel compiler
|
||||||
add_compile_options(-Wall -Wconversion -Wshadow -Wextra -Werror=conversion)
|
add_compile_options(-Wall -Wconversion -Wshadow -Wextra)
|
||||||
|
|
||||||
if(JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR)
|
if(JSONCPP_WITH_WARNING_AS_ERROR)
|
||||||
|
add_compile_options(-Werror=conversion)
|
||||||
|
elseif(JSONCPP_WITH_STRICT_ISO)
|
||||||
add_compile_options(-Wpedantic)
|
add_compile_options(-Wpedantic)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@@ -146,6 +166,11 @@ if(JSONCPP_WITH_WARNING_AS_ERROR)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(JSONCPP_WITH_PKGCONFIG_SUPPORT)
|
if(JSONCPP_WITH_PKGCONFIG_SUPPORT)
|
||||||
|
include(JoinPaths)
|
||||||
|
|
||||||
|
join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
"pkg-config/jsoncpp.pc.in"
|
"pkg-config/jsoncpp.pc.in"
|
||||||
"pkg-config/jsoncpp.pc"
|
"pkg-config/jsoncpp.pc"
|
||||||
@@ -158,11 +183,16 @@ if(JSONCPP_WITH_CMAKE_PACKAGE)
|
|||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
install(EXPORT jsoncpp
|
install(EXPORT jsoncpp
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp
|
||||||
FILE jsoncppConfig.cmake)
|
FILE jsoncpp-targets.cmake)
|
||||||
|
configure_package_config_file(jsoncppConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfig.cmake
|
||||||
|
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp)
|
||||||
|
|
||||||
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake"
|
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake"
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
COMPATIBILITY SameMajorVersion)
|
COMPATIBILITY SameMajorVersion)
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake
|
install(FILES
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfig.cmake
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/jsoncpp-namespaced-targets.cmake
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp)
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ If you wish to install to a directory other than /usr/local, set an environment
|
|||||||
DESTDIR=/path/to/install/dir
|
DESTDIR=/path/to/install/dir
|
||||||
|
|
||||||
Then,
|
Then,
|
||||||
|
```sh
|
||||||
cd jsoncpp/
|
cd jsoncpp/
|
||||||
BUILD_TYPE=debug
|
BUILD_TYPE=debug
|
||||||
#BUILD_TYPE=release
|
#BUILD_TYPE=release
|
||||||
@@ -35,6 +35,7 @@ Then,
|
|||||||
#meson test --no-rebuild --print-errorlogs
|
#meson test --no-rebuild --print-errorlogs
|
||||||
|
|
||||||
sudo ninja install
|
sudo ninja install
|
||||||
|
```
|
||||||
|
|
||||||
## Building and testing with other build systems
|
## Building and testing with other build systems
|
||||||
See https://github.com/open-source-parsers/jsoncpp/wiki/Building
|
See https://github.com/open-source-parsers/jsoncpp/wiki/Building
|
||||||
@@ -143,7 +144,9 @@ bool Reader::decodeNumber(Token& token) {
|
|||||||
```
|
```
|
||||||
|
|
||||||
Before submitting your code, ensure that you meet the versioning requirements above, follow the style guide of the file you are modifying (or the above rules for new files), and run clang format. Meson exposes clang format with the following command:
|
Before submitting your code, ensure that you meet the versioning requirements above, follow the style guide of the file you are modifying (or the above rules for new files), and run clang format. Meson exposes clang format with the following command:
|
||||||
|
|
||||||
```
|
```
|
||||||
ninja -v -C build-${LIB_TYPE}/ clang-format
|
ninja -v -C build-${LIB_TYPE}/ clang-format
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For convenience, you can also run the `reformat.sh` script located in the root directory.
|
||||||
|
|
||||||
|
11
appveyor.yml
11
appveyor.yml
@@ -1,6 +1,7 @@
|
|||||||
clone_folder: c:\projects\jsoncpp
|
clone_folder: c:\projects\jsoncpp
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
CMAKE_GENERATOR: Visual Studio 14 2015
|
CMAKE_GENERATOR: Visual Studio 14 2015
|
||||||
@@ -13,11 +14,15 @@ environment:
|
|||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- cmake --version
|
- cmake --version
|
||||||
- cd c:\projects\jsoncpp
|
# The build script starts in root.
|
||||||
- cmake -G "%CMAKE_GENERATOR%" -DCMAKE_INSTALL_PREFIX:PATH=%CD:\=/%/install -DBUILD_SHARED_LIBS:BOOL=ON .
|
- set JSONCPP_FOLDER=%cd%
|
||||||
|
- set JSONCPP_BUILD_FOLDER=%JSONCPP_FOLDER%\build\release
|
||||||
|
- mkdir -p %JSONCPP_BUILD_FOLDER%
|
||||||
|
- cd %JSONCPP_BUILD_FOLDER%
|
||||||
|
- cmake -G "%CMAKE_GENERATOR%" -DCMAKE_INSTALL_PREFIX:PATH=%CD:\=/%/install -DBUILD_SHARED_LIBS:BOOL=ON %JSONCPP_FOLDER%
|
||||||
# Use ctest to make a dashboard build:
|
# Use ctest to make a dashboard build:
|
||||||
# - ctest -D Experimental(Start|Update|Configure|Build|Test|Coverage|MemCheck|Submit)
|
# - ctest -D Experimental(Start|Update|Configure|Build|Test|Coverage|MemCheck|Submit)
|
||||||
# NOTE: Testing on window is not yet finished:
|
# NOTE: Testing on windows is not yet finished:
|
||||||
# - ctest -C Release -D ExperimentalStart -D ExperimentalConfigure -D ExperimentalBuild -D ExperimentalTest -D ExperimentalSubmit
|
# - ctest -C Release -D ExperimentalStart -D ExperimentalConfigure -D ExperimentalBuild -D ExperimentalTest -D ExperimentalSubmit
|
||||||
- ctest -C Release -D ExperimentalStart -D ExperimentalConfigure -D ExperimentalBuild -D ExperimentalSubmit
|
- ctest -C Release -D ExperimentalStart -D ExperimentalConfigure -D ExperimentalBuild -D ExperimentalSubmit
|
||||||
# Final step is to verify that installation succeeds
|
# Final step is to verify that installation succeeds
|
||||||
|
23
cmake/JoinPaths.cmake
Normal file
23
cmake/JoinPaths.cmake
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# This module provides a function for joining paths
|
||||||
|
# known from most languages
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: (MIT OR CC0-1.0)
|
||||||
|
# Copyright 2020 Jan Tojnar
|
||||||
|
# https://github.com/jtojnar/cmake-snips
|
||||||
|
#
|
||||||
|
# Modelled after Python’s os.path.join
|
||||||
|
# https://docs.python.org/3.7/library/os.path.html#os.path.join
|
||||||
|
# Windows not supported
|
||||||
|
function(join_paths joined_path first_path_segment)
|
||||||
|
set(temp_path "${first_path_segment}")
|
||||||
|
foreach(current_segment IN LISTS ARGN)
|
||||||
|
if(NOT ("${current_segment}" STREQUAL ""))
|
||||||
|
if(IS_ABSOLUTE "${current_segment}")
|
||||||
|
set(temp_path "${current_segment}")
|
||||||
|
else()
|
||||||
|
set(temp_path "${temp_path}/${current_segment}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
set(${joined_path} "${temp_path}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
@@ -1,9 +1,11 @@
|
|||||||
# This is only for jsoncpp developers/contributors.
|
# This is only for jsoncpp developers/contributors.
|
||||||
# We use this to sign releases, generate documentation, etc.
|
# We use this to sign releases, generate documentation, etc.
|
||||||
VER?=$(shell cat version.txt)
|
VER?=$(shell cat version)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@echo "VER=${VER}"
|
@echo "VER=${VER}"
|
||||||
|
update-version:
|
||||||
|
perl get_version.pl meson.build >| version
|
||||||
sign: jsoncpp-${VER}.tar.gz
|
sign: jsoncpp-${VER}.tar.gz
|
||||||
gpg --armor --detach-sign $<
|
gpg --armor --detach-sign $<
|
||||||
gpg --verify $<.asc
|
gpg --verify $<.asc
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "json/json.h"
|
#include "json/json.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
/**
|
/**
|
||||||
* \brief Parse a raw string into Value object using the CharReaderBuilder
|
* \brief Parse a raw string into Value object using the CharReaderBuilder
|
||||||
* class, or the legacy Reader class.
|
* class, or the legacy Reader class.
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "json/json.h"
|
#include "json/json.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
/** \brief Write the Value object to a stream.
|
/** \brief Write the Value object to a stream.
|
||||||
* Example Usage:
|
* Example Usage:
|
||||||
* $g++ streamWrite.cpp -ljsoncpp -std=c++11 -o streamWrite
|
* $g++ streamWrite.cpp -ljsoncpp -std=c++11 -o streamWrite
|
||||||
|
5
get_version.pl
Normal file
5
get_version.pl
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
while (<>) {
|
||||||
|
if (/version : '(.+)',/) {
|
||||||
|
print "$1";
|
||||||
|
}
|
||||||
|
}
|
9
include/PreventInBuildInstalls.cmake
Normal file
9
include/PreventInBuildInstalls.cmake
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
string(TOLOWER "${CMAKE_INSTALL_PREFIX}" _PREFIX)
|
||||||
|
string(TOLOWER "${ITK_BINARY_DIR}" _BUILD)
|
||||||
|
if("${_PREFIX}" STREQUAL "${_BUILD}")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"The current CMAKE_INSTALL_PREFIX points at the build tree:\n"
|
||||||
|
" ${CMAKE_INSTALL_PREFIX}\n"
|
||||||
|
"This is not supported."
|
||||||
|
)
|
||||||
|
endif()
|
45
include/PreventInSourceBuilds.cmake
Normal file
45
include/PreventInSourceBuilds.cmake
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#
|
||||||
|
# This function will prevent in-source builds
|
||||||
|
function(AssureOutOfSourceBuilds)
|
||||||
|
# make sure the user doesn't play dirty with symlinks
|
||||||
|
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
|
||||||
|
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
|
||||||
|
|
||||||
|
# disallow in-source builds
|
||||||
|
if("${srcdir}" STREQUAL "${bindir}")
|
||||||
|
message("######################################################")
|
||||||
|
message("# jsoncpp should not be configured & built in the jsoncpp source directory")
|
||||||
|
message("# You must run cmake in a build directory.")
|
||||||
|
message("# For example:")
|
||||||
|
message("# mkdir jsoncpp-Sandbox ; cd jsoncpp-sandbox")
|
||||||
|
message("# git clone https://github.com/open-source-parsers/jsoncpp.git # or download & unpack the source tarball")
|
||||||
|
message("# mkdir jsoncpp-build")
|
||||||
|
message("# this will create the following directory structure")
|
||||||
|
message("#")
|
||||||
|
message("# jsoncpp-Sandbox")
|
||||||
|
message("# +--jsoncpp")
|
||||||
|
message("# +--jsoncpp-build")
|
||||||
|
message("#")
|
||||||
|
message("# Then you can proceed to configure and build")
|
||||||
|
message("# by using the following commands")
|
||||||
|
message("#")
|
||||||
|
message("# cd jsoncpp-build")
|
||||||
|
message("# cmake ../jsoncpp # or ccmake, or cmake-gui ")
|
||||||
|
message("# make")
|
||||||
|
message("#")
|
||||||
|
message("# NOTE: Given that you already tried to make an in-source build")
|
||||||
|
message("# CMake have already created several files & directories")
|
||||||
|
message("# in your source tree. run 'git status' to find them and")
|
||||||
|
message("# remove them by doing:")
|
||||||
|
message("#")
|
||||||
|
message("# cd jsoncpp-Sandbox/jsoncpp")
|
||||||
|
message("# git clean -n -d")
|
||||||
|
message("# git clean -f -d")
|
||||||
|
message("# git checkout --")
|
||||||
|
message("#")
|
||||||
|
message("######################################################")
|
||||||
|
message(FATAL_ERROR "Quitting configuration")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
AssureOutOfSourceBuilds()
|
@@ -35,11 +35,10 @@ public:
|
|||||||
* Release memory which was allocated for N items at pointer P.
|
* Release memory which was allocated for N items at pointer P.
|
||||||
*
|
*
|
||||||
* The memory block is filled with zeroes before being released.
|
* The memory block is filled with zeroes before being released.
|
||||||
* The pointer argument is tagged as "volatile" to prevent the
|
|
||||||
* compiler optimizing out this critical step.
|
|
||||||
*/
|
*/
|
||||||
void deallocate(volatile pointer p, size_type n) {
|
void deallocate(pointer p, size_type n) {
|
||||||
std::memset(p, 0, n * sizeof(T));
|
// memset_s is used because memset may be optimized away by the compiler
|
||||||
|
memset_s(p, n * sizeof(T), 0, n * sizeof(T));
|
||||||
// free using "global operator delete"
|
// free using "global operator delete"
|
||||||
::operator delete(p);
|
::operator delete(p);
|
||||||
}
|
}
|
||||||
|
@@ -33,8 +33,7 @@ namespace Json {
|
|||||||
* \deprecated Use CharReader and CharReaderBuilder.
|
* \deprecated Use CharReader and CharReaderBuilder.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class JSONCPP_DEPRECATED(
|
class JSON_API Reader {
|
||||||
"Use CharReader and CharReaderBuilder instead.") JSON_API Reader {
|
|
||||||
public:
|
public:
|
||||||
using Char = char;
|
using Char = char;
|
||||||
using Location = const Char*;
|
using Location = const Char*;
|
||||||
@@ -51,13 +50,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Constructs a Reader allowing all features for parsing.
|
/** \brief Constructs a Reader allowing all features for parsing.
|
||||||
|
* \deprecated Use CharReader and CharReaderBuilder.
|
||||||
*/
|
*/
|
||||||
JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
|
|
||||||
Reader();
|
Reader();
|
||||||
|
|
||||||
/** \brief Constructs a Reader allowing the specified feature set for parsing.
|
/** \brief Constructs a Reader allowing the specified feature set for parsing.
|
||||||
|
* \deprecated Use CharReader and CharReaderBuilder.
|
||||||
*/
|
*/
|
||||||
JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
|
|
||||||
Reader(const Features& features);
|
Reader(const Features& features);
|
||||||
|
|
||||||
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
||||||
@@ -324,6 +323,9 @@ public:
|
|||||||
* - `"allowSpecialFloats": false or true`
|
* - `"allowSpecialFloats": false or true`
|
||||||
* - If true, special float values (NaNs and infinities) are allowed and
|
* - If true, special float values (NaNs and infinities) are allowed and
|
||||||
* their values are lossfree restorable.
|
* their values are lossfree restorable.
|
||||||
|
* - `"skipBom": false or true`
|
||||||
|
* - If true, if the input starts with the Unicode byte order mark (BOM),
|
||||||
|
* it is skipped.
|
||||||
*
|
*
|
||||||
* You can examine 'settings_` yourself to see the defaults. You can also
|
* You can examine 'settings_` yourself to see the defaults. You can also
|
||||||
* write and read them just like any JSON Value.
|
* write and read them just like any JSON Value.
|
||||||
|
@@ -50,7 +50,7 @@
|
|||||||
// be used by...
|
// be used by...
|
||||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4251)
|
#pragma warning(disable : 4251 4275)
|
||||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
|
|
||||||
#pragma pack(push, 8)
|
#pragma pack(push, 8)
|
||||||
@@ -263,10 +263,10 @@ private:
|
|||||||
CZString(ArrayIndex index);
|
CZString(ArrayIndex index);
|
||||||
CZString(char const* str, unsigned length, DuplicationPolicy allocate);
|
CZString(char const* str, unsigned length, DuplicationPolicy allocate);
|
||||||
CZString(CZString const& other);
|
CZString(CZString const& other);
|
||||||
CZString(CZString&& other);
|
CZString(CZString&& other) noexcept;
|
||||||
~CZString();
|
~CZString();
|
||||||
CZString& operator=(const CZString& other);
|
CZString& operator=(const CZString& other);
|
||||||
CZString& operator=(CZString&& other);
|
CZString& operator=(CZString&& other) noexcept;
|
||||||
|
|
||||||
bool operator<(CZString const& other) const;
|
bool operator<(CZString const& other) const;
|
||||||
bool operator==(CZString const& other) const;
|
bool operator==(CZString const& other) const;
|
||||||
@@ -342,14 +342,15 @@ public:
|
|||||||
Value(const StaticString& value);
|
Value(const StaticString& value);
|
||||||
Value(const String& value);
|
Value(const String& value);
|
||||||
Value(bool value);
|
Value(bool value);
|
||||||
|
Value(std::nullptr_t ptr) = delete;
|
||||||
Value(const Value& other);
|
Value(const Value& other);
|
||||||
Value(Value&& other);
|
Value(Value&& other) noexcept;
|
||||||
~Value();
|
~Value();
|
||||||
|
|
||||||
/// \note Overwrite existing comments. To preserve comments, use
|
/// \note Overwrite existing comments. To preserve comments, use
|
||||||
/// #swapPayload().
|
/// #swapPayload().
|
||||||
Value& operator=(const Value& other);
|
Value& operator=(const Value& other);
|
||||||
Value& operator=(Value&& other);
|
Value& operator=(Value&& other) noexcept;
|
||||||
|
|
||||||
/// Swap everything.
|
/// Swap everything.
|
||||||
void swap(Value& other);
|
void swap(Value& other);
|
||||||
@@ -634,9 +635,9 @@ private:
|
|||||||
public:
|
public:
|
||||||
Comments() = default;
|
Comments() = default;
|
||||||
Comments(const Comments& that);
|
Comments(const Comments& that);
|
||||||
Comments(Comments&& that);
|
Comments(Comments&& that) noexcept;
|
||||||
Comments& operator=(const Comments& that);
|
Comments& operator=(const Comments& that);
|
||||||
Comments& operator=(Comments&& that);
|
Comments& operator=(Comments&& that) noexcept;
|
||||||
bool has(CommentPlacement slot) const;
|
bool has(CommentPlacement slot) const;
|
||||||
String get(CommentPlacement slot) const;
|
String get(CommentPlacement slot) const;
|
||||||
void set(CommentPlacement slot, String comment);
|
void set(CommentPlacement slot, String comment);
|
||||||
@@ -917,8 +918,8 @@ public:
|
|||||||
* because the returned references/pointers can be used
|
* because the returned references/pointers can be used
|
||||||
* to change state of the base class.
|
* to change state of the base class.
|
||||||
*/
|
*/
|
||||||
reference operator*() { return deref(); }
|
reference operator*() const { return const_cast<reference>(deref()); }
|
||||||
pointer operator->() { return &deref(); }
|
pointer operator->() const { return const_cast<pointer>(&deref()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void swap(Value& a, Value& b) { a.swap(b); }
|
inline void swap(Value& a, Value& b) { a.swap(b); }
|
||||||
|
@@ -9,10 +9,10 @@
|
|||||||
// 3. /CMakeLists.txt
|
// 3. /CMakeLists.txt
|
||||||
// IMPORTANT: also update the SOVERSION!!
|
// IMPORTANT: also update the SOVERSION!!
|
||||||
|
|
||||||
#define JSONCPP_VERSION_STRING "1.9.3"
|
#define JSONCPP_VERSION_STRING "1.9.5"
|
||||||
#define JSONCPP_VERSION_MAJOR 1
|
#define JSONCPP_VERSION_MAJOR 1
|
||||||
#define JSONCPP_VERSION_MINOR 9
|
#define JSONCPP_VERSION_MINOR 9
|
||||||
#define JSONCPP_VERSION_PATCH 3
|
#define JSONCPP_VERSION_PATCH 5
|
||||||
#define JSONCPP_VERSION_QUALIFIER
|
#define JSONCPP_VERSION_QUALIFIER
|
||||||
#define JSONCPP_VERSION_HEXA \
|
#define JSONCPP_VERSION_HEXA \
|
||||||
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
|
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
|
||||||
|
@@ -110,6 +110,8 @@ public:
|
|||||||
* - Number of precision digits for formatting of real values.
|
* - Number of precision digits for formatting of real values.
|
||||||
* - "precisionType": "significant"(default) or "decimal"
|
* - "precisionType": "significant"(default) or "decimal"
|
||||||
* - Type of precision for formatting of real values.
|
* - Type of precision for formatting of real values.
|
||||||
|
* - "emitUTF8": false or true
|
||||||
|
* - If true, outputs raw UTF8 strings instead of escaping them.
|
||||||
|
|
||||||
* You can examine 'settings_` yourself
|
* You can examine 'settings_` yourself
|
||||||
* to see the defaults. You can also write and read them just like any
|
* to see the defaults. You can also write and read them just like any
|
||||||
@@ -145,7 +147,7 @@ public:
|
|||||||
/** \brief Abstract class for writers.
|
/** \brief Abstract class for writers.
|
||||||
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
|
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
|
||||||
*/
|
*/
|
||||||
class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer {
|
class JSON_API Writer {
|
||||||
public:
|
public:
|
||||||
virtual ~Writer();
|
virtual ~Writer();
|
||||||
|
|
||||||
@@ -165,7 +167,7 @@ public:
|
|||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4996) // Deriving from deprecated class
|
#pragma warning(disable : 4996) // Deriving from deprecated class
|
||||||
#endif
|
#endif
|
||||||
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter
|
class JSON_API FastWriter
|
||||||
: public Writer {
|
: public Writer {
|
||||||
public:
|
public:
|
||||||
FastWriter();
|
FastWriter();
|
||||||
@@ -225,7 +227,7 @@ private:
|
|||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4996) // Deriving from deprecated class
|
#pragma warning(disable : 4996) // Deriving from deprecated class
|
||||||
#endif
|
#endif
|
||||||
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
|
class JSON_API
|
||||||
StyledWriter : public Writer {
|
StyledWriter : public Writer {
|
||||||
public:
|
public:
|
||||||
StyledWriter();
|
StyledWriter();
|
||||||
@@ -294,7 +296,7 @@ private:
|
|||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4996) // Deriving from deprecated class
|
#pragma warning(disable : 4996) // Deriving from deprecated class
|
||||||
#endif
|
#endif
|
||||||
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API
|
class JSON_API
|
||||||
StyledStreamWriter {
|
StyledStreamWriter {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
7
jsoncpp-namespaced-targets.cmake
Normal file
7
jsoncpp-namespaced-targets.cmake
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
if (TARGET jsoncpp_static)
|
||||||
|
add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
|
||||||
|
set_target_properties(JsonCpp::JsonCpp PROPERTIES INTERFACE_LINK_LIBRARIES "jsoncpp_static")
|
||||||
|
elseif (TARGET jsoncpp_lib)
|
||||||
|
add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
|
||||||
|
set_target_properties(JsonCpp::JsonCpp PROPERTIES INTERFACE_LINK_LIBRARIES "jsoncpp_lib")
|
||||||
|
endif ()
|
11
jsoncppConfig.cmake.in
Normal file
11
jsoncppConfig.cmake.in
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
cmake_policy(PUSH)
|
||||||
|
cmake_policy(VERSION 3.0)
|
||||||
|
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include ( "${CMAKE_CURRENT_LIST_DIR}/jsoncpp-targets.cmake" )
|
||||||
|
include ( "${CMAKE_CURRENT_LIST_DIR}/jsoncpp-namespaced-targets.cmake" )
|
||||||
|
|
||||||
|
check_required_components(JsonCpp)
|
||||||
|
|
||||||
|
cmake_policy(POP)
|
@@ -9,7 +9,7 @@ project(
|
|||||||
# 2. /include/json/version.h
|
# 2. /include/json/version.h
|
||||||
# 3. /CMakeLists.txt
|
# 3. /CMakeLists.txt
|
||||||
# IMPORTANT: also update the SOVERSION!!
|
# IMPORTANT: also update the SOVERSION!!
|
||||||
version : '1.9.3',
|
version : '1.9.4',
|
||||||
default_options : [
|
default_options : [
|
||||||
'buildtype=release',
|
'buildtype=release',
|
||||||
'cpp_std=c++11',
|
'cpp_std=c++11',
|
||||||
@@ -50,7 +50,7 @@ jsoncpp_lib = library(
|
|||||||
'src/lib_json/json_value.cpp',
|
'src/lib_json/json_value.cpp',
|
||||||
'src/lib_json/json_writer.cpp',
|
'src/lib_json/json_writer.cpp',
|
||||||
]),
|
]),
|
||||||
soversion : 24,
|
soversion : 25,
|
||||||
install : true,
|
install : true,
|
||||||
include_directories : jsoncpp_include_directories,
|
include_directories : jsoncpp_include_directories,
|
||||||
cpp_args: dll_export_flag)
|
cpp_args: dll_export_flag)
|
||||||
@@ -73,7 +73,7 @@ if meson.is_subproject() or not get_option('tests')
|
|||||||
subdir_done()
|
subdir_done()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
python = import('python').find_installation('python3')
|
python = import('python').find_installation()
|
||||||
|
|
||||||
jsoncpp_test = executable(
|
jsoncpp_test = executable(
|
||||||
'jsoncpp_test', files([
|
'jsoncpp_test', files([
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
prefix=@CMAKE_INSTALL_PREFIX@
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
exec_prefix=@CMAKE_INSTALL_PREFIX@
|
exec_prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
|
libdir=@libdir_for_pc_file@
|
||||||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
includedir=@includedir_for_pc_file@
|
||||||
|
|
||||||
Name: jsoncpp
|
Name: jsoncpp
|
||||||
Description: A C++ library for interacting with JSON
|
Description: A C++ library for interacting with JSON
|
||||||
Version: @JSONCPP_VERSION@
|
Version: @PROJECT_VERSION@
|
||||||
URL: https://github.com/open-source-parsers/jsoncpp
|
URL: https://github.com/open-source-parsers/jsoncpp
|
||||||
Libs: -L${libdir} -ljsoncpp
|
Libs: -L${libdir} -ljsoncpp
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
1
reformat.sh
Executable file
1
reformat.sh
Executable file
@@ -0,0 +1 @@
|
|||||||
|
find src -name '*.cpp' -or -name '*.h' | xargs clang-format -i
|
@@ -19,8 +19,10 @@ if(BUILD_SHARED_LIBS)
|
|||||||
else()
|
else()
|
||||||
add_definitions(-DJSON_DLL)
|
add_definitions(-DJSON_DLL)
|
||||||
endif()
|
endif()
|
||||||
|
target_link_libraries(jsontestrunner_exe jsoncpp_lib)
|
||||||
|
else()
|
||||||
|
target_link_libraries(jsontestrunner_exe jsoncpp_static)
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(jsontestrunner_exe jsoncpp_lib)
|
|
||||||
|
|
||||||
set_target_properties(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe)
|
set_target_properties(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe)
|
||||||
|
|
||||||
|
@@ -335,6 +335,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
std::cerr << "Unhandled exception:" << std::endl << e.what() << std::endl;
|
std::cerr << "Unhandled exception:" << std::endl << e.what() << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
|
@@ -11,20 +11,10 @@ include(CheckCXXSymbolExists)
|
|||||||
check_include_file_cxx(clocale HAVE_CLOCALE)
|
check_include_file_cxx(clocale HAVE_CLOCALE)
|
||||||
check_cxx_symbol_exists(localeconv clocale HAVE_LOCALECONV)
|
check_cxx_symbol_exists(localeconv clocale HAVE_LOCALECONV)
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_LESS 3.0.0)
|
set(CMAKE_EXTRA_INCLUDE_FILES clocale)
|
||||||
# The "LANGUAGE CXX" parameter is not supported in CMake versions below 3,
|
check_type_size(lconv LCONV_SIZE LANGUAGE CXX)
|
||||||
# so the C compiler and header has to be used.
|
unset(CMAKE_EXTRA_INCLUDE_FILES)
|
||||||
check_include_file(locale.h HAVE_LOCALE_H)
|
check_struct_has_member(lconv decimal_point clocale HAVE_DECIMAL_POINT LANGUAGE CXX)
|
||||||
set(CMAKE_EXTRA_INCLUDE_FILES locale.h)
|
|
||||||
check_type_size("struct lconv" LCONV_SIZE)
|
|
||||||
unset(CMAKE_EXTRA_INCLUDE_FILES)
|
|
||||||
check_struct_has_member("struct lconv" decimal_point locale.h HAVE_DECIMAL_POINT)
|
|
||||||
else()
|
|
||||||
set(CMAKE_EXTRA_INCLUDE_FILES clocale)
|
|
||||||
check_type_size(lconv LCONV_SIZE LANGUAGE CXX)
|
|
||||||
unset(CMAKE_EXTRA_INCLUDE_FILES)
|
|
||||||
check_struct_has_member(lconv decimal_point clocale HAVE_DECIMAL_POINT LANGUAGE CXX)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT (HAVE_CLOCALE AND HAVE_LCONV_SIZE AND HAVE_DECIMAL_POINT AND HAVE_LOCALECONV))
|
if(NOT (HAVE_CLOCALE AND HAVE_LCONV_SIZE AND HAVE_DECIMAL_POINT AND HAVE_LOCALECONV))
|
||||||
message(WARNING "Locale functionality is not supported")
|
message(WARNING "Locale functionality is not supported")
|
||||||
@@ -50,7 +40,7 @@ set(PUBLIC_HEADERS
|
|||||||
|
|
||||||
source_group("Public API" FILES ${PUBLIC_HEADERS})
|
source_group("Public API" FILES ${PUBLIC_HEADERS})
|
||||||
|
|
||||||
set(jsoncpp_sources
|
set(JSONCPP_SOURCES
|
||||||
json_tool.h
|
json_tool.h
|
||||||
json_reader.cpp
|
json_reader.cpp
|
||||||
json_valueiterator.inl
|
json_valueiterator.inl
|
||||||
@@ -65,32 +55,10 @@ else()
|
|||||||
set(INSTALL_EXPORT)
|
set(INSTALL_EXPORT)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(BUILD_SHARED_LIBS)
|
|
||||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
|
|
||||||
add_compile_definitions(JSON_DLL_BUILD)
|
|
||||||
else()
|
|
||||||
add_definitions(-DJSON_DLL_BUILD)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(jsoncpp_lib ${PUBLIC_HEADERS} ${jsoncpp_sources})
|
|
||||||
set_target_properties( jsoncpp_lib PROPERTIES
|
|
||||||
OUTPUT_NAME jsoncpp
|
|
||||||
VERSION ${JSONCPP_VERSION}
|
|
||||||
SOVERSION ${JSONCPP_SOVERSION}
|
|
||||||
POSITION_INDEPENDENT_CODE ON
|
|
||||||
)
|
|
||||||
|
|
||||||
# Set library's runtime search path on OSX
|
|
||||||
if(APPLE)
|
|
||||||
set_target_properties(jsoncpp_lib PROPERTIES INSTALL_RPATH "@loader_path/.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Specify compiler features required when compiling a given target.
|
# Specify compiler features required when compiling a given target.
|
||||||
# See https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#prop_gbl:CMAKE_CXX_KNOWN_FEATURES
|
# See https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#prop_gbl:CMAKE_CXX_KNOWN_FEATURES
|
||||||
# for complete list of features available
|
# for complete list of features available
|
||||||
target_compile_features(jsoncpp_lib PUBLIC
|
list(APPEND REQUIRED_FEATURES
|
||||||
cxx_std_11 # Compiler mode is aware of C++ 11.
|
cxx_std_11 # Compiler mode is aware of C++ 11.
|
||||||
#MSVC 1900 cxx_alignas # Alignment control alignas, as defined in N2341.
|
#MSVC 1900 cxx_alignas # Alignment control alignas, as defined in N2341.
|
||||||
#MSVC 1900 cxx_alignof # Alignment control alignof, as defined in N2341.
|
#MSVC 1900 cxx_alignof # Alignment control alignof, as defined in N2341.
|
||||||
@@ -137,16 +105,104 @@ target_compile_features(jsoncpp_lib PUBLIC
|
|||||||
cxx_variadic_templates # Variadic templates, as defined in N2242.
|
cxx_variadic_templates # Variadic templates, as defined in N2242.
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS jsoncpp_lib ${INSTALL_EXPORT}
|
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
if(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
|
if(BUILD_SHARED_LIBS)
|
||||||
target_include_directories(jsoncpp_lib PUBLIC
|
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
|
||||||
|
add_compile_definitions(JSON_DLL_BUILD)
|
||||||
|
else()
|
||||||
|
add_definitions(-DJSON_DLL_BUILD)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SHARED_LIB ${PROJECT_NAME}_lib)
|
||||||
|
add_library(${SHARED_LIB} SHARED ${PUBLIC_HEADERS} ${JSONCPP_SOURCES})
|
||||||
|
set_target_properties(${SHARED_LIB} PROPERTIES
|
||||||
|
OUTPUT_NAME jsoncpp
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
SOVERSION ${PROJECT_SOVERSION}
|
||||||
|
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set library's runtime search path on OSX
|
||||||
|
if(APPLE)
|
||||||
|
set_target_properties(${SHARED_LIB} PROPERTIES INSTALL_RPATH "@loader_path/.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_compile_features(${SHARED_LIB} PUBLIC ${REQUIRED_FEATURES})
|
||||||
|
|
||||||
|
target_include_directories(${SHARED_LIB} PUBLIC
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
|
||||||
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/json>
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/json>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
list(APPEND CMAKE_TARGETS ${SHARED_LIB})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_STATIC_LIBS)
|
||||||
|
set(STATIC_LIB ${PROJECT_NAME}_static)
|
||||||
|
add_library(${STATIC_LIB} STATIC ${PUBLIC_HEADERS} ${JSONCPP_SOURCES})
|
||||||
|
|
||||||
|
# avoid name clashes on windows as the shared import lib is alse named jsoncpp.lib
|
||||||
|
if(NOT DEFINED STATIC_SUFFIX AND BUILD_SHARED_LIBS)
|
||||||
|
if (MSVC)
|
||||||
|
set(STATIC_SUFFIX "_static")
|
||||||
|
else()
|
||||||
|
set(STATIC_SUFFIX "")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_target_properties(${STATIC_LIB} PROPERTIES
|
||||||
|
OUTPUT_NAME jsoncpp${STATIC_SUFFIX}
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set library's runtime search path on OSX
|
||||||
|
if(APPLE)
|
||||||
|
set_target_properties(${STATIC_LIB} PROPERTIES INSTALL_RPATH "@loader_path/.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_compile_features(${STATIC_LIB} PUBLIC ${REQUIRED_FEATURES})
|
||||||
|
|
||||||
|
target_include_directories(${STATIC_LIB} PUBLIC
|
||||||
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
|
||||||
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/json>
|
||||||
|
)
|
||||||
|
|
||||||
|
list(APPEND CMAKE_TARGETS ${STATIC_LIB})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_OBJECT_LIBS)
|
||||||
|
set(OBJECT_LIB ${PROJECT_NAME}_object)
|
||||||
|
add_library(${OBJECT_LIB} OBJECT ${PUBLIC_HEADERS} ${JSONCPP_SOURCES})
|
||||||
|
|
||||||
|
set_target_properties(${OBJECT_LIB} PROPERTIES
|
||||||
|
OUTPUT_NAME jsoncpp
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
SOVERSION ${PROJECT_SOVERSION}
|
||||||
|
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set library's runtime search path on OSX
|
||||||
|
if(APPLE)
|
||||||
|
set_target_properties(${OBJECT_LIB} PROPERTIES INSTALL_RPATH "@loader_path/.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_compile_features(${OBJECT_LIB} PUBLIC ${REQUIRED_FEATURES})
|
||||||
|
|
||||||
|
target_include_directories(${OBJECT_LIB} PUBLIC
|
||||||
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
|
||||||
|
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/json>
|
||||||
|
)
|
||||||
|
|
||||||
|
list(APPEND CMAKE_TARGETS ${OBJECT_LIB})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(TARGETS ${CMAKE_TARGETS} ${INSTALL_EXPORT}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
OBJECTS DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
@@ -104,8 +104,7 @@ bool Reader::parse(std::istream& is, Value& root, bool collectComments) {
|
|||||||
|
|
||||||
// Since String is reference-counted, this at least does not
|
// Since String is reference-counted, this at least does not
|
||||||
// create an extra copy.
|
// create an extra copy.
|
||||||
String doc;
|
String doc(std::istreambuf_iterator<char>(is), {});
|
||||||
std::getline(is, doc, static_cast<char> EOF);
|
|
||||||
return parse(doc.data(), doc.data() + doc.size(), root, collectComments);
|
return parse(doc.data(), doc.data() + doc.size(), root, collectComments);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1175,8 +1174,11 @@ bool OurReader::readToken(Token& token) {
|
|||||||
if (features_.allowSingleQuotes_) {
|
if (features_.allowSingleQuotes_) {
|
||||||
token.type_ = tokenString;
|
token.type_ = tokenString;
|
||||||
ok = readStringSingleQuote();
|
ok = readStringSingleQuote();
|
||||||
|
} else {
|
||||||
|
// If we don't allow single quotes, this is a failure case.
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
} // else fall through
|
|
||||||
case '/':
|
case '/':
|
||||||
token.type_ = tokenComment;
|
token.type_ = tokenComment;
|
||||||
ok = readComment();
|
ok = readComment();
|
||||||
@@ -1918,7 +1920,7 @@ bool CharReaderBuilder::validate(Json::Value* invalid) const {
|
|||||||
if (valid_keys.count(key))
|
if (valid_keys.count(key))
|
||||||
continue;
|
continue;
|
||||||
if (invalid)
|
if (invalid)
|
||||||
(*invalid)[std::move(key)] = *si;
|
(*invalid)[key] = *si;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -116,15 +116,19 @@ template <typename Iter> void fixNumericLocaleInput(Iter begin, Iter end) {
|
|||||||
* Return iterator that would be the new end of the range [begin,end), if we
|
* Return iterator that would be the new end of the range [begin,end), if we
|
||||||
* were to delete zeros in the end of string, but not the last zero before '.'.
|
* were to delete zeros in the end of string, but not the last zero before '.'.
|
||||||
*/
|
*/
|
||||||
template <typename Iter> Iter fixZerosInTheEnd(Iter begin, Iter end) {
|
template <typename Iter>
|
||||||
|
Iter fixZerosInTheEnd(Iter begin, Iter end, unsigned int precision) {
|
||||||
for (; begin != end; --end) {
|
for (; begin != end; --end) {
|
||||||
if (*(end - 1) != '0') {
|
if (*(end - 1) != '0') {
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
// Don't delete the last zero before the decimal point.
|
// Don't delete the last zero before the decimal point.
|
||||||
if (begin != (end - 1) && *(end - 2) == '.') {
|
if (begin != (end - 1) && begin != (end - 2) && *(end - 2) == '.') {
|
||||||
|
if (precision) {
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
return end - 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
@@ -259,7 +259,7 @@ Value::CZString::CZString(const CZString& other) {
|
|||||||
storage_.length_ = other.storage_.length_;
|
storage_.length_ = other.storage_.length_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::CZString::CZString(CZString&& other)
|
Value::CZString::CZString(CZString&& other) noexcept
|
||||||
: cstr_(other.cstr_), index_(other.index_) {
|
: cstr_(other.cstr_), index_(other.index_) {
|
||||||
other.cstr_ = nullptr;
|
other.cstr_ = nullptr;
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,7 @@ Value::CZString& Value::CZString::operator=(const CZString& other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::CZString& Value::CZString::operator=(CZString&& other) {
|
Value::CZString& Value::CZString::operator=(CZString&& other) noexcept {
|
||||||
cstr_ = other.cstr_;
|
cstr_ = other.cstr_;
|
||||||
index_ = other.index_;
|
index_ = other.index_;
|
||||||
other.cstr_ = nullptr;
|
other.cstr_ = nullptr;
|
||||||
@@ -433,7 +433,7 @@ Value::Value(const Value& other) {
|
|||||||
dupMeta(other);
|
dupMeta(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Value(Value&& other) {
|
Value::Value(Value&& other) noexcept {
|
||||||
initBasic(nullValue);
|
initBasic(nullValue);
|
||||||
swap(other);
|
swap(other);
|
||||||
}
|
}
|
||||||
@@ -448,7 +448,7 @@ Value& Value::operator=(const Value& other) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value& Value::operator=(Value&& other) {
|
Value& Value::operator=(Value&& other) noexcept {
|
||||||
other.swap(*this);
|
other.swap(*this);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -912,7 +912,8 @@ void Value::resize(ArrayIndex newSize) {
|
|||||||
if (newSize == 0)
|
if (newSize == 0)
|
||||||
clear();
|
clear();
|
||||||
else if (newSize > oldSize)
|
else if (newSize > oldSize)
|
||||||
this->operator[](newSize - 1);
|
for (ArrayIndex i = oldSize; i < newSize; ++i)
|
||||||
|
(*this)[i];
|
||||||
else {
|
else {
|
||||||
for (ArrayIndex index = newSize; index < oldSize; ++index) {
|
for (ArrayIndex index = newSize; index < oldSize; ++index) {
|
||||||
value_.map_->erase(index);
|
value_.map_->erase(index);
|
||||||
@@ -1373,14 +1374,15 @@ bool Value::isObject() const { return type() == objectValue; }
|
|||||||
Value::Comments::Comments(const Comments& that)
|
Value::Comments::Comments(const Comments& that)
|
||||||
: ptr_{cloneUnique(that.ptr_)} {}
|
: ptr_{cloneUnique(that.ptr_)} {}
|
||||||
|
|
||||||
Value::Comments::Comments(Comments&& that) : ptr_{std::move(that.ptr_)} {}
|
Value::Comments::Comments(Comments&& that) noexcept
|
||||||
|
: ptr_{std::move(that.ptr_)} {}
|
||||||
|
|
||||||
Value::Comments& Value::Comments::operator=(const Comments& that) {
|
Value::Comments& Value::Comments::operator=(const Comments& that) {
|
||||||
ptr_ = cloneUnique(that.ptr_);
|
ptr_ = cloneUnique(that.ptr_);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Comments& Value::Comments::operator=(Comments&& that) {
|
Value::Comments& Value::Comments::operator=(Comments&& that) noexcept {
|
||||||
ptr_ = std::move(that.ptr_);
|
ptr_ = std::move(that.ptr_);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -1396,13 +1398,11 @@ String Value::Comments::get(CommentPlacement slot) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Value::Comments::set(CommentPlacement slot, String comment) {
|
void Value::Comments::set(CommentPlacement slot, String comment) {
|
||||||
if (!ptr_) {
|
if (slot >= CommentPlacement::numberOfCommentPlacement)
|
||||||
|
return;
|
||||||
|
if (!ptr_)
|
||||||
ptr_ = std::unique_ptr<Array>(new Array());
|
ptr_ = std::unique_ptr<Array>(new Array());
|
||||||
}
|
|
||||||
// check comments array boundry.
|
|
||||||
if (slot < CommentPlacement::numberOfCommentPlacement) {
|
|
||||||
(*ptr_)[slot] = std::move(comment);
|
(*ptr_)[slot] = std::move(comment);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Value::setComment(String comment, CommentPlacement placement) {
|
void Value::setComment(String comment, CommentPlacement placement) {
|
||||||
|
@@ -68,7 +68,7 @@
|
|||||||
|
|
||||||
#if !defined(isnan)
|
#if !defined(isnan)
|
||||||
// IEEE standard states that NaN values will not compare to themselves
|
// IEEE standard states that NaN values will not compare to themselves
|
||||||
#define isnan(x) (x != x)
|
#define isnan(x) ((x) != (x))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(__APPLE__)
|
#if !defined(__APPLE__)
|
||||||
@@ -154,16 +154,18 @@ String valueToString(double value, bool useSpecialFloats,
|
|||||||
|
|
||||||
buffer.erase(fixNumericLocale(buffer.begin(), buffer.end()), buffer.end());
|
buffer.erase(fixNumericLocale(buffer.begin(), buffer.end()), buffer.end());
|
||||||
|
|
||||||
// strip the zero padding from the right
|
|
||||||
if (precisionType == PrecisionType::decimalPlaces) {
|
|
||||||
buffer.erase(fixZerosInTheEnd(buffer.begin(), buffer.end()), buffer.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
// try to ensure we preserve the fact that this was given to us as a double on
|
// try to ensure we preserve the fact that this was given to us as a double on
|
||||||
// input
|
// input
|
||||||
if (buffer.find('.') == buffer.npos && buffer.find('e') == buffer.npos) {
|
if (buffer.find('.') == buffer.npos && buffer.find('e') == buffer.npos) {
|
||||||
buffer += ".0";
|
buffer += ".0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// strip the zero padding from the right
|
||||||
|
if (precisionType == PrecisionType::decimalPlaces) {
|
||||||
|
buffer.erase(fixZerosInTheEnd(buffer.begin(), buffer.end(), precision),
|
||||||
|
buffer.end());
|
||||||
|
}
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
@@ -175,11 +177,11 @@ String valueToString(double value, unsigned int precision,
|
|||||||
|
|
||||||
String valueToString(bool value) { return value ? "true" : "false"; }
|
String valueToString(bool value) { return value ? "true" : "false"; }
|
||||||
|
|
||||||
static bool isAnyCharRequiredQuoting(char const* s, size_t n) {
|
static bool doesAnyCharRequireEscaping(char const* s, size_t n) {
|
||||||
assert(s || !n);
|
assert(s || !n);
|
||||||
|
|
||||||
return std::any_of(s, s + n, [](unsigned char c) {
|
return std::any_of(s, s + n, [](unsigned char c) {
|
||||||
return c == '\\' || c == '"' || !std::isprint(c);
|
return c == '\\' || c == '"' || c < 0x20 || c > 0x7F;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,12 +272,12 @@ static void appendHex(String& result, unsigned ch) {
|
|||||||
result.append("\\u").append(toHex16Bit(ch));
|
result.append("\\u").append(toHex16Bit(ch));
|
||||||
}
|
}
|
||||||
|
|
||||||
static String valueToQuotedStringN(const char* value, unsigned length,
|
static String valueToQuotedStringN(const char* value, size_t length,
|
||||||
bool emitUTF8 = false) {
|
bool emitUTF8 = false) {
|
||||||
if (value == nullptr)
|
if (value == nullptr)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
if (!isAnyCharRequiredQuoting(value, length))
|
if (!doesAnyCharRequireEscaping(value, length))
|
||||||
return String("\"") + value + "\"";
|
return String("\"") + value + "\"";
|
||||||
// We have to walk value and escape any special characters.
|
// We have to walk value and escape any special characters.
|
||||||
// Appending to String is not efficient, but this should be rare.
|
// Appending to String is not efficient, but this should be rare.
|
||||||
@@ -348,7 +350,7 @@ static String valueToQuotedStringN(const char* value, unsigned length,
|
|||||||
}
|
}
|
||||||
|
|
||||||
String valueToQuotedString(const char* value) {
|
String valueToQuotedString(const char* value) {
|
||||||
return valueToQuotedStringN(value, static_cast<unsigned int>(strlen(value)));
|
return valueToQuotedStringN(value, strlen(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Class Writer
|
// Class Writer
|
||||||
@@ -397,7 +399,7 @@ void FastWriter::writeValue(const Value& value) {
|
|||||||
char const* end;
|
char const* end;
|
||||||
bool ok = value.getString(&str, &end);
|
bool ok = value.getString(&str, &end);
|
||||||
if (ok)
|
if (ok)
|
||||||
document_ += valueToQuotedStringN(str, static_cast<unsigned>(end - str));
|
document_ += valueToQuotedStringN(str, static_cast<size_t>(end - str));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case booleanValue:
|
case booleanValue:
|
||||||
@@ -420,8 +422,7 @@ void FastWriter::writeValue(const Value& value) {
|
|||||||
const String& name = *it;
|
const String& name = *it;
|
||||||
if (it != members.begin())
|
if (it != members.begin())
|
||||||
document_ += ',';
|
document_ += ',';
|
||||||
document_ += valueToQuotedStringN(name.data(),
|
document_ += valueToQuotedStringN(name.data(), name.length());
|
||||||
static_cast<unsigned>(name.length()));
|
|
||||||
document_ += yamlCompatibilityEnabled_ ? ": " : ":";
|
document_ += yamlCompatibilityEnabled_ ? ": " : ":";
|
||||||
writeValue(value[name]);
|
writeValue(value[name]);
|
||||||
}
|
}
|
||||||
@@ -466,7 +467,7 @@ void StyledWriter::writeValue(const Value& value) {
|
|||||||
char const* end;
|
char const* end;
|
||||||
bool ok = value.getString(&str, &end);
|
bool ok = value.getString(&str, &end);
|
||||||
if (ok)
|
if (ok)
|
||||||
pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end - str)));
|
pushValue(valueToQuotedStringN(str, static_cast<size_t>(end - str)));
|
||||||
else
|
else
|
||||||
pushValue("");
|
pushValue("");
|
||||||
break;
|
break;
|
||||||
@@ -507,7 +508,7 @@ void StyledWriter::writeValue(const Value& value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StyledWriter::writeArrayValue(const Value& value) {
|
void StyledWriter::writeArrayValue(const Value& value) {
|
||||||
unsigned size = value.size();
|
size_t size = value.size();
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
pushValue("[]");
|
pushValue("[]");
|
||||||
else {
|
else {
|
||||||
@@ -516,7 +517,7 @@ void StyledWriter::writeArrayValue(const Value& value) {
|
|||||||
writeWithIndent("[");
|
writeWithIndent("[");
|
||||||
indent();
|
indent();
|
||||||
bool hasChildValue = !childValues_.empty();
|
bool hasChildValue = !childValues_.empty();
|
||||||
unsigned index = 0;
|
ArrayIndex index = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const Value& childValue = value[index];
|
const Value& childValue = value[index];
|
||||||
writeCommentBeforeValue(childValue);
|
writeCommentBeforeValue(childValue);
|
||||||
@@ -539,7 +540,7 @@ void StyledWriter::writeArrayValue(const Value& value) {
|
|||||||
{
|
{
|
||||||
assert(childValues_.size() == size);
|
assert(childValues_.size() == size);
|
||||||
document_ += "[ ";
|
document_ += "[ ";
|
||||||
for (unsigned index = 0; index < size; ++index) {
|
for (size_t index = 0; index < size; ++index) {
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
document_ += ", ";
|
document_ += ", ";
|
||||||
document_ += childValues_[index];
|
document_ += childValues_[index];
|
||||||
@@ -684,7 +685,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
|
|||||||
char const* end;
|
char const* end;
|
||||||
bool ok = value.getString(&str, &end);
|
bool ok = value.getString(&str, &end);
|
||||||
if (ok)
|
if (ok)
|
||||||
pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end - str)));
|
pushValue(valueToQuotedStringN(str, static_cast<size_t>(end - str)));
|
||||||
else
|
else
|
||||||
pushValue("");
|
pushValue("");
|
||||||
break;
|
break;
|
||||||
@@ -958,8 +959,8 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
|
|||||||
char const* end;
|
char const* end;
|
||||||
bool ok = value.getString(&str, &end);
|
bool ok = value.getString(&str, &end);
|
||||||
if (ok)
|
if (ok)
|
||||||
pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end - str),
|
pushValue(
|
||||||
emitUTF8_));
|
valueToQuotedStringN(str, static_cast<size_t>(end - str), emitUTF8_));
|
||||||
else
|
else
|
||||||
pushValue("");
|
pushValue("");
|
||||||
break;
|
break;
|
||||||
@@ -982,8 +983,8 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
|
|||||||
String const& name = *it;
|
String const& name = *it;
|
||||||
Value const& childValue = value[name];
|
Value const& childValue = value[name];
|
||||||
writeCommentBeforeValue(childValue);
|
writeCommentBeforeValue(childValue);
|
||||||
writeWithIndent(valueToQuotedStringN(
|
writeWithIndent(
|
||||||
name.data(), static_cast<unsigned>(name.length()), emitUTF8_));
|
valueToQuotedStringN(name.data(), name.length(), emitUTF8_));
|
||||||
*sout_ << colonSymbol_;
|
*sout_ << colonSymbol_;
|
||||||
writeValue(childValue);
|
writeValue(childValue);
|
||||||
if (++it == members.end()) {
|
if (++it == members.end()) {
|
||||||
@@ -1217,7 +1218,7 @@ bool StreamWriterBuilder::validate(Json::Value* invalid) const {
|
|||||||
if (valid_keys.count(key))
|
if (valid_keys.count(key))
|
||||||
continue;
|
continue;
|
||||||
if (invalid)
|
if (invalid)
|
||||||
(*invalid)[std::move(key)] = *si;
|
(*invalid)[key] = *si;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -15,8 +15,10 @@ if(BUILD_SHARED_LIBS)
|
|||||||
else()
|
else()
|
||||||
add_definitions( -DJSON_DLL )
|
add_definitions( -DJSON_DLL )
|
||||||
endif()
|
endif()
|
||||||
|
target_link_libraries(jsoncpp_test jsoncpp_lib)
|
||||||
|
else()
|
||||||
|
target_link_libraries(jsoncpp_test jsoncpp_static)
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(jsoncpp_test jsoncpp_lib)
|
|
||||||
|
|
||||||
# another way to solve issue #90
|
# another way to solve issue #90
|
||||||
#set_target_properties(jsoncpp_test PROPERTIES COMPILE_FLAGS -ffloat-store)
|
#set_target_properties(jsoncpp_test PROPERTIES COMPILE_FLAGS -ffloat-store)
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "fuzz.h"
|
#include "fuzz.h"
|
||||||
#include "jsontest.h"
|
#include "jsontest.h"
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using CharReaderPtr = std::unique_ptr<Json::CharReader>;
|
using CharReaderPtr = std::unique_ptr<Json::CharReader>;
|
||||||
|
|
||||||
@@ -347,6 +349,17 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, resizeArray) {
|
|||||||
JSONTEST_ASSERT_EQUAL(array.size(), 0);
|
JSONTEST_ASSERT_EQUAL(array.size(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSONTEST_FIXTURE_LOCAL(ValueTest, resizePopulatesAllMissingElements) {
|
||||||
|
Json::ArrayIndex n = 10;
|
||||||
|
Json::Value v;
|
||||||
|
v.resize(n);
|
||||||
|
JSONTEST_ASSERT_EQUAL(n, v.size());
|
||||||
|
JSONTEST_ASSERT_EQUAL(n, std::distance(v.begin(), v.end()));
|
||||||
|
for (const Json::Value& e : v)
|
||||||
|
JSONTEST_ASSERT_EQUAL(e, Json::Value{});
|
||||||
|
}
|
||||||
|
|
||||||
JSONTEST_FIXTURE_LOCAL(ValueTest, getArrayValue) {
|
JSONTEST_FIXTURE_LOCAL(ValueTest, getArrayValue) {
|
||||||
Json::Value array;
|
Json::Value array;
|
||||||
for (Json::ArrayIndex i = 0; i < 5; i++)
|
for (Json::ArrayIndex i = 0; i < 5; i++)
|
||||||
@@ -2005,6 +2018,34 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, precision) {
|
|||||||
result = Json::writeString(b, v);
|
result = Json::writeString(b, v);
|
||||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
|
|
||||||
|
b.settings_["precision"] = 0;
|
||||||
|
b.settings_["precisionType"] = "decimal";
|
||||||
|
v = 123.56345694873740545068;
|
||||||
|
expected = "124";
|
||||||
|
result = Json::writeString(b, v);
|
||||||
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
|
|
||||||
|
b.settings_["precision"] = 1;
|
||||||
|
b.settings_["precisionType"] = "decimal";
|
||||||
|
v = 1230.001;
|
||||||
|
expected = "1230.0";
|
||||||
|
result = Json::writeString(b, v);
|
||||||
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
|
|
||||||
|
b.settings_["precision"] = 0;
|
||||||
|
b.settings_["precisionType"] = "decimal";
|
||||||
|
v = 1230.001;
|
||||||
|
expected = "1230";
|
||||||
|
result = Json::writeString(b, v);
|
||||||
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
|
|
||||||
|
b.settings_["precision"] = 0;
|
||||||
|
b.settings_["precisionType"] = "decimal";
|
||||||
|
v = 1231.5;
|
||||||
|
expected = "1232";
|
||||||
|
result = Json::writeString(b, v);
|
||||||
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
|
|
||||||
b.settings_["precision"] = 10;
|
b.settings_["precision"] = 10;
|
||||||
b.settings_["precisionType"] = "decimal";
|
b.settings_["precisionType"] = "decimal";
|
||||||
v = 0.23300000;
|
v = 0.23300000;
|
||||||
@@ -2702,6 +2743,34 @@ JSONTEST_FIXTURE_LOCAL(StreamWriterTest, escapeControlCharacters) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
JSONTEST_FIXTURE_LOCAL(StreamWriterTest, escapeTabCharacterWindows) {
|
||||||
|
// Get the current locale before changing it
|
||||||
|
std::string currentLocale = setlocale(LC_ALL, NULL);
|
||||||
|
setlocale(LC_ALL, "English_United States.1252");
|
||||||
|
|
||||||
|
Json::Value root;
|
||||||
|
root["test"] = "\tTabTesting\t";
|
||||||
|
|
||||||
|
Json::StreamWriterBuilder b;
|
||||||
|
|
||||||
|
JSONTEST_ASSERT(Json::writeString(b, root) == "{\n\t\"test\" : "
|
||||||
|
"\"\\tTabTesting\\t\"\n}");
|
||||||
|
|
||||||
|
b.settings_["emitUTF8"] = true;
|
||||||
|
JSONTEST_ASSERT(Json::writeString(b, root) == "{\n\t\"test\" : "
|
||||||
|
"\"\\tTabTesting\\t\"\n}");
|
||||||
|
|
||||||
|
b.settings_["emitUTF8"] = false;
|
||||||
|
JSONTEST_ASSERT(Json::writeString(b, root) == "{\n\t\"test\" : "
|
||||||
|
"\"\\tTabTesting\\t\"\n}");
|
||||||
|
|
||||||
|
// Restore the locale
|
||||||
|
if (!currentLocale.empty())
|
||||||
|
setlocale(LC_ALL, currentLocale.c_str());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ReaderTest : JsonTest::TestCase {
|
struct ReaderTest : JsonTest::TestCase {
|
||||||
void setStrictMode() {
|
void setStrictMode() {
|
||||||
reader = std::unique_ptr<Json::Reader>(
|
reader = std::unique_ptr<Json::Reader>(
|
||||||
@@ -3888,6 +3957,15 @@ JSONTEST_FIXTURE_LOCAL(MemberTemplateIs, BehavesSameAsNamedIs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class VersionTest : public JsonTest::TestCase {};
|
||||||
|
|
||||||
|
JSONTEST_FIXTURE_LOCAL(VersionTest, VersionNumbersMatch) {
|
||||||
|
std::ostringstream vstr;
|
||||||
|
vstr << JSONCPP_VERSION_MAJOR << '.' << JSONCPP_VERSION_MINOR << '.'
|
||||||
|
<< JSONCPP_VERSION_PATCH;
|
||||||
|
JSONTEST_ASSERT_EQUAL(vstr.str(), std::string(JSONCPP_VERSION_STRING));
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
1
test/data/fail_invalid_quote.json
Normal file
1
test/data/fail_invalid_quote.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{'//this is bad JSON.'}
|
Reference in New Issue
Block a user