mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-14 15:05:34 +02:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1021ff66d3 | ||
![]() |
f3aa9c1201 | ||
![]() |
b0879b2ab8 | ||
![]() |
3feaf29075 | ||
![]() |
360153687d | ||
![]() |
a67d378236 | ||
![]() |
e7f6e91381 | ||
![]() |
f025d8d225 | ||
![]() |
a3007ee301 | ||
![]() |
c2040ec371 |
11
.gitattributes
vendored
11
.gitattributes
vendored
@@ -1,11 +0,0 @@
|
||||
* text=auto
|
||||
*.h text
|
||||
*.cpp text
|
||||
*.json text
|
||||
*.in text
|
||||
*.sh eol=lf
|
||||
*.bat eol=crlf
|
||||
*.vcproj eol=crlf
|
||||
*.vcxproj eol=crlf
|
||||
*.sln eol=crlf
|
||||
devtools/agent_vm* eol=crlf
|
16
.gitignore
vendored
16
.gitignore
vendored
@@ -34,19 +34,3 @@ CTestTestFile.cmake
|
||||
cmake_install.cmake
|
||||
pkg-config/jsoncpp.pc
|
||||
jsoncpp_lib_static.dir/
|
||||
|
||||
# In case someone runs cmake in the root-dir:
|
||||
/CMakeCache.txt
|
||||
/Makefile
|
||||
/include/Makefile
|
||||
/src/Makefile
|
||||
/src/jsontestrunner/Makefile
|
||||
/src/jsontestrunner/jsontestrunner_exe
|
||||
/src/lib_json/Makefile
|
||||
/src/test_lib_json/Makefile
|
||||
/src/test_lib_json/jsoncpp_test
|
||||
|
||||
# eclipse project files
|
||||
.project
|
||||
.cproject
|
||||
/.settings/
|
||||
|
34
.travis.yml
34
.travis.yml
@@ -2,42 +2,16 @@
|
||||
# http://about.travis-ci.org/docs/user/build-configuration/
|
||||
# This file can be validated on:
|
||||
# http://lint.travis-ci.org/
|
||||
# See also
|
||||
# http://stackoverflow.com/questions/22111549/travis-ci-with-clang-3-4-and-c11/30925448#30925448
|
||||
# to allow C++11, though we are not yet building with -std=c++11
|
||||
|
||||
install:
|
||||
# /usr/bin/gcc is 4.6 always, but gcc-X.Y is available.
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
|
||||
# /usr/bin/clang is our version already, and clang-X.Y does not exist.
|
||||
#- if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi
|
||||
- echo ${PATH}
|
||||
- ls /usr/local
|
||||
- ls /usr/local/bin
|
||||
- export PATH=/usr/local/bin:/usr/bin:${PATH}
|
||||
- echo ${CXX}
|
||||
- ${CXX} --version
|
||||
- which valgrind
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- gcc-4.9
|
||||
- g++-4.9
|
||||
- clang
|
||||
- valgrind
|
||||
os:
|
||||
- linux
|
||||
before_install: sudo apt-get install cmake
|
||||
language: cpp
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
script: ./travis.sh
|
||||
script: cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DJSONCPP_LIB_BUILD_SHARED=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE . && make && make jsoncpp_check
|
||||
env:
|
||||
matrix:
|
||||
- SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false
|
||||
- SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE_MAKE=true VERBOSE
|
||||
notifications:
|
||||
email: false
|
||||
sudo: false
|
||||
email:
|
||||
- aaronjjacobs@gmail.com
|
||||
|
@@ -7,11 +7,8 @@ ENABLE_TESTING()
|
||||
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_WARNING_AS_ERROR "Force compilation to fail if a warning occurs" OFF)
|
||||
OPTION(JSONCPP_WITH_STRICT_ISO "Issue all the warnings demanded by strict ISO C and ISO C++" ON)
|
||||
OPTION(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON)
|
||||
OPTION(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" OFF)
|
||||
OPTION(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." OFF)
|
||||
OPTION(BUILD_STATIC_LIBS "Build jsoncpp_lib static library." ON)
|
||||
|
||||
# Ensures that CMAKE_BUILD_TYPE is visible in cmake-gui on Unix
|
||||
IF(NOT WIN32)
|
||||
@@ -19,10 +16,9 @@ IF(NOT WIN32)
|
||||
SET(CMAKE_BUILD_TYPE Release CACHE STRING
|
||||
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage."
|
||||
FORCE)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF(NOT CMAKE_BUILD_TYPE)
|
||||
ENDIF(NOT WIN32)
|
||||
|
||||
SET(DEBUG_LIBNAME_SUFFIX "" CACHE STRING "Optional suffix to append to the library name for a debug build")
|
||||
SET(LIB_SUFFIX "" CACHE STRING "Optional arch-dependent suffix for the library installation directory")
|
||||
|
||||
SET(RUNTIME_INSTALL_DIR bin
|
||||
@@ -40,7 +36,7 @@ MARK_AS_ADVANCED( RUNTIME_INSTALL_DIR ARCHIVE_INSTALL_DIR INCLUDE_INSTALL_DIR PA
|
||||
# Set variable named ${VAR_NAME} to value ${VALUE}
|
||||
FUNCTION(set_using_dynamic_name VAR_NAME VALUE)
|
||||
SET( "${VAR_NAME}" "${VALUE}" PARENT_SCOPE)
|
||||
ENDFUNCTION()
|
||||
ENDFUNCTION(set_using_dynamic_name)
|
||||
|
||||
# Extract major, minor, patch from version text
|
||||
# Parse a version string "X.Y.Z" and outputs
|
||||
@@ -56,20 +52,19 @@ MACRO(jsoncpp_parse_version VERSION_TEXT OUPUT_PREFIX)
|
||||
set_using_dynamic_name( "${OUPUT_PREFIX}_FOUND" TRUE )
|
||||
ELSE( ${VERSION_TEXT} MATCHES ${VERSION_REGEX} )
|
||||
set_using_dynamic_name( "${OUPUT_PREFIX}_FOUND" FALSE )
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
ENDIF( ${VERSION_TEXT} MATCHES ${VERSION_REGEX} )
|
||||
ENDMACRO(jsoncpp_parse_version)
|
||||
|
||||
# Read out version from "version" file
|
||||
#FILE(STRINGS "version" JSONCPP_VERSION)
|
||||
#SET( JSONCPP_VERSION_MAJOR X )
|
||||
#SET( JSONCPP_VERSION_MINOR Y )
|
||||
#SET( JSONCPP_VERSION_PATCH Z )
|
||||
SET( JSONCPP_VERSION 1.7.4 )
|
||||
SET( JSONCPP_VERSION 1.10.0 )
|
||||
jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION )
|
||||
#IF(NOT JSONCPP_VERSION_FOUND)
|
||||
# MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
|
||||
#ENDIF(NOT JSONCPP_VERSION_FOUND)
|
||||
SET( JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL" )
|
||||
|
||||
MESSAGE(STATUS "JsonCpp Version: ${JSONCPP_VERSION_MAJOR}.${JSONCPP_VERSION_MINOR}.${JSONCPP_VERSION_PATCH}")
|
||||
# File version.h is only regenerated on CMake configure step
|
||||
@@ -85,12 +80,7 @@ macro(UseCompilationWarningAsError)
|
||||
# Only enabled in debug because some old versions of VS STL generate
|
||||
# warnings when compiled in release configuration.
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||
if (JSONCPP_WITH_STRICT_ISO)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
|
||||
endif ()
|
||||
endif()
|
||||
endif( MSVC )
|
||||
endmacro()
|
||||
|
||||
# Include our configuration header
|
||||
@@ -100,52 +90,34 @@ if ( MSVC )
|
||||
# Only enabled in debug because some old versions of VS STL generate
|
||||
# unreachable code warning when compiled in release configuration.
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ")
|
||||
endif()
|
||||
endif( MSVC )
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# using regular Clang or AppleClang
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
# using GCC
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Wextra")
|
||||
# not yet ready for -Wsign-conversion
|
||||
|
||||
if (JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=conversion -pedantic")
|
||||
endif ()
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
# using Intel compiler
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Wextra -Werror=conversion")
|
||||
|
||||
if (JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
|
||||
endif ()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
|
||||
endif()
|
||||
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
if(CCACHE_FOUND)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||
endif(CCACHE_FOUND)
|
||||
|
||||
IF(JSONCPP_WITH_WARNING_AS_ERROR)
|
||||
UseCompilationWarningAsError()
|
||||
ENDIF()
|
||||
ENDIF(JSONCPP_WITH_WARNING_AS_ERROR)
|
||||
|
||||
IF(JSONCPP_WITH_PKGCONFIG_SUPPORT)
|
||||
CONFIGURE_FILE(
|
||||
"pkg-config/jsoncpp.pc.in"
|
||||
"pkg-config/jsoncpp.pc"
|
||||
@ONLY)
|
||||
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkg-config/jsoncpp.pc"
|
||||
INSTALL(FILES "${CMAKE_BINARY_DIR}/pkg-config/jsoncpp.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig")
|
||||
ENDIF()
|
||||
ENDIF(JSONCPP_WITH_PKGCONFIG_SUPPORT)
|
||||
|
||||
IF(JSONCPP_WITH_CMAKE_PACKAGE)
|
||||
INSTALL(EXPORT jsoncpp
|
||||
DESTINATION ${PACKAGE_INSTALL_DIR}/jsoncpp
|
||||
FILE jsoncppConfig.cmake)
|
||||
ENDIF()
|
||||
ENDIF(JSONCPP_WITH_CMAKE_PACKAGE)
|
||||
|
||||
# Build the different applications
|
||||
ADD_SUBDIRECTORY( src )
|
||||
|
68
README.md
68
README.md
@@ -19,14 +19,12 @@ format to store user input files.
|
||||
* `0.y.z` can be used with older compilers.
|
||||
* Major versions maintain binary-compatibility.
|
||||
|
||||
# Using JsonCpp in your project
|
||||
Using JsonCpp in your project
|
||||
-----------------------------
|
||||
The recommended approach to integrating JsonCpp in your project is to include
|
||||
the [amalgamated source](#generating-amalgamated-source-and-header) (a single
|
||||
`.cpp` file and two `.h` files) in your project, and compile and build as you
|
||||
would any other source file. This ensures consistency of compilation flags and
|
||||
ABI compatibility, issues which arise when building shared or static
|
||||
libraries. See the next section for instructions.
|
||||
The recommended approach to integrating JsonCpp in your project is to build
|
||||
the amalgamated source (a single `.cpp` file) with your own build system. This
|
||||
ensures consistency of compilation flags and ABI compatibility. See the section
|
||||
"Generating amalgamated source and header" for instructions.
|
||||
|
||||
The `include/` should be added to your compiler include path. Jsoncpp headers
|
||||
should be included as follow:
|
||||
@@ -36,31 +34,6 @@ should be included as follow:
|
||||
If JsonCpp was built as a dynamic library on Windows, then your project needs to
|
||||
define the macro `JSON_DLL`.
|
||||
|
||||
Generating amalgamated source and header
|
||||
----------------------------------------
|
||||
JsonCpp is provided with a script to generate a single header and a single
|
||||
source file to ease inclusion into an existing project. The amalgamated source
|
||||
can be generated at any time by running the following command from the
|
||||
top-directory (this requires Python 2.6):
|
||||
|
||||
python amalgamate.py
|
||||
|
||||
It is possible to specify header name. See the `-h` option for detail.
|
||||
|
||||
By default, the following files are generated:
|
||||
* `dist/jsoncpp.cpp`: source file that needs to be added to your project.
|
||||
* `dist/json/json.h`: corresponding header file for use in your project. It is
|
||||
equivalent to including `json/json.h` in non-amalgamated source. This header
|
||||
only depends on standard headers.
|
||||
* `dist/json/json-forwards.h`: header that provides forward declaration of all
|
||||
JsonCpp types.
|
||||
|
||||
The amalgamated sources are generated by concatenating JsonCpp source in the
|
||||
correct order and defining the macro `JSON_IS_AMALGAMATION` to prevent inclusion
|
||||
of other headers.
|
||||
|
||||
# Contributing to JsonCpp
|
||||
|
||||
Building and testing with CMake
|
||||
-------------------------------
|
||||
[CMake][] is a C++ Makefiles/Solution generator. It is usually available on most
|
||||
@@ -85,7 +58,7 @@ Steps for generating solution/makefiles using `cmake-gui`:
|
||||
* Make "source code" point to the source directory.
|
||||
* Make "where to build the binary" point to the directory to use for the build.
|
||||
* Click on the "Grouped" check box.
|
||||
* Review JsonCpp build options (tick `BUILD_SHARED_LIBS` to build as a
|
||||
* Review JsonCpp build options (tick `JSONCPP_LIB_BUILD_SHARED` to build as a
|
||||
dynamic library).
|
||||
* Click the configure button at the bottom, then the generate button.
|
||||
* The generated solution/makefiles can be found in the binary directory.
|
||||
@@ -94,10 +67,10 @@ Alternatively, from the command-line on Unix in the source directory:
|
||||
|
||||
mkdir -p build/debug
|
||||
cd build/debug
|
||||
cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles" ../..
|
||||
cmake -DCMAKE_BUILD_TYPE=debug -DJSONCPP_LIB_BUILD_STATIC=ON -DJSONCPP_LIB_BUILD_SHARED=OFF -G "Unix Makefiles" ../..
|
||||
make
|
||||
|
||||
Running `cmake -h` will display the list of available generators (passed using
|
||||
Running `cmake -`" will display the list of available generators (passed using
|
||||
the `-G` option).
|
||||
|
||||
By default CMake hides compilation commands. This can be modified by specifying
|
||||
@@ -133,7 +106,7 @@ If you are building with Microsoft Visual Studio 2008, you need to set up the
|
||||
environment by running `vcvars32.bat` (e.g. MSVC 2008 command prompt) before
|
||||
running SCons.
|
||||
|
||||
## Running the tests manually
|
||||
# Running the tests manually
|
||||
You need to run tests manually only if you are troubleshooting an issue.
|
||||
|
||||
In the instructions below, replace `path/to/jsontest` with the path of the
|
||||
@@ -169,6 +142,29 @@ Run the Python script `doxybuild.py` from the top directory:
|
||||
|
||||
See `doxybuild.py --help` for options.
|
||||
|
||||
Generating amalgamated source and header
|
||||
----------------------------------------
|
||||
JsonCpp is provided with a script to generate a single header and a single
|
||||
source file to ease inclusion into an existing project. The amalgamated source
|
||||
can be generated at any time by running the following command from the
|
||||
top-directory (this requires Python 2.6):
|
||||
|
||||
python amalgamate.py
|
||||
|
||||
It is possible to specify header name. See the `-h` option for detail.
|
||||
|
||||
By default, the following files are generated:
|
||||
* `dist/jsoncpp.cpp`: source file that needs to be added to your project.
|
||||
* `dist/json/json.h`: corresponding header file for use in your project. It is
|
||||
equivalent to including `json/json.h` in non-amalgamated source. This header
|
||||
only depends on standard headers.
|
||||
* `dist/json/json-forwards.h`: header that provides forward declaration of all
|
||||
JsonCpp types.
|
||||
|
||||
The amalgamated sources are generated by concatenating JsonCpp source in the
|
||||
correct order and defining the macro `JSON_IS_AMALGAMATION` to prevent inclusion
|
||||
of other headers.
|
||||
|
||||
Adding a reader/writer test
|
||||
---------------------------
|
||||
To add a test, you need to create two files in test/data:
|
||||
|
@@ -67,7 +67,6 @@ def amalgamate_source(source_top_dir=None,
|
||||
header.add_text("/// to prevent private header inclusion.")
|
||||
header.add_text("#define JSON_IS_AMALGAMATION")
|
||||
header.add_file("include/json/version.h")
|
||||
#header.add_file("include/json/allocator.h") # Not available here.
|
||||
header.add_file("include/json/config.h")
|
||||
header.add_file("include/json/forwards.h")
|
||||
header.add_file("include/json/features.h")
|
||||
|
35
appveyor.yml
35
appveyor.yml
@@ -1,35 +0,0 @@
|
||||
# This is a comment.
|
||||
|
||||
version: build.{build}
|
||||
|
||||
os: Windows Server 2012 R2
|
||||
|
||||
clone_folder: c:\projects\jsoncpp
|
||||
|
||||
platform:
|
||||
- Win32
|
||||
- x64
|
||||
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
|
||||
# scripts to run before build
|
||||
before_build:
|
||||
- echo "Running cmake..."
|
||||
- cd c:\projects\jsoncpp
|
||||
- cmake --version
|
||||
- set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
|
||||
- if %PLATFORM% == Win32 cmake .
|
||||
- if %PLATFORM% == x64 cmake -G "Visual Studio 12 2013 Win64" .
|
||||
|
||||
build:
|
||||
project: jsoncpp.sln # path to Visual Studio solution or project
|
||||
|
||||
deploy:
|
||||
provider: GitHub
|
||||
auth_token:
|
||||
secure: K2Tp1q8pIZ7rs0Ot24ZMWuwr12Ev6Tc6QkhMjGQxoQG3ng1pXtgPasiJ45IDXGdg
|
||||
on:
|
||||
branch: master
|
||||
appveyor_repo_tag: true
|
@@ -16,7 +16,7 @@ dox:
|
||||
# Then 'git add -A' and 'git push' in jsoncpp-docs.
|
||||
build:
|
||||
mkdir -p build/debug
|
||||
cd build/debug; cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_SHARED_LIBS=ON -G "Unix Makefiles" ../..
|
||||
cd build/debug; cmake -DCMAKE_BUILD_TYPE=debug -DJSONCPP_LIB_BUILD_SHARED=ON -G "Unix Makefiles" ../..
|
||||
make -C build/debug
|
||||
|
||||
# Currently, this depends on include/json/version.h generated
|
||||
@@ -26,9 +26,6 @@ test-amalgamate:
|
||||
python3.4 amalgamate.py
|
||||
cd dist; gcc -I. -c jsoncpp.cpp
|
||||
|
||||
valgrind:
|
||||
valgrind --error-exitcode=42 --leak-check=full ./build/debug/src/test_lib_json/jsoncpp_test
|
||||
|
||||
clean:
|
||||
\rm -rf *.gz *.asc dist/
|
||||
|
||||
|
@@ -1,6 +1 @@
|
||||
# Copyright 2010 Baptiste Lepilleur
|
||||
# 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
|
||||
|
||||
# module
|
||||
# module
|
@@ -1,33 +1,33 @@
|
||||
{
|
||||
"cmake_variants" : [
|
||||
{"name": "generator",
|
||||
"generators": [
|
||||
{"generator": [
|
||||
"Visual Studio 7 .NET 2003",
|
||||
"Visual Studio 9 2008",
|
||||
"Visual Studio 9 2008 Win64",
|
||||
"Visual Studio 10",
|
||||
"Visual Studio 10 Win64",
|
||||
"Visual Studio 11",
|
||||
"Visual Studio 11 Win64"
|
||||
]
|
||||
},
|
||||
{"generator": ["MinGW Makefiles"],
|
||||
"env_prepend": [{"path": "c:/wut/prg/MinGW/bin"}]
|
||||
}
|
||||
]
|
||||
},
|
||||
{"name": "shared_dll",
|
||||
"variables": [
|
||||
["BUILD_SHARED_LIBS=true"],
|
||||
["BUILD_SHARED_LIBS=false"]
|
||||
]
|
||||
},
|
||||
{"name": "build_type",
|
||||
"build_types": [
|
||||
"debug",
|
||||
"release"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"cmake_variants" : [
|
||||
{"name": "generator",
|
||||
"generators": [
|
||||
{"generator": [
|
||||
"Visual Studio 7 .NET 2003",
|
||||
"Visual Studio 9 2008",
|
||||
"Visual Studio 9 2008 Win64",
|
||||
"Visual Studio 10",
|
||||
"Visual Studio 10 Win64",
|
||||
"Visual Studio 11",
|
||||
"Visual Studio 11 Win64"
|
||||
]
|
||||
},
|
||||
{"generator": ["MinGW Makefiles"],
|
||||
"env_prepend": [{"path": "c:/wut/prg/MinGW/bin"}]
|
||||
}
|
||||
]
|
||||
},
|
||||
{"name": "shared_dll",
|
||||
"variables": [
|
||||
["JSONCPP_LIB_BUILD_SHARED=true"],
|
||||
["JSONCPP_LIB_BUILD_SHARED=false"]
|
||||
]
|
||||
},
|
||||
{"name": "build_type",
|
||||
"build_types": [
|
||||
"debug",
|
||||
"release"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -1,26 +1,26 @@
|
||||
{
|
||||
"cmake_variants" : [
|
||||
{"name": "generator",
|
||||
"generators": [
|
||||
{"generator": [
|
||||
"Visual Studio 6",
|
||||
"Visual Studio 7",
|
||||
"Visual Studio 8 2005"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{"name": "shared_dll",
|
||||
"variables": [
|
||||
["BUILD_SHARED_LIBS=true"],
|
||||
["BUILD_SHARED_LIBS=false"]
|
||||
]
|
||||
},
|
||||
{"name": "build_type",
|
||||
"build_types": [
|
||||
"debug",
|
||||
"release"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"cmake_variants" : [
|
||||
{"name": "generator",
|
||||
"generators": [
|
||||
{"generator": [
|
||||
"Visual Studio 6",
|
||||
"Visual Studio 7",
|
||||
"Visual Studio 8 2005"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{"name": "shared_dll",
|
||||
"variables": [
|
||||
["JSONCPP_LIB_BUILD_SHARED=true"],
|
||||
["JSONCPP_LIB_BUILD_SHARED=false"]
|
||||
]
|
||||
},
|
||||
{"name": "build_type",
|
||||
"build_types": [
|
||||
"debug",
|
||||
"release"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -1,9 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Copyright 2009 Baptiste Lepilleur
|
||||
# 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
|
||||
# Baptiste Lepilleur, 2009
|
||||
|
||||
from __future__ import print_function
|
||||
from dircache import listdir
|
||||
|
@@ -1,11 +1,5 @@
|
||||
# Copyright 2010 Baptiste Lepilleur
|
||||
# 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
|
||||
|
||||
from __future__ import print_function
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
def fix_source_eol(path, is_dry_run = True, verbose = True, eol = '\n'):
|
||||
"""Makes sure that all sources have the specified eol sequence (default: unix)."""
|
||||
|
@@ -1,8 +1,3 @@
|
||||
# Copyright 2010 Baptiste Lepilleur
|
||||
# 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
|
||||
|
||||
from contextlib import closing
|
||||
import os
|
||||
import tarfile
|
||||
|
@@ -31,7 +31,7 @@ def find_program(*filenames):
|
||||
paths = os.environ.get('PATH', '').split(os.pathsep)
|
||||
suffixes = ('win32' in sys.platform) and '.exe .com .bat .cmd' or ''
|
||||
for filename in filenames:
|
||||
for name in [filename+ext for ext in suffixes.split(' ')]:
|
||||
for name in [filename+ext for ext in suffixes.split()]:
|
||||
for directory in paths:
|
||||
full_path = os.path.join(directory, name)
|
||||
if os.path.isfile(full_path):
|
||||
@@ -72,7 +72,7 @@ def run_cmd(cmd, silent=False):
|
||||
if silent:
|
||||
status, output = getstatusoutput(cmd)
|
||||
else:
|
||||
status, output = subprocess.call(cmd), ''
|
||||
status, output = os.system(' '.join(cmd)), ''
|
||||
if status:
|
||||
msg = 'Error while %s ...\n\terror=%d, output="""%s"""' %(info, status, output)
|
||||
raise Exception(msg)
|
||||
|
@@ -1,94 +0,0 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
|
||||
#ifndef CPPTL_JSON_ALLOCATOR_H_INCLUDED
|
||||
#define CPPTL_JSON_ALLOCATOR_H_INCLUDED
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
namespace Json {
|
||||
template<typename T>
|
||||
class SecureAllocator {
|
||||
public:
|
||||
// Type definitions
|
||||
using value_type = T;
|
||||
using pointer = T*;
|
||||
using const_pointer = const T*;
|
||||
using reference = T&;
|
||||
using const_reference = const T&;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
/**
|
||||
* Allocate memory for N items using the standard allocator.
|
||||
*/
|
||||
pointer allocate(size_type n) {
|
||||
// allocate using "global operator new"
|
||||
return static_cast<pointer>(::operator new(n * sizeof(T)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Release memory which was allocated for N items at pointer P.
|
||||
*
|
||||
* 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) {
|
||||
std::memset(p, 0, n * sizeof(T));
|
||||
// free using "global operator delete"
|
||||
::operator delete(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an item in-place at pointer P.
|
||||
*/
|
||||
template<typename... Args>
|
||||
void construct(pointer p, Args&&... args) {
|
||||
// construct using "placement new" and "perfect forwarding"
|
||||
::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
size_type max_size() const {
|
||||
return size_t(-1) / sizeof(T);
|
||||
}
|
||||
|
||||
pointer address( reference x ) const {
|
||||
return std::addressof(x);
|
||||
}
|
||||
|
||||
const_pointer address( const_reference x ) const {
|
||||
return std::addressof(x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy an item in-place at pointer P.
|
||||
*/
|
||||
void destroy(pointer p) {
|
||||
// destroy using "explicit destructor"
|
||||
p->~T();
|
||||
}
|
||||
|
||||
// Boilerplate
|
||||
SecureAllocator() {}
|
||||
template<typename U> SecureAllocator(const SecureAllocator<U>&) {}
|
||||
template<typename U> struct rebind { using other = SecureAllocator<U>; };
|
||||
};
|
||||
|
||||
|
||||
template<typename T, typename U>
|
||||
bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T, typename U>
|
||||
bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} //namespace Json
|
||||
|
||||
#endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED
|
@@ -25,7 +25,7 @@
|
||||
|
||||
# define JSON_FAIL_MESSAGE(message) \
|
||||
{ \
|
||||
JSONCPP_OSTRINGSTREAM oss; oss << message; \
|
||||
std::ostringstream oss; oss << message; \
|
||||
Json::throwLogicError(oss.str()); \
|
||||
abort(); \
|
||||
}
|
||||
@@ -38,7 +38,7 @@
|
||||
// release builds we abort, for a core-dump or debugger.
|
||||
# define JSON_FAIL_MESSAGE(message) \
|
||||
{ \
|
||||
JSONCPP_OSTRINGSTREAM oss; oss << message; \
|
||||
std::ostringstream oss; oss << message; \
|
||||
assert(false && oss.str().c_str()); \
|
||||
abort(); \
|
||||
}
|
||||
|
@@ -5,8 +5,6 @@
|
||||
|
||||
#ifndef JSON_CONFIG_H_INCLUDED
|
||||
#define JSON_CONFIG_H_INCLUDED
|
||||
#include <stddef.h>
|
||||
#include <string> //typdef String
|
||||
|
||||
/// If defined, indicates that json library is embedded in CppTL library.
|
||||
//# define JSON_IN_CPPTL 1
|
||||
@@ -39,12 +37,12 @@
|
||||
#ifdef JSON_IN_CPPTL
|
||||
#define JSON_API CPPTL_API
|
||||
#elif defined(JSON_DLL_BUILD)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#if defined(_MSC_VER)
|
||||
#define JSON_API __declspec(dllexport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#endif // if defined(_MSC_VER)
|
||||
#elif defined(JSON_DLL)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#if defined(_MSC_VER)
|
||||
#define JSON_API __declspec(dllimport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#endif // if defined(_MSC_VER)
|
||||
@@ -58,87 +56,34 @@
|
||||
// Storages, and 64 bits integer support is disabled.
|
||||
// #define JSON_NO_INT64 1
|
||||
|
||||
#if defined(_MSC_VER) // MSVC
|
||||
# if _MSC_VER <= 1200 // MSVC 6
|
||||
// Microsoft Visual Studio 6 only support conversion from __int64 to double
|
||||
// (no conversion from unsigned __int64).
|
||||
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
|
||||
// characters in the debug information)
|
||||
// All projects I've ever seen with VS6 were using this globally (not bothering
|
||||
// with pragma push/pop).
|
||||
# pragma warning(disable : 4786)
|
||||
# endif // MSVC 6
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
|
||||
// Microsoft Visual Studio 6 only support conversion from __int64 to double
|
||||
// (no conversion from unsigned __int64).
|
||||
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
|
||||
// characters in the debug information)
|
||||
// All projects I've ever seen with VS6 were using this globally (not bothering
|
||||
// with pragma push/pop).
|
||||
#pragma warning(disable : 4786)
|
||||
#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
|
||||
|
||||
# if _MSC_VER >= 1500 // MSVC 2008
|
||||
/// Indicates that the following function is deprecated.
|
||||
# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
||||
# endif
|
||||
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
// In c++11 the override keyword allows you to explicity define that a function
|
||||
// is intended to override the base-class version. This makes the code more
|
||||
// managable and fixes a set of common hard-to-find bugs.
|
||||
#if __cplusplus >= 201103L
|
||||
# define JSONCPP_OVERRIDE override
|
||||
#elif defined(_MSC_VER) && _MSC_VER > 1600
|
||||
# define JSONCPP_OVERRIDE override
|
||||
#else
|
||||
# define JSONCPP_OVERRIDE
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
|
||||
/// Indicates that the following function is deprecated.
|
||||
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
||||
#elif defined(__clang__) && defined(__has_feature)
|
||||
#if __has_feature(attribute_deprecated_with_message)
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
||||
#endif
|
||||
|
||||
#ifndef JSON_HAS_RVALUE_REFERENCES
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
|
||||
#define JSON_HAS_RVALUE_REFERENCES 1
|
||||
#endif // MSVC >= 2010
|
||||
|
||||
#ifdef __clang__
|
||||
#if __has_feature(cxx_rvalue_references)
|
||||
#define JSON_HAS_RVALUE_REFERENCES 1
|
||||
#endif // has_feature
|
||||
|
||||
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
|
||||
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
|
||||
#define JSON_HAS_RVALUE_REFERENCES 1
|
||||
#endif // GXX_EXPERIMENTAL
|
||||
|
||||
#endif // __clang__ || __GNUC__
|
||||
|
||||
#endif // not defined JSON_HAS_RVALUE_REFERENCES
|
||||
|
||||
#ifndef JSON_HAS_RVALUE_REFERENCES
|
||||
#define JSON_HAS_RVALUE_REFERENCES 0
|
||||
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
||||
#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
|
||||
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||
# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
||||
# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
# define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
|
||||
# endif // GNUC version
|
||||
#endif // __clang__ || __GNUC__
|
||||
|
||||
#if !defined(JSONCPP_DEPRECATED)
|
||||
#define JSONCPP_DEPRECATED(message)
|
||||
#endif // if !defined(JSONCPP_DEPRECATED)
|
||||
|
||||
#if __GNUC__ >= 6
|
||||
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
#endif
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
# include "version.h"
|
||||
|
||||
# if JSONCPP_USING_SECURE_MEMORY
|
||||
# include "allocator.h" //typedef Allocator
|
||||
# endif
|
||||
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
typedef int Int;
|
||||
typedef unsigned int UInt;
|
||||
@@ -159,19 +104,6 @@ typedef Int64 LargestInt;
|
||||
typedef UInt64 LargestUInt;
|
||||
#define JSON_HAS_INT64
|
||||
#endif // if defined(JSON_NO_INT64)
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
#define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
|
||||
#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_ISTREAM std::istream
|
||||
#else
|
||||
#define JSONCPP_STRING std::string
|
||||
#define JSONCPP_OSTRINGSTREAM std::ostringstream
|
||||
#define JSONCPP_OSTREAM std::ostream
|
||||
#define JSONCPP_ISTRINGSTREAM std::istringstream
|
||||
#define JSONCPP_ISTREAM std::istream
|
||||
#endif // if JSONCPP_USING_SECURE_MEMORY
|
||||
} // end namespace Json
|
||||
|
||||
#endif // JSON_CONFIG_H_INCLUDED
|
||||
|
@@ -44,12 +44,6 @@ public:
|
||||
/// \c true if root must be either an array or an object value. Default: \c
|
||||
/// false.
|
||||
bool strictRoot_;
|
||||
|
||||
/// \c true if dropped null placeholders are allowed. Default: \c false.
|
||||
bool allowDroppedNullPlaceholders_;
|
||||
|
||||
/// \c true if numeric object key are allowed. Default: \c false.
|
||||
bool allowNumericKeys_;
|
||||
};
|
||||
|
||||
} // namespace Json
|
||||
|
@@ -35,18 +35,6 @@ public:
|
||||
typedef char Char;
|
||||
typedef const Char* Location;
|
||||
|
||||
/** \brief An error tagged with where in the JSON text it was encountered.
|
||||
*
|
||||
* The offsets give the [start, limit) range of bytes within the text. Note
|
||||
* that this is bytes, not codepoints.
|
||||
*
|
||||
*/
|
||||
struct StructuredError {
|
||||
ptrdiff_t offset_start;
|
||||
ptrdiff_t offset_limit;
|
||||
JSONCPP_STRING message;
|
||||
};
|
||||
|
||||
/** \brief Constructs a Reader allowing all features
|
||||
* for parsing.
|
||||
*/
|
||||
@@ -99,7 +87,7 @@ public:
|
||||
|
||||
/// \brief Parse from input stream.
|
||||
/// \see Json::operator>>(std::istream&, Json::Value&).
|
||||
bool parse(JSONCPP_ISTREAM& is, Value& root, bool collectComments = true);
|
||||
bool parse(std::istream& is, Value& root, bool collectComments = true);
|
||||
|
||||
/** \brief Returns a user friendly string that list errors in the parsed
|
||||
* document.
|
||||
@@ -111,7 +99,7 @@ public:
|
||||
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
|
||||
*/
|
||||
JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
|
||||
JSONCPP_STRING getFormatedErrorMessages() const;
|
||||
std::string getFormatedErrorMessages() const;
|
||||
|
||||
/** \brief Returns a user friendly string that list errors in the parsed
|
||||
* document.
|
||||
@@ -121,39 +109,7 @@ public:
|
||||
* occurred
|
||||
* during parsing.
|
||||
*/
|
||||
JSONCPP_STRING getFormattedErrorMessages() const;
|
||||
|
||||
/** \brief Returns a vector of structured erros encounted while parsing.
|
||||
* \return A (possibly empty) vector of StructuredError objects. Currently
|
||||
* only one error can be returned, but the caller should tolerate
|
||||
* multiple
|
||||
* errors. This can occur if the parser recovers from a non-fatal
|
||||
* parse error and then encounters additional errors.
|
||||
*/
|
||||
std::vector<StructuredError> getStructuredErrors() const;
|
||||
|
||||
/** \brief Add a semantic error message.
|
||||
* \param value JSON Value location associated with the error
|
||||
* \param message The error message.
|
||||
* \return \c true if the error was successfully added, \c false if the
|
||||
* Value offset exceeds the document size.
|
||||
*/
|
||||
bool pushError(const Value& value, const JSONCPP_STRING& message);
|
||||
|
||||
/** \brief Add a semantic error message with extra context.
|
||||
* \param value JSON Value location associated with the error
|
||||
* \param message The error message.
|
||||
* \param extra Additional JSON Value location to contextualize the error
|
||||
* \return \c true if the error was successfully added, \c false if either
|
||||
* Value offset exceeds the document size.
|
||||
*/
|
||||
bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra);
|
||||
|
||||
/** \brief Return whether there are any errors.
|
||||
* \return \c true if there are no errors to report \c false if
|
||||
* errors have occurred.
|
||||
*/
|
||||
bool good() const;
|
||||
std::string getFormattedErrorMessages() const;
|
||||
|
||||
private:
|
||||
enum TokenType {
|
||||
@@ -183,7 +139,7 @@ private:
|
||||
class ErrorInfo {
|
||||
public:
|
||||
Token token_;
|
||||
JSONCPP_STRING message_;
|
||||
std::string message_;
|
||||
Location extra_;
|
||||
};
|
||||
|
||||
@@ -203,7 +159,7 @@ private:
|
||||
bool decodeNumber(Token& token);
|
||||
bool decodeNumber(Token& token, Value& decoded);
|
||||
bool decodeString(Token& token);
|
||||
bool decodeString(Token& token, JSONCPP_STRING& decoded);
|
||||
bool decodeString(Token& token, std::string& decoded);
|
||||
bool decodeDouble(Token& token);
|
||||
bool decodeDouble(Token& token, Value& decoded);
|
||||
bool decodeUnicodeCodePoint(Token& token,
|
||||
@@ -214,9 +170,9 @@ private:
|
||||
Location& current,
|
||||
Location end,
|
||||
unsigned int& unicode);
|
||||
bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0);
|
||||
bool addError(const std::string& message, Token& token, Location extra = 0);
|
||||
bool recoverFromError(TokenType skipUntilToken);
|
||||
bool addErrorAndRecover(const JSONCPP_STRING& message,
|
||||
bool addErrorAndRecover(const std::string& message,
|
||||
Token& token,
|
||||
TokenType skipUntilToken);
|
||||
void skipUntilSpace();
|
||||
@@ -224,20 +180,20 @@ private:
|
||||
Char getNextChar();
|
||||
void
|
||||
getLocationLineAndColumn(Location location, int& line, int& column) const;
|
||||
JSONCPP_STRING getLocationLineAndColumn(Location location) const;
|
||||
std::string getLocationLineAndColumn(Location location) const;
|
||||
void addComment(Location begin, Location end, CommentPlacement placement);
|
||||
void skipCommentTokens(Token& token);
|
||||
|
||||
typedef std::stack<Value*> Nodes;
|
||||
Nodes nodes_;
|
||||
Errors errors_;
|
||||
JSONCPP_STRING document_;
|
||||
std::string document_;
|
||||
Location begin_;
|
||||
Location end_;
|
||||
Location current_;
|
||||
Location lastValueEnd_;
|
||||
Value* lastValue_;
|
||||
JSONCPP_STRING commentsBefore_;
|
||||
std::string commentsBefore_;
|
||||
Features features_;
|
||||
bool collectComments_;
|
||||
}; // Reader
|
||||
@@ -266,9 +222,9 @@ public:
|
||||
*/
|
||||
virtual bool parse(
|
||||
char const* beginDoc, char const* endDoc,
|
||||
Value* root, JSONCPP_STRING* errs) = 0;
|
||||
Value* root, std::string* errs) = 0;
|
||||
|
||||
class JSON_API Factory {
|
||||
class Factory {
|
||||
public:
|
||||
virtual ~Factory() {}
|
||||
/** \brief Allocate a CharReader via operator new().
|
||||
@@ -286,7 +242,7 @@ Usage:
|
||||
CharReaderBuilder builder;
|
||||
builder["collectComments"] = false;
|
||||
Value value;
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
bool ok = parseFromStream(builder, std::cin, &value, &errs);
|
||||
\endcode
|
||||
*/
|
||||
@@ -321,9 +277,6 @@ public:
|
||||
the JSON value in the input string.
|
||||
- `"rejectDupKeys": false or true`
|
||||
- If true, `parse()` returns false when a key is duplicated within an object.
|
||||
- `"allowSpecialFloats": false or true`
|
||||
- If true, special float values (NaNs and infinities) are allowed
|
||||
and their values are lossfree restorable.
|
||||
|
||||
You can examine 'settings_` yourself
|
||||
to see the defaults. You can also write and read them just like any
|
||||
@@ -333,9 +286,9 @@ public:
|
||||
Json::Value settings_;
|
||||
|
||||
CharReaderBuilder();
|
||||
~CharReaderBuilder() JSONCPP_OVERRIDE;
|
||||
virtual ~CharReaderBuilder();
|
||||
|
||||
CharReader* newCharReader() const JSONCPP_OVERRIDE;
|
||||
virtual CharReader* newCharReader() const;
|
||||
|
||||
/** \return true if 'settings' are legal and consistent;
|
||||
* otherwise, indicate bad settings via 'invalid'.
|
||||
@@ -344,18 +297,18 @@ public:
|
||||
|
||||
/** A simple way to update a specific setting.
|
||||
*/
|
||||
Value& operator[](JSONCPP_STRING key);
|
||||
Value& operator[](std::string key);
|
||||
|
||||
/** Called by ctor, but you can use this to reset settings_.
|
||||
* \pre 'settings' != NULL (but Json::null is fine)
|
||||
* \remark Defaults:
|
||||
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
|
||||
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
|
||||
*/
|
||||
static void setDefaults(Json::Value* settings);
|
||||
/** Same as old Features::strictMode().
|
||||
* \pre 'settings' != NULL (but Json::null is fine)
|
||||
* \remark Defaults:
|
||||
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
|
||||
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
|
||||
*/
|
||||
static void strictMode(Json::Value* settings);
|
||||
};
|
||||
@@ -366,7 +319,7 @@ public:
|
||||
*/
|
||||
bool JSON_API parseFromStream(
|
||||
CharReader::Factory const&,
|
||||
JSONCPP_ISTREAM&,
|
||||
std::istream&,
|
||||
Value* root, std::string* errs);
|
||||
|
||||
/** \brief Read from 'sin' into 'root'.
|
||||
@@ -393,7 +346,7 @@ bool JSON_API parseFromStream(
|
||||
\throw std::exception on parse error.
|
||||
\see Json::operator<<()
|
||||
*/
|
||||
JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
|
||||
JSON_API std::istream& operator>>(std::istream&, Value&);
|
||||
|
||||
} // namespace Json
|
||||
|
||||
|
@@ -22,19 +22,6 @@
|
||||
#include <cpptl/forwards.h>
|
||||
#endif
|
||||
|
||||
//Conditional NORETURN attribute on the throw functions would:
|
||||
// a) suppress false positives from static code analysis
|
||||
// b) possibly improve optimization opportunities.
|
||||
#if !defined(JSONCPP_NORETURN)
|
||||
# if defined(_MSC_VER)
|
||||
# define JSONCPP_NORETURN __declspec(noreturn)
|
||||
# elif defined(__GNUC__)
|
||||
# define JSONCPP_NORETURN __attribute__ ((__noreturn__))
|
||||
# else
|
||||
# define JSONCPP_NORETURN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
||||
// be used by...
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
@@ -50,41 +37,26 @@ namespace Json {
|
||||
*
|
||||
* We use nothing but these internally. Of course, STL can throw others.
|
||||
*/
|
||||
class JSON_API Exception : public std::exception {
|
||||
public:
|
||||
Exception(JSONCPP_STRING const& msg);
|
||||
~Exception() throw() JSONCPP_OVERRIDE;
|
||||
char const* what() const throw() JSONCPP_OVERRIDE;
|
||||
protected:
|
||||
JSONCPP_STRING msg_;
|
||||
};
|
||||
|
||||
class JSON_API Exception;
|
||||
/** Exceptions which the user cannot easily avoid.
|
||||
*
|
||||
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
|
||||
*
|
||||
* \remark derived from Json::Exception
|
||||
*/
|
||||
class JSON_API RuntimeError : public Exception {
|
||||
public:
|
||||
RuntimeError(JSONCPP_STRING const& msg);
|
||||
};
|
||||
|
||||
class JSON_API RuntimeError;
|
||||
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
|
||||
*
|
||||
* These are precondition-violations (user bugs) and internal errors (our bugs).
|
||||
*
|
||||
* \remark derived from Json::Exception
|
||||
*/
|
||||
class JSON_API LogicError : public Exception {
|
||||
public:
|
||||
LogicError(JSONCPP_STRING const& msg);
|
||||
};
|
||||
class JSON_API LogicError;
|
||||
|
||||
/// used internally
|
||||
JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg);
|
||||
void throwRuntimeError(std::string const& msg);
|
||||
/// used internally
|
||||
JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg);
|
||||
void throwLogicError(std::string const& msg);
|
||||
|
||||
/** \brief Type of the value held by a Value object.
|
||||
*/
|
||||
@@ -175,7 +147,7 @@ private:
|
||||
class JSON_API Value {
|
||||
friend class ValueIteratorBase;
|
||||
public:
|
||||
typedef std::vector<JSONCPP_STRING> Members;
|
||||
typedef std::vector<std::string> Members;
|
||||
typedef ValueIterator iterator;
|
||||
typedef ValueConstIterator const_iterator;
|
||||
typedef Json::UInt UInt;
|
||||
@@ -188,10 +160,11 @@ public:
|
||||
typedef Json::LargestUInt LargestUInt;
|
||||
typedef Json::ArrayIndex ArrayIndex;
|
||||
|
||||
static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value().
|
||||
static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null
|
||||
static Value const& nullSingleton(); ///< Prefer this to null or nullRef.
|
||||
|
||||
static const Value& nullRef;
|
||||
#if !defined(__ARMEL__)
|
||||
/// \deprecated This exists for binary compatibility only. Use nullRef.
|
||||
static const Value null;
|
||||
#endif
|
||||
/// Minimum signed integer value that can be stored in a Json::Value.
|
||||
static const LargestInt minLargestInt;
|
||||
/// Maximum signed integer value that can be stored in a Json::Value.
|
||||
@@ -227,9 +200,6 @@ private:
|
||||
CZString(ArrayIndex index);
|
||||
CZString(char const* str, unsigned length, DuplicationPolicy allocate);
|
||||
CZString(CZString const& other);
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
CZString(CZString&& other);
|
||||
#endif
|
||||
~CZString();
|
||||
CZString& operator=(CZString other);
|
||||
bool operator<(CZString const& other) const;
|
||||
@@ -244,7 +214,7 @@ private:
|
||||
void swap(CZString& other);
|
||||
|
||||
struct StringStorage {
|
||||
unsigned policy_: 2;
|
||||
DuplicationPolicy policy_: 2;
|
||||
unsigned length_: 30; // 1GB max
|
||||
};
|
||||
|
||||
@@ -288,7 +258,7 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
#endif // if defined(JSON_HAS_INT64)
|
||||
Value(double value);
|
||||
Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
|
||||
Value(const char* begin, const char* end); ///< Copy all, incl zeroes.
|
||||
Value(const char* beginValue, const char* endValue); ///< Copy all, incl zeroes.
|
||||
/** \brief Constructs a value from a static string.
|
||||
|
||||
* Like other value string constructor but do not duplicate the string for
|
||||
@@ -305,22 +275,18 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
* \endcode
|
||||
*/
|
||||
Value(const StaticString& value);
|
||||
Value(const JSONCPP_STRING& value); ///< Copy data() til size(). Embedded zeroes too.
|
||||
Value(const std::string& value); ///< Copy data() til size(). Embedded zeroes too.
|
||||
#ifdef JSON_USE_CPPTL
|
||||
Value(const CppTL::ConstString& value);
|
||||
#endif
|
||||
Value(bool value);
|
||||
/// Deep copy.
|
||||
Value(const Value& other);
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
/// Move constructor
|
||||
Value(Value&& other);
|
||||
#endif
|
||||
~Value();
|
||||
|
||||
/// Deep copy, then swap(other).
|
||||
/// \note Over-write existing comments. To preserve comments, use #swapPayload().
|
||||
Value& operator=(Value other);
|
||||
Value &operator=(const Value &other);
|
||||
/// Swap everything.
|
||||
void swap(Value& other);
|
||||
/// Swap values but leave comments and source offsets in place.
|
||||
@@ -338,15 +304,12 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
int compare(const Value& other) const;
|
||||
|
||||
const char* asCString() const; ///< Embedded zeroes could cause you trouble!
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
unsigned getCStringLength() const; //Allows you to understand the length of the CString
|
||||
#endif
|
||||
JSONCPP_STRING asString() const; ///< Embedded zeroes are possible.
|
||||
std::string asString() const; ///< Embedded zeroes are possible.
|
||||
/** Get raw char* of string-value.
|
||||
* \return false if !string. (Seg-fault if str or end are NULL.)
|
||||
*/
|
||||
bool getString(
|
||||
char const** begin, char const** end) const;
|
||||
char const** str, char const** end) const;
|
||||
#ifdef JSON_USE_CPPTL
|
||||
CppTL::ConstString asConstString() const;
|
||||
#endif
|
||||
@@ -445,11 +408,11 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
const Value& operator[](const char* key) const;
|
||||
/// Access an object value by name, create a null member if it does not exist.
|
||||
/// \param key may contain embedded nulls.
|
||||
Value& operator[](const JSONCPP_STRING& key);
|
||||
Value& operator[](const std::string& key);
|
||||
/// Access an object value by name, returns null if there is no member with
|
||||
/// that name.
|
||||
/// \param key may contain embedded nulls.
|
||||
const Value& operator[](const JSONCPP_STRING& key) const;
|
||||
const Value& operator[](const std::string& key) const;
|
||||
/** \brief Access an object value by name, create a null member if it does not
|
||||
exist.
|
||||
|
||||
@@ -475,12 +438,12 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
Value get(const char* key, const Value& defaultValue) const;
|
||||
/// Return the member named key if it exist, defaultValue otherwise.
|
||||
/// \note deep copy
|
||||
/// \note key may contain embedded nulls.
|
||||
Value get(const char* begin, const char* end, const Value& defaultValue) const;
|
||||
/// \param key may contain embedded nulls.
|
||||
Value get(const char* key, const char* end, const Value& defaultValue) const;
|
||||
/// Return the member named key if it exist, defaultValue otherwise.
|
||||
/// \note deep copy
|
||||
/// \param key may contain embedded nulls.
|
||||
Value get(const JSONCPP_STRING& key, const Value& defaultValue) const;
|
||||
Value get(const std::string& key, const Value& defaultValue) const;
|
||||
#ifdef JSON_USE_CPPTL
|
||||
/// Return the member named key if it exist, defaultValue otherwise.
|
||||
/// \note deep copy
|
||||
@@ -488,12 +451,12 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
#endif
|
||||
/// Most general and efficient version of isMember()const, get()const,
|
||||
/// and operator[]const
|
||||
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
|
||||
Value const* find(char const* begin, char const* end) const;
|
||||
/// \note As stated elsewhere, behavior is undefined if (end-key) >= 2^30
|
||||
Value const* find(char const* key, char const* end) const;
|
||||
/// Most general and efficient version of object-mutators.
|
||||
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
|
||||
/// \note As stated elsewhere, behavior is undefined if (end-key) >= 2^30
|
||||
/// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
|
||||
Value const* demand(char const* begin, char const* end);
|
||||
Value const* demand(char const* key, char const* end);
|
||||
/// \brief Remove and return the named member.
|
||||
///
|
||||
/// Do nothing if it did not exist.
|
||||
@@ -505,8 +468,8 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
/// Same as removeMember(const char*)
|
||||
/// \param key may contain embedded nulls.
|
||||
/// \deprecated
|
||||
Value removeMember(const JSONCPP_STRING& key);
|
||||
/// Same as removeMember(const char* begin, const char* end, Value* removed),
|
||||
Value removeMember(const std::string& key);
|
||||
/// Same as removeMember(const char* key, const char* end, Value* removed),
|
||||
/// but 'key' is null-terminated.
|
||||
bool removeMember(const char* key, Value* removed);
|
||||
/** \brief Remove the named map member.
|
||||
@@ -515,9 +478,9 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
\param key may contain embedded nulls.
|
||||
\return true iff removed (no exceptions)
|
||||
*/
|
||||
bool removeMember(JSONCPP_STRING const& key, Value* removed);
|
||||
/// Same as removeMember(JSONCPP_STRING const& key, Value* removed)
|
||||
bool removeMember(const char* begin, const char* end, Value* removed);
|
||||
bool removeMember(std::string const& key, Value* removed);
|
||||
/// Same as removeMember(std::string const& key, Value* removed)
|
||||
bool removeMember(const char* key, const char* end, Value* removed);
|
||||
/** \brief Remove the indexed array element.
|
||||
|
||||
O(n) expensive operations.
|
||||
@@ -531,9 +494,9 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
bool isMember(const char* key) const;
|
||||
/// Return true if the object has a member named key.
|
||||
/// \param key may contain embedded nulls.
|
||||
bool isMember(const JSONCPP_STRING& key) const;
|
||||
/// Same as isMember(JSONCPP_STRING const& key)const
|
||||
bool isMember(const char* begin, const char* end) const;
|
||||
bool isMember(const std::string& key) const;
|
||||
/// Same as isMember(std::string const& key)const
|
||||
bool isMember(const char* key, const char* end) const;
|
||||
#ifdef JSON_USE_CPPTL
|
||||
/// Return true if the object has a member named key.
|
||||
bool isMember(const CppTL::ConstString& key) const;
|
||||
@@ -552,17 +515,17 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
//# endif
|
||||
|
||||
/// \deprecated Always pass len.
|
||||
JSONCPP_DEPRECATED("Use setComment(JSONCPP_STRING const&) instead.")
|
||||
JSONCPP_DEPRECATED("Use setComment(std::string const&) instead.")
|
||||
void setComment(const char* comment, CommentPlacement placement);
|
||||
/// Comments must be //... or /* ... */
|
||||
void setComment(const char* comment, size_t len, CommentPlacement placement);
|
||||
/// Comments must be //... or /* ... */
|
||||
void setComment(const JSONCPP_STRING& comment, CommentPlacement placement);
|
||||
void setComment(const std::string& comment, CommentPlacement placement);
|
||||
bool hasComment(CommentPlacement placement) const;
|
||||
/// Include delimiters and embedded newlines.
|
||||
JSONCPP_STRING getComment(CommentPlacement placement) const;
|
||||
std::string getComment(CommentPlacement placement) const;
|
||||
|
||||
JSONCPP_STRING toStyledString() const;
|
||||
std::string toStyledString() const;
|
||||
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
@@ -570,13 +533,6 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
iterator begin();
|
||||
iterator end();
|
||||
|
||||
// Accessors for the [start, limit) range of bytes within the JSON text from
|
||||
// which this value was parsed, if any.
|
||||
void setOffsetStart(ptrdiff_t start);
|
||||
void setOffsetLimit(ptrdiff_t limit);
|
||||
ptrdiff_t getOffsetStart() const;
|
||||
ptrdiff_t getOffsetLimit() const;
|
||||
|
||||
private:
|
||||
void initBasic(ValueType type, bool allocated = false);
|
||||
|
||||
@@ -613,11 +569,6 @@ private:
|
||||
unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
|
||||
// If not allocated_, string_ must be null-terminated.
|
||||
CommentInfo* comments_;
|
||||
|
||||
// [start, limit) byte offsets in the source JSON text from which this Value
|
||||
// was extracted.
|
||||
ptrdiff_t start_;
|
||||
ptrdiff_t limit_;
|
||||
};
|
||||
|
||||
/** \brief Experimental and untested: represents an element of the "path" to
|
||||
@@ -630,7 +581,7 @@ public:
|
||||
PathArgument();
|
||||
PathArgument(ArrayIndex index);
|
||||
PathArgument(const char* key);
|
||||
PathArgument(const JSONCPP_STRING& key);
|
||||
PathArgument(const std::string& key);
|
||||
|
||||
private:
|
||||
enum Kind {
|
||||
@@ -638,7 +589,7 @@ private:
|
||||
kindIndex,
|
||||
kindKey
|
||||
};
|
||||
JSONCPP_STRING key_;
|
||||
std::string key_;
|
||||
ArrayIndex index_;
|
||||
Kind kind_;
|
||||
};
|
||||
@@ -656,7 +607,7 @@ private:
|
||||
*/
|
||||
class JSON_API Path {
|
||||
public:
|
||||
Path(const JSONCPP_STRING& path,
|
||||
Path(const std::string& path,
|
||||
const PathArgument& a1 = PathArgument(),
|
||||
const PathArgument& a2 = PathArgument(),
|
||||
const PathArgument& a3 = PathArgument(),
|
||||
@@ -673,12 +624,12 @@ private:
|
||||
typedef std::vector<const PathArgument*> InArgs;
|
||||
typedef std::vector<PathArgument> Args;
|
||||
|
||||
void makePath(const JSONCPP_STRING& path, const InArgs& in);
|
||||
void addPathInArg(const JSONCPP_STRING& path,
|
||||
void makePath(const std::string& path, const InArgs& in);
|
||||
void addPathInArg(const std::string& path,
|
||||
const InArgs& in,
|
||||
InArgs::const_iterator& itInArg,
|
||||
PathArgument::Kind kind);
|
||||
void invalidPath(const JSONCPP_STRING& path, int location);
|
||||
void invalidPath(const std::string& path, int location);
|
||||
|
||||
Args args_;
|
||||
};
|
||||
@@ -693,6 +644,9 @@ public:
|
||||
typedef int difference_type;
|
||||
typedef ValueIteratorBase SelfType;
|
||||
|
||||
ValueIteratorBase();
|
||||
explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
|
||||
|
||||
bool operator==(const SelfType& other) const { return isEqual(other); }
|
||||
|
||||
bool operator!=(const SelfType& other) const { return !isEqual(other); }
|
||||
@@ -711,7 +665,7 @@ public:
|
||||
/// Return the member name of the referenced Value, or "" if it is not an
|
||||
/// objectValue.
|
||||
/// \note Avoid `c_str()` on result, as embedded zeroes are possible.
|
||||
JSONCPP_STRING name() const;
|
||||
std::string name() const;
|
||||
|
||||
/// Return the member name of the referenced Value. "" if it is not an
|
||||
/// objectValue.
|
||||
@@ -740,12 +694,6 @@ private:
|
||||
Value::ObjectValues::iterator current_;
|
||||
// Indicates that iterator is for a null value.
|
||||
bool isNull_;
|
||||
|
||||
public:
|
||||
// For some reason, BORLAND needs these at the end, rather
|
||||
// than earlier. No idea why.
|
||||
ValueIteratorBase();
|
||||
explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
|
||||
};
|
||||
|
||||
/** \brief const iterator for object and array value.
|
||||
@@ -763,7 +711,6 @@ public:
|
||||
typedef ValueConstIterator SelfType;
|
||||
|
||||
ValueConstIterator();
|
||||
ValueConstIterator(ValueIterator const& other);
|
||||
|
||||
private:
|
||||
/*! \internal Use by Value to create an iterator.
|
||||
@@ -813,7 +760,7 @@ public:
|
||||
typedef ValueIterator SelfType;
|
||||
|
||||
ValueIterator();
|
||||
explicit ValueIterator(const ValueConstIterator& other);
|
||||
ValueIterator(const ValueConstIterator& other);
|
||||
ValueIterator(const ValueIterator& other);
|
||||
|
||||
private:
|
||||
|
@@ -1,20 +1,14 @@
|
||||
// DO NOT EDIT. This file (and "version") is generated by CMake.
|
||||
// DO NOT EDIT. This file is generated by CMake from "version"
|
||||
// and "version.h.in" files.
|
||||
// Run CMake configure step to update it.
|
||||
#ifndef JSON_VERSION_H_INCLUDED
|
||||
# define JSON_VERSION_H_INCLUDED
|
||||
|
||||
# define JSONCPP_VERSION_STRING "1.7.4"
|
||||
# define JSONCPP_VERSION_STRING "1.10.0"
|
||||
# define JSONCPP_VERSION_MAJOR 1
|
||||
# define JSONCPP_VERSION_MINOR 7
|
||||
# define JSONCPP_VERSION_PATCH 4
|
||||
# define JSONCPP_VERSION_MINOR 10
|
||||
# define JSONCPP_VERSION_PATCH 0
|
||||
# define JSONCPP_VERSION_QUALIFIER
|
||||
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
||||
|
||||
#ifdef JSONCPP_USING_SECURE_MEMORY
|
||||
#undef JSONCPP_USING_SECURE_MEMORY
|
||||
#endif
|
||||
#define JSONCPP_USING_SECURE_MEMORY 0
|
||||
// If non-zero, the library zeroes any memory that it has allocated before
|
||||
// it frees its memory.
|
||||
|
||||
#endif // JSON_VERSION_H_INCLUDED
|
||||
|
@@ -39,7 +39,7 @@ Usage:
|
||||
*/
|
||||
class JSON_API StreamWriter {
|
||||
protected:
|
||||
JSONCPP_OSTREAM* sout_; // not owned; will not delete
|
||||
std::ostream* sout_; // not owned; will not delete
|
||||
public:
|
||||
StreamWriter();
|
||||
virtual ~StreamWriter();
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
\return zero on success (For now, we always return zero, so check the stream instead.)
|
||||
\throw std::exception possibly, depending on configuration
|
||||
*/
|
||||
virtual int write(Value const& root, JSONCPP_OSTREAM* sout) = 0;
|
||||
virtual int write(Value const& root, std::ostream* sout) = 0;
|
||||
|
||||
/** \brief A simple abstract factory.
|
||||
*/
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
/** \brief Write into stringstream, then return string, for convenience.
|
||||
* A StreamWriter will be created from the factory, used, and then deleted.
|
||||
*/
|
||||
JSONCPP_STRING JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
|
||||
std::string JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
|
||||
|
||||
|
||||
/** \brief Build a StreamWriter implementation.
|
||||
@@ -99,10 +99,6 @@ public:
|
||||
Strictly speaking, this is not valid JSON. But when the output is being
|
||||
fed to a browser's Javascript, it makes for smaller output and the
|
||||
browser can handle the output just fine.
|
||||
- "useSpecialFloats": false or true
|
||||
- If true, outputs non-finite floating point values in the following way:
|
||||
NaN values as "NaN", positive infinity as "Infinity", and negative infinity
|
||||
as "-Infinity".
|
||||
|
||||
You can examine 'settings_` yourself
|
||||
to see the defaults. You can also write and read them just like any
|
||||
@@ -112,12 +108,12 @@ public:
|
||||
Json::Value settings_;
|
||||
|
||||
StreamWriterBuilder();
|
||||
~StreamWriterBuilder() JSONCPP_OVERRIDE;
|
||||
virtual ~StreamWriterBuilder();
|
||||
|
||||
/**
|
||||
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
||||
*/
|
||||
StreamWriter* newStreamWriter() const JSONCPP_OVERRIDE;
|
||||
virtual StreamWriter* newStreamWriter() const;
|
||||
|
||||
/** \return true if 'settings' are legal and consistent;
|
||||
* otherwise, indicate bad settings via 'invalid'.
|
||||
@@ -125,7 +121,7 @@ public:
|
||||
bool validate(Json::Value* invalid) const;
|
||||
/** A simple way to update a specific setting.
|
||||
*/
|
||||
Value& operator[](JSONCPP_STRING key);
|
||||
Value& operator[](std::string key);
|
||||
|
||||
/** Called by ctor, but you can use this to reset settings_.
|
||||
* \pre 'settings' != NULL (but Json::null is fine)
|
||||
@@ -142,7 +138,7 @@ class JSON_API Writer {
|
||||
public:
|
||||
virtual ~Writer();
|
||||
|
||||
virtual JSONCPP_STRING write(const Value& root) = 0;
|
||||
virtual std::string write(const Value& root) = 0;
|
||||
};
|
||||
|
||||
/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
|
||||
@@ -158,29 +154,18 @@ class JSON_API FastWriter : public Writer {
|
||||
|
||||
public:
|
||||
FastWriter();
|
||||
~FastWriter() JSONCPP_OVERRIDE {}
|
||||
virtual ~FastWriter() {}
|
||||
|
||||
void enableYAMLCompatibility();
|
||||
|
||||
/** \brief Drop the "null" string from the writer's output for nullValues.
|
||||
* Strictly speaking, this is not valid JSON. But when the output is being
|
||||
* fed to a browser's Javascript, it makes for smaller output and the
|
||||
* browser can handle the output just fine.
|
||||
*/
|
||||
void dropNullPlaceholders();
|
||||
|
||||
void omitEndingLineFeed();
|
||||
|
||||
public: // overridden from Writer
|
||||
JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
|
||||
virtual std::string write(const Value& root);
|
||||
|
||||
private:
|
||||
void writeValue(const Value& value);
|
||||
|
||||
JSONCPP_STRING document_;
|
||||
std::string document_;
|
||||
bool yamlCompatiblityEnabled_;
|
||||
bool dropNullPlaceholders_;
|
||||
bool omitEndingLineFeed_;
|
||||
};
|
||||
|
||||
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
||||
@@ -210,36 +195,36 @@ private:
|
||||
class JSON_API StyledWriter : public Writer {
|
||||
public:
|
||||
StyledWriter();
|
||||
~StyledWriter() JSONCPP_OVERRIDE {}
|
||||
virtual ~StyledWriter() {}
|
||||
|
||||
public: // overridden from Writer
|
||||
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
||||
* \param root Value to serialize.
|
||||
* \return String containing the JSON document that represents the root value.
|
||||
*/
|
||||
JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
|
||||
virtual std::string write(const Value& root);
|
||||
|
||||
private:
|
||||
void writeValue(const Value& value);
|
||||
void writeArrayValue(const Value& value);
|
||||
bool isMultineArray(const Value& value);
|
||||
void pushValue(const JSONCPP_STRING& value);
|
||||
void pushValue(const std::string& value);
|
||||
void writeIndent();
|
||||
void writeWithIndent(const JSONCPP_STRING& value);
|
||||
void writeWithIndent(const std::string& value);
|
||||
void indent();
|
||||
void unindent();
|
||||
void writeCommentBeforeValue(const Value& root);
|
||||
void writeCommentAfterValueOnSameLine(const Value& root);
|
||||
bool hasCommentForValue(const Value& value);
|
||||
static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
|
||||
static std::string normalizeEOL(const std::string& text);
|
||||
|
||||
typedef std::vector<JSONCPP_STRING> ChildValues;
|
||||
typedef std::vector<std::string> ChildValues;
|
||||
|
||||
ChildValues childValues_;
|
||||
JSONCPP_STRING document_;
|
||||
JSONCPP_STRING indentString_;
|
||||
unsigned int rightMargin_;
|
||||
unsigned int indentSize_;
|
||||
std::string document_;
|
||||
std::string indentString_;
|
||||
int rightMargin_;
|
||||
int indentSize_;
|
||||
bool addChildValues_;
|
||||
};
|
||||
|
||||
@@ -271,7 +256,7 @@ private:
|
||||
*/
|
||||
class JSON_API StyledStreamWriter {
|
||||
public:
|
||||
StyledStreamWriter(JSONCPP_STRING indentation = "\t");
|
||||
StyledStreamWriter(std::string indentation = "\t");
|
||||
~StyledStreamWriter() {}
|
||||
|
||||
public:
|
||||
@@ -281,46 +266,46 @@ public:
|
||||
* \note There is no point in deriving from Writer, since write() should not
|
||||
* return a value.
|
||||
*/
|
||||
void write(JSONCPP_OSTREAM& out, const Value& root);
|
||||
void write(std::ostream& out, const Value& root);
|
||||
|
||||
private:
|
||||
void writeValue(const Value& value);
|
||||
void writeArrayValue(const Value& value);
|
||||
bool isMultineArray(const Value& value);
|
||||
void pushValue(const JSONCPP_STRING& value);
|
||||
void pushValue(const std::string& value);
|
||||
void writeIndent();
|
||||
void writeWithIndent(const JSONCPP_STRING& value);
|
||||
void writeWithIndent(const std::string& value);
|
||||
void indent();
|
||||
void unindent();
|
||||
void writeCommentBeforeValue(const Value& root);
|
||||
void writeCommentAfterValueOnSameLine(const Value& root);
|
||||
bool hasCommentForValue(const Value& value);
|
||||
static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
|
||||
static std::string normalizeEOL(const std::string& text);
|
||||
|
||||
typedef std::vector<JSONCPP_STRING> ChildValues;
|
||||
typedef std::vector<std::string> ChildValues;
|
||||
|
||||
ChildValues childValues_;
|
||||
JSONCPP_OSTREAM* document_;
|
||||
JSONCPP_STRING indentString_;
|
||||
unsigned int rightMargin_;
|
||||
JSONCPP_STRING indentation_;
|
||||
std::ostream* document_;
|
||||
std::string indentString_;
|
||||
int rightMargin_;
|
||||
std::string indentation_;
|
||||
bool addChildValues_ : 1;
|
||||
bool indented_ : 1;
|
||||
};
|
||||
|
||||
#if defined(JSON_HAS_INT64)
|
||||
JSONCPP_STRING JSON_API valueToString(Int value);
|
||||
JSONCPP_STRING JSON_API valueToString(UInt value);
|
||||
std::string JSON_API valueToString(Int value);
|
||||
std::string JSON_API valueToString(UInt value);
|
||||
#endif // if defined(JSON_HAS_INT64)
|
||||
JSONCPP_STRING JSON_API valueToString(LargestInt value);
|
||||
JSONCPP_STRING JSON_API valueToString(LargestUInt value);
|
||||
JSONCPP_STRING JSON_API valueToString(double value);
|
||||
JSONCPP_STRING JSON_API valueToString(bool value);
|
||||
JSONCPP_STRING JSON_API valueToQuotedString(const char* value);
|
||||
std::string JSON_API valueToString(LargestInt value);
|
||||
std::string JSON_API valueToString(LargestUInt value);
|
||||
std::string JSON_API valueToString(double value);
|
||||
std::string JSON_API valueToString(bool value);
|
||||
std::string JSON_API valueToQuotedString(const char* value);
|
||||
|
||||
/// \brief Output using the StyledStreamWriter.
|
||||
/// \see Json::operator>>()
|
||||
JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
|
||||
JSON_API std::ostream& operator<<(std::ostream&, const Value& root);
|
||||
|
||||
} // namespace Json
|
||||
|
||||
|
@@ -1,46 +1,46 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_json", "lib_json.vcproj", "{B84F7231-16CE-41D8-8C08-7B523FF4225B}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsontest", "jsontest.vcproj", "{25AF2DD2-D396-4668-B188-488C33B8E620}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B} = {B84F7231-16CE-41D8-8C08-7B523FF4225B}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_lib_json", "test_lib_json.vcproj", "{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B} = {B84F7231-16CE-41D8-8C08-7B523FF4225B}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
dummy = dummy
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.Debug.ActiveCfg = Debug|Win32
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.Debug.Build.0 = Debug|Win32
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.dummy.ActiveCfg = dummy|Win32
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.dummy.Build.0 = dummy|Win32
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.Release.ActiveCfg = Release|Win32
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.Release.Build.0 = Release|Win32
|
||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.Debug.ActiveCfg = Debug|Win32
|
||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.Debug.Build.0 = Debug|Win32
|
||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.dummy.ActiveCfg = Debug|Win32
|
||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.dummy.Build.0 = Debug|Win32
|
||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.Release.ActiveCfg = Release|Win32
|
||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.Release.Build.0 = Release|Win32
|
||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Debug.ActiveCfg = Debug|Win32
|
||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Debug.Build.0 = Debug|Win32
|
||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.dummy.ActiveCfg = Debug|Win32
|
||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.dummy.Build.0 = Debug|Win32
|
||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release.ActiveCfg = Release|Win32
|
||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_json", "lib_json.vcproj", "{B84F7231-16CE-41D8-8C08-7B523FF4225B}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsontest", "jsontest.vcproj", "{25AF2DD2-D396-4668-B188-488C33B8E620}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B} = {B84F7231-16CE-41D8-8C08-7B523FF4225B}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_lib_json", "test_lib_json.vcproj", "{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B} = {B84F7231-16CE-41D8-8C08-7B523FF4225B}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
dummy = dummy
|
||||
Release = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.Debug.ActiveCfg = Debug|Win32
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.Debug.Build.0 = Debug|Win32
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.dummy.ActiveCfg = dummy|Win32
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.dummy.Build.0 = dummy|Win32
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.Release.ActiveCfg = Release|Win32
|
||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.Release.Build.0 = Release|Win32
|
||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.Debug.ActiveCfg = Debug|Win32
|
||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.Debug.Build.0 = Debug|Win32
|
||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.dummy.ActiveCfg = Debug|Win32
|
||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.dummy.Build.0 = Debug|Win32
|
||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.Release.ActiveCfg = Release|Win32
|
||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.Release.Build.0 = Release|Win32
|
||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Debug.ActiveCfg = Debug|Win32
|
||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Debug.Build.0 = Debug|Win32
|
||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.dummy.ActiveCfg = Debug|Win32
|
||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.dummy.Build.0 = Debug|Win32
|
||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release.ActiveCfg = Release|Win32
|
||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@@ -1,119 +1,119 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="jsontest"
|
||||
ProjectGUID="{25AF2DD2-D396-4668-B188-488C33B8E620}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../build/vs71/debug/jsontest"
|
||||
IntermediateDirectory="../../build/vs71/debug/jsontest"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/jsontest.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/jsontest.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../build/vs71/release/jsontest"
|
||||
IntermediateDirectory="../../build/vs71/release/jsontest"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/jsontest.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="..\..\src\jsontestrunner\main.cpp">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="jsontest"
|
||||
ProjectGUID="{25AF2DD2-D396-4668-B188-488C33B8E620}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../build/vs71/debug/jsontest"
|
||||
IntermediateDirectory="../../build/vs71/debug/jsontest"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/jsontest.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/jsontest.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../build/vs71/release/jsontest"
|
||||
IntermediateDirectory="../../build/vs71/release/jsontest"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/jsontest.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="..\..\src\jsontestrunner\main.cpp">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
|
@@ -1,205 +1,205 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="lib_json"
|
||||
ProjectGUID="{B84F7231-16CE-41D8-8C08-7B523FF4225B}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../build/vs71/debug/lib_json"
|
||||
IntermediateDirectory="../../build/vs71/debug/lib_json"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
StringPooling="TRUE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
RuntimeTypeInfo="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/json_vc71_libmtd.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../build/vs71/release/lib_json"
|
||||
IntermediateDirectory="../../build/vs71/release/lib_json"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
GlobalOptimizations="TRUE"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
RuntimeTypeInfo="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
AssemblerOutput="4"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/json_vc71_libmt.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="dummy|Win32"
|
||||
OutputDirectory="$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
GlobalOptimizations="TRUE"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
RuntimeTypeInfo="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
AssemblerOutput="4"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="..\..\include\json\autolink.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\config.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\features.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\forwards.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\json.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\lib_json\json_reader.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\lib_json\json_value.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\lib_json\json_valueiterator.inl">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\lib_json\json_writer.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\reader.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\value.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\writer.h">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="lib_json"
|
||||
ProjectGUID="{B84F7231-16CE-41D8-8C08-7B523FF4225B}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../build/vs71/debug/lib_json"
|
||||
IntermediateDirectory="../../build/vs71/debug/lib_json"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
StringPooling="TRUE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
RuntimeTypeInfo="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/json_vc71_libmtd.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../build/vs71/release/lib_json"
|
||||
IntermediateDirectory="../../build/vs71/release/lib_json"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
GlobalOptimizations="TRUE"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
RuntimeTypeInfo="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
AssemblerOutput="4"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/json_vc71_libmt.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="dummy|Win32"
|
||||
OutputDirectory="$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="TRUE">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
GlobalOptimizations="TRUE"
|
||||
EnableIntrinsicFunctions="TRUE"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
DisableLanguageExtensions="TRUE"
|
||||
ForceConformanceInForLoopScope="FALSE"
|
||||
RuntimeTypeInfo="TRUE"
|
||||
UsePrecompiledHeader="0"
|
||||
AssemblerOutput="4"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="..\..\include\json\autolink.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\config.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\features.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\forwards.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\json.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\lib_json\json_reader.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\lib_json\json_value.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\lib_json\json_valueiterator.inl">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\lib_json\json_writer.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\reader.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\value.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\json\writer.h">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
|
@@ -1,130 +1,130 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="test_lib_json"
|
||||
ProjectGUID="{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}"
|
||||
RootNamespace="test_lib_json"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../build/vs71/debug/test_lib_json"
|
||||
IntermediateDirectory="../../build/vs71/debug/test_lib_json"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/test_lib_json.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/test_lib_json.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Running all unit tests"
|
||||
CommandLine="$(TargetPath)"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../build/vs71/release/test_lib_json"
|
||||
IntermediateDirectory="../../build/vs71/release/test_lib_json"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/test_lib_json.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Running all unit tests"
|
||||
CommandLine="$(TargetPath)"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="..\..\src\test_lib_json\jsontest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\test_lib_json\jsontest.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\test_lib_json\main.cpp">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="test_lib_json"
|
||||
ProjectGUID="{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}"
|
||||
RootNamespace="test_lib_json"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../build/vs71/debug/test_lib_json"
|
||||
IntermediateDirectory="../../build/vs71/debug/test_lib_json"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/test_lib_json.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/test_lib_json.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Running all unit tests"
|
||||
CommandLine="$(TargetPath)"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../build/vs71/release/test_lib_json"
|
||||
IntermediateDirectory="../../build/vs71/release/test_lib_json"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/test_lib_json.exe"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
Description="Running all unit tests"
|
||||
CommandLine="$(TargetPath)"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="..\..\src\test_lib_json\jsontest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\test_lib_json\jsontest.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\test_lib_json\main.cpp">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
|
@@ -1,8 +1,3 @@
|
||||
# Copyright 2010 Baptiste Lepilleur
|
||||
# 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
|
||||
|
||||
"""Tag the sandbox for release, make source and doc tarballs.
|
||||
|
||||
Requires Python 2.6
|
||||
@@ -19,7 +14,6 @@ python makerelease.py 0.5.0 0.6.0-dev
|
||||
Note: This was for Subversion. Now that we are in GitHub, we do not
|
||||
need to build versioned tarballs anymore, so makerelease.py is defunct.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
import os.path
|
||||
import subprocess
|
||||
|
@@ -1,8 +1,3 @@
|
||||
# Copyright 2009 Baptiste Lepilleur
|
||||
# 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
|
||||
|
||||
import fnmatch
|
||||
import os
|
||||
|
||||
|
@@ -1,8 +1,3 @@
|
||||
# Copyright 2007 Baptiste Lepilleur
|
||||
# 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
|
||||
|
||||
import os
|
||||
import os.path
|
||||
from fnmatch import fnmatch
|
||||
|
@@ -1,8 +1,3 @@
|
||||
# Copyright 2010 Baptiste Lepilleur
|
||||
# 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
|
||||
|
||||
import re
|
||||
from SCons.Script import * # the usual scons stuff you get in a SConscript
|
||||
import collections
|
||||
|
@@ -1,8 +1,3 @@
|
||||
# Copyright 2007 Baptiste Lepilleur
|
||||
# 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
|
||||
|
||||
"""tarball
|
||||
|
||||
Tool-specific initialization for tarball.
|
||||
|
@@ -2,4 +2,4 @@ ADD_SUBDIRECTORY(lib_json)
|
||||
IF(JSONCPP_WITH_TESTS)
|
||||
ADD_SUBDIRECTORY(jsontestrunner)
|
||||
ADD_SUBDIRECTORY(test_lib_json)
|
||||
ENDIF()
|
||||
ENDIF(JSONCPP_WITH_TESTS)
|
||||
|
@@ -1,15 +1,18 @@
|
||||
FIND_PACKAGE(PythonInterp 2.6)
|
||||
|
||||
IF(JSONCPP_LIB_BUILD_SHARED)
|
||||
ADD_DEFINITIONS( -DJSON_DLL )
|
||||
ENDIF(JSONCPP_LIB_BUILD_SHARED)
|
||||
|
||||
ADD_EXECUTABLE(jsontestrunner_exe
|
||||
main.cpp
|
||||
)
|
||||
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
ADD_DEFINITIONS( -DJSON_DLL )
|
||||
IF(JSONCPP_LIB_BUILD_SHARED)
|
||||
TARGET_LINK_LIBRARIES(jsontestrunner_exe jsoncpp_lib)
|
||||
ELSE(BUILD_SHARED_LIBS)
|
||||
ELSE(JSONCPP_LIB_BUILD_SHARED)
|
||||
TARGET_LINK_LIBRARIES(jsontestrunner_exe jsoncpp_lib_static)
|
||||
ENDIF()
|
||||
ENDIF(JSONCPP_LIB_BUILD_SHARED)
|
||||
|
||||
SET_TARGET_PROPERTIES(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe)
|
||||
|
||||
@@ -22,4 +25,4 @@ IF(PYTHONINTERP_FOUND)
|
||||
DEPENDS jsontestrunner_exe jsoncpp_test
|
||||
)
|
||||
ADD_CUSTOM_TARGET(jsoncpp_check DEPENDS jsoncpp_readerwriter_tests)
|
||||
ENDIF()
|
||||
ENDIF(PYTHONINTERP_FOUND)
|
||||
|
@@ -17,14 +17,14 @@
|
||||
|
||||
struct Options
|
||||
{
|
||||
JSONCPP_STRING path;
|
||||
std::string path;
|
||||
Json::Features features;
|
||||
bool parseOnly;
|
||||
typedef JSONCPP_STRING (*writeFuncType)(Json::Value const&);
|
||||
typedef std::string (*writeFuncType)(Json::Value const&);
|
||||
writeFuncType write;
|
||||
};
|
||||
|
||||
static JSONCPP_STRING normalizeFloatingPointStr(double value) {
|
||||
static std::string normalizeFloatingPointStr(double value) {
|
||||
char buffer[32];
|
||||
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
|
||||
sprintf_s(buffer, sizeof(buffer), "%.16g", value);
|
||||
@@ -32,18 +32,18 @@ static JSONCPP_STRING normalizeFloatingPointStr(double value) {
|
||||
snprintf(buffer, sizeof(buffer), "%.16g", value);
|
||||
#endif
|
||||
buffer[sizeof(buffer) - 1] = 0;
|
||||
JSONCPP_STRING s(buffer);
|
||||
JSONCPP_STRING::size_type index = s.find_last_of("eE");
|
||||
if (index != JSONCPP_STRING::npos) {
|
||||
JSONCPP_STRING::size_type hasSign =
|
||||
std::string s(buffer);
|
||||
std::string::size_type index = s.find_last_of("eE");
|
||||
if (index != std::string::npos) {
|
||||
std::string::size_type hasSign =
|
||||
(s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0;
|
||||
JSONCPP_STRING::size_type exponentStartIndex = index + 1 + hasSign;
|
||||
JSONCPP_STRING normalized = s.substr(0, exponentStartIndex);
|
||||
JSONCPP_STRING::size_type indexDigit =
|
||||
std::string::size_type exponentStartIndex = index + 1 + hasSign;
|
||||
std::string normalized = s.substr(0, exponentStartIndex);
|
||||
std::string::size_type indexDigit =
|
||||
s.find_first_not_of('0', exponentStartIndex);
|
||||
JSONCPP_STRING exponent = "0";
|
||||
std::string exponent = "0";
|
||||
if (indexDigit !=
|
||||
JSONCPP_STRING::npos) // There is an exponent different from 0
|
||||
std::string::npos) // There is an exponent different from 0
|
||||
{
|
||||
exponent = s.substr(indexDigit);
|
||||
}
|
||||
@@ -52,18 +52,17 @@ static JSONCPP_STRING normalizeFloatingPointStr(double value) {
|
||||
return s;
|
||||
}
|
||||
|
||||
static JSONCPP_STRING readInputTestFile(const char* path) {
|
||||
static std::string readInputTestFile(const char* path) {
|
||||
FILE* file = fopen(path, "rb");
|
||||
if (!file)
|
||||
return JSONCPP_STRING("");
|
||||
return std::string("");
|
||||
fseek(file, 0, SEEK_END);
|
||||
long const size = ftell(file);
|
||||
unsigned long const usize = static_cast<unsigned long>(size);
|
||||
long size = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
JSONCPP_STRING text;
|
||||
std::string text;
|
||||
char* buffer = new char[size + 1];
|
||||
buffer[size] = 0;
|
||||
if (fread(buffer, 1, usize, file) == usize)
|
||||
if (fread(buffer, 1, size, file) == (unsigned long)size)
|
||||
text = buffer;
|
||||
fclose(file);
|
||||
delete[] buffer;
|
||||
@@ -71,7 +70,7 @@ static JSONCPP_STRING readInputTestFile(const char* path) {
|
||||
}
|
||||
|
||||
static void
|
||||
printValueTree(FILE* fout, Json::Value& value, const JSONCPP_STRING& path = ".") {
|
||||
printValueTree(FILE* fout, Json::Value& value, const std::string& path = ".") {
|
||||
if (value.hasComment(Json::commentBefore)) {
|
||||
fprintf(fout, "%s\n", value.getComment(Json::commentBefore).c_str());
|
||||
}
|
||||
@@ -105,8 +104,8 @@ printValueTree(FILE* fout, Json::Value& value, const JSONCPP_STRING& path = ".")
|
||||
break;
|
||||
case Json::arrayValue: {
|
||||
fprintf(fout, "%s=[]\n", path.c_str());
|
||||
Json::ArrayIndex size = value.size();
|
||||
for (Json::ArrayIndex index = 0; index < size; ++index) {
|
||||
int size = value.size();
|
||||
for (int index = 0; index < size; ++index) {
|
||||
static char buffer[16];
|
||||
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
|
||||
sprintf_s(buffer, sizeof(buffer), "[%d]", index);
|
||||
@@ -120,11 +119,11 @@ printValueTree(FILE* fout, Json::Value& value, const JSONCPP_STRING& path = ".")
|
||||
fprintf(fout, "%s={}\n", path.c_str());
|
||||
Json::Value::Members members(value.getMemberNames());
|
||||
std::sort(members.begin(), members.end());
|
||||
JSONCPP_STRING suffix = *(path.end() - 1) == '.' ? "" : ".";
|
||||
std::string suffix = *(path.end() - 1) == '.' ? "" : ".";
|
||||
for (Json::Value::Members::iterator it = members.begin();
|
||||
it != members.end();
|
||||
++it) {
|
||||
const JSONCPP_STRING name = *it;
|
||||
const std::string& name = *it;
|
||||
printValueTree(fout, value[name], path + suffix + name);
|
||||
}
|
||||
} break;
|
||||
@@ -137,15 +136,15 @@ printValueTree(FILE* fout, Json::Value& value, const JSONCPP_STRING& path = ".")
|
||||
}
|
||||
}
|
||||
|
||||
static int parseAndSaveValueTree(const JSONCPP_STRING& input,
|
||||
const JSONCPP_STRING& actual,
|
||||
const JSONCPP_STRING& kind,
|
||||
static int parseAndSaveValueTree(const std::string& input,
|
||||
const std::string& actual,
|
||||
const std::string& kind,
|
||||
const Json::Features& features,
|
||||
bool parseOnly,
|
||||
Json::Value* root)
|
||||
{
|
||||
Json::Reader reader(features);
|
||||
bool parsingSuccessful = reader.parse(input.data(), input.data() + input.size(), *root);
|
||||
bool parsingSuccessful = reader.parse(input, *root);
|
||||
if (!parsingSuccessful) {
|
||||
printf("Failed to parse %s file: \n%s\n",
|
||||
kind.c_str(),
|
||||
@@ -163,36 +162,36 @@ static int parseAndSaveValueTree(const JSONCPP_STRING& input,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// static JSONCPP_STRING useFastWriter(Json::Value const& root) {
|
||||
// static std::string useFastWriter(Json::Value const& root) {
|
||||
// Json::FastWriter writer;
|
||||
// writer.enableYAMLCompatibility();
|
||||
// return writer.write(root);
|
||||
// }
|
||||
static JSONCPP_STRING useStyledWriter(
|
||||
static std::string useStyledWriter(
|
||||
Json::Value const& root)
|
||||
{
|
||||
Json::StyledWriter writer;
|
||||
return writer.write(root);
|
||||
}
|
||||
static JSONCPP_STRING useStyledStreamWriter(
|
||||
static std::string useStyledStreamWriter(
|
||||
Json::Value const& root)
|
||||
{
|
||||
Json::StyledStreamWriter writer;
|
||||
JSONCPP_OSTRINGSTREAM sout;
|
||||
std::ostringstream sout;
|
||||
writer.write(sout, root);
|
||||
return sout.str();
|
||||
}
|
||||
static JSONCPP_STRING useBuiltStyledStreamWriter(
|
||||
static std::string useBuiltStyledStreamWriter(
|
||||
Json::Value const& root)
|
||||
{
|
||||
Json::StreamWriterBuilder builder;
|
||||
return Json::writeString(builder, root);
|
||||
}
|
||||
static int rewriteValueTree(
|
||||
const JSONCPP_STRING& rewritePath,
|
||||
const std::string& rewritePath,
|
||||
const Json::Value& root,
|
||||
Options::writeFuncType write,
|
||||
JSONCPP_STRING* rewrite)
|
||||
std::string* rewrite)
|
||||
{
|
||||
*rewrite = write(root);
|
||||
FILE* fout = fopen(rewritePath.c_str(), "wt");
|
||||
@@ -205,13 +204,13 @@ static int rewriteValueTree(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static JSONCPP_STRING removeSuffix(const JSONCPP_STRING& path,
|
||||
const JSONCPP_STRING& extension) {
|
||||
static std::string removeSuffix(const std::string& path,
|
||||
const std::string& extension) {
|
||||
if (extension.length() >= path.length())
|
||||
return JSONCPP_STRING("");
|
||||
JSONCPP_STRING suffix = path.substr(path.length() - extension.length());
|
||||
return std::string("");
|
||||
std::string suffix = path.substr(path.length() - extension.length());
|
||||
if (suffix != extension)
|
||||
return JSONCPP_STRING("");
|
||||
return std::string("");
|
||||
return path.substr(0, path.length() - extension.length());
|
||||
}
|
||||
|
||||
@@ -238,18 +237,18 @@ static int parseCommandLine(
|
||||
return printUsage(argv);
|
||||
}
|
||||
int index = 1;
|
||||
if (JSONCPP_STRING(argv[index]) == "--json-checker") {
|
||||
if (std::string(argv[index]) == "--json-checker") {
|
||||
opts->features = Json::Features::strictMode();
|
||||
opts->parseOnly = true;
|
||||
++index;
|
||||
}
|
||||
if (JSONCPP_STRING(argv[index]) == "--json-config") {
|
||||
if (std::string(argv[index]) == "--json-config") {
|
||||
printConfig();
|
||||
return 3;
|
||||
}
|
||||
if (JSONCPP_STRING(argv[index]) == "--json-writer") {
|
||||
if (std::string(argv[index]) == "--json-writer") {
|
||||
++index;
|
||||
JSONCPP_STRING const writerName(argv[index++]);
|
||||
std::string const writerName(argv[index++]);
|
||||
if (writerName == "StyledWriter") {
|
||||
opts->write = &useStyledWriter;
|
||||
} else if (writerName == "StyledStreamWriter") {
|
||||
@@ -271,22 +270,22 @@ static int runTest(Options const& opts)
|
||||
{
|
||||
int exitCode = 0;
|
||||
|
||||
JSONCPP_STRING input = readInputTestFile(opts.path.c_str());
|
||||
std::string input = readInputTestFile(opts.path.c_str());
|
||||
if (input.empty()) {
|
||||
printf("Failed to read input or empty input: %s\n", opts.path.c_str());
|
||||
return 3;
|
||||
}
|
||||
|
||||
JSONCPP_STRING basePath = removeSuffix(opts.path, ".json");
|
||||
std::string basePath = removeSuffix(opts.path, ".json");
|
||||
if (!opts.parseOnly && basePath.empty()) {
|
||||
printf("Bad input path. Path does not end with '.expected':\n%s\n",
|
||||
opts.path.c_str());
|
||||
return 3;
|
||||
}
|
||||
|
||||
JSONCPP_STRING const actualPath = basePath + ".actual";
|
||||
JSONCPP_STRING const rewritePath = basePath + ".rewrite";
|
||||
JSONCPP_STRING const rewriteActualPath = basePath + ".actual-rewrite";
|
||||
std::string const actualPath = basePath + ".actual";
|
||||
std::string const rewritePath = basePath + ".rewrite";
|
||||
std::string const rewriteActualPath = basePath + ".actual-rewrite";
|
||||
|
||||
Json::Value root;
|
||||
exitCode = parseAndSaveValueTree(
|
||||
@@ -295,7 +294,7 @@ static int runTest(Options const& opts)
|
||||
if (exitCode || opts.parseOnly) {
|
||||
return exitCode;
|
||||
}
|
||||
JSONCPP_STRING rewrite;
|
||||
std::string rewrite;
|
||||
exitCode = rewriteValueTree(rewritePath, root, opts.write, &rewrite);
|
||||
if (exitCode) {
|
||||
return exitCode;
|
||||
@@ -311,12 +310,12 @@ static int runTest(Options const& opts)
|
||||
}
|
||||
int main(int argc, const char* argv[]) {
|
||||
Options opts;
|
||||
try {
|
||||
int exitCode = parseCommandLine(argc, argv, &opts);
|
||||
if (exitCode != 0) {
|
||||
printf("Failed to parse command-line.");
|
||||
return exitCode;
|
||||
}
|
||||
try {
|
||||
return runTest(opts);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
|
@@ -1,8 +1,15 @@
|
||||
OPTION(JSONCPP_LIB_BUILD_SHARED "Build jsoncpp_lib as a shared library." OFF)
|
||||
OPTION(JSONCPP_LIB_BUILD_STATIC "Build jsoncpp_lib static library." ON)
|
||||
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
SET(JSONCPP_LIB_BUILD_SHARED ON)
|
||||
ENDIF(BUILD_SHARED_LIBS)
|
||||
|
||||
if( CMAKE_COMPILER_IS_GNUCXX )
|
||||
#Get compiler version.
|
||||
execute_process( COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
|
||||
OUTPUT_VARIABLE GNUCXX_VERSION )
|
||||
|
||||
|
||||
#-Werror=* was introduced -after- GCC 4.1.2
|
||||
if( GNUCXX_VERSION VERSION_GREATER 4.1.2 )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=strict-aliasing")
|
||||
@@ -37,14 +44,13 @@ IF(JSONCPP_WITH_CMAKE_PACKAGE)
|
||||
SET(INSTALL_EXPORT EXPORT jsoncpp)
|
||||
ELSE(JSONCPP_WITH_CMAKE_PACKAGE)
|
||||
SET(INSTALL_EXPORT)
|
||||
ENDIF()
|
||||
ENDIF(JSONCPP_WITH_CMAKE_PACKAGE)
|
||||
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
IF(JSONCPP_LIB_BUILD_SHARED)
|
||||
ADD_DEFINITIONS( -DJSON_DLL_BUILD )
|
||||
ADD_LIBRARY(jsoncpp_lib SHARED ${PUBLIC_HEADERS} ${jsoncpp_sources})
|
||||
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_VERSION_MAJOR})
|
||||
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES OUTPUT_NAME jsoncpp
|
||||
DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )
|
||||
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES OUTPUT_NAME jsoncpp )
|
||||
|
||||
INSTALL( TARGETS jsoncpp_lib ${INSTALL_EXPORT}
|
||||
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
|
||||
@@ -55,15 +61,14 @@ IF(BUILD_SHARED_LIBS)
|
||||
TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib PUBLIC
|
||||
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>)
|
||||
ENDIF()
|
||||
ENDIF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_STATIC_LIBS)
|
||||
IF(JSONCPP_LIB_BUILD_STATIC)
|
||||
ADD_LIBRARY(jsoncpp_lib_static STATIC ${PUBLIC_HEADERS} ${jsoncpp_sources})
|
||||
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_VERSION_MAJOR})
|
||||
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES OUTPUT_NAME jsoncpp
|
||||
DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )
|
||||
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES OUTPUT_NAME jsoncpp )
|
||||
|
||||
INSTALL( TARGETS jsoncpp_lib_static ${INSTALL_EXPORT}
|
||||
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
|
||||
@@ -75,6 +80,6 @@ IF(BUILD_STATIC_LIBS)
|
||||
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
|
||||
)
|
||||
ENDIF()
|
||||
ENDIF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
|
||||
ENDIF()
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -15,8 +15,8 @@
|
||||
namespace Json {
|
||||
|
||||
/// Converts a unicode code-point to UTF-8.
|
||||
static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
||||
JSONCPP_STRING result;
|
||||
static inline std::string codePointToUTF8(unsigned int cp) {
|
||||
std::string result;
|
||||
|
||||
// based on description from http://en.wikipedia.org/wiki/UTF-8
|
||||
|
||||
@@ -30,8 +30,8 @@ static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
||||
} else if (cp <= 0xFFFF) {
|
||||
result.resize(3);
|
||||
result[2] = static_cast<char>(0x80 | (0x3f & cp));
|
||||
result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
|
||||
result[0] = static_cast<char>(0xE0 | (0xf & (cp >> 12)));
|
||||
result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));
|
||||
result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));
|
||||
} else if (cp <= 0x10FFFF) {
|
||||
result.resize(4);
|
||||
result[3] = static_cast<char>(0x80 | (0x3f & cp));
|
||||
@@ -43,7 +43,7 @@ static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Returns true if ch is a control character (in range [1,31]).
|
||||
/// Returns true if ch is a control character (in range [0,32[).
|
||||
static inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }
|
||||
|
||||
enum {
|
||||
@@ -63,7 +63,7 @@ typedef char UIntToStringBuffer[uintToStringBufferSize];
|
||||
static inline void uintToString(LargestUInt value, char*& current) {
|
||||
*--current = 0;
|
||||
do {
|
||||
*--current = static_cast<char>(value % 10U + static_cast<unsigned>('0'));
|
||||
*--current = char(value % 10) + '0';
|
||||
value /= 10;
|
||||
} while (value != 0);
|
||||
}
|
||||
|
@@ -29,24 +29,13 @@ namespace Json {
|
||||
#if defined(__ARMEL__)
|
||||
#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
|
||||
#else
|
||||
// This exists for binary compatibility only. Use nullRef.
|
||||
const Value Value::null;
|
||||
#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
|
||||
Value const& Value::nullSingleton()
|
||||
{
|
||||
static Value const* nullStatic = new Value;
|
||||
return *nullStatic;
|
||||
}
|
||||
|
||||
// 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();
|
||||
static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
|
||||
const unsigned char& kNullRef = kNull[0];
|
||||
const Value& Value::nullRef = reinterpret_cast<const Value&>(kNullRef);
|
||||
|
||||
const Int Value::minInt = Int(~(UInt(-1) / 2));
|
||||
const Int Value::maxInt = Int(UInt(-1) / 2);
|
||||
@@ -67,14 +56,11 @@ 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) {
|
||||
// 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 >= 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));
|
||||
return static_cast<double>(Int64(value / 2)) * 2.0 + Int64(value & 1);
|
||||
}
|
||||
|
||||
template <typename T> static inline double integerToDouble(T value) {
|
||||
@@ -95,11 +81,10 @@ static inline bool InRange(double d, T min, U max) {
|
||||
* @return Pointer on the duplicate instance of string.
|
||||
*/
|
||||
static inline char* duplicateStringValue(const char* value,
|
||||
size_t length)
|
||||
{
|
||||
size_t length) {
|
||||
// Avoid an integer overflow in the call to malloc below by limiting length
|
||||
// to a sane value.
|
||||
if (length >= static_cast<size_t>(Value::maxInt))
|
||||
if (length >= (size_t)Value::maxInt)
|
||||
length = Value::maxInt - 1;
|
||||
|
||||
char* newString = static_cast<char*>(malloc(length + 1));
|
||||
@@ -121,10 +106,10 @@ static inline char* duplicateAndPrefixStringValue(
|
||||
{
|
||||
// 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 <= (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 + sizeof(unsigned) + 1U;
|
||||
char* newString = static_cast<char*>(malloc(actualLength));
|
||||
if (newString == 0) {
|
||||
throwRuntimeError(
|
||||
@@ -141,7 +126,7 @@ inline static void decodePrefixedString(
|
||||
unsigned* length, char const** value)
|
||||
{
|
||||
if (!isPrefixed) {
|
||||
*length = static_cast<unsigned>(strlen(prefixed));
|
||||
*length = strlen(prefixed);
|
||||
*value = prefixed;
|
||||
} else {
|
||||
*length = *reinterpret_cast<unsigned const*>(prefixed);
|
||||
@@ -150,29 +135,7 @@ inline static void decodePrefixedString(
|
||||
}
|
||||
/** Free the string duplicated by duplicateStringValue()/duplicateAndPrefixStringValue().
|
||||
*/
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
static inline void releasePrefixedStringValue(char* value) {
|
||||
unsigned length = 0;
|
||||
char const* valueDecoded;
|
||||
decodePrefixedString(true, value, &length, &valueDecoded);
|
||||
size_t const size = sizeof(unsigned) + length + 1U;
|
||||
memset(value, 0, size);
|
||||
free(value);
|
||||
}
|
||||
static inline void releaseStringValue(char* value, unsigned length) {
|
||||
// length==0 => we allocated the strings memory
|
||||
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) {
|
||||
free(value);
|
||||
}
|
||||
static inline void releaseStringValue(char* value, unsigned) {
|
||||
free(value);
|
||||
}
|
||||
#endif // JSONCPP_USING_SECURE_MEMORY
|
||||
static inline void releaseStringValue(char* value) { free(value); }
|
||||
|
||||
} // namespace Json
|
||||
|
||||
@@ -190,7 +153,24 @@ static inline void releaseStringValue(char* value, unsigned) {
|
||||
|
||||
namespace Json {
|
||||
|
||||
Exception::Exception(JSONCPP_STRING const& msg)
|
||||
class JSON_API Exception : public std::exception {
|
||||
public:
|
||||
Exception(std::string const& msg);
|
||||
virtual ~Exception() throw();
|
||||
virtual char const* what() const throw();
|
||||
protected:
|
||||
std::string const msg_;
|
||||
};
|
||||
class JSON_API RuntimeError : public Exception {
|
||||
public:
|
||||
RuntimeError(std::string const& msg);
|
||||
};
|
||||
class JSON_API LogicError : public Exception {
|
||||
public:
|
||||
LogicError(std::string const& msg);
|
||||
};
|
||||
|
||||
Exception::Exception(std::string const& msg)
|
||||
: msg_(msg)
|
||||
{}
|
||||
Exception::~Exception() throw()
|
||||
@@ -199,17 +179,17 @@ char const* Exception::what() const throw()
|
||||
{
|
||||
return msg_.c_str();
|
||||
}
|
||||
RuntimeError::RuntimeError(JSONCPP_STRING const& msg)
|
||||
RuntimeError::RuntimeError(std::string const& msg)
|
||||
: Exception(msg)
|
||||
{}
|
||||
LogicError::LogicError(JSONCPP_STRING const& msg)
|
||||
LogicError::LogicError(std::string const& msg)
|
||||
: Exception(msg)
|
||||
{}
|
||||
JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg)
|
||||
void throwRuntimeError(std::string const& msg)
|
||||
{
|
||||
throw RuntimeError(msg);
|
||||
}
|
||||
JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg)
|
||||
void throwLogicError(std::string const& msg)
|
||||
{
|
||||
throw LogicError(msg);
|
||||
}
|
||||
@@ -222,17 +202,16 @@ JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg)
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
Value::CommentInfo::CommentInfo() : comment_(0)
|
||||
{}
|
||||
Value::CommentInfo::CommentInfo() : comment_(0) {}
|
||||
|
||||
Value::CommentInfo::~CommentInfo() {
|
||||
if (comment_)
|
||||
releaseStringValue(comment_, 0u);
|
||||
releaseStringValue(comment_);
|
||||
}
|
||||
|
||||
void Value::CommentInfo::setComment(const char* text, size_t len) {
|
||||
if (comment_) {
|
||||
releaseStringValue(comment_, 0u);
|
||||
releaseStringValue(comment_);
|
||||
comment_ = 0;
|
||||
}
|
||||
JSON_ASSERT(text != 0);
|
||||
@@ -254,37 +233,31 @@ 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 index) : cstr_(0), index_(index) {}
|
||||
|
||||
Value::CZString::CZString(char const* str, unsigned ulength, DuplicationPolicy allocate)
|
||||
: cstr_(str) {
|
||||
Value::CZString::CZString(char const* str, unsigned length, DuplicationPolicy allocate)
|
||||
: cstr_(str)
|
||||
{
|
||||
// allocate != duplicate
|
||||
storage_.policy_ = allocate & 0x3;
|
||||
storage_.length_ = ulength & 0x3FFFFFFF;
|
||||
storage_.policy_ = allocate;
|
||||
storage_.length_ = 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
|
||||
Value::CZString::CZString(const CZString& other)
|
||||
: cstr_(other.storage_.policy_ != noDuplication && other.cstr_ != 0
|
||||
? duplicateStringValue(other.cstr_, other.storage_.length_)
|
||||
: other.cstr_)
|
||||
{
|
||||
storage_.policy_ = (other.cstr_
|
||||
? (other.storage_.policy_ == noDuplication
|
||||
? noDuplication : duplicate)
|
||||
: static_cast<DuplicationPolicy>(other.storage_.policy_)) & 3U;
|
||||
: other.storage_.policy_);
|
||||
storage_.length_ = other.storage_.length_;
|
||||
}
|
||||
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
Value::CZString::CZString(CZString&& other)
|
||||
: cstr_(other.cstr_), index_(other.index_) {
|
||||
other.cstr_ = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
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
|
||||
}
|
||||
if (cstr_ && storage_.policy_ == duplicate)
|
||||
releaseStringValue(const_cast<char*>(cstr_));
|
||||
}
|
||||
|
||||
void Value::CZString::swap(CZString& other) {
|
||||
@@ -304,7 +277,6 @@ bool Value::CZString::operator<(const CZString& other) const {
|
||||
unsigned this_len = this->storage_.length_;
|
||||
unsigned other_len = other.storage_.length_;
|
||||
unsigned min_len = std::min(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;
|
||||
@@ -318,7 +290,6 @@ bool Value::CZString::operator==(const CZString& other) const {
|
||||
unsigned this_len = this->storage_.length_;
|
||||
unsigned other_len = other.storage_.length_;
|
||||
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;
|
||||
}
|
||||
@@ -342,9 +313,9 @@ bool Value::CZString::isStaticString() const { return storage_.policy_ == noDupl
|
||||
* memset( this, 0, sizeof(Value) )
|
||||
* This optimization is used in ValueInternalMap fast allocator.
|
||||
*/
|
||||
Value::Value(ValueType vtype) {
|
||||
initBasic(vtype);
|
||||
switch (vtype) {
|
||||
Value::Value(ValueType type) {
|
||||
initBasic(type);
|
||||
switch (type) {
|
||||
case nullValue:
|
||||
break;
|
||||
case intValue:
|
||||
@@ -405,7 +376,7 @@ Value::Value(const char* beginValue, const char* endValue) {
|
||||
duplicateAndPrefixStringValue(beginValue, static_cast<unsigned>(endValue - beginValue));
|
||||
}
|
||||
|
||||
Value::Value(const JSONCPP_STRING& value) {
|
||||
Value::Value(const std::string& value) {
|
||||
initBasic(stringValue, true);
|
||||
value_.string_ =
|
||||
duplicateAndPrefixStringValue(value.data(), static_cast<unsigned>(value.length()));
|
||||
@@ -431,7 +402,7 @@ Value::Value(bool value) {
|
||||
Value::Value(Value const& other)
|
||||
: type_(other.type_), allocated_(false)
|
||||
,
|
||||
comments_(0), start_(other.start_), limit_(other.limit_)
|
||||
comments_(0)
|
||||
{
|
||||
switch (type_) {
|
||||
case nullValue:
|
||||
@@ -472,14 +443,6 @@ Value::Value(Value const& other)
|
||||
}
|
||||
}
|
||||
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
// Move constructor
|
||||
Value::Value(Value&& other) {
|
||||
initBasic(nullValue);
|
||||
swap(other);
|
||||
}
|
||||
#endif
|
||||
|
||||
Value::~Value() {
|
||||
switch (type_) {
|
||||
case nullValue:
|
||||
@@ -490,7 +453,7 @@ Value::~Value() {
|
||||
break;
|
||||
case stringValue:
|
||||
if (allocated_)
|
||||
releasePrefixedStringValue(value_.string_);
|
||||
releaseStringValue(value_.string_);
|
||||
break;
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
@@ -502,12 +465,11 @@ Value::~Value() {
|
||||
|
||||
if (comments_)
|
||||
delete[] comments_;
|
||||
|
||||
value_.uint_ = 0;
|
||||
}
|
||||
|
||||
Value& Value::operator=(Value other) {
|
||||
swap(other);
|
||||
Value &Value::operator=(const Value &other) {
|
||||
Value temp(other);
|
||||
swap(temp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -518,14 +480,12 @@ void Value::swapPayload(Value& other) {
|
||||
std::swap(value_, other.value_);
|
||||
int temp2 = allocated_;
|
||||
allocated_ = other.allocated_;
|
||||
other.allocated_ = temp2 & 0x1;
|
||||
other.allocated_ = temp2;
|
||||
}
|
||||
|
||||
void Value::swap(Value& other) {
|
||||
swapPayload(other);
|
||||
std::swap(comments_, other.comments_);
|
||||
std::swap(start_, other.start_);
|
||||
std::swap(limit_, other.limit_);
|
||||
}
|
||||
|
||||
ValueType Value::type() const { return type_; }
|
||||
@@ -566,7 +526,6 @@ bool Value::operator<(const Value& other) const {
|
||||
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(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;
|
||||
@@ -622,7 +581,6 @@ bool Value::operator==(const Value& other) const {
|
||||
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;
|
||||
}
|
||||
@@ -648,28 +606,16 @@ const char* Value::asCString() const {
|
||||
return this_str;
|
||||
}
|
||||
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
unsigned Value::getCStringLength() const {
|
||||
JSON_ASSERT_MESSAGE(type_ == stringValue,
|
||||
"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);
|
||||
return this_len;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Value::getString(char const** str, char const** cend) const {
|
||||
bool Value::getString(char const** str, char const** end) 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;
|
||||
*end = *str + length;
|
||||
return true;
|
||||
}
|
||||
|
||||
JSONCPP_STRING Value::asString() const {
|
||||
std::string Value::asString() const {
|
||||
switch (type_) {
|
||||
case nullValue:
|
||||
return "";
|
||||
@@ -679,7 +625,7 @@ JSONCPP_STRING Value::asString() const {
|
||||
unsigned this_len;
|
||||
char const* this_str;
|
||||
decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
|
||||
return JSONCPP_STRING(this_str, this_len);
|
||||
return std::string(this_str, this_len);
|
||||
}
|
||||
case booleanValue:
|
||||
return value_.bool_ ? "true" : "false";
|
||||
@@ -839,8 +785,7 @@ float Value::asFloat() const {
|
||||
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||
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_));
|
||||
return integerToDouble(value_.uint_);
|
||||
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||
case realValue:
|
||||
return static_cast<float>(value_.real_);
|
||||
@@ -865,8 +810,7 @@ bool Value::asBool() const {
|
||||
case uintValue:
|
||||
return value_.uint_ ? true : false;
|
||||
case realValue:
|
||||
// This is kind of strange. Not recommended.
|
||||
return (value_.real_ != 0.0) ? true : false;
|
||||
return value_.real_ ? true : false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -943,8 +887,6 @@ void Value::clear() {
|
||||
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue ||
|
||||
type_ == objectValue,
|
||||
"in Json::Value::clear(): requires complex value");
|
||||
start_ = 0;
|
||||
limit_ = 0;
|
||||
switch (type_) {
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
@@ -969,7 +911,7 @@ void Value::resize(ArrayIndex newSize) {
|
||||
for (ArrayIndex index = newSize; index < oldSize; ++index) {
|
||||
value_.map_->erase(index);
|
||||
}
|
||||
JSON_ASSERT(size() == newSize);
|
||||
assert(size() == newSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -984,7 +926,7 @@ Value& Value::operator[](ArrayIndex index) {
|
||||
if (it != value_.map_->end() && (*it).first == key)
|
||||
return (*it).second;
|
||||
|
||||
ObjectValues::value_type defaultValue(key, nullSingleton());
|
||||
ObjectValues::value_type defaultValue(key, nullRef);
|
||||
it = value_.map_->insert(it, defaultValue);
|
||||
return (*it).second;
|
||||
}
|
||||
@@ -1001,11 +943,11 @@ const Value& Value::operator[](ArrayIndex index) const {
|
||||
type_ == nullValue || type_ == arrayValue,
|
||||
"in Json::Value::operator[](ArrayIndex)const: requires arrayValue");
|
||||
if (type_ == nullValue)
|
||||
return nullSingleton();
|
||||
return nullRef;
|
||||
CZString key(index);
|
||||
ObjectValues::const_iterator it = value_.map_->find(key);
|
||||
if (it == value_.map_->end())
|
||||
return nullSingleton();
|
||||
return nullRef;
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
@@ -1016,12 +958,10 @@ const Value& Value::operator[](int index) const {
|
||||
return (*this)[ArrayIndex(index)];
|
||||
}
|
||||
|
||||
void Value::initBasic(ValueType vtype, bool allocated) {
|
||||
type_ = vtype;
|
||||
void Value::initBasic(ValueType type, bool allocated) {
|
||||
type_ = type;
|
||||
allocated_ = allocated;
|
||||
comments_ = 0;
|
||||
start_ = 0;
|
||||
limit_ = 0;
|
||||
}
|
||||
|
||||
// Access an object value by name, create a null member if it does not exist.
|
||||
@@ -1039,14 +979,14 @@ Value& Value::resolveReference(const char* key) {
|
||||
if (it != value_.map_->end() && (*it).first == actualKey)
|
||||
return (*it).second;
|
||||
|
||||
ObjectValues::value_type defaultValue(actualKey, nullSingleton());
|
||||
ObjectValues::value_type defaultValue(actualKey, nullRef);
|
||||
it = value_.map_->insert(it, defaultValue);
|
||||
Value& value = (*it).second;
|
||||
return value;
|
||||
}
|
||||
|
||||
// @param key is not null-terminated.
|
||||
Value& Value::resolveReference(char const* key, char const* cend)
|
||||
Value& Value::resolveReference(char const* key, char const* end)
|
||||
{
|
||||
JSON_ASSERT_MESSAGE(
|
||||
type_ == nullValue || type_ == objectValue,
|
||||
@@ -1054,12 +994,12 @@ Value& Value::resolveReference(char const* key, char const* cend)
|
||||
if (type_ == nullValue)
|
||||
*this = Value(objectValue);
|
||||
CZString actualKey(
|
||||
key, static_cast<unsigned>(cend-key), CZString::duplicateOnCopy);
|
||||
key, static_cast<unsigned>(end-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());
|
||||
ObjectValues::value_type defaultValue(actualKey, nullRef);
|
||||
it = value_.map_->insert(it, defaultValue);
|
||||
Value& value = (*it).second;
|
||||
return value;
|
||||
@@ -1067,18 +1007,18 @@ Value& Value::resolveReference(char const* key, char const* cend)
|
||||
|
||||
Value Value::get(ArrayIndex index, const Value& defaultValue) const {
|
||||
const Value* value = &((*this)[index]);
|
||||
return value == &nullSingleton() ? defaultValue : *value;
|
||||
return value == &nullRef ? defaultValue : *value;
|
||||
}
|
||||
|
||||
bool Value::isValidIndex(ArrayIndex index) const { return index < size(); }
|
||||
|
||||
Value const* Value::find(char const* key, char const* cend) const
|
||||
Value const* Value::find(char const* key, char const* end) const
|
||||
{
|
||||
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);
|
||||
CZString actualKey(key, static_cast<unsigned>(end-key), CZString::noDuplication);
|
||||
ObjectValues::const_iterator it = value_.map_->find(actualKey);
|
||||
if (it == value_.map_->end()) return NULL;
|
||||
return &(*it).second;
|
||||
@@ -1086,13 +1026,13 @@ Value const* Value::find(char const* key, char const* cend) const
|
||||
const Value& Value::operator[](const char* key) const
|
||||
{
|
||||
Value const* found = find(key, key + strlen(key));
|
||||
if (!found) return nullSingleton();
|
||||
if (!found) return nullRef;
|
||||
return *found;
|
||||
}
|
||||
Value const& Value::operator[](JSONCPP_STRING const& key) const
|
||||
Value const& Value::operator[](std::string const& key) const
|
||||
{
|
||||
Value const* found = find(key.data(), key.data() + key.length());
|
||||
if (!found) return nullSingleton();
|
||||
if (!found) return nullRef;
|
||||
return *found;
|
||||
}
|
||||
|
||||
@@ -1100,7 +1040,7 @@ Value& Value::operator[](const char* key) {
|
||||
return resolveReference(key, key + strlen(key));
|
||||
}
|
||||
|
||||
Value& Value::operator[](const JSONCPP_STRING& key) {
|
||||
Value& Value::operator[](const std::string& key) {
|
||||
return resolveReference(key.data(), key.data() + key.length());
|
||||
}
|
||||
|
||||
@@ -1115,34 +1055,34 @@ Value& Value::operator[](const CppTL::ConstString& key) {
|
||||
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 nullRef;
|
||||
return *found;
|
||||
}
|
||||
#endif
|
||||
|
||||
Value& Value::append(const Value& value) { return (*this)[size()] = value; }
|
||||
|
||||
Value Value::get(char const* key, char const* cend, Value const& defaultValue) const
|
||||
Value Value::get(char const* key, char const* end, Value const& defaultValue) const
|
||||
{
|
||||
Value const* found = find(key, cend);
|
||||
Value const* found = find(key, end);
|
||||
return !found ? defaultValue : *found;
|
||||
}
|
||||
Value Value::get(char const* key, Value const& defaultValue) const
|
||||
{
|
||||
return get(key, key + strlen(key), defaultValue);
|
||||
}
|
||||
Value Value::get(JSONCPP_STRING const& key, Value const& defaultValue) const
|
||||
Value Value::get(std::string const& key, Value const& defaultValue) const
|
||||
{
|
||||
return get(key.data(), key.data() + key.length(), defaultValue);
|
||||
}
|
||||
|
||||
|
||||
bool Value::removeMember(const char* key, const char* cend, Value* removed)
|
||||
bool Value::removeMember(const char* key, const char* end, Value* removed)
|
||||
{
|
||||
if (type_ != objectValue) {
|
||||
return false;
|
||||
}
|
||||
CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
|
||||
CZString actualKey(key, static_cast<unsigned>(end-key), CZString::noDuplication);
|
||||
ObjectValues::iterator it = value_.map_->find(actualKey);
|
||||
if (it == value_.map_->end())
|
||||
return false;
|
||||
@@ -1154,7 +1094,7 @@ bool Value::removeMember(const char* key, Value* removed)
|
||||
{
|
||||
return removeMember(key, key + strlen(key), removed);
|
||||
}
|
||||
bool Value::removeMember(JSONCPP_STRING const& key, Value* removed)
|
||||
bool Value::removeMember(std::string const& key, Value* removed)
|
||||
{
|
||||
return removeMember(key.data(), key.data() + key.length(), removed);
|
||||
}
|
||||
@@ -1163,13 +1103,13 @@ Value Value::removeMember(const char* key)
|
||||
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
|
||||
"in Json::Value::removeMember(): requires objectValue");
|
||||
if (type_ == nullValue)
|
||||
return nullSingleton();
|
||||
return nullRef;
|
||||
|
||||
Value removed; // null
|
||||
removeMember(key, key + strlen(key), &removed);
|
||||
return removed; // still null if removeMember() did nothing
|
||||
}
|
||||
Value Value::removeMember(const JSONCPP_STRING& key)
|
||||
Value Value::removeMember(const std::string& key)
|
||||
{
|
||||
return removeMember(key.c_str());
|
||||
}
|
||||
@@ -1187,8 +1127,8 @@ bool Value::removeIndex(ArrayIndex index, Value* removed) {
|
||||
ArrayIndex oldSize = size();
|
||||
// shift left all items left, into the place of the "removed"
|
||||
for (ArrayIndex i = index; i < (oldSize - 1); ++i){
|
||||
CZString keey(i);
|
||||
(*value_.map_)[keey] = (*this)[i + 1];
|
||||
CZString key(i);
|
||||
(*value_.map_)[key] = (*this)[i + 1];
|
||||
}
|
||||
// erase the last one ("leftover")
|
||||
CZString keyLast(oldSize - 1);
|
||||
@@ -1204,16 +1144,16 @@ Value Value::get(const CppTL::ConstString& key,
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Value::isMember(char const* key, char const* cend) const
|
||||
bool Value::isMember(char const* key, char const* end) const
|
||||
{
|
||||
Value const* value = find(key, cend);
|
||||
Value const* value = find(key, end);
|
||||
return NULL != value;
|
||||
}
|
||||
bool Value::isMember(char const* key) const
|
||||
{
|
||||
return isMember(key, key + strlen(key));
|
||||
}
|
||||
bool Value::isMember(JSONCPP_STRING const& key) const
|
||||
bool Value::isMember(std::string const& key) const
|
||||
{
|
||||
return isMember(key.data(), key.data() + key.length());
|
||||
}
|
||||
@@ -1235,7 +1175,7 @@ Value::Members Value::getMemberNames() const {
|
||||
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(),
|
||||
members.push_back(std::string((*it).first.data(),
|
||||
(*it).first.length()));
|
||||
}
|
||||
return members;
|
||||
@@ -1377,7 +1317,7 @@ void Value::setComment(const char* comment, CommentPlacement placement) {
|
||||
setComment(comment, strlen(comment), placement);
|
||||
}
|
||||
|
||||
void Value::setComment(const JSONCPP_STRING& comment, CommentPlacement placement) {
|
||||
void Value::setComment(const std::string& comment, CommentPlacement placement) {
|
||||
setComment(comment.c_str(), comment.length(), placement);
|
||||
}
|
||||
|
||||
@@ -1385,21 +1325,13 @@ bool Value::hasComment(CommentPlacement placement) const {
|
||||
return comments_ != 0 && comments_[placement].comment_ != 0;
|
||||
}
|
||||
|
||||
JSONCPP_STRING Value::getComment(CommentPlacement placement) const {
|
||||
std::string Value::getComment(CommentPlacement placement) const {
|
||||
if (hasComment(placement))
|
||||
return comments_[placement].comment_;
|
||||
return "";
|
||||
}
|
||||
|
||||
void Value::setOffsetStart(ptrdiff_t start) { start_ = start; }
|
||||
|
||||
void Value::setOffsetLimit(ptrdiff_t limit) { limit_ = limit; }
|
||||
|
||||
ptrdiff_t Value::getOffsetStart() const { return start_; }
|
||||
|
||||
ptrdiff_t Value::getOffsetLimit() const { return limit_; }
|
||||
|
||||
JSONCPP_STRING Value::toStyledString() const {
|
||||
std::string Value::toStyledString() const {
|
||||
StyledWriter writer;
|
||||
return writer.write(*this);
|
||||
}
|
||||
@@ -1467,13 +1399,13 @@ PathArgument::PathArgument(ArrayIndex index)
|
||||
PathArgument::PathArgument(const char* key)
|
||||
: key_(key), index_(), kind_(kindKey) {}
|
||||
|
||||
PathArgument::PathArgument(const JSONCPP_STRING& key)
|
||||
PathArgument::PathArgument(const std::string& key)
|
||||
: key_(key.c_str()), index_(), kind_(kindKey) {}
|
||||
|
||||
// class Path
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
Path::Path(const JSONCPP_STRING& path,
|
||||
Path::Path(const std::string& path,
|
||||
const PathArgument& a1,
|
||||
const PathArgument& a2,
|
||||
const PathArgument& a3,
|
||||
@@ -1488,7 +1420,7 @@ Path::Path(const JSONCPP_STRING& path,
|
||||
makePath(path, in);
|
||||
}
|
||||
|
||||
void Path::makePath(const JSONCPP_STRING& path, const InArgs& in) {
|
||||
void Path::makePath(const std::string& path, const InArgs& in) {
|
||||
const char* current = path.c_str();
|
||||
const char* end = current + path.length();
|
||||
InArgs::const_iterator itInArg = in.begin();
|
||||
@@ -1514,12 +1446,12 @@ void Path::makePath(const JSONCPP_STRING& path, const InArgs& in) {
|
||||
const char* beginName = current;
|
||||
while (current != end && !strchr("[.", *current))
|
||||
++current;
|
||||
args_.push_back(JSONCPP_STRING(beginName, current));
|
||||
args_.push_back(std::string(beginName, current));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Path::addPathInArg(const JSONCPP_STRING& /*path*/,
|
||||
void Path::addPathInArg(const std::string& /*path*/,
|
||||
const InArgs& in,
|
||||
InArgs::const_iterator& itInArg,
|
||||
PathArgument::Kind kind) {
|
||||
@@ -1532,7 +1464,7 @@ void Path::addPathInArg(const JSONCPP_STRING& /*path*/,
|
||||
}
|
||||
}
|
||||
|
||||
void Path::invalidPath(const JSONCPP_STRING& /*path*/, int /*location*/) {
|
||||
void Path::invalidPath(const std::string& /*path*/, int /*location*/) {
|
||||
// Error: invalid path.
|
||||
}
|
||||
|
||||
@@ -1550,7 +1482,7 @@ const Value& Path::resolve(const Value& root) const {
|
||||
// Error: unable to resolve path (object value expected at position...)
|
||||
}
|
||||
node = &((*node)[arg.key_]);
|
||||
if (node == &Value::nullSingleton()) {
|
||||
if (node == &Value::nullRef) {
|
||||
// Error: unable to resolve path (object has no member named '' at
|
||||
// position...)
|
||||
}
|
||||
@@ -1571,7 +1503,7 @@ Value Path::resolve(const Value& root, const Value& defaultValue) const {
|
||||
if (!node->isObject())
|
||||
return defaultValue;
|
||||
node = &((*node)[arg.key_]);
|
||||
if (node == &Value::nullSingleton())
|
||||
if (node == &Value::nullRef)
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
@@ -92,27 +92,27 @@ UInt ValueIteratorBase::index() const {
|
||||
return Value::UInt(-1);
|
||||
}
|
||||
|
||||
JSONCPP_STRING ValueIteratorBase::name() const {
|
||||
char const* keey;
|
||||
std::string ValueIteratorBase::name() const {
|
||||
char const* key;
|
||||
char const* end;
|
||||
keey = memberName(&end);
|
||||
if (!keey) return JSONCPP_STRING();
|
||||
return JSONCPP_STRING(keey, end);
|
||||
key = memberName(&end);
|
||||
if (!key) return std::string();
|
||||
return std::string(key, end);
|
||||
}
|
||||
|
||||
char const* ValueIteratorBase::memberName() const {
|
||||
const char* cname = (*current_).first.data();
|
||||
return cname ? cname : "";
|
||||
const char* name = (*current_).first.data();
|
||||
return name ? name : "";
|
||||
}
|
||||
|
||||
char const* ValueIteratorBase::memberName(char const** end) const {
|
||||
const char* cname = (*current_).first.data();
|
||||
if (!cname) {
|
||||
const char* name = (*current_).first.data();
|
||||
if (!name) {
|
||||
*end = NULL;
|
||||
return NULL;
|
||||
}
|
||||
*end = cname + (*current_).first.length();
|
||||
return cname;
|
||||
*end = name + (*current_).first.length();
|
||||
return name;
|
||||
}
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
@@ -129,9 +129,6 @@ ValueConstIterator::ValueConstIterator(
|
||||
const Value::ObjectValues::iterator& current)
|
||||
: ValueIteratorBase(current) {}
|
||||
|
||||
ValueConstIterator::ValueConstIterator(ValueIterator const& other)
|
||||
: ValueIteratorBase(other) {}
|
||||
|
||||
ValueConstIterator& ValueConstIterator::
|
||||
operator=(const ValueIteratorBase& other) {
|
||||
copy(other);
|
||||
@@ -152,9 +149,7 @@ ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)
|
||||
: ValueIteratorBase(current) {}
|
||||
|
||||
ValueIterator::ValueIterator(const ValueConstIterator& other)
|
||||
: ValueIteratorBase(other) {
|
||||
throwRuntimeError("ConstIterator to Iterator should never be allowed.");
|
||||
}
|
||||
: ValueIteratorBase(other) {}
|
||||
|
||||
ValueIterator::ValueIterator(const ValueIterator& other)
|
||||
: ValueIteratorBase(other) {}
|
||||
|
@@ -20,53 +20,18 @@
|
||||
#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
|
||||
#elif defined(__hpux)
|
||||
#if !defined(isfinite)
|
||||
#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
|
||||
#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
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below
|
||||
#define snprintf _snprintf
|
||||
#else
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
#elif defined(__ANDROID__) || defined(__QNXNTO__)
|
||||
#define snprintf snprintf
|
||||
#elif __cplusplus >= 201103L
|
||||
#if !defined(__MINGW32__) && !defined(__CYGWIN__)
|
||||
#define snprintf std::snprintf
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
#include <float.h>
|
||||
#define isfinite _finite
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
|
||||
// Disable warning about strdup being deprecated.
|
||||
@@ -75,7 +40,7 @@
|
||||
|
||||
namespace Json {
|
||||
|
||||
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
|
||||
#if __cplusplus >= 201103L
|
||||
typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
|
||||
#else
|
||||
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
|
||||
@@ -99,23 +64,20 @@ static bool containsControlCharacter0(const char* str, unsigned len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
JSONCPP_STRING valueToString(LargestInt value) {
|
||||
std::string valueToString(LargestInt value) {
|
||||
UIntToStringBuffer buffer;
|
||||
char* current = buffer + sizeof(buffer);
|
||||
if (value == Value::minLargestInt) {
|
||||
uintToString(LargestUInt(Value::maxLargestInt) + 1, current);
|
||||
bool isNegative = value < 0;
|
||||
if (isNegative)
|
||||
value = -value;
|
||||
uintToString(LargestUInt(value), current);
|
||||
if (isNegative)
|
||||
*--current = '-';
|
||||
} else if (value < 0) {
|
||||
uintToString(LargestUInt(-value), current);
|
||||
*--current = '-';
|
||||
} else {
|
||||
uintToString(LargestUInt(value), current);
|
||||
}
|
||||
assert(current >= buffer);
|
||||
return current;
|
||||
}
|
||||
|
||||
JSONCPP_STRING valueToString(LargestUInt value) {
|
||||
std::string valueToString(LargestUInt value) {
|
||||
UIntToStringBuffer buffer;
|
||||
char* current = buffer + sizeof(buffer);
|
||||
uintToString(value, current);
|
||||
@@ -125,65 +87,68 @@ JSONCPP_STRING valueToString(LargestUInt value) {
|
||||
|
||||
#if defined(JSON_HAS_INT64)
|
||||
|
||||
JSONCPP_STRING valueToString(Int value) {
|
||||
std::string valueToString(Int value) {
|
||||
return valueToString(LargestInt(value));
|
||||
}
|
||||
|
||||
JSONCPP_STRING valueToString(UInt value) {
|
||||
std::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) {
|
||||
std::string valueToString(double value) {
|
||||
// Allocate a buffer that is more than large enough to store the 16 digits of
|
||||
// precision requested below.
|
||||
char buffer[32];
|
||||
int len = -1;
|
||||
|
||||
char formatString[6];
|
||||
sprintf(formatString, "%%.%dg", precision);
|
||||
|
||||
// Print into the buffer. We need not request the alternative representation
|
||||
// that always has a decimal point because JSON doesn't distingish the
|
||||
// concepts of reals and integers.
|
||||
// Print into the buffer. We need not request the alternative representation
|
||||
// that always has a decimal point because JSON doesn't distingish the
|
||||
// concepts of reals and integers.
|
||||
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with
|
||||
// visual studio 2005 to
|
||||
// avoid warning.
|
||||
#if defined(WINCE)
|
||||
len = _snprintf(buffer, sizeof(buffer), "%.17g", value);
|
||||
#else
|
||||
len = sprintf_s(buffer, sizeof(buffer), "%.17g", value);
|
||||
#endif
|
||||
#else
|
||||
if (isfinite(value)) {
|
||||
len = snprintf(buffer, sizeof(buffer), formatString, value);
|
||||
len = snprintf(buffer, sizeof(buffer), "%.17g", value);
|
||||
} 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), "null");
|
||||
} else if (value < 0) {
|
||||
len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "-Infinity" : "-1e+9999");
|
||||
len = snprintf(buffer, sizeof(buffer), "-1e+9999");
|
||||
} else {
|
||||
len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "Infinity" : "1e+9999");
|
||||
len = snprintf(buffer, sizeof(buffer), "1e+9999");
|
||||
}
|
||||
// For those, we do not need to call fixNumLoc, but it is fast.
|
||||
}
|
||||
#endif
|
||||
assert(len >= 0);
|
||||
fixNumericLocale(buffer, buffer + len);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
JSONCPP_STRING valueToString(double value) { return valueToString(value, false, 17); }
|
||||
std::string valueToString(bool value) { return value ? "true" : "false"; }
|
||||
|
||||
JSONCPP_STRING valueToString(bool value) { return value ? "true" : "false"; }
|
||||
|
||||
JSONCPP_STRING valueToQuotedString(const char* value) {
|
||||
std::string valueToQuotedString(const char* value) {
|
||||
if (value == NULL)
|
||||
return "";
|
||||
// Not sure how to handle unicode...
|
||||
if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL &&
|
||||
!containsControlCharacter(value))
|
||||
return JSONCPP_STRING("\"") + value + "\"";
|
||||
return std::string("\"") + value + "\"";
|
||||
// We have to walk value and escape any special characters.
|
||||
// Appending to JSONCPP_STRING is not efficient, but this should be rare.
|
||||
// Appending to std::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 =
|
||||
std::string::size_type maxsize =
|
||||
strlen(value) * 2 + 3; // allescaped+quotes+NULL
|
||||
JSONCPP_STRING result;
|
||||
std::string result;
|
||||
result.reserve(maxsize); // to avoid lots of mallocs
|
||||
result += "\"";
|
||||
for (const char* c = value; *c != 0; ++c) {
|
||||
@@ -219,7 +184,7 @@ JSONCPP_STRING valueToQuotedString(const char* value) {
|
||||
// sequence from occurring.
|
||||
default:
|
||||
if (isControlCharacter(*c)) {
|
||||
JSONCPP_OSTRINGSTREAM oss;
|
||||
std::ostringstream oss;
|
||||
oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
|
||||
<< std::setw(4) << static_cast<int>(*c);
|
||||
result += oss.str();
|
||||
@@ -248,19 +213,19 @@ 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 std::string valueToQuotedStringN(const char* value, unsigned length) {
|
||||
if (value == NULL)
|
||||
return "";
|
||||
// Not sure how to handle unicode...
|
||||
if (strnpbrk(value, "\"\\\b\f\n\r\t", length) == NULL &&
|
||||
!containsControlCharacter0(value, length))
|
||||
return JSONCPP_STRING("\"") + value + "\"";
|
||||
return std::string("\"") + value + "\"";
|
||||
// We have to walk value and escape any special characters.
|
||||
// Appending to JSONCPP_STRING is not efficient, but this should be rare.
|
||||
// Appending to std::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 =
|
||||
std::string::size_type maxsize =
|
||||
length * 2 + 3; // allescaped+quotes+NULL
|
||||
JSONCPP_STRING result;
|
||||
std::string result;
|
||||
result.reserve(maxsize); // to avoid lots of mallocs
|
||||
result += "\"";
|
||||
char const* end = value + length;
|
||||
@@ -297,7 +262,7 @@ static JSONCPP_STRING valueToQuotedStringN(const char* value, unsigned length) {
|
||||
// sequence from occurring.
|
||||
default:
|
||||
if ((isControlCharacter(*c)) || (*c == 0)) {
|
||||
JSONCPP_OSTRINGSTREAM oss;
|
||||
std::ostringstream oss;
|
||||
oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
|
||||
<< std::setw(4) << static_cast<int>(*c);
|
||||
result += oss.str();
|
||||
@@ -319,28 +284,21 @@ Writer::~Writer() {}
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
FastWriter::FastWriter()
|
||||
: yamlCompatiblityEnabled_(false), dropNullPlaceholders_(false),
|
||||
omitEndingLineFeed_(false) {}
|
||||
: yamlCompatiblityEnabled_(false) {}
|
||||
|
||||
void FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; }
|
||||
|
||||
void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
|
||||
|
||||
void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
|
||||
|
||||
JSONCPP_STRING FastWriter::write(const Value& root) {
|
||||
std::string FastWriter::write(const Value& root) {
|
||||
document_ = "";
|
||||
writeValue(root);
|
||||
if (!omitEndingLineFeed_)
|
||||
document_ += "\n";
|
||||
document_ += "\n";
|
||||
return document_;
|
||||
}
|
||||
|
||||
void FastWriter::writeValue(const Value& value) {
|
||||
switch (value.type()) {
|
||||
case nullValue:
|
||||
if (!dropNullPlaceholders_)
|
||||
document_ += "null";
|
||||
document_ += "null";
|
||||
break;
|
||||
case intValue:
|
||||
document_ += valueToString(value.asLargestInt());
|
||||
@@ -352,21 +310,15 @@ void FastWriter::writeValue(const Value& value) {
|
||||
document_ += valueToString(value.asDouble());
|
||||
break;
|
||||
case stringValue:
|
||||
{
|
||||
// Is NULL possible for value.string_?
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
if (ok) document_ += valueToQuotedStringN(str, static_cast<unsigned>(end-str));
|
||||
document_ += valueToQuotedString(value.asCString());
|
||||
break;
|
||||
}
|
||||
case booleanValue:
|
||||
document_ += valueToString(value.asBool());
|
||||
break;
|
||||
case arrayValue: {
|
||||
document_ += '[';
|
||||
ArrayIndex size = value.size();
|
||||
for (ArrayIndex index = 0; index < size; ++index) {
|
||||
int size = value.size();
|
||||
for (int index = 0; index < size; ++index) {
|
||||
if (index > 0)
|
||||
document_ += ',';
|
||||
writeValue(value[index]);
|
||||
@@ -378,10 +330,10 @@ void FastWriter::writeValue(const Value& value) {
|
||||
document_ += '{';
|
||||
for (Value::Members::iterator it = members.begin(); it != members.end();
|
||||
++it) {
|
||||
const JSONCPP_STRING& name = *it;
|
||||
const std::string& name = *it;
|
||||
if (it != members.begin())
|
||||
document_ += ',';
|
||||
document_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length()));
|
||||
document_ += valueToQuotedStringN(name.data(), name.length());
|
||||
document_ += yamlCompatiblityEnabled_ ? ": " : ":";
|
||||
writeValue(value[name]);
|
||||
}
|
||||
@@ -396,7 +348,7 @@ void FastWriter::writeValue(const Value& value) {
|
||||
StyledWriter::StyledWriter()
|
||||
: rightMargin_(74), indentSize_(3), addChildValues_() {}
|
||||
|
||||
JSONCPP_STRING StyledWriter::write(const Value& root) {
|
||||
std::string StyledWriter::write(const Value& root) {
|
||||
document_ = "";
|
||||
addChildValues_ = false;
|
||||
indentString_ = "";
|
||||
@@ -423,7 +375,7 @@ void StyledWriter::writeValue(const Value& value) {
|
||||
break;
|
||||
case stringValue:
|
||||
{
|
||||
// Is NULL possible for value.string_?
|
||||
// Is NULL is possible for value.string_?
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
@@ -446,7 +398,7 @@ void StyledWriter::writeValue(const Value& value) {
|
||||
indent();
|
||||
Value::Members::iterator it = members.begin();
|
||||
for (;;) {
|
||||
const JSONCPP_STRING& name = *it;
|
||||
const std::string& name = *it;
|
||||
const Value& childValue = value[name];
|
||||
writeCommentBeforeValue(childValue);
|
||||
writeWithIndent(valueToQuotedString(name.c_str()));
|
||||
@@ -510,25 +462,26 @@ void StyledWriter::writeArrayValue(const Value& value) {
|
||||
}
|
||||
|
||||
bool StyledWriter::isMultineArray(const Value& value) {
|
||||
ArrayIndex const size = value.size();
|
||||
int size = value.size();
|
||||
bool isMultiLine = size * 3 >= rightMargin_;
|
||||
childValues_.clear();
|
||||
for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
|
||||
for (int index = 0; index < size && !isMultiLine; ++index) {
|
||||
const Value& childValue = value[index];
|
||||
isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
|
||||
isMultiLine =
|
||||
isMultiLine || ((childValue.isArray() || childValue.isObject()) &&
|
||||
childValue.size() > 0);
|
||||
}
|
||||
if (!isMultiLine) // check if line length > max line length
|
||||
{
|
||||
childValues_.reserve(size);
|
||||
addChildValues_ = true;
|
||||
ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||
for (ArrayIndex index = 0; index < size; ++index) {
|
||||
int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||
for (int index = 0; index < size; ++index) {
|
||||
if (hasCommentForValue(value[index])) {
|
||||
isMultiLine = true;
|
||||
}
|
||||
writeValue(value[index]);
|
||||
lineLength += static_cast<ArrayIndex>(childValues_[index].length());
|
||||
lineLength += int(childValues_[index].length());
|
||||
}
|
||||
addChildValues_ = false;
|
||||
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
||||
@@ -536,7 +489,7 @@ bool StyledWriter::isMultineArray(const Value& value) {
|
||||
return isMultiLine;
|
||||
}
|
||||
|
||||
void StyledWriter::pushValue(const JSONCPP_STRING& value) {
|
||||
void StyledWriter::pushValue(const std::string& value) {
|
||||
if (addChildValues_)
|
||||
childValues_.push_back(value);
|
||||
else
|
||||
@@ -554,15 +507,15 @@ void StyledWriter::writeIndent() {
|
||||
document_ += indentString_;
|
||||
}
|
||||
|
||||
void StyledWriter::writeWithIndent(const JSONCPP_STRING& value) {
|
||||
void StyledWriter::writeWithIndent(const std::string& value) {
|
||||
writeIndent();
|
||||
document_ += value;
|
||||
}
|
||||
|
||||
void StyledWriter::indent() { indentString_ += JSONCPP_STRING(indentSize_, ' '); }
|
||||
void StyledWriter::indent() { indentString_ += std::string(indentSize_, ' '); }
|
||||
|
||||
void StyledWriter::unindent() {
|
||||
assert(indentString_.size() >= indentSize_);
|
||||
assert(int(indentString_.size()) >= indentSize_);
|
||||
indentString_.resize(indentString_.size() - indentSize_);
|
||||
}
|
||||
|
||||
@@ -572,8 +525,8 @@ void StyledWriter::writeCommentBeforeValue(const Value& root) {
|
||||
|
||||
document_ += "\n";
|
||||
writeIndent();
|
||||
const JSONCPP_STRING& comment = root.getComment(commentBefore);
|
||||
JSONCPP_STRING::const_iterator iter = comment.begin();
|
||||
const std::string& comment = root.getComment(commentBefore);
|
||||
std::string::const_iterator iter = comment.begin();
|
||||
while (iter != comment.end()) {
|
||||
document_ += *iter;
|
||||
if (*iter == '\n' &&
|
||||
@@ -606,11 +559,11 @@ bool StyledWriter::hasCommentForValue(const Value& value) {
|
||||
// Class StyledStreamWriter
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
StyledStreamWriter::StyledStreamWriter(JSONCPP_STRING indentation)
|
||||
StyledStreamWriter::StyledStreamWriter(std::string indentation)
|
||||
: document_(NULL), rightMargin_(74), indentation_(indentation),
|
||||
addChildValues_() {}
|
||||
|
||||
void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
|
||||
void StyledStreamWriter::write(std::ostream& out, const Value& root) {
|
||||
document_ = &out;
|
||||
addChildValues_ = false;
|
||||
indentString_ = "";
|
||||
@@ -639,15 +592,8 @@ void StyledStreamWriter::writeValue(const Value& value) {
|
||||
pushValue(valueToString(value.asDouble()));
|
||||
break;
|
||||
case stringValue:
|
||||
{
|
||||
// Is NULL possible for value.string_?
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
|
||||
else pushValue("");
|
||||
pushValue(valueToQuotedString(value.asCString()));
|
||||
break;
|
||||
}
|
||||
case booleanValue:
|
||||
pushValue(valueToString(value.asBool()));
|
||||
break;
|
||||
@@ -663,7 +609,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
|
||||
indent();
|
||||
Value::Members::iterator it = members.begin();
|
||||
for (;;) {
|
||||
const JSONCPP_STRING& name = *it;
|
||||
const std::string& name = *it;
|
||||
const Value& childValue = value[name];
|
||||
writeCommentBeforeValue(childValue);
|
||||
writeWithIndent(valueToQuotedString(name.c_str()));
|
||||
@@ -729,25 +675,26 @@ void StyledStreamWriter::writeArrayValue(const Value& value) {
|
||||
}
|
||||
|
||||
bool StyledStreamWriter::isMultineArray(const Value& value) {
|
||||
ArrayIndex const size = value.size();
|
||||
int size = value.size();
|
||||
bool isMultiLine = size * 3 >= rightMargin_;
|
||||
childValues_.clear();
|
||||
for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
|
||||
for (int index = 0; index < size && !isMultiLine; ++index) {
|
||||
const Value& childValue = value[index];
|
||||
isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
|
||||
isMultiLine =
|
||||
isMultiLine || ((childValue.isArray() || childValue.isObject()) &&
|
||||
childValue.size() > 0);
|
||||
}
|
||||
if (!isMultiLine) // check if line length > max line length
|
||||
{
|
||||
childValues_.reserve(size);
|
||||
addChildValues_ = true;
|
||||
ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||
for (ArrayIndex index = 0; index < size; ++index) {
|
||||
int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||
for (int index = 0; index < size; ++index) {
|
||||
if (hasCommentForValue(value[index])) {
|
||||
isMultiLine = true;
|
||||
}
|
||||
writeValue(value[index]);
|
||||
lineLength += static_cast<ArrayIndex>(childValues_[index].length());
|
||||
lineLength += int(childValues_[index].length());
|
||||
}
|
||||
addChildValues_ = false;
|
||||
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
||||
@@ -755,7 +702,7 @@ bool StyledStreamWriter::isMultineArray(const Value& value) {
|
||||
return isMultiLine;
|
||||
}
|
||||
|
||||
void StyledStreamWriter::pushValue(const JSONCPP_STRING& value) {
|
||||
void StyledStreamWriter::pushValue(const std::string& value) {
|
||||
if (addChildValues_)
|
||||
childValues_.push_back(value);
|
||||
else
|
||||
@@ -770,7 +717,7 @@ void StyledStreamWriter::writeIndent() {
|
||||
*document_ << '\n' << indentString_;
|
||||
}
|
||||
|
||||
void StyledStreamWriter::writeWithIndent(const JSONCPP_STRING& value) {
|
||||
void StyledStreamWriter::writeWithIndent(const std::string& value) {
|
||||
if (!indented_) writeIndent();
|
||||
*document_ << value;
|
||||
indented_ = false;
|
||||
@@ -788,8 +735,8 @@ void StyledStreamWriter::writeCommentBeforeValue(const Value& root) {
|
||||
return;
|
||||
|
||||
if (!indented_) writeIndent();
|
||||
const JSONCPP_STRING& comment = root.getComment(commentBefore);
|
||||
JSONCPP_STRING::const_iterator iter = comment.begin();
|
||||
const std::string& comment = root.getComment(commentBefore);
|
||||
std::string::const_iterator iter = comment.begin();
|
||||
while (iter != comment.end()) {
|
||||
*document_ << *iter;
|
||||
if (*iter == '\n' &&
|
||||
@@ -834,50 +781,44 @@ struct CommentStyle {
|
||||
struct BuiltStyledStreamWriter : public StreamWriter
|
||||
{
|
||||
BuiltStyledStreamWriter(
|
||||
JSONCPP_STRING const& indentation,
|
||||
std::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;
|
||||
std::string const& colonSymbol,
|
||||
std::string const& nullSymbol,
|
||||
std::string const& endingLineFeedSymbol);
|
||||
virtual int write(Value const& root, std::ostream* sout);
|
||||
private:
|
||||
void writeValue(Value const& value);
|
||||
void writeArrayValue(Value const& value);
|
||||
bool isMultineArray(Value const& value);
|
||||
void pushValue(JSONCPP_STRING const& value);
|
||||
void pushValue(std::string const& value);
|
||||
void writeIndent();
|
||||
void writeWithIndent(JSONCPP_STRING const& value);
|
||||
void writeWithIndent(std::string const& value);
|
||||
void indent();
|
||||
void unindent();
|
||||
void writeCommentBeforeValue(Value const& root);
|
||||
void writeCommentAfterValueOnSameLine(Value const& root);
|
||||
static bool hasCommentForValue(const Value& value);
|
||||
|
||||
typedef std::vector<JSONCPP_STRING> ChildValues;
|
||||
typedef std::vector<std::string> ChildValues;
|
||||
|
||||
ChildValues childValues_;
|
||||
JSONCPP_STRING indentString_;
|
||||
unsigned int rightMargin_;
|
||||
JSONCPP_STRING indentation_;
|
||||
std::string indentString_;
|
||||
int rightMargin_;
|
||||
std::string indentation_;
|
||||
CommentStyle::Enum cs_;
|
||||
JSONCPP_STRING colonSymbol_;
|
||||
JSONCPP_STRING nullSymbol_;
|
||||
JSONCPP_STRING endingLineFeedSymbol_;
|
||||
std::string colonSymbol_;
|
||||
std::string nullSymbol_;
|
||||
std::string endingLineFeedSymbol_;
|
||||
bool addChildValues_ : 1;
|
||||
bool indented_ : 1;
|
||||
bool useSpecialFloats_ : 1;
|
||||
unsigned int precision_;
|
||||
};
|
||||
BuiltStyledStreamWriter::BuiltStyledStreamWriter(
|
||||
JSONCPP_STRING const& indentation,
|
||||
std::string const& indentation,
|
||||
CommentStyle::Enum cs,
|
||||
JSONCPP_STRING const& colonSymbol,
|
||||
JSONCPP_STRING const& nullSymbol,
|
||||
JSONCPP_STRING const& endingLineFeedSymbol,
|
||||
bool useSpecialFloats,
|
||||
unsigned int precision)
|
||||
std::string const& colonSymbol,
|
||||
std::string const& nullSymbol,
|
||||
std::string const& endingLineFeedSymbol)
|
||||
: rightMargin_(74)
|
||||
, indentation_(indentation)
|
||||
, cs_(cs)
|
||||
@@ -886,11 +827,9 @@ BuiltStyledStreamWriter::BuiltStyledStreamWriter(
|
||||
, endingLineFeedSymbol_(endingLineFeedSymbol)
|
||||
, addChildValues_(false)
|
||||
, indented_(false)
|
||||
, useSpecialFloats_(useSpecialFloats)
|
||||
, precision_(precision)
|
||||
{
|
||||
}
|
||||
int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout)
|
||||
int BuiltStyledStreamWriter::write(Value const& root, std::ostream* sout)
|
||||
{
|
||||
sout_ = sout;
|
||||
addChildValues_ = false;
|
||||
@@ -917,7 +856,7 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
|
||||
pushValue(valueToString(value.asLargestUInt()));
|
||||
break;
|
||||
case realValue:
|
||||
pushValue(valueToString(value.asDouble(), useSpecialFloats_, precision_));
|
||||
pushValue(valueToString(value.asDouble()));
|
||||
break;
|
||||
case stringValue:
|
||||
{
|
||||
@@ -944,10 +883,10 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
|
||||
indent();
|
||||
Value::Members::iterator it = members.begin();
|
||||
for (;;) {
|
||||
JSONCPP_STRING const& name = *it;
|
||||
std::string const& name = *it;
|
||||
Value const& childValue = value[name];
|
||||
writeCommentBeforeValue(childValue);
|
||||
writeWithIndent(valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length())));
|
||||
writeWithIndent(valueToQuotedStringN(name.data(), name.length()));
|
||||
*sout_ << colonSymbol_;
|
||||
writeValue(childValue);
|
||||
if (++it == members.end()) {
|
||||
@@ -1012,25 +951,26 @@ void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
|
||||
}
|
||||
|
||||
bool BuiltStyledStreamWriter::isMultineArray(Value const& value) {
|
||||
ArrayIndex const size = value.size();
|
||||
int size = value.size();
|
||||
bool isMultiLine = size * 3 >= rightMargin_;
|
||||
childValues_.clear();
|
||||
for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
|
||||
for (int index = 0; index < size && !isMultiLine; ++index) {
|
||||
Value const& childValue = value[index];
|
||||
isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
|
||||
isMultiLine =
|
||||
isMultiLine || ((childValue.isArray() || childValue.isObject()) &&
|
||||
childValue.size() > 0);
|
||||
}
|
||||
if (!isMultiLine) // check if line length > max line length
|
||||
{
|
||||
childValues_.reserve(size);
|
||||
addChildValues_ = true;
|
||||
ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||
for (ArrayIndex index = 0; index < size; ++index) {
|
||||
int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||
for (int index = 0; index < size; ++index) {
|
||||
if (hasCommentForValue(value[index])) {
|
||||
isMultiLine = true;
|
||||
}
|
||||
writeValue(value[index]);
|
||||
lineLength += static_cast<ArrayIndex>(childValues_[index].length());
|
||||
lineLength += int(childValues_[index].length());
|
||||
}
|
||||
addChildValues_ = false;
|
||||
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
||||
@@ -1038,7 +978,7 @@ bool BuiltStyledStreamWriter::isMultineArray(Value const& value) {
|
||||
return isMultiLine;
|
||||
}
|
||||
|
||||
void BuiltStyledStreamWriter::pushValue(JSONCPP_STRING const& value) {
|
||||
void BuiltStyledStreamWriter::pushValue(std::string const& value) {
|
||||
if (addChildValues_)
|
||||
childValues_.push_back(value);
|
||||
else
|
||||
@@ -1057,7 +997,7 @@ void BuiltStyledStreamWriter::writeIndent() {
|
||||
}
|
||||
}
|
||||
|
||||
void BuiltStyledStreamWriter::writeWithIndent(JSONCPP_STRING const& value) {
|
||||
void BuiltStyledStreamWriter::writeWithIndent(std::string const& value) {
|
||||
if (!indented_) writeIndent();
|
||||
*sout_ << value;
|
||||
indented_ = false;
|
||||
@@ -1076,8 +1016,8 @@ void BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root) {
|
||||
return;
|
||||
|
||||
if (!indented_) writeIndent();
|
||||
const JSONCPP_STRING& comment = root.getComment(commentBefore);
|
||||
JSONCPP_STRING::const_iterator iter = comment.begin();
|
||||
const std::string& comment = root.getComment(commentBefore);
|
||||
std::string::const_iterator iter = comment.begin();
|
||||
while (iter != comment.end()) {
|
||||
*sout_ << *iter;
|
||||
if (*iter == '\n' &&
|
||||
@@ -1127,12 +1067,10 @@ StreamWriterBuilder::~StreamWriterBuilder()
|
||||
{}
|
||||
StreamWriter* StreamWriterBuilder::newStreamWriter() const
|
||||
{
|
||||
JSONCPP_STRING indentation = settings_["indentation"].asString();
|
||||
JSONCPP_STRING cs_str = settings_["commentStyle"].asString();
|
||||
std::string indentation = settings_["indentation"].asString();
|
||||
std::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;
|
||||
@@ -1141,50 +1079,47 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
|
||||
} else {
|
||||
throwRuntimeError("commentStyle must be 'All' or 'None'");
|
||||
}
|
||||
JSONCPP_STRING colonSymbol = " : ";
|
||||
std::string colonSymbol = " : ";
|
||||
if (eyc) {
|
||||
colonSymbol = ": ";
|
||||
} else if (indentation.empty()) {
|
||||
colonSymbol = ":";
|
||||
}
|
||||
JSONCPP_STRING nullSymbol = "null";
|
||||
std::string nullSymbol = "null";
|
||||
if (dnp) {
|
||||
nullSymbol = "";
|
||||
}
|
||||
if (pre > 17) pre = 17;
|
||||
JSONCPP_STRING endingLineFeedSymbol = "";
|
||||
std::string endingLineFeedSymbol = "";
|
||||
return new BuiltStyledStreamWriter(
|
||||
indentation, cs,
|
||||
colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);
|
||||
colonSymbol, nullSymbol, endingLineFeedSymbol);
|
||||
}
|
||||
static void getValidWriterKeys(std::set<JSONCPP_STRING>* valid_keys)
|
||||
static void getValidWriterKeys(std::set<std::string>* valid_keys)
|
||||
{
|
||||
valid_keys->clear();
|
||||
valid_keys->insert("indentation");
|
||||
valid_keys->insert("commentStyle");
|
||||
valid_keys->insert("enableYAMLCompatibility");
|
||||
valid_keys->insert("dropNullPlaceholders");
|
||||
valid_keys->insert("useSpecialFloats");
|
||||
valid_keys->insert("precision");
|
||||
}
|
||||
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
|
||||
Json::Value& inv = *invalid;
|
||||
std::set<JSONCPP_STRING> valid_keys;
|
||||
std::set<std::string> valid_keys;
|
||||
getValidWriterKeys(&valid_keys);
|
||||
Value::Members keys = settings_.getMemberNames();
|
||||
size_t n = keys.size();
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
JSONCPP_STRING const& key = keys[i];
|
||||
std::string const& key = keys[i];
|
||||
if (valid_keys.find(key) == valid_keys.end()) {
|
||||
inv[key] = settings_[key];
|
||||
}
|
||||
}
|
||||
return 0u == inv.size();
|
||||
}
|
||||
Value& StreamWriterBuilder::operator[](JSONCPP_STRING key)
|
||||
Value& StreamWriterBuilder::operator[](std::string key)
|
||||
{
|
||||
return settings_[key];
|
||||
}
|
||||
@@ -1196,19 +1131,17 @@ void StreamWriterBuilder::setDefaults(Json::Value* settings)
|
||||
(*settings)["indentation"] = "\t";
|
||||
(*settings)["enableYAMLCompatibility"] = false;
|
||||
(*settings)["dropNullPlaceholders"] = false;
|
||||
(*settings)["useSpecialFloats"] = false;
|
||||
(*settings)["precision"] = 17;
|
||||
//! [StreamWriterBuilderDefaults]
|
||||
}
|
||||
|
||||
JSONCPP_STRING writeString(StreamWriter::Factory const& builder, Value const& root) {
|
||||
JSONCPP_OSTRINGSTREAM sout;
|
||||
std::string writeString(StreamWriter::Factory const& builder, Value const& root) {
|
||||
std::ostringstream sout;
|
||||
StreamWriterPtr const writer(builder.newStreamWriter());
|
||||
writer->write(root, &sout);
|
||||
return sout.str();
|
||||
}
|
||||
|
||||
JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM& sout, Value const& root) {
|
||||
std::ostream& operator<<(std::ostream& sout, Value const& root) {
|
||||
StreamWriterBuilder builder;
|
||||
StreamWriterPtr const writer(builder.newStreamWriter());
|
||||
writer->write(root, &sout);
|
||||
|
@@ -1,4 +1,5 @@
|
||||
// DO NOT EDIT. This file (and "version") is generated by CMake.
|
||||
// DO NOT EDIT. This file is generated by CMake from "version"
|
||||
// and "version.h.in" files.
|
||||
// Run CMake configure step to update it.
|
||||
#ifndef JSON_VERSION_H_INCLUDED
|
||||
# define JSON_VERSION_H_INCLUDED
|
||||
@@ -10,11 +11,4 @@
|
||||
# define JSONCPP_VERSION_QUALIFIER
|
||||
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
||||
|
||||
#ifdef JSONCPP_USING_SECURE_MEMORY
|
||||
#undef JSONCPP_USING_SECURE_MEMORY
|
||||
#endif
|
||||
#define JSONCPP_USING_SECURE_MEMORY @JSONCPP_USE_SECURE_MEMORY@
|
||||
// If non-zero, the library zeroes any memory that it has allocated before
|
||||
// it frees its memory.
|
||||
|
||||
#endif // JSON_VERSION_H_INCLUDED
|
||||
|
@@ -1,5 +1,9 @@
|
||||
# vim: et ts=4 sts=4 sw=4 tw=0
|
||||
|
||||
IF(JSONCPP_LIB_BUILD_SHARED)
|
||||
ADD_DEFINITIONS( -DJSON_DLL )
|
||||
ENDIF(JSONCPP_LIB_BUILD_SHARED)
|
||||
|
||||
ADD_EXECUTABLE( jsoncpp_test
|
||||
jsontest.cpp
|
||||
jsontest.h
|
||||
@@ -7,12 +11,11 @@ ADD_EXECUTABLE( jsoncpp_test
|
||||
)
|
||||
|
||||
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
ADD_DEFINITIONS( -DJSON_DLL )
|
||||
IF(JSONCPP_LIB_BUILD_SHARED)
|
||||
TARGET_LINK_LIBRARIES(jsoncpp_test jsoncpp_lib)
|
||||
ELSE(BUILD_SHARED_LIBS)
|
||||
ELSE(JSONCPP_LIB_BUILD_SHARED)
|
||||
TARGET_LINK_LIBRARIES(jsoncpp_test jsoncpp_lib_static)
|
||||
ENDIF()
|
||||
ENDIF(JSONCPP_LIB_BUILD_SHARED)
|
||||
|
||||
# another way to solve issue #90
|
||||
#set_target_properties(jsoncpp_test PROPERTIES COMPILE_FLAGS -ffloat-store)
|
||||
@@ -20,19 +23,19 @@ ENDIF()
|
||||
# Run unit tests in post-build
|
||||
# (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?)
|
||||
IF(JSONCPP_WITH_POST_BUILD_UNITTEST)
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
IF(JSONCPP_LIB_BUILD_SHARED)
|
||||
# First, copy the shared lib, for Microsoft.
|
||||
# Then, run the test executable.
|
||||
ADD_CUSTOM_COMMAND( TARGET jsoncpp_test
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:jsoncpp_lib> $<TARGET_FILE_DIR:jsoncpp_test>
|
||||
COMMAND $<TARGET_FILE:jsoncpp_test>)
|
||||
ELSE(BUILD_SHARED_LIBS)
|
||||
ELSE(JSONCPP_LIB_BUILD_SHARED)
|
||||
# Just run the test executable.
|
||||
ADD_CUSTOM_COMMAND( TARGET jsoncpp_test
|
||||
POST_BUILD
|
||||
COMMAND $<TARGET_FILE:jsoncpp_test>)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF(JSONCPP_LIB_BUILD_SHARED)
|
||||
ENDIF(JSONCPP_WITH_POST_BUILD_UNITTEST)
|
||||
|
||||
SET_TARGET_PROPERTIES(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test)
|
||||
|
@@ -81,7 +81,7 @@ TestResult::TestResult()
|
||||
predicateStackTail_ = &rootPredicateNode_;
|
||||
}
|
||||
|
||||
void TestResult::setTestName(const JSONCPP_STRING& name) { name_ = name; }
|
||||
void TestResult::setTestName(const std::string& name) { name_ = name; }
|
||||
|
||||
TestResult&
|
||||
TestResult::addFailure(const char* file, unsigned int line, const char* expr) {
|
||||
@@ -163,7 +163,7 @@ void TestResult::printFailure(bool printTestName) const {
|
||||
Failures::const_iterator itEnd = failures_.end();
|
||||
for (Failures::const_iterator it = failures_.begin(); it != itEnd; ++it) {
|
||||
const Failure& failure = *it;
|
||||
JSONCPP_STRING indent(failure.nestingLevel_ * 2, ' ');
|
||||
std::string indent(failure.nestingLevel_ * 2, ' ');
|
||||
if (failure.file_) {
|
||||
printf("%s%s(%d): ", indent.c_str(), failure.file_, failure.line_);
|
||||
}
|
||||
@@ -173,19 +173,19 @@ void TestResult::printFailure(bool printTestName) const {
|
||||
printf("\n");
|
||||
}
|
||||
if (!failure.message_.empty()) {
|
||||
JSONCPP_STRING reindented = indentText(failure.message_, indent + " ");
|
||||
std::string reindented = indentText(failure.message_, indent + " ");
|
||||
printf("%s\n", reindented.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSONCPP_STRING TestResult::indentText(const JSONCPP_STRING& text,
|
||||
const JSONCPP_STRING& indent) {
|
||||
JSONCPP_STRING reindented;
|
||||
JSONCPP_STRING::size_type lastIndex = 0;
|
||||
std::string TestResult::indentText(const std::string& text,
|
||||
const std::string& indent) {
|
||||
std::string reindented;
|
||||
std::string::size_type lastIndex = 0;
|
||||
while (lastIndex < text.size()) {
|
||||
JSONCPP_STRING::size_type nextIndex = text.find('\n', lastIndex);
|
||||
if (nextIndex == JSONCPP_STRING::npos) {
|
||||
std::string::size_type nextIndex = text.find('\n', lastIndex);
|
||||
if (nextIndex == std::string::npos) {
|
||||
nextIndex = text.size() - 1;
|
||||
}
|
||||
reindented += indent;
|
||||
@@ -195,7 +195,7 @@ JSONCPP_STRING TestResult::indentText(const JSONCPP_STRING& text,
|
||||
return reindented;
|
||||
}
|
||||
|
||||
TestResult& TestResult::addToLastFailure(const JSONCPP_STRING& message) {
|
||||
TestResult& TestResult::addToLastFailure(const std::string& message) {
|
||||
if (messageTarget_ != 0) {
|
||||
messageTarget_->message_ += message;
|
||||
}
|
||||
@@ -240,9 +240,9 @@ unsigned int Runner::testCount() const {
|
||||
return static_cast<unsigned int>(tests_.size());
|
||||
}
|
||||
|
||||
JSONCPP_STRING Runner::testNameAt(unsigned int index) const {
|
||||
std::string Runner::testNameAt(unsigned int index) const {
|
||||
TestCase* test = tests_[index]();
|
||||
JSONCPP_STRING name = test->testName();
|
||||
std::string name = test->testName();
|
||||
delete test;
|
||||
return name;
|
||||
}
|
||||
@@ -303,7 +303,7 @@ bool Runner::runAllTest(bool printSummary) const {
|
||||
}
|
||||
}
|
||||
|
||||
bool Runner::testIndex(const JSONCPP_STRING& testName,
|
||||
bool Runner::testIndex(const std::string& testName,
|
||||
unsigned int& indexOut) const {
|
||||
unsigned int count = testCount();
|
||||
for (unsigned int index = 0; index < count; ++index) {
|
||||
@@ -323,10 +323,10 @@ void Runner::listTests() const {
|
||||
}
|
||||
|
||||
int Runner::runCommandLine(int argc, const char* argv[]) const {
|
||||
// typedef std::deque<JSONCPP_STRING> TestNames;
|
||||
// typedef std::deque<std::string> TestNames;
|
||||
Runner subrunner;
|
||||
for (int index = 1; index < argc; ++index) {
|
||||
JSONCPP_STRING opt = argv[index];
|
||||
std::string opt = argv[index];
|
||||
if (opt == "--list-tests") {
|
||||
listTests();
|
||||
return 0;
|
||||
@@ -426,23 +426,9 @@ void Runner::printUsage(const char* appName) {
|
||||
// Assertion functions
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
JSONCPP_STRING ToJsonString(const char* toConvert) {
|
||||
return JSONCPP_STRING(toConvert);
|
||||
}
|
||||
|
||||
JSONCPP_STRING ToJsonString(JSONCPP_STRING in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
JSONCPP_STRING ToJsonString(std::string in) {
|
||||
return JSONCPP_STRING(in.data(), in.data() + in.length());
|
||||
}
|
||||
#endif
|
||||
|
||||
TestResult& checkStringEqual(TestResult& result,
|
||||
const JSONCPP_STRING& expected,
|
||||
const JSONCPP_STRING& actual,
|
||||
const std::string& expected,
|
||||
const std::string& actual,
|
||||
const char* file,
|
||||
unsigned int line,
|
||||
const char* expr) {
|
||||
|
@@ -32,8 +32,8 @@ class Failure {
|
||||
public:
|
||||
const char* file_;
|
||||
unsigned int line_;
|
||||
JSONCPP_STRING expr_;
|
||||
JSONCPP_STRING message_;
|
||||
std::string expr_;
|
||||
std::string message_;
|
||||
unsigned int nestingLevel_;
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
/// \internal Implementation detail for predicate macros
|
||||
PredicateContext* predicateStackTail_;
|
||||
|
||||
void setTestName(const JSONCPP_STRING& name);
|
||||
void setTestName(const std::string& name);
|
||||
|
||||
/// Adds an assertion failure.
|
||||
TestResult&
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
|
||||
// Generic operator that will work with anything ostream can deal with.
|
||||
template <typename T> TestResult& operator<<(const T& value) {
|
||||
JSONCPP_OSTRINGSTREAM oss;
|
||||
std::ostringstream oss;
|
||||
oss.precision(16);
|
||||
oss.setf(std::ios_base::floatfield);
|
||||
oss << value;
|
||||
@@ -96,19 +96,19 @@ public:
|
||||
TestResult& operator<<(Json::UInt64 value);
|
||||
|
||||
private:
|
||||
TestResult& addToLastFailure(const JSONCPP_STRING& message);
|
||||
TestResult& addToLastFailure(const std::string& message);
|
||||
unsigned int getAssertionNestingLevel() const;
|
||||
/// Adds a failure or a predicate context
|
||||
void addFailureInfo(const char* file,
|
||||
unsigned int line,
|
||||
const char* expr,
|
||||
unsigned int nestingLevel);
|
||||
static JSONCPP_STRING indentText(const JSONCPP_STRING& text,
|
||||
const JSONCPP_STRING& indent);
|
||||
static std::string indentText(const std::string& text,
|
||||
const std::string& indent);
|
||||
|
||||
typedef std::deque<Failure> Failures;
|
||||
Failures failures_;
|
||||
JSONCPP_STRING name_;
|
||||
std::string name_;
|
||||
PredicateContext rootPredicateNode_;
|
||||
PredicateContext::Id lastUsedPredicateId_;
|
||||
/// Failure which is the target of the messages added using operator <<
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
unsigned int testCount() const;
|
||||
|
||||
/// Returns the name of the test case at the specified index
|
||||
JSONCPP_STRING testNameAt(unsigned int index) const;
|
||||
std::string testNameAt(unsigned int index) const;
|
||||
|
||||
/// Runs the test case at the specified index using the specified TestResult
|
||||
void runTestAt(unsigned int index, TestResult& result) const;
|
||||
@@ -168,7 +168,7 @@ private: // prevents copy construction and assignment
|
||||
|
||||
private:
|
||||
void listTests() const;
|
||||
bool testIndex(const JSONCPP_STRING& testName, unsigned int& index) const;
|
||||
bool testIndex(const std::string& testName, unsigned int& index) const;
|
||||
static void preventDialogOnCrash();
|
||||
|
||||
private:
|
||||
@@ -191,15 +191,9 @@ TestResult& checkEqual(TestResult& result,
|
||||
return result;
|
||||
}
|
||||
|
||||
JSONCPP_STRING ToJsonString(const char* toConvert);
|
||||
JSONCPP_STRING ToJsonString(JSONCPP_STRING in);
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
JSONCPP_STRING ToJsonString(std::string in);
|
||||
#endif
|
||||
|
||||
TestResult& checkStringEqual(TestResult& result,
|
||||
const JSONCPP_STRING& expected,
|
||||
const JSONCPP_STRING& actual,
|
||||
const std::string& expected,
|
||||
const std::string& actual,
|
||||
const char* file,
|
||||
unsigned int line,
|
||||
const char* expr);
|
||||
@@ -241,8 +235,8 @@ TestResult& checkStringEqual(TestResult& result,
|
||||
/// \brief Asserts that two values are equals.
|
||||
#define JSONTEST_ASSERT_STRING_EQUAL(expected, actual) \
|
||||
JsonTest::checkStringEqual(*result_, \
|
||||
JsonTest::ToJsonString(expected), \
|
||||
JsonTest::ToJsonString(actual), \
|
||||
std::string(expected), \
|
||||
std::string(actual), \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
#expected " == " #actual)
|
||||
@@ -271,8 +265,8 @@ TestResult& checkStringEqual(TestResult& result,
|
||||
} \
|
||||
\
|
||||
public: /* overidden from TestCase */ \
|
||||
const char* testName() const JSONCPP_OVERRIDE { return #FixtureType "/" #name; } \
|
||||
void runTestCase() JSONCPP_OVERRIDE; \
|
||||
virtual const char* testName() const { return #FixtureType "/" #name; } \
|
||||
virtual void runTestCase(); \
|
||||
}; \
|
||||
\
|
||||
void Test##FixtureType##name::runTestCase()
|
||||
|
@@ -7,10 +7,6 @@
|
||||
#include <json/config.h>
|
||||
#include <json/json.h>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
// Make numeric limits more convenient to talk about.
|
||||
// Assumes int type in 32 bits.
|
||||
@@ -39,7 +35,7 @@ static inline double uint64ToDouble(Json::UInt64 value) {
|
||||
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||
static inline double uint64ToDouble(Json::UInt64 value) {
|
||||
return static_cast<double>(Json::Int64(value / 2)) * 2.0 +
|
||||
static_cast<double>(Json::Int64(value & 1));
|
||||
Json::Int64(value & 1);
|
||||
}
|
||||
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||
|
||||
@@ -102,21 +98,21 @@ struct ValueTest : JsonTest::TestCase {
|
||||
|
||||
/// Normalize the representation of floating-point number by stripped leading
|
||||
/// 0 in exponent.
|
||||
static JSONCPP_STRING normalizeFloatingPointStr(const JSONCPP_STRING& s);
|
||||
static std::string normalizeFloatingPointStr(const std::string& s);
|
||||
};
|
||||
|
||||
JSONCPP_STRING ValueTest::normalizeFloatingPointStr(const JSONCPP_STRING& s) {
|
||||
JSONCPP_STRING::size_type index = s.find_last_of("eE");
|
||||
if (index != JSONCPP_STRING::npos) {
|
||||
JSONCPP_STRING::size_type hasSign =
|
||||
std::string ValueTest::normalizeFloatingPointStr(const std::string& s) {
|
||||
std::string::size_type index = s.find_last_of("eE");
|
||||
if (index != std::string::npos) {
|
||||
std::string::size_type hasSign =
|
||||
(s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0;
|
||||
JSONCPP_STRING::size_type exponentStartIndex = index + 1 + hasSign;
|
||||
JSONCPP_STRING normalized = s.substr(0, exponentStartIndex);
|
||||
JSONCPP_STRING::size_type indexDigit =
|
||||
std::string::size_type exponentStartIndex = index + 1 + hasSign;
|
||||
std::string normalized = s.substr(0, exponentStartIndex);
|
||||
std::string::size_type indexDigit =
|
||||
s.find_first_not_of('0', exponentStartIndex);
|
||||
JSONCPP_STRING exponent = "0";
|
||||
std::string exponent = "0";
|
||||
if (indexDigit !=
|
||||
JSONCPP_STRING::npos) // There is an exponent different from 0
|
||||
std::string::npos) // There is an exponent different from 0
|
||||
{
|
||||
exponent = s.substr(indexDigit);
|
||||
}
|
||||
@@ -261,20 +257,6 @@ JSONTEST_FIXTURE(ValueTest, arrays) {
|
||||
JSONTEST_ASSERT_EQUAL(Json::Value(17), got);
|
||||
JSONTEST_ASSERT_EQUAL(false, array1_.removeIndex(2, &got)); // gone now
|
||||
}
|
||||
JSONTEST_FIXTURE(ValueTest, arrayIssue252)
|
||||
{
|
||||
int count = 5;
|
||||
Json::Value root;
|
||||
Json::Value item;
|
||||
root["array"] = Json::Value::nullRef;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
item["a"] = i;
|
||||
item["b"] = i;
|
||||
root["array"][i] = item;
|
||||
}
|
||||
//JSONTEST_ASSERT_EQUAL(5, root["array"].size());
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, null) {
|
||||
JSONTEST_ASSERT_EQUAL(Json::nullValue, null_.type());
|
||||
@@ -647,7 +629,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
JSONTEST_ASSERT_EQUAL((1 << 20), val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1048576",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
|
||||
// -2^20
|
||||
val = Json::Value(-(1 << 20));
|
||||
@@ -888,7 +870,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
JSONTEST_ASSERT_EQUAL((Json::Int64(1) << 40), val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1099511627776",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
|
||||
// -2^40
|
||||
val = Json::Value(-(Json::Int64(1) << 40));
|
||||
@@ -963,7 +945,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("9.2233720368547758e+18",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
|
||||
// int64 min
|
||||
val = Json::Value(Json::Int64(kint64min));
|
||||
@@ -1011,7 +993,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
JSONTEST_ASSERT_EQUAL(-9223372036854775808.0, val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("-9.2233720368547758e+18",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
|
||||
// 10^19
|
||||
const Json::UInt64 ten_to_19 = static_cast<Json::UInt64>(1e19);
|
||||
@@ -1058,7 +1040,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
JSONTEST_ASSERT_EQUAL(1e19, val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1e+19",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
|
||||
// uint64 max
|
||||
val = Json::Value(Json::UInt64(kuint64max));
|
||||
@@ -1102,7 +1084,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
JSONTEST_ASSERT_EQUAL(18446744073709551616.0, val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1.8446744073709552e+19",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1192,7 +1174,7 @@ JSONTEST_FIXTURE(ValueTest, nonIntegers) {
|
||||
#endif
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_EQUAL("2147483647.5",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
|
||||
// A bit under int32 min
|
||||
val = Json::Value(kint32min - 0.5);
|
||||
@@ -1216,11 +1198,11 @@ JSONTEST_FIXTURE(ValueTest, nonIntegers) {
|
||||
JSONTEST_ASSERT_EQUAL(-2147483648.5, val.asDouble());
|
||||
JSONTEST_ASSERT_EQUAL(float(-2147483648.5), val.asFloat());
|
||||
#ifdef JSON_HAS_INT64
|
||||
JSONTEST_ASSERT_EQUAL(-(Json::Int64(1) << 31), val.asLargestInt());
|
||||
JSONTEST_ASSERT_EQUAL(-Json::Int64(1) << 31, val.asLargestInt());
|
||||
#endif
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_EQUAL("-2147483648.5",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
|
||||
// A bit over uint32 max
|
||||
val = Json::Value(kuint32max + 0.5);
|
||||
@@ -1250,29 +1232,29 @@ JSONTEST_FIXTURE(ValueTest, nonIntegers) {
|
||||
#endif
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_EQUAL("4294967295.5",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
|
||||
val = Json::Value(1.2345678901234);
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1.2345678901234001",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
|
||||
// A 16-digit floating point number.
|
||||
val = Json::Value(2199023255552000.0f);
|
||||
JSONTEST_ASSERT_EQUAL(float(2199023255552000.0f), val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(float(2199023255552000), val.asFloat());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("2199023255552000",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
|
||||
// A very large floating point number.
|
||||
val = Json::Value(3.402823466385289e38);
|
||||
JSONTEST_ASSERT_EQUAL(float(3.402823466385289e38), val.asFloat());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("3.402823466385289e+38",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
|
||||
// An even larger floating point number.
|
||||
val = Json::Value(1.2345678e300);
|
||||
JSONTEST_ASSERT_EQUAL(double(1.2345678e300), val.asDouble());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1.2345678e+300",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
}
|
||||
|
||||
void ValueTest::checkConstMemberCount(const Json::Value& value,
|
||||
@@ -1516,29 +1498,10 @@ JSONTEST_FIXTURE(ValueTest, typeChecksThrowExceptions) {
|
||||
#endif
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, offsetAccessors) {
|
||||
Json::Value x;
|
||||
JSONTEST_ASSERT(x.getOffsetStart() == 0);
|
||||
JSONTEST_ASSERT(x.getOffsetLimit() == 0);
|
||||
x.setOffsetStart(10);
|
||||
x.setOffsetLimit(20);
|
||||
JSONTEST_ASSERT(x.getOffsetStart() == 10);
|
||||
JSONTEST_ASSERT(x.getOffsetLimit() == 20);
|
||||
Json::Value y(x);
|
||||
JSONTEST_ASSERT(y.getOffsetStart() == 10);
|
||||
JSONTEST_ASSERT(y.getOffsetLimit() == 20);
|
||||
Json::Value z;
|
||||
z.swap(y);
|
||||
JSONTEST_ASSERT(z.getOffsetStart() == 10);
|
||||
JSONTEST_ASSERT(z.getOffsetLimit() == 20);
|
||||
JSONTEST_ASSERT(y.getOffsetStart() == 0);
|
||||
JSONTEST_ASSERT(y.getOffsetLimit() == 0);
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, StaticString) {
|
||||
char mutant[] = "hello";
|
||||
Json::StaticString ss(mutant);
|
||||
JSONCPP_STRING regular(mutant);
|
||||
std::string regular(mutant);
|
||||
mutant[1] = 'a';
|
||||
JSONTEST_ASSERT_STRING_EQUAL("hallo", ss.c_str());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("hello", regular.c_str());
|
||||
@@ -1560,15 +1523,15 @@ JSONTEST_FIXTURE(ValueTest, StaticString) {
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, CommentBefore) {
|
||||
Json::Value val; // fill val
|
||||
val.setComment(JSONCPP_STRING("// this comment should appear before"), Json::commentBefore);
|
||||
val.setComment(std::string("// this comment should appear before"), Json::commentBefore);
|
||||
Json::StreamWriterBuilder wbuilder;
|
||||
wbuilder.settings_["commentStyle"] = "All";
|
||||
{
|
||||
char const expected[] = "// this comment should appear before\nnull";
|
||||
JSONCPP_STRING result = Json::writeString(wbuilder, val);
|
||||
std::string result = Json::writeString(wbuilder, val);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
JSONCPP_STRING res2 = val.toStyledString();
|
||||
JSONCPP_STRING exp2 = "\n";
|
||||
std::string res2 = val.toStyledString();
|
||||
std::string exp2 = "\n";
|
||||
exp2 += expected;
|
||||
exp2 += "\n";
|
||||
JSONTEST_ASSERT_STRING_EQUAL(exp2, res2);
|
||||
@@ -1577,10 +1540,10 @@ JSONTEST_FIXTURE(ValueTest, CommentBefore) {
|
||||
val.swapPayload(other);
|
||||
{
|
||||
char const expected[] = "// this comment should appear before\n\"hello\"";
|
||||
JSONCPP_STRING result = Json::writeString(wbuilder, val);
|
||||
std::string result = Json::writeString(wbuilder, val);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
JSONCPP_STRING res2 = val.toStyledString();
|
||||
JSONCPP_STRING exp2 = "\n";
|
||||
std::string res2 = val.toStyledString();
|
||||
std::string exp2 = "\n";
|
||||
exp2 += expected;
|
||||
exp2 += "\n";
|
||||
JSONTEST_ASSERT_STRING_EQUAL(exp2, res2);
|
||||
@@ -1591,10 +1554,10 @@ JSONTEST_FIXTURE(ValueTest, CommentBefore) {
|
||||
// Assignment over-writes comments.
|
||||
{
|
||||
char const expected[] = "\"hello\"";
|
||||
JSONCPP_STRING result = Json::writeString(wbuilder, val);
|
||||
std::string result = Json::writeString(wbuilder, val);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
JSONCPP_STRING res2 = val.toStyledString();
|
||||
JSONCPP_STRING exp2 = "";
|
||||
std::string res2 = val.toStyledString();
|
||||
std::string exp2 = "";
|
||||
exp2 += expected;
|
||||
exp2 += "\n";
|
||||
JSONTEST_ASSERT_STRING_EQUAL(exp2, res2);
|
||||
@@ -1603,7 +1566,7 @@ JSONTEST_FIXTURE(ValueTest, CommentBefore) {
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, zeroes) {
|
||||
char const cstr[] = "h\0i";
|
||||
JSONCPP_STRING binary(cstr, sizeof(cstr)); // include trailing 0
|
||||
std::string binary(cstr, sizeof(cstr)); // include trailing 0
|
||||
JSONTEST_ASSERT_EQUAL(4U, binary.length());
|
||||
Json::StreamWriterBuilder b;
|
||||
{
|
||||
@@ -1631,7 +1594,7 @@ JSONTEST_FIXTURE(ValueTest, zeroes) {
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, zeroesInKeys) {
|
||||
char const cstr[] = "h\0i";
|
||||
JSONCPP_STRING binary(cstr, sizeof(cstr)); // include trailing 0
|
||||
std::string binary(cstr, sizeof(cstr)); // include trailing 0
|
||||
JSONTEST_ASSERT_EQUAL(4U, binary.length());
|
||||
{
|
||||
Json::Value root;
|
||||
@@ -1655,74 +1618,6 @@ JSONTEST_FIXTURE(ValueTest, zeroesInKeys) {
|
||||
}
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, specialFloats) {
|
||||
Json::StreamWriterBuilder b;
|
||||
b.settings_["useSpecialFloats"] = true;
|
||||
|
||||
Json::Value v = std::numeric_limits<double>::quiet_NaN();
|
||||
JSONCPP_STRING expected = "NaN";
|
||||
JSONCPP_STRING result = Json::writeString(b, v);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
|
||||
v = std::numeric_limits<double>::infinity();
|
||||
expected = "Infinity";
|
||||
result = Json::writeString(b, v);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
|
||||
v = -std::numeric_limits<double>::infinity();
|
||||
expected = "-Infinity";
|
||||
result = Json::writeString(b, v);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, precision) {
|
||||
Json::StreamWriterBuilder b;
|
||||
b.settings_["precision"] = 5;
|
||||
|
||||
Json::Value v = 100.0/3;
|
||||
JSONCPP_STRING expected = "33.333";
|
||||
JSONCPP_STRING result = Json::writeString(b, v);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
|
||||
v = 0.25000000;
|
||||
expected = "0.25";
|
||||
result = Json::writeString(b, v);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
|
||||
v = 0.2563456;
|
||||
expected = "0.25635";
|
||||
result = Json::writeString(b, v);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
|
||||
b.settings_["precision"] = 1;
|
||||
expected = "0.3";
|
||||
result = Json::writeString(b, v);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
|
||||
b.settings_["precision"] = 17;
|
||||
v = 1234857476305.256345694873740545068;
|
||||
expected = "1234857476305.2563";
|
||||
result = Json::writeString(b, v);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
|
||||
b.settings_["precision"] = 24;
|
||||
v = 0.256345694873740545068;
|
||||
expected = "0.25634569487374054";
|
||||
result = Json::writeString(b, v);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
}
|
||||
|
||||
struct WriterTest : JsonTest::TestCase {};
|
||||
|
||||
JSONTEST_FIXTURE(WriterTest, dropNullPlaceholders) {
|
||||
Json::FastWriter writer;
|
||||
Json::Value nullValue;
|
||||
JSONTEST_ASSERT(writer.write(nullValue) == "null\n");
|
||||
|
||||
writer.dropNullPlaceholders();
|
||||
JSONTEST_ASSERT(writer.write(nullValue) == "\n");
|
||||
}
|
||||
|
||||
struct StreamWriterTest : JsonTest::TestCase {};
|
||||
|
||||
JSONTEST_FIXTURE(StreamWriterTest, dropNullPlaceholders) {
|
||||
@@ -1735,15 +1630,15 @@ JSONTEST_FIXTURE(StreamWriterTest, dropNullPlaceholders) {
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(StreamWriterTest, writeZeroes) {
|
||||
JSONCPP_STRING binary("hi", 3); // include trailing 0
|
||||
std::string binary("hi", 3); // include trailing 0
|
||||
JSONTEST_ASSERT_EQUAL(3, binary.length());
|
||||
JSONCPP_STRING expected("\"hi\\u0000\""); // unicoded zero
|
||||
std::string expected("\"hi\\u0000\""); // unicoded zero
|
||||
Json::StreamWriterBuilder b;
|
||||
{
|
||||
Json::Value root;
|
||||
root = binary;
|
||||
JSONTEST_ASSERT_STRING_EQUAL(binary, root.asString());
|
||||
JSONCPP_STRING out = Json::writeString(b, root);
|
||||
std::string out = Json::writeString(b, root);
|
||||
JSONTEST_ASSERT_EQUAL(expected.size(), out.size());
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, out);
|
||||
}
|
||||
@@ -1751,7 +1646,7 @@ JSONTEST_FIXTURE(StreamWriterTest, writeZeroes) {
|
||||
Json::Value root;
|
||||
root["top"] = binary;
|
||||
JSONTEST_ASSERT_STRING_EQUAL(binary, root["top"].asString());
|
||||
JSONCPP_STRING out = Json::writeString(b, root["top"]);
|
||||
std::string out = Json::writeString(b, root["top"]);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, out);
|
||||
}
|
||||
}
|
||||
@@ -1764,7 +1659,6 @@ JSONTEST_FIXTURE(ReaderTest, parseWithNoErrors) {
|
||||
bool ok = reader.parse("{ \"property\" : \"value\" }", root);
|
||||
JSONTEST_ASSERT(ok);
|
||||
JSONTEST_ASSERT(reader.getFormattedErrorMessages().size() == 0);
|
||||
JSONTEST_ASSERT(reader.getStructuredErrors().size() == 0);
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ReaderTest, parseWithNoErrorsTestingOffsets) {
|
||||
@@ -1776,25 +1670,6 @@ JSONTEST_FIXTURE(ReaderTest, parseWithNoErrorsTestingOffsets) {
|
||||
root);
|
||||
JSONTEST_ASSERT(ok);
|
||||
JSONTEST_ASSERT(reader.getFormattedErrorMessages().size() == 0);
|
||||
JSONTEST_ASSERT(reader.getStructuredErrors().size() == 0);
|
||||
JSONTEST_ASSERT(root["property"].getOffsetStart() == 15);
|
||||
JSONTEST_ASSERT(root["property"].getOffsetLimit() == 34);
|
||||
JSONTEST_ASSERT(root["property"][0].getOffsetStart() == 16);
|
||||
JSONTEST_ASSERT(root["property"][0].getOffsetLimit() == 23);
|
||||
JSONTEST_ASSERT(root["property"][1].getOffsetStart() == 25);
|
||||
JSONTEST_ASSERT(root["property"][1].getOffsetLimit() == 33);
|
||||
JSONTEST_ASSERT(root["obj"].getOffsetStart() == 44);
|
||||
JSONTEST_ASSERT(root["obj"].getOffsetLimit() == 76);
|
||||
JSONTEST_ASSERT(root["obj"]["nested"].getOffsetStart() == 57);
|
||||
JSONTEST_ASSERT(root["obj"]["nested"].getOffsetLimit() == 60);
|
||||
JSONTEST_ASSERT(root["obj"]["bool"].getOffsetStart() == 71);
|
||||
JSONTEST_ASSERT(root["obj"]["bool"].getOffsetLimit() == 75);
|
||||
JSONTEST_ASSERT(root["null"].getOffsetStart() == 87);
|
||||
JSONTEST_ASSERT(root["null"].getOffsetLimit() == 91);
|
||||
JSONTEST_ASSERT(root["false"].getOffsetStart() == 103);
|
||||
JSONTEST_ASSERT(root["false"].getOffsetLimit() == 108);
|
||||
JSONTEST_ASSERT(root.getOffsetStart() == 0);
|
||||
JSONTEST_ASSERT(root.getOffsetLimit() == 110);
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ReaderTest, parseWithOneError) {
|
||||
@@ -1805,13 +1680,6 @@ JSONTEST_FIXTURE(ReaderTest, parseWithOneError) {
|
||||
JSONTEST_ASSERT(reader.getFormattedErrorMessages() ==
|
||||
"* Line 1, Column 15\n Syntax error: value, object or array "
|
||||
"expected.\n");
|
||||
std::vector<Json::Reader::StructuredError> errors =
|
||||
reader.getStructuredErrors();
|
||||
JSONTEST_ASSERT(errors.size() == 1);
|
||||
JSONTEST_ASSERT(errors.at(0).offset_start == 14);
|
||||
JSONTEST_ASSERT(errors.at(0).offset_limit == 15);
|
||||
JSONTEST_ASSERT(errors.at(0).message ==
|
||||
"Syntax error: value, object or array expected.");
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ReaderTest, parseChineseWithOneError) {
|
||||
@@ -1822,13 +1690,6 @@ JSONTEST_FIXTURE(ReaderTest, parseChineseWithOneError) {
|
||||
JSONTEST_ASSERT(reader.getFormattedErrorMessages() ==
|
||||
"* Line 1, Column 19\n Syntax error: value, object or array "
|
||||
"expected.\n");
|
||||
std::vector<Json::Reader::StructuredError> errors =
|
||||
reader.getStructuredErrors();
|
||||
JSONTEST_ASSERT(errors.size() == 1);
|
||||
JSONTEST_ASSERT(errors.at(0).offset_start == 18);
|
||||
JSONTEST_ASSERT(errors.at(0).offset_limit == 19);
|
||||
JSONTEST_ASSERT(errors.at(0).message ==
|
||||
"Syntax error: value, object or array expected.");
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ReaderTest, parseWithDetailError) {
|
||||
@@ -1839,12 +1700,6 @@ JSONTEST_FIXTURE(ReaderTest, parseWithDetailError) {
|
||||
JSONTEST_ASSERT(reader.getFormattedErrorMessages() ==
|
||||
"* Line 1, Column 16\n Bad escape sequence in string\nSee "
|
||||
"Line 1, Column 20 for detail.\n");
|
||||
std::vector<Json::Reader::StructuredError> errors =
|
||||
reader.getStructuredErrors();
|
||||
JSONTEST_ASSERT(errors.size() == 1);
|
||||
JSONTEST_ASSERT(errors.at(0).offset_start == 15);
|
||||
JSONTEST_ASSERT(errors.at(0).offset_limit == 23);
|
||||
JSONTEST_ASSERT(errors.at(0).message == "Bad escape sequence in string");
|
||||
}
|
||||
|
||||
struct CharReaderTest : JsonTest::TestCase {};
|
||||
@@ -1852,7 +1707,7 @@ struct CharReaderTest : JsonTest::TestCase {};
|
||||
JSONTEST_FIXTURE(CharReaderTest, parseWithNoErrors) {
|
||||
Json::CharReaderBuilder b;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
Json::Value root;
|
||||
char const doc[] = "{ \"property\" : \"value\" }";
|
||||
bool ok = reader->parse(
|
||||
@@ -1866,7 +1721,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithNoErrors) {
|
||||
JSONTEST_FIXTURE(CharReaderTest, parseWithNoErrorsTestingOffsets) {
|
||||
Json::CharReaderBuilder b;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
Json::Value root;
|
||||
char const doc[] =
|
||||
"{ \"property\" : [\"value\", \"value2\"], \"obj\" : "
|
||||
@@ -1883,7 +1738,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithNoErrorsTestingOffsets) {
|
||||
JSONTEST_FIXTURE(CharReaderTest, parseWithOneError) {
|
||||
Json::CharReaderBuilder b;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
Json::Value root;
|
||||
char const doc[] =
|
||||
"{ \"property\" :: \"value\" }";
|
||||
@@ -1900,7 +1755,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithOneError) {
|
||||
JSONTEST_FIXTURE(CharReaderTest, parseChineseWithOneError) {
|
||||
Json::CharReaderBuilder b;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
Json::Value root;
|
||||
char const doc[] =
|
||||
"{ \"pr佐藤erty\" :: \"value\" }";
|
||||
@@ -1917,7 +1772,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseChineseWithOneError) {
|
||||
JSONTEST_FIXTURE(CharReaderTest, parseWithDetailError) {
|
||||
Json::CharReaderBuilder b;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
Json::Value root;
|
||||
char const doc[] =
|
||||
"{ \"property\" : \"v\\alue\" }";
|
||||
@@ -1939,7 +1794,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithStackLimit) {
|
||||
{
|
||||
b.settings_["stackLimit"] = 2;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -1951,7 +1806,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithStackLimit) {
|
||||
{
|
||||
b.settings_["stackLimit"] = 1;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
JSONTEST_ASSERT_THROWS(reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs));
|
||||
@@ -1969,7 +1824,7 @@ JSONTEST_FIXTURE(CharReaderStrictModeTest, dupKeys) {
|
||||
{
|
||||
b.strictMode(&b.settings_);
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -1985,7 +1840,7 @@ JSONTEST_FIXTURE(CharReaderStrictModeTest, dupKeys) {
|
||||
struct CharReaderFailIfExtraTest : JsonTest::TestCase {};
|
||||
|
||||
JSONTEST_FIXTURE(CharReaderFailIfExtraTest, issue164) {
|
||||
// This is interpreted as a string value followed by a colon.
|
||||
// This is interpretted as a string value followed by a colon.
|
||||
Json::CharReaderBuilder b;
|
||||
Json::Value root;
|
||||
char const doc[] =
|
||||
@@ -1993,7 +1848,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, issue164) {
|
||||
{
|
||||
b.settings_["failIfExtra"] = false;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -2005,7 +1860,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, issue164) {
|
||||
{
|
||||
b.settings_["failIfExtra"] = true;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -2020,7 +1875,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, issue164) {
|
||||
b.settings_["failIfExtra"] = false;
|
||||
b.strictMode(&b.settings_);
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -2040,7 +1895,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, issue107) {
|
||||
"1:2:3";
|
||||
b.settings_["failIfExtra"] = true;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -2060,7 +1915,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, commentAfterObject) {
|
||||
"{ \"property\" : \"value\" } //trailing\n//comment\n";
|
||||
b.settings_["failIfExtra"] = true;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -2077,7 +1932,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, commentAfterArray) {
|
||||
"[ \"property\" , \"value\" ] //trailing\n//comment\n";
|
||||
b.settings_["failIfExtra"] = true;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -2093,7 +1948,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, commentAfterBool) {
|
||||
" true /*trailing\ncomment*/";
|
||||
b.settings_["failIfExtra"] = true;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -2108,7 +1963,7 @@ JSONTEST_FIXTURE(CharReaderAllowDropNullTest, issue178) {
|
||||
Json::CharReaderBuilder b;
|
||||
b.settings_["allowDroppedNullPlaceholders"] = true;
|
||||
Json::Value root;
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
{
|
||||
char const doc[] = "{\"a\":,\"b\":true}";
|
||||
@@ -2260,7 +2115,7 @@ JSONTEST_FIXTURE(CharReaderAllowSingleQuotesTest, issue182) {
|
||||
Json::CharReaderBuilder b;
|
||||
b.settings_["allowSingleQuotes"] = true;
|
||||
Json::Value root;
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
{
|
||||
char const doc[] = "{'a':true,\"b\":true}";
|
||||
@@ -2284,7 +2139,6 @@ JSONTEST_FIXTURE(CharReaderAllowSingleQuotesTest, issue182) {
|
||||
JSONTEST_ASSERT_STRING_EQUAL("x", root["a"].asString());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("y", root["b"].asString());
|
||||
}
|
||||
delete reader;
|
||||
}
|
||||
|
||||
struct CharReaderAllowZeroesTest : JsonTest::TestCase {};
|
||||
@@ -2293,7 +2147,7 @@ JSONTEST_FIXTURE(CharReaderAllowZeroesTest, issue176) {
|
||||
Json::CharReaderBuilder b;
|
||||
b.settings_["allowSingleQuotes"] = true;
|
||||
Json::Value root;
|
||||
JSONCPP_STRING errs;
|
||||
std::string errs;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
{
|
||||
char const doc[] = "{'a':true,\"b\":true}";
|
||||
@@ -2317,82 +2171,6 @@ JSONTEST_FIXTURE(CharReaderAllowZeroesTest, issue176) {
|
||||
JSONTEST_ASSERT_STRING_EQUAL("x", root["a"].asString());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("y", root["b"].asString());
|
||||
}
|
||||
delete reader;
|
||||
}
|
||||
|
||||
struct CharReaderAllowSpecialFloatsTest : JsonTest::TestCase {};
|
||||
|
||||
JSONTEST_FIXTURE(CharReaderAllowSpecialFloatsTest, issue209) {
|
||||
Json::CharReaderBuilder b;
|
||||
b.settings_["allowSpecialFloats"] = true;
|
||||
Json::Value root;
|
||||
JSONCPP_STRING errs;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
{
|
||||
char const doc[] = "{\"a\":NaN,\"b\":Infinity,\"c\":-Infinity}";
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
JSONTEST_ASSERT(ok);
|
||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
||||
JSONTEST_ASSERT_EQUAL(3u, root.size());
|
||||
double n = root["a"].asDouble();
|
||||
JSONTEST_ASSERT(n != n);
|
||||
JSONTEST_ASSERT_EQUAL(std::numeric_limits<double>::infinity(), root.get("b", 0.0));
|
||||
JSONTEST_ASSERT_EQUAL(-std::numeric_limits<double>::infinity(), root.get("c", 0.0));
|
||||
}
|
||||
|
||||
struct TestData {
|
||||
int line;
|
||||
bool ok;
|
||||
JSONCPP_STRING in;
|
||||
};
|
||||
const TestData test_data[] = {
|
||||
{__LINE__, 1, "{\"a\":9}"},
|
||||
{__LINE__, 0, "{\"a\":0Infinity}"},
|
||||
{__LINE__, 0, "{\"a\":1Infinity}"},
|
||||
{__LINE__, 0, "{\"a\":9Infinity}"},
|
||||
{__LINE__, 0, "{\"a\":0nfinity}"},
|
||||
{__LINE__, 0, "{\"a\":1nfinity}"},
|
||||
{__LINE__, 0, "{\"a\":9nfinity}"},
|
||||
{__LINE__, 0, "{\"a\":nfinity}"},
|
||||
{__LINE__, 0, "{\"a\":.nfinity}"},
|
||||
{__LINE__, 0, "{\"a\":9nfinity}"},
|
||||
{__LINE__, 0, "{\"a\":-nfinity}"},
|
||||
{__LINE__, 1, "{\"a\":Infinity}"},
|
||||
{__LINE__, 0, "{\"a\":.Infinity}"},
|
||||
{__LINE__, 0, "{\"a\":_Infinity}"},
|
||||
{__LINE__, 0, "{\"a\":_nfinity}"},
|
||||
{__LINE__, 1, "{\"a\":-Infinity}"}
|
||||
};
|
||||
for (size_t tdi = 0; tdi < sizeof(test_data) / sizeof(*test_data); ++tdi) {
|
||||
const TestData& td = test_data[tdi];
|
||||
bool ok = reader->parse(&*td.in.begin(),
|
||||
&*td.in.begin() + td.in.size(),
|
||||
&root, &errs);
|
||||
JSONTEST_ASSERT(td.ok == ok)
|
||||
<< "line:" << td.line << "\n"
|
||||
<< " expected: {"
|
||||
<< "ok:" << td.ok
|
||||
<< ", in:\'" << td.in << "\'"
|
||||
<< "}\n"
|
||||
<< " actual: {"
|
||||
<< "ok:" << ok
|
||||
<< "}\n";
|
||||
}
|
||||
|
||||
{
|
||||
char const doc[] = "{\"posInf\": Infinity, \"NegInf\": -Infinity}";
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
JSONTEST_ASSERT(ok);
|
||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
||||
JSONTEST_ASSERT_EQUAL(2u, root.size());
|
||||
JSONTEST_ASSERT_EQUAL(std::numeric_limits<double>::infinity(), root["posInf"].asDouble());
|
||||
JSONTEST_ASSERT_EQUAL(-std::numeric_limits<double>::infinity(), root["NegInf"].asDouble());
|
||||
}
|
||||
delete reader;
|
||||
}
|
||||
|
||||
struct BuilderTest : JsonTest::TestCase {};
|
||||
@@ -2425,7 +2203,7 @@ JSONTEST_FIXTURE(IteratorTest, distance) {
|
||||
json["k1"] = "a";
|
||||
json["k2"] = "b";
|
||||
int dist = 0;
|
||||
JSONCPP_STRING str;
|
||||
std::string str;
|
||||
for (Json::ValueIterator it = json.begin(); it != json.end(); ++it) {
|
||||
dist = it - json.begin();
|
||||
str = it->asString().c_str();
|
||||
@@ -2470,53 +2248,12 @@ JSONTEST_FIXTURE(IteratorTest, indexes) {
|
||||
JSONTEST_ASSERT(it == json.end());
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(IteratorTest, const) {
|
||||
Json::Value const v;
|
||||
JSONTEST_ASSERT_THROWS(
|
||||
Json::Value::iterator it(v.begin()) // Compile, but throw.
|
||||
);
|
||||
|
||||
Json::Value value;
|
||||
|
||||
for(int i = 9; i < 12; ++i)
|
||||
{
|
||||
JSONCPP_OSTRINGSTREAM out;
|
||||
out << std::setw(2) << i;
|
||||
JSONCPP_STRING str = out.str();
|
||||
value[str] = str;
|
||||
}
|
||||
|
||||
JSONCPP_OSTRINGSTREAM out;
|
||||
//in old code, this will get a compile error
|
||||
Json::Value::const_iterator iter = value.begin();
|
||||
for(; iter != value.end(); ++iter)
|
||||
{
|
||||
out << *iter << ',';
|
||||
}
|
||||
JSONCPP_STRING expected = "\" 9\",\"10\",\"11\",";
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, out.str());
|
||||
}
|
||||
|
||||
struct RValueTest : JsonTest::TestCase {};
|
||||
|
||||
JSONTEST_FIXTURE(RValueTest, moveConstruction) {
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
Json::Value json;
|
||||
json["key"] = "value";
|
||||
Json::Value moved = std::move(json);
|
||||
JSONTEST_ASSERT(moved != json); // Possibly not nullValue; definitely not equal.
|
||||
JSONTEST_ASSERT_EQUAL(Json::objectValue, moved.type());
|
||||
JSONTEST_ASSERT_EQUAL(Json::stringValue, moved["key"].type());
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
JsonTest::Runner runner;
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, checkNormalizeFloatingPointStr);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, memberCount);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, objects);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, arrays);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, arrayIssue252);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, null);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, strings);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, bools);
|
||||
@@ -2531,17 +2268,13 @@ int main(int argc, const char* argv[]) {
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, compareArray);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, compareObject);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, compareType);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, offsetAccessors);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, typeChecksThrowExceptions);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, StaticString);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, CommentBefore);
|
||||
//JSONTEST_REGISTER_FIXTURE(runner, ValueTest, nulls);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, zeroes);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, zeroesInKeys);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, specialFloats);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, precision);
|
||||
|
||||
JSONTEST_REGISTER_FIXTURE(runner, WriterTest, dropNullPlaceholders);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, dropNullPlaceholders);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, writeZeroes);
|
||||
|
||||
@@ -2574,16 +2307,11 @@ int main(int argc, const char* argv[]) {
|
||||
|
||||
JSONTEST_REGISTER_FIXTURE(runner, CharReaderAllowZeroesTest, issue176);
|
||||
|
||||
JSONTEST_REGISTER_FIXTURE(runner, CharReaderAllowSpecialFloatsTest, issue209);
|
||||
|
||||
JSONTEST_REGISTER_FIXTURE(runner, BuilderTest, settings);
|
||||
|
||||
JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, distance);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, names);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, indexes);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, const);
|
||||
|
||||
JSONTEST_REGISTER_FIXTURE(runner, RValueTest, moveConstruction);
|
||||
|
||||
return runner.runCommandLine(argc, argv);
|
||||
}
|
||||
|
@@ -1,10 +1,4 @@
|
||||
# Copyright 2007 Baptiste Lepilleur
|
||||
# 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
|
||||
|
||||
"""Removes all files created during testing."""
|
||||
|
||||
# removes all files created during testing
|
||||
import glob
|
||||
import os
|
||||
|
||||
|
@@ -1,8 +1,3 @@
|
||||
# Copyright 2007 Baptiste Lepilleur
|
||||
# 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
|
||||
|
||||
from __future__ import print_function
|
||||
import glob
|
||||
import os.path
|
||||
|
@@ -1,11 +1,4 @@
|
||||
# Copyright 2007 Baptiste Lepilleur
|
||||
# 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
|
||||
|
||||
"""Simple implementation of a json test runner to run the test against
|
||||
json-py."""
|
||||
|
||||
# Simple implementation of a json test runner to run the test against json-py.
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import os.path
|
||||
|
@@ -1,8 +1,3 @@
|
||||
# Copyright 2007 Baptiste Lepilleur
|
||||
# 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
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
from io import open
|
||||
|
@@ -1,8 +1,3 @@
|
||||
# Copyright 2009 Baptiste Lepilleur
|
||||
# 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
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
from io import open
|
||||
|
31
travis.sh
31
travis.sh
@@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
# This is called by `.travis.yml` via Travis CI.
|
||||
# Travis supplies $TRAVIS_OS_NAME.
|
||||
# http://docs.travis-ci.com/user/multi-os/
|
||||
# Our .travis.yml also defines:
|
||||
# - SHARED_LIB=ON/OFF
|
||||
# - STATIC_LIB=ON/OFF
|
||||
# - CMAKE_PKG=ON/OFF
|
||||
# - BUILD_TYPE=release/debug
|
||||
# - VERBOSE_MAKE=false/true
|
||||
# - VERBOSE (set or not)
|
||||
|
||||
# -e: fail on error
|
||||
# -v: show commands
|
||||
# -x: show expanded commands
|
||||
set -vex
|
||||
|
||||
env | sort
|
||||
|
||||
cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DBUILD_SHARED_LIBS=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE .
|
||||
make
|
||||
cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DBUILD_SHARED_LIBS=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE -DJSONCPP_USE_SECURE_MEMORY=1 .
|
||||
make
|
||||
|
||||
# Python is not available in Travis for osx.
|
||||
# https://github.com/travis-ci/travis-ci/issues/2320
|
||||
if [ "$TRAVIS_OS_NAME" != "osx" ]
|
||||
then
|
||||
make jsoncpp_check
|
||||
valgrind --error-exitcode=42 --leak-check=full ./src/test_lib_json/jsoncpp_test
|
||||
fi
|
Reference in New Issue
Block a user