mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-14 23:07:55 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b31d224fd6 | ||
![]() |
a901a04c28 | ||
![]() |
c9afea87e3 | ||
![]() |
edf9369493 | ||
![]() |
18ae85b44c | ||
![]() |
bd2aa77b94 | ||
![]() |
6a12fb8999 | ||
![]() |
a1ca466e04 | ||
![]() |
5a14ab5ea3 |
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
|
|
44
.gitignore
vendored
44
.gitignore
vendored
@@ -1,5 +1,4 @@
|
|||||||
/build/
|
/build/
|
||||||
/build-*/
|
|
||||||
*.pyc
|
*.pyc
|
||||||
*.swp
|
*.swp
|
||||||
*.actual
|
*.actual
|
||||||
@@ -7,49 +6,8 @@
|
|||||||
*.process-output
|
*.process-output
|
||||||
*.rewrite
|
*.rewrite
|
||||||
/bin/
|
/bin/
|
||||||
|
/buildscons/
|
||||||
/libs/
|
/libs/
|
||||||
/doc/doxyfile
|
/doc/doxyfile
|
||||||
/dist/
|
/dist/
|
||||||
#/version
|
|
||||||
#/include/json/version.h
|
#/include/json/version.h
|
||||||
|
|
||||||
# MSVC project files:
|
|
||||||
*.sln
|
|
||||||
*.vcxproj
|
|
||||||
*.filters
|
|
||||||
*.user
|
|
||||||
*.sdf
|
|
||||||
*.opensdf
|
|
||||||
*.suo
|
|
||||||
|
|
||||||
# MSVC build files:
|
|
||||||
*.lib
|
|
||||||
*.obj
|
|
||||||
*.tlog/
|
|
||||||
*.pdb
|
|
||||||
|
|
||||||
# CMake-generated files:
|
|
||||||
CMakeFiles/
|
|
||||||
*.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
|
|
||||||
*.a
|
|
||||||
|
|
||||||
# eclipse project files
|
|
||||||
.project
|
|
||||||
.cproject
|
|
||||||
/.settings/
|
|
||||||
|
|
||||||
# DS_Store
|
|
||||||
.DS_Store
|
|
||||||
|
50
.travis.yml
50
.travis.yml
@@ -2,54 +2,16 @@
|
|||||||
# http://about.travis-ci.org/docs/user/build-configuration/
|
# http://about.travis-ci.org/docs/user/build-configuration/
|
||||||
# This file can be validated on:
|
# This file can be validated on:
|
||||||
# http://lint.travis-ci.org/
|
# http://lint.travis-ci.org/
|
||||||
# See also
|
before_install: sudo apt-get install cmake
|
||||||
# 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:
|
|
||||||
- if [[ $TRAVIS_OS_NAME == osx ]]; then
|
|
||||||
brew update;
|
|
||||||
brew install python3 ninja;
|
|
||||||
python3 -m venv venv;
|
|
||||||
source venv/bin/activate;
|
|
||||||
elif [[ $TRAVIS_OS_NAME == linux ]]; then
|
|
||||||
wget https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-linux.zip;
|
|
||||||
unzip -q ninja-linux.zip -d build;
|
|
||||||
fi
|
|
||||||
- pip3 install meson
|
|
||||||
# /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 has a conflict with gcc, so use clang-X.Y.
|
|
||||||
- if [[ $CXX = clang++ ]]; then export CXX="clang++-3.5" CC="clang-3.5"; fi
|
|
||||||
- echo ${PATH}
|
|
||||||
- ls /usr/local
|
|
||||||
- ls /usr/local/bin
|
|
||||||
- export PATH="${PWD}"/build:/usr/local/bin:/usr/bin:${PATH}
|
|
||||||
- echo ${CXX}
|
|
||||||
- ${CXX} --version
|
|
||||||
- which valgrind
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
- llvm-toolchain-precise-3.5
|
|
||||||
packages:
|
|
||||||
- gcc-4.9
|
|
||||||
- g++-4.9
|
|
||||||
- clang-3.5
|
|
||||||
- valgrind
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
language: cpp
|
language: cpp
|
||||||
compiler:
|
compiler:
|
||||||
- gcc
|
- gcc
|
||||||
- clang
|
- 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
|
||||||
env:
|
env:
|
||||||
matrix:
|
matrix:
|
||||||
- LIB_TYPE=static BUILD_TYPE=release
|
- SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false
|
||||||
- LIB_TYPE=shared BUILD_TYPE=debug
|
- SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE_MAKE=true VERBOSE
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email:
|
||||||
dist: trusty
|
- aaronjjacobs@gmail.com
|
||||||
sudo: false
|
|
||||||
|
110
AUTHORS
110
AUTHORS
@@ -1,111 +1 @@
|
|||||||
Baptiste Lepilleur <blep@users.sourceforge.net>
|
Baptiste Lepilleur <blep@users.sourceforge.net>
|
||||||
|
|
||||||
Aaron Jacobs <aaronjjacobs@gmail.com>
|
|
||||||
Aaron Jacobs <jacobsa@google.com>
|
|
||||||
Adam Boseley <ABoseley@agjunction.com>
|
|
||||||
Adam Boseley <adam.boseley@gmail.com>
|
|
||||||
Aleksandr Derbenev <13alexac@gmail.com>
|
|
||||||
Alexander Gazarov <DrMetallius@users.noreply.github.com>
|
|
||||||
Alexander V. Brezgin <abrezgin@appliedtech.ru>
|
|
||||||
Alexandr Brezgin <albrezgin@mail.ru>
|
|
||||||
Alexey Kruchinin <alexey@mopals.com>
|
|
||||||
Anton Indrawan <anton.indrawan@gmail.com>
|
|
||||||
Baptiste Jonglez <git@bitsofnetworks.org>
|
|
||||||
Baptiste Lepilleur <baptiste.lepilleur@gmail.com>
|
|
||||||
Baruch Siach <baruch@tkos.co.il>
|
|
||||||
Ben Boeckel <mathstuf@gmail.com>
|
|
||||||
Benjamin Knecht <bknecht@logitech.com>
|
|
||||||
Bernd Kuhls <bernd.kuhls@t-online.de>
|
|
||||||
Billy Donahue <billydonahue@google.com>
|
|
||||||
Braden McDorman <bmcdorman@gmail.com>
|
|
||||||
Brandon Myers <bmyers1788@gmail.com>
|
|
||||||
Brendan Drew <brendan.drew@daqri.com>
|
|
||||||
chason <cxchao802@gmail.com>
|
|
||||||
Chris Gilling <cgilling@iparadigms.com>
|
|
||||||
Christopher Dawes <christopher.dawes.1981@googlemail.com>
|
|
||||||
Christopher Dunn <cdunn2001@gmail.com>
|
|
||||||
Chuck Atkins <chuck.atkins@kitware.com>
|
|
||||||
Cody P Schafer <dev@codyps.com>
|
|
||||||
Connor Manning <connor@hobu.co>
|
|
||||||
Cory Quammen <cory.quammen@kitware.com>
|
|
||||||
Cristóvão B da Cruz e Silva <CrisXed@gmail.com>
|
|
||||||
Daniel Krügler <daniel.kruegler@gmail.com>
|
|
||||||
Dani-Hub <daniel.kruegler@googlemail.com>
|
|
||||||
Dan Liu <gzliudan>
|
|
||||||
datadiode <datadiode@users.noreply.github.com>
|
|
||||||
datadiode <jochen.neubeck@vodafone.de>
|
|
||||||
David Seifert <soap@gentoo.org>
|
|
||||||
David West <david-west@idexx.com>
|
|
||||||
dawesc <chris.dawes@eftlab.co.uk>
|
|
||||||
Dmitry Marakasov <amdmi3@amdmi3.ru>
|
|
||||||
dominicpezzuto <dom@dompezzuto.com>
|
|
||||||
Don Milham <dmilham@gmail.com>
|
|
||||||
drgler <daniel.kruegler@gmail.com>
|
|
||||||
ds283 <D.Seery@sussex.ac.uk>
|
|
||||||
Egor Tensin <Egor.Tensin@gmail.com>
|
|
||||||
eightnoteight <mr.eightnoteight@gmail.com>
|
|
||||||
Evince <baneyue@gmail.com>
|
|
||||||
filipjs <filipjs@users.noreply.github.com>
|
|
||||||
findblar <ft@finbarr.ca>
|
|
||||||
Florian Meier <florian.meier@koalo.de>
|
|
||||||
Gaëtan Lehmann <gaetan.lehmann@gmail.com>
|
|
||||||
Gaurav <g.gupta@samsung.com>
|
|
||||||
Gergely Nagy <ngg@ngg.hu>
|
|
||||||
Gida Pataki <gida.pataki@prezi.com>
|
|
||||||
I3ck <buckmartin@buckmartin.de>
|
|
||||||
Iñaki Baz Castillo <ibc@aliax.net>
|
|
||||||
Jacco <jacco@geul.net>
|
|
||||||
Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
|
|
||||||
Jonas Platte <mail@jonasplatte.de>
|
|
||||||
Jörg Krause <joerg.krause@embedded.rocks>
|
|
||||||
Keith Lea <keith@whamcitylights.com>
|
|
||||||
Kevin Grant <kbradleygrant@gmail.com>
|
|
||||||
Kirill V. Lyadvinsky <jia3ep@gmail.com>
|
|
||||||
Kirill V. Lyadvinsky <mail@codeatcpp.com>
|
|
||||||
Kobi Gurkan <kobigurk@gmail.com>
|
|
||||||
Magnus Bjerke Vik <mbvett@gmail.com>
|
|
||||||
Malay Shah <malays@users.sourceforge.net>
|
|
||||||
Mara Kim <hacker.root@gmail.com>
|
|
||||||
Marek Kotewicz <marek.kotewicz@gmail.com>
|
|
||||||
Mark Lakata <mark@lakata.org>
|
|
||||||
Mark Zeren <mzeren@vmware.com>
|
|
||||||
Martin Buck <buckmartin@buckmartin.de>
|
|
||||||
Martyn Gigg <martyn.gigg@gmail.com>
|
|
||||||
Mattes D <github@xoft.cz>
|
|
||||||
Matthias Loy <matthias.loy@hbm.com>
|
|
||||||
Merlyn Morgan-Graham <kavika@gmail.com>
|
|
||||||
Michael Shields <mshields@google.com>
|
|
||||||
Michał Górny <mgorny@gentoo.org>
|
|
||||||
Mike Naberezny <mike@naberezny.com>
|
|
||||||
mloy <matthias.loy@googlemail.com>
|
|
||||||
Motti <lanzkron@gmail.com>
|
|
||||||
nnkur <nnkur@mail.ru>
|
|
||||||
Omkar Wagh <owagh@owaghlinux.ny.tower-research.com>
|
|
||||||
paulo <paulobrizolara@users.noreply.github.com>
|
|
||||||
pavel.pimenov <pavel.pimenov@gmail.com>
|
|
||||||
Paweł Bylica <chfast@gmail.com>
|
|
||||||
Péricles Lopes Machado <pericles.raskolnikoff@gmail.com>
|
|
||||||
Peter Spiess-Knafl <psk@autistici.org>
|
|
||||||
pffang <pffang@vip.qq.com>
|
|
||||||
Rémi Verschelde <remi@verschelde.fr>
|
|
||||||
renu555 <renu.tyagi@samsung.com>
|
|
||||||
Robert Dailey <rcdailey@gmail.com>
|
|
||||||
Sam Clegg <sbc@chromium.org>
|
|
||||||
selaselah <selah@outlook.com>
|
|
||||||
Sergiy80 <sil2004@gmail.com>
|
|
||||||
sergzub <sergzub@gmail.com>
|
|
||||||
Stefan Schweter <stefan@schweter.it>
|
|
||||||
Steffen Kieß <Steffen.Kiess@ipvs.uni-stuttgart.de>
|
|
||||||
Steven Hahn <hahnse@ornl.gov>
|
|
||||||
Stuart Eichert <stuart@fivemicro.com>
|
|
||||||
SuperManitu <supermanitu@gmail.com>
|
|
||||||
Techwolf <dring@g33kworld.net>
|
|
||||||
Tengiz Sharafiev <btolfa+github@gmail.com>
|
|
||||||
Tomasz Maciejewski <tmaciejewsk@gmail.com>
|
|
||||||
Vicente Olivert Riera <Vincent.Riera@imgtec.com>
|
|
||||||
xiaoyur347 <xiaoyur347@gmail.com>
|
|
||||||
ycqiu <429148848@qq.com>
|
|
||||||
yiqiju <fred_ju@selinc.com>
|
|
||||||
Yu Xiaolei <dreifachstein@gmail.com>
|
|
||||||
|
|
||||||
Google Inc.
|
|
||||||
|
142
CMakeLists.txt
142
CMakeLists.txt
@@ -1,17 +1,12 @@
|
|||||||
# vim: et ts=4 sts=4 sw=4 tw=0
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5)
|
||||||
|
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
|
|
||||||
PROJECT(jsoncpp)
|
PROJECT(jsoncpp)
|
||||||
ENABLE_TESTING()
|
ENABLE_TESTING()
|
||||||
|
|
||||||
OPTION(JSONCPP_WITH_TESTS "Compile and (for jsoncpp_check) run JsonCpp test executables" ON)
|
OPTION(JSONCPP_WITH_TESTS "Compile and run JsonCpp test executables" ON)
|
||||||
OPTION(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON)
|
OPTION(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON)
|
||||||
OPTION(JSONCPP_WITH_WARNING_AS_ERROR "Force compilation to fail if a warning occurs" OFF)
|
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_PKGCONFIG_SUPPORT "Generate and install .pc files" ON)
|
||||||
OPTION(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" OFF)
|
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
|
# Ensures that CMAKE_BUILD_TYPE is visible in cmake-gui on Unix
|
||||||
IF(NOT WIN32)
|
IF(NOT WIN32)
|
||||||
@@ -19,23 +14,27 @@ IF(NOT WIN32)
|
|||||||
SET(CMAKE_BUILD_TYPE Release CACHE STRING
|
SET(CMAKE_BUILD_TYPE Release CACHE STRING
|
||||||
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage."
|
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Coverage."
|
||||||
FORCE)
|
FORCE)
|
||||||
ENDIF()
|
ENDIF(NOT CMAKE_BUILD_TYPE)
|
||||||
ENDIF()
|
ENDIF(NOT WIN32)
|
||||||
|
|
||||||
# Enable runtime search path support for dynamic libraries on OSX
|
SET(LIB_SUFFIX "" CACHE STRING "Optional arch-dependent suffix for the library installation directory")
|
||||||
IF(APPLE)
|
|
||||||
SET(CMAKE_MACOSX_RPATH 1)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
# Adhere to GNU filesystem layout conventions
|
SET(RUNTIME_INSTALL_DIR bin
|
||||||
INCLUDE(GNUInstallDirs)
|
CACHE PATH "Install dir for executables and dlls")
|
||||||
|
SET(ARCHIVE_INSTALL_DIR lib${LIB_SUFFIX}
|
||||||
SET(DEBUG_LIBNAME_SUFFIX "" CACHE STRING "Optional suffix to append to the library name for a debug build")
|
CACHE PATH "Install dir for static libraries")
|
||||||
|
SET(LIBRARY_INSTALL_DIR lib${LIB_SUFFIX}
|
||||||
|
CACHE PATH "Install dir for shared libraries")
|
||||||
|
SET(INCLUDE_INSTALL_DIR include
|
||||||
|
CACHE PATH "Install dir for headers")
|
||||||
|
SET(PACKAGE_INSTALL_DIR lib${LIB_SUFFIX}/cmake
|
||||||
|
CACHE PATH "Install dir for cmake package config files")
|
||||||
|
MARK_AS_ADVANCED( RUNTIME_INSTALL_DIR ARCHIVE_INSTALL_DIR INCLUDE_INSTALL_DIR PACKAGE_INSTALL_DIR )
|
||||||
|
|
||||||
# Set variable named ${VAR_NAME} to value ${VALUE}
|
# Set variable named ${VAR_NAME} to value ${VALUE}
|
||||||
FUNCTION(set_using_dynamic_name VAR_NAME VALUE)
|
FUNCTION(set_using_dynamic_name VAR_NAME VALUE)
|
||||||
SET( "${VAR_NAME}" "${VALUE}" PARENT_SCOPE)
|
SET( "${VAR_NAME}" "${VALUE}" PARENT_SCOPE)
|
||||||
ENDFUNCTION()
|
ENDFUNCTION(set_using_dynamic_name)
|
||||||
|
|
||||||
# Extract major, minor, patch from version text
|
# Extract major, minor, patch from version text
|
||||||
# Parse a version string "X.Y.Z" and outputs
|
# Parse a version string "X.Y.Z" and outputs
|
||||||
@@ -51,106 +50,65 @@ MACRO(jsoncpp_parse_version VERSION_TEXT OUPUT_PREFIX)
|
|||||||
set_using_dynamic_name( "${OUPUT_PREFIX}_FOUND" TRUE )
|
set_using_dynamic_name( "${OUPUT_PREFIX}_FOUND" TRUE )
|
||||||
ELSE( ${VERSION_TEXT} MATCHES ${VERSION_REGEX} )
|
ELSE( ${VERSION_TEXT} MATCHES ${VERSION_REGEX} )
|
||||||
set_using_dynamic_name( "${OUPUT_PREFIX}_FOUND" FALSE )
|
set_using_dynamic_name( "${OUPUT_PREFIX}_FOUND" FALSE )
|
||||||
ENDIF()
|
ENDIF( ${VERSION_TEXT} MATCHES ${VERSION_REGEX} )
|
||||||
ENDMACRO()
|
ENDMACRO(jsoncpp_parse_version)
|
||||||
|
|
||||||
# Read out version from "version" file
|
# Read out version from "version" file
|
||||||
#FILE(STRINGS "version" JSONCPP_VERSION)
|
FILE(STRINGS "version" JSONCPP_VERSION)
|
||||||
#SET( JSONCPP_VERSION_MAJOR X )
|
|
||||||
#SET( JSONCPP_VERSION_MINOR Y )
|
|
||||||
#SET( JSONCPP_VERSION_PATCH Z )
|
|
||||||
SET( JSONCPP_VERSION 1.8.2 )
|
|
||||||
jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION )
|
jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION )
|
||||||
#IF(NOT JSONCPP_VERSION_FOUND)
|
IF(NOT JSONCPP_VERSION_FOUND)
|
||||||
# MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
|
MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
|
||||||
#ENDIF(NOT JSONCPP_VERSION_FOUND)
|
ENDIF(NOT JSONCPP_VERSION_FOUND)
|
||||||
SET( JSONCPP_SOVERSION 11 )
|
|
||||||
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}")
|
MESSAGE(STATUS "JsonCpp Version: ${JSONCPP_VERSION_MAJOR}.${JSONCPP_VERSION_MINOR}.${JSONCPP_VERSION_PATCH}")
|
||||||
# File version.h is only regenerated on CMake configure step
|
# File version.h is only regenerated on CMake configure step
|
||||||
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/src/lib_json/version.h.in"
|
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/src/lib_json/version.h.in"
|
||||||
"${PROJECT_SOURCE_DIR}/include/json/version.h"
|
"${PROJECT_SOURCE_DIR}/include/json/version.h" )
|
||||||
NEWLINE_STYLE UNIX )
|
|
||||||
CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/version.in"
|
|
||||||
"${PROJECT_SOURCE_DIR}/version"
|
|
||||||
NEWLINE_STYLE UNIX )
|
|
||||||
|
|
||||||
MACRO(UseCompilationWarningAsError)
|
macro(UseCompilationWarningAsError)
|
||||||
IF(MSVC)
|
if ( MSVC )
|
||||||
# Only enabled in debug because some old versions of VS STL generate
|
# Only enabled in debug because some old versions of VS STL generate
|
||||||
# warnings when compiled in release configuration.
|
# warnings when compiled in release configuration.
|
||||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ")
|
||||||
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
endif( MSVC )
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
endmacro()
|
||||||
IF(JSONCPP_WITH_STRICT_ISO)
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
ENDMACRO()
|
|
||||||
|
|
||||||
# Include our configuration header
|
# Include our configuration header
|
||||||
INCLUDE_DIRECTORIES( ${jsoncpp_SOURCE_DIR}/include )
|
INCLUDE_DIRECTORIES( ${jsoncpp_SOURCE_DIR}/include )
|
||||||
|
|
||||||
IF(MSVC)
|
if ( MSVC )
|
||||||
# Only enabled in debug because some old versions of VS STL generate
|
# Only enabled in debug because some old versions of VS STL generate
|
||||||
# unreachable code warning when compiled in release configuration.
|
# unreachable code warning when compiled in release configuration.
|
||||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ")
|
||||||
ENDIF()
|
endif( MSVC )
|
||||||
|
|
||||||
# Require C++11 support, prefer ISO C++ over GNU variants,
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
# as relying solely on ISO C++ is more portable.
|
# using regular Clang or AppleClang
|
||||||
SET(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
SET(CMAKE_CXX_EXTENSIONS OFF)
|
# using GCC
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
|
||||||
IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
endif()
|
||||||
# using regular Clang or AppleClang
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare")
|
|
||||||
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
||||||
# using GCC
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wshadow -Wextra")
|
|
||||||
# not yet ready for -Wsign-conversion
|
|
||||||
|
|
||||||
IF(JSONCPP_WITH_STRICT_ISO)
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
|
|
||||||
ENDIF()
|
|
||||||
IF(JSONCPP_WITH_WARNING_AS_ERROR)
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=conversion")
|
|
||||||
ENDIF()
|
|
||||||
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
|
||||||
# using Intel compiler
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -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()
|
|
||||||
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)
|
IF(JSONCPP_WITH_WARNING_AS_ERROR)
|
||||||
UseCompilationWarningAsError()
|
UseCompilationWarningAsError()
|
||||||
ENDIF()
|
ENDIF(JSONCPP_WITH_WARNING_AS_ERROR)
|
||||||
|
|
||||||
IF(JSONCPP_WITH_PKGCONFIG_SUPPORT)
|
IF(JSONCPP_WITH_PKGCONFIG_SUPPORT)
|
||||||
CONFIGURE_FILE(
|
CONFIGURE_FILE(
|
||||||
"pkg-config/jsoncpp.pc.in"
|
"pkg-config/jsoncpp.pc.in"
|
||||||
"pkg-config/jsoncpp.pc"
|
"pkg-config/jsoncpp.pc"
|
||||||
@ONLY)
|
@ONLY)
|
||||||
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkg-config/jsoncpp.pc"
|
INSTALL(FILES "${CMAKE_BINARY_DIR}/pkg-config/jsoncpp.pc"
|
||||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig")
|
||||||
ENDIF()
|
ENDIF(JSONCPP_WITH_PKGCONFIG_SUPPORT)
|
||||||
|
|
||||||
IF(JSONCPP_WITH_CMAKE_PACKAGE)
|
IF(JSONCPP_WITH_CMAKE_PACKAGE)
|
||||||
INSTALL(EXPORT jsoncpp
|
INSTALL(EXPORT jsoncpp
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp
|
DESTINATION ${PACKAGE_INSTALL_DIR}/jsoncpp
|
||||||
FILE jsoncppConfig.cmake)
|
FILE jsoncppConfig.cmake)
|
||||||
ENDIF()
|
ENDIF(JSONCPP_WITH_CMAKE_PACKAGE)
|
||||||
|
|
||||||
# Build the different applications
|
# Build the different applications
|
||||||
ADD_SUBDIRECTORY( src )
|
ADD_SUBDIRECTORY( src )
|
||||||
|
8
LICENSE
8
LICENSE
@@ -2,13 +2,13 @@ The JsonCpp library's source code, including accompanying documentation,
|
|||||||
tests and demonstration applications, are licensed under the following
|
tests and demonstration applications, are licensed under the following
|
||||||
conditions...
|
conditions...
|
||||||
|
|
||||||
Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all
|
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
||||||
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||||
this software is released into the Public Domain.
|
this software is released into the Public Domain.
|
||||||
|
|
||||||
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
||||||
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
|
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
|
||||||
The JsonCpp Authors, and is released under the terms of the MIT License (see below).
|
released under the terms of the MIT License (see below).
|
||||||
|
|
||||||
In jurisdictions which recognize Public Domain property, the user of this
|
In jurisdictions which recognize Public Domain property, the user of this
|
||||||
software may choose to accept it either as 1) Public Domain, 2) under the
|
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||||
@@ -23,7 +23,7 @@ described in clear, concise terms at:
|
|||||||
The full text of the MIT License follows:
|
The full text of the MIT License follows:
|
||||||
|
|
||||||
========================================================================
|
========================================================================
|
||||||
Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
Copyright (c) 2007-2010 Baptiste Lepilleur
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation
|
obtaining a copy of this software and associated documentation
|
||||||
|
175
NEWS.txt
Normal file
175
NEWS.txt
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
New in SVN
|
||||||
|
----------
|
||||||
|
|
||||||
|
* Updated the type system's behavior, in order to better support backwards
|
||||||
|
compatibility with code that was written before 64-bit integer support was
|
||||||
|
introduced. Here's how it works now:
|
||||||
|
|
||||||
|
* isInt, isInt64, isUInt, and isUInt64 return true if and only if the
|
||||||
|
value can be exactly represented as that type. In particular, a value
|
||||||
|
constructed with a double like 17.0 will now return true for all of
|
||||||
|
these methods.
|
||||||
|
|
||||||
|
* isDouble and isFloat now return true for all numeric values, since all
|
||||||
|
numeric values can be converted to a double or float without
|
||||||
|
truncation. Note however that the conversion may not be exact -- for
|
||||||
|
example, doubles cannot exactly represent all integers above 2^53 + 1.
|
||||||
|
|
||||||
|
* isBool, isNull, isString, isArray, and isObject now return true if and
|
||||||
|
only if the value is of that type.
|
||||||
|
|
||||||
|
* isConvertibleTo(fooValue) indicates that it is safe to call asFoo.
|
||||||
|
(For each type foo, isFoo always implies isConvertibleTo(fooValue).)
|
||||||
|
asFoo returns an approximate or exact representation as appropriate.
|
||||||
|
For example, a double value may be truncated when asInt is called.
|
||||||
|
|
||||||
|
* For backwards compatibility with old code, isConvertibleTo(intValue)
|
||||||
|
may return false even if type() == intValue. This is because the value
|
||||||
|
may have been constructed with a 64-bit integer larger than maxInt,
|
||||||
|
and calling asInt() would cause an exception. If you're writing new
|
||||||
|
code, use isInt64 to find out whether the value is exactly
|
||||||
|
representable using an Int64, or asDouble() combined with minInt64 and
|
||||||
|
maxInt64 to figure out whether it is approximately representable.
|
||||||
|
|
||||||
|
* Value
|
||||||
|
- Patch #10: BOOST_FOREACH compatibility. Made Json::iterator more
|
||||||
|
standard compliant, added missing iterator_category and value_type
|
||||||
|
typedefs (contribued by Robert A. Iannucci).
|
||||||
|
|
||||||
|
* Compilation
|
||||||
|
|
||||||
|
- New CMake based build system. Based in part on contribution from
|
||||||
|
Igor Okulist and Damien Buhl (Patch #14).
|
||||||
|
|
||||||
|
- New header json/version.h now contains version number macros
|
||||||
|
(JSONCPP_VERSION_MAJOR, JSONCPP_VERSION_MINOR, JSONCPP_VERSION_PATCH
|
||||||
|
and JSONCPP_VERSION_HEXA).
|
||||||
|
|
||||||
|
- Patch #11: added missing JSON_API on some classes causing link issues
|
||||||
|
when building as a dynamic library on Windows
|
||||||
|
(contributed by Francis Bolduc).
|
||||||
|
|
||||||
|
- Visual Studio DLL: suppressed warning "C4251: <data member>: <type>
|
||||||
|
needs to have dll-interface to be used by..." via pragma push/pop
|
||||||
|
in json-cpp headers.
|
||||||
|
|
||||||
|
- Added Travis CI intregration: https://travis-ci.org/blep/jsoncpp-mirror
|
||||||
|
|
||||||
|
* Bug fixes
|
||||||
|
- Patch #15: Copy constructor does not initialize allocated_ for stringValue
|
||||||
|
(contributed by rmongia).
|
||||||
|
|
||||||
|
- Patch #16: Missing field copy in Json::Value::iterator causing infinite
|
||||||
|
loop when using experimental internal map (#define JSON_VALUE_USE_INTERNAL_MAP)
|
||||||
|
(contributed by Ming-Lin Kao).
|
||||||
|
|
||||||
|
|
||||||
|
New in JsonCpp 0.6.0:
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
* Compilation
|
||||||
|
|
||||||
|
- LD_LIBRARY_PATH and LIBRARY_PATH environment variables are now
|
||||||
|
propagated to the build environment as this is required for some
|
||||||
|
compiler installation.
|
||||||
|
|
||||||
|
- Added support for Microsoft Visual Studio 2008 (bug #2930462):
|
||||||
|
The platform "msvc90" has been added.
|
||||||
|
|
||||||
|
Notes: you need to setup the environment by running vcvars32.bat
|
||||||
|
(e.g. MSVC 2008 command prompt in start menu) before running scons.
|
||||||
|
|
||||||
|
- Added support for amalgamated source and header generation (a la sqlite).
|
||||||
|
Refer to README.md section "Generating amalgamated source and header"
|
||||||
|
for detail.
|
||||||
|
|
||||||
|
* Value
|
||||||
|
|
||||||
|
- Removed experimental ValueAllocator, it caused static
|
||||||
|
initialization/destruction order issues (bug #2934500).
|
||||||
|
The DefaultValueAllocator has been inlined in code.
|
||||||
|
|
||||||
|
- Added support for 64 bits integer:
|
||||||
|
|
||||||
|
Types Json::Int64 and Json::UInt64 have been added. They are aliased
|
||||||
|
to 64 bits integers on system that support them (based on __int64 on
|
||||||
|
Microsoft Visual Studio platform, and long long on other platforms).
|
||||||
|
|
||||||
|
Types Json::LargestInt and Json::LargestUInt have been added. They are
|
||||||
|
aliased to the largest integer type supported:
|
||||||
|
either Json::Int/Json::UInt or Json::Int64/Json::UInt64 respectively.
|
||||||
|
|
||||||
|
Json::Value::asInt() and Json::Value::asUInt() still returns plain
|
||||||
|
"int" based types, but asserts if an attempt is made to retrieve
|
||||||
|
a 64 bits value that can not represented as the return type.
|
||||||
|
|
||||||
|
Json::Value::asInt64() and Json::Value::asUInt64() have been added
|
||||||
|
to obtain the 64 bits integer value.
|
||||||
|
|
||||||
|
Json::Value::asLargestInt() and Json::Value::asLargestUInt() returns
|
||||||
|
the integer as a LargestInt/LargestUInt respectively. Those functions
|
||||||
|
functions are typically used when implementing writer.
|
||||||
|
|
||||||
|
The reader attempts to read number as 64 bits integer, and fall back
|
||||||
|
to reading a double if the number is not in the range of 64 bits
|
||||||
|
integer.
|
||||||
|
|
||||||
|
Warning: Json::Value::asInt() and Json::Value::asUInt() now returns
|
||||||
|
long long. This changes break code that was passing the return value
|
||||||
|
to *printf() function.
|
||||||
|
|
||||||
|
Support for 64 bits integer can be disabled by defining the macro
|
||||||
|
JSON_NO_INT64 (uncomment it in json/config.h for example), though
|
||||||
|
it should have no impact on existing usage.
|
||||||
|
|
||||||
|
- The type Json::ArrayIndex is used for indexes of a JSON value array. It
|
||||||
|
is an unsigned int (typically 32 bits).
|
||||||
|
|
||||||
|
- Array index can be passed as int to operator[], allowing use of literal:
|
||||||
|
Json::Value array;
|
||||||
|
array.append( 1234 );
|
||||||
|
int value = array[0].asInt(); // did not compile previously
|
||||||
|
|
||||||
|
- Added float Json::Value::asFloat() to obtain a floating point value as a
|
||||||
|
float (avoid lost of precision warning caused by used of asDouble()
|
||||||
|
to initialize a float).
|
||||||
|
|
||||||
|
* Reader
|
||||||
|
|
||||||
|
- Renamed Reader::getFormatedErrorMessages() to getFormattedErrorMessages.
|
||||||
|
Bug #3023708 (Formatted has 2 't'). The old member function is deprecated
|
||||||
|
but still present for backward compatibility.
|
||||||
|
|
||||||
|
* Tests
|
||||||
|
|
||||||
|
- Added test to ensure that the escape sequence "\/" is corrected handled
|
||||||
|
by the parser.
|
||||||
|
|
||||||
|
* Bug fixes
|
||||||
|
|
||||||
|
- Bug #3139677: JSON [1 2 3] was incorrectly parsed as [1, 3]. Error is now
|
||||||
|
correctly detected.
|
||||||
|
|
||||||
|
- Bug #3139678: stack buffer overflow when parsing a double with a
|
||||||
|
length of 32 characters.
|
||||||
|
|
||||||
|
- Fixed Value::operator <= implementation (had the semantic of operator >=).
|
||||||
|
Found when adding unit tests for comparison operators.
|
||||||
|
|
||||||
|
- Value::compare() is now const and has an actual implementation with
|
||||||
|
unit tests.
|
||||||
|
|
||||||
|
- Bug #2407932: strpbrk() can fail for NULL pointer.
|
||||||
|
|
||||||
|
- Bug #3306345: Fixed minor typo in Path::resolve().
|
||||||
|
|
||||||
|
- Bug #3314841/#3306896: errors in amalgamate.py
|
||||||
|
|
||||||
|
- Fixed some Coverity warnings and line-endings.
|
||||||
|
|
||||||
|
* License
|
||||||
|
|
||||||
|
- See file LICENSE for details. Basically JsonCpp is now licensed under
|
||||||
|
MIT license, or public domain if desired and recognized in your jurisdiction.
|
||||||
|
Thanks to Stephan G. Beal [http://wanderinghorse.net/home/stephan/]) who
|
||||||
|
helped figuring out the solution to the public domain issue.
|
191
README.md
191
README.md
@@ -1,6 +1,5 @@
|
|||||||
# JsonCpp
|
Introduction
|
||||||
|
------------
|
||||||
[](http://www.conan.io/source/jsoncpp/1.8.0/theirix/ci)
|
|
||||||
|
|
||||||
[JSON][json-org] is a lightweight data-interchange format. It can represent
|
[JSON][json-org] is a lightweight data-interchange format. It can represent
|
||||||
numbers, strings, ordered sequences of values, and collections of name/value
|
numbers, strings, ordered sequences of values, and collections of name/value
|
||||||
@@ -13,42 +12,108 @@ serialization and deserialization to and from strings. It can also preserve
|
|||||||
existing comment in unserialization/serialization steps, making it a convenient
|
existing comment in unserialization/serialization steps, making it a convenient
|
||||||
format to store user input files.
|
format to store user input files.
|
||||||
|
|
||||||
|
|
||||||
## Documentation
|
|
||||||
|
|
||||||
[JsonCpp documentation][JsonCpp-documentation] is generated using [Doxygen][].
|
|
||||||
|
|
||||||
[JsonCpp-documentation]: http://open-source-parsers.github.io/jsoncpp-docs/doxygen/index.html
|
|
||||||
[Doxygen]: http://www.doxygen.org
|
|
||||||
|
|
||||||
|
|
||||||
## A note on backward-compatibility
|
## A note on backward-compatibility
|
||||||
|
Very soon, we are switching to C++11 only. For older compilers, try the `pre-C++11` branch.
|
||||||
|
|
||||||
* `1.y.z` is built with C++11.
|
Using JsonCpp in your project
|
||||||
* `0.y.z` can be used with older compilers.
|
-----------------------------
|
||||||
* Major versions maintain binary-compatibility.
|
|
||||||
|
|
||||||
## Contributing to JsonCpp
|
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:
|
||||||
|
|
||||||
### Building and testing with Meson/Ninja
|
#include <json/json.h>
|
||||||
Thanks to David Seifert (@SoapGentoo), we (the maintainers) now use [meson](http://mesonbuild.com/) and [ninja](https://ninja-build.org/) to build for debugging, as well as for continuous integration (see [`travis.sh`](travis.sh) ). Other systems may work, but minor things like version strings might break.
|
|
||||||
|
|
||||||
First, install both meson (which requires Python3) and ninja.
|
If JsonCpp was build as a dynamic library on Windows, then your project needs to
|
||||||
|
define the macro `JSON_DLL`.
|
||||||
|
|
||||||
Then,
|
|
||||||
|
|
||||||
cd jsoncpp/
|
Building and testing with new CMake
|
||||||
BUILD_TYPE=shared
|
-----------------------------------
|
||||||
#BUILD_TYPE=static
|
|
||||||
LIB_TYPE=debug
|
|
||||||
#LIB_TYPE=release
|
|
||||||
meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . build-${LIB_TYPE}
|
|
||||||
ninja -v -C build-${LIB_TYPE} test
|
|
||||||
|
|
||||||
### Building and testing with other build systems
|
[CMake][] is a C++ Makefiles/Solution generator. It is usually available on most
|
||||||
See https://github.com/open-source-parsers/jsoncpp/wiki/Building
|
Linux system as package. On Ubuntu:
|
||||||
|
|
||||||
### Running the tests manually
|
sudo apt-get install cmake
|
||||||
|
|
||||||
|
[CMake]: http://www.cmake.org
|
||||||
|
|
||||||
|
Note that Python is also required to run the JSON reader/writer tests. If
|
||||||
|
missing, the build will skip running those tests.
|
||||||
|
|
||||||
|
When running CMake, a few parameters are required:
|
||||||
|
|
||||||
|
* a build directory where the makefiles/solution are generated. It is also used
|
||||||
|
to store objects, libraries and executables files.
|
||||||
|
* the generator to use: makefiles or Visual Studio solution? What version or
|
||||||
|
Visual Studio, 32 or 64 bits solution?
|
||||||
|
|
||||||
|
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 `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.
|
||||||
|
|
||||||
|
Alternatively, from the command-line on Unix in the source directory:
|
||||||
|
|
||||||
|
mkdir -p build/debug
|
||||||
|
cd build/debug
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=debug -DJSONCPP_LIB_BUILD_STATIC=ON -DJSONCPP_LIB_BUILD_SHARED=OFF -G "Unix Makefiles" ../..
|
||||||
|
make
|
||||||
|
|
||||||
|
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
|
||||||
|
`-DCMAKE_VERBOSE_MAKEFILE=true` when generating makefiles.
|
||||||
|
|
||||||
|
|
||||||
|
Building and testing with SCons
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
**Note:** The SCons-based build system is deprecated. Please use CMake; see the
|
||||||
|
section above.
|
||||||
|
|
||||||
|
JsonCpp can use [Scons][] as a build system. Note that SCons requires Python to
|
||||||
|
be installed.
|
||||||
|
|
||||||
|
[SCons]: http://www.scons.org/
|
||||||
|
|
||||||
|
Invoke SCons as follows:
|
||||||
|
|
||||||
|
scons platform=$PLATFORM [TARGET]
|
||||||
|
|
||||||
|
where `$PLATFORM` may be one of:
|
||||||
|
|
||||||
|
* `suncc`: Sun C++ (Solaris)
|
||||||
|
* `vacpp`: Visual Age C++ (AIX)
|
||||||
|
* `mingw`
|
||||||
|
* `msvc6`: Microsoft Visual Studio 6 service pack 5-6
|
||||||
|
* `msvc70`: Microsoft Visual Studio 2002
|
||||||
|
* `msvc71`: Microsoft Visual Studio 2003
|
||||||
|
* `msvc80`: Microsoft Visual Studio 2005
|
||||||
|
* `msvc90`: Microsoft Visual Studio 2008
|
||||||
|
* `linux-gcc`: Gnu C++ (linux, also reported to work for Mac OS X)
|
||||||
|
|
||||||
|
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
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
Note that test can be run using SCons using the `check` target:
|
||||||
|
|
||||||
|
scons platform=$PLATFORM check
|
||||||
|
|
||||||
You need to run tests manually only if you are troubleshooting an issue.
|
You need to run tests manually only if you are troubleshooting an issue.
|
||||||
|
|
||||||
@@ -58,21 +123,23 @@ In the instructions below, replace `path/to/jsontest` with the path of the
|
|||||||
cd test
|
cd test
|
||||||
# This will run the Reader/Writer tests
|
# This will run the Reader/Writer tests
|
||||||
python runjsontests.py path/to/jsontest
|
python runjsontests.py path/to/jsontest
|
||||||
|
|
||||||
# This will run the Reader/Writer tests, using JSONChecker test suite
|
# This will run the Reader/Writer tests, using JSONChecker test suite
|
||||||
# (http://www.json.org/JSON_checker/).
|
# (http://www.json.org/JSON_checker/).
|
||||||
# Notes: not all tests pass: JsonCpp is too lenient (for example,
|
# Notes: not all tests pass: JsonCpp is too lenient (for example,
|
||||||
# it allows an integer to start with '0'). The goal is to improve
|
# it allows an integer to start with '0'). The goal is to improve
|
||||||
# strict mode parsing to get all tests to pass.
|
# strict mode parsing to get all tests to pass.
|
||||||
python runjsontests.py --with-json-checker path/to/jsontest
|
python runjsontests.py --with-json-checker path/to/jsontest
|
||||||
|
|
||||||
# This will run the unit tests (mostly Value)
|
# This will run the unit tests (mostly Value)
|
||||||
python rununittests.py path/to/test_lib_json
|
python rununittests.py path/to/test_lib_json
|
||||||
|
|
||||||
# You can run the tests using valgrind:
|
# You can run the tests using valgrind:
|
||||||
python rununittests.py --valgrind path/to/test_lib_json
|
python rununittests.py --valgrind path/to/test_lib_json
|
||||||
|
|
||||||
### Building the documentation
|
|
||||||
|
Building the documentation
|
||||||
|
--------------------------
|
||||||
|
|
||||||
Run the Python script `doxybuild.py` from the top directory:
|
Run the Python script `doxybuild.py` from the top directory:
|
||||||
|
|
||||||
@@ -80,7 +147,34 @@ Run the Python script `doxybuild.py` from the top directory:
|
|||||||
|
|
||||||
See `doxybuild.py --help` for options.
|
See `doxybuild.py --help` for options.
|
||||||
|
|
||||||
### Adding a reader/writer test
|
|
||||||
|
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:
|
To add a test, you need to create two files in test/data:
|
||||||
|
|
||||||
@@ -90,19 +184,23 @@ To add a test, you need to create two files in test/data:
|
|||||||
|
|
||||||
The `TESTNAME.expected` file format is as follows:
|
The `TESTNAME.expected` file format is as follows:
|
||||||
|
|
||||||
* Each line represents a JSON element of the element tree represented by the
|
* each line represents a JSON element of the element tree represented by the
|
||||||
input document.
|
input document.
|
||||||
* Each line has two parts: the path to access the element separated from the
|
* each line has two parts: the path to access the element separated from the
|
||||||
element value by `=`. Array and object values are always empty (i.e.
|
element value by `=`. Array and object values are always empty (i.e.
|
||||||
represented by either `[]` or `{}`).
|
represented by either `[]` or `{}`).
|
||||||
* Element path `.` represents the root element, and is used to separate object
|
* element path: `.` represents the root element, and is used to separate object
|
||||||
members. `[N]` is used to specify the value of an array element at index `N`.
|
members. `[N]` is used to specify the value of an array element at index `N`.
|
||||||
|
|
||||||
See the examples `test_complex_01.json` and `test_complex_01.expected` to better understand element paths.
|
See the examples `test_complex_01.json` and `test_complex_01.expected` to better
|
||||||
|
understand element paths.
|
||||||
|
|
||||||
### Understanding reader/writer test output
|
|
||||||
|
|
||||||
When a test is run, output files are generated beside the input test files. Below is a short description of the content of each file:
|
Understanding reader/writer test output
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
|
When a test is run, output files are generated beside the input test files.
|
||||||
|
Below is a short description of the content of each file:
|
||||||
|
|
||||||
* `test_complex_01.json`: input JSON document.
|
* `test_complex_01.json`: input JSON document.
|
||||||
* `test_complex_01.expected`: flattened JSON element tree used to check if
|
* `test_complex_01.expected`: flattened JSON element tree used to check if
|
||||||
@@ -117,15 +215,10 @@ When a test is run, output files are generated beside the input test files. Belo
|
|||||||
* `test_complex_01.process-output`: `jsontest` output, typically useful for
|
* `test_complex_01.process-output`: `jsontest` output, typically useful for
|
||||||
understanding parsing errors.
|
understanding parsing errors.
|
||||||
|
|
||||||
## Using JsonCpp in your project
|
|
||||||
|
|
||||||
### Amalgamated source
|
License
|
||||||
https://github.com/open-source-parsers/jsoncpp/wiki/Amalgamated
|
-------
|
||||||
|
|
||||||
### Other ways
|
|
||||||
If you have trouble, see the Wiki, or post a question as an Issue.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
See the `LICENSE` file for details. In summary, JsonCpp is licensed under the
|
See the `LICENSE` file for details. In summary, JsonCpp is licensed under the
|
||||||
MIT license, or public domain if desired and recognized in your jurisdiction.
|
MIT license, or public domain if desired and recognized in your jurisdiction.
|
||||||
|
|
||||||
|
248
SConstruct
Normal file
248
SConstruct
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
"""
|
||||||
|
Notes:
|
||||||
|
- shared library support is buggy: it assumes that a static and dynamic library can be build from the same object files. This is not true on many platforms. For this reason it is only enabled on linux-gcc at the current time.
|
||||||
|
|
||||||
|
To add a platform:
|
||||||
|
- add its name in options allowed_values below
|
||||||
|
- add tool initialization for this platform. Search for "if platform == 'suncc'" as an example.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
import sys
|
||||||
|
|
||||||
|
JSONCPP_VERSION = open(File('#version').abspath,'rt').read().strip()
|
||||||
|
DIST_DIR = '#dist'
|
||||||
|
|
||||||
|
options = Variables()
|
||||||
|
options.Add( EnumVariable('platform',
|
||||||
|
'Platform (compiler/stl) used to build the project',
|
||||||
|
'msvc71',
|
||||||
|
allowed_values='suncc vacpp mingw msvc6 msvc7 msvc71 msvc80 msvc90 linux-gcc'.split(),
|
||||||
|
ignorecase=2) )
|
||||||
|
|
||||||
|
try:
|
||||||
|
platform = ARGUMENTS['platform']
|
||||||
|
if platform == 'linux-gcc':
|
||||||
|
CXX = 'g++' # not quite right, but env is not yet available.
|
||||||
|
import commands
|
||||||
|
version = commands.getoutput('%s -dumpversion' %CXX)
|
||||||
|
platform = 'linux-gcc-%s' %version
|
||||||
|
print "Using platform '%s'" %platform
|
||||||
|
LD_LIBRARY_PATH = os.environ.get('LD_LIBRARY_PATH', '')
|
||||||
|
LD_LIBRARY_PATH = "%s:libs/%s" %(LD_LIBRARY_PATH, platform)
|
||||||
|
os.environ['LD_LIBRARY_PATH'] = LD_LIBRARY_PATH
|
||||||
|
print "LD_LIBRARY_PATH =", LD_LIBRARY_PATH
|
||||||
|
except KeyError:
|
||||||
|
print 'You must specify a "platform"'
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
|
print "Building using PLATFORM =", platform
|
||||||
|
|
||||||
|
rootbuild_dir = Dir('#buildscons')
|
||||||
|
build_dir = os.path.join( '#buildscons', platform )
|
||||||
|
bin_dir = os.path.join( '#bin', platform )
|
||||||
|
lib_dir = os.path.join( '#libs', platform )
|
||||||
|
sconsign_dir_path = Dir(build_dir).abspath
|
||||||
|
sconsign_path = os.path.join( sconsign_dir_path, '.sconsign.dbm' )
|
||||||
|
|
||||||
|
# Ensure build directory exist (SConsignFile fail otherwise!)
|
||||||
|
if not os.path.exists( sconsign_dir_path ):
|
||||||
|
os.makedirs( sconsign_dir_path )
|
||||||
|
|
||||||
|
# Store all dependencies signature in a database
|
||||||
|
SConsignFile( sconsign_path )
|
||||||
|
|
||||||
|
def make_environ_vars():
|
||||||
|
"""Returns a dictionnary with environment variable to use when compiling."""
|
||||||
|
# PATH is required to find the compiler
|
||||||
|
# TEMP is required for at least mingw
|
||||||
|
# LD_LIBRARY_PATH & co is required on some system for the compiler
|
||||||
|
vars = {}
|
||||||
|
for name in ('PATH', 'TEMP', 'TMP', 'LD_LIBRARY_PATH', 'LIBRARY_PATH'):
|
||||||
|
if name in os.environ:
|
||||||
|
vars[name] = os.environ[name]
|
||||||
|
return vars
|
||||||
|
|
||||||
|
|
||||||
|
env = Environment( ENV = make_environ_vars(),
|
||||||
|
toolpath = ['scons-tools'],
|
||||||
|
tools=[] ) #, tools=['default'] )
|
||||||
|
|
||||||
|
if platform == 'suncc':
|
||||||
|
env.Tool( 'sunc++' )
|
||||||
|
env.Tool( 'sunlink' )
|
||||||
|
env.Tool( 'sunar' )
|
||||||
|
env.Append( CCFLAGS = ['-mt'] )
|
||||||
|
elif platform == 'vacpp':
|
||||||
|
env.Tool( 'default' )
|
||||||
|
env.Tool( 'aixcc' )
|
||||||
|
env['CXX'] = 'xlC_r' #scons does not pick-up the correct one !
|
||||||
|
# using xlC_r ensure multi-threading is enabled:
|
||||||
|
# http://publib.boulder.ibm.com/infocenter/pseries/index.jsp?topic=/com.ibm.vacpp7a.doc/compiler/ref/cuselect.htm
|
||||||
|
env.Append( CCFLAGS = '-qrtti=all',
|
||||||
|
LINKFLAGS='-bh:5' ) # -bh:5 remove duplicate symbol warning
|
||||||
|
elif platform == 'msvc6':
|
||||||
|
env['MSVS_VERSION']='6.0'
|
||||||
|
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
|
||||||
|
env.Tool( tool )
|
||||||
|
env['CXXFLAGS']='-GR -GX /nologo /MT'
|
||||||
|
elif platform == 'msvc70':
|
||||||
|
env['MSVS_VERSION']='7.0'
|
||||||
|
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
|
||||||
|
env.Tool( tool )
|
||||||
|
env['CXXFLAGS']='-GR -GX /nologo /MT'
|
||||||
|
elif platform == 'msvc71':
|
||||||
|
env['MSVS_VERSION']='7.1'
|
||||||
|
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
|
||||||
|
env.Tool( tool )
|
||||||
|
env['CXXFLAGS']='-GR -GX /nologo /MT'
|
||||||
|
elif platform == 'msvc80':
|
||||||
|
env['MSVS_VERSION']='8.0'
|
||||||
|
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
|
||||||
|
env.Tool( tool )
|
||||||
|
env['CXXFLAGS']='-GR -EHsc /nologo /MT'
|
||||||
|
elif platform == 'msvc90':
|
||||||
|
env['MSVS_VERSION']='9.0'
|
||||||
|
# Scons 1.2 fails to detect the correct location of the platform SDK.
|
||||||
|
# So we propagate those from the environment. This requires that the
|
||||||
|
# user run vcvars32.bat before compiling.
|
||||||
|
if 'INCLUDE' in os.environ:
|
||||||
|
env['ENV']['INCLUDE'] = os.environ['INCLUDE']
|
||||||
|
if 'LIB' in os.environ:
|
||||||
|
env['ENV']['LIB'] = os.environ['LIB']
|
||||||
|
for tool in ['msvc', 'msvs', 'mslink', 'masm', 'mslib']:
|
||||||
|
env.Tool( tool )
|
||||||
|
env['CXXFLAGS']='-GR -EHsc /nologo /MT'
|
||||||
|
elif platform == 'mingw':
|
||||||
|
env.Tool( 'mingw' )
|
||||||
|
env.Append( CPPDEFINES=[ "WIN32", "NDEBUG", "_MT" ] )
|
||||||
|
elif platform.startswith('linux-gcc'):
|
||||||
|
env.Tool( 'default' )
|
||||||
|
env.Append( LIBS = ['pthread'], CCFLAGS = os.environ.get("CXXFLAGS", "-Wall"), LINKFLAGS=os.environ.get("LDFLAGS", "") )
|
||||||
|
env['SHARED_LIB_ENABLED'] = True
|
||||||
|
else:
|
||||||
|
print "UNSUPPORTED PLATFORM."
|
||||||
|
env.Exit(1)
|
||||||
|
|
||||||
|
env.Tool('targz')
|
||||||
|
env.Tool('srcdist')
|
||||||
|
env.Tool('globtool')
|
||||||
|
|
||||||
|
env.Append( CPPPATH = ['#include'],
|
||||||
|
LIBPATH = lib_dir )
|
||||||
|
short_platform = platform
|
||||||
|
if short_platform.startswith('msvc'):
|
||||||
|
short_platform = short_platform[2:]
|
||||||
|
# Notes: on Windows you need to rebuild the source for each variant
|
||||||
|
# Build script does not support that yet so we only build static libraries.
|
||||||
|
# This also fails on AIX because both dynamic and static library ends with
|
||||||
|
# extension .a.
|
||||||
|
env['SHARED_LIB_ENABLED'] = env.get('SHARED_LIB_ENABLED', False)
|
||||||
|
env['LIB_PLATFORM'] = short_platform
|
||||||
|
env['LIB_LINK_TYPE'] = 'lib' # static
|
||||||
|
env['LIB_CRUNTIME'] = 'mt'
|
||||||
|
env['LIB_NAME_SUFFIX'] = '${LIB_PLATFORM}_${LIB_LINK_TYPE}${LIB_CRUNTIME}' # must match autolink naming convention
|
||||||
|
env['JSONCPP_VERSION'] = JSONCPP_VERSION
|
||||||
|
env['BUILD_DIR'] = env.Dir(build_dir)
|
||||||
|
env['ROOTBUILD_DIR'] = env.Dir(rootbuild_dir)
|
||||||
|
env['DIST_DIR'] = DIST_DIR
|
||||||
|
if 'TarGz' in env['BUILDERS']:
|
||||||
|
class SrcDistAdder:
|
||||||
|
def __init__( self, env ):
|
||||||
|
self.env = env
|
||||||
|
def __call__( self, *args, **kw ):
|
||||||
|
apply( self.env.SrcDist, (self.env['SRCDIST_TARGET'],) + args, kw )
|
||||||
|
env['SRCDIST_BUILDER'] = env.TarGz
|
||||||
|
else: # If tarfile module is missing
|
||||||
|
class SrcDistAdder:
|
||||||
|
def __init__( self, env ):
|
||||||
|
pass
|
||||||
|
def __call__( self, *args, **kw ):
|
||||||
|
pass
|
||||||
|
env['SRCDIST_ADD'] = SrcDistAdder( env )
|
||||||
|
env['SRCDIST_TARGET'] = os.path.join( DIST_DIR, 'jsoncpp-src-%s.tar.gz' % env['JSONCPP_VERSION'] )
|
||||||
|
|
||||||
|
env_testing = env.Clone( )
|
||||||
|
env_testing.Append( LIBS = ['json_${LIB_NAME_SUFFIX}'] )
|
||||||
|
|
||||||
|
def buildJSONExample( env, target_sources, target_name ):
|
||||||
|
env = env.Clone()
|
||||||
|
env.Append( CPPPATH = ['#'] )
|
||||||
|
exe = env.Program( target=target_name,
|
||||||
|
source=target_sources )
|
||||||
|
env['SRCDIST_ADD']( source=[target_sources] )
|
||||||
|
global bin_dir
|
||||||
|
return env.Install( bin_dir, exe )
|
||||||
|
|
||||||
|
def buildJSONTests( env, target_sources, target_name ):
|
||||||
|
jsontests_node = buildJSONExample( env, target_sources, target_name )
|
||||||
|
check_alias_target = env.Alias( 'check', jsontests_node, RunJSONTests( jsontests_node, jsontests_node ) )
|
||||||
|
env.AlwaysBuild( check_alias_target )
|
||||||
|
|
||||||
|
def buildUnitTests( env, target_sources, target_name ):
|
||||||
|
jsontests_node = buildJSONExample( env, target_sources, target_name )
|
||||||
|
check_alias_target = env.Alias( 'check', jsontests_node,
|
||||||
|
RunUnitTests( jsontests_node, jsontests_node ) )
|
||||||
|
env.AlwaysBuild( check_alias_target )
|
||||||
|
|
||||||
|
def buildLibrary( env, target_sources, target_name ):
|
||||||
|
static_lib = env.StaticLibrary( target=target_name + '_${LIB_NAME_SUFFIX}',
|
||||||
|
source=target_sources )
|
||||||
|
global lib_dir
|
||||||
|
env.Install( lib_dir, static_lib )
|
||||||
|
if env['SHARED_LIB_ENABLED']:
|
||||||
|
shared_lib = env.SharedLibrary( target=target_name + '_${LIB_NAME_SUFFIX}',
|
||||||
|
source=target_sources )
|
||||||
|
env.Install( lib_dir, shared_lib )
|
||||||
|
env['SRCDIST_ADD']( source=[target_sources] )
|
||||||
|
|
||||||
|
Export( 'env env_testing buildJSONExample buildLibrary buildJSONTests buildUnitTests' )
|
||||||
|
|
||||||
|
def buildProjectInDirectory( target_directory ):
|
||||||
|
global build_dir
|
||||||
|
target_build_dir = os.path.join( build_dir, target_directory )
|
||||||
|
target = os.path.join( target_directory, 'sconscript' )
|
||||||
|
SConscript( target, build_dir=target_build_dir, duplicate=0 )
|
||||||
|
env['SRCDIST_ADD']( source=[target] )
|
||||||
|
|
||||||
|
|
||||||
|
def runJSONTests_action( target, source = None, env = None ):
|
||||||
|
# Add test scripts to python path
|
||||||
|
jsontest_path = Dir( '#test' ).abspath
|
||||||
|
sys.path.insert( 0, jsontest_path )
|
||||||
|
data_path = os.path.join( jsontest_path, 'data' )
|
||||||
|
import runjsontests
|
||||||
|
return runjsontests.runAllTests( os.path.abspath(source[0].path), data_path )
|
||||||
|
|
||||||
|
def runJSONTests_string( target, source = None, env = None ):
|
||||||
|
return 'RunJSONTests("%s")' % source[0]
|
||||||
|
|
||||||
|
import SCons.Action
|
||||||
|
ActionFactory = SCons.Action.ActionFactory
|
||||||
|
RunJSONTests = ActionFactory(runJSONTests_action, runJSONTests_string )
|
||||||
|
|
||||||
|
def runUnitTests_action( target, source = None, env = None ):
|
||||||
|
# Add test scripts to python path
|
||||||
|
jsontest_path = Dir( '#test' ).abspath
|
||||||
|
sys.path.insert( 0, jsontest_path )
|
||||||
|
import rununittests
|
||||||
|
return rununittests.runAllTests( os.path.abspath(source[0].path) )
|
||||||
|
|
||||||
|
def runUnitTests_string( target, source = None, env = None ):
|
||||||
|
return 'RunUnitTests("%s")' % source[0]
|
||||||
|
|
||||||
|
RunUnitTests = ActionFactory(runUnitTests_action, runUnitTests_string )
|
||||||
|
|
||||||
|
env.Alias( 'check' )
|
||||||
|
|
||||||
|
srcdist_cmd = env['SRCDIST_ADD']( source = """
|
||||||
|
AUTHORS README.md SConstruct
|
||||||
|
""".split() )
|
||||||
|
env.Alias( 'src-dist', srcdist_cmd )
|
||||||
|
|
||||||
|
buildProjectInDirectory( 'src/jsontestrunner' )
|
||||||
|
buildProjectInDirectory( 'src/lib_json' )
|
||||||
|
buildProjectInDirectory( 'src/test_lib_json' )
|
||||||
|
#print env.Dump()
|
||||||
|
|
@@ -1,6 +1,6 @@
|
|||||||
"""Amalgate json-cpp library sources into a single source and header file.
|
"""Amalgate json-cpp library sources into a single source and header file.
|
||||||
|
|
||||||
Works with python2.6+ and python3.4+.
|
Requires Python 2.6
|
||||||
|
|
||||||
Example of invocation (must be invoked from json-cpp top directory):
|
Example of invocation (must be invoked from json-cpp top directory):
|
||||||
python amalgate.py
|
python amalgate.py
|
||||||
@@ -59,7 +59,7 @@ def amalgamate_source(source_top_dir=None,
|
|||||||
print("Amalgating header...")
|
print("Amalgating header...")
|
||||||
header = AmalgamationFile(source_top_dir)
|
header = AmalgamationFile(source_top_dir)
|
||||||
header.add_text("/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).")
|
header.add_text("/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).")
|
||||||
header.add_text('/// It is intended to be used with #include "%s"' % header_include_path)
|
header.add_text("/// It is intented to be used with #include <%s>" % header_include_path)
|
||||||
header.add_file("LICENSE", wrap_in_comment=True)
|
header.add_file("LICENSE", wrap_in_comment=True)
|
||||||
header.add_text("#ifndef JSON_AMALGATED_H_INCLUDED")
|
header.add_text("#ifndef JSON_AMALGATED_H_INCLUDED")
|
||||||
header.add_text("# define JSON_AMALGATED_H_INCLUDED")
|
header.add_text("# define JSON_AMALGATED_H_INCLUDED")
|
||||||
@@ -67,7 +67,6 @@ def amalgamate_source(source_top_dir=None,
|
|||||||
header.add_text("/// to prevent private header inclusion.")
|
header.add_text("/// to prevent private header inclusion.")
|
||||||
header.add_text("#define JSON_IS_AMALGAMATION")
|
header.add_text("#define JSON_IS_AMALGAMATION")
|
||||||
header.add_file("include/json/version.h")
|
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/config.h")
|
||||||
header.add_file("include/json/forwards.h")
|
header.add_file("include/json/forwards.h")
|
||||||
header.add_file("include/json/features.h")
|
header.add_file("include/json/features.h")
|
||||||
@@ -86,7 +85,7 @@ def amalgamate_source(source_top_dir=None,
|
|||||||
print("Amalgating forward header...")
|
print("Amalgating forward header...")
|
||||||
header = AmalgamationFile(source_top_dir)
|
header = AmalgamationFile(source_top_dir)
|
||||||
header.add_text("/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).")
|
header.add_text("/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).")
|
||||||
header.add_text('/// It is intended to be used with #include "%s"' % forward_header_include_path)
|
header.add_text("/// It is intented to be used with #include <%s>" % forward_header_include_path)
|
||||||
header.add_text("/// This header provides forward declaration for all JsonCpp types.")
|
header.add_text("/// This header provides forward declaration for all JsonCpp types.")
|
||||||
header.add_file("LICENSE", wrap_in_comment=True)
|
header.add_file("LICENSE", wrap_in_comment=True)
|
||||||
header.add_text("#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED")
|
header.add_text("#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED")
|
||||||
@@ -106,19 +105,15 @@ def amalgamate_source(source_top_dir=None,
|
|||||||
print("Amalgating source...")
|
print("Amalgating source...")
|
||||||
source = AmalgamationFile(source_top_dir)
|
source = AmalgamationFile(source_top_dir)
|
||||||
source.add_text("/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/).")
|
source.add_text("/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/).")
|
||||||
source.add_text('/// It is intended to be used with #include "%s"' % header_include_path)
|
source.add_text("/// It is intented to be used with #include <%s>" % header_include_path)
|
||||||
source.add_file("LICENSE", wrap_in_comment=True)
|
source.add_file("LICENSE", wrap_in_comment=True)
|
||||||
source.add_text("")
|
source.add_text("")
|
||||||
source.add_text('#include "%s"' % header_include_path)
|
source.add_text("#include <%s>" % header_include_path)
|
||||||
source.add_text("""
|
|
||||||
#ifndef JSON_IS_AMALGAMATION
|
|
||||||
#error "Compile with -I PATH_TO_JSON_DIRECTORY"
|
|
||||||
#endif
|
|
||||||
""")
|
|
||||||
source.add_text("")
|
source.add_text("")
|
||||||
lib_json = "src/lib_json"
|
lib_json = "src/lib_json"
|
||||||
source.add_file(os.path.join(lib_json, "json_tool.h"))
|
source.add_file(os.path.join(lib_json, "json_tool.h"))
|
||||||
source.add_file(os.path.join(lib_json, "json_reader.cpp"))
|
source.add_file(os.path.join(lib_json, "json_reader.cpp"))
|
||||||
|
source.add_file(os.path.join(lib_json, "json_batchallocator.h"))
|
||||||
source.add_file(os.path.join(lib_json, "json_valueiterator.inl"))
|
source.add_file(os.path.join(lib_json, "json_valueiterator.inl"))
|
||||||
source.add_file(os.path.join(lib_json, "json_value.cpp"))
|
source.add_file(os.path.join(lib_json, "json_value.cpp"))
|
||||||
source.add_file(os.path.join(lib_json, "json_writer.cpp"))
|
source.add_file(os.path.join(lib_json, "json_writer.cpp"))
|
||||||
|
22
appveyor.yml
22
appveyor.yml
@@ -1,22 +0,0 @@
|
|||||||
clone_folder: c:\projects\jsoncpp
|
|
||||||
|
|
||||||
environment:
|
|
||||||
matrix:
|
|
||||||
- CMAKE_GENERATOR: Visual Studio 12 2013
|
|
||||||
- CMAKE_GENERATOR: Visual Studio 12 2013 Win64
|
|
||||||
- CMAKE_GENERATOR: Visual Studio 14 2015
|
|
||||||
- CMAKE_GENERATOR: Visual Studio 14 2015 Win64
|
|
||||||
|
|
||||||
build_script:
|
|
||||||
- cmake --version
|
|
||||||
- cd c:\projects\jsoncpp
|
|
||||||
- cmake -G "%CMAKE_GENERATOR%" -DCMAKE_INSTALL_PREFIX=%CD:\=/%/install -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON .
|
|
||||||
- cmake --build . --config Release --target install
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
provider: GitHub
|
|
||||||
auth_token:
|
|
||||||
secure: K2Tp1q8pIZ7rs0Ot24ZMWuwr12Ev6Tc6QkhMjGQxoQG3ng1pXtgPasiJ45IDXGdg
|
|
||||||
on:
|
|
||||||
branch: master
|
|
||||||
appveyor_repo_tag: true
|
|
27
dev.makefile
27
dev.makefile
@@ -1,35 +1,14 @@
|
|||||||
# This is only for jsoncpp developers/contributors.
|
all: build test-amalgamate
|
||||||
# We use this to sign releases, generate documentation, etc.
|
|
||||||
VER?=$(shell cat version)
|
|
||||||
|
|
||||||
default:
|
|
||||||
@echo "VER=${VER}"
|
|
||||||
sign: jsoncpp-${VER}.tar.gz
|
|
||||||
gpg --armor --detach-sign $<
|
|
||||||
gpg --verify $<.asc
|
|
||||||
# Then upload .asc to the release.
|
|
||||||
jsoncpp-%.tar.gz:
|
|
||||||
curl https://github.com/open-source-parsers/jsoncpp/archive/$*.tar.gz -o $@
|
|
||||||
dox:
|
|
||||||
python doxybuild.py --doxygen=$$(which doxygen) --in doc/web_doxyfile.in
|
|
||||||
rsync -va --delete dist/doxygen/jsoncpp-api-html-${VER}/ ../jsoncpp-docs/doxygen/
|
|
||||||
# Then 'git add -A' and 'git push' in jsoncpp-docs.
|
|
||||||
build:
|
build:
|
||||||
mkdir -p build/debug
|
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
|
make -C build/debug
|
||||||
|
|
||||||
# Currently, this depends on include/json/version.h generated
|
# Currently, this depends on include/json/version.h generated
|
||||||
# by cmake.
|
# by cmake.
|
||||||
test-amalgamate:
|
test-amalgamate: build
|
||||||
python2.7 amalgamate.py
|
python2.7 amalgamate.py
|
||||||
python3.4 amalgamate.py
|
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/
|
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
|
@@ -1,6 +1 @@
|
|||||||
# Copyright 2010 Baptiste Lepilleur and The JsonCpp Authors
|
# module
|
||||||
# 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
|
|
@@ -1,33 +1,33 @@
|
|||||||
{
|
{
|
||||||
"cmake_variants" : [
|
"cmake_variants" : [
|
||||||
{"name": "generator",
|
{"name": "generator",
|
||||||
"generators": [
|
"generators": [
|
||||||
{"generator": [
|
{"generator": [
|
||||||
"Visual Studio 7 .NET 2003",
|
"Visual Studio 7 .NET 2003",
|
||||||
"Visual Studio 9 2008",
|
"Visual Studio 9 2008",
|
||||||
"Visual Studio 9 2008 Win64",
|
"Visual Studio 9 2008 Win64",
|
||||||
"Visual Studio 10",
|
"Visual Studio 10",
|
||||||
"Visual Studio 10 Win64",
|
"Visual Studio 10 Win64",
|
||||||
"Visual Studio 11",
|
"Visual Studio 11",
|
||||||
"Visual Studio 11 Win64"
|
"Visual Studio 11 Win64"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{"generator": ["MinGW Makefiles"],
|
{"generator": ["MinGW Makefiles"],
|
||||||
"env_prepend": [{"path": "c:/wut/prg/MinGW/bin"}]
|
"env_prepend": [{"path": "c:/wut/prg/MinGW/bin"}]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{"name": "shared_dll",
|
{"name": "shared_dll",
|
||||||
"variables": [
|
"variables": [
|
||||||
["BUILD_SHARED_LIBS=true"],
|
["JSONCPP_LIB_BUILD_SHARED=true"],
|
||||||
["BUILD_SHARED_LIBS=false"]
|
["JSONCPP_LIB_BUILD_SHARED=false"]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{"name": "build_type",
|
{"name": "build_type",
|
||||||
"build_types": [
|
"build_types": [
|
||||||
"debug",
|
"debug",
|
||||||
"release"
|
"release"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -1,26 +1,26 @@
|
|||||||
{
|
{
|
||||||
"cmake_variants" : [
|
"cmake_variants" : [
|
||||||
{"name": "generator",
|
{"name": "generator",
|
||||||
"generators": [
|
"generators": [
|
||||||
{"generator": [
|
{"generator": [
|
||||||
"Visual Studio 6",
|
"Visual Studio 6",
|
||||||
"Visual Studio 7",
|
"Visual Studio 7",
|
||||||
"Visual Studio 8 2005"
|
"Visual Studio 8 2005"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{"name": "shared_dll",
|
{"name": "shared_dll",
|
||||||
"variables": [
|
"variables": [
|
||||||
["BUILD_SHARED_LIBS=true"],
|
["JSONCPP_LIB_BUILD_SHARED=true"],
|
||||||
["BUILD_SHARED_LIBS=false"]
|
["JSONCPP_LIB_BUILD_SHARED=false"]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{"name": "build_type",
|
{"name": "build_type",
|
||||||
"build_types": [
|
"build_types": [
|
||||||
"debug",
|
"debug",
|
||||||
"release"
|
"release"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
# Copyright 2009 Baptiste Lepilleur and The JsonCpp Authors
|
# Baptiste Lepilleur, 2009
|
||||||
# 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 print_function
|
||||||
from dircache import listdir
|
from dircache import listdir
|
||||||
|
@@ -1,11 +1,5 @@
|
|||||||
# Copyright 2010 Baptiste Lepilleur and The JsonCpp Authors
|
|
||||||
# Distributed under MIT license, or public domain if desired and
|
|
||||||
# recognized in your jurisdiction.
|
|
||||||
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
|
||||||
|
|
||||||
def fix_source_eol(path, is_dry_run = True, verbose = True, eol = '\n'):
|
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)."""
|
"""Makes sure that all sources have the specified eol sequence (default: unix)."""
|
||||||
|
@@ -6,7 +6,7 @@ from __future__ import print_function
|
|||||||
# and ends with the first blank line.
|
# and ends with the first blank line.
|
||||||
LICENSE_BEGIN = "// Copyright "
|
LICENSE_BEGIN = "// Copyright "
|
||||||
|
|
||||||
BRIEF_LICENSE = LICENSE_BEGIN + """2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
BRIEF_LICENSE = LICENSE_BEGIN + """2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
|
@@ -1,8 +1,3 @@
|
|||||||
# Copyright 2010 Baptiste Lepilleur and The JsonCpp Authors
|
|
||||||
# Distributed under MIT license, or public domain if desired and
|
|
||||||
# recognized in your jurisdiction.
|
|
||||||
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
|
||||||
|
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
import os
|
import os
|
||||||
import tarfile
|
import tarfile
|
||||||
|
@@ -1946,7 +1946,8 @@ INCLUDE_FILE_PATTERNS = *.h
|
|||||||
PREDEFINED = "_MSC_VER=1400" \
|
PREDEFINED = "_MSC_VER=1400" \
|
||||||
_CPPRTTI \
|
_CPPRTTI \
|
||||||
_WIN32 \
|
_WIN32 \
|
||||||
JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
JSONCPP_DOC_EXCLUDE_IMPLEMENTATION \
|
||||||
|
JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
|
||||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
||||||
# tag can be used to specify a list of macro names that should be expanded. The
|
# tag can be used to specify a list of macro names that should be expanded. The
|
||||||
|
@@ -56,24 +56,20 @@ std::cin >> root;
|
|||||||
// You can also read into a particular sub-value.
|
// You can also read into a particular sub-value.
|
||||||
std::cin >> root["subtree"];
|
std::cin >> root["subtree"];
|
||||||
|
|
||||||
// Get the value of the member of root named 'encoding',
|
// Get the value of the member of root named 'encoding', return 'UTF-8' if there is no
|
||||||
// and return 'UTF-8' if there is no such member.
|
// such member.
|
||||||
std::string encoding = root.get("encoding", "UTF-8" ).asString();
|
std::string encoding = root.get("encoding", "UTF-8" ).asString();
|
||||||
|
// Get the value of the member of root named 'encoding'; return a 'null' value if
|
||||||
// Get the value of the member of root named 'plug-ins'; return a 'null' value if
|
|
||||||
// there is no such member.
|
// there is no such member.
|
||||||
const Json::Value plugins = root["plug-ins"];
|
const Json::Value plugins = root["plug-ins"];
|
||||||
|
for ( int index = 0; index < plugins.size(); ++index ) // Iterates over the sequence elements.
|
||||||
// Iterate over the sequence elements.
|
|
||||||
for ( int index = 0; index < plugins.size(); ++index )
|
|
||||||
loadPlugIn( plugins[index].asString() );
|
loadPlugIn( plugins[index].asString() );
|
||||||
|
|
||||||
// Try other datatypes. Some are auto-convertible to others.
|
|
||||||
foo::setIndentLength( root["indent"].get("length", 3).asInt() );
|
foo::setIndentLength( root["indent"].get("length", 3).asInt() );
|
||||||
foo::setIndentUseSpace( root["indent"].get("use_space", true).asBool() );
|
foo::setIndentUseSpace( root["indent"].get("use_space", true).asBool() );
|
||||||
|
|
||||||
// Since Json::Value has an implicit constructor for all value types, it is not
|
// Since Json::Value has implicit constructor for all value types, it is not
|
||||||
// necessary to explicitly construct the Json::Value object.
|
// necessary to explicitly construct the Json::Value object:
|
||||||
root["encoding"] = foo::getCurrentEncoding();
|
root["encoding"] = foo::getCurrentEncoding();
|
||||||
root["indent"]["length"] = foo::getCurrentIndentLength();
|
root["indent"]["length"] = foo::getCurrentIndentLength();
|
||||||
root["indent"]["use_space"] = foo::getCurrentIndentUseSpace();
|
root["indent"]["use_space"] = foo::getCurrentIndentUseSpace();
|
||||||
@@ -96,13 +92,13 @@ features without losing binary-compatibility.
|
|||||||
\code
|
\code
|
||||||
// For convenience, use `writeString()` with a specialized builder.
|
// For convenience, use `writeString()` with a specialized builder.
|
||||||
Json::StreamWriterBuilder wbuilder;
|
Json::StreamWriterBuilder wbuilder;
|
||||||
wbuilder["indentation"] = "\t";
|
wbuilder.settings_["indentation"] = "\t"; // simple Json::Value
|
||||||
std::string document = Json::writeString(wbuilder, root);
|
std::string document = Json::writeString(wbuilder, root);
|
||||||
|
|
||||||
// Here, using a specialized Builder, we discard comments and
|
// Here, using a specialized Builder, we discard comments and
|
||||||
// record errors as we parse.
|
// record errors as we parse.
|
||||||
Json::CharReaderBuilder rbuilder;
|
Json::CharReaderBuilder rbuilder;
|
||||||
rbuilder["collectComments"] = false;
|
rbuilder.settings_["collectComments"] = false; // simple Json::Value
|
||||||
std::string errs;
|
std::string errs;
|
||||||
bool ok = Json::parseFromStream(rbuilder, std::cin, &root, &errs);
|
bool ok = Json::parseFromStream(rbuilder, std::cin, &root, &errs);
|
||||||
\endcode
|
\endcode
|
||||||
@@ -156,7 +152,6 @@ Basically JsonCpp is licensed under MIT license, or public domain if desired
|
|||||||
and recognized in your jurisdiction.
|
and recognized in your jurisdiction.
|
||||||
|
|
||||||
\author Baptiste Lepilleur <blep@users.sourceforge.net> (originator)
|
\author Baptiste Lepilleur <blep@users.sourceforge.net> (originator)
|
||||||
\author Christopher Dunn <cdunn2001@gmail.com> (primary maintainer)
|
|
||||||
\version \include version
|
\version \include version
|
||||||
We make strong guarantees about binary-compatibility, consistent with
|
We make strong guarantees about binary-compatibility, consistent with
|
||||||
<a href="http://apr.apache.org/versioning.html">the Apache versioning scheme</a>.
|
<a href="http://apr.apache.org/versioning.html">the Apache versioning scheme</a>.
|
||||||
|
@@ -1946,7 +1946,8 @@ INCLUDE_FILE_PATTERNS = *.h
|
|||||||
PREDEFINED = "_MSC_VER=1400" \
|
PREDEFINED = "_MSC_VER=1400" \
|
||||||
_CPPRTTI \
|
_CPPRTTI \
|
||||||
_WIN32 \
|
_WIN32 \
|
||||||
JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
JSONCPP_DOC_EXCLUDE_IMPLEMENTATION \
|
||||||
|
JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
|
||||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
||||||
# tag can be used to specify a list of macro names that should be expanded. The
|
# tag can be used to specify a list of macro names that should be expanded. The
|
||||||
|
@@ -31,7 +31,7 @@ def find_program(*filenames):
|
|||||||
paths = os.environ.get('PATH', '').split(os.pathsep)
|
paths = os.environ.get('PATH', '').split(os.pathsep)
|
||||||
suffixes = ('win32' in sys.platform) and '.exe .com .bat .cmd' or ''
|
suffixes = ('win32' in sys.platform) and '.exe .com .bat .cmd' or ''
|
||||||
for filename in filenames:
|
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:
|
for directory in paths:
|
||||||
full_path = os.path.join(directory, name)
|
full_path = os.path.join(directory, name)
|
||||||
if os.path.isfile(full_path):
|
if os.path.isfile(full_path):
|
||||||
@@ -72,7 +72,7 @@ def run_cmd(cmd, silent=False):
|
|||||||
if silent:
|
if silent:
|
||||||
status, output = getstatusoutput(cmd)
|
status, output = getstatusoutput(cmd)
|
||||||
else:
|
else:
|
||||||
status, output = subprocess.call(cmd), ''
|
status, output = os.system(' '.join(cmd)), ''
|
||||||
if status:
|
if status:
|
||||||
msg = 'Error while %s ...\n\terror=%d, output="""%s"""' %(info, status, output)
|
msg = 'Error while %s ...\n\terror=%d, output="""%s"""' %(info, status, output)
|
||||||
raise Exception(msg)
|
raise Exception(msg)
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
FILE(GLOB INCLUDE_FILES "json/*.h")
|
FILE(GLOB INCLUDE_FILES "json/*.h")
|
||||||
INSTALL(FILES ${INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json)
|
INSTALL(FILES ${INCLUDE_FILES} DESTINATION ${INCLUDE_INSTALL_DIR}/json)
|
||||||
|
@@ -1,98 +0,0 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
|
||||||
// Distributed under MIT license, or public domain if desired and
|
|
||||||
// recognized in your jurisdiction.
|
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
|
||||||
|
|
||||||
#ifndef CPPTL_JSON_ALLOCATOR_H_INCLUDED
|
|
||||||
#define CPPTL_JSON_ALLOCATOR_H_INCLUDED
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#pragma pack(push, 8)
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
#endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED
|
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@@ -13,32 +13,20 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||||
|
|
||||||
/** It should not be possible for a maliciously designed file to
|
|
||||||
* cause an abort() or seg-fault, so these macros are used only
|
|
||||||
* for pre-condition violations and internal logic errors.
|
|
||||||
*/
|
|
||||||
#if JSON_USE_EXCEPTION
|
#if JSON_USE_EXCEPTION
|
||||||
|
#include <stdexcept>
|
||||||
// @todo <= add detail about condition in exception
|
#define JSON_ASSERT(condition) \
|
||||||
# define JSON_ASSERT(condition) \
|
assert(condition); // @todo <= change this into an exception throw
|
||||||
{if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
|
#define JSON_FAIL_MESSAGE(message) do{std::ostringstream oss; oss << message; throw std::runtime_error(oss.str());}while(0)
|
||||||
|
//#define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message)
|
||||||
# define JSON_FAIL_MESSAGE(message) \
|
|
||||||
{ \
|
|
||||||
JSONCPP_OSTRINGSTREAM oss; oss << message; \
|
|
||||||
Json::throwLogicError(oss.str()); \
|
|
||||||
abort(); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // JSON_USE_EXCEPTION
|
#else // JSON_USE_EXCEPTION
|
||||||
|
#define JSON_ASSERT(condition) assert(condition);
|
||||||
# define JSON_ASSERT(condition) assert(condition)
|
|
||||||
|
|
||||||
// The call to assert() will show the failure message in debug builds. In
|
// The call to assert() will show the failure message in debug builds. In
|
||||||
// release builds we abort, for a core-dump or debugger.
|
// release bugs we abort, for a core-dump or debugger.
|
||||||
# define JSON_FAIL_MESSAGE(message) \
|
#define JSON_FAIL_MESSAGE(message) \
|
||||||
{ \
|
{ \
|
||||||
JSONCPP_OSTRINGSTREAM oss; oss << message; \
|
std::ostringstream oss; oss << message; \
|
||||||
assert(false && oss.str().c_str()); \
|
assert(false && oss.str().c_str()); \
|
||||||
abort(); \
|
abort(); \
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
|
@@ -1,13 +1,10 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
|
|
||||||
#ifndef JSON_CONFIG_H_INCLUDED
|
#ifndef JSON_CONFIG_H_INCLUDED
|
||||||
#define JSON_CONFIG_H_INCLUDED
|
#define JSON_CONFIG_H_INCLUDED
|
||||||
#include <stddef.h>
|
|
||||||
#include <string> //typedef String
|
|
||||||
#include <stdint.h> //typedef int64_t, uint64_t
|
|
||||||
|
|
||||||
/// If defined, indicates that json library is embedded in CppTL library.
|
/// If defined, indicates that json library is embedded in CppTL library.
|
||||||
//# define JSON_IN_CPPTL 1
|
//# define JSON_IN_CPPTL 1
|
||||||
@@ -18,6 +15,17 @@
|
|||||||
/// std::map
|
/// std::map
|
||||||
/// as Value container.
|
/// as Value container.
|
||||||
//# define JSON_USE_CPPTL_SMALLMAP 1
|
//# define JSON_USE_CPPTL_SMALLMAP 1
|
||||||
|
/// If defined, indicates that Json specific container should be used
|
||||||
|
/// (hash table & simple deque container with customizable allocator).
|
||||||
|
/// THIS FEATURE IS STILL EXPERIMENTAL! There is know bugs: See #3177332
|
||||||
|
//# define JSON_VALUE_USE_INTERNAL_MAP 1
|
||||||
|
/// Force usage of standard new/malloc based allocator instead of memory pool
|
||||||
|
/// based allocator.
|
||||||
|
/// The memory pools allocator used optimization (initializing Value and
|
||||||
|
/// ValueInternalLink
|
||||||
|
/// as if it was a POD) that may cause some validation tool to report errors.
|
||||||
|
/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.
|
||||||
|
//# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1
|
||||||
|
|
||||||
// If non-zero, the library uses exceptions to report bad input instead of C
|
// If non-zero, the library uses exceptions to report bad input instead of C
|
||||||
// assertion macros. The default is to use exceptions.
|
// assertion macros. The default is to use exceptions.
|
||||||
@@ -40,12 +48,12 @@
|
|||||||
#ifdef JSON_IN_CPPTL
|
#ifdef JSON_IN_CPPTL
|
||||||
#define JSON_API CPPTL_API
|
#define JSON_API CPPTL_API
|
||||||
#elif defined(JSON_DLL_BUILD)
|
#elif defined(JSON_DLL_BUILD)
|
||||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
#if defined(_MSC_VER)
|
||||||
#define JSON_API __declspec(dllexport)
|
#define JSON_API __declspec(dllexport)
|
||||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||||
#endif // if defined(_MSC_VER)
|
#endif // if defined(_MSC_VER)
|
||||||
#elif defined(JSON_DLL)
|
#elif defined(JSON_DLL)
|
||||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
#if defined(_MSC_VER)
|
||||||
#define JSON_API __declspec(dllimport)
|
#define JSON_API __declspec(dllimport)
|
||||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||||
#endif // if defined(_MSC_VER)
|
#endif // if defined(_MSC_VER)
|
||||||
@@ -59,96 +67,26 @@
|
|||||||
// Storages, and 64 bits integer support is disabled.
|
// Storages, and 64 bits integer support is disabled.
|
||||||
// #define JSON_NO_INT64 1
|
// #define JSON_NO_INT64 1
|
||||||
|
|
||||||
#if defined(_MSC_VER) // MSVC
|
#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
|
||||||
# if _MSC_VER <= 1200 // MSVC 6
|
// Microsoft Visual Studio 6 only support conversion from __int64 to double
|
||||||
// Microsoft Visual Studio 6 only support conversion from __int64 to double
|
// (no conversion from unsigned __int64).
|
||||||
// (no conversion from unsigned __int64).
|
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||||
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
|
||||||
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
|
// characters in the debug information)
|
||||||
// characters in the debug information)
|
// All projects I've ever seen with VS6 were using this globally (not bothering
|
||||||
// All projects I've ever seen with VS6 were using this globally (not bothering
|
// with pragma push/pop).
|
||||||
// with pragma push/pop).
|
#pragma warning(disable : 4786)
|
||||||
# pragma warning(disable : 4786)
|
#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
|
||||||
# endif // MSVC 6
|
|
||||||
|
|
||||||
# if _MSC_VER >= 1500 // MSVC 2008
|
#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
|
||||||
/// Indicates that the following function is deprecated.
|
/// Indicates that the following function is deprecated.
|
||||||
# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
#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
|
|
||||||
# define JSONCPP_NOEXCEPT noexcept
|
|
||||||
#elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
|
|
||||||
# define JSONCPP_OVERRIDE override
|
|
||||||
# define JSONCPP_NOEXCEPT throw()
|
|
||||||
#elif defined(_MSC_VER) && _MSC_VER >= 1900
|
|
||||||
# define JSONCPP_OVERRIDE override
|
|
||||||
# define JSONCPP_NOEXCEPT noexcept
|
|
||||||
#else
|
|
||||||
# define JSONCPP_OVERRIDE
|
|
||||||
# define JSONCPP_NOEXCEPT throw()
|
|
||||||
#endif
|
#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
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __clang__
|
|
||||||
# if __has_extension(attribute_deprecated_with_message)
|
|
||||||
# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
|
||||||
# endif
|
|
||||||
#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)
|
#if !defined(JSONCPP_DEPRECATED)
|
||||||
#define JSONCPP_DEPRECATED(message)
|
#define JSONCPP_DEPRECATED(message)
|
||||||
#endif // if !defined(JSONCPP_DEPRECATED)
|
#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 {
|
namespace Json {
|
||||||
typedef int Int;
|
typedef int Int;
|
||||||
typedef unsigned int UInt;
|
typedef unsigned int UInt;
|
||||||
@@ -162,26 +100,13 @@ typedef unsigned int LargestUInt;
|
|||||||
typedef __int64 Int64;
|
typedef __int64 Int64;
|
||||||
typedef unsigned __int64 UInt64;
|
typedef unsigned __int64 UInt64;
|
||||||
#else // if defined(_MSC_VER) // Other platforms, use long long
|
#else // if defined(_MSC_VER) // Other platforms, use long long
|
||||||
typedef int64_t Int64;
|
typedef long long int Int64;
|
||||||
typedef uint64_t UInt64;
|
typedef unsigned long long int UInt64;
|
||||||
#endif // if defined(_MSC_VER)
|
#endif // if defined(_MSC_VER)
|
||||||
typedef Int64 LargestInt;
|
typedef Int64 LargestInt;
|
||||||
typedef UInt64 LargestUInt;
|
typedef UInt64 LargestUInt;
|
||||||
#define JSON_HAS_INT64
|
#define JSON_HAS_INT64
|
||||||
#endif // if defined(JSON_NO_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
|
} // end namespace Json
|
||||||
|
|
||||||
#endif // JSON_CONFIG_H_INCLUDED
|
#endif // JSON_CONFIG_H_INCLUDED
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@@ -10,8 +10,6 @@
|
|||||||
#include "forwards.h"
|
#include "forwards.h"
|
||||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||||
|
|
||||||
#pragma pack(push, 8)
|
|
||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
|
|
||||||
/** \brief Configuration passed to reader and writer.
|
/** \brief Configuration passed to reader and writer.
|
||||||
@@ -46,16 +44,8 @@ public:
|
|||||||
/// \c true if root must be either an array or an object value. Default: \c
|
/// \c true if root must be either an array or an object value. Default: \c
|
||||||
/// false.
|
/// false.
|
||||||
bool strictRoot_;
|
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
|
} // namespace Json
|
||||||
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
#endif // CPPTL_JSON_FEATURES_H_INCLUDED
|
#endif // CPPTL_JSON_FEATURES_H_INCLUDED
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@@ -31,6 +31,12 @@ class Value;
|
|||||||
class ValueIteratorBase;
|
class ValueIteratorBase;
|
||||||
class ValueIterator;
|
class ValueIterator;
|
||||||
class ValueConstIterator;
|
class ValueConstIterator;
|
||||||
|
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
class ValueMapAllocator;
|
||||||
|
class ValueInternalLink;
|
||||||
|
class ValueInternalArray;
|
||||||
|
class ValueInternalMap;
|
||||||
|
#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
|
||||||
} // namespace Json
|
} // namespace Json
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@@ -23,8 +23,6 @@
|
|||||||
#pragma warning(disable : 4251)
|
#pragma warning(disable : 4251)
|
||||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
|
|
||||||
#pragma pack(push, 8)
|
|
||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
|
|
||||||
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
|
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
|
||||||
@@ -32,23 +30,11 @@ namespace Json {
|
|||||||
*
|
*
|
||||||
* \deprecated Use CharReader and CharReaderBuilder.
|
* \deprecated Use CharReader and CharReaderBuilder.
|
||||||
*/
|
*/
|
||||||
class JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead") JSON_API Reader {
|
class JSON_API Reader {
|
||||||
public:
|
public:
|
||||||
typedef char Char;
|
typedef char Char;
|
||||||
typedef const Char* Location;
|
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
|
/** \brief Constructs a Reader allowing all features
|
||||||
* for parsing.
|
* for parsing.
|
||||||
*/
|
*/
|
||||||
@@ -101,7 +87,7 @@ public:
|
|||||||
|
|
||||||
/// \brief Parse from input stream.
|
/// \brief Parse from input stream.
|
||||||
/// \see Json::operator>>(std::istream&, Json::Value&).
|
/// \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
|
/** \brief Returns a user friendly string that list errors in the parsed
|
||||||
* document.
|
* document.
|
||||||
@@ -112,8 +98,8 @@ public:
|
|||||||
* during parsing.
|
* during parsing.
|
||||||
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
|
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
|
||||||
*/
|
*/
|
||||||
JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
|
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
|
/** \brief Returns a user friendly string that list errors in the parsed
|
||||||
* document.
|
* document.
|
||||||
@@ -123,39 +109,7 @@ public:
|
|||||||
* occurred
|
* occurred
|
||||||
* during parsing.
|
* during parsing.
|
||||||
*/
|
*/
|
||||||
JSONCPP_STRING getFormattedErrorMessages() const;
|
std::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;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum TokenType {
|
enum TokenType {
|
||||||
@@ -185,7 +139,7 @@ private:
|
|||||||
class ErrorInfo {
|
class ErrorInfo {
|
||||||
public:
|
public:
|
||||||
Token token_;
|
Token token_;
|
||||||
JSONCPP_STRING message_;
|
std::string message_;
|
||||||
Location extra_;
|
Location extra_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -205,7 +159,7 @@ private:
|
|||||||
bool decodeNumber(Token& token);
|
bool decodeNumber(Token& token);
|
||||||
bool decodeNumber(Token& token, Value& decoded);
|
bool decodeNumber(Token& token, Value& decoded);
|
||||||
bool decodeString(Token& token);
|
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);
|
||||||
bool decodeDouble(Token& token, Value& decoded);
|
bool decodeDouble(Token& token, Value& decoded);
|
||||||
bool decodeUnicodeCodePoint(Token& token,
|
bool decodeUnicodeCodePoint(Token& token,
|
||||||
@@ -216,9 +170,9 @@ private:
|
|||||||
Location& current,
|
Location& current,
|
||||||
Location end,
|
Location end,
|
||||||
unsigned int& unicode);
|
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 recoverFromError(TokenType skipUntilToken);
|
||||||
bool addErrorAndRecover(const JSONCPP_STRING& message,
|
bool addErrorAndRecover(const std::string& message,
|
||||||
Token& token,
|
Token& token,
|
||||||
TokenType skipUntilToken);
|
TokenType skipUntilToken);
|
||||||
void skipUntilSpace();
|
void skipUntilSpace();
|
||||||
@@ -226,23 +180,20 @@ private:
|
|||||||
Char getNextChar();
|
Char getNextChar();
|
||||||
void
|
void
|
||||||
getLocationLineAndColumn(Location location, int& line, int& column) const;
|
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 addComment(Location begin, Location end, CommentPlacement placement);
|
||||||
void skipCommentTokens(Token& token);
|
void skipCommentTokens(Token& token);
|
||||||
|
|
||||||
static bool containsNewLine(Location begin, Location end);
|
|
||||||
static JSONCPP_STRING normalizeEOL(Location begin, Location end);
|
|
||||||
|
|
||||||
typedef std::stack<Value*> Nodes;
|
typedef std::stack<Value*> Nodes;
|
||||||
Nodes nodes_;
|
Nodes nodes_;
|
||||||
Errors errors_;
|
Errors errors_;
|
||||||
JSONCPP_STRING document_;
|
std::string document_;
|
||||||
Location begin_;
|
Location begin_;
|
||||||
Location end_;
|
Location end_;
|
||||||
Location current_;
|
Location current_;
|
||||||
Location lastValueEnd_;
|
Location lastValueEnd_;
|
||||||
Value* lastValue_;
|
Value* lastValue_;
|
||||||
JSONCPP_STRING commentsBefore_;
|
std::string commentsBefore_;
|
||||||
Features features_;
|
Features features_;
|
||||||
bool collectComments_;
|
bool collectComments_;
|
||||||
}; // Reader
|
}; // Reader
|
||||||
@@ -271,11 +222,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool parse(
|
virtual bool parse(
|
||||||
char const* beginDoc, char const* endDoc,
|
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:
|
public:
|
||||||
virtual ~Factory() {}
|
|
||||||
/** \brief Allocate a CharReader via operator new().
|
/** \brief Allocate a CharReader via operator new().
|
||||||
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
||||||
*/
|
*/
|
||||||
@@ -285,13 +235,15 @@ public:
|
|||||||
|
|
||||||
/** \brief Build a CharReader implementation.
|
/** \brief Build a CharReader implementation.
|
||||||
|
|
||||||
|
\deprecated This is experimental and will be altered before the next release.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
\code
|
\code
|
||||||
using namespace Json;
|
using namespace Json;
|
||||||
CharReaderBuilder builder;
|
CharReaderBuilder builder;
|
||||||
builder["collectComments"] = false;
|
builder.settings_["collectComments"] = false;
|
||||||
Value value;
|
Value value;
|
||||||
JSONCPP_STRING errs;
|
std::string errs;
|
||||||
bool ok = parseFromStream(builder, std::cin, &value, &errs);
|
bool ok = parseFromStream(builder, std::cin, &value, &errs);
|
||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
@@ -302,33 +254,21 @@ public:
|
|||||||
/** Configuration of this builder.
|
/** Configuration of this builder.
|
||||||
These are case-sensitive.
|
These are case-sensitive.
|
||||||
Available settings (case-sensitive):
|
Available settings (case-sensitive):
|
||||||
- `"collectComments": false or true`
|
- "collectComments": false or true
|
||||||
- true to collect comment and allow writing them
|
- true to collect comment and allow writing them
|
||||||
back during serialization, false to discard comments.
|
back during serialization, false to discard comments.
|
||||||
This parameter is ignored if allowComments is false.
|
This parameter is ignored if allowComments is false.
|
||||||
- `"allowComments": false or true`
|
- "allowComments": false or true
|
||||||
- true if comments are allowed.
|
- true if comments are allowed.
|
||||||
- `"strictRoot": false or true`
|
- "strictRoot": false or true
|
||||||
- true if root must be either an array or an object value
|
- true if root must be either an array or an object value
|
||||||
- `"allowDroppedNullPlaceholders": false or true`
|
- "allowDroppedNullPlaceholders": false or true
|
||||||
- true if dropped null placeholders are allowed. (See StreamWriterBuilder.)
|
- true if dropped null placeholders are allowed. (See StreamWriterBuilder.)
|
||||||
- `"allowNumericKeys": false or true`
|
- "allowNumericKeys": false or true
|
||||||
- true if numeric object keys are allowed.
|
- true if numeric object keys are allowed.
|
||||||
- `"allowSingleQuotes": false or true`
|
- "stackLimit": integer
|
||||||
- true if '' are allowed for strings (both keys and values)
|
|
||||||
- `"stackLimit": integer`
|
|
||||||
- Exceeding stackLimit (recursive depth of `readValue()`) will
|
|
||||||
cause an exception.
|
|
||||||
- This is a security issue (seg-faults caused by deeply nested JSON),
|
- This is a security issue (seg-faults caused by deeply nested JSON),
|
||||||
so the default is low.
|
so the default is low.
|
||||||
- `"failIfExtra": false or true`
|
|
||||||
- If true, `parse()` returns false when extra non-whitespace trails
|
|
||||||
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
|
You can examine 'settings_` yourself
|
||||||
to see the defaults. You can also write and read them just like any
|
to see the defaults. You can also write and read them just like any
|
||||||
@@ -338,29 +278,24 @@ public:
|
|||||||
Json::Value settings_;
|
Json::Value settings_;
|
||||||
|
|
||||||
CharReaderBuilder();
|
CharReaderBuilder();
|
||||||
~CharReaderBuilder() JSONCPP_OVERRIDE;
|
virtual ~CharReaderBuilder();
|
||||||
|
|
||||||
CharReader* newCharReader() const JSONCPP_OVERRIDE;
|
virtual CharReader* newCharReader() const;
|
||||||
|
|
||||||
/** \return true if 'settings' are legal and consistent;
|
/** \return true if 'settings' are legal and consistent;
|
||||||
* otherwise, indicate bad settings via 'invalid'.
|
* otherwise, indicate bad settings via 'invalid'.
|
||||||
*/
|
*/
|
||||||
bool validate(Json::Value* invalid) const;
|
bool validate(Json::Value* invalid) const;
|
||||||
|
|
||||||
/** A simple way to update a specific setting.
|
|
||||||
*/
|
|
||||||
Value& operator[](JSONCPP_STRING key);
|
|
||||||
|
|
||||||
/** Called by ctor, but you can use this to reset settings_.
|
/** Called by ctor, but you can use this to reset settings_.
|
||||||
* \pre 'settings' != NULL (but Json::null is fine)
|
* \pre 'settings' != NULL (but Json::null is fine)
|
||||||
* \remark Defaults:
|
* \remark Defaults:
|
||||||
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
|
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
|
||||||
*/
|
*/
|
||||||
static void setDefaults(Json::Value* settings);
|
static void setDefaults(Json::Value* settings);
|
||||||
/** Same as old Features::strictMode().
|
/** Same as old Features::strictMode().
|
||||||
* \pre 'settings' != NULL (but Json::null is fine)
|
* \pre 'settings' != NULL (but Json::null is fine)
|
||||||
* \remark Defaults:
|
* \remark Defaults:
|
||||||
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
|
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
|
||||||
*/
|
*/
|
||||||
static void strictMode(Json::Value* settings);
|
static void strictMode(Json::Value* settings);
|
||||||
};
|
};
|
||||||
@@ -369,9 +304,9 @@ public:
|
|||||||
* Someday we might have a real StreamReader, but for now this
|
* Someday we might have a real StreamReader, but for now this
|
||||||
* is convenient.
|
* is convenient.
|
||||||
*/
|
*/
|
||||||
bool JSON_API parseFromStream(
|
bool parseFromStream(
|
||||||
CharReader::Factory const&,
|
CharReader::Factory const&,
|
||||||
JSONCPP_ISTREAM&,
|
std::istream&,
|
||||||
Value* root, std::string* errs);
|
Value* root, std::string* errs);
|
||||||
|
|
||||||
/** \brief Read from 'sin' into 'root'.
|
/** \brief Read from 'sin' into 'root'.
|
||||||
@@ -398,12 +333,10 @@ bool JSON_API parseFromStream(
|
|||||||
\throw std::exception on parse error.
|
\throw std::exception on parse error.
|
||||||
\see Json::operator<<()
|
\see Json::operator<<()
|
||||||
*/
|
*/
|
||||||
JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
|
JSON_API std::istream& operator>>(std::istream&, Value&);
|
||||||
|
|
||||||
} // namespace Json
|
} // namespace Json
|
||||||
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <exception>
|
|
||||||
|
|
||||||
#ifndef JSON_USE_CPPTL_SMALLMAP
|
#ifndef JSON_USE_CPPTL_SMALLMAP
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -22,19 +21,6 @@
|
|||||||
#include <cpptl/forwards.h>
|
#include <cpptl/forwards.h>
|
||||||
#endif
|
#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
|
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
||||||
// be used by...
|
// be used by...
|
||||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
@@ -42,52 +28,10 @@
|
|||||||
#pragma warning(disable : 4251)
|
#pragma warning(disable : 4251)
|
||||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
|
|
||||||
#pragma pack(push, 8)
|
|
||||||
|
|
||||||
/** \brief JSON (JavaScript Object Notation).
|
/** \brief JSON (JavaScript Object Notation).
|
||||||
*/
|
*/
|
||||||
namespace Json {
|
namespace Json {
|
||||||
|
|
||||||
/** Base class for all exceptions we throw.
|
|
||||||
*
|
|
||||||
* 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() JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
|
|
||||||
char const* what() const JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
|
|
||||||
protected:
|
|
||||||
JSONCPP_STRING msg_;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 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);
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 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);
|
|
||||||
};
|
|
||||||
|
|
||||||
/// used internally
|
|
||||||
JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg);
|
|
||||||
/// used internally
|
|
||||||
JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg);
|
|
||||||
|
|
||||||
/** \brief Type of the value held by a Value object.
|
/** \brief Type of the value held by a Value object.
|
||||||
*/
|
*/
|
||||||
enum ValueType {
|
enum ValueType {
|
||||||
@@ -130,14 +74,14 @@ enum CommentPlacement {
|
|||||||
*/
|
*/
|
||||||
class JSON_API StaticString {
|
class JSON_API StaticString {
|
||||||
public:
|
public:
|
||||||
explicit StaticString(const char* czstring) : c_str_(czstring) {}
|
explicit StaticString(const char* czstring) : str_(czstring) {}
|
||||||
|
|
||||||
operator const char*() const { return c_str_; }
|
operator const char*() const { return str_; }
|
||||||
|
|
||||||
const char* c_str() const { return c_str_; }
|
const char* c_str() const { return str_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char* c_str_;
|
const char* str_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
|
/** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
|
||||||
@@ -155,29 +99,28 @@ private:
|
|||||||
* The type of the held value is represented by a #ValueType and
|
* The type of the held value is represented by a #ValueType and
|
||||||
* can be obtained using type().
|
* can be obtained using type().
|
||||||
*
|
*
|
||||||
* Values of an #objectValue or #arrayValue can be accessed using operator[]()
|
* values of an #objectValue or #arrayValue can be accessed using operator[]()
|
||||||
* methods.
|
*methods.
|
||||||
* Non-const methods will automatically create the a #nullValue element
|
* Non const methods will automatically create the a #nullValue element
|
||||||
* if it does not exist.
|
* if it does not exist.
|
||||||
* The sequence of an #arrayValue will be automatically resized and initialized
|
* The sequence of an #arrayValue will be automatically resize and initialized
|
||||||
* with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
|
* with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
|
||||||
*
|
*
|
||||||
* The get() methods can be used to obtain default value in the case the
|
* The get() methods can be used to obtanis default value in the case the
|
||||||
* required element does not exist.
|
*required element
|
||||||
|
* does not exist.
|
||||||
*
|
*
|
||||||
* It is possible to iterate over the list of a #objectValue values using
|
* It is possible to iterate over the list of a #objectValue values using
|
||||||
* the getMemberNames() method.
|
* the getMemberNames() method.
|
||||||
*
|
|
||||||
* \note #Value string-length fit in size_t, but keys must be < 2^30.
|
|
||||||
* (The reason is an implementation detail.) A #CharReader will raise an
|
|
||||||
* exception if a bound is exceeded to avoid security holes in your app,
|
|
||||||
* but the Value API does *not* check bounds. That is the responsibility
|
|
||||||
* of the caller.
|
|
||||||
*/
|
*/
|
||||||
class JSON_API Value {
|
class JSON_API Value {
|
||||||
friend class ValueIteratorBase;
|
friend class ValueIteratorBase;
|
||||||
|
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
friend class ValueInternalLink;
|
||||||
|
friend class ValueInternalMap;
|
||||||
|
#endif
|
||||||
public:
|
public:
|
||||||
typedef std::vector<JSONCPP_STRING> Members;
|
typedef std::vector<std::string> Members;
|
||||||
typedef ValueIterator iterator;
|
typedef ValueIterator iterator;
|
||||||
typedef ValueConstIterator const_iterator;
|
typedef ValueConstIterator const_iterator;
|
||||||
typedef Json::UInt UInt;
|
typedef Json::UInt UInt;
|
||||||
@@ -190,10 +133,11 @@ public:
|
|||||||
typedef Json::LargestUInt LargestUInt;
|
typedef Json::LargestUInt LargestUInt;
|
||||||
typedef Json::ArrayIndex ArrayIndex;
|
typedef Json::ArrayIndex ArrayIndex;
|
||||||
|
|
||||||
static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value().
|
static const Value& nullRef;
|
||||||
static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null
|
#if !defined(__ARMEL__)
|
||||||
static Value const& nullSingleton(); ///< Prefer this to null or nullRef.
|
/// \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.
|
/// Minimum signed integer value that can be stored in a Json::Value.
|
||||||
static const LargestInt minLargestInt;
|
static const LargestInt minLargestInt;
|
||||||
/// Maximum signed integer value that can be stored in a Json::Value.
|
/// Maximum signed integer value that can be stored in a Json::Value.
|
||||||
@@ -219,6 +163,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
class CZString {
|
class CZString {
|
||||||
public:
|
public:
|
||||||
enum DuplicationPolicy {
|
enum DuplicationPolicy {
|
||||||
@@ -227,39 +172,20 @@ private:
|
|||||||
duplicateOnCopy
|
duplicateOnCopy
|
||||||
};
|
};
|
||||||
CZString(ArrayIndex index);
|
CZString(ArrayIndex index);
|
||||||
CZString(char const* str, unsigned length, DuplicationPolicy allocate);
|
CZString(const char* cstr, DuplicationPolicy allocate);
|
||||||
CZString(CZString const& other);
|
CZString(const CZString& other);
|
||||||
#if JSON_HAS_RVALUE_REFERENCES
|
|
||||||
CZString(CZString&& other);
|
|
||||||
#endif
|
|
||||||
~CZString();
|
~CZString();
|
||||||
CZString& operator=(const CZString& other);
|
CZString &operator=(const CZString &other);
|
||||||
|
bool operator<(const CZString& other) const;
|
||||||
#if JSON_HAS_RVALUE_REFERENCES
|
bool operator==(const CZString& other) const;
|
||||||
CZString& operator=(CZString&& other);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool operator<(CZString const& other) const;
|
|
||||||
bool operator==(CZString const& other) const;
|
|
||||||
ArrayIndex index() const;
|
ArrayIndex index() const;
|
||||||
//const char* c_str() const; ///< \deprecated
|
const char* c_str() const;
|
||||||
char const* data() const;
|
|
||||||
unsigned length() const;
|
|
||||||
bool isStaticString() const;
|
bool isStaticString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void swap(CZString& other);
|
void swap(CZString& other);
|
||||||
|
const char* cstr_;
|
||||||
struct StringStorage {
|
ArrayIndex index_;
|
||||||
unsigned policy_: 2;
|
|
||||||
unsigned length_: 30; // 1GB max
|
|
||||||
};
|
|
||||||
|
|
||||||
char const* cstr_; // actually, a prefixed string, unless policy is noDup
|
|
||||||
union {
|
|
||||||
ArrayIndex index_;
|
|
||||||
StringStorage storage_;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -268,6 +194,7 @@ public:
|
|||||||
#else
|
#else
|
||||||
typedef CppTL::SmallMap<CZString, Value> ObjectValues;
|
typedef CppTL::SmallMap<CZString, Value> ObjectValues;
|
||||||
#endif // ifndef JSON_USE_CPPTL_SMALLMAP
|
#endif // ifndef JSON_USE_CPPTL_SMALLMAP
|
||||||
|
#endif // ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -294,51 +221,35 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
Value(UInt64 value);
|
Value(UInt64 value);
|
||||||
#endif // if defined(JSON_HAS_INT64)
|
#endif // if defined(JSON_HAS_INT64)
|
||||||
Value(double value);
|
Value(double value);
|
||||||
Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
|
Value(const char* value);
|
||||||
Value(const char* begin, const char* end); ///< Copy all, incl zeroes.
|
Value(const char* beginValue, const char* endValue);
|
||||||
/** \brief Constructs a value from a static string.
|
/** \brief Constructs a value from a static string.
|
||||||
|
|
||||||
* Like other value string constructor but do not duplicate the string for
|
* Like other value string constructor but do not duplicate the string for
|
||||||
* internal storage. The given string must remain alive after the call to this
|
* internal storage. The given string must remain alive after the call to this
|
||||||
* constructor.
|
* constructor.
|
||||||
* \note This works only for null-terminated strings. (We cannot change the
|
|
||||||
* size of this class, so we have nowhere to store the length,
|
|
||||||
* which might be computed later for various operations.)
|
|
||||||
*
|
|
||||||
* Example of usage:
|
* Example of usage:
|
||||||
* \code
|
* \code
|
||||||
* static StaticString foo("some text");
|
* Json::Value aValue( StaticString("some text") );
|
||||||
* Json::Value aValue(foo);
|
|
||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
Value(const StaticString& value);
|
Value(const StaticString& value);
|
||||||
Value(const JSONCPP_STRING& value); ///< Copy data() til size(). Embedded zeroes too.
|
Value(const std::string& value);
|
||||||
#ifdef JSON_USE_CPPTL
|
#ifdef JSON_USE_CPPTL
|
||||||
Value(const CppTL::ConstString& value);
|
Value(const CppTL::ConstString& value);
|
||||||
#endif
|
#endif
|
||||||
Value(bool value);
|
Value(bool value);
|
||||||
/// Deep copy.
|
/// Deep copy.
|
||||||
Value(const Value& other);
|
Value(const Value& other);
|
||||||
#if JSON_HAS_RVALUE_REFERENCES
|
|
||||||
/// Move constructor
|
|
||||||
Value(Value&& other);
|
|
||||||
#endif
|
|
||||||
~Value();
|
~Value();
|
||||||
|
|
||||||
/// Deep copy, then swap(other).
|
// Deep copy, then swap(other).
|
||||||
/// \note Over-write existing comments. To preserve comments, use #swapPayload().
|
Value &operator=(const Value &other);
|
||||||
Value& operator=(Value other);
|
|
||||||
|
|
||||||
/// Swap everything.
|
/// Swap everything.
|
||||||
void swap(Value& other);
|
void swap(Value& other);
|
||||||
/// Swap values but leave comments and source offsets in place.
|
/// Swap values but leave comments and source offsets in place.
|
||||||
void swapPayload(Value& other);
|
void swapPayload(Value& other);
|
||||||
|
|
||||||
/// copy everything.
|
|
||||||
void copy(const Value& other);
|
|
||||||
/// copy values but leave comments and source offsets in place.
|
|
||||||
void copyPayload(const Value& other);
|
|
||||||
|
|
||||||
ValueType type() const;
|
ValueType type() const;
|
||||||
|
|
||||||
/// Compare payload only, not comments etc.
|
/// Compare payload only, not comments etc.
|
||||||
@@ -350,16 +261,8 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
bool operator!=(const Value& other) const;
|
bool operator!=(const Value& other) const;
|
||||||
int compare(const Value& other) const;
|
int compare(const Value& other) const;
|
||||||
|
|
||||||
const char* asCString() const; ///< Embedded zeroes could cause you trouble!
|
const char* asCString() const;
|
||||||
#if JSONCPP_USING_SECURE_MEMORY
|
std::string asString() const;
|
||||||
unsigned getCStringLength() const; //Allows you to understand the length of the CString
|
|
||||||
#endif
|
|
||||||
JSONCPP_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;
|
|
||||||
#ifdef JSON_USE_CPPTL
|
#ifdef JSON_USE_CPPTL
|
||||||
CppTL::ConstString asConstString() const;
|
CppTL::ConstString asConstString() const;
|
||||||
#endif
|
#endif
|
||||||
@@ -449,28 +352,20 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
/// Equivalent to jsonvalue[jsonvalue.size()] = value;
|
/// Equivalent to jsonvalue[jsonvalue.size()] = value;
|
||||||
Value& append(const Value& value);
|
Value& append(const Value& value);
|
||||||
|
|
||||||
#if JSON_HAS_RVALUE_REFERENCES
|
|
||||||
Value& append(Value&& value);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Access an object value by name, create a null member if it does not exist.
|
/// Access an object value by name, create a null member if it does not exist.
|
||||||
/// \note Because of our implementation, keys are limited to 2^30 -1 chars.
|
|
||||||
/// Exceeding that will cause an exception.
|
|
||||||
Value& operator[](const char* key);
|
Value& operator[](const char* key);
|
||||||
/// Access an object value by name, returns null if there is no member with
|
/// Access an object value by name, returns null if there is no member with
|
||||||
/// that name.
|
/// that name.
|
||||||
const Value& operator[](const char* key) const;
|
const Value& operator[](const char* key) const;
|
||||||
/// Access an object value by name, create a null member if it does not exist.
|
/// Access an object value by name, create a null member if it does not exist.
|
||||||
/// \param key may contain embedded nulls.
|
Value& operator[](const std::string& key);
|
||||||
Value& operator[](const JSONCPP_STRING& key);
|
|
||||||
/// Access an object value by name, returns null if there is no member with
|
/// Access an object value by name, returns null if there is no member with
|
||||||
/// that name.
|
/// that name.
|
||||||
/// \param key may contain embedded nulls.
|
const Value& operator[](const std::string& key) const;
|
||||||
const Value& operator[](const JSONCPP_STRING& key) const;
|
|
||||||
/** \brief Access an object value by name, create a null member if it does not
|
/** \brief Access an object value by name, create a null member if it does not
|
||||||
exist.
|
exist.
|
||||||
|
|
||||||
* If the object has no entry for that name, then the member name used to store
|
* If the object as no entry for that name, then the member name used to store
|
||||||
* the new entry is not duplicated.
|
* the new entry is not duplicated.
|
||||||
* Example of use:
|
* Example of use:
|
||||||
* \code
|
* \code
|
||||||
@@ -488,29 +383,13 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
const Value& operator[](const CppTL::ConstString& key) const;
|
const Value& operator[](const CppTL::ConstString& key) const;
|
||||||
#endif
|
#endif
|
||||||
/// Return the member named key if it exist, defaultValue otherwise.
|
/// Return the member named key if it exist, defaultValue otherwise.
|
||||||
/// \note deep copy
|
|
||||||
Value get(const char* key, const Value& defaultValue) const;
|
Value get(const char* key, const Value& defaultValue) const;
|
||||||
/// Return the member named key if it exist, defaultValue otherwise.
|
/// Return the member named key if it exist, defaultValue otherwise.
|
||||||
/// \note deep copy
|
Value get(const std::string& key, const Value& defaultValue) const;
|
||||||
/// \note key may contain embedded nulls.
|
|
||||||
Value get(const char* begin, 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;
|
|
||||||
#ifdef JSON_USE_CPPTL
|
#ifdef JSON_USE_CPPTL
|
||||||
/// Return the member named key if it exist, defaultValue otherwise.
|
/// Return the member named key if it exist, defaultValue otherwise.
|
||||||
/// \note deep copy
|
|
||||||
Value get(const CppTL::ConstString& key, const Value& defaultValue) const;
|
Value get(const CppTL::ConstString& key, const Value& defaultValue) const;
|
||||||
#endif
|
#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;
|
|
||||||
/// Most general and efficient version of object-mutators.
|
|
||||||
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
|
|
||||||
/// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
|
|
||||||
Value const* demand(char const* begin, char const* end);
|
|
||||||
/// \brief Remove and return the named member.
|
/// \brief Remove and return the named member.
|
||||||
///
|
///
|
||||||
/// Do nothing if it did not exist.
|
/// Do nothing if it did not exist.
|
||||||
@@ -518,25 +397,16 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
/// \pre type() is objectValue or nullValue
|
/// \pre type() is objectValue or nullValue
|
||||||
/// \post type() is unchanged
|
/// \post type() is unchanged
|
||||||
/// \deprecated
|
/// \deprecated
|
||||||
JSONCPP_DEPRECATED("")
|
|
||||||
Value removeMember(const char* key);
|
Value removeMember(const char* key);
|
||||||
/// Same as removeMember(const char*)
|
/// Same as removeMember(const char*)
|
||||||
/// \param key may contain embedded nulls.
|
|
||||||
/// \deprecated
|
/// \deprecated
|
||||||
JSONCPP_DEPRECATED("")
|
Value removeMember(const std::string& key);
|
||||||
Value removeMember(const JSONCPP_STRING& key);
|
|
||||||
/// Same as removeMember(const char* begin, const char* end, Value* removed),
|
|
||||||
/// but 'key' is null-terminated.
|
|
||||||
bool removeMember(const char* key, Value* removed);
|
|
||||||
/** \brief Remove the named map member.
|
/** \brief Remove the named map member.
|
||||||
|
|
||||||
Update 'removed' iff removed.
|
Update 'removed' iff removed.
|
||||||
\param key may contain embedded nulls.
|
|
||||||
\return true iff removed (no exceptions)
|
\return true iff removed (no exceptions)
|
||||||
*/
|
*/
|
||||||
bool removeMember(JSONCPP_STRING const& key, Value* removed);
|
bool removeMember(const char* key, Value* removed);
|
||||||
/// Same as removeMember(JSONCPP_STRING const& key, Value* removed)
|
|
||||||
bool removeMember(const char* begin, const char* end, Value* removed);
|
|
||||||
/** \brief Remove the indexed array element.
|
/** \brief Remove the indexed array element.
|
||||||
|
|
||||||
O(n) expensive operations.
|
O(n) expensive operations.
|
||||||
@@ -546,13 +416,9 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
bool removeIndex(ArrayIndex i, Value* removed);
|
bool removeIndex(ArrayIndex i, Value* removed);
|
||||||
|
|
||||||
/// Return true if the object has a member named key.
|
/// Return true if the object has a member named key.
|
||||||
/// \note 'key' must be null-terminated.
|
|
||||||
bool isMember(const char* key) const;
|
bool isMember(const char* key) const;
|
||||||
/// Return true if the object has a member named key.
|
/// Return true if the object has a member named key.
|
||||||
/// \param key may contain embedded nulls.
|
bool isMember(const std::string& key) const;
|
||||||
bool isMember(const JSONCPP_STRING& key) const;
|
|
||||||
/// Same as isMember(JSONCPP_STRING const& key)const
|
|
||||||
bool isMember(const char* begin, const char* end) const;
|
|
||||||
#ifdef JSON_USE_CPPTL
|
#ifdef JSON_USE_CPPTL
|
||||||
/// Return true if the object has a member named key.
|
/// Return true if the object has a member named key.
|
||||||
bool isMember(const CppTL::ConstString& key) const;
|
bool isMember(const CppTL::ConstString& key) const;
|
||||||
@@ -571,17 +437,16 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
//# endif
|
//# endif
|
||||||
|
|
||||||
/// \deprecated Always pass len.
|
/// \deprecated Always pass len.
|
||||||
JSONCPP_DEPRECATED("Use setComment(JSONCPP_STRING const&) instead.")
|
|
||||||
void setComment(const char* comment, CommentPlacement placement);
|
void setComment(const char* comment, CommentPlacement placement);
|
||||||
/// Comments must be //... or /* ... */
|
/// Comments must be //... or /* ... */
|
||||||
void setComment(const char* comment, size_t len, CommentPlacement placement);
|
void setComment(const char* comment, size_t len, CommentPlacement placement);
|
||||||
/// Comments must be //... or /* ... */
|
/// 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;
|
bool hasComment(CommentPlacement placement) const;
|
||||||
/// Include delimiters and embedded newlines.
|
/// 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 begin() const;
|
||||||
const_iterator end() const;
|
const_iterator end() const;
|
||||||
@@ -589,19 +454,24 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
iterator begin();
|
iterator begin();
|
||||||
iterator end();
|
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:
|
private:
|
||||||
void initBasic(ValueType type, bool allocated = false);
|
void initBasic(ValueType type, bool allocated = false);
|
||||||
|
|
||||||
Value& resolveReference(const char* key);
|
Value& resolveReference(const char* key, bool isStatic);
|
||||||
Value& resolveReference(const char* key, const char* end);
|
|
||||||
|
|
||||||
|
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
inline bool isItemAvailable() const { return itemIsUsed_ == 0; }
|
||||||
|
|
||||||
|
inline void setItemUsed(bool isUsed = true) { itemIsUsed_ = isUsed ? 1 : 0; }
|
||||||
|
|
||||||
|
inline bool isMemberNameStatic() const { return memberNameIsStatic_ == 0; }
|
||||||
|
|
||||||
|
inline void setMemberNameIsStatic(bool isStatic) {
|
||||||
|
memberNameIsStatic_ = isStatic ? 1 : 0;
|
||||||
|
}
|
||||||
|
#endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
|
||||||
|
private:
|
||||||
struct CommentInfo {
|
struct CommentInfo {
|
||||||
CommentInfo();
|
CommentInfo();
|
||||||
~CommentInfo();
|
~CommentInfo();
|
||||||
@@ -625,18 +495,21 @@ private:
|
|||||||
LargestUInt uint_;
|
LargestUInt uint_;
|
||||||
double real_;
|
double real_;
|
||||||
bool bool_;
|
bool bool_;
|
||||||
char* string_; // actually ptr to unsigned, followed by str, unless !allocated_
|
char* string_;
|
||||||
|
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
ValueInternalArray* array_;
|
||||||
|
ValueInternalMap* map_;
|
||||||
|
#else
|
||||||
ObjectValues* map_;
|
ObjectValues* map_;
|
||||||
|
#endif
|
||||||
} value_;
|
} value_;
|
||||||
ValueType type_ : 8;
|
ValueType type_ : 8;
|
||||||
unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
|
unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
|
||||||
// If not allocated_, string_ must be null-terminated.
|
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container.
|
||||||
|
unsigned int memberNameIsStatic_ : 1; // used by the ValueInternalMap container.
|
||||||
|
#endif
|
||||||
CommentInfo* comments_;
|
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
|
/** \brief Experimental and untested: represents an element of the "path" to
|
||||||
@@ -649,7 +522,7 @@ public:
|
|||||||
PathArgument();
|
PathArgument();
|
||||||
PathArgument(ArrayIndex index);
|
PathArgument(ArrayIndex index);
|
||||||
PathArgument(const char* key);
|
PathArgument(const char* key);
|
||||||
PathArgument(const JSONCPP_STRING& key);
|
PathArgument(const std::string& key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Kind {
|
enum Kind {
|
||||||
@@ -657,7 +530,7 @@ private:
|
|||||||
kindIndex,
|
kindIndex,
|
||||||
kindKey
|
kindKey
|
||||||
};
|
};
|
||||||
JSONCPP_STRING key_;
|
std::string key_;
|
||||||
ArrayIndex index_;
|
ArrayIndex index_;
|
||||||
Kind kind_;
|
Kind kind_;
|
||||||
};
|
};
|
||||||
@@ -675,7 +548,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
class JSON_API Path {
|
class JSON_API Path {
|
||||||
public:
|
public:
|
||||||
Path(const JSONCPP_STRING& path,
|
Path(const std::string& path,
|
||||||
const PathArgument& a1 = PathArgument(),
|
const PathArgument& a1 = PathArgument(),
|
||||||
const PathArgument& a2 = PathArgument(),
|
const PathArgument& a2 = PathArgument(),
|
||||||
const PathArgument& a3 = PathArgument(),
|
const PathArgument& a3 = PathArgument(),
|
||||||
@@ -692,16 +565,355 @@ private:
|
|||||||
typedef std::vector<const PathArgument*> InArgs;
|
typedef std::vector<const PathArgument*> InArgs;
|
||||||
typedef std::vector<PathArgument> Args;
|
typedef std::vector<PathArgument> Args;
|
||||||
|
|
||||||
void makePath(const JSONCPP_STRING& path, const InArgs& in);
|
void makePath(const std::string& path, const InArgs& in);
|
||||||
void addPathInArg(const JSONCPP_STRING& path,
|
void addPathInArg(const std::string& path,
|
||||||
const InArgs& in,
|
const InArgs& in,
|
||||||
InArgs::const_iterator& itInArg,
|
InArgs::const_iterator& itInArg,
|
||||||
PathArgument::Kind kind);
|
PathArgument::Kind kind);
|
||||||
void invalidPath(const JSONCPP_STRING& path, int location);
|
void invalidPath(const std::string& path, int location);
|
||||||
|
|
||||||
Args args_;
|
Args args_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
/** \brief Allocator to customize Value internal map.
|
||||||
|
* Below is an example of a simple implementation (default implementation
|
||||||
|
actually
|
||||||
|
* use memory pool for speed).
|
||||||
|
* \code
|
||||||
|
class DefaultValueMapAllocator : public ValueMapAllocator
|
||||||
|
{
|
||||||
|
public: // overridden from ValueMapAllocator
|
||||||
|
virtual ValueInternalMap *newMap()
|
||||||
|
{
|
||||||
|
return new ValueInternalMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
|
||||||
|
{
|
||||||
|
return new ValueInternalMap( other );
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void destructMap( ValueInternalMap *map )
|
||||||
|
{
|
||||||
|
delete map;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
|
||||||
|
{
|
||||||
|
return new ValueInternalLink[size];
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void releaseMapBuckets( ValueInternalLink *links )
|
||||||
|
{
|
||||||
|
delete [] links;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ValueInternalLink *allocateMapLink()
|
||||||
|
{
|
||||||
|
return new ValueInternalLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void releaseMapLink( ValueInternalLink *link )
|
||||||
|
{
|
||||||
|
delete link;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
|
class JSON_API ValueMapAllocator {
|
||||||
|
public:
|
||||||
|
virtual ~ValueMapAllocator();
|
||||||
|
virtual ValueInternalMap* newMap() = 0;
|
||||||
|
virtual ValueInternalMap* newMapCopy(const ValueInternalMap& other) = 0;
|
||||||
|
virtual void destructMap(ValueInternalMap* map) = 0;
|
||||||
|
virtual ValueInternalLink* allocateMapBuckets(unsigned int size) = 0;
|
||||||
|
virtual void releaseMapBuckets(ValueInternalLink* links) = 0;
|
||||||
|
virtual ValueInternalLink* allocateMapLink() = 0;
|
||||||
|
virtual void releaseMapLink(ValueInternalLink* link) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** \brief ValueInternalMap hash-map bucket chain link (for internal use only).
|
||||||
|
* \internal previous_ & next_ allows for bidirectional traversal.
|
||||||
|
*/
|
||||||
|
class JSON_API ValueInternalLink {
|
||||||
|
public:
|
||||||
|
enum {
|
||||||
|
itemPerLink = 6
|
||||||
|
}; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.
|
||||||
|
enum InternalFlags {
|
||||||
|
flagAvailable = 0,
|
||||||
|
flagUsed = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
ValueInternalLink();
|
||||||
|
|
||||||
|
~ValueInternalLink();
|
||||||
|
|
||||||
|
Value items_[itemPerLink];
|
||||||
|
char* keys_[itemPerLink];
|
||||||
|
ValueInternalLink* previous_;
|
||||||
|
ValueInternalLink* next_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** \brief A linked page based hash-table implementation used internally by
|
||||||
|
*Value.
|
||||||
|
* \internal ValueInternalMap is a tradional bucket based hash-table, with a
|
||||||
|
*linked
|
||||||
|
* list in each bucket to handle collision. There is an addional twist in that
|
||||||
|
* each node of the collision linked list is a page containing a fixed amount of
|
||||||
|
* value. This provides a better compromise between memory usage and speed.
|
||||||
|
*
|
||||||
|
* Each bucket is made up of a chained list of ValueInternalLink. The last
|
||||||
|
* link of a given bucket can be found in the 'previous_' field of the following
|
||||||
|
*bucket.
|
||||||
|
* The last link of the last bucket is stored in tailLink_ as it has no
|
||||||
|
*following bucket.
|
||||||
|
* Only the last link of a bucket may contains 'available' item. The last link
|
||||||
|
*always
|
||||||
|
* contains at least one element unless is it the bucket one very first link.
|
||||||
|
*/
|
||||||
|
class JSON_API ValueInternalMap {
|
||||||
|
friend class ValueIteratorBase;
|
||||||
|
friend class Value;
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef unsigned int HashKey;
|
||||||
|
typedef unsigned int BucketIndex;
|
||||||
|
|
||||||
|
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
||||||
|
struct IteratorState {
|
||||||
|
IteratorState() : map_(0), link_(0), itemIndex_(0), bucketIndex_(0) {}
|
||||||
|
ValueInternalMap* map_;
|
||||||
|
ValueInternalLink* link_;
|
||||||
|
BucketIndex itemIndex_;
|
||||||
|
BucketIndex bucketIndex_;
|
||||||
|
};
|
||||||
|
#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
||||||
|
|
||||||
|
ValueInternalMap();
|
||||||
|
ValueInternalMap(const ValueInternalMap& other);
|
||||||
|
ValueInternalMap& operator=(ValueInternalMap other);
|
||||||
|
~ValueInternalMap();
|
||||||
|
|
||||||
|
void swap(ValueInternalMap& other);
|
||||||
|
|
||||||
|
BucketIndex size() const;
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
bool reserveDelta(BucketIndex growth);
|
||||||
|
|
||||||
|
bool reserve(BucketIndex newItemCount);
|
||||||
|
|
||||||
|
const Value* find(const char* key) const;
|
||||||
|
|
||||||
|
Value* find(const char* key);
|
||||||
|
|
||||||
|
Value& resolveReference(const char* key, bool isStatic);
|
||||||
|
|
||||||
|
void remove(const char* key);
|
||||||
|
|
||||||
|
void doActualRemove(ValueInternalLink* link,
|
||||||
|
BucketIndex index,
|
||||||
|
BucketIndex bucketIndex);
|
||||||
|
|
||||||
|
ValueInternalLink*& getLastLinkInBucket(BucketIndex bucketIndex);
|
||||||
|
|
||||||
|
Value& setNewItem(const char* key,
|
||||||
|
bool isStatic,
|
||||||
|
ValueInternalLink* link,
|
||||||
|
BucketIndex index);
|
||||||
|
|
||||||
|
Value& unsafeAdd(const char* key, bool isStatic, HashKey hashedKey);
|
||||||
|
|
||||||
|
HashKey hash(const char* key) const;
|
||||||
|
|
||||||
|
int compare(const ValueInternalMap& other) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void makeBeginIterator(IteratorState& it) const;
|
||||||
|
void makeEndIterator(IteratorState& it) const;
|
||||||
|
static bool equals(const IteratorState& x, const IteratorState& other);
|
||||||
|
static void increment(IteratorState& iterator);
|
||||||
|
static void incrementBucket(IteratorState& iterator);
|
||||||
|
static void decrement(IteratorState& iterator);
|
||||||
|
static const char* key(const IteratorState& iterator);
|
||||||
|
static const char* key(const IteratorState& iterator, bool& isStatic);
|
||||||
|
static Value& value(const IteratorState& iterator);
|
||||||
|
static int distance(const IteratorState& x, const IteratorState& y);
|
||||||
|
|
||||||
|
private:
|
||||||
|
ValueInternalLink* buckets_;
|
||||||
|
ValueInternalLink* tailLink_;
|
||||||
|
BucketIndex bucketsSize_;
|
||||||
|
BucketIndex itemCount_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** \brief A simplified deque implementation used internally by Value.
|
||||||
|
* \internal
|
||||||
|
* It is based on a list of fixed "page", each page contains a fixed number of
|
||||||
|
*items.
|
||||||
|
* Instead of using a linked-list, a array of pointer is used for fast item
|
||||||
|
*look-up.
|
||||||
|
* Look-up for an element is as follow:
|
||||||
|
* - compute page index: pageIndex = itemIndex / itemsPerPage
|
||||||
|
* - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]
|
||||||
|
*
|
||||||
|
* Insertion is amortized constant time (only the array containing the index of
|
||||||
|
*pointers
|
||||||
|
* need to be reallocated when items are appended).
|
||||||
|
*/
|
||||||
|
class JSON_API ValueInternalArray {
|
||||||
|
friend class Value;
|
||||||
|
friend class ValueIteratorBase;
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum {
|
||||||
|
itemsPerPage = 8
|
||||||
|
}; // should be a power of 2 for fast divide and modulo.
|
||||||
|
typedef Value::ArrayIndex ArrayIndex;
|
||||||
|
typedef unsigned int PageIndex;
|
||||||
|
|
||||||
|
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
||||||
|
struct IteratorState // Must be a POD
|
||||||
|
{
|
||||||
|
IteratorState() : array_(0), currentPageIndex_(0), currentItemIndex_(0) {}
|
||||||
|
ValueInternalArray* array_;
|
||||||
|
Value** currentPageIndex_;
|
||||||
|
unsigned int currentItemIndex_;
|
||||||
|
};
|
||||||
|
#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
||||||
|
|
||||||
|
ValueInternalArray();
|
||||||
|
ValueInternalArray(const ValueInternalArray& other);
|
||||||
|
ValueInternalArray& operator=(ValueInternalArray other);
|
||||||
|
~ValueInternalArray();
|
||||||
|
void swap(ValueInternalArray& other);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
void resize(ArrayIndex newSize);
|
||||||
|
|
||||||
|
Value& resolveReference(ArrayIndex index);
|
||||||
|
|
||||||
|
Value* find(ArrayIndex index) const;
|
||||||
|
|
||||||
|
ArrayIndex size() const;
|
||||||
|
|
||||||
|
int compare(const ValueInternalArray& other) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static bool equals(const IteratorState& x, const IteratorState& other);
|
||||||
|
static void increment(IteratorState& iterator);
|
||||||
|
static void decrement(IteratorState& iterator);
|
||||||
|
static Value& dereference(const IteratorState& iterator);
|
||||||
|
static Value& unsafeDereference(const IteratorState& iterator);
|
||||||
|
static int distance(const IteratorState& x, const IteratorState& y);
|
||||||
|
static ArrayIndex indexOf(const IteratorState& iterator);
|
||||||
|
void makeBeginIterator(IteratorState& it) const;
|
||||||
|
void makeEndIterator(IteratorState& it) const;
|
||||||
|
void makeIterator(IteratorState& it, ArrayIndex index) const;
|
||||||
|
|
||||||
|
void makeIndexValid(ArrayIndex index);
|
||||||
|
|
||||||
|
Value** pages_;
|
||||||
|
ArrayIndex size_;
|
||||||
|
PageIndex pageCount_;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** \brief Experimental: do not use. Allocator to customize Value internal
|
||||||
|
array.
|
||||||
|
* Below is an example of a simple implementation (actual implementation use
|
||||||
|
* memory pool).
|
||||||
|
\code
|
||||||
|
class DefaultValueArrayAllocator : public ValueArrayAllocator
|
||||||
|
{
|
||||||
|
public: // overridden from ValueArrayAllocator
|
||||||
|
virtual ~DefaultValueArrayAllocator()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ValueInternalArray *newArray()
|
||||||
|
{
|
||||||
|
return new ValueInternalArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )
|
||||||
|
{
|
||||||
|
return new ValueInternalArray( other );
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void destruct( ValueInternalArray *array )
|
||||||
|
{
|
||||||
|
delete array;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void reallocateArrayPageIndex( Value **&indexes,
|
||||||
|
ValueInternalArray::PageIndex
|
||||||
|
&indexCount,
|
||||||
|
ValueInternalArray::PageIndex
|
||||||
|
minNewIndexCount )
|
||||||
|
{
|
||||||
|
ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;
|
||||||
|
if ( minNewIndexCount > newIndexCount )
|
||||||
|
newIndexCount = minNewIndexCount;
|
||||||
|
void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );
|
||||||
|
if ( !newIndexes )
|
||||||
|
throw std::bad_alloc();
|
||||||
|
indexCount = newIndexCount;
|
||||||
|
indexes = static_cast<Value **>( newIndexes );
|
||||||
|
}
|
||||||
|
virtual void releaseArrayPageIndex( Value **indexes,
|
||||||
|
ValueInternalArray::PageIndex indexCount )
|
||||||
|
{
|
||||||
|
if ( indexes )
|
||||||
|
free( indexes );
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual Value *allocateArrayPage()
|
||||||
|
{
|
||||||
|
return static_cast<Value *>( malloc( sizeof(Value) *
|
||||||
|
ValueInternalArray::itemsPerPage ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void releaseArrayPage( Value *value )
|
||||||
|
{
|
||||||
|
if ( value )
|
||||||
|
free( value );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
\endcode
|
||||||
|
*/
|
||||||
|
class JSON_API ValueArrayAllocator {
|
||||||
|
public:
|
||||||
|
virtual ~ValueArrayAllocator();
|
||||||
|
virtual ValueInternalArray* newArray() = 0;
|
||||||
|
virtual ValueInternalArray* newArrayCopy(const ValueInternalArray& other) = 0;
|
||||||
|
virtual void destructArray(ValueInternalArray* array) = 0;
|
||||||
|
/** \brief Reallocate array page index.
|
||||||
|
* Reallocates an array of pointer on each page.
|
||||||
|
* \param indexes [input] pointer on the current index. May be \c NULL.
|
||||||
|
* [output] pointer on the new index of at least
|
||||||
|
* \a minNewIndexCount pages.
|
||||||
|
* \param indexCount [input] current number of pages in the index.
|
||||||
|
* [output] number of page the reallocated index can handle.
|
||||||
|
* \b MUST be >= \a minNewIndexCount.
|
||||||
|
* \param minNewIndexCount Minimum number of page the new index must be able
|
||||||
|
* to
|
||||||
|
* handle.
|
||||||
|
*/
|
||||||
|
virtual void
|
||||||
|
reallocateArrayPageIndex(Value**& indexes,
|
||||||
|
ValueInternalArray::PageIndex& indexCount,
|
||||||
|
ValueInternalArray::PageIndex minNewIndexCount) = 0;
|
||||||
|
virtual void
|
||||||
|
releaseArrayPageIndex(Value** indexes,
|
||||||
|
ValueInternalArray::PageIndex indexCount) = 0;
|
||||||
|
virtual Value* allocateArrayPage() = 0;
|
||||||
|
virtual void releaseArrayPage(Value* value) = 0;
|
||||||
|
};
|
||||||
|
#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
|
||||||
/** \brief base class for Value iterators.
|
/** \brief base class for Value iterators.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -712,35 +924,32 @@ public:
|
|||||||
typedef int difference_type;
|
typedef int difference_type;
|
||||||
typedef ValueIteratorBase SelfType;
|
typedef ValueIteratorBase SelfType;
|
||||||
|
|
||||||
|
ValueIteratorBase();
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
|
explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
|
||||||
|
#else
|
||||||
|
ValueIteratorBase(const ValueInternalArray::IteratorState& state);
|
||||||
|
ValueIteratorBase(const ValueInternalMap::IteratorState& state);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool operator==(const SelfType& other) const { return isEqual(other); }
|
bool operator==(const SelfType& other) const { return isEqual(other); }
|
||||||
|
|
||||||
bool operator!=(const SelfType& other) const { return !isEqual(other); }
|
bool operator!=(const SelfType& other) const { return !isEqual(other); }
|
||||||
|
|
||||||
difference_type operator-(const SelfType& other) const {
|
difference_type operator-(const SelfType& other) const {
|
||||||
return other.computeDistance(*this);
|
return computeDistance(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return either the index or the member name of the referenced value as a
|
/// Return either the index or the member name of the referenced value as a
|
||||||
/// Value.
|
/// Value.
|
||||||
Value key() const;
|
Value key() const;
|
||||||
|
|
||||||
/// Return the index of the referenced Value, or -1 if it is not an arrayValue.
|
/// Return the index of the referenced Value. -1 if it is not an arrayValue.
|
||||||
UInt index() const;
|
UInt index() const;
|
||||||
|
|
||||||
/// 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;
|
|
||||||
|
|
||||||
/// Return the member name of the referenced Value. "" if it is not an
|
/// Return the member name of the referenced Value. "" if it is not an
|
||||||
/// objectValue.
|
/// objectValue.
|
||||||
/// \deprecated This cannot be used for UTF-8 strings, since there can be embedded nulls.
|
const char* memberName() const;
|
||||||
JSONCPP_DEPRECATED("Use `key = name();` instead.")
|
|
||||||
char const* memberName() const;
|
|
||||||
/// Return the member name of the referenced Value, or NULL if it is not an
|
|
||||||
/// objectValue.
|
|
||||||
/// \note Better version than memberName(). Allows embedded nulls.
|
|
||||||
char const* memberName(char const** end) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Value& deref() const;
|
Value& deref() const;
|
||||||
@@ -756,15 +965,17 @@ protected:
|
|||||||
void copy(const SelfType& other);
|
void copy(const SelfType& other);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
Value::ObjectValues::iterator current_;
|
Value::ObjectValues::iterator current_;
|
||||||
// Indicates that iterator is for a null value.
|
// Indicates that iterator is for a null value.
|
||||||
bool isNull_;
|
bool isNull_;
|
||||||
|
#else
|
||||||
public:
|
union {
|
||||||
// For some reason, BORLAND needs these at the end, rather
|
ValueInternalArray::IteratorState array_;
|
||||||
// than earlier. No idea why.
|
ValueInternalMap::IteratorState map_;
|
||||||
ValueIteratorBase();
|
} iterator_;
|
||||||
explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
|
bool isArray_;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief const iterator for object and array value.
|
/** \brief const iterator for object and array value.
|
||||||
@@ -775,19 +986,23 @@ class JSON_API ValueConstIterator : public ValueIteratorBase {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
typedef const Value value_type;
|
typedef const Value value_type;
|
||||||
//typedef unsigned int size_t;
|
typedef unsigned int size_t;
|
||||||
//typedef int difference_type;
|
typedef int difference_type;
|
||||||
typedef const Value& reference;
|
typedef const Value& reference;
|
||||||
typedef const Value* pointer;
|
typedef const Value* pointer;
|
||||||
typedef ValueConstIterator SelfType;
|
typedef ValueConstIterator SelfType;
|
||||||
|
|
||||||
ValueConstIterator();
|
ValueConstIterator();
|
||||||
ValueConstIterator(ValueIterator const& other);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*! \internal Use by Value to create an iterator.
|
/*! \internal Use by Value to create an iterator.
|
||||||
*/
|
*/
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
|
explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
|
||||||
|
#else
|
||||||
|
ValueConstIterator(const ValueInternalArray::IteratorState& state);
|
||||||
|
ValueConstIterator(const ValueInternalMap::IteratorState& state);
|
||||||
|
#endif
|
||||||
public:
|
public:
|
||||||
SelfType& operator=(const ValueIteratorBase& other);
|
SelfType& operator=(const ValueIteratorBase& other);
|
||||||
|
|
||||||
@@ -832,13 +1047,18 @@ public:
|
|||||||
typedef ValueIterator SelfType;
|
typedef ValueIterator SelfType;
|
||||||
|
|
||||||
ValueIterator();
|
ValueIterator();
|
||||||
explicit ValueIterator(const ValueConstIterator& other);
|
ValueIterator(const ValueConstIterator& other);
|
||||||
ValueIterator(const ValueIterator& other);
|
ValueIterator(const ValueIterator& other);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*! \internal Use by Value to create an iterator.
|
/*! \internal Use by Value to create an iterator.
|
||||||
*/
|
*/
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
explicit ValueIterator(const Value::ObjectValues::iterator& current);
|
explicit ValueIterator(const Value::ObjectValues::iterator& current);
|
||||||
|
#else
|
||||||
|
ValueIterator(const ValueInternalArray::IteratorState& state);
|
||||||
|
ValueIterator(const ValueInternalMap::IteratorState& state);
|
||||||
|
#endif
|
||||||
public:
|
public:
|
||||||
SelfType& operator=(const SelfType& other);
|
SelfType& operator=(const SelfType& other);
|
||||||
|
|
||||||
@@ -878,7 +1098,6 @@ template<>
|
|||||||
inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
|
inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
@@ -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.
|
// Run CMake configure step to update it.
|
||||||
#ifndef JSON_VERSION_H_INCLUDED
|
#ifndef JSON_VERSION_H_INCLUDED
|
||||||
# define JSON_VERSION_H_INCLUDED
|
# define JSON_VERSION_H_INCLUDED
|
||||||
|
|
||||||
# define JSONCPP_VERSION_STRING "1.8.2"
|
# define JSONCPP_VERSION_STRING "0.8.0"
|
||||||
# define JSONCPP_VERSION_MAJOR 1
|
# define JSONCPP_VERSION_MAJOR 0
|
||||||
# define JSONCPP_VERSION_MINOR 8
|
# define JSONCPP_VERSION_MINOR 8
|
||||||
# define JSONCPP_VERSION_PATCH 2
|
# define JSONCPP_VERSION_PATCH 0
|
||||||
# define JSONCPP_VERSION_QUALIFIER
|
# define JSONCPP_VERSION_QUALIFIER
|
||||||
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
# 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
|
#endif // JSON_VERSION_H_INCLUDED
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@@ -20,8 +20,6 @@
|
|||||||
#pragma warning(disable : 4251)
|
#pragma warning(disable : 4251)
|
||||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
|
|
||||||
#pragma pack(push, 8)
|
|
||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
|
|
||||||
class Value;
|
class Value;
|
||||||
@@ -41,17 +39,17 @@ Usage:
|
|||||||
*/
|
*/
|
||||||
class JSON_API StreamWriter {
|
class JSON_API StreamWriter {
|
||||||
protected:
|
protected:
|
||||||
JSONCPP_OSTREAM* sout_; // not owned; will not delete
|
std::ostream* sout_; // not owned; will not delete
|
||||||
public:
|
public:
|
||||||
StreamWriter();
|
StreamWriter();
|
||||||
virtual ~StreamWriter();
|
virtual ~StreamWriter();
|
||||||
/** Write Value into document as configured in sub-class.
|
/** Write Value into document as configured in sub-class.
|
||||||
Do not take ownership of sout, but maintain a reference during function.
|
Do not take ownership of sout, but maintain a reference during function.
|
||||||
\pre sout != NULL
|
\pre sout != NULL
|
||||||
\return zero on success (For now, we always return zero, so check the stream instead.)
|
\return zero on success
|
||||||
\throw std::exception possibly, depending on configuration
|
\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.
|
/** \brief A simple abstract factory.
|
||||||
*/
|
*/
|
||||||
@@ -68,7 +66,7 @@ public:
|
|||||||
/** \brief Write into stringstream, then return string, for convenience.
|
/** \brief Write into stringstream, then return string, for convenience.
|
||||||
* A StreamWriter will be created from the factory, used, and then deleted.
|
* 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 writeString(StreamWriter::Factory const& factory, Value const& root);
|
||||||
|
|
||||||
|
|
||||||
/** \brief Build a StreamWriter implementation.
|
/** \brief Build a StreamWriter implementation.
|
||||||
@@ -78,8 +76,8 @@ Usage:
|
|||||||
using namespace Json;
|
using namespace Json;
|
||||||
Value value = ...;
|
Value value = ...;
|
||||||
StreamWriterBuilder builder;
|
StreamWriterBuilder builder;
|
||||||
builder["commentStyle"] = "None";
|
builder.settings_["commentStyle"] = "None";
|
||||||
builder["indentation"] = " "; // or whatever you like
|
builder.settings_["indentation"] = " "; // or whatever you like
|
||||||
std::unique_ptr<Json::StreamWriter> writer(
|
std::unique_ptr<Json::StreamWriter> writer(
|
||||||
builder.newStreamWriter());
|
builder.newStreamWriter());
|
||||||
writer->write(value, &std::cout);
|
writer->write(value, &std::cout);
|
||||||
@@ -101,10 +99,6 @@ public:
|
|||||||
Strictly speaking, this is not valid JSON. But when the output is being
|
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
|
fed to a browser's Javascript, it makes for smaller output and the
|
||||||
browser can handle the output just fine.
|
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
|
You can examine 'settings_` yourself
|
||||||
to see the defaults. You can also write and read them just like any
|
to see the defaults. You can also write and read them just like any
|
||||||
@@ -114,21 +108,17 @@ public:
|
|||||||
Json::Value settings_;
|
Json::Value settings_;
|
||||||
|
|
||||||
StreamWriterBuilder();
|
StreamWriterBuilder();
|
||||||
~StreamWriterBuilder() JSONCPP_OVERRIDE;
|
virtual ~StreamWriterBuilder();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
* \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;
|
/** \return true if 'settings' are legal and consistent;
|
||||||
* otherwise, indicate bad settings via 'invalid'.
|
* otherwise, indicate bad settings via 'invalid'.
|
||||||
*/
|
*/
|
||||||
bool validate(Json::Value* invalid) const;
|
bool validate(Json::Value* invalid) const;
|
||||||
/** A simple way to update a specific setting.
|
|
||||||
*/
|
|
||||||
Value& operator[](JSONCPP_STRING key);
|
|
||||||
|
|
||||||
/** Called by ctor, but you can use this to reset settings_.
|
/** Called by ctor, but you can use this to reset settings_.
|
||||||
* \pre 'settings' != NULL (but Json::null is fine)
|
* \pre 'settings' != NULL (but Json::null is fine)
|
||||||
* \remark Defaults:
|
* \remark Defaults:
|
||||||
@@ -138,13 +128,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Abstract class for writers.
|
/** \brief Abstract class for writers.
|
||||||
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
|
* \deprecated Use StreamWriter.
|
||||||
*/
|
*/
|
||||||
class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer {
|
class JSON_API Writer {
|
||||||
public:
|
public:
|
||||||
virtual ~Writer();
|
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
|
/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
|
||||||
@@ -156,33 +146,21 @@ public:
|
|||||||
* \sa Reader, Value
|
* \sa Reader, Value
|
||||||
* \deprecated Use StreamWriterBuilder.
|
* \deprecated Use StreamWriterBuilder.
|
||||||
*/
|
*/
|
||||||
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter : public Writer {
|
class JSON_API FastWriter : public Writer {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FastWriter();
|
FastWriter();
|
||||||
~FastWriter() JSONCPP_OVERRIDE {}
|
virtual ~FastWriter() {}
|
||||||
|
|
||||||
void enableYAMLCompatibility();
|
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
|
public: // overridden from Writer
|
||||||
JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
|
virtual std::string write(const Value& root);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void writeValue(const Value& value);
|
void writeValue(const Value& value);
|
||||||
|
|
||||||
JSONCPP_STRING document_;
|
std::string document_;
|
||||||
bool yamlCompatiblityEnabled_;
|
bool yamlCompatiblityEnabled_;
|
||||||
bool dropNullPlaceholders_;
|
|
||||||
bool omitEndingLineFeed_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
||||||
@@ -209,39 +187,39 @@ private:
|
|||||||
* \sa Reader, Value, Value::setComment()
|
* \sa Reader, Value, Value::setComment()
|
||||||
* \deprecated Use StreamWriterBuilder.
|
* \deprecated Use StreamWriterBuilder.
|
||||||
*/
|
*/
|
||||||
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledWriter : public Writer {
|
class JSON_API StyledWriter : public Writer {
|
||||||
public:
|
public:
|
||||||
StyledWriter();
|
StyledWriter();
|
||||||
~StyledWriter() JSONCPP_OVERRIDE {}
|
virtual ~StyledWriter() {}
|
||||||
|
|
||||||
public: // overridden from Writer
|
public: // overridden from Writer
|
||||||
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
||||||
* \param root Value to serialize.
|
* \param root Value to serialize.
|
||||||
* \return String containing the JSON document that represents the root value.
|
* \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:
|
private:
|
||||||
void writeValue(const Value& value);
|
void writeValue(const Value& value);
|
||||||
void writeArrayValue(const Value& value);
|
void writeArrayValue(const Value& value);
|
||||||
bool isMultineArray(const Value& value);
|
bool isMultineArray(const Value& value);
|
||||||
void pushValue(const JSONCPP_STRING& value);
|
void pushValue(const std::string& value);
|
||||||
void writeIndent();
|
void writeIndent();
|
||||||
void writeWithIndent(const JSONCPP_STRING& value);
|
void writeWithIndent(const std::string& value);
|
||||||
void indent();
|
void indent();
|
||||||
void unindent();
|
void unindent();
|
||||||
void writeCommentBeforeValue(const Value& root);
|
void writeCommentBeforeValue(const Value& root);
|
||||||
void writeCommentAfterValueOnSameLine(const Value& root);
|
void writeCommentAfterValueOnSameLine(const Value& root);
|
||||||
bool hasCommentForValue(const Value& value);
|
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_;
|
ChildValues childValues_;
|
||||||
JSONCPP_STRING document_;
|
std::string document_;
|
||||||
JSONCPP_STRING indentString_;
|
std::string indentString_;
|
||||||
unsigned int rightMargin_;
|
int rightMargin_;
|
||||||
unsigned int indentSize_;
|
int indentSize_;
|
||||||
bool addChildValues_;
|
bool addChildValues_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -267,15 +245,13 @@ private:
|
|||||||
* If the Value have comments then they are outputed according to their
|
* If the Value have comments then they are outputed according to their
|
||||||
#CommentPlacement.
|
#CommentPlacement.
|
||||||
*
|
*
|
||||||
|
* \param indentation Each level will be indented by this amount extra.
|
||||||
* \sa Reader, Value, Value::setComment()
|
* \sa Reader, Value, Value::setComment()
|
||||||
* \deprecated Use StreamWriterBuilder.
|
* \deprecated Use StreamWriterBuilder.
|
||||||
*/
|
*/
|
||||||
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledStreamWriter {
|
class JSON_API StyledStreamWriter {
|
||||||
public:
|
public:
|
||||||
/**
|
StyledStreamWriter(std::string indentation = "\t");
|
||||||
* \param indentation Each level will be indented by this amount extra.
|
|
||||||
*/
|
|
||||||
StyledStreamWriter(JSONCPP_STRING indentation = "\t");
|
|
||||||
~StyledStreamWriter() {}
|
~StyledStreamWriter() {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -285,51 +261,49 @@ public:
|
|||||||
* \note There is no point in deriving from Writer, since write() should not
|
* \note There is no point in deriving from Writer, since write() should not
|
||||||
* return a value.
|
* return a value.
|
||||||
*/
|
*/
|
||||||
void write(JSONCPP_OSTREAM& out, const Value& root);
|
void write(std::ostream& out, const Value& root);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void writeValue(const Value& value);
|
void writeValue(const Value& value);
|
||||||
void writeArrayValue(const Value& value);
|
void writeArrayValue(const Value& value);
|
||||||
bool isMultineArray(const Value& value);
|
bool isMultineArray(const Value& value);
|
||||||
void pushValue(const JSONCPP_STRING& value);
|
void pushValue(const std::string& value);
|
||||||
void writeIndent();
|
void writeIndent();
|
||||||
void writeWithIndent(const JSONCPP_STRING& value);
|
void writeWithIndent(const std::string& value);
|
||||||
void indent();
|
void indent();
|
||||||
void unindent();
|
void unindent();
|
||||||
void writeCommentBeforeValue(const Value& root);
|
void writeCommentBeforeValue(const Value& root);
|
||||||
void writeCommentAfterValueOnSameLine(const Value& root);
|
void writeCommentAfterValueOnSameLine(const Value& root);
|
||||||
bool hasCommentForValue(const Value& value);
|
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_;
|
ChildValues childValues_;
|
||||||
JSONCPP_OSTREAM* document_;
|
std::ostream* document_;
|
||||||
JSONCPP_STRING indentString_;
|
std::string indentString_;
|
||||||
unsigned int rightMargin_;
|
int rightMargin_;
|
||||||
JSONCPP_STRING indentation_;
|
std::string indentation_;
|
||||||
bool addChildValues_ : 1;
|
bool addChildValues_ : 1;
|
||||||
bool indented_ : 1;
|
bool indented_ : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(JSON_HAS_INT64)
|
#if defined(JSON_HAS_INT64)
|
||||||
JSONCPP_STRING JSON_API valueToString(Int value);
|
std::string JSON_API valueToString(Int value);
|
||||||
JSONCPP_STRING JSON_API valueToString(UInt value);
|
std::string JSON_API valueToString(UInt value);
|
||||||
#endif // if defined(JSON_HAS_INT64)
|
#endif // if defined(JSON_HAS_INT64)
|
||||||
JSONCPP_STRING JSON_API valueToString(LargestInt value);
|
std::string JSON_API valueToString(LargestInt value);
|
||||||
JSONCPP_STRING JSON_API valueToString(LargestUInt value);
|
std::string JSON_API valueToString(LargestUInt value);
|
||||||
JSONCPP_STRING JSON_API valueToString(double value);
|
std::string JSON_API valueToString(double value);
|
||||||
JSONCPP_STRING JSON_API valueToString(bool value);
|
std::string JSON_API valueToString(bool value);
|
||||||
JSONCPP_STRING JSON_API valueToQuotedString(const char* value);
|
std::string JSON_API valueToQuotedString(const char* value);
|
||||||
|
|
||||||
/// \brief Output using the StyledStreamWriter.
|
/// \brief Output using the StyledStreamWriter.
|
||||||
/// \see Json::operator>>()
|
/// \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
|
} // namespace Json
|
||||||
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||||
|
@@ -1,46 +1,46 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
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}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_json", "lib_json.vcproj", "{B84F7231-16CE-41D8-8C08-7B523FF4225B}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsontest", "jsontest.vcproj", "{25AF2DD2-D396-4668-B188-488C33B8E620}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsontest", "jsontest.vcproj", "{25AF2DD2-D396-4668-B188-488C33B8E620}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B} = {B84F7231-16CE-41D8-8C08-7B523FF4225B}
|
{B84F7231-16CE-41D8-8C08-7B523FF4225B} = {B84F7231-16CE-41D8-8C08-7B523FF4225B}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_lib_json", "test_lib_json.vcproj", "{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_lib_json", "test_lib_json.vcproj", "{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B} = {B84F7231-16CE-41D8-8C08-7B523FF4225B}
|
{B84F7231-16CE-41D8-8C08-7B523FF4225B} = {B84F7231-16CE-41D8-8C08-7B523FF4225B}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfiguration) = preSolution
|
GlobalSection(SolutionConfiguration) = preSolution
|
||||||
Debug = Debug
|
Debug = Debug
|
||||||
dummy = dummy
|
dummy = dummy
|
||||||
Release = Release
|
Release = Release
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfiguration) = postSolution
|
GlobalSection(ProjectConfiguration) = postSolution
|
||||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.Debug.ActiveCfg = Debug|Win32
|
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.Debug.ActiveCfg = Debug|Win32
|
||||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.Debug.Build.0 = 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.ActiveCfg = dummy|Win32
|
||||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.dummy.Build.0 = 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.ActiveCfg = Release|Win32
|
||||||
{B84F7231-16CE-41D8-8C08-7B523FF4225B}.Release.Build.0 = 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.ActiveCfg = Debug|Win32
|
||||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.Debug.Build.0 = 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.ActiveCfg = Debug|Win32
|
||||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.dummy.Build.0 = 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.ActiveCfg = Release|Win32
|
||||||
{25AF2DD2-D396-4668-B188-488C33B8E620}.Release.Build.0 = 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.ActiveCfg = Debug|Win32
|
||||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Debug.Build.0 = 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.ActiveCfg = Debug|Win32
|
||||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.dummy.Build.0 = 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.ActiveCfg = Release|Win32
|
||||||
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release.Build.0 = Release|Win32
|
{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}.Release.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
@@ -1,119 +1,119 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="7.10"
|
Version="7.10"
|
||||||
Name="jsontest"
|
Name="jsontest"
|
||||||
ProjectGUID="{25AF2DD2-D396-4668-B188-488C33B8E620}"
|
ProjectGUID="{25AF2DD2-D396-4668-B188-488C33B8E620}"
|
||||||
Keyword="Win32Proj">
|
Keyword="Win32Proj">
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"/>
|
Name="Win32"/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory="../../build/vs71/debug/jsontest"
|
OutputDirectory="../../build/vs71/debug/jsontest"
|
||||||
IntermediateDirectory="../../build/vs71/debug/jsontest"
|
IntermediateDirectory="../../build/vs71/debug/jsontest"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="2">
|
CharacterSet="2">
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="../../include"
|
AdditionalIncludeDirectories="../../include"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
DebugInformationFormat="4"/>
|
DebugInformationFormat="4"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)/jsontest.exe"
|
OutputFile="$(OutDir)/jsontest.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
ProgramDatabaseFile="$(OutDir)/jsontest.pdb"
|
ProgramDatabaseFile="$(OutDir)/jsontest.pdb"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"/>
|
TargetMachine="1"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"/>
|
Name="VCMIDLTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"/>
|
Name="VCPostBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"/>
|
Name="VCPreBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"/>
|
Name="VCPreLinkEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"/>
|
Name="VCResourceCompilerTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebDeploymentTool"/>
|
Name="VCWebDeploymentTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="../../build/vs71/release/jsontest"
|
OutputDirectory="../../build/vs71/release/jsontest"
|
||||||
IntermediateDirectory="../../build/vs71/release/jsontest"
|
IntermediateDirectory="../../build/vs71/release/jsontest"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="2">
|
CharacterSet="2">
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories="../../include"
|
AdditionalIncludeDirectories="../../include"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
DebugInformationFormat="3"/>
|
DebugInformationFormat="3"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)/jsontest.exe"
|
OutputFile="$(OutDir)/jsontest.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="1"/>
|
TargetMachine="1"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"/>
|
Name="VCMIDLTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"/>
|
Name="VCPostBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"/>
|
Name="VCPreBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"/>
|
Name="VCPreLinkEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"/>
|
Name="VCResourceCompilerTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebDeploymentTool"/>
|
Name="VCWebDeploymentTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
</References>
|
</References>
|
||||||
<Files>
|
<Files>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\jsontestrunner\main.cpp">
|
RelativePath="..\..\src\jsontestrunner\main.cpp">
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
</VisualStudioProject>
|
</VisualStudioProject>
|
||||||
|
@@ -1,205 +1,214 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="7.10"
|
Version="7.10"
|
||||||
Name="lib_json"
|
Name="lib_json"
|
||||||
ProjectGUID="{B84F7231-16CE-41D8-8C08-7B523FF4225B}"
|
ProjectGUID="{B84F7231-16CE-41D8-8C08-7B523FF4225B}"
|
||||||
Keyword="Win32Proj">
|
Keyword="Win32Proj">
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"/>
|
Name="Win32"/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory="../../build/vs71/debug/lib_json"
|
OutputDirectory="../../build/vs71/debug/lib_json"
|
||||||
IntermediateDirectory="../../build/vs71/debug/lib_json"
|
IntermediateDirectory="../../build/vs71/debug/lib_json"
|
||||||
ConfigurationType="4"
|
ConfigurationType="4"
|
||||||
CharacterSet="2">
|
CharacterSet="2">
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="../../include"
|
AdditionalIncludeDirectories="../../include"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||||
StringPooling="TRUE"
|
StringPooling="TRUE"
|
||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
EnableFunctionLevelLinking="TRUE"
|
EnableFunctionLevelLinking="TRUE"
|
||||||
DisableLanguageExtensions="TRUE"
|
DisableLanguageExtensions="TRUE"
|
||||||
ForceConformanceInForLoopScope="FALSE"
|
ForceConformanceInForLoopScope="FALSE"
|
||||||
RuntimeTypeInfo="TRUE"
|
RuntimeTypeInfo="TRUE"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
DebugInformationFormat="4"/>
|
DebugInformationFormat="4"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLibrarianTool"
|
Name="VCLibrarianTool"
|
||||||
OutputFile="$(OutDir)/json_vc71_libmtd.lib"/>
|
OutputFile="$(OutDir)/json_vc71_libmtd.lib"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"/>
|
Name="VCMIDLTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"/>
|
Name="VCPostBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"/>
|
Name="VCPreBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"/>
|
Name="VCPreLinkEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"/>
|
Name="VCResourceCompilerTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="../../build/vs71/release/lib_json"
|
OutputDirectory="../../build/vs71/release/lib_json"
|
||||||
IntermediateDirectory="../../build/vs71/release/lib_json"
|
IntermediateDirectory="../../build/vs71/release/lib_json"
|
||||||
ConfigurationType="4"
|
ConfigurationType="4"
|
||||||
CharacterSet="2"
|
CharacterSet="2"
|
||||||
WholeProgramOptimization="TRUE">
|
WholeProgramOptimization="TRUE">
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
GlobalOptimizations="TRUE"
|
GlobalOptimizations="TRUE"
|
||||||
EnableIntrinsicFunctions="TRUE"
|
EnableIntrinsicFunctions="TRUE"
|
||||||
AdditionalIncludeDirectories="../../include"
|
AdditionalIncludeDirectories="../../include"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||||
StringPooling="TRUE"
|
StringPooling="TRUE"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="TRUE"
|
EnableFunctionLevelLinking="TRUE"
|
||||||
DisableLanguageExtensions="TRUE"
|
DisableLanguageExtensions="TRUE"
|
||||||
ForceConformanceInForLoopScope="FALSE"
|
ForceConformanceInForLoopScope="FALSE"
|
||||||
RuntimeTypeInfo="TRUE"
|
RuntimeTypeInfo="TRUE"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
AssemblerOutput="4"
|
AssemblerOutput="4"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
DebugInformationFormat="3"/>
|
DebugInformationFormat="3"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLibrarianTool"
|
Name="VCLibrarianTool"
|
||||||
OutputFile="$(OutDir)/json_vc71_libmt.lib"/>
|
OutputFile="$(OutDir)/json_vc71_libmt.lib"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"/>
|
Name="VCMIDLTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"/>
|
Name="VCPostBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"/>
|
Name="VCPreBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"/>
|
Name="VCPreLinkEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"/>
|
Name="VCResourceCompilerTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="dummy|Win32"
|
Name="dummy|Win32"
|
||||||
OutputDirectory="$(ConfigurationName)"
|
OutputDirectory="$(ConfigurationName)"
|
||||||
IntermediateDirectory="$(ConfigurationName)"
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
ConfigurationType="2"
|
ConfigurationType="2"
|
||||||
CharacterSet="2"
|
CharacterSet="2"
|
||||||
WholeProgramOptimization="TRUE">
|
WholeProgramOptimization="TRUE">
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
GlobalOptimizations="TRUE"
|
GlobalOptimizations="TRUE"
|
||||||
EnableIntrinsicFunctions="TRUE"
|
EnableIntrinsicFunctions="TRUE"
|
||||||
AdditionalIncludeDirectories="../../include"
|
AdditionalIncludeDirectories="../../include"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||||
StringPooling="TRUE"
|
StringPooling="TRUE"
|
||||||
RuntimeLibrary="4"
|
RuntimeLibrary="4"
|
||||||
EnableFunctionLevelLinking="TRUE"
|
EnableFunctionLevelLinking="TRUE"
|
||||||
DisableLanguageExtensions="TRUE"
|
DisableLanguageExtensions="TRUE"
|
||||||
ForceConformanceInForLoopScope="FALSE"
|
ForceConformanceInForLoopScope="FALSE"
|
||||||
RuntimeTypeInfo="TRUE"
|
RuntimeTypeInfo="TRUE"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
AssemblerOutput="4"
|
AssemblerOutput="4"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
DebugInformationFormat="3"/>
|
DebugInformationFormat="3"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
SubSystem="2"
|
SubSystem="2"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="1"/>
|
TargetMachine="1"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"/>
|
Name="VCMIDLTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"/>
|
Name="VCPostBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"/>
|
Name="VCPreBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"/>
|
Name="VCPreLinkEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"/>
|
Name="VCResourceCompilerTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebDeploymentTool"/>
|
Name="VCWebDeploymentTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
</References>
|
</References>
|
||||||
<Files>
|
<Files>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\json\autolink.h">
|
RelativePath="..\..\include\json\autolink.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\json\config.h">
|
RelativePath="..\..\include\json\config.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\json\features.h">
|
RelativePath="..\..\include\json\features.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\json\forwards.h">
|
RelativePath="..\..\include\json\forwards.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\json\json.h">
|
RelativePath="..\..\include\json\json.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\lib_json\json_reader.cpp">
|
RelativePath="..\..\src\lib_json\json_batchallocator.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\lib_json\json_value.cpp">
|
RelativePath="..\..\src\lib_json\json_internalarray.inl">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\lib_json\json_valueiterator.inl">
|
RelativePath="..\..\src\lib_json\json_internalmap.inl">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\lib_json\json_writer.cpp">
|
RelativePath="..\..\src\lib_json\json_reader.cpp">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\json\reader.h">
|
RelativePath="..\..\src\lib_json\json_value.cpp">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\json\value.h">
|
RelativePath="..\..\src\lib_json\json_valueiterator.inl">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\json\writer.h">
|
RelativePath="..\..\src\lib_json\json_writer.cpp">
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
<File
|
||||||
<Globals>
|
RelativePath="..\..\include\json\reader.h">
|
||||||
</Globals>
|
</File>
|
||||||
</VisualStudioProject>
|
<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"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="7.10"
|
Version="7.10"
|
||||||
Name="test_lib_json"
|
Name="test_lib_json"
|
||||||
ProjectGUID="{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}"
|
ProjectGUID="{B7A96B78-2782-40D2-8F37-A2DEF2B9C26D}"
|
||||||
RootNamespace="test_lib_json"
|
RootNamespace="test_lib_json"
|
||||||
Keyword="Win32Proj">
|
Keyword="Win32Proj">
|
||||||
<Platforms>
|
<Platforms>
|
||||||
<Platform
|
<Platform
|
||||||
Name="Win32"/>
|
Name="Win32"/>
|
||||||
</Platforms>
|
</Platforms>
|
||||||
<Configurations>
|
<Configurations>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32"
|
||||||
OutputDirectory="../../build/vs71/debug/test_lib_json"
|
OutputDirectory="../../build/vs71/debug/test_lib_json"
|
||||||
IntermediateDirectory="../../build/vs71/debug/test_lib_json"
|
IntermediateDirectory="../../build/vs71/debug/test_lib_json"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="2">
|
CharacterSet="2">
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="../../include"
|
AdditionalIncludeDirectories="../../include"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="1"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
DebugInformationFormat="4"/>
|
DebugInformationFormat="4"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)/test_lib_json.exe"
|
OutputFile="$(OutDir)/test_lib_json.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
ProgramDatabaseFile="$(OutDir)/test_lib_json.pdb"
|
ProgramDatabaseFile="$(OutDir)/test_lib_json.pdb"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
TargetMachine="1"/>
|
TargetMachine="1"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"/>
|
Name="VCMIDLTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
Description="Running all unit tests"
|
Description="Running all unit tests"
|
||||||
CommandLine="$(TargetPath)"/>
|
CommandLine="$(TargetPath)"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"/>
|
Name="VCPreBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"/>
|
Name="VCPreLinkEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"/>
|
Name="VCResourceCompilerTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebDeploymentTool"/>
|
Name="VCWebDeploymentTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="../../build/vs71/release/test_lib_json"
|
OutputDirectory="../../build/vs71/release/test_lib_json"
|
||||||
IntermediateDirectory="../../build/vs71/release/test_lib_json"
|
IntermediateDirectory="../../build/vs71/release/test_lib_json"
|
||||||
ConfigurationType="1"
|
ConfigurationType="1"
|
||||||
CharacterSet="2">
|
CharacterSet="2">
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalIncludeDirectories="../../include"
|
AdditionalIncludeDirectories="../../include"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||||
RuntimeLibrary="0"
|
RuntimeLibrary="0"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
DebugInformationFormat="3"/>
|
DebugInformationFormat="3"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="$(OutDir)/test_lib_json.exe"
|
OutputFile="$(OutDir)/test_lib_json.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
OptimizeReferences="2"
|
OptimizeReferences="2"
|
||||||
EnableCOMDATFolding="2"
|
EnableCOMDATFolding="2"
|
||||||
TargetMachine="1"/>
|
TargetMachine="1"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"/>
|
Name="VCMIDLTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
Description="Running all unit tests"
|
Description="Running all unit tests"
|
||||||
CommandLine="$(TargetPath)"/>
|
CommandLine="$(TargetPath)"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"/>
|
Name="VCPreBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreLinkEventTool"/>
|
Name="VCPreLinkEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCResourceCompilerTool"/>
|
Name="VCResourceCompilerTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebServiceProxyGeneratorTool"/>
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXMLDataGeneratorTool"/>
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCWebDeploymentTool"/>
|
Name="VCWebDeploymentTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCManagedWrapperGeneratorTool"/>
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
</Configurations>
|
</Configurations>
|
||||||
<References>
|
<References>
|
||||||
</References>
|
</References>
|
||||||
<Files>
|
<Files>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\test_lib_json\jsontest.cpp">
|
RelativePath="..\..\src\test_lib_json\jsontest.cpp">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\test_lib_json\jsontest.h">
|
RelativePath="..\..\src\test_lib_json\jsontest.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\src\test_lib_json\main.cpp">
|
RelativePath="..\..\src\test_lib_json\main.cpp">
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
</VisualStudioProject>
|
</VisualStudioProject>
|
||||||
|
@@ -1,8 +1,3 @@
|
|||||||
# Copyright 2010 Baptiste Lepilleur and The JsonCpp Authors
|
|
||||||
# Distributed under MIT license, or public domain if desired and
|
|
||||||
# recognized in your jurisdiction.
|
|
||||||
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
|
||||||
|
|
||||||
"""Tag the sandbox for release, make source and doc tarballs.
|
"""Tag the sandbox for release, make source and doc tarballs.
|
||||||
|
|
||||||
Requires Python 2.6
|
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
|
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.
|
need to build versioned tarballs anymore, so makerelease.py is defunct.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import os.path
|
import os.path
|
||||||
import subprocess
|
import subprocess
|
||||||
|
102
meson.build
102
meson.build
@@ -1,102 +0,0 @@
|
|||||||
project(
|
|
||||||
'jsoncpp',
|
|
||||||
'cpp',
|
|
||||||
version : '1.8.2',
|
|
||||||
default_options : [
|
|
||||||
'buildtype=release',
|
|
||||||
'warning_level=1'],
|
|
||||||
license : 'Public Domain',
|
|
||||||
meson_version : '>= 0.41.1')
|
|
||||||
|
|
||||||
jsoncpp_ver_arr = meson.project_version().split('.')
|
|
||||||
jsoncpp_major_version = jsoncpp_ver_arr[0]
|
|
||||||
jsoncpp_minor_version = jsoncpp_ver_arr[1]
|
|
||||||
jsoncpp_patch_version = jsoncpp_ver_arr[2]
|
|
||||||
|
|
||||||
jsoncpp_cdata = configuration_data()
|
|
||||||
jsoncpp_cdata.set('JSONCPP_VERSION', meson.project_version())
|
|
||||||
jsoncpp_cdata.set('JSONCPP_VERSION_MAJOR', jsoncpp_major_version)
|
|
||||||
jsoncpp_cdata.set('JSONCPP_VERSION_MINOR', jsoncpp_minor_version)
|
|
||||||
jsoncpp_cdata.set('JSONCPP_VERSION_PATCH', jsoncpp_patch_version)
|
|
||||||
|
|
||||||
jsoncpp_gen_sources = configure_file(
|
|
||||||
input : 'src/lib_json/version.h.in',
|
|
||||||
output : 'version.h',
|
|
||||||
configuration : jsoncpp_cdata,
|
|
||||||
install : true,
|
|
||||||
install_dir : join_paths(get_option('prefix'), get_option('includedir'), 'json')
|
|
||||||
)
|
|
||||||
|
|
||||||
jsoncpp_headers = [
|
|
||||||
'include/json/allocator.h',
|
|
||||||
'include/json/assertions.h',
|
|
||||||
'include/json/autolink.h',
|
|
||||||
'include/json/config.h',
|
|
||||||
'include/json/features.h',
|
|
||||||
'include/json/forwards.h',
|
|
||||||
'include/json/json.h',
|
|
||||||
'include/json/reader.h',
|
|
||||||
'include/json/value.h',
|
|
||||||
'include/json/writer.h']
|
|
||||||
jsoncpp_include_directories = include_directories('include')
|
|
||||||
|
|
||||||
install_headers(
|
|
||||||
jsoncpp_headers,
|
|
||||||
subdir : 'json')
|
|
||||||
|
|
||||||
jsoncpp_lib = library(
|
|
||||||
'jsoncpp',
|
|
||||||
[ jsoncpp_gen_sources,
|
|
||||||
jsoncpp_headers,
|
|
||||||
'src/lib_json/json_tool.h',
|
|
||||||
'src/lib_json/json_reader.cpp',
|
|
||||||
'src/lib_json/json_value.cpp',
|
|
||||||
'src/lib_json/json_writer.cpp'],
|
|
||||||
soversion : 18,
|
|
||||||
install : true,
|
|
||||||
include_directories : jsoncpp_include_directories)
|
|
||||||
|
|
||||||
import('pkgconfig').generate(
|
|
||||||
libraries : jsoncpp_lib,
|
|
||||||
version : meson.project_version(),
|
|
||||||
name : 'jsoncpp',
|
|
||||||
filebase : 'jsoncpp',
|
|
||||||
description : 'A C++ library for interacting with JSON')
|
|
||||||
|
|
||||||
# for libraries bundling jsoncpp
|
|
||||||
declare_dependency(
|
|
||||||
include_directories : jsoncpp_include_directories,
|
|
||||||
link_with : jsoncpp_lib,
|
|
||||||
version : meson.project_version(),
|
|
||||||
sources : jsoncpp_gen_sources)
|
|
||||||
|
|
||||||
# tests
|
|
||||||
python = import('python3').find_python()
|
|
||||||
|
|
||||||
jsoncpp_test = executable(
|
|
||||||
'jsoncpp_test',
|
|
||||||
[ 'src/test_lib_json/jsontest.cpp',
|
|
||||||
'src/test_lib_json/jsontest.h',
|
|
||||||
'src/test_lib_json/main.cpp'],
|
|
||||||
include_directories : jsoncpp_include_directories,
|
|
||||||
link_with : jsoncpp_lib,
|
|
||||||
install : false)
|
|
||||||
test(
|
|
||||||
'unittest_jsoncpp_test',
|
|
||||||
jsoncpp_test)
|
|
||||||
|
|
||||||
jsontestrunner = executable(
|
|
||||||
'jsontestrunner',
|
|
||||||
'src/jsontestrunner/main.cpp',
|
|
||||||
include_directories : jsoncpp_include_directories,
|
|
||||||
link_with : jsoncpp_lib,
|
|
||||||
install : false)
|
|
||||||
test(
|
|
||||||
'unittest_jsontestrunner',
|
|
||||||
python,
|
|
||||||
args : [
|
|
||||||
'-B',
|
|
||||||
join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
|
|
||||||
jsontestrunner,
|
|
||||||
join_paths(meson.current_source_dir(), 'test/data')]
|
|
||||||
)
|
|
@@ -1,5 +1,7 @@
|
|||||||
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
prefix=@CMAKE_INSTALL_PREFIX@
|
||||||
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
exec_prefix=${prefix}
|
||||||
|
libdir=${exec_prefix}/@LIBRARY_INSTALL_DIR@
|
||||||
|
includedir=${prefix}/@INCLUDE_INSTALL_DIR@
|
||||||
|
|
||||||
Name: jsoncpp
|
Name: jsoncpp
|
||||||
Description: A C++ library for interacting with JSON
|
Description: A C++ library for interacting with JSON
|
||||||
|
53
scons-tools/globtool.py
Normal file
53
scons-tools/globtool.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import fnmatch
|
||||||
|
import os
|
||||||
|
|
||||||
|
def generate(env):
|
||||||
|
def Glob(env, includes = None, excludes = None, dir = '.'):
|
||||||
|
"""Adds Glob(includes = Split('*'), excludes = None, dir = '.')
|
||||||
|
helper function to environment.
|
||||||
|
|
||||||
|
Glob both the file-system files.
|
||||||
|
|
||||||
|
includes: list of file name pattern included in the return list when matched.
|
||||||
|
excludes: list of file name pattern exluced from the return list.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
sources = env.Glob(("*.cpp", '*.h'), "~*.cpp", "#src")
|
||||||
|
"""
|
||||||
|
def filterFilename(path):
|
||||||
|
abs_path = os.path.join(dir, path)
|
||||||
|
if not os.path.isfile(abs_path):
|
||||||
|
return 0
|
||||||
|
fn = os.path.basename(path)
|
||||||
|
match = 0
|
||||||
|
for include in includes:
|
||||||
|
if fnmatch.fnmatchcase(fn, include):
|
||||||
|
match = 1
|
||||||
|
break
|
||||||
|
if match == 1 and not excludes is None:
|
||||||
|
for exclude in excludes:
|
||||||
|
if fnmatch.fnmatchcase(fn, exclude):
|
||||||
|
match = 0
|
||||||
|
break
|
||||||
|
return match
|
||||||
|
if includes is None:
|
||||||
|
includes = ('*',)
|
||||||
|
elif type(includes) in (type(''), type(u'')):
|
||||||
|
includes = (includes,)
|
||||||
|
if type(excludes) in (type(''), type(u'')):
|
||||||
|
excludes = (excludes,)
|
||||||
|
dir = env.Dir(dir).abspath
|
||||||
|
paths = os.listdir(dir)
|
||||||
|
def makeAbsFileNode(path):
|
||||||
|
return env.File(os.path.join(dir, path))
|
||||||
|
nodes = filter(filterFilename, paths)
|
||||||
|
return map(makeAbsFileNode, nodes)
|
||||||
|
|
||||||
|
from SCons.Script import Environment
|
||||||
|
Environment.Glob = Glob
|
||||||
|
|
||||||
|
def exists(env):
|
||||||
|
"""
|
||||||
|
Tool always exists.
|
||||||
|
"""
|
||||||
|
return True
|
178
scons-tools/srcdist.py
Normal file
178
scons-tools/srcdist.py
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
from fnmatch import fnmatch
|
||||||
|
import targz
|
||||||
|
|
||||||
|
##def DoxyfileParse(file_contents):
|
||||||
|
## """
|
||||||
|
## Parse a Doxygen source file and return a dictionary of all the values.
|
||||||
|
## Values will be strings and lists of strings.
|
||||||
|
## """
|
||||||
|
## data = {}
|
||||||
|
##
|
||||||
|
## import shlex
|
||||||
|
## lex = shlex.shlex(instream = file_contents, posix = True)
|
||||||
|
## lex.wordchars += "*+./-:"
|
||||||
|
## lex.whitespace = lex.whitespace.replace("\n", "")
|
||||||
|
## lex.escape = ""
|
||||||
|
##
|
||||||
|
## lineno = lex.lineno
|
||||||
|
## last_backslash_lineno = lineno
|
||||||
|
## token = lex.get_token()
|
||||||
|
## key = token # the first token should be a key
|
||||||
|
## last_token = ""
|
||||||
|
## key_token = False
|
||||||
|
## next_key = False
|
||||||
|
## new_data = True
|
||||||
|
##
|
||||||
|
## def append_data(data, key, new_data, token):
|
||||||
|
## if new_data or len(data[key]) == 0:
|
||||||
|
## data[key].append(token)
|
||||||
|
## else:
|
||||||
|
## data[key][-1] += token
|
||||||
|
##
|
||||||
|
## while token:
|
||||||
|
## if token in ['\n']:
|
||||||
|
## if last_token not in ['\\']:
|
||||||
|
## key_token = True
|
||||||
|
## elif token in ['\\']:
|
||||||
|
## pass
|
||||||
|
## elif key_token:
|
||||||
|
## key = token
|
||||||
|
## key_token = False
|
||||||
|
## else:
|
||||||
|
## if token == "+=":
|
||||||
|
## if not data.has_key(key):
|
||||||
|
## data[key] = list()
|
||||||
|
## elif token == "=":
|
||||||
|
## data[key] = list()
|
||||||
|
## else:
|
||||||
|
## append_data(data, key, new_data, token)
|
||||||
|
## new_data = True
|
||||||
|
##
|
||||||
|
## last_token = token
|
||||||
|
## token = lex.get_token()
|
||||||
|
##
|
||||||
|
## if last_token == '\\' and token != '\n':
|
||||||
|
## new_data = False
|
||||||
|
## append_data(data, key, new_data, '\\')
|
||||||
|
##
|
||||||
|
## # compress lists of len 1 into single strings
|
||||||
|
## for (k, v) in data.items():
|
||||||
|
## if len(v) == 0:
|
||||||
|
## data.pop(k)
|
||||||
|
##
|
||||||
|
## # items in the following list will be kept as lists and not converted to strings
|
||||||
|
## if k in ["INPUT", "FILE_PATTERNS", "EXCLUDE_PATTERNS"]:
|
||||||
|
## continue
|
||||||
|
##
|
||||||
|
## if len(v) == 1:
|
||||||
|
## data[k] = v[0]
|
||||||
|
##
|
||||||
|
## return data
|
||||||
|
##
|
||||||
|
##def DoxySourceScan(node, env, path):
|
||||||
|
## """
|
||||||
|
## Doxygen Doxyfile source scanner. This should scan the Doxygen file and add
|
||||||
|
## any files used to generate docs to the list of source files.
|
||||||
|
## """
|
||||||
|
## default_file_patterns = [
|
||||||
|
## '*.c', '*.cc', '*.cxx', '*.cpp', '*.c++', '*.java', '*.ii', '*.ixx',
|
||||||
|
## '*.ipp', '*.i++', '*.inl', '*.h', '*.hh ', '*.hxx', '*.hpp', '*.h++',
|
||||||
|
## '*.idl', '*.odl', '*.cs', '*.php', '*.php3', '*.inc', '*.m', '*.mm',
|
||||||
|
## '*.py',
|
||||||
|
## ]
|
||||||
|
##
|
||||||
|
## default_exclude_patterns = [
|
||||||
|
## '*~',
|
||||||
|
## ]
|
||||||
|
##
|
||||||
|
## sources = []
|
||||||
|
##
|
||||||
|
## data = DoxyfileParse(node.get_contents())
|
||||||
|
##
|
||||||
|
## if data.get("RECURSIVE", "NO") == "YES":
|
||||||
|
## recursive = True
|
||||||
|
## else:
|
||||||
|
## recursive = False
|
||||||
|
##
|
||||||
|
## file_patterns = data.get("FILE_PATTERNS", default_file_patterns)
|
||||||
|
## exclude_patterns = data.get("EXCLUDE_PATTERNS", default_exclude_patterns)
|
||||||
|
##
|
||||||
|
## for node in data.get("INPUT", []):
|
||||||
|
## if os.path.isfile(node):
|
||||||
|
## sources.add(node)
|
||||||
|
## elif os.path.isdir(node):
|
||||||
|
## if recursive:
|
||||||
|
## for root, dirs, files in os.walk(node):
|
||||||
|
## for f in files:
|
||||||
|
## filename = os.path.join(root, f)
|
||||||
|
##
|
||||||
|
## pattern_check = reduce(lambda x, y: x or bool(fnmatch(filename, y)), file_patterns, False)
|
||||||
|
## exclude_check = reduce(lambda x, y: x and fnmatch(filename, y), exclude_patterns, True)
|
||||||
|
##
|
||||||
|
## if pattern_check and not exclude_check:
|
||||||
|
## sources.append(filename)
|
||||||
|
## else:
|
||||||
|
## for pattern in file_patterns:
|
||||||
|
## sources.extend(glob.glob("/".join([node, pattern])))
|
||||||
|
## sources = map(lambda path: env.File(path), sources)
|
||||||
|
## return sources
|
||||||
|
##
|
||||||
|
##
|
||||||
|
##def DoxySourceScanCheck(node, env):
|
||||||
|
## """Check if we should scan this file"""
|
||||||
|
## return os.path.isfile(node.path)
|
||||||
|
|
||||||
|
def srcDistEmitter(source, target, env):
|
||||||
|
## """Doxygen Doxyfile emitter"""
|
||||||
|
## # possible output formats and their default values and output locations
|
||||||
|
## output_formats = {
|
||||||
|
## "HTML": ("YES", "html"),
|
||||||
|
## "LATEX": ("YES", "latex"),
|
||||||
|
## "RTF": ("NO", "rtf"),
|
||||||
|
## "MAN": ("YES", "man"),
|
||||||
|
## "XML": ("NO", "xml"),
|
||||||
|
## }
|
||||||
|
##
|
||||||
|
## data = DoxyfileParse(source[0].get_contents())
|
||||||
|
##
|
||||||
|
## targets = []
|
||||||
|
## out_dir = data.get("OUTPUT_DIRECTORY", ".")
|
||||||
|
##
|
||||||
|
## # add our output locations
|
||||||
|
## for (k, v) in output_formats.items():
|
||||||
|
## if data.get("GENERATE_" + k, v[0]) == "YES":
|
||||||
|
## targets.append(env.Dir(os.path.join(out_dir, data.get(k + "_OUTPUT", v[1]))))
|
||||||
|
##
|
||||||
|
## # don't clobber targets
|
||||||
|
## for node in targets:
|
||||||
|
## env.Precious(node)
|
||||||
|
##
|
||||||
|
## # set up cleaning stuff
|
||||||
|
## for node in targets:
|
||||||
|
## env.Clean(node, node)
|
||||||
|
##
|
||||||
|
## return (targets, source)
|
||||||
|
return (target,source)
|
||||||
|
|
||||||
|
def generate(env):
|
||||||
|
"""
|
||||||
|
Add builders and construction variables for the
|
||||||
|
SrcDist tool.
|
||||||
|
"""
|
||||||
|
## doxyfile_scanner = env.Scanner(## DoxySourceScan,
|
||||||
|
## "DoxySourceScan",
|
||||||
|
## scan_check = DoxySourceScanCheck,
|
||||||
|
##)
|
||||||
|
|
||||||
|
if targz.exists(env):
|
||||||
|
srcdist_builder = targz.makeBuilder(srcDistEmitter)
|
||||||
|
|
||||||
|
env['BUILDERS']['SrcDist'] = srcdist_builder
|
||||||
|
|
||||||
|
def exists(env):
|
||||||
|
"""
|
||||||
|
Make sure srcdist exists.
|
||||||
|
"""
|
||||||
|
return targz.exists(env)
|
80
scons-tools/substinfile.py
Normal file
80
scons-tools/substinfile.py
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
import re
|
||||||
|
from SCons.Script import * # the usual scons stuff you get in a SConscript
|
||||||
|
import collections
|
||||||
|
|
||||||
|
def generate(env):
|
||||||
|
"""
|
||||||
|
Add builders and construction variables for the
|
||||||
|
SubstInFile tool.
|
||||||
|
|
||||||
|
Adds SubstInFile builder, which substitutes the keys->values of SUBST_DICT
|
||||||
|
from the source to the target.
|
||||||
|
The values of SUBST_DICT first have any construction variables expanded
|
||||||
|
(its keys are not expanded).
|
||||||
|
If a value of SUBST_DICT is a python callable function, it is called and
|
||||||
|
the result is expanded as the value.
|
||||||
|
If there's more than one source and more than one target, each target gets
|
||||||
|
substituted from the corresponding source.
|
||||||
|
"""
|
||||||
|
def do_subst_in_file(targetfile, sourcefile, dict):
|
||||||
|
"""Replace all instances of the keys of dict with their values.
|
||||||
|
For example, if dict is {'%VERSION%': '1.2345', '%BASE%': 'MyProg'},
|
||||||
|
then all instances of %VERSION% in the file will be replaced with 1.2345 etc.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
f = open(sourcefile, 'rb')
|
||||||
|
contents = f.read()
|
||||||
|
f.close()
|
||||||
|
except:
|
||||||
|
raise SCons.Errors.UserError("Can't read source file %s"%sourcefile)
|
||||||
|
for (k,v) in list(dict.items()):
|
||||||
|
contents = re.sub(k, v, contents)
|
||||||
|
try:
|
||||||
|
f = open(targetfile, 'wb')
|
||||||
|
f.write(contents)
|
||||||
|
f.close()
|
||||||
|
except:
|
||||||
|
raise SCons.Errors.UserError("Can't write target file %s"%targetfile)
|
||||||
|
return 0 # success
|
||||||
|
|
||||||
|
def subst_in_file(target, source, env):
|
||||||
|
if 'SUBST_DICT' not in env:
|
||||||
|
raise SCons.Errors.UserError("SubstInFile requires SUBST_DICT to be set.")
|
||||||
|
d = dict(env['SUBST_DICT']) # copy it
|
||||||
|
for (k,v) in list(d.items()):
|
||||||
|
if isinstance(v, collections.Callable):
|
||||||
|
d[k] = env.subst(v()).replace('\\','\\\\')
|
||||||
|
elif SCons.Util.is_String(v):
|
||||||
|
d[k] = env.subst(v).replace('\\','\\\\')
|
||||||
|
else:
|
||||||
|
raise SCons.Errors.UserError("SubstInFile: key %s: %s must be a string or callable"%(k, repr(v)))
|
||||||
|
for (t,s) in zip(target, source):
|
||||||
|
return do_subst_in_file(str(t), str(s), d)
|
||||||
|
|
||||||
|
def subst_in_file_string(target, source, env):
|
||||||
|
"""This is what gets printed on the console."""
|
||||||
|
return '\n'.join(['Substituting vars from %s into %s'%(str(s), str(t))
|
||||||
|
for (t,s) in zip(target, source)])
|
||||||
|
|
||||||
|
def subst_emitter(target, source, env):
|
||||||
|
"""Add dependency from substituted SUBST_DICT to target.
|
||||||
|
Returns original target, source tuple unchanged.
|
||||||
|
"""
|
||||||
|
d = env['SUBST_DICT'].copy() # copy it
|
||||||
|
for (k,v) in list(d.items()):
|
||||||
|
if isinstance(v, collections.Callable):
|
||||||
|
d[k] = env.subst(v())
|
||||||
|
elif SCons.Util.is_String(v):
|
||||||
|
d[k]=env.subst(v)
|
||||||
|
Depends(target, SCons.Node.Python.Value(d))
|
||||||
|
return target, source
|
||||||
|
|
||||||
|
## env.Append(TOOLS = 'substinfile') # this should be automaticaly done by Scons ?!?
|
||||||
|
subst_action = SCons.Action.Action(subst_in_file, subst_in_file_string)
|
||||||
|
env['BUILDERS']['SubstInFile'] = Builder(action=subst_action, emitter=subst_emitter)
|
||||||
|
|
||||||
|
def exists(env):
|
||||||
|
"""
|
||||||
|
Make sure tool exists.
|
||||||
|
"""
|
||||||
|
return True
|
82
scons-tools/targz.py
Normal file
82
scons-tools/targz.py
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
"""tarball
|
||||||
|
|
||||||
|
Tool-specific initialization for tarball.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
## Commands to tackle a command based implementation:
|
||||||
|
##to unpack on the fly...
|
||||||
|
##gunzip < FILE.tar.gz | tar xvf -
|
||||||
|
##to pack on the fly...
|
||||||
|
##tar cvf - FILE-LIST | gzip -c > FILE.tar.gz
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
import SCons.Builder
|
||||||
|
import SCons.Node.FS
|
||||||
|
import SCons.Util
|
||||||
|
|
||||||
|
try:
|
||||||
|
import gzip
|
||||||
|
import tarfile
|
||||||
|
internal_targz = 1
|
||||||
|
except ImportError:
|
||||||
|
internal_targz = 0
|
||||||
|
|
||||||
|
TARGZ_DEFAULT_COMPRESSION_LEVEL = 9
|
||||||
|
|
||||||
|
if internal_targz:
|
||||||
|
def targz(target, source, env):
|
||||||
|
def archive_name(path):
|
||||||
|
path = os.path.normpath(os.path.abspath(path))
|
||||||
|
common_path = os.path.commonprefix((base_dir, path))
|
||||||
|
archive_name = path[len(common_path):]
|
||||||
|
return archive_name
|
||||||
|
|
||||||
|
def visit(tar, dirname, names):
|
||||||
|
for name in names:
|
||||||
|
path = os.path.join(dirname, name)
|
||||||
|
if os.path.isfile(path):
|
||||||
|
tar.add(path, archive_name(path))
|
||||||
|
compression = env.get('TARGZ_COMPRESSION_LEVEL',TARGZ_DEFAULT_COMPRESSION_LEVEL)
|
||||||
|
base_dir = os.path.normpath(env.get('TARGZ_BASEDIR', env.Dir('.')).abspath)
|
||||||
|
target_path = str(target[0])
|
||||||
|
fileobj = gzip.GzipFile(target_path, 'wb', compression)
|
||||||
|
tar = tarfile.TarFile(os.path.splitext(target_path)[0], 'w', fileobj)
|
||||||
|
for source in source:
|
||||||
|
source_path = str(source)
|
||||||
|
if source.isdir():
|
||||||
|
os.path.walk(source_path, visit, tar)
|
||||||
|
else:
|
||||||
|
tar.add(source_path, archive_name(source_path)) # filename, arcname
|
||||||
|
tar.close()
|
||||||
|
|
||||||
|
targzAction = SCons.Action.Action(targz, varlist=['TARGZ_COMPRESSION_LEVEL','TARGZ_BASEDIR'])
|
||||||
|
|
||||||
|
def makeBuilder(emitter = None):
|
||||||
|
return SCons.Builder.Builder(action = SCons.Action.Action('$TARGZ_COM', '$TARGZ_COMSTR'),
|
||||||
|
source_factory = SCons.Node.FS.Entry,
|
||||||
|
source_scanner = SCons.Defaults.DirScanner,
|
||||||
|
suffix = '$TARGZ_SUFFIX',
|
||||||
|
multi = 1)
|
||||||
|
TarGzBuilder = makeBuilder()
|
||||||
|
|
||||||
|
def generate(env):
|
||||||
|
"""Add Builders and construction variables for zip to an Environment.
|
||||||
|
The following environnement variables may be set:
|
||||||
|
TARGZ_COMPRESSION_LEVEL: integer, [0-9]. 0: no compression, 9: best compression (same as gzip compression level).
|
||||||
|
TARGZ_BASEDIR: base-directory used to determine archive name (this allow archive name to be relative
|
||||||
|
to something other than top-dir).
|
||||||
|
"""
|
||||||
|
env['BUILDERS']['TarGz'] = TarGzBuilder
|
||||||
|
env['TARGZ_COM'] = targzAction
|
||||||
|
env['TARGZ_COMPRESSION_LEVEL'] = TARGZ_DEFAULT_COMPRESSION_LEVEL # range 0-9
|
||||||
|
env['TARGZ_SUFFIX'] = '.tar.gz'
|
||||||
|
env['TARGZ_BASEDIR'] = env.Dir('.') # Sources archive name are made relative to that directory.
|
||||||
|
else:
|
||||||
|
def generate(env):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def exists(env):
|
||||||
|
return internal_targz
|
@@ -2,4 +2,4 @@ ADD_SUBDIRECTORY(lib_json)
|
|||||||
IF(JSONCPP_WITH_TESTS)
|
IF(JSONCPP_WITH_TESTS)
|
||||||
ADD_SUBDIRECTORY(jsontestrunner)
|
ADD_SUBDIRECTORY(jsontestrunner)
|
||||||
ADD_SUBDIRECTORY(test_lib_json)
|
ADD_SUBDIRECTORY(test_lib_json)
|
||||||
ENDIF()
|
ENDIF(JSONCPP_WITH_TESTS)
|
||||||
|
@@ -1,15 +1,18 @@
|
|||||||
FIND_PACKAGE(PythonInterp 2.6)
|
FIND_PACKAGE(PythonInterp 2.6 REQUIRED)
|
||||||
|
|
||||||
|
IF(JSONCPP_LIB_BUILD_SHARED)
|
||||||
|
ADD_DEFINITIONS( -DJSON_DLL )
|
||||||
|
ENDIF(JSONCPP_LIB_BUILD_SHARED)
|
||||||
|
|
||||||
ADD_EXECUTABLE(jsontestrunner_exe
|
ADD_EXECUTABLE(jsontestrunner_exe
|
||||||
main.cpp
|
main.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
IF(BUILD_SHARED_LIBS)
|
IF(JSONCPP_LIB_BUILD_SHARED)
|
||||||
ADD_DEFINITIONS( -DJSON_DLL )
|
|
||||||
TARGET_LINK_LIBRARIES(jsontestrunner_exe jsoncpp_lib)
|
TARGET_LINK_LIBRARIES(jsontestrunner_exe jsoncpp_lib)
|
||||||
ELSE(BUILD_SHARED_LIBS)
|
ELSE(JSONCPP_LIB_BUILD_SHARED)
|
||||||
TARGET_LINK_LIBRARIES(jsontestrunner_exe jsoncpp_lib_static)
|
TARGET_LINK_LIBRARIES(jsontestrunner_exe jsoncpp_lib_static)
|
||||||
ENDIF()
|
ENDIF(JSONCPP_LIB_BUILD_SHARED)
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe)
|
SET_TARGET_PROPERTIES(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe)
|
||||||
|
|
||||||
@@ -17,9 +20,9 @@ IF(PYTHONINTERP_FOUND)
|
|||||||
# Run end to end parser/writer tests
|
# Run end to end parser/writer tests
|
||||||
SET(TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../test)
|
SET(TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../test)
|
||||||
SET(RUNJSONTESTS_PATH ${TEST_DIR}/runjsontests.py)
|
SET(RUNJSONTESTS_PATH ${TEST_DIR}/runjsontests.py)
|
||||||
ADD_CUSTOM_TARGET(jsoncpp_readerwriter_tests
|
ADD_CUSTOM_TARGET(jsoncpp_readerwriter_tests ALL
|
||||||
"${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $<TARGET_FILE:jsontestrunner_exe> "${TEST_DIR}/data"
|
"${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $<TARGET_FILE:jsontestrunner_exe> "${TEST_DIR}/data"
|
||||||
DEPENDS jsontestrunner_exe jsoncpp_test
|
DEPENDS jsontestrunner_exe jsoncpp_test
|
||||||
)
|
)
|
||||||
ADD_CUSTOM_TARGET(jsoncpp_check DEPENDS jsoncpp_readerwriter_tests)
|
ADD_CUSTOM_TARGET(jsoncpp_check DEPENDS jsoncpp_readerwriter_tests)
|
||||||
ENDIF()
|
ENDIF(PYTHONINTERP_FOUND)
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@@ -17,14 +17,14 @@
|
|||||||
|
|
||||||
struct Options
|
struct Options
|
||||||
{
|
{
|
||||||
JSONCPP_STRING path;
|
std::string path;
|
||||||
Json::Features features;
|
Json::Features features;
|
||||||
bool parseOnly;
|
bool parseOnly;
|
||||||
typedef JSONCPP_STRING (*writeFuncType)(Json::Value const&);
|
typedef std::string (*writeFuncType)(Json::Value const&);
|
||||||
writeFuncType write;
|
writeFuncType write;
|
||||||
};
|
};
|
||||||
|
|
||||||
static JSONCPP_STRING normalizeFloatingPointStr(double value) {
|
static std::string normalizeFloatingPointStr(double value) {
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
|
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
|
||||||
sprintf_s(buffer, sizeof(buffer), "%.16g", value);
|
sprintf_s(buffer, sizeof(buffer), "%.16g", value);
|
||||||
@@ -32,18 +32,18 @@ static JSONCPP_STRING normalizeFloatingPointStr(double value) {
|
|||||||
snprintf(buffer, sizeof(buffer), "%.16g", value);
|
snprintf(buffer, sizeof(buffer), "%.16g", value);
|
||||||
#endif
|
#endif
|
||||||
buffer[sizeof(buffer) - 1] = 0;
|
buffer[sizeof(buffer) - 1] = 0;
|
||||||
JSONCPP_STRING s(buffer);
|
std::string s(buffer);
|
||||||
JSONCPP_STRING::size_type index = s.find_last_of("eE");
|
std::string::size_type index = s.find_last_of("eE");
|
||||||
if (index != JSONCPP_STRING::npos) {
|
if (index != std::string::npos) {
|
||||||
JSONCPP_STRING::size_type hasSign =
|
std::string::size_type hasSign =
|
||||||
(s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0;
|
(s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0;
|
||||||
JSONCPP_STRING::size_type exponentStartIndex = index + 1 + hasSign;
|
std::string::size_type exponentStartIndex = index + 1 + hasSign;
|
||||||
JSONCPP_STRING normalized = s.substr(0, exponentStartIndex);
|
std::string normalized = s.substr(0, exponentStartIndex);
|
||||||
JSONCPP_STRING::size_type indexDigit =
|
std::string::size_type indexDigit =
|
||||||
s.find_first_not_of('0', exponentStartIndex);
|
s.find_first_not_of('0', exponentStartIndex);
|
||||||
JSONCPP_STRING exponent = "0";
|
std::string exponent = "0";
|
||||||
if (indexDigit !=
|
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);
|
exponent = s.substr(indexDigit);
|
||||||
}
|
}
|
||||||
@@ -52,18 +52,17 @@ static JSONCPP_STRING normalizeFloatingPointStr(double value) {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSONCPP_STRING readInputTestFile(const char* path) {
|
static std::string readInputTestFile(const char* path) {
|
||||||
FILE* file = fopen(path, "rb");
|
FILE* file = fopen(path, "rb");
|
||||||
if (!file)
|
if (!file)
|
||||||
return JSONCPP_STRING("");
|
return std::string("");
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
long const size = ftell(file);
|
long size = ftell(file);
|
||||||
unsigned long const usize = static_cast<unsigned long>(size);
|
|
||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
JSONCPP_STRING text;
|
std::string text;
|
||||||
char* buffer = new char[size + 1];
|
char* buffer = new char[size + 1];
|
||||||
buffer[size] = 0;
|
buffer[size] = 0;
|
||||||
if (fread(buffer, 1, usize, file) == usize)
|
if (fread(buffer, 1, size, file) == (unsigned long)size)
|
||||||
text = buffer;
|
text = buffer;
|
||||||
fclose(file);
|
fclose(file);
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
@@ -71,7 +70,7 @@ static JSONCPP_STRING readInputTestFile(const char* path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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)) {
|
if (value.hasComment(Json::commentBefore)) {
|
||||||
fprintf(fout, "%s\n", value.getComment(Json::commentBefore).c_str());
|
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;
|
break;
|
||||||
case Json::arrayValue: {
|
case Json::arrayValue: {
|
||||||
fprintf(fout, "%s=[]\n", path.c_str());
|
fprintf(fout, "%s=[]\n", path.c_str());
|
||||||
Json::ArrayIndex size = value.size();
|
int size = value.size();
|
||||||
for (Json::ArrayIndex index = 0; index < size; ++index) {
|
for (int index = 0; index < size; ++index) {
|
||||||
static char buffer[16];
|
static char buffer[16];
|
||||||
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
|
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
|
||||||
sprintf_s(buffer, sizeof(buffer), "[%d]", index);
|
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());
|
fprintf(fout, "%s={}\n", path.c_str());
|
||||||
Json::Value::Members members(value.getMemberNames());
|
Json::Value::Members members(value.getMemberNames());
|
||||||
std::sort(members.begin(), members.end());
|
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();
|
for (Json::Value::Members::iterator it = members.begin();
|
||||||
it != members.end();
|
it != members.end();
|
||||||
++it) {
|
++it) {
|
||||||
const JSONCPP_STRING name = *it;
|
const std::string& name = *it;
|
||||||
printValueTree(fout, value[name], path + suffix + name);
|
printValueTree(fout, value[name], path + suffix + name);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@@ -137,15 +136,15 @@ printValueTree(FILE* fout, Json::Value& value, const JSONCPP_STRING& path = ".")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parseAndSaveValueTree(const JSONCPP_STRING& input,
|
static int parseAndSaveValueTree(const std::string& input,
|
||||||
const JSONCPP_STRING& actual,
|
const std::string& actual,
|
||||||
const JSONCPP_STRING& kind,
|
const std::string& kind,
|
||||||
const Json::Features& features,
|
const Json::Features& features,
|
||||||
bool parseOnly,
|
bool parseOnly,
|
||||||
Json::Value* root)
|
Json::Value* root)
|
||||||
{
|
{
|
||||||
Json::Reader reader(features);
|
Json::Reader reader(features);
|
||||||
bool parsingSuccessful = reader.parse(input.data(), input.data() + input.size(), *root);
|
bool parsingSuccessful = reader.parse(input, *root);
|
||||||
if (!parsingSuccessful) {
|
if (!parsingSuccessful) {
|
||||||
printf("Failed to parse %s file: \n%s\n",
|
printf("Failed to parse %s file: \n%s\n",
|
||||||
kind.c_str(),
|
kind.c_str(),
|
||||||
@@ -163,36 +162,36 @@ static int parseAndSaveValueTree(const JSONCPP_STRING& input,
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// static JSONCPP_STRING useFastWriter(Json::Value const& root) {
|
// static std::string useFastWriter(Json::Value const& root) {
|
||||||
// Json::FastWriter writer;
|
// Json::FastWriter writer;
|
||||||
// writer.enableYAMLCompatibility();
|
// writer.enableYAMLCompatibility();
|
||||||
// return writer.write(root);
|
// return writer.write(root);
|
||||||
// }
|
// }
|
||||||
static JSONCPP_STRING useStyledWriter(
|
static std::string useStyledWriter(
|
||||||
Json::Value const& root)
|
Json::Value const& root)
|
||||||
{
|
{
|
||||||
Json::StyledWriter writer;
|
Json::StyledWriter writer;
|
||||||
return writer.write(root);
|
return writer.write(root);
|
||||||
}
|
}
|
||||||
static JSONCPP_STRING useStyledStreamWriter(
|
static std::string useStyledStreamWriter(
|
||||||
Json::Value const& root)
|
Json::Value const& root)
|
||||||
{
|
{
|
||||||
Json::StyledStreamWriter writer;
|
Json::StyledStreamWriter writer;
|
||||||
JSONCPP_OSTRINGSTREAM sout;
|
std::ostringstream sout;
|
||||||
writer.write(sout, root);
|
writer.write(sout, root);
|
||||||
return sout.str();
|
return sout.str();
|
||||||
}
|
}
|
||||||
static JSONCPP_STRING useBuiltStyledStreamWriter(
|
static std::string useBuiltStyledStreamWriter(
|
||||||
Json::Value const& root)
|
Json::Value const& root)
|
||||||
{
|
{
|
||||||
Json::StreamWriterBuilder builder;
|
Json::StreamWriterBuilder builder;
|
||||||
return Json::writeString(builder, root);
|
return Json::writeString(builder, root);
|
||||||
}
|
}
|
||||||
static int rewriteValueTree(
|
static int rewriteValueTree(
|
||||||
const JSONCPP_STRING& rewritePath,
|
const std::string& rewritePath,
|
||||||
const Json::Value& root,
|
const Json::Value& root,
|
||||||
Options::writeFuncType write,
|
Options::writeFuncType write,
|
||||||
JSONCPP_STRING* rewrite)
|
std::string* rewrite)
|
||||||
{
|
{
|
||||||
*rewrite = write(root);
|
*rewrite = write(root);
|
||||||
FILE* fout = fopen(rewritePath.c_str(), "wt");
|
FILE* fout = fopen(rewritePath.c_str(), "wt");
|
||||||
@@ -205,13 +204,13 @@ static int rewriteValueTree(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSONCPP_STRING removeSuffix(const JSONCPP_STRING& path,
|
static std::string removeSuffix(const std::string& path,
|
||||||
const JSONCPP_STRING& extension) {
|
const std::string& extension) {
|
||||||
if (extension.length() >= path.length())
|
if (extension.length() >= path.length())
|
||||||
return JSONCPP_STRING("");
|
return std::string("");
|
||||||
JSONCPP_STRING suffix = path.substr(path.length() - extension.length());
|
std::string suffix = path.substr(path.length() - extension.length());
|
||||||
if (suffix != extension)
|
if (suffix != extension)
|
||||||
return JSONCPP_STRING("");
|
return std::string("");
|
||||||
return path.substr(0, path.length() - extension.length());
|
return path.substr(0, path.length() - extension.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,18 +237,18 @@ static int parseCommandLine(
|
|||||||
return printUsage(argv);
|
return printUsage(argv);
|
||||||
}
|
}
|
||||||
int index = 1;
|
int index = 1;
|
||||||
if (JSONCPP_STRING(argv[index]) == "--json-checker") {
|
if (std::string(argv[index]) == "--json-checker") {
|
||||||
opts->features = Json::Features::strictMode();
|
opts->features = Json::Features::strictMode();
|
||||||
opts->parseOnly = true;
|
opts->parseOnly = true;
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
if (JSONCPP_STRING(argv[index]) == "--json-config") {
|
if (std::string(argv[index]) == "--json-config") {
|
||||||
printConfig();
|
printConfig();
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
if (JSONCPP_STRING(argv[index]) == "--json-writer") {
|
if (std::string(argv[index]) == "--json-writer") {
|
||||||
++index;
|
++index;
|
||||||
JSONCPP_STRING const writerName(argv[index++]);
|
std::string const writerName(argv[index++]);
|
||||||
if (writerName == "StyledWriter") {
|
if (writerName == "StyledWriter") {
|
||||||
opts->write = &useStyledWriter;
|
opts->write = &useStyledWriter;
|
||||||
} else if (writerName == "StyledStreamWriter") {
|
} else if (writerName == "StyledStreamWriter") {
|
||||||
@@ -271,22 +270,22 @@ static int runTest(Options const& opts)
|
|||||||
{
|
{
|
||||||
int exitCode = 0;
|
int exitCode = 0;
|
||||||
|
|
||||||
JSONCPP_STRING input = readInputTestFile(opts.path.c_str());
|
std::string input = readInputTestFile(opts.path.c_str());
|
||||||
if (input.empty()) {
|
if (input.empty()) {
|
||||||
printf("Failed to read input or empty input: %s\n", opts.path.c_str());
|
printf("Failed to read input or empty input: %s\n", opts.path.c_str());
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONCPP_STRING basePath = removeSuffix(opts.path, ".json");
|
std::string basePath = removeSuffix(opts.path, ".json");
|
||||||
if (!opts.parseOnly && basePath.empty()) {
|
if (!opts.parseOnly && basePath.empty()) {
|
||||||
printf("Bad input path. Path does not end with '.expected':\n%s\n",
|
printf("Bad input path. Path does not end with '.expected':\n%s\n",
|
||||||
opts.path.c_str());
|
opts.path.c_str());
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONCPP_STRING const actualPath = basePath + ".actual";
|
std::string const actualPath = basePath + ".actual";
|
||||||
JSONCPP_STRING const rewritePath = basePath + ".rewrite";
|
std::string const rewritePath = basePath + ".rewrite";
|
||||||
JSONCPP_STRING const rewriteActualPath = basePath + ".actual-rewrite";
|
std::string const rewriteActualPath = basePath + ".actual-rewrite";
|
||||||
|
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
exitCode = parseAndSaveValueTree(
|
exitCode = parseAndSaveValueTree(
|
||||||
@@ -295,7 +294,7 @@ static int runTest(Options const& opts)
|
|||||||
if (exitCode || opts.parseOnly) {
|
if (exitCode || opts.parseOnly) {
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
JSONCPP_STRING rewrite;
|
std::string rewrite;
|
||||||
exitCode = rewriteValueTree(rewritePath, root, opts.write, &rewrite);
|
exitCode = rewriteValueTree(rewritePath, root, opts.write, &rewrite);
|
||||||
if (exitCode) {
|
if (exitCode) {
|
||||||
return exitCode;
|
return exitCode;
|
||||||
@@ -311,12 +310,12 @@ static int runTest(Options const& opts)
|
|||||||
}
|
}
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
Options opts;
|
Options opts;
|
||||||
try {
|
|
||||||
int exitCode = parseCommandLine(argc, argv, &opts);
|
int exitCode = parseCommandLine(argc, argv, &opts);
|
||||||
if (exitCode != 0) {
|
if (exitCode != 0) {
|
||||||
printf("Failed to parse command-line.");
|
printf("Failed to parse command-line.");
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
return runTest(opts);
|
return runTest(opts);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
|
9
src/jsontestrunner/sconscript
Normal file
9
src/jsontestrunner/sconscript
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
Import( 'env_testing buildJSONTests' )
|
||||||
|
|
||||||
|
buildJSONTests( env_testing, Split( """
|
||||||
|
main.cpp
|
||||||
|
""" ),
|
||||||
|
'jsontestrunner' )
|
||||||
|
|
||||||
|
# For 'check' to work, 'libs' must be built first.
|
||||||
|
env_testing.Depends('jsontestrunner', '#libs')
|
@@ -1,41 +1,20 @@
|
|||||||
IF( CMAKE_COMPILER_IS_GNUCXX )
|
OPTION(JSONCPP_LIB_BUILD_SHARED "Build jsoncpp_lib as a shared library." OFF)
|
||||||
#Get compiler version.
|
OPTION(JSONCPP_LIB_BUILD_STATIC "Build jsoncpp_lib static library." ON)
|
||||||
EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
|
|
||||||
OUTPUT_VARIABLE GNUCXX_VERSION )
|
|
||||||
|
|
||||||
#-Werror=* was introduced -after- GCC 4.1.2
|
IF(BUILD_SHARED_LIBS)
|
||||||
IF( GNUCXX_VERSION VERSION_GREATER 4.1.2 )
|
SET(JSONCPP_LIB_BUILD_SHARED ON)
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=strict-aliasing")
|
ENDIF(BUILD_SHARED_LIBS)
|
||||||
ENDIF()
|
|
||||||
ENDIF( CMAKE_COMPILER_IS_GNUCXX )
|
|
||||||
|
|
||||||
INCLUDE(CheckIncludeFileCXX)
|
if( CMAKE_COMPILER_IS_GNUCXX )
|
||||||
INCLUDE(CheckTypeSize)
|
#Get compiler version.
|
||||||
INCLUDE(CheckStructHasMember)
|
execute_process( COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
|
||||||
INCLUDE(CheckCXXSymbolExists)
|
OUTPUT_VARIABLE GNUCXX_VERSION )
|
||||||
|
|
||||||
check_include_file_cxx(clocale HAVE_CLOCALE)
|
#-Werror=* was introduced -after- GCC 4.1.2
|
||||||
check_cxx_symbol_exists(localeconv clocale HAVE_LOCALECONV)
|
if( GNUCXX_VERSION VERSION_GREATER 4.1.2 )
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=strict-aliasing")
|
||||||
IF(CMAKE_VERSION VERSION_LESS 3.0.0)
|
endif()
|
||||||
# The "LANGUAGE CXX" parameter is not supported in CMake versions below 3,
|
endif( CMAKE_COMPILER_IS_GNUCXX )
|
||||||
# so the C compiler and header has to be used.
|
|
||||||
check_include_file(locale.h HAVE_LOCALE_H)
|
|
||||||
SET(CMAKE_EXTRA_INCLUDE_FILES locale.h)
|
|
||||||
check_type_size("struct lconv" LCONV_SIZE)
|
|
||||||
UNSET(CMAKE_EXTRA_INCLUDE_FILES)
|
|
||||||
check_struct_has_member("struct lconv" decimal_point locale.h HAVE_DECIMAL_POINT)
|
|
||||||
ELSE()
|
|
||||||
SET(CMAKE_EXTRA_INCLUDE_FILES clocale)
|
|
||||||
check_type_size(lconv LCONV_SIZE LANGUAGE CXX)
|
|
||||||
UNSET(CMAKE_EXTRA_INCLUDE_FILES)
|
|
||||||
check_struct_has_member(lconv decimal_point clocale HAVE_DECIMAL_POINT LANGUAGE CXX)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
IF(NOT (HAVE_CLOCALE AND HAVE_LCONV_SIZE AND HAVE_DECIMAL_POINT AND HAVE_LOCALECONV))
|
|
||||||
MESSAGE(WARNING "Locale functionality is not supported")
|
|
||||||
ADD_DEFINITIONS(-DJSONCPP_NO_LOCALE_SUPPORT)
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET( JSONCPP_INCLUDE_DIR ../../include )
|
SET( JSONCPP_INCLUDE_DIR ../../include )
|
||||||
|
|
||||||
@@ -55,6 +34,7 @@ SOURCE_GROUP( "Public API" FILES ${PUBLIC_HEADERS} )
|
|||||||
SET(jsoncpp_sources
|
SET(jsoncpp_sources
|
||||||
json_tool.h
|
json_tool.h
|
||||||
json_reader.cpp
|
json_reader.cpp
|
||||||
|
json_batchallocator.h
|
||||||
json_valueiterator.inl
|
json_valueiterator.inl
|
||||||
json_value.cpp
|
json_value.cpp
|
||||||
json_writer.cpp
|
json_writer.cpp
|
||||||
@@ -65,53 +45,42 @@ IF(JSONCPP_WITH_CMAKE_PACKAGE)
|
|||||||
SET(INSTALL_EXPORT EXPORT jsoncpp)
|
SET(INSTALL_EXPORT EXPORT jsoncpp)
|
||||||
ELSE(JSONCPP_WITH_CMAKE_PACKAGE)
|
ELSE(JSONCPP_WITH_CMAKE_PACKAGE)
|
||||||
SET(INSTALL_EXPORT)
|
SET(INSTALL_EXPORT)
|
||||||
ENDIF()
|
ENDIF(JSONCPP_WITH_CMAKE_PACKAGE)
|
||||||
|
|
||||||
IF(BUILD_SHARED_LIBS)
|
IF(JSONCPP_LIB_BUILD_SHARED)
|
||||||
ADD_DEFINITIONS( -DJSON_DLL_BUILD )
|
ADD_DEFINITIONS( -DJSON_DLL_BUILD )
|
||||||
ADD_LIBRARY(jsoncpp_lib SHARED ${PUBLIC_HEADERS} ${jsoncpp_sources})
|
ADD_LIBRARY(jsoncpp_lib SHARED ${PUBLIC_HEADERS} ${jsoncpp_sources})
|
||||||
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_SOVERSION})
|
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_VERSION_MAJOR})
|
||||||
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES OUTPUT_NAME jsoncpp
|
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES OUTPUT_NAME jsoncpp )
|
||||||
DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )
|
|
||||||
|
|
||||||
# Set library's runtime search path on OSX
|
|
||||||
IF(APPLE)
|
|
||||||
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES INSTALL_RPATH "@loader_path/." )
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
INSTALL( TARGETS jsoncpp_lib ${INSTALL_EXPORT}
|
INSTALL( TARGETS jsoncpp_lib ${INSTALL_EXPORT}
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
ARCHIVE DESTINATION ${ARCHIVE_INSTALL_DIR})
|
||||||
|
|
||||||
IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
|
IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||||
TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib PUBLIC
|
TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib PUBLIC
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>)
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>)
|
||||||
ENDIF()
|
ENDIF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||||
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(BUILD_STATIC_LIBS)
|
IF(JSONCPP_LIB_BUILD_STATIC)
|
||||||
ADD_LIBRARY(jsoncpp_lib_static STATIC ${PUBLIC_HEADERS} ${jsoncpp_sources})
|
ADD_LIBRARY(jsoncpp_lib_static STATIC ${PUBLIC_HEADERS} ${jsoncpp_sources})
|
||||||
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_SOVERSION})
|
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_VERSION_MAJOR})
|
||||||
# avoid name clashes on windows as the shared import lib is also named jsoncpp.lib
|
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES OUTPUT_NAME jsoncpp )
|
||||||
if (NOT DEFINED STATIC_SUFFIX AND BUILD_SHARED_LIBS)
|
|
||||||
set (STATIC_SUFFIX "_static")
|
|
||||||
endif ()
|
|
||||||
set_target_properties (jsoncpp_lib_static PROPERTIES OUTPUT_NAME jsoncpp${STATIC_SUFFIX}
|
|
||||||
DEBUG_OUTPUT_NAME jsoncpp${STATIC_SUFFIX}${DEBUG_LIBNAME_SUFFIX})
|
|
||||||
|
|
||||||
INSTALL( TARGETS jsoncpp_lib_static ${INSTALL_EXPORT}
|
INSTALL( TARGETS jsoncpp_lib_static ${INSTALL_EXPORT}
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
ARCHIVE DESTINATION ${ARCHIVE_INSTALL_DIR})
|
||||||
|
|
||||||
IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
|
IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||||
TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib_static PUBLIC
|
TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib_static PUBLIC
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
|
||||||
)
|
)
|
||||||
ENDIF()
|
ENDIF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||||
|
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
121
src/lib_json/json_batchallocator.h
Normal file
121
src/lib_json/json_batchallocator.h
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
// 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 JSONCPP_BATCHALLOCATOR_H_INCLUDED
|
||||||
|
#define JSONCPP_BATCHALLOCATOR_H_INCLUDED
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
||||||
|
|
||||||
|
namespace Json {
|
||||||
|
|
||||||
|
/* Fast memory allocator.
|
||||||
|
*
|
||||||
|
* This memory allocator allocates memory for a batch of object (specified by
|
||||||
|
* the page size, the number of object in each page).
|
||||||
|
*
|
||||||
|
* It does not allow the destruction of a single object. All the allocated
|
||||||
|
* objects can be destroyed at once. The memory can be either released or reused
|
||||||
|
* for future allocation.
|
||||||
|
*
|
||||||
|
* The in-place new operator must be used to construct the object using the
|
||||||
|
* pointer returned by allocate.
|
||||||
|
*/
|
||||||
|
template <typename AllocatedType, const unsigned int objectPerAllocation>
|
||||||
|
class BatchAllocator {
|
||||||
|
public:
|
||||||
|
BatchAllocator(unsigned int objectsPerPage = 255)
|
||||||
|
: freeHead_(0), objectsPerPage_(objectsPerPage) {
|
||||||
|
// printf( "Size: %d => %s\n", sizeof(AllocatedType),
|
||||||
|
// typeid(AllocatedType).name() );
|
||||||
|
assert(sizeof(AllocatedType) * objectPerAllocation >=
|
||||||
|
sizeof(AllocatedType*)); // We must be able to store a slist in the
|
||||||
|
// object free space.
|
||||||
|
assert(objectsPerPage >= 16);
|
||||||
|
batches_ = allocateBatch(0); // allocated a dummy page
|
||||||
|
currentBatch_ = batches_;
|
||||||
|
}
|
||||||
|
|
||||||
|
~BatchAllocator() {
|
||||||
|
for (BatchInfo* batch = batches_; batch;) {
|
||||||
|
BatchInfo* nextBatch = batch->next_;
|
||||||
|
free(batch);
|
||||||
|
batch = nextBatch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// allocate space for an array of objectPerAllocation object.
|
||||||
|
/// @warning it is the responsability of the caller to call objects
|
||||||
|
/// constructors.
|
||||||
|
AllocatedType* allocate() {
|
||||||
|
if (freeHead_) // returns node from free list.
|
||||||
|
{
|
||||||
|
AllocatedType* object = freeHead_;
|
||||||
|
freeHead_ = *(AllocatedType**)object;
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
if (currentBatch_->used_ == currentBatch_->end_) {
|
||||||
|
currentBatch_ = currentBatch_->next_;
|
||||||
|
while (currentBatch_ && currentBatch_->used_ == currentBatch_->end_)
|
||||||
|
currentBatch_ = currentBatch_->next_;
|
||||||
|
|
||||||
|
if (!currentBatch_) // no free batch found, allocate a new one
|
||||||
|
{
|
||||||
|
currentBatch_ = allocateBatch(objectsPerPage_);
|
||||||
|
currentBatch_->next_ = batches_; // insert at the head of the list
|
||||||
|
batches_ = currentBatch_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AllocatedType* allocated = currentBatch_->used_;
|
||||||
|
currentBatch_->used_ += objectPerAllocation;
|
||||||
|
return allocated;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Release the object.
|
||||||
|
/// @warning it is the responsability of the caller to actually destruct the
|
||||||
|
/// object.
|
||||||
|
void release(AllocatedType* object) {
|
||||||
|
assert(object != 0);
|
||||||
|
*(AllocatedType**)object = freeHead_;
|
||||||
|
freeHead_ = object;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct BatchInfo {
|
||||||
|
BatchInfo* next_;
|
||||||
|
AllocatedType* used_;
|
||||||
|
AllocatedType* end_;
|
||||||
|
AllocatedType buffer_[objectPerAllocation];
|
||||||
|
};
|
||||||
|
|
||||||
|
// disabled copy constructor and assignement operator.
|
||||||
|
BatchAllocator(const BatchAllocator&);
|
||||||
|
void operator=(const BatchAllocator&);
|
||||||
|
|
||||||
|
static BatchInfo* allocateBatch(unsigned int objectsPerPage) {
|
||||||
|
const unsigned int mallocSize =
|
||||||
|
sizeof(BatchInfo) - sizeof(AllocatedType) * objectPerAllocation +
|
||||||
|
sizeof(AllocatedType) * objectPerAllocation * objectsPerPage;
|
||||||
|
BatchInfo* batch = static_cast<BatchInfo*>(malloc(mallocSize));
|
||||||
|
batch->next_ = 0;
|
||||||
|
batch->used_ = batch->buffer_;
|
||||||
|
batch->end_ = batch->buffer_ + objectsPerPage;
|
||||||
|
return batch;
|
||||||
|
}
|
||||||
|
|
||||||
|
BatchInfo* batches_;
|
||||||
|
BatchInfo* currentBatch_;
|
||||||
|
/// Head of a single linked list within the allocated space of freeed object
|
||||||
|
AllocatedType* freeHead_;
|
||||||
|
unsigned int objectsPerPage_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Json
|
||||||
|
|
||||||
|
#endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION
|
||||||
|
|
||||||
|
#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED
|
360
src/lib_json/json_internalarray.inl
Normal file
360
src/lib_json/json_internalarray.inl
Normal file
@@ -0,0 +1,360 @@
|
|||||||
|
// 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
|
||||||
|
|
||||||
|
// included by json_value.cpp
|
||||||
|
|
||||||
|
namespace Json {
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// class ValueInternalArray
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ValueArrayAllocator::~ValueArrayAllocator() {}
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// class DefaultValueArrayAllocator
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
|
||||||
|
class DefaultValueArrayAllocator : public ValueArrayAllocator {
|
||||||
|
public: // overridden from ValueArrayAllocator
|
||||||
|
virtual ~DefaultValueArrayAllocator() {}
|
||||||
|
|
||||||
|
virtual ValueInternalArray* newArray() { return new ValueInternalArray(); }
|
||||||
|
|
||||||
|
virtual ValueInternalArray* newArrayCopy(const ValueInternalArray& other) {
|
||||||
|
return new ValueInternalArray(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void destructArray(ValueInternalArray* array) { delete array; }
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
reallocateArrayPageIndex(Value**& indexes,
|
||||||
|
ValueInternalArray::PageIndex& indexCount,
|
||||||
|
ValueInternalArray::PageIndex minNewIndexCount) {
|
||||||
|
ValueInternalArray::PageIndex newIndexCount = (indexCount * 3) / 2 + 1;
|
||||||
|
if (minNewIndexCount > newIndexCount)
|
||||||
|
newIndexCount = minNewIndexCount;
|
||||||
|
void* newIndexes = realloc(indexes, sizeof(Value*) * newIndexCount);
|
||||||
|
JSON_ASSERT_MESSAGE(newIndexes, "Couldn't realloc.");
|
||||||
|
indexCount = newIndexCount;
|
||||||
|
indexes = static_cast<Value**>(newIndexes);
|
||||||
|
}
|
||||||
|
virtual void releaseArrayPageIndex(Value** indexes,
|
||||||
|
ValueInternalArray::PageIndex indexCount) {
|
||||||
|
if (indexes)
|
||||||
|
free(indexes);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual Value* allocateArrayPage() {
|
||||||
|
return static_cast<Value*>(
|
||||||
|
malloc(sizeof(Value) * ValueInternalArray::itemsPerPage));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void releaseArrayPage(Value* value) {
|
||||||
|
if (value)
|
||||||
|
free(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#else // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
|
||||||
|
/// @todo make this thread-safe (lock when accessign batch allocator)
|
||||||
|
class DefaultValueArrayAllocator : public ValueArrayAllocator {
|
||||||
|
public: // overridden from ValueArrayAllocator
|
||||||
|
virtual ~DefaultValueArrayAllocator() {}
|
||||||
|
|
||||||
|
virtual ValueInternalArray* newArray() {
|
||||||
|
ValueInternalArray* array = arraysAllocator_.allocate();
|
||||||
|
new (array) ValueInternalArray(); // placement new
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ValueInternalArray* newArrayCopy(const ValueInternalArray& other) {
|
||||||
|
ValueInternalArray* array = arraysAllocator_.allocate();
|
||||||
|
new (array) ValueInternalArray(other); // placement new
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void destructArray(ValueInternalArray* array) {
|
||||||
|
if (array) {
|
||||||
|
array->~ValueInternalArray();
|
||||||
|
arraysAllocator_.release(array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
reallocateArrayPageIndex(Value**& indexes,
|
||||||
|
ValueInternalArray::PageIndex& indexCount,
|
||||||
|
ValueInternalArray::PageIndex minNewIndexCount) {
|
||||||
|
ValueInternalArray::PageIndex newIndexCount = (indexCount * 3) / 2 + 1;
|
||||||
|
if (minNewIndexCount > newIndexCount)
|
||||||
|
newIndexCount = minNewIndexCount;
|
||||||
|
void* newIndexes = realloc(indexes, sizeof(Value*) * newIndexCount);
|
||||||
|
JSON_ASSERT_MESSAGE(newIndexes, "Couldn't realloc.");
|
||||||
|
indexCount = newIndexCount;
|
||||||
|
indexes = static_cast<Value**>(newIndexes);
|
||||||
|
}
|
||||||
|
virtual void releaseArrayPageIndex(Value** indexes,
|
||||||
|
ValueInternalArray::PageIndex indexCount) {
|
||||||
|
if (indexes)
|
||||||
|
free(indexes);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual Value* allocateArrayPage() {
|
||||||
|
return static_cast<Value*>(pagesAllocator_.allocate());
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void releaseArrayPage(Value* value) {
|
||||||
|
if (value)
|
||||||
|
pagesAllocator_.release(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
BatchAllocator<ValueInternalArray, 1> arraysAllocator_;
|
||||||
|
BatchAllocator<Value, ValueInternalArray::itemsPerPage> pagesAllocator_;
|
||||||
|
};
|
||||||
|
#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
|
||||||
|
|
||||||
|
static ValueArrayAllocator*& arrayAllocator() {
|
||||||
|
static DefaultValueArrayAllocator defaultAllocator;
|
||||||
|
static ValueArrayAllocator* arrayAllocator = &defaultAllocator;
|
||||||
|
return arrayAllocator;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct DummyArrayAllocatorInitializer {
|
||||||
|
DummyArrayAllocatorInitializer() {
|
||||||
|
arrayAllocator(); // ensure arrayAllocator() statics are initialized before
|
||||||
|
// main().
|
||||||
|
}
|
||||||
|
} dummyArrayAllocatorInitializer;
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// class ValueInternalArray
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
bool ValueInternalArray::equals(const IteratorState& x,
|
||||||
|
const IteratorState& other) {
|
||||||
|
return x.array_ == other.array_ &&
|
||||||
|
x.currentItemIndex_ == other.currentItemIndex_ &&
|
||||||
|
x.currentPageIndex_ == other.currentPageIndex_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalArray::increment(IteratorState& it) {
|
||||||
|
JSON_ASSERT_MESSAGE(
|
||||||
|
it.array_ && (it.currentPageIndex_ - it.array_->pages_) * itemsPerPage +
|
||||||
|
it.currentItemIndex_ !=
|
||||||
|
it.array_->size_,
|
||||||
|
"ValueInternalArray::increment(): moving iterator beyond end");
|
||||||
|
++(it.currentItemIndex_);
|
||||||
|
if (it.currentItemIndex_ == itemsPerPage) {
|
||||||
|
it.currentItemIndex_ = 0;
|
||||||
|
++(it.currentPageIndex_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalArray::decrement(IteratorState& it) {
|
||||||
|
JSON_ASSERT_MESSAGE(
|
||||||
|
it.array_ && it.currentPageIndex_ == it.array_->pages_ &&
|
||||||
|
it.currentItemIndex_ == 0,
|
||||||
|
"ValueInternalArray::decrement(): moving iterator beyond end");
|
||||||
|
if (it.currentItemIndex_ == 0) {
|
||||||
|
it.currentItemIndex_ = itemsPerPage - 1;
|
||||||
|
--(it.currentPageIndex_);
|
||||||
|
} else {
|
||||||
|
--(it.currentItemIndex_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Value& ValueInternalArray::unsafeDereference(const IteratorState& it) {
|
||||||
|
return (*(it.currentPageIndex_))[it.currentItemIndex_];
|
||||||
|
}
|
||||||
|
|
||||||
|
Value& ValueInternalArray::dereference(const IteratorState& it) {
|
||||||
|
JSON_ASSERT_MESSAGE(
|
||||||
|
it.array_ && (it.currentPageIndex_ - it.array_->pages_) * itemsPerPage +
|
||||||
|
it.currentItemIndex_ <
|
||||||
|
it.array_->size_,
|
||||||
|
"ValueInternalArray::dereference(): dereferencing invalid iterator");
|
||||||
|
return unsafeDereference(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalArray::makeBeginIterator(IteratorState& it) const {
|
||||||
|
it.array_ = const_cast<ValueInternalArray*>(this);
|
||||||
|
it.currentItemIndex_ = 0;
|
||||||
|
it.currentPageIndex_ = pages_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalArray::makeIterator(IteratorState& it,
|
||||||
|
ArrayIndex index) const {
|
||||||
|
it.array_ = const_cast<ValueInternalArray*>(this);
|
||||||
|
it.currentItemIndex_ = index % itemsPerPage;
|
||||||
|
it.currentPageIndex_ = pages_ + index / itemsPerPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalArray::makeEndIterator(IteratorState& it) const {
|
||||||
|
makeIterator(it, size_);
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueInternalArray::ValueInternalArray() : pages_(0), size_(0), pageCount_(0) {}
|
||||||
|
|
||||||
|
ValueInternalArray::ValueInternalArray(const ValueInternalArray& other)
|
||||||
|
: pages_(0), size_(other.size_), pageCount_(0) {
|
||||||
|
PageIndex minNewPages = other.size_ / itemsPerPage;
|
||||||
|
arrayAllocator()->reallocateArrayPageIndex(pages_, pageCount_, minNewPages);
|
||||||
|
JSON_ASSERT_MESSAGE(pageCount_ >= minNewPages,
|
||||||
|
"ValueInternalArray::reserve(): bad reallocation");
|
||||||
|
IteratorState itOther;
|
||||||
|
other.makeBeginIterator(itOther);
|
||||||
|
Value* value;
|
||||||
|
for (ArrayIndex index = 0; index < size_; ++index, increment(itOther)) {
|
||||||
|
if (index % itemsPerPage == 0) {
|
||||||
|
PageIndex pageIndex = index / itemsPerPage;
|
||||||
|
value = arrayAllocator()->allocateArrayPage();
|
||||||
|
pages_[pageIndex] = value;
|
||||||
|
}
|
||||||
|
new (value) Value(dereference(itOther));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueInternalArray& ValueInternalArray::operator=(ValueInternalArray other) {
|
||||||
|
swap(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueInternalArray::~ValueInternalArray() {
|
||||||
|
// destroy all constructed items
|
||||||
|
IteratorState it;
|
||||||
|
IteratorState itEnd;
|
||||||
|
makeBeginIterator(it);
|
||||||
|
makeEndIterator(itEnd);
|
||||||
|
for (; !equals(it, itEnd); increment(it)) {
|
||||||
|
Value* value = &dereference(it);
|
||||||
|
value->~Value();
|
||||||
|
}
|
||||||
|
// release all pages
|
||||||
|
PageIndex lastPageIndex = size_ / itemsPerPage;
|
||||||
|
for (PageIndex pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex)
|
||||||
|
arrayAllocator()->releaseArrayPage(pages_[pageIndex]);
|
||||||
|
// release pages index
|
||||||
|
arrayAllocator()->releaseArrayPageIndex(pages_, pageCount_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalArray::swap(ValueInternalArray& other) {
|
||||||
|
Value** tempPages = pages_;
|
||||||
|
pages_ = other.pages_;
|
||||||
|
other.pages_ = tempPages;
|
||||||
|
ArrayIndex tempSize = size_;
|
||||||
|
size_ = other.size_;
|
||||||
|
other.size_ = tempSize;
|
||||||
|
PageIndex tempPageCount = pageCount_;
|
||||||
|
pageCount_ = other.pageCount_;
|
||||||
|
other.pageCount_ = tempPageCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalArray::clear() {
|
||||||
|
ValueInternalArray dummy;
|
||||||
|
swap(dummy);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalArray::resize(ArrayIndex newSize) {
|
||||||
|
if (newSize == 0)
|
||||||
|
clear();
|
||||||
|
else if (newSize < size_) {
|
||||||
|
IteratorState it;
|
||||||
|
IteratorState itEnd;
|
||||||
|
makeIterator(it, newSize);
|
||||||
|
makeIterator(itEnd, size_);
|
||||||
|
for (; !equals(it, itEnd); increment(it)) {
|
||||||
|
Value* value = &dereference(it);
|
||||||
|
value->~Value();
|
||||||
|
}
|
||||||
|
PageIndex pageIndex = (newSize + itemsPerPage - 1) / itemsPerPage;
|
||||||
|
PageIndex lastPageIndex = size_ / itemsPerPage;
|
||||||
|
for (; pageIndex < lastPageIndex; ++pageIndex)
|
||||||
|
arrayAllocator()->releaseArrayPage(pages_[pageIndex]);
|
||||||
|
size_ = newSize;
|
||||||
|
} else if (newSize > size_)
|
||||||
|
resolveReference(newSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalArray::makeIndexValid(ArrayIndex index) {
|
||||||
|
// Need to enlarge page index ?
|
||||||
|
if (index >= pageCount_ * itemsPerPage) {
|
||||||
|
PageIndex minNewPages = (index + 1) / itemsPerPage;
|
||||||
|
arrayAllocator()->reallocateArrayPageIndex(pages_, pageCount_, minNewPages);
|
||||||
|
JSON_ASSERT_MESSAGE(pageCount_ >= minNewPages,
|
||||||
|
"ValueInternalArray::reserve(): bad reallocation");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Need to allocate new pages ?
|
||||||
|
ArrayIndex nextPageIndex = (size_ % itemsPerPage) != 0
|
||||||
|
? size_ - (size_ % itemsPerPage) + itemsPerPage
|
||||||
|
: size_;
|
||||||
|
if (nextPageIndex <= index) {
|
||||||
|
PageIndex pageIndex = nextPageIndex / itemsPerPage;
|
||||||
|
PageIndex pageToAllocate = (index - nextPageIndex) / itemsPerPage + 1;
|
||||||
|
for (; pageToAllocate-- > 0; ++pageIndex)
|
||||||
|
pages_[pageIndex] = arrayAllocator()->allocateArrayPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize all new entries
|
||||||
|
IteratorState it;
|
||||||
|
IteratorState itEnd;
|
||||||
|
makeIterator(it, size_);
|
||||||
|
size_ = index + 1;
|
||||||
|
makeIterator(itEnd, size_);
|
||||||
|
for (; !equals(it, itEnd); increment(it)) {
|
||||||
|
Value* value = &dereference(it);
|
||||||
|
new (value) Value(); // Construct a default value using placement new
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Value& ValueInternalArray::resolveReference(ArrayIndex index) {
|
||||||
|
if (index >= size_)
|
||||||
|
makeIndexValid(index);
|
||||||
|
return pages_[index / itemsPerPage][index % itemsPerPage];
|
||||||
|
}
|
||||||
|
|
||||||
|
Value* ValueInternalArray::find(ArrayIndex index) const {
|
||||||
|
if (index >= size_)
|
||||||
|
return 0;
|
||||||
|
return &(pages_[index / itemsPerPage][index % itemsPerPage]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueInternalArray::ArrayIndex ValueInternalArray::size() const {
|
||||||
|
return size_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ValueInternalArray::distance(const IteratorState& x,
|
||||||
|
const IteratorState& y) {
|
||||||
|
return indexOf(y) - indexOf(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueInternalArray::ArrayIndex
|
||||||
|
ValueInternalArray::indexOf(const IteratorState& iterator) {
|
||||||
|
if (!iterator.array_)
|
||||||
|
return ArrayIndex(-1);
|
||||||
|
return ArrayIndex((iterator.currentPageIndex_ - iterator.array_->pages_) *
|
||||||
|
itemsPerPage +
|
||||||
|
iterator.currentItemIndex_);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ValueInternalArray::compare(const ValueInternalArray& other) const {
|
||||||
|
int sizeDiff(size_ - other.size_);
|
||||||
|
if (sizeDiff != 0)
|
||||||
|
return sizeDiff;
|
||||||
|
|
||||||
|
for (ArrayIndex index = 0; index < size_; ++index) {
|
||||||
|
int diff = pages_[index / itemsPerPage][index % itemsPerPage].compare(
|
||||||
|
other.pages_[index / itemsPerPage][index % itemsPerPage]);
|
||||||
|
if (diff != 0)
|
||||||
|
return diff;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Json
|
473
src/lib_json/json_internalmap.inl
Normal file
473
src/lib_json/json_internalmap.inl
Normal file
@@ -0,0 +1,473 @@
|
|||||||
|
// 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
|
||||||
|
|
||||||
|
// included by json_value.cpp
|
||||||
|
|
||||||
|
namespace Json {
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// class ValueInternalMap
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/** \internal MUST be safely initialized using memset( this, 0,
|
||||||
|
* sizeof(ValueInternalLink) );
|
||||||
|
* This optimization is used by the fast allocator.
|
||||||
|
*/
|
||||||
|
ValueInternalLink::ValueInternalLink() : previous_(0), next_(0) {}
|
||||||
|
|
||||||
|
ValueInternalLink::~ValueInternalLink() {
|
||||||
|
for (int index = 0; index < itemPerLink; ++index) {
|
||||||
|
if (!items_[index].isItemAvailable()) {
|
||||||
|
if (!items_[index].isMemberNameStatic())
|
||||||
|
free(keys_[index]);
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueMapAllocator::~ValueMapAllocator() {}
|
||||||
|
|
||||||
|
#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
|
||||||
|
class DefaultValueMapAllocator : public ValueMapAllocator {
|
||||||
|
public: // overridden from ValueMapAllocator
|
||||||
|
virtual ValueInternalMap* newMap() { return new ValueInternalMap(); }
|
||||||
|
|
||||||
|
virtual ValueInternalMap* newMapCopy(const ValueInternalMap& other) {
|
||||||
|
return new ValueInternalMap(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void destructMap(ValueInternalMap* map) { delete map; }
|
||||||
|
|
||||||
|
virtual ValueInternalLink* allocateMapBuckets(unsigned int size) {
|
||||||
|
return new ValueInternalLink[size];
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void releaseMapBuckets(ValueInternalLink* links) { delete[] links; }
|
||||||
|
|
||||||
|
virtual ValueInternalLink* allocateMapLink() {
|
||||||
|
return new ValueInternalLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void releaseMapLink(ValueInternalLink* link) { delete link; }
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
/// @todo make this thread-safe (lock when accessign batch allocator)
|
||||||
|
class DefaultValueMapAllocator : public ValueMapAllocator {
|
||||||
|
public: // overridden from ValueMapAllocator
|
||||||
|
virtual ValueInternalMap* newMap() {
|
||||||
|
ValueInternalMap* map = mapsAllocator_.allocate();
|
||||||
|
new (map) ValueInternalMap(); // placement new
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ValueInternalMap* newMapCopy(const ValueInternalMap& other) {
|
||||||
|
ValueInternalMap* map = mapsAllocator_.allocate();
|
||||||
|
new (map) ValueInternalMap(other); // placement new
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void destructMap(ValueInternalMap* map) {
|
||||||
|
if (map) {
|
||||||
|
map->~ValueInternalMap();
|
||||||
|
mapsAllocator_.release(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ValueInternalLink* allocateMapBuckets(unsigned int size) {
|
||||||
|
return new ValueInternalLink[size];
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void releaseMapBuckets(ValueInternalLink* links) { delete[] links; }
|
||||||
|
|
||||||
|
virtual ValueInternalLink* allocateMapLink() {
|
||||||
|
ValueInternalLink* link = linksAllocator_.allocate();
|
||||||
|
memset(link, 0, sizeof(ValueInternalLink));
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void releaseMapLink(ValueInternalLink* link) {
|
||||||
|
link->~ValueInternalLink();
|
||||||
|
linksAllocator_.release(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
BatchAllocator<ValueInternalMap, 1> mapsAllocator_;
|
||||||
|
BatchAllocator<ValueInternalLink, 1> linksAllocator_;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static ValueMapAllocator*& mapAllocator() {
|
||||||
|
static DefaultValueMapAllocator defaultAllocator;
|
||||||
|
static ValueMapAllocator* mapAllocator = &defaultAllocator;
|
||||||
|
return mapAllocator;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct DummyMapAllocatorInitializer {
|
||||||
|
DummyMapAllocatorInitializer() {
|
||||||
|
mapAllocator(); // ensure mapAllocator() statics are initialized before
|
||||||
|
// main().
|
||||||
|
}
|
||||||
|
} dummyMapAllocatorInitializer;
|
||||||
|
|
||||||
|
// h(K) = value * K >> w ; with w = 32 & K prime w.r.t. 2^32.
|
||||||
|
|
||||||
|
/*
|
||||||
|
use linked list hash map.
|
||||||
|
buckets array is a container.
|
||||||
|
linked list element contains 6 key/values. (memory = (16+4) * 6 + 4 = 124)
|
||||||
|
value have extra state: valid, available, deleted
|
||||||
|
*/
|
||||||
|
|
||||||
|
ValueInternalMap::ValueInternalMap()
|
||||||
|
: buckets_(0), tailLink_(0), bucketsSize_(0), itemCount_(0) {}
|
||||||
|
|
||||||
|
ValueInternalMap::ValueInternalMap(const ValueInternalMap& other)
|
||||||
|
: buckets_(0), tailLink_(0), bucketsSize_(0), itemCount_(0) {
|
||||||
|
reserve(other.itemCount_);
|
||||||
|
IteratorState it;
|
||||||
|
IteratorState itEnd;
|
||||||
|
other.makeBeginIterator(it);
|
||||||
|
other.makeEndIterator(itEnd);
|
||||||
|
for (; !equals(it, itEnd); increment(it)) {
|
||||||
|
bool isStatic;
|
||||||
|
const char* memberName = key(it, isStatic);
|
||||||
|
const Value& aValue = value(it);
|
||||||
|
resolveReference(memberName, isStatic) = aValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueInternalMap& ValueInternalMap::operator=(ValueInternalMap other) {
|
||||||
|
swap(other);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueInternalMap::~ValueInternalMap() {
|
||||||
|
if (buckets_) {
|
||||||
|
for (BucketIndex bucketIndex = 0; bucketIndex < bucketsSize_;
|
||||||
|
++bucketIndex) {
|
||||||
|
ValueInternalLink* link = buckets_[bucketIndex].next_;
|
||||||
|
while (link) {
|
||||||
|
ValueInternalLink* linkToRelease = link;
|
||||||
|
link = link->next_;
|
||||||
|
mapAllocator()->releaseMapLink(linkToRelease);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mapAllocator()->releaseMapBuckets(buckets_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalMap::swap(ValueInternalMap& other) {
|
||||||
|
ValueInternalLink* tempBuckets = buckets_;
|
||||||
|
buckets_ = other.buckets_;
|
||||||
|
other.buckets_ = tempBuckets;
|
||||||
|
ValueInternalLink* tempTailLink = tailLink_;
|
||||||
|
tailLink_ = other.tailLink_;
|
||||||
|
other.tailLink_ = tempTailLink;
|
||||||
|
BucketIndex tempBucketsSize = bucketsSize_;
|
||||||
|
bucketsSize_ = other.bucketsSize_;
|
||||||
|
other.bucketsSize_ = tempBucketsSize;
|
||||||
|
BucketIndex tempItemCount = itemCount_;
|
||||||
|
itemCount_ = other.itemCount_;
|
||||||
|
other.itemCount_ = tempItemCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalMap::clear() {
|
||||||
|
ValueInternalMap dummy;
|
||||||
|
swap(dummy);
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueInternalMap::BucketIndex ValueInternalMap::size() const {
|
||||||
|
return itemCount_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ValueInternalMap::reserveDelta(BucketIndex growth) {
|
||||||
|
return reserve(itemCount_ + growth);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ValueInternalMap::reserve(BucketIndex newItemCount) {
|
||||||
|
if (!buckets_ && newItemCount > 0) {
|
||||||
|
buckets_ = mapAllocator()->allocateMapBuckets(1);
|
||||||
|
bucketsSize_ = 1;
|
||||||
|
tailLink_ = &buckets_[0];
|
||||||
|
}
|
||||||
|
// BucketIndex idealBucketCount = (newItemCount +
|
||||||
|
// ValueInternalLink::itemPerLink) / ValueInternalLink::itemPerLink;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Value* ValueInternalMap::find(const char* key) const {
|
||||||
|
if (!bucketsSize_)
|
||||||
|
return 0;
|
||||||
|
HashKey hashedKey = hash(key);
|
||||||
|
BucketIndex bucketIndex = hashedKey % bucketsSize_;
|
||||||
|
for (const ValueInternalLink* current = &buckets_[bucketIndex]; current != 0;
|
||||||
|
current = current->next_) {
|
||||||
|
for (BucketIndex index = 0; index < ValueInternalLink::itemPerLink;
|
||||||
|
++index) {
|
||||||
|
if (current->items_[index].isItemAvailable())
|
||||||
|
return 0;
|
||||||
|
if (strcmp(key, current->keys_[index]) == 0)
|
||||||
|
return ¤t->items_[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Value* ValueInternalMap::find(const char* key) {
|
||||||
|
const ValueInternalMap* constThis = this;
|
||||||
|
return const_cast<Value*>(constThis->find(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
Value& ValueInternalMap::resolveReference(const char* key, bool isStatic) {
|
||||||
|
HashKey hashedKey = hash(key);
|
||||||
|
if (bucketsSize_) {
|
||||||
|
BucketIndex bucketIndex = hashedKey % bucketsSize_;
|
||||||
|
ValueInternalLink** previous = 0;
|
||||||
|
BucketIndex index;
|
||||||
|
for (ValueInternalLink* current = &buckets_[bucketIndex]; current != 0;
|
||||||
|
previous = ¤t->next_, current = current->next_) {
|
||||||
|
for (index = 0; index < ValueInternalLink::itemPerLink; ++index) {
|
||||||
|
if (current->items_[index].isItemAvailable())
|
||||||
|
return setNewItem(key, isStatic, current, index);
|
||||||
|
if (strcmp(key, current->keys_[index]) == 0)
|
||||||
|
return current->items_[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reserveDelta(1);
|
||||||
|
return unsafeAdd(key, isStatic, hashedKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalMap::remove(const char* key) {
|
||||||
|
HashKey hashedKey = hash(key);
|
||||||
|
if (!bucketsSize_)
|
||||||
|
return;
|
||||||
|
BucketIndex bucketIndex = hashedKey % bucketsSize_;
|
||||||
|
for (ValueInternalLink* link = &buckets_[bucketIndex]; link != 0;
|
||||||
|
link = link->next_) {
|
||||||
|
BucketIndex index;
|
||||||
|
for (index = 0; index < ValueInternalLink::itemPerLink; ++index) {
|
||||||
|
if (link->items_[index].isItemAvailable())
|
||||||
|
return;
|
||||||
|
if (strcmp(key, link->keys_[index]) == 0) {
|
||||||
|
doActualRemove(link, index, bucketIndex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalMap::doActualRemove(ValueInternalLink* link,
|
||||||
|
BucketIndex index,
|
||||||
|
BucketIndex bucketIndex) {
|
||||||
|
// find last item of the bucket and swap it with the 'removed' one.
|
||||||
|
// set removed items flags to 'available'.
|
||||||
|
// if last page only contains 'available' items, then desallocate it (it's
|
||||||
|
// empty)
|
||||||
|
ValueInternalLink*& lastLink = getLastLinkInBucket(index);
|
||||||
|
BucketIndex lastItemIndex = 1; // a link can never be empty, so start at 1
|
||||||
|
for (; lastItemIndex < ValueInternalLink::itemPerLink;
|
||||||
|
++lastItemIndex) // may be optimized with dicotomic search
|
||||||
|
{
|
||||||
|
if (lastLink->items_[lastItemIndex].isItemAvailable())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BucketIndex lastUsedIndex = lastItemIndex - 1;
|
||||||
|
Value* valueToDelete = &link->items_[index];
|
||||||
|
Value* valueToPreserve = &lastLink->items_[lastUsedIndex];
|
||||||
|
if (valueToDelete != valueToPreserve)
|
||||||
|
valueToDelete->swap(*valueToPreserve);
|
||||||
|
if (lastUsedIndex == 0) // page is now empty
|
||||||
|
{ // remove it from bucket linked list and delete it.
|
||||||
|
ValueInternalLink* linkPreviousToLast = lastLink->previous_;
|
||||||
|
if (linkPreviousToLast != 0) // can not deleted bucket link.
|
||||||
|
{
|
||||||
|
mapAllocator()->releaseMapLink(lastLink);
|
||||||
|
linkPreviousToLast->next_ = 0;
|
||||||
|
lastLink = linkPreviousToLast;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Value dummy;
|
||||||
|
valueToPreserve->swap(dummy); // restore deleted to default Value.
|
||||||
|
valueToPreserve->setItemUsed(false);
|
||||||
|
}
|
||||||
|
--itemCount_;
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueInternalLink*&
|
||||||
|
ValueInternalMap::getLastLinkInBucket(BucketIndex bucketIndex) {
|
||||||
|
if (bucketIndex == bucketsSize_ - 1)
|
||||||
|
return tailLink_;
|
||||||
|
ValueInternalLink*& previous = buckets_[bucketIndex + 1].previous_;
|
||||||
|
if (!previous)
|
||||||
|
previous = &buckets_[bucketIndex];
|
||||||
|
return previous;
|
||||||
|
}
|
||||||
|
|
||||||
|
Value& ValueInternalMap::setNewItem(const char* key,
|
||||||
|
bool isStatic,
|
||||||
|
ValueInternalLink* link,
|
||||||
|
BucketIndex index) {
|
||||||
|
char* duplicatedKey = makeMemberName(key);
|
||||||
|
++itemCount_;
|
||||||
|
link->keys_[index] = duplicatedKey;
|
||||||
|
link->items_[index].setItemUsed();
|
||||||
|
link->items_[index].setMemberNameIsStatic(isStatic);
|
||||||
|
return link->items_[index]; // items already default constructed.
|
||||||
|
}
|
||||||
|
|
||||||
|
Value&
|
||||||
|
ValueInternalMap::unsafeAdd(const char* key, bool isStatic, HashKey hashedKey) {
|
||||||
|
JSON_ASSERT_MESSAGE(bucketsSize_ > 0,
|
||||||
|
"ValueInternalMap::unsafeAdd(): internal logic error.");
|
||||||
|
BucketIndex bucketIndex = hashedKey % bucketsSize_;
|
||||||
|
ValueInternalLink*& previousLink = getLastLinkInBucket(bucketIndex);
|
||||||
|
ValueInternalLink* link = previousLink;
|
||||||
|
BucketIndex index;
|
||||||
|
for (index = 0; index < ValueInternalLink::itemPerLink; ++index) {
|
||||||
|
if (link->items_[index].isItemAvailable())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (index == ValueInternalLink::itemPerLink) // need to add a new page
|
||||||
|
{
|
||||||
|
ValueInternalLink* newLink = mapAllocator()->allocateMapLink();
|
||||||
|
index = 0;
|
||||||
|
link->next_ = newLink;
|
||||||
|
previousLink = newLink;
|
||||||
|
link = newLink;
|
||||||
|
}
|
||||||
|
return setNewItem(key, isStatic, link, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueInternalMap::HashKey ValueInternalMap::hash(const char* key) const {
|
||||||
|
HashKey hash = 0;
|
||||||
|
while (*key)
|
||||||
|
hash += *key++ * 37;
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ValueInternalMap::compare(const ValueInternalMap& other) const {
|
||||||
|
int sizeDiff(itemCount_ - other.itemCount_);
|
||||||
|
if (sizeDiff != 0)
|
||||||
|
return sizeDiff;
|
||||||
|
// Strict order guaranty is required. Compare all keys FIRST, then compare
|
||||||
|
// values.
|
||||||
|
IteratorState it;
|
||||||
|
IteratorState itEnd;
|
||||||
|
makeBeginIterator(it);
|
||||||
|
makeEndIterator(itEnd);
|
||||||
|
for (; !equals(it, itEnd); increment(it)) {
|
||||||
|
if (!other.find(key(it)))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// All keys are equals, let's compare values
|
||||||
|
makeBeginIterator(it);
|
||||||
|
for (; !equals(it, itEnd); increment(it)) {
|
||||||
|
const Value* otherValue = other.find(key(it));
|
||||||
|
int valueDiff = value(it).compare(*otherValue);
|
||||||
|
if (valueDiff != 0)
|
||||||
|
return valueDiff;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalMap::makeBeginIterator(IteratorState& it) const {
|
||||||
|
it.map_ = const_cast<ValueInternalMap*>(this);
|
||||||
|
it.bucketIndex_ = 0;
|
||||||
|
it.itemIndex_ = 0;
|
||||||
|
it.link_ = buckets_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalMap::makeEndIterator(IteratorState& it) const {
|
||||||
|
it.map_ = const_cast<ValueInternalMap*>(this);
|
||||||
|
it.bucketIndex_ = bucketsSize_;
|
||||||
|
it.itemIndex_ = 0;
|
||||||
|
it.link_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ValueInternalMap::equals(const IteratorState& x,
|
||||||
|
const IteratorState& other) {
|
||||||
|
return x.map_ == other.map_ && x.bucketIndex_ == other.bucketIndex_ &&
|
||||||
|
x.link_ == other.link_ && x.itemIndex_ == other.itemIndex_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalMap::incrementBucket(IteratorState& iterator) {
|
||||||
|
++iterator.bucketIndex_;
|
||||||
|
JSON_ASSERT_MESSAGE(
|
||||||
|
iterator.bucketIndex_ <= iterator.map_->bucketsSize_,
|
||||||
|
"ValueInternalMap::increment(): attempting to iterate beyond end.");
|
||||||
|
if (iterator.bucketIndex_ == iterator.map_->bucketsSize_)
|
||||||
|
iterator.link_ = 0;
|
||||||
|
else
|
||||||
|
iterator.link_ = &(iterator.map_->buckets_[iterator.bucketIndex_]);
|
||||||
|
iterator.itemIndex_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalMap::increment(IteratorState& iterator) {
|
||||||
|
JSON_ASSERT_MESSAGE(iterator.map_,
|
||||||
|
"Attempting to iterator using invalid iterator.");
|
||||||
|
++iterator.itemIndex_;
|
||||||
|
if (iterator.itemIndex_ == ValueInternalLink::itemPerLink) {
|
||||||
|
JSON_ASSERT_MESSAGE(
|
||||||
|
iterator.link_ != 0,
|
||||||
|
"ValueInternalMap::increment(): attempting to iterate beyond end.");
|
||||||
|
iterator.link_ = iterator.link_->next_;
|
||||||
|
if (iterator.link_ == 0)
|
||||||
|
incrementBucket(iterator);
|
||||||
|
} else if (iterator.link_->items_[iterator.itemIndex_].isItemAvailable()) {
|
||||||
|
incrementBucket(iterator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValueInternalMap::decrement(IteratorState& iterator) {
|
||||||
|
if (iterator.itemIndex_ == 0) {
|
||||||
|
JSON_ASSERT_MESSAGE(iterator.map_,
|
||||||
|
"Attempting to iterate using invalid iterator.");
|
||||||
|
if (iterator.link_ == &iterator.map_->buckets_[iterator.bucketIndex_]) {
|
||||||
|
JSON_ASSERT_MESSAGE(iterator.bucketIndex_ > 0,
|
||||||
|
"Attempting to iterate beyond beginning.");
|
||||||
|
--(iterator.bucketIndex_);
|
||||||
|
}
|
||||||
|
iterator.link_ = iterator.link_->previous_;
|
||||||
|
iterator.itemIndex_ = ValueInternalLink::itemPerLink - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* ValueInternalMap::key(const IteratorState& iterator) {
|
||||||
|
JSON_ASSERT_MESSAGE(iterator.link_,
|
||||||
|
"Attempting to iterate using invalid iterator.");
|
||||||
|
return iterator.link_->keys_[iterator.itemIndex_];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* ValueInternalMap::key(const IteratorState& iterator,
|
||||||
|
bool& isStatic) {
|
||||||
|
JSON_ASSERT_MESSAGE(iterator.link_,
|
||||||
|
"Attempting to iterate using invalid iterator.");
|
||||||
|
isStatic = iterator.link_->items_[iterator.itemIndex_].isMemberNameStatic();
|
||||||
|
return iterator.link_->keys_[iterator.itemIndex_];
|
||||||
|
}
|
||||||
|
|
||||||
|
Value& ValueInternalMap::value(const IteratorState& iterator) {
|
||||||
|
JSON_ASSERT_MESSAGE(iterator.link_,
|
||||||
|
"Attempting to iterate using invalid iterator.");
|
||||||
|
return iterator.link_->items_[iterator.itemIndex_];
|
||||||
|
}
|
||||||
|
|
||||||
|
int ValueInternalMap::distance(const IteratorState& x, const IteratorState& y) {
|
||||||
|
int offset = 0;
|
||||||
|
IteratorState it = x;
|
||||||
|
while (!equals(it, y))
|
||||||
|
increment(it);
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Json
|
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@@ -6,16 +6,6 @@
|
|||||||
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||||
#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
// Also support old flag NO_LOCALE_SUPPORT
|
|
||||||
#ifdef NO_LOCALE_SUPPORT
|
|
||||||
#define JSONCPP_NO_LOCALE_SUPPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef JSONCPP_NO_LOCALE_SUPPORT
|
|
||||||
#include <clocale>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This header provides common string manipulation support, such as UTF-8,
|
/* This header provides common string manipulation support, such as UTF-8,
|
||||||
* portable conversion from/to string...
|
* portable conversion from/to string...
|
||||||
*
|
*
|
||||||
@@ -23,18 +13,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
static char getDecimalPoint() {
|
|
||||||
#ifdef JSONCPP_NO_LOCALE_SUPPORT
|
|
||||||
return '\0';
|
|
||||||
#else
|
|
||||||
struct lconv* lc = localeconv();
|
|
||||||
return lc ? *(lc->decimal_point) : '\0';
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Converts a unicode code-point to UTF-8.
|
/// Converts a unicode code-point to UTF-8.
|
||||||
static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
static inline std::string codePointToUTF8(unsigned int cp) {
|
||||||
JSONCPP_STRING result;
|
std::string result;
|
||||||
|
|
||||||
// based on description from http://en.wikipedia.org/wiki/UTF-8
|
// based on description from http://en.wikipedia.org/wiki/UTF-8
|
||||||
|
|
||||||
@@ -48,8 +30,8 @@ static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
|||||||
} else if (cp <= 0xFFFF) {
|
} else if (cp <= 0xFFFF) {
|
||||||
result.resize(3);
|
result.resize(3);
|
||||||
result[2] = static_cast<char>(0x80 | (0x3f & cp));
|
result[2] = static_cast<char>(0x80 | (0x3f & cp));
|
||||||
result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
|
result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));
|
||||||
result[0] = static_cast<char>(0xE0 | (0xf & (cp >> 12)));
|
result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));
|
||||||
} else if (cp <= 0x10FFFF) {
|
} else if (cp <= 0x10FFFF) {
|
||||||
result.resize(4);
|
result.resize(4);
|
||||||
result[3] = static_cast<char>(0x80 | (0x3f & cp));
|
result[3] = static_cast<char>(0x80 | (0x3f & cp));
|
||||||
@@ -61,7 +43,7 @@ static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
|||||||
return result;
|
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; }
|
static inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -81,7 +63,7 @@ typedef char UIntToStringBuffer[uintToStringBufferSize];
|
|||||||
static inline void uintToString(LargestUInt value, char*& current) {
|
static inline void uintToString(LargestUInt value, char*& current) {
|
||||||
*--current = 0;
|
*--current = 0;
|
||||||
do {
|
do {
|
||||||
*--current = static_cast<char>(value % 10U + static_cast<unsigned>('0'));
|
*--current = char(value % 10) + '0';
|
||||||
value /= 10;
|
value /= 10;
|
||||||
} while (value != 0);
|
} while (value != 0);
|
||||||
}
|
}
|
||||||
@@ -100,18 +82,6 @@ static inline void fixNumericLocale(char* begin, char* end) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void fixNumericLocaleInput(char* begin, char* end) {
|
|
||||||
char decimalPoint = getDecimalPoint();
|
|
||||||
if (decimalPoint != '\0' && decimalPoint != '.') {
|
|
||||||
while (begin < end) {
|
|
||||||
if (*begin == '.') {
|
|
||||||
*begin = decimalPoint;
|
|
||||||
}
|
|
||||||
++begin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Json {
|
} // namespace Json {
|
||||||
|
|
||||||
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@@ -16,29 +16,68 @@ namespace Json {
|
|||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ValueIteratorBase::ValueIteratorBase()
|
ValueIteratorBase::ValueIteratorBase()
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
: current_(), isNull_(true) {
|
: current_(), isNull_(true) {
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
: isArray_(true), isNull_(true) {
|
||||||
|
iterator_.array_ = ValueInternalArray::IteratorState();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
ValueIteratorBase::ValueIteratorBase(
|
ValueIteratorBase::ValueIteratorBase(
|
||||||
const Value::ObjectValues::iterator& current)
|
const Value::ObjectValues::iterator& current)
|
||||||
: current_(current), isNull_(false) {}
|
: current_(current), isNull_(false) {}
|
||||||
|
#else
|
||||||
|
ValueIteratorBase::ValueIteratorBase(
|
||||||
|
const ValueInternalArray::IteratorState& state)
|
||||||
|
: isArray_(true) {
|
||||||
|
iterator_.array_ = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueIteratorBase::ValueIteratorBase(
|
||||||
|
const ValueInternalMap::IteratorState& state)
|
||||||
|
: isArray_(false) {
|
||||||
|
iterator_.map_ = state;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Value& ValueIteratorBase::deref() const {
|
Value& ValueIteratorBase::deref() const {
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
return current_->second;
|
return current_->second;
|
||||||
|
#else
|
||||||
|
if (isArray_)
|
||||||
|
return ValueInternalArray::dereference(iterator_.array_);
|
||||||
|
return ValueInternalMap::value(iterator_.map_);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValueIteratorBase::increment() {
|
void ValueIteratorBase::increment() {
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
++current_;
|
++current_;
|
||||||
|
#else
|
||||||
|
if (isArray_)
|
||||||
|
ValueInternalArray::increment(iterator_.array_);
|
||||||
|
ValueInternalMap::increment(iterator_.map_);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValueIteratorBase::decrement() {
|
void ValueIteratorBase::decrement() {
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
--current_;
|
--current_;
|
||||||
|
#else
|
||||||
|
if (isArray_)
|
||||||
|
ValueInternalArray::decrement(iterator_.array_);
|
||||||
|
ValueInternalMap::decrement(iterator_.map_);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueIteratorBase::difference_type
|
ValueIteratorBase::difference_type
|
||||||
ValueIteratorBase::computeDistance(const SelfType& other) const {
|
ValueIteratorBase::computeDistance(const SelfType& other) const {
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
#ifdef JSON_USE_CPPTL_SMALLMAP
|
#ifdef JSON_USE_CPPTL_SMALLMAP
|
||||||
return other.current_ - current_;
|
return current_ - other.current_;
|
||||||
#else
|
#else
|
||||||
// Iterator for null value are initialized using the default
|
// Iterator for null value are initialized using the default
|
||||||
// constructor, which initialize current_ to the default
|
// constructor, which initialize current_ to the default
|
||||||
@@ -61,58 +100,80 @@ ValueIteratorBase::computeDistance(const SelfType& other) const {
|
|||||||
}
|
}
|
||||||
return myDistance;
|
return myDistance;
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
if (isArray_)
|
||||||
|
return ValueInternalArray::distance(iterator_.array_,
|
||||||
|
other.iterator_.array_);
|
||||||
|
return ValueInternalMap::distance(iterator_.map_, other.iterator_.map_);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ValueIteratorBase::isEqual(const SelfType& other) const {
|
bool ValueIteratorBase::isEqual(const SelfType& other) const {
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
if (isNull_) {
|
if (isNull_) {
|
||||||
return other.isNull_;
|
return other.isNull_;
|
||||||
}
|
}
|
||||||
return current_ == other.current_;
|
return current_ == other.current_;
|
||||||
|
#else
|
||||||
|
if (isArray_)
|
||||||
|
return ValueInternalArray::equals(iterator_.array_, other.iterator_.array_);
|
||||||
|
return ValueInternalMap::equals(iterator_.map_, other.iterator_.map_);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValueIteratorBase::copy(const SelfType& other) {
|
void ValueIteratorBase::copy(const SelfType& other) {
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
current_ = other.current_;
|
current_ = other.current_;
|
||||||
isNull_ = other.isNull_;
|
isNull_ = other.isNull_;
|
||||||
|
#else
|
||||||
|
if (isArray_)
|
||||||
|
iterator_.array_ = other.iterator_.array_;
|
||||||
|
iterator_.map_ = other.iterator_.map_;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ValueIteratorBase::key() const {
|
Value ValueIteratorBase::key() const {
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
const Value::CZString czstring = (*current_).first;
|
const Value::CZString czstring = (*current_).first;
|
||||||
if (czstring.data()) {
|
if (czstring.c_str()) {
|
||||||
if (czstring.isStaticString())
|
if (czstring.isStaticString())
|
||||||
return Value(StaticString(czstring.data()));
|
return Value(StaticString(czstring.c_str()));
|
||||||
return Value(czstring.data(), czstring.data() + czstring.length());
|
return Value(czstring.c_str());
|
||||||
}
|
}
|
||||||
return Value(czstring.index());
|
return Value(czstring.index());
|
||||||
|
#else
|
||||||
|
if (isArray_)
|
||||||
|
return Value(ValueInternalArray::indexOf(iterator_.array_));
|
||||||
|
bool isStatic;
|
||||||
|
const char* memberName = ValueInternalMap::key(iterator_.map_, isStatic);
|
||||||
|
if (isStatic)
|
||||||
|
return Value(StaticString(memberName));
|
||||||
|
return Value(memberName);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt ValueIteratorBase::index() const {
|
UInt ValueIteratorBase::index() const {
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
const Value::CZString czstring = (*current_).first;
|
const Value::CZString czstring = (*current_).first;
|
||||||
if (!czstring.data())
|
if (!czstring.c_str())
|
||||||
return czstring.index();
|
return czstring.index();
|
||||||
return Value::UInt(-1);
|
return Value::UInt(-1);
|
||||||
|
#else
|
||||||
|
if (isArray_)
|
||||||
|
return Value::UInt(ValueInternalArray::indexOf(iterator_.array_));
|
||||||
|
return Value::UInt(-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONCPP_STRING ValueIteratorBase::name() const {
|
const char* ValueIteratorBase::memberName() const {
|
||||||
char const* keey;
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
char const* end;
|
const char* name = (*current_).first.c_str();
|
||||||
keey = memberName(&end);
|
return name ? name : "";
|
||||||
if (!keey) return JSONCPP_STRING();
|
#else
|
||||||
return JSONCPP_STRING(keey, end);
|
if (!isArray_)
|
||||||
}
|
return ValueInternalMap::key(iterator_.map_);
|
||||||
|
return "";
|
||||||
char const* ValueIteratorBase::memberName() const {
|
#endif
|
||||||
const char* cname = (*current_).first.data();
|
|
||||||
return cname ? cname : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
char const* ValueIteratorBase::memberName(char const** end) const {
|
|
||||||
const char* cname = (*current_).first.data();
|
|
||||||
if (!cname) {
|
|
||||||
*end = NULL;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*end = cname + (*current_).first.length();
|
|
||||||
return cname;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
@@ -125,12 +186,19 @@ char const* ValueIteratorBase::memberName(char const** end) const {
|
|||||||
|
|
||||||
ValueConstIterator::ValueConstIterator() {}
|
ValueConstIterator::ValueConstIterator() {}
|
||||||
|
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
ValueConstIterator::ValueConstIterator(
|
ValueConstIterator::ValueConstIterator(
|
||||||
const Value::ObjectValues::iterator& current)
|
const Value::ObjectValues::iterator& current)
|
||||||
: ValueIteratorBase(current) {}
|
: ValueIteratorBase(current) {}
|
||||||
|
#else
|
||||||
|
ValueConstIterator::ValueConstIterator(
|
||||||
|
const ValueInternalArray::IteratorState& state)
|
||||||
|
: ValueIteratorBase(state) {}
|
||||||
|
|
||||||
ValueConstIterator::ValueConstIterator(ValueIterator const& other)
|
ValueConstIterator::ValueConstIterator(
|
||||||
: ValueIteratorBase(other) {}
|
const ValueInternalMap::IteratorState& state)
|
||||||
|
: ValueIteratorBase(state) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
ValueConstIterator& ValueConstIterator::
|
ValueConstIterator& ValueConstIterator::
|
||||||
operator=(const ValueIteratorBase& other) {
|
operator=(const ValueIteratorBase& other) {
|
||||||
@@ -148,13 +216,19 @@ operator=(const ValueIteratorBase& other) {
|
|||||||
|
|
||||||
ValueIterator::ValueIterator() {}
|
ValueIterator::ValueIterator() {}
|
||||||
|
|
||||||
|
#ifndef JSON_VALUE_USE_INTERNAL_MAP
|
||||||
ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)
|
ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)
|
||||||
: ValueIteratorBase(current) {}
|
: ValueIteratorBase(current) {}
|
||||||
|
#else
|
||||||
|
ValueIterator::ValueIterator(const ValueInternalArray::IteratorState& state)
|
||||||
|
: ValueIteratorBase(state) {}
|
||||||
|
|
||||||
|
ValueIterator::ValueIterator(const ValueInternalMap::IteratorState& state)
|
||||||
|
: ValueIteratorBase(state) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
ValueIterator::ValueIterator(const ValueConstIterator& other)
|
ValueIterator::ValueIterator(const ValueConstIterator& other)
|
||||||
: ValueIteratorBase(other) {
|
: ValueIteratorBase(other) {}
|
||||||
throwRuntimeError("ConstIterator to Iterator should never be allowed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
ValueIterator::ValueIterator(const ValueIterator& other)
|
ValueIterator::ValueIterator(const ValueIterator& other)
|
||||||
: ValueIteratorBase(other) {}
|
: ValueIteratorBase(other) {}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2011 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@@ -12,57 +12,13 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <cassert>
|
#include <stdexcept>
|
||||||
#include <cstring>
|
#include <assert.h>
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1800 // Between VC++ 6.0 and VC++ 11.0
|
|
||||||
#include <float.h>
|
|
||||||
#define isfinite _finite
|
|
||||||
#elif defined(__sun) && defined(__SVR4) //Solaris
|
|
||||||
#if !defined(isfinite)
|
|
||||||
#include <ieeefp.h>
|
|
||||||
#define isfinite finite
|
|
||||||
#endif
|
|
||||||
#elif defined(_AIX)
|
|
||||||
#if !defined(isfinite)
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#define isfinite finite
|
#include <stdio.h>
|
||||||
#endif
|
#include <string.h>
|
||||||
#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(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below
|
||||||
#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
|
|
||||||
#define snprintf sprintf_s
|
|
||||||
#elif _MSC_VER >= 1900 // VC++ 14.0 and above
|
|
||||||
#define snprintf std::snprintf
|
|
||||||
#else
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#endif
|
|
||||||
#elif defined(__ANDROID__) || defined(__QNXNTO__)
|
|
||||||
#define snprintf snprintf
|
|
||||||
#elif __cplusplus >= 201103L
|
|
||||||
#if !defined(__MINGW32__) && !defined(__CYGWIN__)
|
|
||||||
#define snprintf std::snprintf
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__BORLANDC__)
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#define isfinite _finite
|
#define isfinite _finite
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
@@ -73,9 +29,14 @@
|
|||||||
#pragma warning(disable : 4996)
|
#pragma warning(disable : 4996)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__sun) && defined(__SVR4) //Solaris
|
||||||
|
#include <ieeefp.h>
|
||||||
|
#define isfinite finite
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
|
|
||||||
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
|
#if __cplusplus >= 201103L
|
||||||
typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
|
typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
|
||||||
#else
|
#else
|
||||||
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
|
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
|
||||||
@@ -89,33 +50,20 @@ static bool containsControlCharacter(const char* str) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool containsControlCharacter0(const char* str, unsigned len) {
|
std::string valueToString(LargestInt value) {
|
||||||
char const* end = str + len;
|
|
||||||
while (end != str) {
|
|
||||||
if (isControlCharacter(*str) || 0==*str)
|
|
||||||
return true;
|
|
||||||
++str;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONCPP_STRING valueToString(LargestInt value) {
|
|
||||||
UIntToStringBuffer buffer;
|
UIntToStringBuffer buffer;
|
||||||
char* current = buffer + sizeof(buffer);
|
char* current = buffer + sizeof(buffer);
|
||||||
if (value == Value::minLargestInt) {
|
bool isNegative = value < 0;
|
||||||
uintToString(LargestUInt(Value::maxLargestInt) + 1, current);
|
if (isNegative)
|
||||||
|
value = -value;
|
||||||
|
uintToString(LargestUInt(value), current);
|
||||||
|
if (isNegative)
|
||||||
*--current = '-';
|
*--current = '-';
|
||||||
} else if (value < 0) {
|
|
||||||
uintToString(LargestUInt(-value), current);
|
|
||||||
*--current = '-';
|
|
||||||
} else {
|
|
||||||
uintToString(LargestUInt(value), current);
|
|
||||||
}
|
|
||||||
assert(current >= buffer);
|
assert(current >= buffer);
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONCPP_STRING valueToString(LargestUInt value) {
|
std::string valueToString(LargestUInt value) {
|
||||||
UIntToStringBuffer buffer;
|
UIntToStringBuffer buffer;
|
||||||
char* current = buffer + sizeof(buffer);
|
char* current = buffer + sizeof(buffer);
|
||||||
uintToString(value, current);
|
uintToString(value, current);
|
||||||
@@ -125,70 +73,68 @@ JSONCPP_STRING valueToString(LargestUInt value) {
|
|||||||
|
|
||||||
#if defined(JSON_HAS_INT64)
|
#if defined(JSON_HAS_INT64)
|
||||||
|
|
||||||
JSONCPP_STRING valueToString(Int value) {
|
std::string valueToString(Int value) {
|
||||||
return valueToString(LargestInt(value));
|
return valueToString(LargestInt(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONCPP_STRING valueToString(UInt value) {
|
std::string valueToString(UInt value) {
|
||||||
return valueToString(LargestUInt(value));
|
return valueToString(LargestUInt(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // # if defined(JSON_HAS_INT64)
|
#endif // # if defined(JSON_HAS_INT64)
|
||||||
|
|
||||||
namespace {
|
std::string valueToString(double value) {
|
||||||
JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int precision) {
|
|
||||||
// Allocate a buffer that is more than large enough to store the 16 digits of
|
// Allocate a buffer that is more than large enough to store the 16 digits of
|
||||||
// precision requested below.
|
// precision requested below.
|
||||||
char buffer[36];
|
char buffer[32];
|
||||||
int len = -1;
|
int len = -1;
|
||||||
|
|
||||||
char formatString[15];
|
// Print into the buffer. We need not request the alternative representation
|
||||||
snprintf(formatString, sizeof(formatString), "%%.%dg", precision);
|
// 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
|
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with
|
||||||
// that always has a decimal point because JSON doesn't distingish the
|
// visual studio 2005 to
|
||||||
// concepts of reals and integers.
|
// 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)) {
|
if (isfinite(value)) {
|
||||||
len = snprintf(buffer, sizeof(buffer), formatString, value);
|
len = snprintf(buffer, sizeof(buffer), "%.17g", value);
|
||||||
fixNumericLocale(buffer, buffer + len);
|
|
||||||
|
|
||||||
// try to ensure we preserve the fact that this was given to us as a double on input
|
|
||||||
if (!strchr(buffer, '.') && !strchr(buffer, 'e')) {
|
|
||||||
strcat(buffer, ".0");
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// IEEE standard states that NaN values will not compare to themselves
|
// IEEE standard states that NaN values will not compare to themselves
|
||||||
if (value != value) {
|
if (value != value) {
|
||||||
len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "NaN" : "null");
|
len = snprintf(buffer, sizeof(buffer), "null");
|
||||||
} else if (value < 0) {
|
} else if (value < 0) {
|
||||||
len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "-Infinity" : "-1e+9999");
|
len = snprintf(buffer, sizeof(buffer), "-1e+9999");
|
||||||
} else {
|
} 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);
|
assert(len >= 0);
|
||||||
|
fixNumericLocale(buffer, buffer + len);
|
||||||
return buffer;
|
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"; }
|
std::string valueToQuotedString(const char* value) {
|
||||||
|
|
||||||
JSONCPP_STRING valueToQuotedString(const char* value) {
|
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
return "";
|
return "";
|
||||||
// Not sure how to handle unicode...
|
// Not sure how to handle unicode...
|
||||||
if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL &&
|
if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL &&
|
||||||
!containsControlCharacter(value))
|
!containsControlCharacter(value))
|
||||||
return JSONCPP_STRING("\"") + value + "\"";
|
return std::string("\"") + value + "\"";
|
||||||
// We have to walk value and escape any special characters.
|
// 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.)
|
// (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
|
strlen(value) * 2 + 3; // allescaped+quotes+NULL
|
||||||
JSONCPP_STRING result;
|
std::string result;
|
||||||
result.reserve(maxsize); // to avoid lots of mallocs
|
result.reserve(maxsize); // to avoid lots of mallocs
|
||||||
result += "\"";
|
result += "\"";
|
||||||
for (const char* c = value; *c != 0; ++c) {
|
for (const char* c = value; *c != 0; ++c) {
|
||||||
@@ -224,85 +170,7 @@ JSONCPP_STRING valueToQuotedString(const char* value) {
|
|||||||
// sequence from occurring.
|
// sequence from occurring.
|
||||||
default:
|
default:
|
||||||
if (isControlCharacter(*c)) {
|
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();
|
|
||||||
} else {
|
|
||||||
result += *c;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result += "\"";
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://github.com/upcaste/upcaste/blob/master/src/upcore/src/cstring/strnpbrk.cpp
|
|
||||||
static char const* strnpbrk(char const* s, char const* accept, size_t n) {
|
|
||||||
assert((s || !n) && accept);
|
|
||||||
|
|
||||||
char const* const end = s + n;
|
|
||||||
for (char const* cur = s; cur < end; ++cur) {
|
|
||||||
int const c = *cur;
|
|
||||||
for (char const* a = accept; *a; ++a) {
|
|
||||||
if (*a == c) {
|
|
||||||
return cur;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
static JSONCPP_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 + "\"";
|
|
||||||
// We have to walk value and escape any special characters.
|
|
||||||
// Appending to JSONCPP_STRING is not efficient, but this should be rare.
|
|
||||||
// (Note: forward slashes are *not* rare, but I am not escaping them.)
|
|
||||||
JSONCPP_STRING::size_type maxsize =
|
|
||||||
length * 2 + 3; // allescaped+quotes+NULL
|
|
||||||
JSONCPP_STRING result;
|
|
||||||
result.reserve(maxsize); // to avoid lots of mallocs
|
|
||||||
result += "\"";
|
|
||||||
char const* end = value + length;
|
|
||||||
for (const char* c = value; c != end; ++c) {
|
|
||||||
switch (*c) {
|
|
||||||
case '\"':
|
|
||||||
result += "\\\"";
|
|
||||||
break;
|
|
||||||
case '\\':
|
|
||||||
result += "\\\\";
|
|
||||||
break;
|
|
||||||
case '\b':
|
|
||||||
result += "\\b";
|
|
||||||
break;
|
|
||||||
case '\f':
|
|
||||||
result += "\\f";
|
|
||||||
break;
|
|
||||||
case '\n':
|
|
||||||
result += "\\n";
|
|
||||||
break;
|
|
||||||
case '\r':
|
|
||||||
result += "\\r";
|
|
||||||
break;
|
|
||||||
case '\t':
|
|
||||||
result += "\\t";
|
|
||||||
break;
|
|
||||||
// case '/':
|
|
||||||
// Even though \/ is considered a legal escape in JSON, a bare
|
|
||||||
// slash is also legal, so I see no reason to escape it.
|
|
||||||
// (I hope I am not misunderstanding something.)
|
|
||||||
// blep notes: actually escaping \/ may be useful in javascript to avoid </
|
|
||||||
// sequence.
|
|
||||||
// Should add a flag to allow this compatibility mode and prevent this
|
|
||||||
// sequence from occurring.
|
|
||||||
default:
|
|
||||||
if ((isControlCharacter(*c)) || (*c == 0)) {
|
|
||||||
JSONCPP_OSTRINGSTREAM oss;
|
|
||||||
oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
|
oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
|
||||||
<< std::setw(4) << static_cast<int>(*c);
|
<< std::setw(4) << static_cast<int>(*c);
|
||||||
result += oss.str();
|
result += oss.str();
|
||||||
@@ -324,28 +192,21 @@ Writer::~Writer() {}
|
|||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FastWriter::FastWriter()
|
FastWriter::FastWriter()
|
||||||
: yamlCompatiblityEnabled_(false), dropNullPlaceholders_(false),
|
: yamlCompatiblityEnabled_(false) {}
|
||||||
omitEndingLineFeed_(false) {}
|
|
||||||
|
|
||||||
void FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; }
|
void FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; }
|
||||||
|
|
||||||
void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
|
std::string FastWriter::write(const Value& root) {
|
||||||
|
document_ = "";
|
||||||
void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
|
|
||||||
|
|
||||||
JSONCPP_STRING FastWriter::write(const Value& root) {
|
|
||||||
document_.clear();
|
|
||||||
writeValue(root);
|
writeValue(root);
|
||||||
if (!omitEndingLineFeed_)
|
document_ += "\n";
|
||||||
document_ += "\n";
|
|
||||||
return document_;
|
return document_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FastWriter::writeValue(const Value& value) {
|
void FastWriter::writeValue(const Value& value) {
|
||||||
switch (value.type()) {
|
switch (value.type()) {
|
||||||
case nullValue:
|
case nullValue:
|
||||||
if (!dropNullPlaceholders_)
|
document_ += "null";
|
||||||
document_ += "null";
|
|
||||||
break;
|
break;
|
||||||
case intValue:
|
case intValue:
|
||||||
document_ += valueToString(value.asLargestInt());
|
document_ += valueToString(value.asLargestInt());
|
||||||
@@ -357,21 +218,15 @@ void FastWriter::writeValue(const Value& value) {
|
|||||||
document_ += valueToString(value.asDouble());
|
document_ += valueToString(value.asDouble());
|
||||||
break;
|
break;
|
||||||
case stringValue:
|
case stringValue:
|
||||||
{
|
document_ += valueToQuotedString(value.asCString());
|
||||||
// Is NULL possible for value.string_? No.
|
|
||||||
char const* str;
|
|
||||||
char const* end;
|
|
||||||
bool ok = value.getString(&str, &end);
|
|
||||||
if (ok) document_ += valueToQuotedStringN(str, static_cast<unsigned>(end-str));
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case booleanValue:
|
case booleanValue:
|
||||||
document_ += valueToString(value.asBool());
|
document_ += valueToString(value.asBool());
|
||||||
break;
|
break;
|
||||||
case arrayValue: {
|
case arrayValue: {
|
||||||
document_ += '[';
|
document_ += '[';
|
||||||
ArrayIndex size = value.size();
|
int size = value.size();
|
||||||
for (ArrayIndex index = 0; index < size; ++index) {
|
for (int index = 0; index < size; ++index) {
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
document_ += ',';
|
document_ += ',';
|
||||||
writeValue(value[index]);
|
writeValue(value[index]);
|
||||||
@@ -383,10 +238,10 @@ void FastWriter::writeValue(const Value& value) {
|
|||||||
document_ += '{';
|
document_ += '{';
|
||||||
for (Value::Members::iterator it = members.begin(); it != members.end();
|
for (Value::Members::iterator it = members.begin(); it != members.end();
|
||||||
++it) {
|
++it) {
|
||||||
const JSONCPP_STRING& name = *it;
|
const std::string& name = *it;
|
||||||
if (it != members.begin())
|
if (it != members.begin())
|
||||||
document_ += ',';
|
document_ += ',';
|
||||||
document_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length()));
|
document_ += valueToQuotedString(name.c_str());
|
||||||
document_ += yamlCompatiblityEnabled_ ? ": " : ":";
|
document_ += yamlCompatiblityEnabled_ ? ": " : ":";
|
||||||
writeValue(value[name]);
|
writeValue(value[name]);
|
||||||
}
|
}
|
||||||
@@ -401,10 +256,10 @@ void FastWriter::writeValue(const Value& value) {
|
|||||||
StyledWriter::StyledWriter()
|
StyledWriter::StyledWriter()
|
||||||
: rightMargin_(74), indentSize_(3), addChildValues_() {}
|
: rightMargin_(74), indentSize_(3), addChildValues_() {}
|
||||||
|
|
||||||
JSONCPP_STRING StyledWriter::write(const Value& root) {
|
std::string StyledWriter::write(const Value& root) {
|
||||||
document_.clear();
|
document_ = "";
|
||||||
addChildValues_ = false;
|
addChildValues_ = false;
|
||||||
indentString_.clear();
|
indentString_ = "";
|
||||||
writeCommentBeforeValue(root);
|
writeCommentBeforeValue(root);
|
||||||
writeValue(root);
|
writeValue(root);
|
||||||
writeCommentAfterValueOnSameLine(root);
|
writeCommentAfterValueOnSameLine(root);
|
||||||
@@ -427,15 +282,8 @@ void StyledWriter::writeValue(const Value& value) {
|
|||||||
pushValue(valueToString(value.asDouble()));
|
pushValue(valueToString(value.asDouble()));
|
||||||
break;
|
break;
|
||||||
case stringValue:
|
case stringValue:
|
||||||
{
|
pushValue(valueToQuotedString(value.asCString()));
|
||||||
// Is NULL possible for value.string_? No.
|
|
||||||
char const* str;
|
|
||||||
char const* end;
|
|
||||||
bool ok = value.getString(&str, &end);
|
|
||||||
if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
|
|
||||||
else pushValue("");
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case booleanValue:
|
case booleanValue:
|
||||||
pushValue(valueToString(value.asBool()));
|
pushValue(valueToString(value.asBool()));
|
||||||
break;
|
break;
|
||||||
@@ -451,7 +299,7 @@ void StyledWriter::writeValue(const Value& value) {
|
|||||||
indent();
|
indent();
|
||||||
Value::Members::iterator it = members.begin();
|
Value::Members::iterator it = members.begin();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const JSONCPP_STRING& name = *it;
|
const std::string& name = *it;
|
||||||
const Value& childValue = value[name];
|
const Value& childValue = value[name];
|
||||||
writeCommentBeforeValue(childValue);
|
writeCommentBeforeValue(childValue);
|
||||||
writeWithIndent(valueToQuotedString(name.c_str()));
|
writeWithIndent(valueToQuotedString(name.c_str()));
|
||||||
@@ -515,25 +363,26 @@ void StyledWriter::writeArrayValue(const Value& value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool StyledWriter::isMultineArray(const Value& value) {
|
bool StyledWriter::isMultineArray(const Value& value) {
|
||||||
ArrayIndex const size = value.size();
|
int size = value.size();
|
||||||
bool isMultiLine = size * 3 >= rightMargin_;
|
bool isMultiLine = size * 3 >= rightMargin_;
|
||||||
childValues_.clear();
|
childValues_.clear();
|
||||||
for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
|
for (int index = 0; index < size && !isMultiLine; ++index) {
|
||||||
const Value& childValue = value[index];
|
const Value& childValue = value[index];
|
||||||
isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
|
isMultiLine =
|
||||||
|
isMultiLine || ((childValue.isArray() || childValue.isObject()) &&
|
||||||
childValue.size() > 0);
|
childValue.size() > 0);
|
||||||
}
|
}
|
||||||
if (!isMultiLine) // check if line length > max line length
|
if (!isMultiLine) // check if line length > max line length
|
||||||
{
|
{
|
||||||
childValues_.reserve(size);
|
childValues_.reserve(size);
|
||||||
addChildValues_ = true;
|
addChildValues_ = true;
|
||||||
ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||||
for (ArrayIndex index = 0; index < size; ++index) {
|
for (int index = 0; index < size; ++index) {
|
||||||
if (hasCommentForValue(value[index])) {
|
if (hasCommentForValue(value[index])) {
|
||||||
isMultiLine = true;
|
isMultiLine = true;
|
||||||
}
|
}
|
||||||
writeValue(value[index]);
|
writeValue(value[index]);
|
||||||
lineLength += static_cast<ArrayIndex>(childValues_[index].length());
|
lineLength += int(childValues_[index].length());
|
||||||
}
|
}
|
||||||
addChildValues_ = false;
|
addChildValues_ = false;
|
||||||
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
||||||
@@ -541,7 +390,7 @@ bool StyledWriter::isMultineArray(const Value& value) {
|
|||||||
return isMultiLine;
|
return isMultiLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyledWriter::pushValue(const JSONCPP_STRING& value) {
|
void StyledWriter::pushValue(const std::string& value) {
|
||||||
if (addChildValues_)
|
if (addChildValues_)
|
||||||
childValues_.push_back(value);
|
childValues_.push_back(value);
|
||||||
else
|
else
|
||||||
@@ -559,15 +408,15 @@ void StyledWriter::writeIndent() {
|
|||||||
document_ += indentString_;
|
document_ += indentString_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyledWriter::writeWithIndent(const JSONCPP_STRING& value) {
|
void StyledWriter::writeWithIndent(const std::string& value) {
|
||||||
writeIndent();
|
writeIndent();
|
||||||
document_ += value;
|
document_ += value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyledWriter::indent() { indentString_ += JSONCPP_STRING(indentSize_, ' '); }
|
void StyledWriter::indent() { indentString_ += std::string(indentSize_, ' '); }
|
||||||
|
|
||||||
void StyledWriter::unindent() {
|
void StyledWriter::unindent() {
|
||||||
assert(indentString_.size() >= indentSize_);
|
assert(int(indentString_.size()) >= indentSize_);
|
||||||
indentString_.resize(indentString_.size() - indentSize_);
|
indentString_.resize(indentString_.size() - indentSize_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,8 +426,8 @@ void StyledWriter::writeCommentBeforeValue(const Value& root) {
|
|||||||
|
|
||||||
document_ += "\n";
|
document_ += "\n";
|
||||||
writeIndent();
|
writeIndent();
|
||||||
const JSONCPP_STRING& comment = root.getComment(commentBefore);
|
const std::string& comment = root.getComment(commentBefore);
|
||||||
JSONCPP_STRING::const_iterator iter = comment.begin();
|
std::string::const_iterator iter = comment.begin();
|
||||||
while (iter != comment.end()) {
|
while (iter != comment.end()) {
|
||||||
document_ += *iter;
|
document_ += *iter;
|
||||||
if (*iter == '\n' &&
|
if (*iter == '\n' &&
|
||||||
@@ -611,14 +460,14 @@ bool StyledWriter::hasCommentForValue(const Value& value) {
|
|||||||
// Class StyledStreamWriter
|
// Class StyledStreamWriter
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
StyledStreamWriter::StyledStreamWriter(JSONCPP_STRING indentation)
|
StyledStreamWriter::StyledStreamWriter(std::string indentation)
|
||||||
: document_(NULL), rightMargin_(74), indentation_(indentation),
|
: document_(NULL), rightMargin_(74), indentation_(indentation),
|
||||||
addChildValues_() {}
|
addChildValues_() {}
|
||||||
|
|
||||||
void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
|
void StyledStreamWriter::write(std::ostream& out, const Value& root) {
|
||||||
document_ = &out;
|
document_ = &out;
|
||||||
addChildValues_ = false;
|
addChildValues_ = false;
|
||||||
indentString_.clear();
|
indentString_ = "";
|
||||||
indented_ = true;
|
indented_ = true;
|
||||||
writeCommentBeforeValue(root);
|
writeCommentBeforeValue(root);
|
||||||
if (!indented_) writeIndent();
|
if (!indented_) writeIndent();
|
||||||
@@ -644,15 +493,8 @@ void StyledStreamWriter::writeValue(const Value& value) {
|
|||||||
pushValue(valueToString(value.asDouble()));
|
pushValue(valueToString(value.asDouble()));
|
||||||
break;
|
break;
|
||||||
case stringValue:
|
case stringValue:
|
||||||
{
|
pushValue(valueToQuotedString(value.asCString()));
|
||||||
// Is NULL possible for value.string_? No.
|
|
||||||
char const* str;
|
|
||||||
char const* end;
|
|
||||||
bool ok = value.getString(&str, &end);
|
|
||||||
if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
|
|
||||||
else pushValue("");
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case booleanValue:
|
case booleanValue:
|
||||||
pushValue(valueToString(value.asBool()));
|
pushValue(valueToString(value.asBool()));
|
||||||
break;
|
break;
|
||||||
@@ -668,7 +510,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
|
|||||||
indent();
|
indent();
|
||||||
Value::Members::iterator it = members.begin();
|
Value::Members::iterator it = members.begin();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const JSONCPP_STRING& name = *it;
|
const std::string& name = *it;
|
||||||
const Value& childValue = value[name];
|
const Value& childValue = value[name];
|
||||||
writeCommentBeforeValue(childValue);
|
writeCommentBeforeValue(childValue);
|
||||||
writeWithIndent(valueToQuotedString(name.c_str()));
|
writeWithIndent(valueToQuotedString(name.c_str()));
|
||||||
@@ -734,25 +576,26 @@ void StyledStreamWriter::writeArrayValue(const Value& value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool StyledStreamWriter::isMultineArray(const Value& value) {
|
bool StyledStreamWriter::isMultineArray(const Value& value) {
|
||||||
ArrayIndex const size = value.size();
|
int size = value.size();
|
||||||
bool isMultiLine = size * 3 >= rightMargin_;
|
bool isMultiLine = size * 3 >= rightMargin_;
|
||||||
childValues_.clear();
|
childValues_.clear();
|
||||||
for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
|
for (int index = 0; index < size && !isMultiLine; ++index) {
|
||||||
const Value& childValue = value[index];
|
const Value& childValue = value[index];
|
||||||
isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
|
isMultiLine =
|
||||||
|
isMultiLine || ((childValue.isArray() || childValue.isObject()) &&
|
||||||
childValue.size() > 0);
|
childValue.size() > 0);
|
||||||
}
|
}
|
||||||
if (!isMultiLine) // check if line length > max line length
|
if (!isMultiLine) // check if line length > max line length
|
||||||
{
|
{
|
||||||
childValues_.reserve(size);
|
childValues_.reserve(size);
|
||||||
addChildValues_ = true;
|
addChildValues_ = true;
|
||||||
ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||||
for (ArrayIndex index = 0; index < size; ++index) {
|
for (int index = 0; index < size; ++index) {
|
||||||
if (hasCommentForValue(value[index])) {
|
if (hasCommentForValue(value[index])) {
|
||||||
isMultiLine = true;
|
isMultiLine = true;
|
||||||
}
|
}
|
||||||
writeValue(value[index]);
|
writeValue(value[index]);
|
||||||
lineLength += static_cast<ArrayIndex>(childValues_[index].length());
|
lineLength += int(childValues_[index].length());
|
||||||
}
|
}
|
||||||
addChildValues_ = false;
|
addChildValues_ = false;
|
||||||
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
||||||
@@ -760,7 +603,7 @@ bool StyledStreamWriter::isMultineArray(const Value& value) {
|
|||||||
return isMultiLine;
|
return isMultiLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyledStreamWriter::pushValue(const JSONCPP_STRING& value) {
|
void StyledStreamWriter::pushValue(const std::string& value) {
|
||||||
if (addChildValues_)
|
if (addChildValues_)
|
||||||
childValues_.push_back(value);
|
childValues_.push_back(value);
|
||||||
else
|
else
|
||||||
@@ -775,7 +618,7 @@ void StyledStreamWriter::writeIndent() {
|
|||||||
*document_ << '\n' << indentString_;
|
*document_ << '\n' << indentString_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyledStreamWriter::writeWithIndent(const JSONCPP_STRING& value) {
|
void StyledStreamWriter::writeWithIndent(const std::string& value) {
|
||||||
if (!indented_) writeIndent();
|
if (!indented_) writeIndent();
|
||||||
*document_ << value;
|
*document_ << value;
|
||||||
indented_ = false;
|
indented_ = false;
|
||||||
@@ -793,8 +636,8 @@ void StyledStreamWriter::writeCommentBeforeValue(const Value& root) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!indented_) writeIndent();
|
if (!indented_) writeIndent();
|
||||||
const JSONCPP_STRING& comment = root.getComment(commentBefore);
|
const std::string& comment = root.getComment(commentBefore);
|
||||||
JSONCPP_STRING::const_iterator iter = comment.begin();
|
std::string::const_iterator iter = comment.begin();
|
||||||
while (iter != comment.end()) {
|
while (iter != comment.end()) {
|
||||||
*document_ << *iter;
|
*document_ << *iter;
|
||||||
if (*iter == '\n' &&
|
if (*iter == '\n' &&
|
||||||
@@ -839,50 +682,44 @@ struct CommentStyle {
|
|||||||
struct BuiltStyledStreamWriter : public StreamWriter
|
struct BuiltStyledStreamWriter : public StreamWriter
|
||||||
{
|
{
|
||||||
BuiltStyledStreamWriter(
|
BuiltStyledStreamWriter(
|
||||||
JSONCPP_STRING const& indentation,
|
std::string const& indentation,
|
||||||
CommentStyle::Enum cs,
|
CommentStyle::Enum cs,
|
||||||
JSONCPP_STRING const& colonSymbol,
|
std::string const& colonSymbol,
|
||||||
JSONCPP_STRING const& nullSymbol,
|
std::string const& nullSymbol,
|
||||||
JSONCPP_STRING const& endingLineFeedSymbol,
|
std::string const& endingLineFeedSymbol);
|
||||||
bool useSpecialFloats,
|
virtual int write(Value const& root, std::ostream* sout);
|
||||||
unsigned int precision);
|
|
||||||
int write(Value const& root, JSONCPP_OSTREAM* sout) JSONCPP_OVERRIDE;
|
|
||||||
private:
|
private:
|
||||||
void writeValue(Value const& value);
|
void writeValue(Value const& value);
|
||||||
void writeArrayValue(Value const& value);
|
void writeArrayValue(Value const& value);
|
||||||
bool isMultineArray(Value const& value);
|
bool isMultineArray(Value const& value);
|
||||||
void pushValue(JSONCPP_STRING const& value);
|
void pushValue(std::string const& value);
|
||||||
void writeIndent();
|
void writeIndent();
|
||||||
void writeWithIndent(JSONCPP_STRING const& value);
|
void writeWithIndent(std::string const& value);
|
||||||
void indent();
|
void indent();
|
||||||
void unindent();
|
void unindent();
|
||||||
void writeCommentBeforeValue(Value const& root);
|
void writeCommentBeforeValue(Value const& root);
|
||||||
void writeCommentAfterValueOnSameLine(Value const& root);
|
void writeCommentAfterValueOnSameLine(Value const& root);
|
||||||
static bool hasCommentForValue(const Value& value);
|
static bool hasCommentForValue(const Value& value);
|
||||||
|
|
||||||
typedef std::vector<JSONCPP_STRING> ChildValues;
|
typedef std::vector<std::string> ChildValues;
|
||||||
|
|
||||||
ChildValues childValues_;
|
ChildValues childValues_;
|
||||||
JSONCPP_STRING indentString_;
|
std::string indentString_;
|
||||||
unsigned int rightMargin_;
|
int rightMargin_;
|
||||||
JSONCPP_STRING indentation_;
|
std::string indentation_;
|
||||||
CommentStyle::Enum cs_;
|
CommentStyle::Enum cs_;
|
||||||
JSONCPP_STRING colonSymbol_;
|
std::string colonSymbol_;
|
||||||
JSONCPP_STRING nullSymbol_;
|
std::string nullSymbol_;
|
||||||
JSONCPP_STRING endingLineFeedSymbol_;
|
std::string endingLineFeedSymbol_;
|
||||||
bool addChildValues_ : 1;
|
bool addChildValues_ : 1;
|
||||||
bool indented_ : 1;
|
bool indented_ : 1;
|
||||||
bool useSpecialFloats_ : 1;
|
|
||||||
unsigned int precision_;
|
|
||||||
};
|
};
|
||||||
BuiltStyledStreamWriter::BuiltStyledStreamWriter(
|
BuiltStyledStreamWriter::BuiltStyledStreamWriter(
|
||||||
JSONCPP_STRING const& indentation,
|
std::string const& indentation,
|
||||||
CommentStyle::Enum cs,
|
CommentStyle::Enum cs,
|
||||||
JSONCPP_STRING const& colonSymbol,
|
std::string const& colonSymbol,
|
||||||
JSONCPP_STRING const& nullSymbol,
|
std::string const& nullSymbol,
|
||||||
JSONCPP_STRING const& endingLineFeedSymbol,
|
std::string const& endingLineFeedSymbol)
|
||||||
bool useSpecialFloats,
|
|
||||||
unsigned int precision)
|
|
||||||
: rightMargin_(74)
|
: rightMargin_(74)
|
||||||
, indentation_(indentation)
|
, indentation_(indentation)
|
||||||
, cs_(cs)
|
, cs_(cs)
|
||||||
@@ -891,16 +728,14 @@ BuiltStyledStreamWriter::BuiltStyledStreamWriter(
|
|||||||
, endingLineFeedSymbol_(endingLineFeedSymbol)
|
, endingLineFeedSymbol_(endingLineFeedSymbol)
|
||||||
, addChildValues_(false)
|
, addChildValues_(false)
|
||||||
, indented_(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;
|
sout_ = sout;
|
||||||
addChildValues_ = false;
|
addChildValues_ = false;
|
||||||
indented_ = true;
|
indented_ = true;
|
||||||
indentString_.clear();
|
indentString_ = "";
|
||||||
writeCommentBeforeValue(root);
|
writeCommentBeforeValue(root);
|
||||||
if (!indented_) writeIndent();
|
if (!indented_) writeIndent();
|
||||||
indented_ = true;
|
indented_ = true;
|
||||||
@@ -922,18 +757,11 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
|
|||||||
pushValue(valueToString(value.asLargestUInt()));
|
pushValue(valueToString(value.asLargestUInt()));
|
||||||
break;
|
break;
|
||||||
case realValue:
|
case realValue:
|
||||||
pushValue(valueToString(value.asDouble(), useSpecialFloats_, precision_));
|
pushValue(valueToString(value.asDouble()));
|
||||||
break;
|
break;
|
||||||
case stringValue:
|
case stringValue:
|
||||||
{
|
pushValue(valueToQuotedString(value.asCString()));
|
||||||
// Is NULL is possible for value.string_? No.
|
|
||||||
char const* str;
|
|
||||||
char const* end;
|
|
||||||
bool ok = value.getString(&str, &end);
|
|
||||||
if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
|
|
||||||
else pushValue("");
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case booleanValue:
|
case booleanValue:
|
||||||
pushValue(valueToString(value.asBool()));
|
pushValue(valueToString(value.asBool()));
|
||||||
break;
|
break;
|
||||||
@@ -949,10 +777,10 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
|
|||||||
indent();
|
indent();
|
||||||
Value::Members::iterator it = members.begin();
|
Value::Members::iterator it = members.begin();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
JSONCPP_STRING const& name = *it;
|
std::string const& name = *it;
|
||||||
Value const& childValue = value[name];
|
Value const& childValue = value[name];
|
||||||
writeCommentBeforeValue(childValue);
|
writeCommentBeforeValue(childValue);
|
||||||
writeWithIndent(valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length())));
|
writeWithIndent(valueToQuotedString(name.c_str()));
|
||||||
*sout_ << colonSymbol_;
|
*sout_ << colonSymbol_;
|
||||||
writeValue(childValue);
|
writeValue(childValue);
|
||||||
if (++it == members.end()) {
|
if (++it == members.end()) {
|
||||||
@@ -1007,7 +835,7 @@ void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
|
|||||||
if (!indentation_.empty()) *sout_ << " ";
|
if (!indentation_.empty()) *sout_ << " ";
|
||||||
for (unsigned index = 0; index < size; ++index) {
|
for (unsigned index = 0; index < size; ++index) {
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
*sout_ << ((!indentation_.empty()) ? ", " : ",");
|
*sout_ << ", ";
|
||||||
*sout_ << childValues_[index];
|
*sout_ << childValues_[index];
|
||||||
}
|
}
|
||||||
if (!indentation_.empty()) *sout_ << " ";
|
if (!indentation_.empty()) *sout_ << " ";
|
||||||
@@ -1017,25 +845,26 @@ void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BuiltStyledStreamWriter::isMultineArray(Value const& value) {
|
bool BuiltStyledStreamWriter::isMultineArray(Value const& value) {
|
||||||
ArrayIndex const size = value.size();
|
int size = value.size();
|
||||||
bool isMultiLine = size * 3 >= rightMargin_;
|
bool isMultiLine = size * 3 >= rightMargin_;
|
||||||
childValues_.clear();
|
childValues_.clear();
|
||||||
for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
|
for (int index = 0; index < size && !isMultiLine; ++index) {
|
||||||
Value const& childValue = value[index];
|
Value const& childValue = value[index];
|
||||||
isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
|
isMultiLine =
|
||||||
|
isMultiLine || ((childValue.isArray() || childValue.isObject()) &&
|
||||||
childValue.size() > 0);
|
childValue.size() > 0);
|
||||||
}
|
}
|
||||||
if (!isMultiLine) // check if line length > max line length
|
if (!isMultiLine) // check if line length > max line length
|
||||||
{
|
{
|
||||||
childValues_.reserve(size);
|
childValues_.reserve(size);
|
||||||
addChildValues_ = true;
|
addChildValues_ = true;
|
||||||
ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||||
for (ArrayIndex index = 0; index < size; ++index) {
|
for (int index = 0; index < size; ++index) {
|
||||||
if (hasCommentForValue(value[index])) {
|
if (hasCommentForValue(value[index])) {
|
||||||
isMultiLine = true;
|
isMultiLine = true;
|
||||||
}
|
}
|
||||||
writeValue(value[index]);
|
writeValue(value[index]);
|
||||||
lineLength += static_cast<ArrayIndex>(childValues_[index].length());
|
lineLength += int(childValues_[index].length());
|
||||||
}
|
}
|
||||||
addChildValues_ = false;
|
addChildValues_ = false;
|
||||||
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
||||||
@@ -1043,7 +872,7 @@ bool BuiltStyledStreamWriter::isMultineArray(Value const& value) {
|
|||||||
return isMultiLine;
|
return isMultiLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuiltStyledStreamWriter::pushValue(JSONCPP_STRING const& value) {
|
void BuiltStyledStreamWriter::pushValue(std::string const& value) {
|
||||||
if (addChildValues_)
|
if (addChildValues_)
|
||||||
childValues_.push_back(value);
|
childValues_.push_back(value);
|
||||||
else
|
else
|
||||||
@@ -1062,7 +891,7 @@ void BuiltStyledStreamWriter::writeIndent() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuiltStyledStreamWriter::writeWithIndent(JSONCPP_STRING const& value) {
|
void BuiltStyledStreamWriter::writeWithIndent(std::string const& value) {
|
||||||
if (!indented_) writeIndent();
|
if (!indented_) writeIndent();
|
||||||
*sout_ << value;
|
*sout_ << value;
|
||||||
indented_ = false;
|
indented_ = false;
|
||||||
@@ -1081,8 +910,8 @@ void BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!indented_) writeIndent();
|
if (!indented_) writeIndent();
|
||||||
const JSONCPP_STRING& comment = root.getComment(commentBefore);
|
const std::string& comment = root.getComment(commentBefore);
|
||||||
JSONCPP_STRING::const_iterator iter = comment.begin();
|
std::string::const_iterator iter = comment.begin();
|
||||||
while (iter != comment.end()) {
|
while (iter != comment.end()) {
|
||||||
*sout_ << *iter;
|
*sout_ << *iter;
|
||||||
if (*iter == '\n' &&
|
if (*iter == '\n' &&
|
||||||
@@ -1132,66 +961,58 @@ StreamWriterBuilder::~StreamWriterBuilder()
|
|||||||
{}
|
{}
|
||||||
StreamWriter* StreamWriterBuilder::newStreamWriter() const
|
StreamWriter* StreamWriterBuilder::newStreamWriter() const
|
||||||
{
|
{
|
||||||
JSONCPP_STRING indentation = settings_["indentation"].asString();
|
std::string indentation = settings_["indentation"].asString();
|
||||||
JSONCPP_STRING cs_str = settings_["commentStyle"].asString();
|
std::string cs_str = settings_["commentStyle"].asString();
|
||||||
bool eyc = settings_["enableYAMLCompatibility"].asBool();
|
bool eyc = settings_["enableYAMLCompatibility"].asBool();
|
||||||
bool dnp = settings_["dropNullPlaceholders"].asBool();
|
bool dnp = settings_["dropNullPlaceholders"].asBool();
|
||||||
bool usf = settings_["useSpecialFloats"].asBool();
|
|
||||||
unsigned int pre = settings_["precision"].asUInt();
|
|
||||||
CommentStyle::Enum cs = CommentStyle::All;
|
CommentStyle::Enum cs = CommentStyle::All;
|
||||||
if (cs_str == "All") {
|
if (cs_str == "All") {
|
||||||
cs = CommentStyle::All;
|
cs = CommentStyle::All;
|
||||||
} else if (cs_str == "None") {
|
} else if (cs_str == "None") {
|
||||||
cs = CommentStyle::None;
|
cs = CommentStyle::None;
|
||||||
} else {
|
} else {
|
||||||
throwRuntimeError("commentStyle must be 'All' or 'None'");
|
throw std::runtime_error("commentStyle must be 'All' or 'None'");
|
||||||
}
|
}
|
||||||
JSONCPP_STRING colonSymbol = " : ";
|
std::string colonSymbol = " : ";
|
||||||
if (eyc) {
|
if (eyc) {
|
||||||
colonSymbol = ": ";
|
colonSymbol = ": ";
|
||||||
} else if (indentation.empty()) {
|
} else if (indentation.empty()) {
|
||||||
colonSymbol = ":";
|
colonSymbol = ":";
|
||||||
}
|
}
|
||||||
JSONCPP_STRING nullSymbol = "null";
|
std::string nullSymbol = "null";
|
||||||
if (dnp) {
|
if (dnp) {
|
||||||
nullSymbol.clear();
|
nullSymbol = "";
|
||||||
}
|
}
|
||||||
if (pre > 17) pre = 17;
|
std::string endingLineFeedSymbol = "";
|
||||||
JSONCPP_STRING endingLineFeedSymbol;
|
|
||||||
return new BuiltStyledStreamWriter(
|
return new BuiltStyledStreamWriter(
|
||||||
indentation, cs,
|
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->clear();
|
||||||
valid_keys->insert("indentation");
|
valid_keys->insert("indentation");
|
||||||
valid_keys->insert("commentStyle");
|
valid_keys->insert("commentStyle");
|
||||||
valid_keys->insert("enableYAMLCompatibility");
|
valid_keys->insert("enableYAMLCompatibility");
|
||||||
valid_keys->insert("dropNullPlaceholders");
|
valid_keys->insert("dropNullPlaceholders");
|
||||||
valid_keys->insert("useSpecialFloats");
|
|
||||||
valid_keys->insert("precision");
|
|
||||||
}
|
}
|
||||||
bool StreamWriterBuilder::validate(Json::Value* invalid) const
|
bool StreamWriterBuilder::validate(Json::Value* invalid) const
|
||||||
{
|
{
|
||||||
Json::Value my_invalid;
|
Json::Value my_invalid;
|
||||||
if (!invalid) invalid = &my_invalid; // so we do not need to test for NULL
|
if (!invalid) invalid = &my_invalid; // so we do not need to test for NULL
|
||||||
Json::Value& inv = *invalid;
|
Json::Value& inv = *invalid;
|
||||||
std::set<JSONCPP_STRING> valid_keys;
|
bool valid = true;
|
||||||
|
std::set<std::string> valid_keys;
|
||||||
getValidWriterKeys(&valid_keys);
|
getValidWriterKeys(&valid_keys);
|
||||||
Value::Members keys = settings_.getMemberNames();
|
Value::Members keys = settings_.getMemberNames();
|
||||||
size_t n = keys.size();
|
size_t n = keys.size();
|
||||||
for (size_t i = 0; i < n; ++i) {
|
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()) {
|
if (valid_keys.find(key) == valid_keys.end()) {
|
||||||
inv[key] = settings_[key];
|
inv[key] = settings_[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0u == inv.size();
|
return valid;
|
||||||
}
|
|
||||||
Value& StreamWriterBuilder::operator[](JSONCPP_STRING key)
|
|
||||||
{
|
|
||||||
return settings_[key];
|
|
||||||
}
|
}
|
||||||
// static
|
// static
|
||||||
void StreamWriterBuilder::setDefaults(Json::Value* settings)
|
void StreamWriterBuilder::setDefaults(Json::Value* settings)
|
||||||
@@ -1201,19 +1022,17 @@ void StreamWriterBuilder::setDefaults(Json::Value* settings)
|
|||||||
(*settings)["indentation"] = "\t";
|
(*settings)["indentation"] = "\t";
|
||||||
(*settings)["enableYAMLCompatibility"] = false;
|
(*settings)["enableYAMLCompatibility"] = false;
|
||||||
(*settings)["dropNullPlaceholders"] = false;
|
(*settings)["dropNullPlaceholders"] = false;
|
||||||
(*settings)["useSpecialFloats"] = false;
|
|
||||||
(*settings)["precision"] = 17;
|
|
||||||
//! [StreamWriterBuilderDefaults]
|
//! [StreamWriterBuilderDefaults]
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONCPP_STRING writeString(StreamWriter::Factory const& builder, Value const& root) {
|
std::string writeString(StreamWriter::Factory const& builder, Value const& root) {
|
||||||
JSONCPP_OSTRINGSTREAM sout;
|
std::ostringstream sout;
|
||||||
StreamWriterPtr const writer(builder.newStreamWriter());
|
StreamWriterPtr const writer(builder.newStreamWriter());
|
||||||
writer->write(root, &sout);
|
writer->write(root, &sout);
|
||||||
return sout.str();
|
return sout.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM& sout, Value const& root) {
|
std::ostream& operator<<(std::ostream& sout, Value const& root) {
|
||||||
StreamWriterBuilder builder;
|
StreamWriterBuilder builder;
|
||||||
StreamWriterPtr const writer(builder.newStreamWriter());
|
StreamWriterPtr const writer(builder.newStreamWriter());
|
||||||
writer->write(root, &sout);
|
writer->write(root, &sout);
|
||||||
|
8
src/lib_json/sconscript
Normal file
8
src/lib_json/sconscript
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
Import( 'env buildLibrary' )
|
||||||
|
|
||||||
|
buildLibrary( env, Split( """
|
||||||
|
json_reader.cpp
|
||||||
|
json_value.cpp
|
||||||
|
json_writer.cpp
|
||||||
|
""" ),
|
||||||
|
'json' )
|
@@ -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.
|
// Run CMake configure step to update it.
|
||||||
#ifndef JSON_VERSION_H_INCLUDED
|
#ifndef JSON_VERSION_H_INCLUDED
|
||||||
# define JSON_VERSION_H_INCLUDED
|
# define JSON_VERSION_H_INCLUDED
|
||||||
@@ -10,11 +11,4 @@
|
|||||||
# define JSONCPP_VERSION_QUALIFIER
|
# define JSONCPP_VERSION_QUALIFIER
|
||||||
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
# 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
|
#endif // JSON_VERSION_H_INCLUDED
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
# 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
|
ADD_EXECUTABLE( jsoncpp_test
|
||||||
jsontest.cpp
|
jsontest.cpp
|
||||||
@@ -7,12 +10,11 @@ ADD_EXECUTABLE( jsoncpp_test
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
IF(BUILD_SHARED_LIBS)
|
IF(JSONCPP_LIB_BUILD_SHARED)
|
||||||
ADD_DEFINITIONS( -DJSON_DLL )
|
|
||||||
TARGET_LINK_LIBRARIES(jsoncpp_test jsoncpp_lib)
|
TARGET_LINK_LIBRARIES(jsoncpp_test jsoncpp_lib)
|
||||||
ELSE(BUILD_SHARED_LIBS)
|
ELSE(JSONCPP_LIB_BUILD_SHARED)
|
||||||
TARGET_LINK_LIBRARIES(jsoncpp_test jsoncpp_lib_static)
|
TARGET_LINK_LIBRARIES(jsoncpp_test jsoncpp_lib_static)
|
||||||
ENDIF()
|
ENDIF(JSONCPP_LIB_BUILD_SHARED)
|
||||||
|
|
||||||
# another way to solve issue #90
|
# another way to solve issue #90
|
||||||
#set_target_properties(jsoncpp_test PROPERTIES COMPILE_FLAGS -ffloat-store)
|
#set_target_properties(jsoncpp_test PROPERTIES COMPILE_FLAGS -ffloat-store)
|
||||||
@@ -20,19 +22,9 @@ ENDIF()
|
|||||||
# Run unit tests in post-build
|
# Run unit tests in post-build
|
||||||
# (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?)
|
# (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?)
|
||||||
IF(JSONCPP_WITH_POST_BUILD_UNITTEST)
|
IF(JSONCPP_WITH_POST_BUILD_UNITTEST)
|
||||||
IF(BUILD_SHARED_LIBS)
|
ADD_CUSTOM_COMMAND( TARGET jsoncpp_test
|
||||||
# First, copy the shared lib, for Microsoft.
|
POST_BUILD
|
||||||
# Then, run the test executable.
|
COMMAND $<TARGET_FILE:jsoncpp_test>)
|
||||||
ADD_CUSTOM_COMMAND( TARGET jsoncpp_test
|
ENDIF(JSONCPP_WITH_POST_BUILD_UNITTEST)
|
||||||
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)
|
|
||||||
# Just run the test executable.
|
|
||||||
ADD_CUSTOM_COMMAND( TARGET jsoncpp_test
|
|
||||||
POST_BUILD
|
|
||||||
COMMAND $<TARGET_FILE:jsoncpp_test>)
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test)
|
SET_TARGET_PROPERTIES(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test)
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@@ -81,7 +81,7 @@ TestResult::TestResult()
|
|||||||
predicateStackTail_ = &rootPredicateNode_;
|
predicateStackTail_ = &rootPredicateNode_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestResult::setTestName(const JSONCPP_STRING& name) { name_ = name; }
|
void TestResult::setTestName(const std::string& name) { name_ = name; }
|
||||||
|
|
||||||
TestResult&
|
TestResult&
|
||||||
TestResult::addFailure(const char* file, unsigned int line, const char* expr) {
|
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();
|
Failures::const_iterator itEnd = failures_.end();
|
||||||
for (Failures::const_iterator it = failures_.begin(); it != itEnd; ++it) {
|
for (Failures::const_iterator it = failures_.begin(); it != itEnd; ++it) {
|
||||||
const Failure& failure = *it;
|
const Failure& failure = *it;
|
||||||
JSONCPP_STRING indent(failure.nestingLevel_ * 2, ' ');
|
std::string indent(failure.nestingLevel_ * 2, ' ');
|
||||||
if (failure.file_) {
|
if (failure.file_) {
|
||||||
printf("%s%s(%d): ", indent.c_str(), failure.file_, failure.line_);
|
printf("%s%s(%d): ", indent.c_str(), failure.file_, failure.line_);
|
||||||
}
|
}
|
||||||
@@ -173,19 +173,19 @@ void TestResult::printFailure(bool printTestName) const {
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
if (!failure.message_.empty()) {
|
if (!failure.message_.empty()) {
|
||||||
JSONCPP_STRING reindented = indentText(failure.message_, indent + " ");
|
std::string reindented = indentText(failure.message_, indent + " ");
|
||||||
printf("%s\n", reindented.c_str());
|
printf("%s\n", reindented.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONCPP_STRING TestResult::indentText(const JSONCPP_STRING& text,
|
std::string TestResult::indentText(const std::string& text,
|
||||||
const JSONCPP_STRING& indent) {
|
const std::string& indent) {
|
||||||
JSONCPP_STRING reindented;
|
std::string reindented;
|
||||||
JSONCPP_STRING::size_type lastIndex = 0;
|
std::string::size_type lastIndex = 0;
|
||||||
while (lastIndex < text.size()) {
|
while (lastIndex < text.size()) {
|
||||||
JSONCPP_STRING::size_type nextIndex = text.find('\n', lastIndex);
|
std::string::size_type nextIndex = text.find('\n', lastIndex);
|
||||||
if (nextIndex == JSONCPP_STRING::npos) {
|
if (nextIndex == std::string::npos) {
|
||||||
nextIndex = text.size() - 1;
|
nextIndex = text.size() - 1;
|
||||||
}
|
}
|
||||||
reindented += indent;
|
reindented += indent;
|
||||||
@@ -195,7 +195,7 @@ JSONCPP_STRING TestResult::indentText(const JSONCPP_STRING& text,
|
|||||||
return reindented;
|
return reindented;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestResult& TestResult::addToLastFailure(const JSONCPP_STRING& message) {
|
TestResult& TestResult::addToLastFailure(const std::string& message) {
|
||||||
if (messageTarget_ != 0) {
|
if (messageTarget_ != 0) {
|
||||||
messageTarget_->message_ += message;
|
messageTarget_->message_ += message;
|
||||||
}
|
}
|
||||||
@@ -240,9 +240,9 @@ unsigned int Runner::testCount() const {
|
|||||||
return static_cast<unsigned int>(tests_.size());
|
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]();
|
TestCase* test = tests_[index]();
|
||||||
JSONCPP_STRING name = test->testName();
|
std::string name = test->testName();
|
||||||
delete test;
|
delete test;
|
||||||
return name;
|
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& indexOut) const {
|
||||||
unsigned int count = testCount();
|
unsigned int count = testCount();
|
||||||
for (unsigned int index = 0; index < count; ++index) {
|
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 {
|
int Runner::runCommandLine(int argc, const char* argv[]) const {
|
||||||
// typedef std::deque<JSONCPP_STRING> TestNames;
|
// typedef std::deque<std::string> TestNames;
|
||||||
Runner subrunner;
|
Runner subrunner;
|
||||||
for (int index = 1; index < argc; ++index) {
|
for (int index = 1; index < argc; ++index) {
|
||||||
JSONCPP_STRING opt = argv[index];
|
std::string opt = argv[index];
|
||||||
if (opt == "--list-tests") {
|
if (opt == "--list-tests") {
|
||||||
listTests();
|
listTests();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -426,23 +426,9 @@ void Runner::printUsage(const char* appName) {
|
|||||||
// Assertion functions
|
// 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,
|
TestResult& checkStringEqual(TestResult& result,
|
||||||
const JSONCPP_STRING& expected,
|
const std::string& expected,
|
||||||
const JSONCPP_STRING& actual,
|
const std::string& actual,
|
||||||
const char* file,
|
const char* file,
|
||||||
unsigned int line,
|
unsigned int line,
|
||||||
const char* expr) {
|
const char* expr) {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
// Copyright 2007-2010 Baptiste Lepilleur
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@@ -32,8 +32,8 @@ class Failure {
|
|||||||
public:
|
public:
|
||||||
const char* file_;
|
const char* file_;
|
||||||
unsigned int line_;
|
unsigned int line_;
|
||||||
JSONCPP_STRING expr_;
|
std::string expr_;
|
||||||
JSONCPP_STRING message_;
|
std::string message_;
|
||||||
unsigned int nestingLevel_;
|
unsigned int nestingLevel_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ public:
|
|||||||
/// \internal Implementation detail for predicate macros
|
/// \internal Implementation detail for predicate macros
|
||||||
PredicateContext* predicateStackTail_;
|
PredicateContext* predicateStackTail_;
|
||||||
|
|
||||||
void setTestName(const JSONCPP_STRING& name);
|
void setTestName(const std::string& name);
|
||||||
|
|
||||||
/// Adds an assertion failure.
|
/// Adds an assertion failure.
|
||||||
TestResult&
|
TestResult&
|
||||||
@@ -82,7 +82,7 @@ public:
|
|||||||
|
|
||||||
// Generic operator that will work with anything ostream can deal with.
|
// Generic operator that will work with anything ostream can deal with.
|
||||||
template <typename T> TestResult& operator<<(const T& value) {
|
template <typename T> TestResult& operator<<(const T& value) {
|
||||||
JSONCPP_OSTRINGSTREAM oss;
|
std::ostringstream oss;
|
||||||
oss.precision(16);
|
oss.precision(16);
|
||||||
oss.setf(std::ios_base::floatfield);
|
oss.setf(std::ios_base::floatfield);
|
||||||
oss << value;
|
oss << value;
|
||||||
@@ -96,19 +96,19 @@ public:
|
|||||||
TestResult& operator<<(Json::UInt64 value);
|
TestResult& operator<<(Json::UInt64 value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestResult& addToLastFailure(const JSONCPP_STRING& message);
|
TestResult& addToLastFailure(const std::string& message);
|
||||||
unsigned int getAssertionNestingLevel() const;
|
unsigned int getAssertionNestingLevel() const;
|
||||||
/// Adds a failure or a predicate context
|
/// Adds a failure or a predicate context
|
||||||
void addFailureInfo(const char* file,
|
void addFailureInfo(const char* file,
|
||||||
unsigned int line,
|
unsigned int line,
|
||||||
const char* expr,
|
const char* expr,
|
||||||
unsigned int nestingLevel);
|
unsigned int nestingLevel);
|
||||||
static JSONCPP_STRING indentText(const JSONCPP_STRING& text,
|
static std::string indentText(const std::string& text,
|
||||||
const JSONCPP_STRING& indent);
|
const std::string& indent);
|
||||||
|
|
||||||
typedef std::deque<Failure> Failures;
|
typedef std::deque<Failure> Failures;
|
||||||
Failures failures_;
|
Failures failures_;
|
||||||
JSONCPP_STRING name_;
|
std::string name_;
|
||||||
PredicateContext rootPredicateNode_;
|
PredicateContext rootPredicateNode_;
|
||||||
PredicateContext::Id lastUsedPredicateId_;
|
PredicateContext::Id lastUsedPredicateId_;
|
||||||
/// Failure which is the target of the messages added using operator <<
|
/// Failure which is the target of the messages added using operator <<
|
||||||
@@ -155,7 +155,7 @@ public:
|
|||||||
unsigned int testCount() const;
|
unsigned int testCount() const;
|
||||||
|
|
||||||
/// Returns the name of the test case at the specified index
|
/// 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
|
/// Runs the test case at the specified index using the specified TestResult
|
||||||
void runTestAt(unsigned int index, TestResult& result) const;
|
void runTestAt(unsigned int index, TestResult& result) const;
|
||||||
@@ -168,7 +168,7 @@ private: // prevents copy construction and assignment
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void listTests() const;
|
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();
|
static void preventDialogOnCrash();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -191,15 +191,9 @@ TestResult& checkEqual(TestResult& result,
|
|||||||
return 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,
|
TestResult& checkStringEqual(TestResult& result,
|
||||||
const JSONCPP_STRING& expected,
|
const std::string& expected,
|
||||||
const JSONCPP_STRING& actual,
|
const std::string& actual,
|
||||||
const char* file,
|
const char* file,
|
||||||
unsigned int line,
|
unsigned int line,
|
||||||
const char* expr);
|
const char* expr);
|
||||||
@@ -241,8 +235,8 @@ TestResult& checkStringEqual(TestResult& result,
|
|||||||
/// \brief Asserts that two values are equals.
|
/// \brief Asserts that two values are equals.
|
||||||
#define JSONTEST_ASSERT_STRING_EQUAL(expected, actual) \
|
#define JSONTEST_ASSERT_STRING_EQUAL(expected, actual) \
|
||||||
JsonTest::checkStringEqual(*result_, \
|
JsonTest::checkStringEqual(*result_, \
|
||||||
JsonTest::ToJsonString(expected), \
|
std::string(expected), \
|
||||||
JsonTest::ToJsonString(actual), \
|
std::string(actual), \
|
||||||
__FILE__, \
|
__FILE__, \
|
||||||
__LINE__, \
|
__LINE__, \
|
||||||
#expected " == " #actual)
|
#expected " == " #actual)
|
||||||
@@ -271,8 +265,8 @@ TestResult& checkStringEqual(TestResult& result,
|
|||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
public: /* overidden from TestCase */ \
|
public: /* overidden from TestCase */ \
|
||||||
const char* testName() const JSONCPP_OVERRIDE { return #FixtureType "/" #name; } \
|
virtual const char* testName() const { return #FixtureType "/" #name; } \
|
||||||
void runTestCase() JSONCPP_OVERRIDE; \
|
virtual void runTestCase(); \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
void Test##FixtureType##name::runTestCase()
|
void Test##FixtureType##name::runTestCase()
|
||||||
|
File diff suppressed because it is too large
Load Diff
10
src/test_lib_json/sconscript
Normal file
10
src/test_lib_json/sconscript
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
Import( 'env_testing buildUnitTests' )
|
||||||
|
|
||||||
|
buildUnitTests( env_testing, Split( """
|
||||||
|
main.cpp
|
||||||
|
jsontest.cpp
|
||||||
|
""" ),
|
||||||
|
'test_lib_json' )
|
||||||
|
|
||||||
|
# For 'check' to work, 'libs' must be built first.
|
||||||
|
env_testing.Depends('test_lib_json', '#libs')
|
@@ -1,10 +1,4 @@
|
|||||||
# Copyright 2007 Baptiste Lepilleur and The JsonCpp Authors
|
# removes all files created during testing
|
||||||
# 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."""
|
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
|
|
@@ -1,8 +1,3 @@
|
|||||||
# Copyright 2007 Baptiste Lepilleur and The JsonCpp Authors
|
|
||||||
# Distributed under MIT license, or public domain if desired and
|
|
||||||
# recognized in your jurisdiction.
|
|
||||||
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import glob
|
import glob
|
||||||
import os.path
|
import os.path
|
||||||
|
@@ -1,11 +1,4 @@
|
|||||||
# Copyright 2007 Baptiste Lepilleur and The JsonCpp Authors
|
# Simple implementation of a json test runner to run the test against json-py.
|
||||||
# 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."""
|
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import os.path
|
import os.path
|
||||||
|
@@ -1,8 +1,3 @@
|
|||||||
# Copyright 2007 Baptiste Lepilleur and The JsonCpp Authors
|
|
||||||
# Distributed under MIT license, or public domain if desired and
|
|
||||||
# recognized in your jurisdiction.
|
|
||||||
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from io import open
|
from io import open
|
||||||
|
@@ -1,8 +1,3 @@
|
|||||||
# Copyright 2009 Baptiste Lepilleur and The JsonCpp Authors
|
|
||||||
# Distributed under MIT license, or public domain if desired and
|
|
||||||
# recognized in your jurisdiction.
|
|
||||||
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from io import open
|
from io import open
|
||||||
|
23
travis.sh
23
travis.sh
@@ -1,23 +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
|
|
||||||
|
|
||||||
meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . build-${LIB_TYPE}
|
|
||||||
ninja -v -C build-${LIB_TYPE}
|
|
||||||
ninja -v -C build-${LIB_TYPE} test
|
|
||||||
rm -r build-${LIB_TYPE}
|
|
@@ -1 +0,0 @@
|
|||||||
@JSONCPP_VERSION@
|
|
Reference in New Issue
Block a user