mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-14 15:05:34 +02:00
Compare commits
244 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4cfae897c0 | ||
![]() |
f4ec601fd3 | ||
![]() |
d40f26d472 | ||
![]() |
c668af9d41 | ||
![]() |
13b5ed7287 | ||
![]() |
6d31cec7cf | ||
![]() |
5331d295aa | ||
![]() |
004270db37 | ||
![]() |
9006194139 | ||
![]() |
6062f9b848 | ||
![]() |
ef16a35328 | ||
![]() |
7354da8077 | ||
![]() |
6a15ca6442 | ||
![]() |
9a048e5766 | ||
![]() |
59e4d35339 | ||
![]() |
f26edb05e5 | ||
![]() |
cadb6dd9a6 | ||
![]() |
ea9f0cec30 | ||
![]() |
ffdcc9355d | ||
![]() |
f45c01a46e | ||
![]() |
3c2069fdd1 | ||
![]() |
414b179d86 | ||
![]() |
0ba8bd73f5 | ||
![]() |
23c44d9f9e | ||
![]() |
8996c377aa | ||
![]() |
a679dde58d | ||
![]() |
c21b4bbfdb | ||
![]() |
d14d8c35c3 | ||
![]() |
ed258de63d | ||
![]() |
154652ee7a | ||
![]() |
4a9d77bcf7 | ||
![]() |
56efb6ba83 | ||
![]() |
7f9cc2705c | ||
![]() |
d7347a2623 | ||
![]() |
2e319850d1 | ||
![]() |
a3d35d7fb8 | ||
![]() |
19fc55f408 | ||
![]() |
acf74290f1 | ||
![]() |
746ef154f1 | ||
![]() |
559b4416e6 | ||
![]() |
6ca374371e | ||
![]() |
f7df408a6a | ||
![]() |
86ed860c4b | ||
![]() |
c442fd96e6 | ||
![]() |
c68443f3a0 | ||
![]() |
11c48d0047 | ||
![]() |
264c3edca7 | ||
![]() |
a47fc398ef | ||
![]() |
2f178f390f | ||
![]() |
f251f15e6a | ||
![]() |
60bfcf1715 | ||
![]() |
81065748e3 | ||
![]() |
11836ae9aa | ||
![]() |
e25fb5384a | ||
![]() |
f700fe4559 | ||
![]() |
d167a09b1c | ||
![]() |
ba158fd22d | ||
![]() |
f3a4941590 | ||
![]() |
0d25d9aebf | ||
![]() |
5021e799dc | ||
![]() |
762ad0fe9d | ||
![]() |
d6e666f573 | ||
![]() |
2ecd2a59de | ||
![]() |
a691cb19de | ||
![]() |
ee7935986e | ||
![]() |
b4abc8241f | ||
![]() |
12e9ef32f9 | ||
![]() |
77632b2611 | ||
![]() |
89aa87bd24 | ||
![]() |
34fc0020c0 | ||
![]() |
f880a9432d | ||
![]() |
5a82131033 | ||
![]() |
1839f2da34 | ||
![]() |
91c1d23461 | ||
![]() |
86f085b810 | ||
![]() |
ac372d2b00 | ||
![]() |
0e24e3c64f | ||
![]() |
89ab7eca7f | ||
![]() |
a1db52b030 | ||
![]() |
1572539bec | ||
![]() |
d8cd848ede | ||
![]() |
92259f7147 | ||
![]() |
4a431bcdac | ||
![]() |
7d868636de | ||
![]() |
ab0f1e234a | ||
![]() |
45a560a8c0 | ||
![]() |
4893a8f667 | ||
![]() |
f6d785fda8 | ||
![]() |
8d54e333ff | ||
![]() |
b063cf4ada | ||
![]() |
c4ab6d733f | ||
![]() |
2f97c0147b | ||
![]() |
52cfe5ae88 | ||
![]() |
a304d61a7b | ||
![]() |
0a97e38ea5 | ||
![]() |
894e78bff1 | ||
![]() |
126bdc2b05 | ||
![]() |
094a7d8564 | ||
![]() |
b9afdf190d | ||
![]() |
80a82ea269 | ||
![]() |
f78f685bab | ||
![]() |
7d8eddb98c | ||
![]() |
7e0571b444 | ||
![]() |
b14c8c1423 | ||
![]() |
b299d3581f | ||
![]() |
48d2a69d47 | ||
![]() |
772e257fc9 | ||
![]() |
101fcf0806 | ||
![]() |
7e4df50d17 | ||
![]() |
318f30357c | ||
![]() |
0f288aecdd | ||
![]() |
e0f9aab0bf | ||
![]() |
43203f1d09 | ||
![]() |
55176b2bdd | ||
![]() |
4356d9bba1 | ||
![]() |
ea4af18317 | ||
![]() |
b999616df8 | ||
![]() |
660307d357 | ||
![]() |
911e2b0fea | ||
![]() |
d4a49cf511 | ||
![]() |
8bd4f943da | ||
![]() |
4018422a05 | ||
![]() |
ba6fa48d31 | ||
![]() |
17fc9b1a80 | ||
![]() |
6f22b0e076 | ||
![]() |
980cdf0fb5 | ||
![]() |
45da594e71 | ||
![]() |
c8a7b445ea | ||
![]() |
c8054483f8 | ||
![]() |
96d32b37ea | ||
![]() |
ef2ff8754a | ||
![]() |
b58c844579 | ||
![]() |
b803b92d11 | ||
![]() |
98e981dff9 | ||
![]() |
1c47796479 | ||
![]() |
12c67e810d | ||
![]() |
c018d9fc3a | ||
![]() |
ae564653c4 | ||
![]() |
f8674c63b1 | ||
![]() |
b50a124fa6 | ||
![]() |
59e327f50b | ||
![]() |
0b597b4b48 | ||
![]() |
d97ea5bf8d | ||
![]() |
e29b671ed5 | ||
![]() |
fbe1cf3916 | ||
![]() |
cf86c473a5 | ||
![]() |
75570d7068 | ||
![]() |
5da29e2707 | ||
![]() |
c80faa400c | ||
![]() |
8aabf93cc1 | ||
![]() |
3e51598176 | ||
![]() |
1b5e61d008 | ||
![]() |
b84e0c159d | ||
![]() |
1e990640a9 | ||
![]() |
38bb491400 | ||
![]() |
724ba29bd3 | ||
![]() |
de5b792168 | ||
![]() |
1b8e3b7f4d | ||
![]() |
4878913143 | ||
![]() |
d179e24c14 | ||
![]() |
ccd70540e3 | ||
![]() |
b4d2b65841 | ||
![]() |
7e46bf76e8 | ||
![]() |
da0c50f7b2 | ||
![]() |
02bc3d77de | ||
![]() |
6b562c850d | ||
![]() |
2713f4f456 | ||
![]() |
83bc9c7cf6 | ||
![]() |
95f120f68e | ||
![]() |
9a4b1e39bf | ||
![]() |
2c872ec997 | ||
![]() |
b860cc38e8 | ||
![]() |
fef4b75796 | ||
![]() |
779d8a33fc | ||
![]() |
d4513fcf45 | ||
![]() |
baefec773c | ||
![]() |
bc72070f43 | ||
![]() |
bc9b445fee | ||
![]() |
2646ac5fa5 | ||
![]() |
2cca1cd239 | ||
![]() |
9234cbbc90 | ||
![]() |
7c93031c9b | ||
![]() |
48bfe91062 | ||
![]() |
0cce773019 | ||
![]() |
6b10ce8c0d | ||
![]() |
34bdbb58b4 | ||
![]() |
527965cbde | ||
![]() |
2b00891a86 | ||
![]() |
a4ce2829dc | ||
![]() |
69e7f1c858 | ||
![]() |
d1a2b94d5b | ||
![]() |
772f634548 | ||
![]() |
9fd1ca8d68 | ||
![]() |
38022157b2 | ||
![]() |
039a6e3b61 | ||
![]() |
9c17e61bd0 | ||
![]() |
c8a8cfcd4b | ||
![]() |
4994c77d09 | ||
![]() |
beae99924f | ||
![]() |
8b9940fd24 | ||
![]() |
b96d90efbd | ||
![]() |
e375b8c89e | ||
![]() |
49393ead06 | ||
![]() |
8df11d518b | ||
![]() |
8e400e9be7 | ||
![]() |
dc5aa4ad7f | ||
![]() |
80def66fa5 | ||
![]() |
6992831c1c | ||
![]() |
7e4875a239 | ||
![]() |
979cbec237 | ||
![]() |
2e625dd9af | ||
![]() |
83ea25e5e2 | ||
![]() |
5721f1ca57 | ||
![]() |
9942f6a1c7 | ||
![]() |
6c14548293 | ||
![]() |
6ee0bff822 | ||
![]() |
e3b35992f8 | ||
![]() |
cc5cdb565c | ||
![]() |
aadd0b1b63 | ||
![]() |
3ee15b7bcc | ||
![]() |
68509e6161 | ||
![]() |
4cea1f6f6c | ||
![]() |
6f9ed421d0 | ||
![]() |
7f7bbeff76 | ||
![]() |
bfffe8cec7 | ||
![]() |
73154fb546 | ||
![]() |
63c747218b | ||
![]() |
2084563efb | ||
![]() |
6329975e6d | ||
![]() |
7acfd599f0 | ||
![]() |
63a961a752 | ||
![]() |
cb2378fa41 | ||
![]() |
37aaaec70e | ||
![]() |
585446e6b3 | ||
![]() |
7f4be39e9f | ||
![]() |
47595e922b | ||
![]() |
9f7dbcb19b | ||
![]() |
c1996256d6 | ||
![]() |
25e4adc4e1 | ||
![]() |
cc2c15c3eb | ||
![]() |
912d55094d | ||
![]() |
d7b84f69c5 | ||
![]() |
9dad198af6 | ||
![]() |
7f06e9dc28 |
27
.gitignore
vendored
27
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
/build/
|
||||
/build-*/
|
||||
*.pyc
|
||||
*.swp
|
||||
*.actual
|
||||
@@ -6,7 +7,6 @@
|
||||
*.process-output
|
||||
*.rewrite
|
||||
/bin/
|
||||
/buildscons/
|
||||
/libs/
|
||||
/doc/doxyfile
|
||||
/dist/
|
||||
@@ -30,7 +30,26 @@
|
||||
|
||||
# CMake-generated files:
|
||||
CMakeFiles/
|
||||
CTestTestFile.cmake
|
||||
cmake_install.cmake
|
||||
pkg-config/jsoncpp.pc
|
||||
*.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
|
||||
|
33
.travis.yml
33
.travis.yml
@@ -7,24 +7,36 @@
|
||||
# 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.8" CC="gcc-4.8"; fi
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.6" CC="gcc-4.6"; fi
|
||||
# /usr/bin/clang is our version already, and clang-X.Y does not exist.
|
||||
#- if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.0" CC="clang-3.0"; fi
|
||||
- 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
|
||||
- export PATH=/usr/bin:${PATH}
|
||||
- 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.6
|
||||
- g++-4.6
|
||||
- clang
|
||||
- gcc-4.9
|
||||
- g++-4.9
|
||||
- clang-3.5
|
||||
- valgrind
|
||||
os:
|
||||
- linux
|
||||
@@ -35,8 +47,9 @@ compiler:
|
||||
script: ./travis.sh
|
||||
env:
|
||||
matrix:
|
||||
- SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false
|
||||
- SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE_MAKE=true VERBOSE
|
||||
- LIB_TYPE=static BUILD_TYPE=release
|
||||
- LIB_TYPE=shared BUILD_TYPE=debug
|
||||
notifications:
|
||||
email: false
|
||||
dist: trusty
|
||||
sudo: false
|
||||
|
110
AUTHORS
110
AUTHORS
@@ -1 +1,111 @@
|
||||
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.
|
||||
|
111
CMakeLists.txt
111
CMakeLists.txt
@@ -1,19 +1,18 @@
|
||||
# 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)
|
||||
ENABLE_TESTING()
|
||||
|
||||
OPTION(JSONCPP_WITH_TESTS "Compile and (for jsoncpp_check) run JsonCpp test executables" ON)
|
||||
OPTION(JSONCPP_WITH_POST_BUILD_UNITTEST "Automatically run unit-tests as a post build step" ON)
|
||||
OPTION(JSONCPP_WITH_WARNING_AS_ERROR "Force compilation to fail if a warning occurs" OFF)
|
||||
OPTION(JSONCPP_WITH_STRICT_ISO "Issue all the warnings demanded by strict ISO C and ISO C++" ON)
|
||||
OPTION(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON)
|
||||
OPTION(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" OFF)
|
||||
OPTION(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." OFF)
|
||||
OPTION(BUILD_STATIC_LIBS "Build jsoncpp_lib static library." ON)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Ensures that CMAKE_BUILD_TYPE is visible in cmake-gui on Unix
|
||||
IF(NOT WIN32)
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
@@ -23,20 +22,15 @@ IF(NOT WIN32)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
SET(DEBUG_LIBNAME_SUFFIX "" CACHE STRING "Optional suffix to append to the library name for a debug build")
|
||||
SET(LIB_SUFFIX "" CACHE STRING "Optional arch-dependent suffix for the library installation directory")
|
||||
# Enable runtime search path support for dynamic libraries on OSX
|
||||
IF(APPLE)
|
||||
SET(CMAKE_MACOSX_RPATH 1)
|
||||
ENDIF()
|
||||
|
||||
SET(RUNTIME_INSTALL_DIR bin
|
||||
CACHE PATH "Install dir for executables and dlls")
|
||||
SET(ARCHIVE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
|
||||
CACHE PATH "Install dir for static libraries")
|
||||
SET(LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
|
||||
CACHE PATH "Install dir for shared libraries")
|
||||
SET(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/jsoncpp
|
||||
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 )
|
||||
# Adhere to GNU filesystem layout conventions
|
||||
INCLUDE(GNUInstallDirs)
|
||||
|
||||
SET(DEBUG_LIBNAME_SUFFIX "" CACHE STRING "Optional suffix to append to the library name for a debug build")
|
||||
|
||||
# Set variable named ${VAR_NAME} to value ${VALUE}
|
||||
FUNCTION(set_using_dynamic_name VAR_NAME VALUE)
|
||||
@@ -65,11 +59,13 @@ ENDMACRO()
|
||||
#SET( JSONCPP_VERSION_MAJOR X )
|
||||
#SET( JSONCPP_VERSION_MINOR Y )
|
||||
#SET( JSONCPP_VERSION_PATCH Z )
|
||||
SET( JSONCPP_VERSION 0.10.7 )
|
||||
SET( JSONCPP_VERSION 1.8.2 )
|
||||
jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION )
|
||||
#IF(NOT JSONCPP_VERSION_FOUND)
|
||||
# MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
|
||||
#ENDIF(NOT JSONCPP_VERSION_FOUND)
|
||||
SET( JSONCPP_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}")
|
||||
# File version.h is only regenerated on CMake configure step
|
||||
@@ -80,50 +76,79 @@ CONFIGURE_FILE( "${PROJECT_SOURCE_DIR}/version.in"
|
||||
"${PROJECT_SOURCE_DIR}/version"
|
||||
NEWLINE_STYLE UNIX )
|
||||
|
||||
macro(UseCompilationWarningAsError)
|
||||
if ( MSVC )
|
||||
# Only enabled in debug because some old versions of VS STL generate
|
||||
# warnings when compiled in release configuration.
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_XX_COMPILER_ID MATCHES "Clang" )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||
endif()
|
||||
endmacro()
|
||||
MACRO(UseCompilationWarningAsError)
|
||||
IF(MSVC)
|
||||
# Only enabled in debug because some old versions of VS STL generate
|
||||
# warnings when compiled in release configuration.
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /WX ")
|
||||
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||
IF(JSONCPP_WITH_STRICT_ISO)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
# Include our configuration header
|
||||
INCLUDE_DIRECTORIES( ${jsoncpp_SOURCE_DIR}/include )
|
||||
|
||||
if ( MSVC )
|
||||
IF(MSVC)
|
||||
# Only enabled in debug because some old versions of VS STL generate
|
||||
# unreachable code warning when compiled in release configuration.
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ")
|
||||
endif()
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ")
|
||||
ENDIF()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# using regular Clang or AppleClang
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wshadow -Wshorten-64-to-32")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
# using GCC
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wshadow -Wextra -pedantic -Wno-long-long")
|
||||
# not yet ready for -Wsign-conversion
|
||||
endif()
|
||||
# Require C++11 support, prefer ISO C++ over GNU variants,
|
||||
# as relying solely on ISO C++ is more portable.
|
||||
SET(CMAKE_CXX_STANDARD 11)
|
||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
SET(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# 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)
|
||||
UseCompilationWarningAsError()
|
||||
ENDIF()
|
||||
|
||||
IF(JSONCPP_WITH_PKGCONFIG_SUPPORT)
|
||||
CONFIGURE_FILE(
|
||||
"pkg-config/jsoncpp.pc.in"
|
||||
"pkg-config/jsoncpp.pc"
|
||||
@ONLY)
|
||||
INSTALL(FILES "${CMAKE_BINARY_DIR}/pkg-config/jsoncpp.pc"
|
||||
CONFIGURE_FILE(
|
||||
"pkg-config/jsoncpp.pc.in"
|
||||
"pkg-config/jsoncpp.pc"
|
||||
@ONLY)
|
||||
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/pkg-config/jsoncpp.pc"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
ENDIF()
|
||||
|
||||
IF(JSONCPP_WITH_CMAKE_PACKAGE)
|
||||
INSTALL(EXPORT jsoncpp
|
||||
DESTINATION ${PACKAGE_INSTALL_DIR}/jsoncpp
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp
|
||||
FILE jsoncppConfig.cmake)
|
||||
ENDIF()
|
||||
|
||||
|
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
|
||||
conditions...
|
||||
|
||||
The author (Baptiste Lepilleur) explicitly disclaims copyright in all
|
||||
Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all
|
||||
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||
this software is released into the Public Domain.
|
||||
|
||||
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 is
|
||||
released under the terms of the MIT License (see below).
|
||||
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
|
||||
The JsonCpp Authors, and is released under the terms of the MIT License (see below).
|
||||
|
||||
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
|
||||
@@ -23,7 +23,7 @@ described in clear, concise terms at:
|
||||
The full text of the MIT License follows:
|
||||
|
||||
========================================================================
|
||||
Copyright (c) 2007-2010 Baptiste Lepilleur
|
||||
Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
|
175
NEWS.txt
175
NEWS.txt
@@ -1,175 +0,0 @@
|
||||
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.
|
185
README.md
185
README.md
@@ -1,5 +1,6 @@
|
||||
Introduction
|
||||
------------
|
||||
# JsonCpp
|
||||
|
||||
[](http://www.conan.io/source/jsoncpp/1.8.0/theirix/ci)
|
||||
|
||||
[JSON][json-org] is a lightweight data-interchange format. It can represent
|
||||
numbers, strings, ordered sequences of values, and collections of name/value
|
||||
@@ -7,133 +8,48 @@ pairs.
|
||||
|
||||
[json-org]: http://json.org/
|
||||
|
||||
[JsonCpp][] is a C++ library that allows manipulating JSON values, including
|
||||
JsonCpp is a C++ library that allows manipulating JSON values, including
|
||||
serialization and deserialization to and from strings. It can also preserve
|
||||
existing comment in unserialization/serialization steps, making it a convenient
|
||||
format to store user input files.
|
||||
|
||||
[JsonCpp]: http://open-source-parsers.github.io/jsoncpp-docs/doxygen/index.html
|
||||
|
||||
## 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
|
||||
|
||||
* `1.y.z` is built with C++11.
|
||||
* `0.y.z` can be used with older compilers.
|
||||
* Major versions maintain binary-compatibility.
|
||||
|
||||
# Using JsonCpp in your project
|
||||
-----------------------------
|
||||
The recommended approach to integrating JsonCpp in your project is to include
|
||||
the [amalgamated source](#generating-amalgamated-source-and-header) (a single
|
||||
`.cpp` file and two `.h` files) in your project, and compile and build as you
|
||||
would any other source file. This ensures consistency of compilation flags and
|
||||
ABI compatibility, issues which arise when building shared or static
|
||||
libraries. See the next section for instructions.
|
||||
|
||||
The `include/` should be added to your compiler include path. Jsoncpp headers
|
||||
should be included as follow:
|
||||
## Contributing to JsonCpp
|
||||
|
||||
#include <json/json.h>
|
||||
### Building and testing with Meson/Ninja
|
||||
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.
|
||||
|
||||
If JsonCpp was built as a dynamic library on Windows, then your project needs to
|
||||
define the macro `JSON_DLL`.
|
||||
First, install both meson (which requires Python3) and ninja.
|
||||
|
||||
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):
|
||||
Then,
|
||||
|
||||
python amalgamate.py
|
||||
cd jsoncpp/
|
||||
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
|
||||
|
||||
It is possible to specify header name. See the `-h` option for detail.
|
||||
### Building and testing with other build systems
|
||||
See https://github.com/open-source-parsers/jsoncpp/wiki/Building
|
||||
|
||||
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.
|
||||
### Running the tests manually
|
||||
|
||||
The amalgamated sources are generated by concatenating JsonCpp source in the
|
||||
correct order and defining the macro `JSON_IS_AMALGAMATION` to prevent inclusion
|
||||
of other headers.
|
||||
|
||||
# Contributing to JsonCpp
|
||||
|
||||
Building and testing with CMake
|
||||
-------------------------------
|
||||
[CMake][] is a C++ Makefiles/Solution generator. It is usually available on most
|
||||
Linux system as package. On Ubuntu:
|
||||
|
||||
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 `BUILD_SHARED_LIBS` 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 -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles" ../..
|
||||
make
|
||||
|
||||
Running `cmake -h` 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
|
||||
You need to run tests manually only if you are troubleshooting an issue.
|
||||
|
||||
In the instructions below, replace `path/to/jsontest` with the path of the
|
||||
@@ -142,35 +58,30 @@ In the instructions below, replace `path/to/jsontest` with the path of the
|
||||
cd test
|
||||
# This will run the Reader/Writer tests
|
||||
python runjsontests.py path/to/jsontest
|
||||
|
||||
|
||||
# This will run the Reader/Writer tests, using JSONChecker test suite
|
||||
# (http://www.json.org/JSON_checker/).
|
||||
# Notes: not all tests pass: JsonCpp is too lenient (for example,
|
||||
# it allows an integer to start with '0'). The goal is to improve
|
||||
# strict mode parsing to get all tests to pass.
|
||||
python runjsontests.py --with-json-checker path/to/jsontest
|
||||
|
||||
|
||||
# This will run the unit tests (mostly Value)
|
||||
python rununittests.py path/to/test_lib_json
|
||||
|
||||
|
||||
# You can run the tests using valgrind:
|
||||
python rununittests.py --valgrind path/to/test_lib_json
|
||||
|
||||
## Running the tests using scons
|
||||
Note that tests can be run using SCons using the `check` target:
|
||||
### Building the documentation
|
||||
|
||||
scons platform=$PLATFORM check
|
||||
|
||||
Building the documentation
|
||||
--------------------------
|
||||
Run the Python script `doxybuild.py` from the top directory:
|
||||
|
||||
python doxybuild.py --doxygen=$(which doxygen) --open --with-dot
|
||||
|
||||
See `doxybuild.py --help` for options.
|
||||
|
||||
Adding a reader/writer test
|
||||
---------------------------
|
||||
### Adding a reader/writer test
|
||||
|
||||
To add a test, you need to create two files in test/data:
|
||||
|
||||
* a `TESTNAME.json` file, that contains the input document in JSON format.
|
||||
@@ -179,21 +90,19 @@ To add a test, you need to create two files in test/data:
|
||||
|
||||
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.
|
||||
* 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.
|
||||
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`.
|
||||
|
||||
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.expected`: flattened JSON element tree used to check if
|
||||
@@ -208,7 +117,15 @@ Below is a short description of the content of each file:
|
||||
* `test_complex_01.process-output`: `jsontest` output, typically useful for
|
||||
understanding parsing errors.
|
||||
|
||||
License
|
||||
-------
|
||||
## Using JsonCpp in your project
|
||||
|
||||
### Amalgamated source
|
||||
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
|
||||
MIT license, or public domain if desired and recognized in your jurisdiction.
|
||||
|
248
SConstruct
248
SConstruct
@@ -1,248 +0,0 @@
|
||||
"""
|
||||
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()
|
||||
|
@@ -67,6 +67,7 @@ def amalgamate_source(source_top_dir=None,
|
||||
header.add_text("/// to prevent private header inclusion.")
|
||||
header.add_text("#define JSON_IS_AMALGAMATION")
|
||||
header.add_file("include/json/version.h")
|
||||
#header.add_file("include/json/allocator.h") # Not available here.
|
||||
header.add_file("include/json/config.h")
|
||||
header.add_file("include/json/forwards.h")
|
||||
header.add_file("include/json/features.h")
|
||||
|
35
appveyor.yml
35
appveyor.yml
@@ -1,30 +1,17 @@
|
||||
# This is a comment.
|
||||
|
||||
version: build.{build}
|
||||
|
||||
os: Windows Server 2012 R2
|
||||
|
||||
clone_folder: c:\projects\jsoncpp
|
||||
|
||||
platform:
|
||||
- Win32
|
||||
- x64
|
||||
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
|
||||
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
|
||||
# scripts to run before build
|
||||
before_build:
|
||||
- echo "Running cmake..."
|
||||
- cd c:\projects\jsoncpp
|
||||
- cmake --version
|
||||
- set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
|
||||
- if %PLATFORM% == Win32 cmake .
|
||||
- if %PLATFORM% == x64 cmake -G "Visual Studio 12 2013 Win64" .
|
||||
|
||||
build:
|
||||
project: jsoncpp.sln # path to Visual Studio solution or project
|
||||
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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright 2010 Baptiste Lepilleur
|
||||
# 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Copyright 2009 Baptiste Lepilleur
|
||||
# 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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright 2010 Baptiste Lepilleur
|
||||
# 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
|
||||
|
@@ -6,7 +6,7 @@ from __future__ import print_function
|
||||
# and ends with the first blank line.
|
||||
LICENSE_BEGIN = "// Copyright "
|
||||
|
||||
BRIEF_LICENSE = LICENSE_BEGIN + """2007-2010 Baptiste Lepilleur
|
||||
BRIEF_LICENSE = LICENSE_BEGIN + """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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright 2010 Baptiste Lepilleur
|
||||
# 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
|
||||
|
@@ -1,2 +1,2 @@
|
||||
FILE(GLOB INCLUDE_FILES "json/*.h")
|
||||
INSTALL(FILES ${INCLUDE_FILES} DESTINATION ${INCLUDE_INSTALL_DIR}/json)
|
||||
INSTALL(FILES ${INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json)
|
||||
|
98
include/json/allocator.h
Normal file
98
include/json/allocator.h
Normal file
@@ -0,0 +1,98 @@
|
||||
// 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
|
||||
// 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
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
# define JSON_FAIL_MESSAGE(message) \
|
||||
{ \
|
||||
std::ostringstream oss; oss << message; \
|
||||
JSONCPP_OSTRINGSTREAM oss; oss << message; \
|
||||
Json::throwLogicError(oss.str()); \
|
||||
abort(); \
|
||||
}
|
||||
@@ -38,7 +38,7 @@
|
||||
// release builds we abort, for a core-dump or debugger.
|
||||
# define JSON_FAIL_MESSAGE(message) \
|
||||
{ \
|
||||
std::ostringstream oss; oss << message; \
|
||||
JSONCPP_OSTRINGSTREAM oss; oss << message; \
|
||||
assert(false && oss.str().c_str()); \
|
||||
abort(); \
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
|
@@ -1,10 +1,13 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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 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.
|
||||
//# define JSON_IN_CPPTL 1
|
||||
@@ -37,12 +40,12 @@
|
||||
#ifdef JSON_IN_CPPTL
|
||||
#define JSON_API CPPTL_API
|
||||
#elif defined(JSON_DLL_BUILD)
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define JSON_API __declspec(dllexport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#endif // if defined(_MSC_VER)
|
||||
#elif defined(JSON_DLL)
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define JSON_API __declspec(dllimport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#endif // if defined(_MSC_VER)
|
||||
@@ -51,49 +54,101 @@
|
||||
#define JSON_API
|
||||
#endif
|
||||
|
||||
#if !defined(JSON_HAS_UNIQUE_PTR)
|
||||
#if __cplusplus >= 201103L
|
||||
#define JSON_HAS_UNIQUE_PTR (1)
|
||||
#elif _MSC_VER >= 1600
|
||||
#define JSON_HAS_UNIQUE_PTR (1)
|
||||
#else
|
||||
#define JSON_HAS_UNIQUE_PTR (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
|
||||
// integer
|
||||
// Storages, and 64 bits integer support is disabled.
|
||||
// #define JSON_NO_INT64 1
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
|
||||
// Microsoft Visual Studio 6 only support conversion from __int64 to double
|
||||
// (no conversion from unsigned __int64).
|
||||
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
|
||||
// characters in the debug information)
|
||||
// All projects I've ever seen with VS6 were using this globally (not bothering
|
||||
// with pragma push/pop).
|
||||
#pragma warning(disable : 4786)
|
||||
#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
|
||||
#if defined(_MSC_VER) // MSVC
|
||||
# if _MSC_VER <= 1200 // MSVC 6
|
||||
// Microsoft Visual Studio 6 only support conversion from __int64 to double
|
||||
// (no conversion from unsigned __int64).
|
||||
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
|
||||
// characters in the debug information)
|
||||
// All projects I've ever seen with VS6 were using this globally (not bothering
|
||||
// with pragma push/pop).
|
||||
# pragma warning(disable : 4786)
|
||||
# endif // MSVC 6
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
|
||||
/// Indicates that the following function is deprecated.
|
||||
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
||||
#elif defined(__clang__) && defined(__has_feature)
|
||||
#if __has_feature(attribute_deprecated_with_message)
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
||||
# if _MSC_VER >= 1500 // MSVC 2008
|
||||
/// Indicates that the following function is deprecated.
|
||||
# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
||||
# endif
|
||||
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
// In c++11 the override keyword allows you to explicity define that a function
|
||||
// is intended to override the base-class version. This makes the code more
|
||||
// managable and fixes a set of common hard-to-find bugs.
|
||||
#if __cplusplus >= 201103L
|
||||
# define JSONCPP_OVERRIDE override
|
||||
# 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
|
||||
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
||||
#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
|
||||
|
||||
#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)
|
||||
#define JSONCPP_DEPRECATED(message)
|
||||
#endif // if !defined(JSONCPP_DEPRECATED)
|
||||
|
||||
#if __GNUC__ >= 6
|
||||
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
#endif
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
# include "version.h"
|
||||
|
||||
# if JSONCPP_USING_SECURE_MEMORY
|
||||
# include "allocator.h" //typedef Allocator
|
||||
# endif
|
||||
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
typedef int Int;
|
||||
typedef unsigned int UInt;
|
||||
@@ -107,13 +162,26 @@ typedef unsigned int LargestUInt;
|
||||
typedef __int64 Int64;
|
||||
typedef unsigned __int64 UInt64;
|
||||
#else // if defined(_MSC_VER) // Other platforms, use long long
|
||||
typedef long long int Int64;
|
||||
typedef unsigned long long int UInt64;
|
||||
typedef int64_t Int64;
|
||||
typedef uint64_t UInt64;
|
||||
#endif // if defined(_MSC_VER)
|
||||
typedef Int64 LargestInt;
|
||||
typedef UInt64 LargestUInt;
|
||||
#define JSON_HAS_INT64
|
||||
#endif // if defined(JSON_NO_INT64)
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
#define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
|
||||
#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
|
||||
#define JSONCPP_ISTREAM std::istream
|
||||
#else
|
||||
#define JSONCPP_STRING std::string
|
||||
#define JSONCPP_OSTRINGSTREAM std::ostringstream
|
||||
#define JSONCPP_OSTREAM std::ostream
|
||||
#define JSONCPP_ISTRINGSTREAM std::istringstream
|
||||
#define JSONCPP_ISTREAM std::istream
|
||||
#endif // if JSONCPP_USING_SECURE_MEMORY
|
||||
} // end namespace Json
|
||||
|
||||
#endif // JSON_CONFIG_H_INCLUDED
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "forwards.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
#pragma pack(push, 8)
|
||||
|
||||
namespace Json {
|
||||
|
||||
/** \brief Configuration passed to reader and writer.
|
||||
@@ -44,8 +46,16 @@ public:
|
||||
/// \c true if root must be either an array or an object value. Default: \c
|
||||
/// false.
|
||||
bool strictRoot_;
|
||||
|
||||
/// \c true if dropped null placeholders are allowed. Default: \c false.
|
||||
bool allowDroppedNullPlaceholders_;
|
||||
|
||||
/// \c true if numeric object key are allowed. Default: \c false.
|
||||
bool allowNumericKeys_;
|
||||
};
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // CPPTL_JSON_FEATURES_H_INCLUDED
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
@@ -23,6 +23,8 @@
|
||||
#pragma warning(disable : 4251)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#pragma pack(push, 8)
|
||||
|
||||
namespace Json {
|
||||
|
||||
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
|
||||
@@ -30,11 +32,23 @@ namespace Json {
|
||||
*
|
||||
* \deprecated Use CharReader and CharReaderBuilder.
|
||||
*/
|
||||
class JSON_API Reader {
|
||||
class JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead") JSON_API Reader {
|
||||
public:
|
||||
typedef char Char;
|
||||
typedef const Char* Location;
|
||||
|
||||
/** \brief An error tagged with where in the JSON text it was encountered.
|
||||
*
|
||||
* The offsets give the [start, limit) range of bytes within the text. Note
|
||||
* that this is bytes, not codepoints.
|
||||
*
|
||||
*/
|
||||
struct StructuredError {
|
||||
ptrdiff_t offset_start;
|
||||
ptrdiff_t offset_limit;
|
||||
JSONCPP_STRING message;
|
||||
};
|
||||
|
||||
/** \brief Constructs a Reader allowing all features
|
||||
* for parsing.
|
||||
*/
|
||||
@@ -87,7 +101,7 @@ public:
|
||||
|
||||
/// \brief Parse from input stream.
|
||||
/// \see Json::operator>>(std::istream&, Json::Value&).
|
||||
bool parse(std::istream& is, Value& root, bool collectComments = true);
|
||||
bool parse(JSONCPP_ISTREAM& is, Value& root, bool collectComments = true);
|
||||
|
||||
/** \brief Returns a user friendly string that list errors in the parsed
|
||||
* document.
|
||||
@@ -99,7 +113,7 @@ public:
|
||||
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
|
||||
*/
|
||||
JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
|
||||
std::string getFormatedErrorMessages() const;
|
||||
JSONCPP_STRING getFormatedErrorMessages() const;
|
||||
|
||||
/** \brief Returns a user friendly string that list errors in the parsed
|
||||
* document.
|
||||
@@ -109,7 +123,39 @@ public:
|
||||
* occurred
|
||||
* during parsing.
|
||||
*/
|
||||
std::string getFormattedErrorMessages() const;
|
||||
JSONCPP_STRING getFormattedErrorMessages() const;
|
||||
|
||||
/** \brief Returns a vector of structured erros encounted while parsing.
|
||||
* \return A (possibly empty) vector of StructuredError objects. Currently
|
||||
* only one error can be returned, but the caller should tolerate
|
||||
* multiple
|
||||
* errors. This can occur if the parser recovers from a non-fatal
|
||||
* parse error and then encounters additional errors.
|
||||
*/
|
||||
std::vector<StructuredError> getStructuredErrors() const;
|
||||
|
||||
/** \brief Add a semantic error message.
|
||||
* \param value JSON Value location associated with the error
|
||||
* \param message The error message.
|
||||
* \return \c true if the error was successfully added, \c false if the
|
||||
* Value offset exceeds the document size.
|
||||
*/
|
||||
bool pushError(const Value& value, const JSONCPP_STRING& message);
|
||||
|
||||
/** \brief Add a semantic error message with extra context.
|
||||
* \param value JSON Value location associated with the error
|
||||
* \param message The error message.
|
||||
* \param extra Additional JSON Value location to contextualize the error
|
||||
* \return \c true if the error was successfully added, \c false if either
|
||||
* Value offset exceeds the document size.
|
||||
*/
|
||||
bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra);
|
||||
|
||||
/** \brief Return whether there are any errors.
|
||||
* \return \c true if there are no errors to report \c false if
|
||||
* errors have occurred.
|
||||
*/
|
||||
bool good() const;
|
||||
|
||||
private:
|
||||
enum TokenType {
|
||||
@@ -139,7 +185,7 @@ private:
|
||||
class ErrorInfo {
|
||||
public:
|
||||
Token token_;
|
||||
std::string message_;
|
||||
JSONCPP_STRING message_;
|
||||
Location extra_;
|
||||
};
|
||||
|
||||
@@ -159,7 +205,7 @@ private:
|
||||
bool decodeNumber(Token& token);
|
||||
bool decodeNumber(Token& token, Value& decoded);
|
||||
bool decodeString(Token& token);
|
||||
bool decodeString(Token& token, std::string& decoded);
|
||||
bool decodeString(Token& token, JSONCPP_STRING& decoded);
|
||||
bool decodeDouble(Token& token);
|
||||
bool decodeDouble(Token& token, Value& decoded);
|
||||
bool decodeUnicodeCodePoint(Token& token,
|
||||
@@ -170,9 +216,9 @@ private:
|
||||
Location& current,
|
||||
Location end,
|
||||
unsigned int& unicode);
|
||||
bool addError(const std::string& message, Token& token, Location extra = 0);
|
||||
bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0);
|
||||
bool recoverFromError(TokenType skipUntilToken);
|
||||
bool addErrorAndRecover(const std::string& message,
|
||||
bool addErrorAndRecover(const JSONCPP_STRING& message,
|
||||
Token& token,
|
||||
TokenType skipUntilToken);
|
||||
void skipUntilSpace();
|
||||
@@ -180,20 +226,23 @@ private:
|
||||
Char getNextChar();
|
||||
void
|
||||
getLocationLineAndColumn(Location location, int& line, int& column) const;
|
||||
std::string getLocationLineAndColumn(Location location) const;
|
||||
JSONCPP_STRING getLocationLineAndColumn(Location location) const;
|
||||
void addComment(Location begin, Location end, CommentPlacement placement);
|
||||
void skipCommentTokens(Token& token);
|
||||
|
||||
static bool containsNewLine(Location begin, Location end);
|
||||
static JSONCPP_STRING normalizeEOL(Location begin, Location end);
|
||||
|
||||
typedef std::stack<Value*> Nodes;
|
||||
Nodes nodes_;
|
||||
Errors errors_;
|
||||
std::string document_;
|
||||
JSONCPP_STRING document_;
|
||||
Location begin_;
|
||||
Location end_;
|
||||
Location current_;
|
||||
Location lastValueEnd_;
|
||||
Value* lastValue_;
|
||||
std::string commentsBefore_;
|
||||
JSONCPP_STRING commentsBefore_;
|
||||
Features features_;
|
||||
bool collectComments_;
|
||||
}; // Reader
|
||||
@@ -222,9 +271,9 @@ public:
|
||||
*/
|
||||
virtual bool parse(
|
||||
char const* beginDoc, char const* endDoc,
|
||||
Value* root, std::string* errs) = 0;
|
||||
Value* root, JSONCPP_STRING* errs) = 0;
|
||||
|
||||
class Factory {
|
||||
class JSON_API Factory {
|
||||
public:
|
||||
virtual ~Factory() {}
|
||||
/** \brief Allocate a CharReader via operator new().
|
||||
@@ -242,7 +291,7 @@ Usage:
|
||||
CharReaderBuilder builder;
|
||||
builder["collectComments"] = false;
|
||||
Value value;
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
bool ok = parseFromStream(builder, std::cin, &value, &errs);
|
||||
\endcode
|
||||
*/
|
||||
@@ -289,9 +338,9 @@ public:
|
||||
Json::Value settings_;
|
||||
|
||||
CharReaderBuilder();
|
||||
virtual ~CharReaderBuilder();
|
||||
~CharReaderBuilder() JSONCPP_OVERRIDE;
|
||||
|
||||
virtual CharReader* newCharReader() const;
|
||||
CharReader* newCharReader() const JSONCPP_OVERRIDE;
|
||||
|
||||
/** \return true if 'settings' are legal and consistent;
|
||||
* otherwise, indicate bad settings via 'invalid'.
|
||||
@@ -300,7 +349,7 @@ public:
|
||||
|
||||
/** A simple way to update a specific setting.
|
||||
*/
|
||||
Value& operator[](std::string key);
|
||||
Value& operator[](JSONCPP_STRING key);
|
||||
|
||||
/** Called by ctor, but you can use this to reset settings_.
|
||||
* \pre 'settings' != NULL (but Json::null is fine)
|
||||
@@ -322,7 +371,7 @@ public:
|
||||
*/
|
||||
bool JSON_API parseFromStream(
|
||||
CharReader::Factory const&,
|
||||
std::istream&,
|
||||
JSONCPP_ISTREAM&,
|
||||
Value* root, std::string* errs);
|
||||
|
||||
/** \brief Read from 'sin' into 'root'.
|
||||
@@ -349,10 +398,12 @@ bool JSON_API parseFromStream(
|
||||
\throw std::exception on parse error.
|
||||
\see Json::operator<<()
|
||||
*/
|
||||
JSON_API std::istream& operator>>(std::istream&, Value&);
|
||||
JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(pop)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
@@ -22,15 +22,8 @@
|
||||
#include <cpptl/forwards.h>
|
||||
#endif
|
||||
|
||||
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
||||
// be used by...
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4251)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
//Conditional NORETURN attribute on the throw functions would:
|
||||
// a) suppress false positives from static code analysis
|
||||
// a) suppress false positives from static code analysis
|
||||
// b) possibly improve optimization opportunities.
|
||||
#if !defined(JSONCPP_NORETURN)
|
||||
# if defined(_MSC_VER)
|
||||
@@ -42,6 +35,15 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
||||
// be used by...
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4251)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#pragma pack(push, 8)
|
||||
|
||||
/** \brief JSON (JavaScript Object Notation).
|
||||
*/
|
||||
namespace Json {
|
||||
@@ -52,39 +54,39 @@ namespace Json {
|
||||
*/
|
||||
class JSON_API Exception : public std::exception {
|
||||
public:
|
||||
Exception(std::string const& msg);
|
||||
virtual ~Exception() throw();
|
||||
virtual char const* what() const throw();
|
||||
Exception(JSONCPP_STRING const& msg);
|
||||
~Exception() JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
|
||||
char const* what() const JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
|
||||
protected:
|
||||
std::string const msg_;
|
||||
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(std::string const& msg);
|
||||
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(std::string const& msg);
|
||||
LogicError(JSONCPP_STRING const& msg);
|
||||
};
|
||||
|
||||
/// used internally
|
||||
JSONCPP_NORETURN void throwRuntimeError(std::string const& msg);
|
||||
JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg);
|
||||
/// used internally
|
||||
JSONCPP_NORETURN void throwLogicError(std::string const& msg);
|
||||
JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg);
|
||||
|
||||
/** \brief Type of the value held by a Value object.
|
||||
*/
|
||||
@@ -175,7 +177,7 @@ private:
|
||||
class JSON_API Value {
|
||||
friend class ValueIteratorBase;
|
||||
public:
|
||||
typedef std::vector<std::string> Members;
|
||||
typedef std::vector<JSONCPP_STRING> Members;
|
||||
typedef ValueIterator iterator;
|
||||
typedef ValueConstIterator const_iterator;
|
||||
typedef Json::UInt UInt;
|
||||
@@ -188,11 +190,10 @@ public:
|
||||
typedef Json::LargestUInt LargestUInt;
|
||||
typedef Json::ArrayIndex ArrayIndex;
|
||||
|
||||
static const Value& nullRef;
|
||||
#if !defined(__ARMEL__)
|
||||
/// \deprecated This exists for binary compatibility only. Use nullRef.
|
||||
static const Value null;
|
||||
#endif
|
||||
static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value().
|
||||
static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null
|
||||
static Value const& nullSingleton(); ///< Prefer this to null or nullRef.
|
||||
|
||||
/// Minimum signed integer value that can be stored in a Json::Value.
|
||||
static const LargestInt minLargestInt;
|
||||
/// Maximum signed integer value that can be stored in a Json::Value.
|
||||
@@ -216,12 +217,7 @@ public:
|
||||
static const UInt64 maxUInt64;
|
||||
#endif // defined(JSON_HAS_INT64)
|
||||
|
||||
//MW: workaround for bug in NVIDIAs CUDA 7.5 nvcc compiler
|
||||
#ifdef __NVCC__
|
||||
public:
|
||||
#else
|
||||
private:
|
||||
#endif //__NVCC__
|
||||
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
||||
class CZString {
|
||||
public:
|
||||
@@ -233,8 +229,16 @@ private:
|
||||
CZString(ArrayIndex index);
|
||||
CZString(char const* str, unsigned length, DuplicationPolicy allocate);
|
||||
CZString(CZString const& other);
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
CZString(CZString&& other);
|
||||
#endif
|
||||
~CZString();
|
||||
CZString& operator=(CZString other);
|
||||
CZString& operator=(const CZString& other);
|
||||
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
CZString& operator=(CZString&& other);
|
||||
#endif
|
||||
|
||||
bool operator<(CZString const& other) const;
|
||||
bool operator==(CZString const& other) const;
|
||||
ArrayIndex index() const;
|
||||
@@ -308,23 +312,33 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
* \endcode
|
||||
*/
|
||||
Value(const StaticString& value);
|
||||
Value(const std::string& value); ///< Copy data() til size(). Embedded zeroes too.
|
||||
Value(const JSONCPP_STRING& value); ///< Copy data() til size(). Embedded zeroes too.
|
||||
#ifdef JSON_USE_CPPTL
|
||||
Value(const CppTL::ConstString& value);
|
||||
#endif
|
||||
Value(bool value);
|
||||
/// Deep copy.
|
||||
Value(const Value& other);
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
/// Move constructor
|
||||
Value(Value&& other);
|
||||
#endif
|
||||
~Value();
|
||||
|
||||
/// Deep copy, then swap(other).
|
||||
/// \note Over-write existing comments. To preserve comments, use #swapPayload().
|
||||
Value &operator=(const Value &other);
|
||||
Value& operator=(Value other);
|
||||
|
||||
/// Swap everything.
|
||||
void swap(Value& other);
|
||||
/// Swap values but leave comments and source offsets in place.
|
||||
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;
|
||||
|
||||
/// Compare payload only, not comments etc.
|
||||
@@ -337,7 +351,10 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
int compare(const Value& other) const;
|
||||
|
||||
const char* asCString() const; ///< Embedded zeroes could cause you trouble!
|
||||
std::string asString() const; ///< Embedded zeroes are possible.
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
unsigned getCStringLength() const; //Allows you to understand the length of the CString
|
||||
#endif
|
||||
JSONCPP_STRING asString() const; ///< Embedded zeroes are possible.
|
||||
/** Get raw char* of string-value.
|
||||
* \return false if !string. (Seg-fault if str or end are NULL.)
|
||||
*/
|
||||
@@ -432,6 +449,10 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
/// Equivalent to jsonvalue[jsonvalue.size()] = 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.
|
||||
/// \note Because of our implementation, keys are limited to 2^30 -1 chars.
|
||||
/// Exceeding that will cause an exception.
|
||||
@@ -441,11 +462,11 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
const Value& operator[](const char* key) const;
|
||||
/// Access an object value by name, create a null member if it does not exist.
|
||||
/// \param key may contain embedded nulls.
|
||||
Value& operator[](const std::string& key);
|
||||
Value& operator[](const JSONCPP_STRING& key);
|
||||
/// Access an object value by name, returns null if there is no member with
|
||||
/// that name.
|
||||
/// \param key may contain embedded nulls.
|
||||
const Value& operator[](const 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
|
||||
exist.
|
||||
|
||||
@@ -476,7 +497,7 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
/// Return the member named key if it exist, defaultValue otherwise.
|
||||
/// \note deep copy
|
||||
/// \param key may contain embedded nulls.
|
||||
Value get(const std::string& key, const Value& defaultValue) const;
|
||||
Value get(const JSONCPP_STRING& key, const Value& defaultValue) const;
|
||||
#ifdef JSON_USE_CPPTL
|
||||
/// Return the member named key if it exist, defaultValue otherwise.
|
||||
/// \note deep copy
|
||||
@@ -497,11 +518,13 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
/// \pre type() is objectValue or nullValue
|
||||
/// \post type() is unchanged
|
||||
/// \deprecated
|
||||
JSONCPP_DEPRECATED("")
|
||||
Value removeMember(const char* key);
|
||||
/// Same as removeMember(const char*)
|
||||
/// \param key may contain embedded nulls.
|
||||
/// \deprecated
|
||||
Value removeMember(const std::string& key);
|
||||
JSONCPP_DEPRECATED("")
|
||||
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);
|
||||
@@ -511,8 +534,8 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
\param key may contain embedded nulls.
|
||||
\return true iff removed (no exceptions)
|
||||
*/
|
||||
bool removeMember(std::string const& key, Value* removed);
|
||||
/// Same as removeMember(std::string const& key, Value* removed)
|
||||
bool removeMember(JSONCPP_STRING const& key, Value* removed);
|
||||
/// Same as removeMember(JSONCPP_STRING const& key, Value* removed)
|
||||
bool removeMember(const char* begin, const char* end, Value* removed);
|
||||
/** \brief Remove the indexed array element.
|
||||
|
||||
@@ -527,8 +550,8 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
bool isMember(const char* key) const;
|
||||
/// Return true if the object has a member named key.
|
||||
/// \param key may contain embedded nulls.
|
||||
bool isMember(const std::string& key) const;
|
||||
/// Same as isMember(std::string const& 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
|
||||
/// Return true if the object has a member named key.
|
||||
@@ -548,17 +571,17 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
//# endif
|
||||
|
||||
/// \deprecated Always pass len.
|
||||
JSONCPP_DEPRECATED("Use setComment(std::string const&) instead.")
|
||||
JSONCPP_DEPRECATED("Use setComment(JSONCPP_STRING const&) instead.")
|
||||
void setComment(const char* comment, CommentPlacement placement);
|
||||
/// Comments must be //... or /* ... */
|
||||
void setComment(const char* comment, size_t len, CommentPlacement placement);
|
||||
/// Comments must be //... or /* ... */
|
||||
void setComment(const std::string& comment, CommentPlacement placement);
|
||||
void setComment(const JSONCPP_STRING& comment, CommentPlacement placement);
|
||||
bool hasComment(CommentPlacement placement) const;
|
||||
/// Include delimiters and embedded newlines.
|
||||
std::string getComment(CommentPlacement placement) const;
|
||||
JSONCPP_STRING getComment(CommentPlacement placement) const;
|
||||
|
||||
std::string toStyledString() const;
|
||||
JSONCPP_STRING toStyledString() const;
|
||||
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
@@ -566,6 +589,13 @@ Json::Value obj_value(Json::objectValue); // {}
|
||||
iterator begin();
|
||||
iterator end();
|
||||
|
||||
// Accessors for the [start, limit) range of bytes within the JSON text from
|
||||
// which this value was parsed, if any.
|
||||
void setOffsetStart(ptrdiff_t start);
|
||||
void setOffsetLimit(ptrdiff_t limit);
|
||||
ptrdiff_t getOffsetStart() const;
|
||||
ptrdiff_t getOffsetLimit() const;
|
||||
|
||||
private:
|
||||
void initBasic(ValueType type, bool allocated = false);
|
||||
|
||||
@@ -602,6 +632,11 @@ private:
|
||||
unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
|
||||
// If not allocated_, string_ must be null-terminated.
|
||||
CommentInfo* comments_;
|
||||
|
||||
// [start, limit) byte offsets in the source JSON text from which this Value
|
||||
// was extracted.
|
||||
ptrdiff_t start_;
|
||||
ptrdiff_t limit_;
|
||||
};
|
||||
|
||||
/** \brief Experimental and untested: represents an element of the "path" to
|
||||
@@ -614,7 +649,7 @@ public:
|
||||
PathArgument();
|
||||
PathArgument(ArrayIndex index);
|
||||
PathArgument(const char* key);
|
||||
PathArgument(const std::string& key);
|
||||
PathArgument(const JSONCPP_STRING& key);
|
||||
|
||||
private:
|
||||
enum Kind {
|
||||
@@ -622,7 +657,7 @@ private:
|
||||
kindIndex,
|
||||
kindKey
|
||||
};
|
||||
std::string key_;
|
||||
JSONCPP_STRING key_;
|
||||
ArrayIndex index_;
|
||||
Kind kind_;
|
||||
};
|
||||
@@ -640,7 +675,7 @@ private:
|
||||
*/
|
||||
class JSON_API Path {
|
||||
public:
|
||||
Path(const std::string& path,
|
||||
Path(const JSONCPP_STRING& path,
|
||||
const PathArgument& a1 = PathArgument(),
|
||||
const PathArgument& a2 = PathArgument(),
|
||||
const PathArgument& a3 = PathArgument(),
|
||||
@@ -657,12 +692,12 @@ private:
|
||||
typedef std::vector<const PathArgument*> InArgs;
|
||||
typedef std::vector<PathArgument> Args;
|
||||
|
||||
void makePath(const std::string& path, const InArgs& in);
|
||||
void addPathInArg(const std::string& path,
|
||||
void makePath(const JSONCPP_STRING& path, const InArgs& in);
|
||||
void addPathInArg(const JSONCPP_STRING& path,
|
||||
const InArgs& in,
|
||||
InArgs::const_iterator& itInArg,
|
||||
PathArgument::Kind kind);
|
||||
void invalidPath(const std::string& path, int location);
|
||||
void invalidPath(const JSONCPP_STRING& path, int location);
|
||||
|
||||
Args args_;
|
||||
};
|
||||
@@ -695,7 +730,7 @@ public:
|
||||
/// Return the member name of the referenced Value, or "" if it is not an
|
||||
/// objectValue.
|
||||
/// \note Avoid `c_str()` on result, as embedded zeroes are possible.
|
||||
std::string name() const;
|
||||
JSONCPP_STRING name() const;
|
||||
|
||||
/// Return the member name of the referenced Value. "" if it is not an
|
||||
/// objectValue.
|
||||
@@ -747,6 +782,7 @@ public:
|
||||
typedef ValueConstIterator SelfType;
|
||||
|
||||
ValueConstIterator();
|
||||
ValueConstIterator(ValueIterator const& other);
|
||||
|
||||
private:
|
||||
/*! \internal Use by Value to create an iterator.
|
||||
@@ -796,7 +832,7 @@ public:
|
||||
typedef ValueIterator SelfType;
|
||||
|
||||
ValueIterator();
|
||||
ValueIterator(const ValueConstIterator& other);
|
||||
explicit ValueIterator(const ValueConstIterator& other);
|
||||
ValueIterator(const ValueIterator& other);
|
||||
|
||||
private:
|
||||
@@ -842,6 +878,7 @@ template<>
|
||||
inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
|
||||
}
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(pop)
|
||||
|
@@ -3,11 +3,18 @@
|
||||
#ifndef JSON_VERSION_H_INCLUDED
|
||||
# define JSON_VERSION_H_INCLUDED
|
||||
|
||||
# define JSONCPP_VERSION_STRING "0.10.7"
|
||||
# define JSONCPP_VERSION_MAJOR 0
|
||||
# define JSONCPP_VERSION_MINOR 10
|
||||
# define JSONCPP_VERSION_PATCH 7
|
||||
# define JSONCPP_VERSION_STRING "1.8.2"
|
||||
# define JSONCPP_VERSION_MAJOR 1
|
||||
# define JSONCPP_VERSION_MINOR 8
|
||||
# define JSONCPP_VERSION_PATCH 2
|
||||
# define JSONCPP_VERSION_QUALIFIER
|
||||
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
||||
|
||||
#ifdef JSONCPP_USING_SECURE_MEMORY
|
||||
#undef JSONCPP_USING_SECURE_MEMORY
|
||||
#endif
|
||||
#define JSONCPP_USING_SECURE_MEMORY 0
|
||||
// If non-zero, the library zeroes any memory that it has allocated before
|
||||
// it frees its memory.
|
||||
|
||||
#endif // JSON_VERSION_H_INCLUDED
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
@@ -20,6 +20,8 @@
|
||||
#pragma warning(disable : 4251)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#pragma pack(push, 8)
|
||||
|
||||
namespace Json {
|
||||
|
||||
class Value;
|
||||
@@ -39,7 +41,7 @@ Usage:
|
||||
*/
|
||||
class JSON_API StreamWriter {
|
||||
protected:
|
||||
std::ostream* sout_; // not owned; will not delete
|
||||
JSONCPP_OSTREAM* sout_; // not owned; will not delete
|
||||
public:
|
||||
StreamWriter();
|
||||
virtual ~StreamWriter();
|
||||
@@ -49,7 +51,7 @@ public:
|
||||
\return zero on success (For now, we always return zero, so check the stream instead.)
|
||||
\throw std::exception possibly, depending on configuration
|
||||
*/
|
||||
virtual int write(Value const& root, std::ostream* sout) = 0;
|
||||
virtual int write(Value const& root, JSONCPP_OSTREAM* sout) = 0;
|
||||
|
||||
/** \brief A simple abstract factory.
|
||||
*/
|
||||
@@ -66,7 +68,7 @@ public:
|
||||
/** \brief Write into stringstream, then return string, for convenience.
|
||||
* A StreamWriter will be created from the factory, used, and then deleted.
|
||||
*/
|
||||
std::string JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
|
||||
JSONCPP_STRING JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
|
||||
|
||||
|
||||
/** \brief Build a StreamWriter implementation.
|
||||
@@ -112,12 +114,12 @@ public:
|
||||
Json::Value settings_;
|
||||
|
||||
StreamWriterBuilder();
|
||||
virtual ~StreamWriterBuilder();
|
||||
~StreamWriterBuilder() JSONCPP_OVERRIDE;
|
||||
|
||||
/**
|
||||
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
||||
*/
|
||||
virtual StreamWriter* newStreamWriter() const;
|
||||
StreamWriter* newStreamWriter() const JSONCPP_OVERRIDE;
|
||||
|
||||
/** \return true if 'settings' are legal and consistent;
|
||||
* otherwise, indicate bad settings via 'invalid'.
|
||||
@@ -125,7 +127,7 @@ public:
|
||||
bool validate(Json::Value* invalid) const;
|
||||
/** A simple way to update a specific setting.
|
||||
*/
|
||||
Value& operator[](std::string key);
|
||||
Value& operator[](JSONCPP_STRING key);
|
||||
|
||||
/** Called by ctor, but you can use this to reset settings_.
|
||||
* \pre 'settings' != NULL (but Json::null is fine)
|
||||
@@ -138,11 +140,11 @@ public:
|
||||
/** \brief Abstract class for writers.
|
||||
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
|
||||
*/
|
||||
class JSON_API Writer {
|
||||
class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer {
|
||||
public:
|
||||
virtual ~Writer();
|
||||
|
||||
virtual std::string write(const Value& root) = 0;
|
||||
virtual JSONCPP_STRING write(const Value& root) = 0;
|
||||
};
|
||||
|
||||
/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
|
||||
@@ -154,22 +156,33 @@ public:
|
||||
* \sa Reader, Value
|
||||
* \deprecated Use StreamWriterBuilder.
|
||||
*/
|
||||
class JSON_API FastWriter : public Writer {
|
||||
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter : public Writer {
|
||||
|
||||
public:
|
||||
FastWriter();
|
||||
virtual ~FastWriter() {}
|
||||
~FastWriter() JSONCPP_OVERRIDE {}
|
||||
|
||||
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
|
||||
virtual std::string write(const Value& root);
|
||||
JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
|
||||
|
||||
private:
|
||||
void writeValue(const Value& value);
|
||||
|
||||
std::string document_;
|
||||
JSONCPP_STRING document_;
|
||||
bool yamlCompatiblityEnabled_;
|
||||
bool dropNullPlaceholders_;
|
||||
bool omitEndingLineFeed_;
|
||||
};
|
||||
|
||||
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
||||
@@ -196,39 +209,39 @@ private:
|
||||
* \sa Reader, Value, Value::setComment()
|
||||
* \deprecated Use StreamWriterBuilder.
|
||||
*/
|
||||
class JSON_API StyledWriter : public Writer {
|
||||
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledWriter : public Writer {
|
||||
public:
|
||||
StyledWriter();
|
||||
virtual ~StyledWriter() {}
|
||||
~StyledWriter() JSONCPP_OVERRIDE {}
|
||||
|
||||
public: // overridden from Writer
|
||||
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
||||
* \param root Value to serialize.
|
||||
* \return String containing the JSON document that represents the root value.
|
||||
*/
|
||||
virtual std::string write(const Value& root);
|
||||
JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
|
||||
|
||||
private:
|
||||
void writeValue(const Value& value);
|
||||
void writeArrayValue(const Value& value);
|
||||
bool isMultineArray(const Value& value);
|
||||
void pushValue(const std::string& value);
|
||||
void pushValue(const JSONCPP_STRING& value);
|
||||
void writeIndent();
|
||||
void writeWithIndent(const std::string& value);
|
||||
void writeWithIndent(const JSONCPP_STRING& value);
|
||||
void indent();
|
||||
void unindent();
|
||||
void writeCommentBeforeValue(const Value& root);
|
||||
void writeCommentAfterValueOnSameLine(const Value& root);
|
||||
bool hasCommentForValue(const Value& value);
|
||||
static std::string normalizeEOL(const std::string& text);
|
||||
static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
|
||||
|
||||
typedef std::vector<std::string> ChildValues;
|
||||
typedef std::vector<JSONCPP_STRING> ChildValues;
|
||||
|
||||
ChildValues childValues_;
|
||||
std::string document_;
|
||||
std::string indentString_;
|
||||
int rightMargin_;
|
||||
int indentSize_;
|
||||
JSONCPP_STRING document_;
|
||||
JSONCPP_STRING indentString_;
|
||||
unsigned int rightMargin_;
|
||||
unsigned int indentSize_;
|
||||
bool addChildValues_;
|
||||
};
|
||||
|
||||
@@ -254,13 +267,15 @@ private:
|
||||
* If the Value have comments then they are outputed according to their
|
||||
#CommentPlacement.
|
||||
*
|
||||
* \param indentation Each level will be indented by this amount extra.
|
||||
* \sa Reader, Value, Value::setComment()
|
||||
* \deprecated Use StreamWriterBuilder.
|
||||
*/
|
||||
class JSON_API StyledStreamWriter {
|
||||
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledStreamWriter {
|
||||
public:
|
||||
StyledStreamWriter(std::string indentation = "\t");
|
||||
/**
|
||||
* \param indentation Each level will be indented by this amount extra.
|
||||
*/
|
||||
StyledStreamWriter(JSONCPP_STRING indentation = "\t");
|
||||
~StyledStreamWriter() {}
|
||||
|
||||
public:
|
||||
@@ -270,49 +285,51 @@ public:
|
||||
* \note There is no point in deriving from Writer, since write() should not
|
||||
* return a value.
|
||||
*/
|
||||
void write(std::ostream& out, const Value& root);
|
||||
void write(JSONCPP_OSTREAM& out, const Value& root);
|
||||
|
||||
private:
|
||||
void writeValue(const Value& value);
|
||||
void writeArrayValue(const Value& value);
|
||||
bool isMultineArray(const Value& value);
|
||||
void pushValue(const std::string& value);
|
||||
void pushValue(const JSONCPP_STRING& value);
|
||||
void writeIndent();
|
||||
void writeWithIndent(const std::string& value);
|
||||
void writeWithIndent(const JSONCPP_STRING& value);
|
||||
void indent();
|
||||
void unindent();
|
||||
void writeCommentBeforeValue(const Value& root);
|
||||
void writeCommentAfterValueOnSameLine(const Value& root);
|
||||
bool hasCommentForValue(const Value& value);
|
||||
static std::string normalizeEOL(const std::string& text);
|
||||
static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
|
||||
|
||||
typedef std::vector<std::string> ChildValues;
|
||||
typedef std::vector<JSONCPP_STRING> ChildValues;
|
||||
|
||||
ChildValues childValues_;
|
||||
std::ostream* document_;
|
||||
std::string indentString_;
|
||||
int rightMargin_;
|
||||
std::string indentation_;
|
||||
JSONCPP_OSTREAM* document_;
|
||||
JSONCPP_STRING indentString_;
|
||||
unsigned int rightMargin_;
|
||||
JSONCPP_STRING indentation_;
|
||||
bool addChildValues_ : 1;
|
||||
bool indented_ : 1;
|
||||
};
|
||||
|
||||
#if defined(JSON_HAS_INT64)
|
||||
std::string JSON_API valueToString(Int value);
|
||||
std::string JSON_API valueToString(UInt value);
|
||||
JSONCPP_STRING JSON_API valueToString(Int value);
|
||||
JSONCPP_STRING JSON_API valueToString(UInt value);
|
||||
#endif // if defined(JSON_HAS_INT64)
|
||||
std::string JSON_API valueToString(LargestInt value);
|
||||
std::string JSON_API valueToString(LargestUInt value);
|
||||
std::string JSON_API valueToString(double value);
|
||||
std::string JSON_API valueToString(bool value);
|
||||
std::string JSON_API valueToQuotedString(const char* value);
|
||||
JSONCPP_STRING JSON_API valueToString(LargestInt value);
|
||||
JSONCPP_STRING JSON_API valueToString(LargestUInt value);
|
||||
JSONCPP_STRING JSON_API valueToString(double value);
|
||||
JSONCPP_STRING JSON_API valueToString(bool value);
|
||||
JSONCPP_STRING JSON_API valueToQuotedString(const char* value);
|
||||
|
||||
/// \brief Output using the StyledStreamWriter.
|
||||
/// \see Json::operator>>()
|
||||
JSON_API std::ostream& operator<<(std::ostream&, const Value& root);
|
||||
JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(pop)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright 2010 Baptiste Lepilleur
|
||||
# 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
|
||||
|
102
meson.build
Normal file
102
meson.build
Normal file
@@ -0,0 +1,102 @@
|
||||
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,7 +1,5 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
libdir=@LIBRARY_INSTALL_DIR@
|
||||
includedir=@INCLUDE_INSTALL_DIR@
|
||||
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||
|
||||
Name: jsoncpp
|
||||
Description: A C++ library for interacting with JSON
|
||||
|
@@ -1,58 +0,0 @@
|
||||
# Copyright 2009 Baptiste Lepilleur
|
||||
# Distributed under MIT license, or public domain if desired and
|
||||
# recognized in your jurisdiction.
|
||||
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
import fnmatch
|
||||
import os
|
||||
|
||||
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
|
@@ -1,183 +0,0 @@
|
||||
# Copyright 2007 Baptiste Lepilleur
|
||||
# Distributed under MIT license, or public domain if desired and
|
||||
# recognized in your jurisdiction.
|
||||
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
import os
|
||||
import os.path
|
||||
from fnmatch import fnmatch
|
||||
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)
|
@@ -1,85 +0,0 @@
|
||||
# Copyright 2010 Baptiste Lepilleur
|
||||
# Distributed under MIT license, or public domain if desired and
|
||||
# recognized in your jurisdiction.
|
||||
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
import re
|
||||
from SCons.Script import * # the usual scons stuff you get in a SConscript
|
||||
import collections
|
||||
|
||||
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
|
@@ -1,87 +0,0 @@
|
||||
# Copyright 2007 Baptiste Lepilleur
|
||||
# Distributed under MIT license, or public domain if desired and
|
||||
# recognized in your jurisdiction.
|
||||
# See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
"""tarball
|
||||
|
||||
Tool-specific initialization for tarball.
|
||||
|
||||
"""
|
||||
|
||||
## 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
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
@@ -17,14 +17,14 @@
|
||||
|
||||
struct Options
|
||||
{
|
||||
std::string path;
|
||||
JSONCPP_STRING path;
|
||||
Json::Features features;
|
||||
bool parseOnly;
|
||||
typedef std::string (*writeFuncType)(Json::Value const&);
|
||||
typedef JSONCPP_STRING (*writeFuncType)(Json::Value const&);
|
||||
writeFuncType write;
|
||||
};
|
||||
|
||||
static std::string normalizeFloatingPointStr(double value) {
|
||||
static JSONCPP_STRING normalizeFloatingPointStr(double value) {
|
||||
char buffer[32];
|
||||
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
|
||||
sprintf_s(buffer, sizeof(buffer), "%.16g", value);
|
||||
@@ -32,18 +32,18 @@ static std::string normalizeFloatingPointStr(double value) {
|
||||
snprintf(buffer, sizeof(buffer), "%.16g", value);
|
||||
#endif
|
||||
buffer[sizeof(buffer) - 1] = 0;
|
||||
std::string s(buffer);
|
||||
std::string::size_type index = s.find_last_of("eE");
|
||||
if (index != std::string::npos) {
|
||||
std::string::size_type hasSign =
|
||||
JSONCPP_STRING s(buffer);
|
||||
JSONCPP_STRING::size_type index = s.find_last_of("eE");
|
||||
if (index != JSONCPP_STRING::npos) {
|
||||
JSONCPP_STRING::size_type hasSign =
|
||||
(s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0;
|
||||
std::string::size_type exponentStartIndex = index + 1 + hasSign;
|
||||
std::string normalized = s.substr(0, exponentStartIndex);
|
||||
std::string::size_type indexDigit =
|
||||
JSONCPP_STRING::size_type exponentStartIndex = index + 1 + hasSign;
|
||||
JSONCPP_STRING normalized = s.substr(0, exponentStartIndex);
|
||||
JSONCPP_STRING::size_type indexDigit =
|
||||
s.find_first_not_of('0', exponentStartIndex);
|
||||
std::string exponent = "0";
|
||||
JSONCPP_STRING exponent = "0";
|
||||
if (indexDigit !=
|
||||
std::string::npos) // There is an exponent different from 0
|
||||
JSONCPP_STRING::npos) // There is an exponent different from 0
|
||||
{
|
||||
exponent = s.substr(indexDigit);
|
||||
}
|
||||
@@ -52,17 +52,18 @@ static std::string normalizeFloatingPointStr(double value) {
|
||||
return s;
|
||||
}
|
||||
|
||||
static std::string readInputTestFile(const char* path) {
|
||||
static JSONCPP_STRING readInputTestFile(const char* path) {
|
||||
FILE* file = fopen(path, "rb");
|
||||
if (!file)
|
||||
return std::string("");
|
||||
return JSONCPP_STRING("");
|
||||
fseek(file, 0, SEEK_END);
|
||||
long size = ftell(file);
|
||||
long const size = ftell(file);
|
||||
unsigned long const usize = static_cast<unsigned long>(size);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
std::string text;
|
||||
JSONCPP_STRING text;
|
||||
char* buffer = new char[size + 1];
|
||||
buffer[size] = 0;
|
||||
if (fread(buffer, 1, size, file) == (unsigned long)size)
|
||||
if (fread(buffer, 1, usize, file) == usize)
|
||||
text = buffer;
|
||||
fclose(file);
|
||||
delete[] buffer;
|
||||
@@ -70,7 +71,7 @@ static std::string readInputTestFile(const char* path) {
|
||||
}
|
||||
|
||||
static void
|
||||
printValueTree(FILE* fout, Json::Value& value, const std::string& path = ".") {
|
||||
printValueTree(FILE* fout, Json::Value& value, const JSONCPP_STRING& path = ".") {
|
||||
if (value.hasComment(Json::commentBefore)) {
|
||||
fprintf(fout, "%s\n", value.getComment(Json::commentBefore).c_str());
|
||||
}
|
||||
@@ -104,8 +105,8 @@ printValueTree(FILE* fout, Json::Value& value, const std::string& path = ".") {
|
||||
break;
|
||||
case Json::arrayValue: {
|
||||
fprintf(fout, "%s=[]\n", path.c_str());
|
||||
int size = value.size();
|
||||
for (int index = 0; index < size; ++index) {
|
||||
Json::ArrayIndex size = value.size();
|
||||
for (Json::ArrayIndex index = 0; index < size; ++index) {
|
||||
static char buffer[16];
|
||||
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
|
||||
sprintf_s(buffer, sizeof(buffer), "[%d]", index);
|
||||
@@ -119,11 +120,11 @@ printValueTree(FILE* fout, Json::Value& value, const std::string& path = ".") {
|
||||
fprintf(fout, "%s={}\n", path.c_str());
|
||||
Json::Value::Members members(value.getMemberNames());
|
||||
std::sort(members.begin(), members.end());
|
||||
std::string suffix = *(path.end() - 1) == '.' ? "" : ".";
|
||||
JSONCPP_STRING suffix = *(path.end() - 1) == '.' ? "" : ".";
|
||||
for (Json::Value::Members::iterator it = members.begin();
|
||||
it != members.end();
|
||||
++it) {
|
||||
const std::string& name = *it;
|
||||
const JSONCPP_STRING name = *it;
|
||||
printValueTree(fout, value[name], path + suffix + name);
|
||||
}
|
||||
} break;
|
||||
@@ -136,15 +137,15 @@ printValueTree(FILE* fout, Json::Value& value, const std::string& path = ".") {
|
||||
}
|
||||
}
|
||||
|
||||
static int parseAndSaveValueTree(const std::string& input,
|
||||
const std::string& actual,
|
||||
const std::string& kind,
|
||||
static int parseAndSaveValueTree(const JSONCPP_STRING& input,
|
||||
const JSONCPP_STRING& actual,
|
||||
const JSONCPP_STRING& kind,
|
||||
const Json::Features& features,
|
||||
bool parseOnly,
|
||||
Json::Value* root)
|
||||
{
|
||||
Json::Reader reader(features);
|
||||
bool parsingSuccessful = reader.parse(input, *root);
|
||||
bool parsingSuccessful = reader.parse(input.data(), input.data() + input.size(), *root);
|
||||
if (!parsingSuccessful) {
|
||||
printf("Failed to parse %s file: \n%s\n",
|
||||
kind.c_str(),
|
||||
@@ -162,36 +163,36 @@ static int parseAndSaveValueTree(const std::string& input,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// static std::string useFastWriter(Json::Value const& root) {
|
||||
// static JSONCPP_STRING useFastWriter(Json::Value const& root) {
|
||||
// Json::FastWriter writer;
|
||||
// writer.enableYAMLCompatibility();
|
||||
// return writer.write(root);
|
||||
// }
|
||||
static std::string useStyledWriter(
|
||||
static JSONCPP_STRING useStyledWriter(
|
||||
Json::Value const& root)
|
||||
{
|
||||
Json::StyledWriter writer;
|
||||
return writer.write(root);
|
||||
}
|
||||
static std::string useStyledStreamWriter(
|
||||
static JSONCPP_STRING useStyledStreamWriter(
|
||||
Json::Value const& root)
|
||||
{
|
||||
Json::StyledStreamWriter writer;
|
||||
std::ostringstream sout;
|
||||
JSONCPP_OSTRINGSTREAM sout;
|
||||
writer.write(sout, root);
|
||||
return sout.str();
|
||||
}
|
||||
static std::string useBuiltStyledStreamWriter(
|
||||
static JSONCPP_STRING useBuiltStyledStreamWriter(
|
||||
Json::Value const& root)
|
||||
{
|
||||
Json::StreamWriterBuilder builder;
|
||||
return Json::writeString(builder, root);
|
||||
}
|
||||
static int rewriteValueTree(
|
||||
const std::string& rewritePath,
|
||||
const JSONCPP_STRING& rewritePath,
|
||||
const Json::Value& root,
|
||||
Options::writeFuncType write,
|
||||
std::string* rewrite)
|
||||
JSONCPP_STRING* rewrite)
|
||||
{
|
||||
*rewrite = write(root);
|
||||
FILE* fout = fopen(rewritePath.c_str(), "wt");
|
||||
@@ -204,13 +205,13 @@ static int rewriteValueTree(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static std::string removeSuffix(const std::string& path,
|
||||
const std::string& extension) {
|
||||
static JSONCPP_STRING removeSuffix(const JSONCPP_STRING& path,
|
||||
const JSONCPP_STRING& extension) {
|
||||
if (extension.length() >= path.length())
|
||||
return std::string("");
|
||||
std::string suffix = path.substr(path.length() - extension.length());
|
||||
return JSONCPP_STRING("");
|
||||
JSONCPP_STRING suffix = path.substr(path.length() - extension.length());
|
||||
if (suffix != extension)
|
||||
return std::string("");
|
||||
return JSONCPP_STRING("");
|
||||
return path.substr(0, path.length() - extension.length());
|
||||
}
|
||||
|
||||
@@ -237,18 +238,18 @@ static int parseCommandLine(
|
||||
return printUsage(argv);
|
||||
}
|
||||
int index = 1;
|
||||
if (std::string(argv[index]) == "--json-checker") {
|
||||
if (JSONCPP_STRING(argv[index]) == "--json-checker") {
|
||||
opts->features = Json::Features::strictMode();
|
||||
opts->parseOnly = true;
|
||||
++index;
|
||||
}
|
||||
if (std::string(argv[index]) == "--json-config") {
|
||||
if (JSONCPP_STRING(argv[index]) == "--json-config") {
|
||||
printConfig();
|
||||
return 3;
|
||||
}
|
||||
if (std::string(argv[index]) == "--json-writer") {
|
||||
if (JSONCPP_STRING(argv[index]) == "--json-writer") {
|
||||
++index;
|
||||
std::string const writerName(argv[index++]);
|
||||
JSONCPP_STRING const writerName(argv[index++]);
|
||||
if (writerName == "StyledWriter") {
|
||||
opts->write = &useStyledWriter;
|
||||
} else if (writerName == "StyledStreamWriter") {
|
||||
@@ -270,22 +271,22 @@ static int runTest(Options const& opts)
|
||||
{
|
||||
int exitCode = 0;
|
||||
|
||||
std::string input = readInputTestFile(opts.path.c_str());
|
||||
JSONCPP_STRING input = readInputTestFile(opts.path.c_str());
|
||||
if (input.empty()) {
|
||||
printf("Failed to read input or empty input: %s\n", opts.path.c_str());
|
||||
return 3;
|
||||
}
|
||||
|
||||
std::string basePath = removeSuffix(opts.path, ".json");
|
||||
JSONCPP_STRING basePath = removeSuffix(opts.path, ".json");
|
||||
if (!opts.parseOnly && basePath.empty()) {
|
||||
printf("Bad input path. Path does not end with '.expected':\n%s\n",
|
||||
opts.path.c_str());
|
||||
return 3;
|
||||
}
|
||||
|
||||
std::string const actualPath = basePath + ".actual";
|
||||
std::string const rewritePath = basePath + ".rewrite";
|
||||
std::string const rewriteActualPath = basePath + ".actual-rewrite";
|
||||
JSONCPP_STRING const actualPath = basePath + ".actual";
|
||||
JSONCPP_STRING const rewritePath = basePath + ".rewrite";
|
||||
JSONCPP_STRING const rewriteActualPath = basePath + ".actual-rewrite";
|
||||
|
||||
Json::Value root;
|
||||
exitCode = parseAndSaveValueTree(
|
||||
@@ -294,7 +295,7 @@ static int runTest(Options const& opts)
|
||||
if (exitCode || opts.parseOnly) {
|
||||
return exitCode;
|
||||
}
|
||||
std::string rewrite;
|
||||
JSONCPP_STRING rewrite;
|
||||
exitCode = rewriteValueTree(rewritePath, root, opts.write, &rewrite);
|
||||
if (exitCode) {
|
||||
return exitCode;
|
||||
@@ -310,12 +311,12 @@ static int runTest(Options const& opts)
|
||||
}
|
||||
int main(int argc, const char* argv[]) {
|
||||
Options opts;
|
||||
try {
|
||||
int exitCode = parseCommandLine(argc, argv, &opts);
|
||||
if (exitCode != 0) {
|
||||
printf("Failed to parse command-line.");
|
||||
return exitCode;
|
||||
}
|
||||
try {
|
||||
return runTest(opts);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
|
@@ -1,9 +0,0 @@
|
||||
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,13 +1,41 @@
|
||||
if( CMAKE_COMPILER_IS_GNUCXX )
|
||||
#Get compiler version.
|
||||
execute_process( COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
|
||||
OUTPUT_VARIABLE GNUCXX_VERSION )
|
||||
IF( CMAKE_COMPILER_IS_GNUCXX )
|
||||
#Get compiler version.
|
||||
EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
|
||||
OUTPUT_VARIABLE GNUCXX_VERSION )
|
||||
|
||||
#-Werror=* was introduced -after- GCC 4.1.2
|
||||
if( GNUCXX_VERSION VERSION_GREATER 4.1.2 )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=strict-aliasing")
|
||||
endif()
|
||||
endif( CMAKE_COMPILER_IS_GNUCXX )
|
||||
#-Werror=* was introduced -after- GCC 4.1.2
|
||||
IF( GNUCXX_VERSION VERSION_GREATER 4.1.2 )
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=strict-aliasing")
|
||||
ENDIF()
|
||||
ENDIF( CMAKE_COMPILER_IS_GNUCXX )
|
||||
|
||||
INCLUDE(CheckIncludeFileCXX)
|
||||
INCLUDE(CheckTypeSize)
|
||||
INCLUDE(CheckStructHasMember)
|
||||
INCLUDE(CheckCXXSymbolExists)
|
||||
|
||||
check_include_file_cxx(clocale HAVE_CLOCALE)
|
||||
check_cxx_symbol_exists(localeconv clocale HAVE_LOCALECONV)
|
||||
|
||||
IF(CMAKE_VERSION VERSION_LESS 3.0.0)
|
||||
# The "LANGUAGE CXX" parameter is not supported in CMake versions below 3,
|
||||
# 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 )
|
||||
|
||||
@@ -42,18 +70,23 @@ ENDIF()
|
||||
IF(BUILD_SHARED_LIBS)
|
||||
ADD_DEFINITIONS( -DJSON_DLL_BUILD )
|
||||
ADD_LIBRARY(jsoncpp_lib SHARED ${PUBLIC_HEADERS} ${jsoncpp_sources})
|
||||
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_VERSION_MAJOR})
|
||||
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_SOVERSION})
|
||||
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}
|
||||
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
|
||||
LIBRARY DESTINATION "${LIBRARY_INSTALL_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
ARCHIVE DESTINATION "${ARCHIVE_INSTALL_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib PUBLIC
|
||||
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>)
|
||||
ENDIF()
|
||||
|
||||
@@ -61,20 +94,24 @@ ENDIF()
|
||||
|
||||
IF(BUILD_STATIC_LIBS)
|
||||
ADD_LIBRARY(jsoncpp_lib_static STATIC ${PUBLIC_HEADERS} ${jsoncpp_sources})
|
||||
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_VERSION_MAJOR})
|
||||
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES OUTPUT_NAME jsoncpp
|
||||
DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )
|
||||
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_SOVERSION})
|
||||
# avoid name clashes on windows as the shared import lib is also named jsoncpp.lib
|
||||
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}
|
||||
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
|
||||
LIBRARY DESTINATION "${LIBRARY_INSTALL_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
ARCHIVE DESTINATION "${ARCHIVE_INSTALL_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
IF(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
TARGET_INCLUDE_DIRECTORIES( jsoncpp_lib_static PUBLIC
|
||||
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
|
||||
)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
ENDIF()
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
@@ -6,6 +6,16 @@
|
||||
#ifndef 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,
|
||||
* portable conversion from/to string...
|
||||
*
|
||||
@@ -13,10 +23,18 @@
|
||||
*/
|
||||
|
||||
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.
|
||||
static inline std::string codePointToUTF8(unsigned int cp) {
|
||||
std::string result;
|
||||
static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
||||
JSONCPP_STRING result;
|
||||
|
||||
// based on description from http://en.wikipedia.org/wiki/UTF-8
|
||||
|
||||
@@ -63,7 +81,7 @@ typedef char UIntToStringBuffer[uintToStringBufferSize];
|
||||
static inline void uintToString(LargestUInt value, char*& current) {
|
||||
*--current = 0;
|
||||
do {
|
||||
*--current = static_cast<signed char>(value % 10U + static_cast<unsigned>('0'));
|
||||
*--current = static_cast<char>(value % 10U + static_cast<unsigned>('0'));
|
||||
value /= 10;
|
||||
} while (value != 0);
|
||||
}
|
||||
@@ -82,6 +100,18 @@ 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 {
|
||||
|
||||
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2011 Baptiste Lepilleur
|
||||
// Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
@@ -18,9 +18,7 @@
|
||||
#endif
|
||||
#include <cstddef> // size_t
|
||||
#include <algorithm> // min()
|
||||
#if defined(__BORLANDC__)
|
||||
#include <mem.h>
|
||||
#endif
|
||||
|
||||
#define JSON_ASSERT_UNREACHABLE assert(false)
|
||||
|
||||
namespace Json {
|
||||
@@ -31,13 +29,24 @@ namespace Json {
|
||||
#if defined(__ARMEL__)
|
||||
#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
|
||||
#else
|
||||
// This exists for binary compatibility only. Use nullRef.
|
||||
const Value Value::null;
|
||||
#define ALIGNAS(byte_alignment)
|
||||
#endif
|
||||
static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
|
||||
const unsigned char& kNullRef = kNull[0];
|
||||
const Value& Value::nullRef = reinterpret_cast<const Value&>(kNullRef);
|
||||
//static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
|
||||
//const unsigned char& kNullRef = kNull[0];
|
||||
//const Value& Value::null = reinterpret_cast<const Value&>(kNullRef);
|
||||
//const Value& Value::nullRef = null;
|
||||
|
||||
// static
|
||||
Value const& Value::nullSingleton()
|
||||
{
|
||||
static Value const nullStatic;
|
||||
return nullStatic;
|
||||
}
|
||||
|
||||
// for backwards compatibility, we'll leave these global references around, but DO NOT
|
||||
// use them in JSONCPP library code any more!
|
||||
Value const& Value::null = Value::nullSingleton();
|
||||
Value const& Value::nullRef = Value::nullSingleton();
|
||||
|
||||
const Int Value::minInt = Int(~(UInt(-1) / 2));
|
||||
const Int Value::maxInt = Int(UInt(-1) / 2);
|
||||
@@ -58,11 +67,14 @@ const LargestUInt Value::maxLargestUInt = LargestUInt(-1);
|
||||
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||
template <typename T, typename U>
|
||||
static inline bool InRange(double d, T min, U max) {
|
||||
// The casts can lose precision, but we are looking only for
|
||||
// an approximate range. Might fail on edge cases though. ~cdunn
|
||||
//return d >= static_cast<double>(min) && d <= static_cast<double>(max);
|
||||
return d >= min && d <= max;
|
||||
}
|
||||
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||
static inline double integerToDouble(Json::UInt64 value) {
|
||||
return static_cast<double>(Int64(value / 2)) * 2.0 + Int64(value & 1);
|
||||
return static_cast<double>(Int64(value / 2)) * 2.0 + static_cast<double>(Int64(value & 1));
|
||||
}
|
||||
|
||||
template <typename T> static inline double integerToDouble(T value) {
|
||||
@@ -83,10 +95,11 @@ static inline bool InRange(double d, T min, U max) {
|
||||
* @return Pointer on the duplicate instance of string.
|
||||
*/
|
||||
static inline char* duplicateStringValue(const char* value,
|
||||
size_t length) {
|
||||
size_t length)
|
||||
{
|
||||
// Avoid an integer overflow in the call to malloc below by limiting length
|
||||
// to a sane value.
|
||||
if (length >= (size_t)Value::maxInt)
|
||||
if (length >= static_cast<size_t>(Value::maxInt))
|
||||
length = Value::maxInt - 1;
|
||||
|
||||
char* newString = static_cast<char*>(malloc(length + 1));
|
||||
@@ -108,7 +121,7 @@ static inline char* duplicateAndPrefixStringValue(
|
||||
{
|
||||
// Avoid an integer overflow in the call to malloc below by limiting length
|
||||
// to a sane value.
|
||||
JSON_ASSERT_MESSAGE(length <= (unsigned)Value::maxInt - sizeof(unsigned) - 1U,
|
||||
JSON_ASSERT_MESSAGE(length <= static_cast<unsigned>(Value::maxInt) - sizeof(unsigned) - 1U,
|
||||
"in Json::Value::duplicateAndPrefixStringValue(): "
|
||||
"length too big for prefixing");
|
||||
unsigned actualLength = length + static_cast<unsigned>(sizeof(unsigned)) + 1U;
|
||||
@@ -137,7 +150,29 @@ inline static void decodePrefixedString(
|
||||
}
|
||||
/** Free the string duplicated by duplicateStringValue()/duplicateAndPrefixStringValue().
|
||||
*/
|
||||
static inline void releaseStringValue(char* value) { free(value); }
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
static inline void releasePrefixedStringValue(char* value) {
|
||||
unsigned length = 0;
|
||||
char const* valueDecoded;
|
||||
decodePrefixedString(true, value, &length, &valueDecoded);
|
||||
size_t const size = sizeof(unsigned) + length + 1U;
|
||||
memset(value, 0, size);
|
||||
free(value);
|
||||
}
|
||||
static inline void releaseStringValue(char* value, unsigned length) {
|
||||
// length==0 => we allocated the strings memory
|
||||
size_t size = (length==0) ? strlen(value) : length;
|
||||
memset(value, 0, size);
|
||||
free(value);
|
||||
}
|
||||
#else // !JSONCPP_USING_SECURE_MEMORY
|
||||
static inline void releasePrefixedStringValue(char* value) {
|
||||
free(value);
|
||||
}
|
||||
static inline void releaseStringValue(char* value, unsigned) {
|
||||
free(value);
|
||||
}
|
||||
#endif // JSONCPP_USING_SECURE_MEMORY
|
||||
|
||||
} // namespace Json
|
||||
|
||||
@@ -155,26 +190,26 @@ static inline void releaseStringValue(char* value) { free(value); }
|
||||
|
||||
namespace Json {
|
||||
|
||||
Exception::Exception(std::string const& msg)
|
||||
Exception::Exception(JSONCPP_STRING const& msg)
|
||||
: msg_(msg)
|
||||
{}
|
||||
Exception::~Exception() throw()
|
||||
Exception::~Exception() JSONCPP_NOEXCEPT
|
||||
{}
|
||||
char const* Exception::what() const throw()
|
||||
char const* Exception::what() const JSONCPP_NOEXCEPT
|
||||
{
|
||||
return msg_.c_str();
|
||||
}
|
||||
RuntimeError::RuntimeError(std::string const& msg)
|
||||
RuntimeError::RuntimeError(JSONCPP_STRING const& msg)
|
||||
: Exception(msg)
|
||||
{}
|
||||
LogicError::LogicError(std::string const& msg)
|
||||
LogicError::LogicError(JSONCPP_STRING const& msg)
|
||||
: Exception(msg)
|
||||
{}
|
||||
JSONCPP_NORETURN void throwRuntimeError(std::string const& msg)
|
||||
JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg)
|
||||
{
|
||||
throw RuntimeError(msg);
|
||||
}
|
||||
JSONCPP_NORETURN void throwLogicError(std::string const& msg)
|
||||
JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg)
|
||||
{
|
||||
throw LogicError(msg);
|
||||
}
|
||||
@@ -187,16 +222,17 @@ JSONCPP_NORETURN void throwLogicError(std::string const& msg)
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
Value::CommentInfo::CommentInfo() : comment_(0) {}
|
||||
Value::CommentInfo::CommentInfo() : comment_(0)
|
||||
{}
|
||||
|
||||
Value::CommentInfo::~CommentInfo() {
|
||||
if (comment_)
|
||||
releaseStringValue(comment_);
|
||||
releaseStringValue(comment_, 0u);
|
||||
}
|
||||
|
||||
void Value::CommentInfo::setComment(const char* text, size_t len) {
|
||||
if (comment_) {
|
||||
releaseStringValue(comment_);
|
||||
releaseStringValue(comment_, 0u);
|
||||
comment_ = 0;
|
||||
}
|
||||
JSON_ASSERT(text != 0);
|
||||
@@ -221,28 +257,34 @@ void Value::CommentInfo::setComment(const char* text, size_t len) {
|
||||
Value::CZString::CZString(ArrayIndex aindex) : cstr_(0), index_(aindex) {}
|
||||
|
||||
Value::CZString::CZString(char const* str, unsigned ulength, DuplicationPolicy allocate)
|
||||
: cstr_(str)
|
||||
{
|
||||
: cstr_(str) {
|
||||
// allocate != duplicate
|
||||
storage_.policy_ = allocate & 0x3;
|
||||
storage_.length_ = ulength & 0x3FFFFFFF;
|
||||
}
|
||||
|
||||
Value::CZString::CZString(const CZString& other)
|
||||
: cstr_(other.storage_.policy_ != noDuplication && other.cstr_ != 0
|
||||
? duplicateStringValue(other.cstr_, other.storage_.length_)
|
||||
: other.cstr_)
|
||||
{
|
||||
storage_.policy_ = (other.cstr_
|
||||
Value::CZString::CZString(const CZString& other) {
|
||||
cstr_ = (other.storage_.policy_ != noDuplication && other.cstr_ != 0
|
||||
? duplicateStringValue(other.cstr_, other.storage_.length_)
|
||||
: other.cstr_);
|
||||
storage_.policy_ = static_cast<unsigned>(other.cstr_
|
||||
? (static_cast<DuplicationPolicy>(other.storage_.policy_) == noDuplication
|
||||
? noDuplication : duplicate)
|
||||
: static_cast<DuplicationPolicy>(other.storage_.policy_));
|
||||
: static_cast<DuplicationPolicy>(other.storage_.policy_)) & 3U;
|
||||
storage_.length_ = other.storage_.length_;
|
||||
}
|
||||
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
Value::CZString::CZString(CZString&& other)
|
||||
: cstr_(other.cstr_), index_(other.index_) {
|
||||
other.cstr_ = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
Value::CZString::~CZString() {
|
||||
if (cstr_ && storage_.policy_ == duplicate)
|
||||
releaseStringValue(const_cast<char*>(cstr_));
|
||||
if (cstr_ && storage_.policy_ == duplicate) {
|
||||
releaseStringValue(const_cast<char*>(cstr_), storage_.length_ + 1u); //+1 for null terminating character for sake of completeness but not actually necessary
|
||||
}
|
||||
}
|
||||
|
||||
void Value::CZString::swap(CZString& other) {
|
||||
@@ -250,18 +292,29 @@ void Value::CZString::swap(CZString& other) {
|
||||
std::swap(index_, other.index_);
|
||||
}
|
||||
|
||||
Value::CZString& Value::CZString::operator=(CZString other) {
|
||||
swap(other);
|
||||
Value::CZString& Value::CZString::operator=(const CZString& other) {
|
||||
cstr_ = other.cstr_;
|
||||
index_ = other.index_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
Value::CZString& Value::CZString::operator=(CZString&& other) {
|
||||
cstr_ = other.cstr_;
|
||||
index_ = other.index_;
|
||||
other.cstr_ = nullptr;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Value::CZString::operator<(const CZString& other) const {
|
||||
if (!cstr_) return index_ < other.index_;
|
||||
//return strcmp(cstr_, other.cstr_) < 0;
|
||||
// Assume both are strings.
|
||||
unsigned this_len = this->storage_.length_;
|
||||
unsigned other_len = other.storage_.length_;
|
||||
unsigned min_len = std::min(this_len, other_len);
|
||||
unsigned min_len = std::min<unsigned>(this_len, other_len);
|
||||
JSON_ASSERT(this->cstr_ && other.cstr_);
|
||||
int comp = memcmp(this->cstr_, other.cstr_, min_len);
|
||||
if (comp < 0) return true;
|
||||
if (comp > 0) return false;
|
||||
@@ -275,6 +328,7 @@ bool Value::CZString::operator==(const CZString& other) const {
|
||||
unsigned this_len = this->storage_.length_;
|
||||
unsigned other_len = other.storage_.length_;
|
||||
if (this_len != other_len) return false;
|
||||
JSON_ASSERT(this->cstr_ && other.cstr_);
|
||||
int comp = memcmp(this->cstr_, other.cstr_, this_len);
|
||||
return comp == 0;
|
||||
}
|
||||
@@ -299,6 +353,7 @@ bool Value::CZString::isStaticString() const { return storage_.policy_ == noDupl
|
||||
* This optimization is used in ValueInternalMap fast allocator.
|
||||
*/
|
||||
Value::Value(ValueType vtype) {
|
||||
static char const emptyString[] = "";
|
||||
initBasic(vtype);
|
||||
switch (vtype) {
|
||||
case nullValue:
|
||||
@@ -311,7 +366,8 @@ Value::Value(ValueType vtype) {
|
||||
value_.real_ = 0.0;
|
||||
break;
|
||||
case stringValue:
|
||||
value_.string_ = 0;
|
||||
// allocated_ == false, so this is safe.
|
||||
value_.string_ = const_cast<char*>(static_cast<char const*>(emptyString));
|
||||
break;
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
@@ -352,6 +408,7 @@ Value::Value(double value) {
|
||||
|
||||
Value::Value(const char* value) {
|
||||
initBasic(stringValue, true);
|
||||
JSON_ASSERT_MESSAGE(value != NULL, "Null Value Passed to Value Constructor");
|
||||
value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));
|
||||
}
|
||||
|
||||
@@ -361,7 +418,7 @@ Value::Value(const char* beginValue, const char* endValue) {
|
||||
duplicateAndPrefixStringValue(beginValue, static_cast<unsigned>(endValue - beginValue));
|
||||
}
|
||||
|
||||
Value::Value(const std::string& value) {
|
||||
Value::Value(const JSONCPP_STRING& value) {
|
||||
initBasic(stringValue, true);
|
||||
value_.string_ =
|
||||
duplicateAndPrefixStringValue(value.data(), static_cast<unsigned>(value.length()));
|
||||
@@ -387,7 +444,7 @@ Value::Value(bool value) {
|
||||
Value::Value(Value const& other)
|
||||
: type_(other.type_), allocated_(false)
|
||||
,
|
||||
comments_(0)
|
||||
comments_(0), start_(other.start_), limit_(other.limit_)
|
||||
{
|
||||
switch (type_) {
|
||||
case nullValue:
|
||||
@@ -428,6 +485,14 @@ Value::Value(Value const& other)
|
||||
}
|
||||
}
|
||||
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
// Move constructor
|
||||
Value::Value(Value&& other) {
|
||||
initBasic(nullValue);
|
||||
swap(other);
|
||||
}
|
||||
#endif
|
||||
|
||||
Value::~Value() {
|
||||
switch (type_) {
|
||||
case nullValue:
|
||||
@@ -438,7 +503,7 @@ Value::~Value() {
|
||||
break;
|
||||
case stringValue:
|
||||
if (allocated_)
|
||||
releaseStringValue(value_.string_);
|
||||
releasePrefixedStringValue(value_.string_);
|
||||
break;
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
@@ -448,13 +513,13 @@ Value::~Value() {
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
|
||||
if (comments_)
|
||||
delete[] comments_;
|
||||
delete[] comments_;
|
||||
|
||||
value_.uint_ = 0;
|
||||
}
|
||||
|
||||
Value &Value::operator=(const Value &other) {
|
||||
Value temp(other);
|
||||
swap(temp);
|
||||
Value& Value::operator=(Value other) {
|
||||
swap(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -468,9 +533,24 @@ void Value::swapPayload(Value& other) {
|
||||
other.allocated_ = temp2 & 0x1;
|
||||
}
|
||||
|
||||
void Value::copyPayload(const Value& other) {
|
||||
type_ = other.type_;
|
||||
value_ = other.value_;
|
||||
allocated_ = other.allocated_;
|
||||
}
|
||||
|
||||
void Value::swap(Value& other) {
|
||||
swapPayload(other);
|
||||
std::swap(comments_, other.comments_);
|
||||
std::swap(start_, other.start_);
|
||||
std::swap(limit_, other.limit_);
|
||||
}
|
||||
|
||||
void Value::copy(const Value& other) {
|
||||
copyPayload(other);
|
||||
comments_ = other.comments_;
|
||||
start_ = other.start_;
|
||||
limit_ = other.limit_;
|
||||
}
|
||||
|
||||
ValueType Value::type() const { return type_; }
|
||||
@@ -510,7 +590,8 @@ bool Value::operator<(const Value& other) const {
|
||||
char const* other_str;
|
||||
decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
|
||||
decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str);
|
||||
unsigned min_len = std::min(this_len, other_len);
|
||||
unsigned min_len = std::min<unsigned>(this_len, other_len);
|
||||
JSON_ASSERT(this_str && other_str);
|
||||
int comp = memcmp(this_str, other_str, min_len);
|
||||
if (comp < 0) return true;
|
||||
if (comp > 0) return false;
|
||||
@@ -566,6 +647,7 @@ bool Value::operator==(const Value& other) const {
|
||||
decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
|
||||
decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str);
|
||||
if (this_len != other_len) return false;
|
||||
JSON_ASSERT(this_str && other_str);
|
||||
int comp = memcmp(this_str, other_str, this_len);
|
||||
return comp == 0;
|
||||
}
|
||||
@@ -591,6 +673,18 @@ const char* Value::asCString() const {
|
||||
return this_str;
|
||||
}
|
||||
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
unsigned Value::getCStringLength() const {
|
||||
JSON_ASSERT_MESSAGE(type_ == stringValue,
|
||||
"in Json::Value::asCString(): requires stringValue");
|
||||
if (value_.string_ == 0) return 0;
|
||||
unsigned this_len;
|
||||
char const* this_str;
|
||||
decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
|
||||
return this_len;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Value::getString(char const** str, char const** cend) const {
|
||||
if (type_ != stringValue) return false;
|
||||
if (value_.string_ == 0) return false;
|
||||
@@ -600,7 +694,7 @@ bool Value::getString(char const** str, char const** cend) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Value::asString() const {
|
||||
JSONCPP_STRING Value::asString() const {
|
||||
switch (type_) {
|
||||
case nullValue:
|
||||
return "";
|
||||
@@ -610,7 +704,7 @@ std::string Value::asString() const {
|
||||
unsigned this_len;
|
||||
char const* this_str;
|
||||
decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
|
||||
return std::string(this_str, this_len);
|
||||
return JSONCPP_STRING(this_str, this_len);
|
||||
}
|
||||
case booleanValue:
|
||||
return value_.bool_ ? "true" : "false";
|
||||
@@ -770,7 +864,8 @@ float Value::asFloat() const {
|
||||
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||
return static_cast<float>(value_.uint_);
|
||||
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||
return integerToDouble(value_.uint_);
|
||||
// This can fail (silently?) if the value is bigger than MAX_FLOAT.
|
||||
return static_cast<float>(integerToDouble(value_.uint_));
|
||||
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||
case realValue:
|
||||
return static_cast<float>(value_.real_);
|
||||
@@ -808,7 +903,7 @@ bool Value::isConvertibleTo(ValueType other) const {
|
||||
case nullValue:
|
||||
return (isNumeric() && asDouble() == 0.0) ||
|
||||
(type_ == booleanValue && value_.bool_ == false) ||
|
||||
(type_ == stringValue && asString() == "") ||
|
||||
(type_ == stringValue && asString().empty()) ||
|
||||
(type_ == arrayValue && value_.map_->size() == 0) ||
|
||||
(type_ == objectValue && value_.map_->size() == 0) ||
|
||||
type_ == nullValue;
|
||||
@@ -873,6 +968,8 @@ void Value::clear() {
|
||||
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue ||
|
||||
type_ == objectValue,
|
||||
"in Json::Value::clear(): requires complex value");
|
||||
start_ = 0;
|
||||
limit_ = 0;
|
||||
switch (type_) {
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
@@ -897,7 +994,7 @@ void Value::resize(ArrayIndex newSize) {
|
||||
for (ArrayIndex index = newSize; index < oldSize; ++index) {
|
||||
value_.map_->erase(index);
|
||||
}
|
||||
assert(size() == newSize);
|
||||
JSON_ASSERT(size() == newSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,7 +1009,7 @@ Value& Value::operator[](ArrayIndex index) {
|
||||
if (it != value_.map_->end() && (*it).first == key)
|
||||
return (*it).second;
|
||||
|
||||
ObjectValues::value_type defaultValue(key, nullRef);
|
||||
ObjectValues::value_type defaultValue(key, nullSingleton());
|
||||
it = value_.map_->insert(it, defaultValue);
|
||||
return (*it).second;
|
||||
}
|
||||
@@ -929,11 +1026,11 @@ const Value& Value::operator[](ArrayIndex index) const {
|
||||
type_ == nullValue || type_ == arrayValue,
|
||||
"in Json::Value::operator[](ArrayIndex)const: requires arrayValue");
|
||||
if (type_ == nullValue)
|
||||
return nullRef;
|
||||
return nullSingleton();
|
||||
CZString key(index);
|
||||
ObjectValues::const_iterator it = value_.map_->find(key);
|
||||
if (it == value_.map_->end())
|
||||
return nullRef;
|
||||
return nullSingleton();
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
@@ -948,6 +1045,8 @@ void Value::initBasic(ValueType vtype, bool allocated) {
|
||||
type_ = vtype;
|
||||
allocated_ = allocated;
|
||||
comments_ = 0;
|
||||
start_ = 0;
|
||||
limit_ = 0;
|
||||
}
|
||||
|
||||
// Access an object value by name, create a null member if it does not exist.
|
||||
@@ -965,7 +1064,7 @@ Value& Value::resolveReference(const char* key) {
|
||||
if (it != value_.map_->end() && (*it).first == actualKey)
|
||||
return (*it).second;
|
||||
|
||||
ObjectValues::value_type defaultValue(actualKey, nullRef);
|
||||
ObjectValues::value_type defaultValue(actualKey, nullSingleton());
|
||||
it = value_.map_->insert(it, defaultValue);
|
||||
Value& value = (*it).second;
|
||||
return value;
|
||||
@@ -985,7 +1084,7 @@ Value& Value::resolveReference(char const* key, char const* cend)
|
||||
if (it != value_.map_->end() && (*it).first == actualKey)
|
||||
return (*it).second;
|
||||
|
||||
ObjectValues::value_type defaultValue(actualKey, nullRef);
|
||||
ObjectValues::value_type defaultValue(actualKey, nullSingleton());
|
||||
it = value_.map_->insert(it, defaultValue);
|
||||
Value& value = (*it).second;
|
||||
return value;
|
||||
@@ -993,7 +1092,7 @@ Value& Value::resolveReference(char const* key, char const* cend)
|
||||
|
||||
Value Value::get(ArrayIndex index, const Value& defaultValue) const {
|
||||
const Value* value = &((*this)[index]);
|
||||
return value == &nullRef ? defaultValue : *value;
|
||||
return value == &nullSingleton() ? defaultValue : *value;
|
||||
}
|
||||
|
||||
bool Value::isValidIndex(ArrayIndex index) const { return index < size(); }
|
||||
@@ -1012,13 +1111,13 @@ Value const* Value::find(char const* key, char const* cend) const
|
||||
const Value& Value::operator[](const char* key) const
|
||||
{
|
||||
Value const* found = find(key, key + strlen(key));
|
||||
if (!found) return nullRef;
|
||||
if (!found) return nullSingleton();
|
||||
return *found;
|
||||
}
|
||||
Value const& Value::operator[](std::string const& key) const
|
||||
Value const& Value::operator[](JSONCPP_STRING const& key) const
|
||||
{
|
||||
Value const* found = find(key.data(), key.data() + key.length());
|
||||
if (!found) return nullRef;
|
||||
if (!found) return nullSingleton();
|
||||
return *found;
|
||||
}
|
||||
|
||||
@@ -1026,7 +1125,7 @@ Value& Value::operator[](const char* key) {
|
||||
return resolveReference(key, key + strlen(key));
|
||||
}
|
||||
|
||||
Value& Value::operator[](const std::string& key) {
|
||||
Value& Value::operator[](const JSONCPP_STRING& key) {
|
||||
return resolveReference(key.data(), key.data() + key.length());
|
||||
}
|
||||
|
||||
@@ -1041,13 +1140,17 @@ Value& Value::operator[](const CppTL::ConstString& key) {
|
||||
Value const& Value::operator[](CppTL::ConstString const& key) const
|
||||
{
|
||||
Value const* found = find(key.c_str(), key.end_c_str());
|
||||
if (!found) return nullRef;
|
||||
if (!found) return nullSingleton();
|
||||
return *found;
|
||||
}
|
||||
#endif
|
||||
|
||||
Value& Value::append(const Value& value) { return (*this)[size()] = value; }
|
||||
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
Value& Value::append(Value&& value) { return (*this)[size()] = value; }
|
||||
#endif
|
||||
|
||||
Value Value::get(char const* key, char const* cend, Value const& defaultValue) const
|
||||
{
|
||||
Value const* found = find(key, cend);
|
||||
@@ -1057,7 +1160,7 @@ Value Value::get(char const* key, Value const& defaultValue) const
|
||||
{
|
||||
return get(key, key + strlen(key), defaultValue);
|
||||
}
|
||||
Value Value::get(std::string const& key, Value const& defaultValue) const
|
||||
Value Value::get(JSONCPP_STRING const& key, Value const& defaultValue) const
|
||||
{
|
||||
return get(key.data(), key.data() + key.length(), defaultValue);
|
||||
}
|
||||
@@ -1080,7 +1183,7 @@ bool Value::removeMember(const char* key, Value* removed)
|
||||
{
|
||||
return removeMember(key, key + strlen(key), removed);
|
||||
}
|
||||
bool Value::removeMember(std::string const& key, Value* removed)
|
||||
bool Value::removeMember(JSONCPP_STRING const& key, Value* removed)
|
||||
{
|
||||
return removeMember(key.data(), key.data() + key.length(), removed);
|
||||
}
|
||||
@@ -1089,13 +1192,13 @@ Value Value::removeMember(const char* key)
|
||||
JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
|
||||
"in Json::Value::removeMember(): requires objectValue");
|
||||
if (type_ == nullValue)
|
||||
return nullRef;
|
||||
return nullSingleton();
|
||||
|
||||
Value removed; // null
|
||||
removeMember(key, key + strlen(key), &removed);
|
||||
return removed; // still null if removeMember() did nothing
|
||||
}
|
||||
Value Value::removeMember(const std::string& key)
|
||||
Value Value::removeMember(const JSONCPP_STRING& key)
|
||||
{
|
||||
return removeMember(key.c_str());
|
||||
}
|
||||
@@ -1139,7 +1242,7 @@ bool Value::isMember(char const* key) const
|
||||
{
|
||||
return isMember(key, key + strlen(key));
|
||||
}
|
||||
bool Value::isMember(std::string const& key) const
|
||||
bool Value::isMember(JSONCPP_STRING const& key) const
|
||||
{
|
||||
return isMember(key.data(), key.data() + key.length());
|
||||
}
|
||||
@@ -1161,7 +1264,7 @@ Value::Members Value::getMemberNames() const {
|
||||
ObjectValues::const_iterator it = value_.map_->begin();
|
||||
ObjectValues::const_iterator itEnd = value_.map_->end();
|
||||
for (; it != itEnd; ++it) {
|
||||
members.push_back(std::string((*it).first.data(),
|
||||
members.push_back(JSONCPP_STRING((*it).first.data(),
|
||||
(*it).first.length()));
|
||||
}
|
||||
return members;
|
||||
@@ -1204,7 +1307,11 @@ bool Value::isBool() const { return type_ == booleanValue; }
|
||||
bool Value::isInt() const {
|
||||
switch (type_) {
|
||||
case intValue:
|
||||
#if defined(JSON_HAS_INT64)
|
||||
return value_.int_ >= minInt && value_.int_ <= maxInt;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
case uintValue:
|
||||
return value_.uint_ <= UInt(maxInt);
|
||||
case realValue:
|
||||
@@ -1219,9 +1326,17 @@ bool Value::isInt() const {
|
||||
bool Value::isUInt() const {
|
||||
switch (type_) {
|
||||
case intValue:
|
||||
#if defined(JSON_HAS_INT64)
|
||||
return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);
|
||||
#else
|
||||
return value_.int_ >= 0;
|
||||
#endif
|
||||
case uintValue:
|
||||
#if defined(JSON_HAS_INT64)
|
||||
return value_.uint_ <= maxUInt;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
case realValue:
|
||||
return value_.real_ >= 0 && value_.real_ <= maxUInt &&
|
||||
IsIntegral(value_.real_);
|
||||
@@ -1272,16 +1387,28 @@ bool Value::isUInt64() const {
|
||||
}
|
||||
|
||||
bool Value::isIntegral() const {
|
||||
switch (type_) {
|
||||
case intValue:
|
||||
case uintValue:
|
||||
return true;
|
||||
case realValue:
|
||||
#if defined(JSON_HAS_INT64)
|
||||
return isInt64() || isUInt64();
|
||||
// Note that maxUInt64 (= 2^64 - 1) is not exactly representable as a
|
||||
// double, so double(maxUInt64) will be rounded up to 2^64. Therefore we
|
||||
// require the value to be strictly less than the limit.
|
||||
return value_.real_ >= double(minInt64) && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_);
|
||||
#else
|
||||
return isInt() || isUInt();
|
||||
#endif
|
||||
return value_.real_ >= minInt && value_.real_ <= maxUInt && IsIntegral(value_.real_);
|
||||
#endif // JSON_HAS_INT64
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Value::isDouble() const { return type_ == realValue || isIntegral(); }
|
||||
bool Value::isDouble() const { return type_ == intValue || type_ == uintValue || type_ == realValue; }
|
||||
|
||||
bool Value::isNumeric() const { return isIntegral() || isDouble(); }
|
||||
bool Value::isNumeric() const { return isDouble(); }
|
||||
|
||||
bool Value::isString() const { return type_ == stringValue; }
|
||||
|
||||
@@ -1303,7 +1430,7 @@ void Value::setComment(const char* comment, CommentPlacement placement) {
|
||||
setComment(comment, strlen(comment), placement);
|
||||
}
|
||||
|
||||
void Value::setComment(const std::string& comment, CommentPlacement placement) {
|
||||
void Value::setComment(const JSONCPP_STRING& comment, CommentPlacement placement) {
|
||||
setComment(comment.c_str(), comment.length(), placement);
|
||||
}
|
||||
|
||||
@@ -1311,15 +1438,28 @@ bool Value::hasComment(CommentPlacement placement) const {
|
||||
return comments_ != 0 && comments_[placement].comment_ != 0;
|
||||
}
|
||||
|
||||
std::string Value::getComment(CommentPlacement placement) const {
|
||||
JSONCPP_STRING Value::getComment(CommentPlacement placement) const {
|
||||
if (hasComment(placement))
|
||||
return comments_[placement].comment_;
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string Value::toStyledString() const {
|
||||
StyledWriter writer;
|
||||
return writer.write(*this);
|
||||
void Value::setOffsetStart(ptrdiff_t start) { start_ = start; }
|
||||
|
||||
void Value::setOffsetLimit(ptrdiff_t limit) { limit_ = limit; }
|
||||
|
||||
ptrdiff_t Value::getOffsetStart() const { return start_; }
|
||||
|
||||
ptrdiff_t Value::getOffsetLimit() const { return limit_; }
|
||||
|
||||
JSONCPP_STRING Value::toStyledString() const {
|
||||
StreamWriterBuilder builder;
|
||||
|
||||
JSONCPP_STRING out = this->hasComment(commentBefore) ? "\n" : "";
|
||||
out += Json::writeString(builder, *this);
|
||||
out += "\n";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
Value::const_iterator Value::begin() const {
|
||||
@@ -1385,19 +1525,20 @@ PathArgument::PathArgument(ArrayIndex index)
|
||||
PathArgument::PathArgument(const char* key)
|
||||
: key_(key), index_(), kind_(kindKey) {}
|
||||
|
||||
PathArgument::PathArgument(const std::string& key)
|
||||
PathArgument::PathArgument(const JSONCPP_STRING& key)
|
||||
: key_(key.c_str()), index_(), kind_(kindKey) {}
|
||||
|
||||
// class Path
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
Path::Path(const std::string& path,
|
||||
Path::Path(const JSONCPP_STRING& path,
|
||||
const PathArgument& a1,
|
||||
const PathArgument& a2,
|
||||
const PathArgument& a3,
|
||||
const PathArgument& a4,
|
||||
const PathArgument& a5) {
|
||||
InArgs in;
|
||||
in.reserve(5);
|
||||
in.push_back(&a1);
|
||||
in.push_back(&a2);
|
||||
in.push_back(&a3);
|
||||
@@ -1406,7 +1547,7 @@ Path::Path(const std::string& path,
|
||||
makePath(path, in);
|
||||
}
|
||||
|
||||
void Path::makePath(const std::string& path, const InArgs& in) {
|
||||
void Path::makePath(const JSONCPP_STRING& path, const InArgs& in) {
|
||||
const char* current = path.c_str();
|
||||
const char* end = current + path.length();
|
||||
InArgs::const_iterator itInArg = in.begin();
|
||||
@@ -1421,23 +1562,23 @@ void Path::makePath(const std::string& path, const InArgs& in) {
|
||||
index = index * 10 + ArrayIndex(*current - '0');
|
||||
args_.push_back(index);
|
||||
}
|
||||
if (current == end || *current++ != ']')
|
||||
if (current == end || *++current != ']')
|
||||
invalidPath(path, int(current - path.c_str()));
|
||||
} else if (*current == '%') {
|
||||
addPathInArg(path, in, itInArg, PathArgument::kindKey);
|
||||
++current;
|
||||
} else if (*current == '.') {
|
||||
} else if (*current == '.' || *current == ']') {
|
||||
++current;
|
||||
} else {
|
||||
const char* beginName = current;
|
||||
while (current != end && !strchr("[.", *current))
|
||||
++current;
|
||||
args_.push_back(std::string(beginName, current));
|
||||
args_.push_back(JSONCPP_STRING(beginName, current));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Path::addPathInArg(const std::string& /*path*/,
|
||||
void Path::addPathInArg(const JSONCPP_STRING& /*path*/,
|
||||
const InArgs& in,
|
||||
InArgs::const_iterator& itInArg,
|
||||
PathArgument::Kind kind) {
|
||||
@@ -1446,11 +1587,11 @@ void Path::addPathInArg(const std::string& /*path*/,
|
||||
} else if ((*itInArg)->kind_ != kind) {
|
||||
// Error: bad argument type
|
||||
} else {
|
||||
args_.push_back(**itInArg);
|
||||
args_.push_back(**itInArg++);
|
||||
}
|
||||
}
|
||||
|
||||
void Path::invalidPath(const std::string& /*path*/, int /*location*/) {
|
||||
void Path::invalidPath(const JSONCPP_STRING& /*path*/, int /*location*/) {
|
||||
// Error: invalid path.
|
||||
}
|
||||
|
||||
@@ -1461,16 +1602,19 @@ const Value& Path::resolve(const Value& root) const {
|
||||
if (arg.kind_ == PathArgument::kindIndex) {
|
||||
if (!node->isArray() || !node->isValidIndex(arg.index_)) {
|
||||
// Error: unable to resolve path (array value expected at position...
|
||||
return Value::null;
|
||||
}
|
||||
node = &((*node)[arg.index_]);
|
||||
} else if (arg.kind_ == PathArgument::kindKey) {
|
||||
if (!node->isObject()) {
|
||||
// Error: unable to resolve path (object value expected at position...)
|
||||
return Value::null;
|
||||
}
|
||||
node = &((*node)[arg.key_]);
|
||||
if (node == &Value::nullRef) {
|
||||
if (node == &Value::nullSingleton()) {
|
||||
// Error: unable to resolve path (object has no member named '' at
|
||||
// position...)
|
||||
return Value::null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1489,7 +1633,7 @@ Value Path::resolve(const Value& root, const Value& defaultValue) const {
|
||||
if (!node->isObject())
|
||||
return defaultValue;
|
||||
node = &((*node)[arg.key_]);
|
||||
if (node == &Value::nullRef)
|
||||
if (node == &Value::nullSingleton())
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
@@ -92,12 +92,12 @@ UInt ValueIteratorBase::index() const {
|
||||
return Value::UInt(-1);
|
||||
}
|
||||
|
||||
std::string ValueIteratorBase::name() const {
|
||||
JSONCPP_STRING ValueIteratorBase::name() const {
|
||||
char const* keey;
|
||||
char const* end;
|
||||
keey = memberName(&end);
|
||||
if (!keey) return std::string();
|
||||
return std::string(keey, end);
|
||||
if (!keey) return JSONCPP_STRING();
|
||||
return JSONCPP_STRING(keey, end);
|
||||
}
|
||||
|
||||
char const* ValueIteratorBase::memberName() const {
|
||||
@@ -129,6 +129,9 @@ ValueConstIterator::ValueConstIterator(
|
||||
const Value::ObjectValues::iterator& current)
|
||||
: ValueIteratorBase(current) {}
|
||||
|
||||
ValueConstIterator::ValueConstIterator(ValueIterator const& other)
|
||||
: ValueIteratorBase(other) {}
|
||||
|
||||
ValueConstIterator& ValueConstIterator::
|
||||
operator=(const ValueIteratorBase& other) {
|
||||
copy(other);
|
||||
@@ -149,7 +152,9 @@ ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)
|
||||
: ValueIteratorBase(current) {}
|
||||
|
||||
ValueIterator::ValueIterator(const ValueConstIterator& other)
|
||||
: ValueIteratorBase(other) {}
|
||||
: ValueIteratorBase(other) {
|
||||
throwRuntimeError("ConstIterator to Iterator should never be allowed.");
|
||||
}
|
||||
|
||||
ValueIterator::ValueIterator(const ValueIterator& other)
|
||||
: ValueIteratorBase(other) {}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2011 Baptiste Lepilleur
|
||||
// Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
@@ -16,33 +16,51 @@
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1800 // Between VC++ 6.0 and VC++ 11.0
|
||||
#include <float.h>
|
||||
#define isfinite _finite
|
||||
#elif defined(__sun) && defined(__SVR4) //Solaris
|
||||
#if !defined(isfinite)
|
||||
#include <ieeefp.h>
|
||||
#define isfinite finite
|
||||
#endif
|
||||
#elif defined(_AIX)
|
||||
#if !defined(isfinite)
|
||||
#include <math.h>
|
||||
#define isfinite finite
|
||||
#endif
|
||||
#elif defined(__hpux)
|
||||
#if !defined(isfinite)
|
||||
#if defined(__ia64) && !defined(finite)
|
||||
#define isfinite(x) ((sizeof(x) == sizeof(float) ? \
|
||||
_Isfinitef(x) : _IsFinite(x)))
|
||||
#else
|
||||
#include <math.h>
|
||||
#define isfinite finite
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#include <cmath>
|
||||
#if !(defined(__QNXNTO__)) // QNX already defines isfinite
|
||||
#define isfinite std::isfinite
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
|
||||
#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__)
|
||||
#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>
|
||||
@@ -57,10 +75,10 @@
|
||||
|
||||
namespace Json {
|
||||
|
||||
#if JSON_HAS_UNIQUE_PTR
|
||||
typedef std::unique_ptr<StreamWriter> const StreamWriterPtr;
|
||||
#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
|
||||
typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
|
||||
#else
|
||||
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
|
||||
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
|
||||
#endif
|
||||
|
||||
static bool containsControlCharacter(const char* str) {
|
||||
@@ -81,7 +99,7 @@ static bool containsControlCharacter0(const char* str, unsigned len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string valueToString(LargestInt value) {
|
||||
JSONCPP_STRING valueToString(LargestInt value) {
|
||||
UIntToStringBuffer buffer;
|
||||
char* current = buffer + sizeof(buffer);
|
||||
if (value == Value::minLargestInt) {
|
||||
@@ -97,7 +115,7 @@ std::string valueToString(LargestInt value) {
|
||||
return current;
|
||||
}
|
||||
|
||||
std::string valueToString(LargestUInt value) {
|
||||
JSONCPP_STRING valueToString(LargestUInt value) {
|
||||
UIntToStringBuffer buffer;
|
||||
char* current = buffer + sizeof(buffer);
|
||||
uintToString(value, current);
|
||||
@@ -107,30 +125,38 @@ std::string valueToString(LargestUInt value) {
|
||||
|
||||
#if defined(JSON_HAS_INT64)
|
||||
|
||||
std::string valueToString(Int value) {
|
||||
JSONCPP_STRING valueToString(Int value) {
|
||||
return valueToString(LargestInt(value));
|
||||
}
|
||||
|
||||
std::string valueToString(UInt value) {
|
||||
JSONCPP_STRING valueToString(UInt value) {
|
||||
return valueToString(LargestUInt(value));
|
||||
}
|
||||
|
||||
#endif // # if defined(JSON_HAS_INT64)
|
||||
|
||||
std::string valueToString(double value, bool useSpecialFloats, unsigned int precision) {
|
||||
namespace {
|
||||
JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int precision) {
|
||||
// Allocate a buffer that is more than large enough to store the 16 digits of
|
||||
// precision requested below.
|
||||
char buffer[32];
|
||||
char buffer[36];
|
||||
int len = -1;
|
||||
|
||||
char formatString[6];
|
||||
sprintf(formatString, "%%.%dg", precision);
|
||||
char formatString[15];
|
||||
snprintf(formatString, sizeof(formatString), "%%.%dg", precision);
|
||||
|
||||
// Print into the buffer. We need not request the alternative representation
|
||||
// that always has a decimal point because JSON doesn't distingish the
|
||||
// concepts of reals and integers.
|
||||
if (isfinite(value)) {
|
||||
len = snprintf(buffer, sizeof(buffer), formatString, value);
|
||||
fixNumericLocale(buffer, buffer + len);
|
||||
|
||||
// try to ensure we preserve the fact that this was given to us as a double on input
|
||||
if (!strchr(buffer, '.') && !strchr(buffer, 'e')) {
|
||||
strcat(buffer, ".0");
|
||||
}
|
||||
|
||||
} else {
|
||||
// IEEE standard states that NaN values will not compare to themselves
|
||||
if (value != value) {
|
||||
@@ -140,30 +166,29 @@ std::string valueToString(double value, bool useSpecialFloats, unsigned int prec
|
||||
} else {
|
||||
len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "Infinity" : "1e+9999");
|
||||
}
|
||||
// For those, we do not need to call fixNumLoc, but it is fast.
|
||||
}
|
||||
assert(len >= 0);
|
||||
fixNumericLocale(buffer, buffer + len);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
std::string valueToString(double value) { return valueToString(value, false, 17); }
|
||||
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)
|
||||
return "";
|
||||
// Not sure how to handle unicode...
|
||||
if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL &&
|
||||
!containsControlCharacter(value))
|
||||
return std::string("\"") + value + "\"";
|
||||
return JSONCPP_STRING("\"") + value + "\"";
|
||||
// We have to walk value and escape any special characters.
|
||||
// Appending to std::string is not efficient, but this should be rare.
|
||||
// Appending to JSONCPP_STRING is not efficient, but this should be rare.
|
||||
// (Note: forward slashes are *not* rare, but I am not escaping them.)
|
||||
std::string::size_type maxsize =
|
||||
JSONCPP_STRING::size_type maxsize =
|
||||
strlen(value) * 2 + 3; // allescaped+quotes+NULL
|
||||
std::string result;
|
||||
JSONCPP_STRING result;
|
||||
result.reserve(maxsize); // to avoid lots of mallocs
|
||||
result += "\"";
|
||||
for (const char* c = value; *c != 0; ++c) {
|
||||
@@ -199,7 +224,7 @@ std::string valueToQuotedString(const char* value) {
|
||||
// sequence from occurring.
|
||||
default:
|
||||
if (isControlCharacter(*c)) {
|
||||
std::ostringstream oss;
|
||||
JSONCPP_OSTRINGSTREAM oss;
|
||||
oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
|
||||
<< std::setw(4) << static_cast<int>(*c);
|
||||
result += oss.str();
|
||||
@@ -228,19 +253,19 @@ static char const* strnpbrk(char const* s, char const* accept, size_t n) {
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
static std::string valueToQuotedStringN(const char* value, unsigned length) {
|
||||
static JSONCPP_STRING valueToQuotedStringN(const char* value, unsigned length) {
|
||||
if (value == NULL)
|
||||
return "";
|
||||
// Not sure how to handle unicode...
|
||||
if (strnpbrk(value, "\"\\\b\f\n\r\t", length) == NULL &&
|
||||
!containsControlCharacter0(value, length))
|
||||
return std::string("\"") + value + "\"";
|
||||
return JSONCPP_STRING("\"") + value + "\"";
|
||||
// We have to walk value and escape any special characters.
|
||||
// Appending to std::string is not efficient, but this should be rare.
|
||||
// Appending to JSONCPP_STRING is not efficient, but this should be rare.
|
||||
// (Note: forward slashes are *not* rare, but I am not escaping them.)
|
||||
std::string::size_type maxsize =
|
||||
JSONCPP_STRING::size_type maxsize =
|
||||
length * 2 + 3; // allescaped+quotes+NULL
|
||||
std::string result;
|
||||
JSONCPP_STRING result;
|
||||
result.reserve(maxsize); // to avoid lots of mallocs
|
||||
result += "\"";
|
||||
char const* end = value + length;
|
||||
@@ -277,7 +302,7 @@ static std::string valueToQuotedStringN(const char* value, unsigned length) {
|
||||
// sequence from occurring.
|
||||
default:
|
||||
if ((isControlCharacter(*c)) || (*c == 0)) {
|
||||
std::ostringstream oss;
|
||||
JSONCPP_OSTRINGSTREAM oss;
|
||||
oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
|
||||
<< std::setw(4) << static_cast<int>(*c);
|
||||
result += oss.str();
|
||||
@@ -299,21 +324,28 @@ Writer::~Writer() {}
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
FastWriter::FastWriter()
|
||||
: yamlCompatiblityEnabled_(false) {}
|
||||
: yamlCompatiblityEnabled_(false), dropNullPlaceholders_(false),
|
||||
omitEndingLineFeed_(false) {}
|
||||
|
||||
void FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; }
|
||||
|
||||
std::string FastWriter::write(const Value& root) {
|
||||
document_ = "";
|
||||
void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
|
||||
|
||||
void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
|
||||
|
||||
JSONCPP_STRING FastWriter::write(const Value& root) {
|
||||
document_.clear();
|
||||
writeValue(root);
|
||||
document_ += "\n";
|
||||
if (!omitEndingLineFeed_)
|
||||
document_ += "\n";
|
||||
return document_;
|
||||
}
|
||||
|
||||
void FastWriter::writeValue(const Value& value) {
|
||||
switch (value.type()) {
|
||||
case nullValue:
|
||||
document_ += "null";
|
||||
if (!dropNullPlaceholders_)
|
||||
document_ += "null";
|
||||
break;
|
||||
case intValue:
|
||||
document_ += valueToString(value.asLargestInt());
|
||||
@@ -326,7 +358,7 @@ void FastWriter::writeValue(const Value& value) {
|
||||
break;
|
||||
case stringValue:
|
||||
{
|
||||
// Is NULL possible for value.string_?
|
||||
// Is NULL possible for value.string_? No.
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
@@ -338,8 +370,8 @@ void FastWriter::writeValue(const Value& value) {
|
||||
break;
|
||||
case arrayValue: {
|
||||
document_ += '[';
|
||||
int size = value.size();
|
||||
for (int index = 0; index < size; ++index) {
|
||||
ArrayIndex size = value.size();
|
||||
for (ArrayIndex index = 0; index < size; ++index) {
|
||||
if (index > 0)
|
||||
document_ += ',';
|
||||
writeValue(value[index]);
|
||||
@@ -351,7 +383,7 @@ void FastWriter::writeValue(const Value& value) {
|
||||
document_ += '{';
|
||||
for (Value::Members::iterator it = members.begin(); it != members.end();
|
||||
++it) {
|
||||
const std::string& name = *it;
|
||||
const JSONCPP_STRING& name = *it;
|
||||
if (it != members.begin())
|
||||
document_ += ',';
|
||||
document_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length()));
|
||||
@@ -369,10 +401,10 @@ void FastWriter::writeValue(const Value& value) {
|
||||
StyledWriter::StyledWriter()
|
||||
: rightMargin_(74), indentSize_(3), addChildValues_() {}
|
||||
|
||||
std::string StyledWriter::write(const Value& root) {
|
||||
document_ = "";
|
||||
JSONCPP_STRING StyledWriter::write(const Value& root) {
|
||||
document_.clear();
|
||||
addChildValues_ = false;
|
||||
indentString_ = "";
|
||||
indentString_.clear();
|
||||
writeCommentBeforeValue(root);
|
||||
writeValue(root);
|
||||
writeCommentAfterValueOnSameLine(root);
|
||||
@@ -396,7 +428,7 @@ void StyledWriter::writeValue(const Value& value) {
|
||||
break;
|
||||
case stringValue:
|
||||
{
|
||||
// Is NULL possible for value.string_?
|
||||
// Is NULL possible for value.string_? No.
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
@@ -419,7 +451,7 @@ void StyledWriter::writeValue(const Value& value) {
|
||||
indent();
|
||||
Value::Members::iterator it = members.begin();
|
||||
for (;;) {
|
||||
const std::string& name = *it;
|
||||
const JSONCPP_STRING& name = *it;
|
||||
const Value& childValue = value[name];
|
||||
writeCommentBeforeValue(childValue);
|
||||
writeWithIndent(valueToQuotedString(name.c_str()));
|
||||
@@ -483,26 +515,25 @@ void StyledWriter::writeArrayValue(const Value& value) {
|
||||
}
|
||||
|
||||
bool StyledWriter::isMultineArray(const Value& value) {
|
||||
int size = value.size();
|
||||
ArrayIndex const size = value.size();
|
||||
bool isMultiLine = size * 3 >= rightMargin_;
|
||||
childValues_.clear();
|
||||
for (int index = 0; index < size && !isMultiLine; ++index) {
|
||||
for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
|
||||
const Value& childValue = value[index];
|
||||
isMultiLine =
|
||||
isMultiLine || ((childValue.isArray() || childValue.isObject()) &&
|
||||
isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
|
||||
childValue.size() > 0);
|
||||
}
|
||||
if (!isMultiLine) // check if line length > max line length
|
||||
{
|
||||
childValues_.reserve(size);
|
||||
addChildValues_ = true;
|
||||
int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||
for (int index = 0; index < size; ++index) {
|
||||
ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||
for (ArrayIndex index = 0; index < size; ++index) {
|
||||
if (hasCommentForValue(value[index])) {
|
||||
isMultiLine = true;
|
||||
}
|
||||
writeValue(value[index]);
|
||||
lineLength += int(childValues_[index].length());
|
||||
lineLength += static_cast<ArrayIndex>(childValues_[index].length());
|
||||
}
|
||||
addChildValues_ = false;
|
||||
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
||||
@@ -510,7 +541,7 @@ bool StyledWriter::isMultineArray(const Value& value) {
|
||||
return isMultiLine;
|
||||
}
|
||||
|
||||
void StyledWriter::pushValue(const std::string& value) {
|
||||
void StyledWriter::pushValue(const JSONCPP_STRING& value) {
|
||||
if (addChildValues_)
|
||||
childValues_.push_back(value);
|
||||
else
|
||||
@@ -528,15 +559,15 @@ void StyledWriter::writeIndent() {
|
||||
document_ += indentString_;
|
||||
}
|
||||
|
||||
void StyledWriter::writeWithIndent(const std::string& value) {
|
||||
void StyledWriter::writeWithIndent(const JSONCPP_STRING& value) {
|
||||
writeIndent();
|
||||
document_ += value;
|
||||
}
|
||||
|
||||
void StyledWriter::indent() { indentString_ += std::string(indentSize_, ' '); }
|
||||
void StyledWriter::indent() { indentString_ += JSONCPP_STRING(indentSize_, ' '); }
|
||||
|
||||
void StyledWriter::unindent() {
|
||||
assert(int(indentString_.size()) >= indentSize_);
|
||||
assert(indentString_.size() >= indentSize_);
|
||||
indentString_.resize(indentString_.size() - indentSize_);
|
||||
}
|
||||
|
||||
@@ -546,8 +577,8 @@ void StyledWriter::writeCommentBeforeValue(const Value& root) {
|
||||
|
||||
document_ += "\n";
|
||||
writeIndent();
|
||||
const std::string& comment = root.getComment(commentBefore);
|
||||
std::string::const_iterator iter = comment.begin();
|
||||
const JSONCPP_STRING& comment = root.getComment(commentBefore);
|
||||
JSONCPP_STRING::const_iterator iter = comment.begin();
|
||||
while (iter != comment.end()) {
|
||||
document_ += *iter;
|
||||
if (*iter == '\n' &&
|
||||
@@ -580,14 +611,14 @@ bool StyledWriter::hasCommentForValue(const Value& value) {
|
||||
// Class StyledStreamWriter
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
StyledStreamWriter::StyledStreamWriter(std::string indentation)
|
||||
StyledStreamWriter::StyledStreamWriter(JSONCPP_STRING indentation)
|
||||
: document_(NULL), rightMargin_(74), indentation_(indentation),
|
||||
addChildValues_() {}
|
||||
|
||||
void StyledStreamWriter::write(std::ostream& out, const Value& root) {
|
||||
void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
|
||||
document_ = &out;
|
||||
addChildValues_ = false;
|
||||
indentString_ = "";
|
||||
indentString_.clear();
|
||||
indented_ = true;
|
||||
writeCommentBeforeValue(root);
|
||||
if (!indented_) writeIndent();
|
||||
@@ -614,7 +645,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
|
||||
break;
|
||||
case stringValue:
|
||||
{
|
||||
// Is NULL possible for value.string_?
|
||||
// Is NULL possible for value.string_? No.
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
@@ -637,7 +668,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
|
||||
indent();
|
||||
Value::Members::iterator it = members.begin();
|
||||
for (;;) {
|
||||
const std::string& name = *it;
|
||||
const JSONCPP_STRING& name = *it;
|
||||
const Value& childValue = value[name];
|
||||
writeCommentBeforeValue(childValue);
|
||||
writeWithIndent(valueToQuotedString(name.c_str()));
|
||||
@@ -703,26 +734,25 @@ void StyledStreamWriter::writeArrayValue(const Value& value) {
|
||||
}
|
||||
|
||||
bool StyledStreamWriter::isMultineArray(const Value& value) {
|
||||
int size = value.size();
|
||||
ArrayIndex const size = value.size();
|
||||
bool isMultiLine = size * 3 >= rightMargin_;
|
||||
childValues_.clear();
|
||||
for (int index = 0; index < size && !isMultiLine; ++index) {
|
||||
for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
|
||||
const Value& childValue = value[index];
|
||||
isMultiLine =
|
||||
isMultiLine || ((childValue.isArray() || childValue.isObject()) &&
|
||||
isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
|
||||
childValue.size() > 0);
|
||||
}
|
||||
if (!isMultiLine) // check if line length > max line length
|
||||
{
|
||||
childValues_.reserve(size);
|
||||
addChildValues_ = true;
|
||||
int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||
for (int index = 0; index < size; ++index) {
|
||||
ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||
for (ArrayIndex index = 0; index < size; ++index) {
|
||||
if (hasCommentForValue(value[index])) {
|
||||
isMultiLine = true;
|
||||
}
|
||||
writeValue(value[index]);
|
||||
lineLength += int(childValues_[index].length());
|
||||
lineLength += static_cast<ArrayIndex>(childValues_[index].length());
|
||||
}
|
||||
addChildValues_ = false;
|
||||
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
||||
@@ -730,7 +760,7 @@ bool StyledStreamWriter::isMultineArray(const Value& value) {
|
||||
return isMultiLine;
|
||||
}
|
||||
|
||||
void StyledStreamWriter::pushValue(const std::string& value) {
|
||||
void StyledStreamWriter::pushValue(const JSONCPP_STRING& value) {
|
||||
if (addChildValues_)
|
||||
childValues_.push_back(value);
|
||||
else
|
||||
@@ -745,7 +775,7 @@ void StyledStreamWriter::writeIndent() {
|
||||
*document_ << '\n' << indentString_;
|
||||
}
|
||||
|
||||
void StyledStreamWriter::writeWithIndent(const std::string& value) {
|
||||
void StyledStreamWriter::writeWithIndent(const JSONCPP_STRING& value) {
|
||||
if (!indented_) writeIndent();
|
||||
*document_ << value;
|
||||
indented_ = false;
|
||||
@@ -763,8 +793,8 @@ void StyledStreamWriter::writeCommentBeforeValue(const Value& root) {
|
||||
return;
|
||||
|
||||
if (!indented_) writeIndent();
|
||||
const std::string& comment = root.getComment(commentBefore);
|
||||
std::string::const_iterator iter = comment.begin();
|
||||
const JSONCPP_STRING& comment = root.getComment(commentBefore);
|
||||
JSONCPP_STRING::const_iterator iter = comment.begin();
|
||||
while (iter != comment.end()) {
|
||||
*document_ << *iter;
|
||||
if (*iter == '\n' &&
|
||||
@@ -809,48 +839,48 @@ struct CommentStyle {
|
||||
struct BuiltStyledStreamWriter : public StreamWriter
|
||||
{
|
||||
BuiltStyledStreamWriter(
|
||||
std::string const& indentation,
|
||||
JSONCPP_STRING const& indentation,
|
||||
CommentStyle::Enum cs,
|
||||
std::string const& colonSymbol,
|
||||
std::string const& nullSymbol,
|
||||
std::string const& endingLineFeedSymbol,
|
||||
JSONCPP_STRING const& colonSymbol,
|
||||
JSONCPP_STRING const& nullSymbol,
|
||||
JSONCPP_STRING const& endingLineFeedSymbol,
|
||||
bool useSpecialFloats,
|
||||
unsigned int precision);
|
||||
virtual int write(Value const& root, std::ostream* sout);
|
||||
int write(Value const& root, JSONCPP_OSTREAM* sout) JSONCPP_OVERRIDE;
|
||||
private:
|
||||
void writeValue(Value const& value);
|
||||
void writeArrayValue(Value const& value);
|
||||
bool isMultineArray(Value const& value);
|
||||
void pushValue(std::string const& value);
|
||||
void pushValue(JSONCPP_STRING const& value);
|
||||
void writeIndent();
|
||||
void writeWithIndent(std::string const& value);
|
||||
void writeWithIndent(JSONCPP_STRING const& value);
|
||||
void indent();
|
||||
void unindent();
|
||||
void writeCommentBeforeValue(Value const& root);
|
||||
void writeCommentAfterValueOnSameLine(Value const& root);
|
||||
static bool hasCommentForValue(const Value& value);
|
||||
|
||||
typedef std::vector<std::string> ChildValues;
|
||||
typedef std::vector<JSONCPP_STRING> ChildValues;
|
||||
|
||||
ChildValues childValues_;
|
||||
std::string indentString_;
|
||||
int rightMargin_;
|
||||
std::string indentation_;
|
||||
JSONCPP_STRING indentString_;
|
||||
unsigned int rightMargin_;
|
||||
JSONCPP_STRING indentation_;
|
||||
CommentStyle::Enum cs_;
|
||||
std::string colonSymbol_;
|
||||
std::string nullSymbol_;
|
||||
std::string endingLineFeedSymbol_;
|
||||
JSONCPP_STRING colonSymbol_;
|
||||
JSONCPP_STRING nullSymbol_;
|
||||
JSONCPP_STRING endingLineFeedSymbol_;
|
||||
bool addChildValues_ : 1;
|
||||
bool indented_ : 1;
|
||||
bool useSpecialFloats_ : 1;
|
||||
unsigned int precision_;
|
||||
};
|
||||
BuiltStyledStreamWriter::BuiltStyledStreamWriter(
|
||||
std::string const& indentation,
|
||||
JSONCPP_STRING const& indentation,
|
||||
CommentStyle::Enum cs,
|
||||
std::string const& colonSymbol,
|
||||
std::string const& nullSymbol,
|
||||
std::string const& endingLineFeedSymbol,
|
||||
JSONCPP_STRING const& colonSymbol,
|
||||
JSONCPP_STRING const& nullSymbol,
|
||||
JSONCPP_STRING const& endingLineFeedSymbol,
|
||||
bool useSpecialFloats,
|
||||
unsigned int precision)
|
||||
: rightMargin_(74)
|
||||
@@ -865,12 +895,12 @@ BuiltStyledStreamWriter::BuiltStyledStreamWriter(
|
||||
, precision_(precision)
|
||||
{
|
||||
}
|
||||
int BuiltStyledStreamWriter::write(Value const& root, std::ostream* sout)
|
||||
int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout)
|
||||
{
|
||||
sout_ = sout;
|
||||
addChildValues_ = false;
|
||||
indented_ = true;
|
||||
indentString_ = "";
|
||||
indentString_.clear();
|
||||
writeCommentBeforeValue(root);
|
||||
if (!indented_) writeIndent();
|
||||
indented_ = true;
|
||||
@@ -896,7 +926,7 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
|
||||
break;
|
||||
case stringValue:
|
||||
{
|
||||
// Is NULL is possible for value.string_?
|
||||
// Is NULL is possible for value.string_? No.
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
@@ -919,7 +949,7 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
|
||||
indent();
|
||||
Value::Members::iterator it = members.begin();
|
||||
for (;;) {
|
||||
std::string const& name = *it;
|
||||
JSONCPP_STRING const& name = *it;
|
||||
Value const& childValue = value[name];
|
||||
writeCommentBeforeValue(childValue);
|
||||
writeWithIndent(valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length())));
|
||||
@@ -977,7 +1007,7 @@ void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
|
||||
if (!indentation_.empty()) *sout_ << " ";
|
||||
for (unsigned index = 0; index < size; ++index) {
|
||||
if (index > 0)
|
||||
*sout_ << ", ";
|
||||
*sout_ << ((!indentation_.empty()) ? ", " : ",");
|
||||
*sout_ << childValues_[index];
|
||||
}
|
||||
if (!indentation_.empty()) *sout_ << " ";
|
||||
@@ -987,26 +1017,25 @@ void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
|
||||
}
|
||||
|
||||
bool BuiltStyledStreamWriter::isMultineArray(Value const& value) {
|
||||
int size = value.size();
|
||||
ArrayIndex const size = value.size();
|
||||
bool isMultiLine = size * 3 >= rightMargin_;
|
||||
childValues_.clear();
|
||||
for (int index = 0; index < size && !isMultiLine; ++index) {
|
||||
for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
|
||||
Value const& childValue = value[index];
|
||||
isMultiLine =
|
||||
isMultiLine || ((childValue.isArray() || childValue.isObject()) &&
|
||||
isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
|
||||
childValue.size() > 0);
|
||||
}
|
||||
if (!isMultiLine) // check if line length > max line length
|
||||
{
|
||||
childValues_.reserve(size);
|
||||
addChildValues_ = true;
|
||||
int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||
for (int index = 0; index < size; ++index) {
|
||||
ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
|
||||
for (ArrayIndex index = 0; index < size; ++index) {
|
||||
if (hasCommentForValue(value[index])) {
|
||||
isMultiLine = true;
|
||||
}
|
||||
writeValue(value[index]);
|
||||
lineLength += int(childValues_[index].length());
|
||||
lineLength += static_cast<ArrayIndex>(childValues_[index].length());
|
||||
}
|
||||
addChildValues_ = false;
|
||||
isMultiLine = isMultiLine || lineLength >= rightMargin_;
|
||||
@@ -1014,7 +1043,7 @@ bool BuiltStyledStreamWriter::isMultineArray(Value const& value) {
|
||||
return isMultiLine;
|
||||
}
|
||||
|
||||
void BuiltStyledStreamWriter::pushValue(std::string const& value) {
|
||||
void BuiltStyledStreamWriter::pushValue(JSONCPP_STRING const& value) {
|
||||
if (addChildValues_)
|
||||
childValues_.push_back(value);
|
||||
else
|
||||
@@ -1033,7 +1062,7 @@ void BuiltStyledStreamWriter::writeIndent() {
|
||||
}
|
||||
}
|
||||
|
||||
void BuiltStyledStreamWriter::writeWithIndent(std::string const& value) {
|
||||
void BuiltStyledStreamWriter::writeWithIndent(JSONCPP_STRING const& value) {
|
||||
if (!indented_) writeIndent();
|
||||
*sout_ << value;
|
||||
indented_ = false;
|
||||
@@ -1052,8 +1081,8 @@ void BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root) {
|
||||
return;
|
||||
|
||||
if (!indented_) writeIndent();
|
||||
const std::string& comment = root.getComment(commentBefore);
|
||||
std::string::const_iterator iter = comment.begin();
|
||||
const JSONCPP_STRING& comment = root.getComment(commentBefore);
|
||||
JSONCPP_STRING::const_iterator iter = comment.begin();
|
||||
while (iter != comment.end()) {
|
||||
*sout_ << *iter;
|
||||
if (*iter == '\n' &&
|
||||
@@ -1103,8 +1132,8 @@ StreamWriterBuilder::~StreamWriterBuilder()
|
||||
{}
|
||||
StreamWriter* StreamWriterBuilder::newStreamWriter() const
|
||||
{
|
||||
std::string indentation = settings_["indentation"].asString();
|
||||
std::string cs_str = settings_["commentStyle"].asString();
|
||||
JSONCPP_STRING indentation = settings_["indentation"].asString();
|
||||
JSONCPP_STRING cs_str = settings_["commentStyle"].asString();
|
||||
bool eyc = settings_["enableYAMLCompatibility"].asBool();
|
||||
bool dnp = settings_["dropNullPlaceholders"].asBool();
|
||||
bool usf = settings_["useSpecialFloats"].asBool();
|
||||
@@ -1117,23 +1146,23 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
|
||||
} else {
|
||||
throwRuntimeError("commentStyle must be 'All' or 'None'");
|
||||
}
|
||||
std::string colonSymbol = " : ";
|
||||
JSONCPP_STRING colonSymbol = " : ";
|
||||
if (eyc) {
|
||||
colonSymbol = ": ";
|
||||
} else if (indentation.empty()) {
|
||||
colonSymbol = ":";
|
||||
}
|
||||
std::string nullSymbol = "null";
|
||||
JSONCPP_STRING nullSymbol = "null";
|
||||
if (dnp) {
|
||||
nullSymbol = "";
|
||||
nullSymbol.clear();
|
||||
}
|
||||
if (pre > 17) pre = 17;
|
||||
std::string endingLineFeedSymbol = "";
|
||||
JSONCPP_STRING endingLineFeedSymbol;
|
||||
return new BuiltStyledStreamWriter(
|
||||
indentation, cs,
|
||||
colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);
|
||||
}
|
||||
static void getValidWriterKeys(std::set<std::string>* valid_keys)
|
||||
static void getValidWriterKeys(std::set<JSONCPP_STRING>* valid_keys)
|
||||
{
|
||||
valid_keys->clear();
|
||||
valid_keys->insert("indentation");
|
||||
@@ -1148,19 +1177,19 @@ bool StreamWriterBuilder::validate(Json::Value* invalid) const
|
||||
Json::Value my_invalid;
|
||||
if (!invalid) invalid = &my_invalid; // so we do not need to test for NULL
|
||||
Json::Value& inv = *invalid;
|
||||
std::set<std::string> valid_keys;
|
||||
std::set<JSONCPP_STRING> valid_keys;
|
||||
getValidWriterKeys(&valid_keys);
|
||||
Value::Members keys = settings_.getMemberNames();
|
||||
size_t n = keys.size();
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
std::string const& key = keys[i];
|
||||
JSONCPP_STRING const& key = keys[i];
|
||||
if (valid_keys.find(key) == valid_keys.end()) {
|
||||
inv[key] = settings_[key];
|
||||
}
|
||||
}
|
||||
return 0u == inv.size();
|
||||
}
|
||||
Value& StreamWriterBuilder::operator[](std::string key)
|
||||
Value& StreamWriterBuilder::operator[](JSONCPP_STRING key)
|
||||
{
|
||||
return settings_[key];
|
||||
}
|
||||
@@ -1177,14 +1206,14 @@ void StreamWriterBuilder::setDefaults(Json::Value* settings)
|
||||
//! [StreamWriterBuilderDefaults]
|
||||
}
|
||||
|
||||
std::string writeString(StreamWriter::Factory const& builder, Value const& root) {
|
||||
std::ostringstream sout;
|
||||
JSONCPP_STRING writeString(StreamWriter::Factory const& builder, Value const& root) {
|
||||
JSONCPP_OSTRINGSTREAM sout;
|
||||
StreamWriterPtr const writer(builder.newStreamWriter());
|
||||
writer->write(root, &sout);
|
||||
return sout.str();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& sout, Value const& root) {
|
||||
JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM& sout, Value const& root) {
|
||||
StreamWriterBuilder builder;
|
||||
StreamWriterPtr const writer(builder.newStreamWriter());
|
||||
writer->write(root, &sout);
|
||||
|
@@ -1,8 +0,0 @@
|
||||
Import( 'env buildLibrary' )
|
||||
|
||||
buildLibrary( env, Split( """
|
||||
json_reader.cpp
|
||||
json_value.cpp
|
||||
json_writer.cpp
|
||||
""" ),
|
||||
'json' )
|
@@ -10,4 +10,11 @@
|
||||
# define JSONCPP_VERSION_QUALIFIER
|
||||
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
||||
|
||||
#ifdef JSONCPP_USING_SECURE_MEMORY
|
||||
#undef JSONCPP_USING_SECURE_MEMORY
|
||||
#endif
|
||||
#define JSONCPP_USING_SECURE_MEMORY @JSONCPP_USE_SECURE_MEMORY@
|
||||
// If non-zero, the library zeroes any memory that it has allocated before
|
||||
// it frees its memory.
|
||||
|
||||
#endif // JSON_VERSION_H_INCLUDED
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
@@ -81,7 +81,7 @@ TestResult::TestResult()
|
||||
predicateStackTail_ = &rootPredicateNode_;
|
||||
}
|
||||
|
||||
void TestResult::setTestName(const std::string& name) { name_ = name; }
|
||||
void TestResult::setTestName(const JSONCPP_STRING& name) { name_ = name; }
|
||||
|
||||
TestResult&
|
||||
TestResult::addFailure(const char* file, unsigned int line, const char* expr) {
|
||||
@@ -163,7 +163,7 @@ void TestResult::printFailure(bool printTestName) const {
|
||||
Failures::const_iterator itEnd = failures_.end();
|
||||
for (Failures::const_iterator it = failures_.begin(); it != itEnd; ++it) {
|
||||
const Failure& failure = *it;
|
||||
std::string indent(failure.nestingLevel_ * 2, ' ');
|
||||
JSONCPP_STRING indent(failure.nestingLevel_ * 2, ' ');
|
||||
if (failure.file_) {
|
||||
printf("%s%s(%d): ", indent.c_str(), failure.file_, failure.line_);
|
||||
}
|
||||
@@ -173,19 +173,19 @@ void TestResult::printFailure(bool printTestName) const {
|
||||
printf("\n");
|
||||
}
|
||||
if (!failure.message_.empty()) {
|
||||
std::string reindented = indentText(failure.message_, indent + " ");
|
||||
JSONCPP_STRING reindented = indentText(failure.message_, indent + " ");
|
||||
printf("%s\n", reindented.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string TestResult::indentText(const std::string& text,
|
||||
const std::string& indent) {
|
||||
std::string reindented;
|
||||
std::string::size_type lastIndex = 0;
|
||||
JSONCPP_STRING TestResult::indentText(const JSONCPP_STRING& text,
|
||||
const JSONCPP_STRING& indent) {
|
||||
JSONCPP_STRING reindented;
|
||||
JSONCPP_STRING::size_type lastIndex = 0;
|
||||
while (lastIndex < text.size()) {
|
||||
std::string::size_type nextIndex = text.find('\n', lastIndex);
|
||||
if (nextIndex == std::string::npos) {
|
||||
JSONCPP_STRING::size_type nextIndex = text.find('\n', lastIndex);
|
||||
if (nextIndex == JSONCPP_STRING::npos) {
|
||||
nextIndex = text.size() - 1;
|
||||
}
|
||||
reindented += indent;
|
||||
@@ -195,7 +195,7 @@ std::string TestResult::indentText(const std::string& text,
|
||||
return reindented;
|
||||
}
|
||||
|
||||
TestResult& TestResult::addToLastFailure(const std::string& message) {
|
||||
TestResult& TestResult::addToLastFailure(const JSONCPP_STRING& message) {
|
||||
if (messageTarget_ != 0) {
|
||||
messageTarget_->message_ += message;
|
||||
}
|
||||
@@ -240,9 +240,9 @@ unsigned int Runner::testCount() const {
|
||||
return static_cast<unsigned int>(tests_.size());
|
||||
}
|
||||
|
||||
std::string Runner::testNameAt(unsigned int index) const {
|
||||
JSONCPP_STRING Runner::testNameAt(unsigned int index) const {
|
||||
TestCase* test = tests_[index]();
|
||||
std::string name = test->testName();
|
||||
JSONCPP_STRING name = test->testName();
|
||||
delete test;
|
||||
return name;
|
||||
}
|
||||
@@ -303,7 +303,7 @@ bool Runner::runAllTest(bool printSummary) const {
|
||||
}
|
||||
}
|
||||
|
||||
bool Runner::testIndex(const std::string& testName,
|
||||
bool Runner::testIndex(const JSONCPP_STRING& testName,
|
||||
unsigned int& indexOut) const {
|
||||
unsigned int count = testCount();
|
||||
for (unsigned int index = 0; index < count; ++index) {
|
||||
@@ -323,10 +323,10 @@ void Runner::listTests() const {
|
||||
}
|
||||
|
||||
int Runner::runCommandLine(int argc, const char* argv[]) const {
|
||||
// typedef std::deque<std::string> TestNames;
|
||||
// typedef std::deque<JSONCPP_STRING> TestNames;
|
||||
Runner subrunner;
|
||||
for (int index = 1; index < argc; ++index) {
|
||||
std::string opt = argv[index];
|
||||
JSONCPP_STRING opt = argv[index];
|
||||
if (opt == "--list-tests") {
|
||||
listTests();
|
||||
return 0;
|
||||
@@ -426,9 +426,23 @@ void Runner::printUsage(const char* appName) {
|
||||
// Assertion functions
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
|
||||
JSONCPP_STRING ToJsonString(const char* toConvert) {
|
||||
return JSONCPP_STRING(toConvert);
|
||||
}
|
||||
|
||||
JSONCPP_STRING ToJsonString(JSONCPP_STRING in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
JSONCPP_STRING ToJsonString(std::string in) {
|
||||
return JSONCPP_STRING(in.data(), in.data() + in.length());
|
||||
}
|
||||
#endif
|
||||
|
||||
TestResult& checkStringEqual(TestResult& result,
|
||||
const std::string& expected,
|
||||
const std::string& actual,
|
||||
const JSONCPP_STRING& expected,
|
||||
const JSONCPP_STRING& actual,
|
||||
const char* file,
|
||||
unsigned int line,
|
||||
const char* expr) {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
@@ -32,8 +32,8 @@ class Failure {
|
||||
public:
|
||||
const char* file_;
|
||||
unsigned int line_;
|
||||
std::string expr_;
|
||||
std::string message_;
|
||||
JSONCPP_STRING expr_;
|
||||
JSONCPP_STRING message_;
|
||||
unsigned int nestingLevel_;
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
/// \internal Implementation detail for predicate macros
|
||||
PredicateContext* predicateStackTail_;
|
||||
|
||||
void setTestName(const std::string& name);
|
||||
void setTestName(const JSONCPP_STRING& name);
|
||||
|
||||
/// Adds an assertion failure.
|
||||
TestResult&
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
|
||||
// Generic operator that will work with anything ostream can deal with.
|
||||
template <typename T> TestResult& operator<<(const T& value) {
|
||||
std::ostringstream oss;
|
||||
JSONCPP_OSTRINGSTREAM oss;
|
||||
oss.precision(16);
|
||||
oss.setf(std::ios_base::floatfield);
|
||||
oss << value;
|
||||
@@ -96,19 +96,19 @@ public:
|
||||
TestResult& operator<<(Json::UInt64 value);
|
||||
|
||||
private:
|
||||
TestResult& addToLastFailure(const std::string& message);
|
||||
TestResult& addToLastFailure(const JSONCPP_STRING& message);
|
||||
unsigned int getAssertionNestingLevel() const;
|
||||
/// Adds a failure or a predicate context
|
||||
void addFailureInfo(const char* file,
|
||||
unsigned int line,
|
||||
const char* expr,
|
||||
unsigned int nestingLevel);
|
||||
static std::string indentText(const std::string& text,
|
||||
const std::string& indent);
|
||||
static JSONCPP_STRING indentText(const JSONCPP_STRING& text,
|
||||
const JSONCPP_STRING& indent);
|
||||
|
||||
typedef std::deque<Failure> Failures;
|
||||
Failures failures_;
|
||||
std::string name_;
|
||||
JSONCPP_STRING name_;
|
||||
PredicateContext rootPredicateNode_;
|
||||
PredicateContext::Id lastUsedPredicateId_;
|
||||
/// Failure which is the target of the messages added using operator <<
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
unsigned int testCount() const;
|
||||
|
||||
/// Returns the name of the test case at the specified index
|
||||
std::string testNameAt(unsigned int index) const;
|
||||
JSONCPP_STRING testNameAt(unsigned int index) const;
|
||||
|
||||
/// Runs the test case at the specified index using the specified TestResult
|
||||
void runTestAt(unsigned int index, TestResult& result) const;
|
||||
@@ -168,7 +168,7 @@ private: // prevents copy construction and assignment
|
||||
|
||||
private:
|
||||
void listTests() const;
|
||||
bool testIndex(const std::string& testName, unsigned int& index) const;
|
||||
bool testIndex(const JSONCPP_STRING& testName, unsigned int& index) const;
|
||||
static void preventDialogOnCrash();
|
||||
|
||||
private:
|
||||
@@ -191,9 +191,15 @@ TestResult& checkEqual(TestResult& result,
|
||||
return result;
|
||||
}
|
||||
|
||||
JSONCPP_STRING ToJsonString(const char* toConvert);
|
||||
JSONCPP_STRING ToJsonString(JSONCPP_STRING in);
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
JSONCPP_STRING ToJsonString(std::string in);
|
||||
#endif
|
||||
|
||||
TestResult& checkStringEqual(TestResult& result,
|
||||
const std::string& expected,
|
||||
const std::string& actual,
|
||||
const JSONCPP_STRING& expected,
|
||||
const JSONCPP_STRING& actual,
|
||||
const char* file,
|
||||
unsigned int line,
|
||||
const char* expr);
|
||||
@@ -235,8 +241,8 @@ TestResult& checkStringEqual(TestResult& result,
|
||||
/// \brief Asserts that two values are equals.
|
||||
#define JSONTEST_ASSERT_STRING_EQUAL(expected, actual) \
|
||||
JsonTest::checkStringEqual(*result_, \
|
||||
std::string(expected), \
|
||||
std::string(actual), \
|
||||
JsonTest::ToJsonString(expected), \
|
||||
JsonTest::ToJsonString(actual), \
|
||||
__FILE__, \
|
||||
__LINE__, \
|
||||
#expected " == " #actual)
|
||||
@@ -265,8 +271,8 @@ TestResult& checkStringEqual(TestResult& result,
|
||||
} \
|
||||
\
|
||||
public: /* overidden from TestCase */ \
|
||||
virtual const char* testName() const { return #FixtureType "/" #name; } \
|
||||
virtual void runTestCase(); \
|
||||
const char* testName() const JSONCPP_OVERRIDE { return #FixtureType "/" #name; } \
|
||||
void runTestCase() JSONCPP_OVERRIDE; \
|
||||
}; \
|
||||
\
|
||||
void Test##FixtureType##name::runTestCase()
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur
|
||||
// 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
|
||||
@@ -8,6 +8,9 @@
|
||||
#include <json/json.h>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
// Make numeric limits more convenient to talk about.
|
||||
// Assumes int type in 32 bits.
|
||||
@@ -36,7 +39,7 @@ static inline double uint64ToDouble(Json::UInt64 value) {
|
||||
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||
static inline double uint64ToDouble(Json::UInt64 value) {
|
||||
return static_cast<double>(Json::Int64(value / 2)) * 2.0 +
|
||||
Json::Int64(value & 1);
|
||||
static_cast<double>(Json::Int64(value & 1));
|
||||
}
|
||||
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||
|
||||
@@ -99,21 +102,21 @@ struct ValueTest : JsonTest::TestCase {
|
||||
|
||||
/// Normalize the representation of floating-point number by stripped leading
|
||||
/// 0 in exponent.
|
||||
static std::string normalizeFloatingPointStr(const std::string& s);
|
||||
static JSONCPP_STRING normalizeFloatingPointStr(const JSONCPP_STRING& s);
|
||||
};
|
||||
|
||||
std::string ValueTest::normalizeFloatingPointStr(const std::string& s) {
|
||||
std::string::size_type index = s.find_last_of("eE");
|
||||
if (index != std::string::npos) {
|
||||
std::string::size_type hasSign =
|
||||
JSONCPP_STRING ValueTest::normalizeFloatingPointStr(const JSONCPP_STRING& s) {
|
||||
JSONCPP_STRING::size_type index = s.find_last_of("eE");
|
||||
if (index != JSONCPP_STRING::npos) {
|
||||
JSONCPP_STRING::size_type hasSign =
|
||||
(s[index + 1] == '+' || s[index + 1] == '-') ? 1 : 0;
|
||||
std::string::size_type exponentStartIndex = index + 1 + hasSign;
|
||||
std::string normalized = s.substr(0, exponentStartIndex);
|
||||
std::string::size_type indexDigit =
|
||||
JSONCPP_STRING::size_type exponentStartIndex = index + 1 + hasSign;
|
||||
JSONCPP_STRING normalized = s.substr(0, exponentStartIndex);
|
||||
JSONCPP_STRING::size_type indexDigit =
|
||||
s.find_first_not_of('0', exponentStartIndex);
|
||||
std::string exponent = "0";
|
||||
JSONCPP_STRING exponent = "0";
|
||||
if (indexDigit !=
|
||||
std::string::npos) // There is an exponent different from 0
|
||||
JSONCPP_STRING::npos) // There is an exponent different from 0
|
||||
{
|
||||
exponent = s.substr(indexDigit);
|
||||
}
|
||||
@@ -297,10 +300,7 @@ JSONTEST_FIXTURE(ValueTest, null) {
|
||||
JSONTEST_ASSERT_EQUAL(0.0, null_.asFloat());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("", null_.asString());
|
||||
|
||||
#if !defined(__ARMEL__)
|
||||
// See line #165 of include/json/value.h
|
||||
JSONTEST_ASSERT_EQUAL(Json::Value::null, null_);
|
||||
#endif
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, strings) {
|
||||
@@ -479,7 +479,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
JSONTEST_ASSERT_EQUAL(0.0, val.asDouble());
|
||||
JSONTEST_ASSERT_EQUAL(0.0, val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(false, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("0", val.asString());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("0.0", val.asString());
|
||||
|
||||
// Zero (signed constructor arg)
|
||||
val = Json::Value(0);
|
||||
@@ -563,7 +563,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
JSONTEST_ASSERT_EQUAL(0.0, val.asDouble());
|
||||
JSONTEST_ASSERT_EQUAL(0.0, val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(false, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("0", val.asString());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("0.0", val.asString());
|
||||
|
||||
// 2^20 (signed constructor arg)
|
||||
val = Json::Value(1 << 20);
|
||||
@@ -646,8 +646,8 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
JSONTEST_ASSERT_EQUAL((1 << 20), val.asDouble());
|
||||
JSONTEST_ASSERT_EQUAL((1 << 20), val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1048576",
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1048576.0",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
|
||||
// -2^20
|
||||
val = Json::Value(-(1 << 20));
|
||||
@@ -887,8 +887,8 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
JSONTEST_ASSERT_EQUAL((Json::Int64(1) << 40), val.asDouble());
|
||||
JSONTEST_ASSERT_EQUAL((Json::Int64(1) << 40), val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1099511627776",
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1099511627776.0",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
|
||||
// -2^40
|
||||
val = Json::Value(-(Json::Int64(1) << 40));
|
||||
@@ -963,7 +963,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("9.2233720368547758e+18",
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
|
||||
// int64 min
|
||||
val = Json::Value(Json::Int64(kint64min));
|
||||
@@ -1011,7 +1011,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
JSONTEST_ASSERT_EQUAL(-9223372036854775808.0, val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("-9.2233720368547758e+18",
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
|
||||
// 10^19
|
||||
const Json::UInt64 ten_to_19 = static_cast<Json::UInt64>(1e19);
|
||||
@@ -1058,7 +1058,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
JSONTEST_ASSERT_EQUAL(1e19, val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1e+19",
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
|
||||
// uint64 max
|
||||
val = Json::Value(Json::UInt64(kuint64max));
|
||||
@@ -1102,7 +1102,7 @@ JSONTEST_FIXTURE(ValueTest, integers) {
|
||||
JSONTEST_ASSERT_EQUAL(18446744073709551616.0, val.asFloat());
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1.8446744073709552e+19",
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1192,7 +1192,7 @@ JSONTEST_FIXTURE(ValueTest, nonIntegers) {
|
||||
#endif
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_EQUAL("2147483647.5",
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
|
||||
// A bit under int32 min
|
||||
val = Json::Value(kint32min - 0.5);
|
||||
@@ -1220,7 +1220,7 @@ JSONTEST_FIXTURE(ValueTest, nonIntegers) {
|
||||
#endif
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_EQUAL("-2147483648.5",
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
|
||||
// A bit over uint32 max
|
||||
val = Json::Value(kuint32max + 0.5);
|
||||
@@ -1250,29 +1250,29 @@ JSONTEST_FIXTURE(ValueTest, nonIntegers) {
|
||||
#endif
|
||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||
JSONTEST_ASSERT_EQUAL("4294967295.5",
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
|
||||
val = Json::Value(1.2345678901234);
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1.2345678901234001",
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
|
||||
// A 16-digit floating point number.
|
||||
val = Json::Value(2199023255552000.0f);
|
||||
JSONTEST_ASSERT_EQUAL(float(2199023255552000.0f), val.asFloat());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("2199023255552000",
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
JSONTEST_ASSERT_STRING_EQUAL("2199023255552000.0",
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
|
||||
// A very large floating point number.
|
||||
val = Json::Value(3.402823466385289e38);
|
||||
JSONTEST_ASSERT_EQUAL(float(3.402823466385289e38), val.asFloat());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("3.402823466385289e+38",
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
|
||||
// An even larger floating point number.
|
||||
val = Json::Value(1.2345678e300);
|
||||
JSONTEST_ASSERT_EQUAL(double(1.2345678e300), val.asDouble());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("1.2345678e+300",
|
||||
normalizeFloatingPointStr(val.asString()));
|
||||
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
|
||||
}
|
||||
|
||||
void ValueTest::checkConstMemberCount(const Json::Value& value,
|
||||
@@ -1516,10 +1516,29 @@ JSONTEST_FIXTURE(ValueTest, typeChecksThrowExceptions) {
|
||||
#endif
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, offsetAccessors) {
|
||||
Json::Value x;
|
||||
JSONTEST_ASSERT(x.getOffsetStart() == 0);
|
||||
JSONTEST_ASSERT(x.getOffsetLimit() == 0);
|
||||
x.setOffsetStart(10);
|
||||
x.setOffsetLimit(20);
|
||||
JSONTEST_ASSERT(x.getOffsetStart() == 10);
|
||||
JSONTEST_ASSERT(x.getOffsetLimit() == 20);
|
||||
Json::Value y(x);
|
||||
JSONTEST_ASSERT(y.getOffsetStart() == 10);
|
||||
JSONTEST_ASSERT(y.getOffsetLimit() == 20);
|
||||
Json::Value z;
|
||||
z.swap(y);
|
||||
JSONTEST_ASSERT(z.getOffsetStart() == 10);
|
||||
JSONTEST_ASSERT(z.getOffsetLimit() == 20);
|
||||
JSONTEST_ASSERT(y.getOffsetStart() == 0);
|
||||
JSONTEST_ASSERT(y.getOffsetLimit() == 0);
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, StaticString) {
|
||||
char mutant[] = "hello";
|
||||
Json::StaticString ss(mutant);
|
||||
std::string regular(mutant);
|
||||
JSONCPP_STRING regular(mutant);
|
||||
mutant[1] = 'a';
|
||||
JSONTEST_ASSERT_STRING_EQUAL("hallo", ss.c_str());
|
||||
JSONTEST_ASSERT_STRING_EQUAL("hello", regular.c_str());
|
||||
@@ -1541,15 +1560,15 @@ JSONTEST_FIXTURE(ValueTest, StaticString) {
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, CommentBefore) {
|
||||
Json::Value val; // fill val
|
||||
val.setComment(std::string("// this comment should appear before"), Json::commentBefore);
|
||||
val.setComment(JSONCPP_STRING("// this comment should appear before"), Json::commentBefore);
|
||||
Json::StreamWriterBuilder wbuilder;
|
||||
wbuilder.settings_["commentStyle"] = "All";
|
||||
{
|
||||
char const expected[] = "// this comment should appear before\nnull";
|
||||
std::string result = Json::writeString(wbuilder, val);
|
||||
JSONCPP_STRING result = Json::writeString(wbuilder, val);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
std::string res2 = val.toStyledString();
|
||||
std::string exp2 = "\n";
|
||||
JSONCPP_STRING res2 = val.toStyledString();
|
||||
JSONCPP_STRING exp2 = "\n";
|
||||
exp2 += expected;
|
||||
exp2 += "\n";
|
||||
JSONTEST_ASSERT_STRING_EQUAL(exp2, res2);
|
||||
@@ -1558,10 +1577,10 @@ JSONTEST_FIXTURE(ValueTest, CommentBefore) {
|
||||
val.swapPayload(other);
|
||||
{
|
||||
char const expected[] = "// this comment should appear before\n\"hello\"";
|
||||
std::string result = Json::writeString(wbuilder, val);
|
||||
JSONCPP_STRING result = Json::writeString(wbuilder, val);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
std::string res2 = val.toStyledString();
|
||||
std::string exp2 = "\n";
|
||||
JSONCPP_STRING res2 = val.toStyledString();
|
||||
JSONCPP_STRING exp2 = "\n";
|
||||
exp2 += expected;
|
||||
exp2 += "\n";
|
||||
JSONTEST_ASSERT_STRING_EQUAL(exp2, res2);
|
||||
@@ -1572,10 +1591,10 @@ JSONTEST_FIXTURE(ValueTest, CommentBefore) {
|
||||
// Assignment over-writes comments.
|
||||
{
|
||||
char const expected[] = "\"hello\"";
|
||||
std::string result = Json::writeString(wbuilder, val);
|
||||
JSONCPP_STRING result = Json::writeString(wbuilder, val);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
std::string res2 = val.toStyledString();
|
||||
std::string exp2 = "";
|
||||
JSONCPP_STRING res2 = val.toStyledString();
|
||||
JSONCPP_STRING exp2 = "";
|
||||
exp2 += expected;
|
||||
exp2 += "\n";
|
||||
JSONTEST_ASSERT_STRING_EQUAL(exp2, res2);
|
||||
@@ -1584,7 +1603,7 @@ JSONTEST_FIXTURE(ValueTest, CommentBefore) {
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, zeroes) {
|
||||
char const cstr[] = "h\0i";
|
||||
std::string binary(cstr, sizeof(cstr)); // include trailing 0
|
||||
JSONCPP_STRING binary(cstr, sizeof(cstr)); // include trailing 0
|
||||
JSONTEST_ASSERT_EQUAL(4U, binary.length());
|
||||
Json::StreamWriterBuilder b;
|
||||
{
|
||||
@@ -1612,7 +1631,7 @@ JSONTEST_FIXTURE(ValueTest, zeroes) {
|
||||
|
||||
JSONTEST_FIXTURE(ValueTest, zeroesInKeys) {
|
||||
char const cstr[] = "h\0i";
|
||||
std::string binary(cstr, sizeof(cstr)); // include trailing 0
|
||||
JSONCPP_STRING binary(cstr, sizeof(cstr)); // include trailing 0
|
||||
JSONTEST_ASSERT_EQUAL(4U, binary.length());
|
||||
{
|
||||
Json::Value root;
|
||||
@@ -1641,8 +1660,8 @@ JSONTEST_FIXTURE(ValueTest, specialFloats) {
|
||||
b.settings_["useSpecialFloats"] = true;
|
||||
|
||||
Json::Value v = std::numeric_limits<double>::quiet_NaN();
|
||||
std::string expected = "NaN";
|
||||
std::string result = Json::writeString(b, v);
|
||||
JSONCPP_STRING expected = "NaN";
|
||||
JSONCPP_STRING result = Json::writeString(b, v);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
|
||||
v = std::numeric_limits<double>::infinity();
|
||||
@@ -1661,10 +1680,10 @@ JSONTEST_FIXTURE(ValueTest, precision) {
|
||||
b.settings_["precision"] = 5;
|
||||
|
||||
Json::Value v = 100.0/3;
|
||||
std::string expected = "33.333";
|
||||
std::string result = Json::writeString(b, v);
|
||||
JSONCPP_STRING expected = "33.333";
|
||||
JSONCPP_STRING result = Json::writeString(b, v);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
|
||||
|
||||
v = 0.25000000;
|
||||
expected = "0.25";
|
||||
result = Json::writeString(b, v);
|
||||
@@ -1693,6 +1712,17 @@ JSONTEST_FIXTURE(ValueTest, precision) {
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||
}
|
||||
|
||||
struct WriterTest : JsonTest::TestCase {};
|
||||
|
||||
JSONTEST_FIXTURE(WriterTest, dropNullPlaceholders) {
|
||||
Json::FastWriter writer;
|
||||
Json::Value nullValue;
|
||||
JSONTEST_ASSERT(writer.write(nullValue) == "null\n");
|
||||
|
||||
writer.dropNullPlaceholders();
|
||||
JSONTEST_ASSERT(writer.write(nullValue) == "\n");
|
||||
}
|
||||
|
||||
struct StreamWriterTest : JsonTest::TestCase {};
|
||||
|
||||
JSONTEST_FIXTURE(StreamWriterTest, dropNullPlaceholders) {
|
||||
@@ -1705,15 +1735,15 @@ JSONTEST_FIXTURE(StreamWriterTest, dropNullPlaceholders) {
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(StreamWriterTest, writeZeroes) {
|
||||
std::string binary("hi", 3); // include trailing 0
|
||||
JSONCPP_STRING binary("hi", 3); // include trailing 0
|
||||
JSONTEST_ASSERT_EQUAL(3, binary.length());
|
||||
std::string expected("\"hi\\u0000\""); // unicoded zero
|
||||
JSONCPP_STRING expected("\"hi\\u0000\""); // unicoded zero
|
||||
Json::StreamWriterBuilder b;
|
||||
{
|
||||
Json::Value root;
|
||||
root = binary;
|
||||
JSONTEST_ASSERT_STRING_EQUAL(binary, root.asString());
|
||||
std::string out = Json::writeString(b, root);
|
||||
JSONCPP_STRING out = Json::writeString(b, root);
|
||||
JSONTEST_ASSERT_EQUAL(expected.size(), out.size());
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, out);
|
||||
}
|
||||
@@ -1721,7 +1751,7 @@ JSONTEST_FIXTURE(StreamWriterTest, writeZeroes) {
|
||||
Json::Value root;
|
||||
root["top"] = binary;
|
||||
JSONTEST_ASSERT_STRING_EQUAL(binary, root["top"].asString());
|
||||
std::string out = Json::writeString(b, root["top"]);
|
||||
JSONCPP_STRING out = Json::writeString(b, root["top"]);
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, out);
|
||||
}
|
||||
}
|
||||
@@ -1734,6 +1764,7 @@ JSONTEST_FIXTURE(ReaderTest, parseWithNoErrors) {
|
||||
bool ok = reader.parse("{ \"property\" : \"value\" }", root);
|
||||
JSONTEST_ASSERT(ok);
|
||||
JSONTEST_ASSERT(reader.getFormattedErrorMessages().size() == 0);
|
||||
JSONTEST_ASSERT(reader.getStructuredErrors().size() == 0);
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ReaderTest, parseWithNoErrorsTestingOffsets) {
|
||||
@@ -1745,6 +1776,25 @@ JSONTEST_FIXTURE(ReaderTest, parseWithNoErrorsTestingOffsets) {
|
||||
root);
|
||||
JSONTEST_ASSERT(ok);
|
||||
JSONTEST_ASSERT(reader.getFormattedErrorMessages().size() == 0);
|
||||
JSONTEST_ASSERT(reader.getStructuredErrors().size() == 0);
|
||||
JSONTEST_ASSERT(root["property"].getOffsetStart() == 15);
|
||||
JSONTEST_ASSERT(root["property"].getOffsetLimit() == 34);
|
||||
JSONTEST_ASSERT(root["property"][0].getOffsetStart() == 16);
|
||||
JSONTEST_ASSERT(root["property"][0].getOffsetLimit() == 23);
|
||||
JSONTEST_ASSERT(root["property"][1].getOffsetStart() == 25);
|
||||
JSONTEST_ASSERT(root["property"][1].getOffsetLimit() == 33);
|
||||
JSONTEST_ASSERT(root["obj"].getOffsetStart() == 44);
|
||||
JSONTEST_ASSERT(root["obj"].getOffsetLimit() == 76);
|
||||
JSONTEST_ASSERT(root["obj"]["nested"].getOffsetStart() == 57);
|
||||
JSONTEST_ASSERT(root["obj"]["nested"].getOffsetLimit() == 60);
|
||||
JSONTEST_ASSERT(root["obj"]["bool"].getOffsetStart() == 71);
|
||||
JSONTEST_ASSERT(root["obj"]["bool"].getOffsetLimit() == 75);
|
||||
JSONTEST_ASSERT(root["null"].getOffsetStart() == 87);
|
||||
JSONTEST_ASSERT(root["null"].getOffsetLimit() == 91);
|
||||
JSONTEST_ASSERT(root["false"].getOffsetStart() == 103);
|
||||
JSONTEST_ASSERT(root["false"].getOffsetLimit() == 108);
|
||||
JSONTEST_ASSERT(root.getOffsetStart() == 0);
|
||||
JSONTEST_ASSERT(root.getOffsetLimit() == 110);
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ReaderTest, parseWithOneError) {
|
||||
@@ -1755,6 +1805,13 @@ JSONTEST_FIXTURE(ReaderTest, parseWithOneError) {
|
||||
JSONTEST_ASSERT(reader.getFormattedErrorMessages() ==
|
||||
"* Line 1, Column 15\n Syntax error: value, object or array "
|
||||
"expected.\n");
|
||||
std::vector<Json::Reader::StructuredError> errors =
|
||||
reader.getStructuredErrors();
|
||||
JSONTEST_ASSERT(errors.size() == 1);
|
||||
JSONTEST_ASSERT(errors.at(0).offset_start == 14);
|
||||
JSONTEST_ASSERT(errors.at(0).offset_limit == 15);
|
||||
JSONTEST_ASSERT(errors.at(0).message ==
|
||||
"Syntax error: value, object or array expected.");
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ReaderTest, parseChineseWithOneError) {
|
||||
@@ -1765,6 +1822,13 @@ JSONTEST_FIXTURE(ReaderTest, parseChineseWithOneError) {
|
||||
JSONTEST_ASSERT(reader.getFormattedErrorMessages() ==
|
||||
"* Line 1, Column 19\n Syntax error: value, object or array "
|
||||
"expected.\n");
|
||||
std::vector<Json::Reader::StructuredError> errors =
|
||||
reader.getStructuredErrors();
|
||||
JSONTEST_ASSERT(errors.size() == 1);
|
||||
JSONTEST_ASSERT(errors.at(0).offset_start == 18);
|
||||
JSONTEST_ASSERT(errors.at(0).offset_limit == 19);
|
||||
JSONTEST_ASSERT(errors.at(0).message ==
|
||||
"Syntax error: value, object or array expected.");
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(ReaderTest, parseWithDetailError) {
|
||||
@@ -1775,6 +1839,12 @@ JSONTEST_FIXTURE(ReaderTest, parseWithDetailError) {
|
||||
JSONTEST_ASSERT(reader.getFormattedErrorMessages() ==
|
||||
"* Line 1, Column 16\n Bad escape sequence in string\nSee "
|
||||
"Line 1, Column 20 for detail.\n");
|
||||
std::vector<Json::Reader::StructuredError> errors =
|
||||
reader.getStructuredErrors();
|
||||
JSONTEST_ASSERT(errors.size() == 1);
|
||||
JSONTEST_ASSERT(errors.at(0).offset_start == 15);
|
||||
JSONTEST_ASSERT(errors.at(0).offset_limit == 23);
|
||||
JSONTEST_ASSERT(errors.at(0).message == "Bad escape sequence in string");
|
||||
}
|
||||
|
||||
struct CharReaderTest : JsonTest::TestCase {};
|
||||
@@ -1782,7 +1852,7 @@ struct CharReaderTest : JsonTest::TestCase {};
|
||||
JSONTEST_FIXTURE(CharReaderTest, parseWithNoErrors) {
|
||||
Json::CharReaderBuilder b;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
Json::Value root;
|
||||
char const doc[] = "{ \"property\" : \"value\" }";
|
||||
bool ok = reader->parse(
|
||||
@@ -1796,7 +1866,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithNoErrors) {
|
||||
JSONTEST_FIXTURE(CharReaderTest, parseWithNoErrorsTestingOffsets) {
|
||||
Json::CharReaderBuilder b;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
Json::Value root;
|
||||
char const doc[] =
|
||||
"{ \"property\" : [\"value\", \"value2\"], \"obj\" : "
|
||||
@@ -1813,7 +1883,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithNoErrorsTestingOffsets) {
|
||||
JSONTEST_FIXTURE(CharReaderTest, parseWithOneError) {
|
||||
Json::CharReaderBuilder b;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
Json::Value root;
|
||||
char const doc[] =
|
||||
"{ \"property\" :: \"value\" }";
|
||||
@@ -1830,7 +1900,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithOneError) {
|
||||
JSONTEST_FIXTURE(CharReaderTest, parseChineseWithOneError) {
|
||||
Json::CharReaderBuilder b;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
Json::Value root;
|
||||
char const doc[] =
|
||||
"{ \"pr佐藤erty\" :: \"value\" }";
|
||||
@@ -1847,7 +1917,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseChineseWithOneError) {
|
||||
JSONTEST_FIXTURE(CharReaderTest, parseWithDetailError) {
|
||||
Json::CharReaderBuilder b;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
Json::Value root;
|
||||
char const doc[] =
|
||||
"{ \"property\" : \"v\\alue\" }";
|
||||
@@ -1869,7 +1939,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithStackLimit) {
|
||||
{
|
||||
b.settings_["stackLimit"] = 2;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -1881,7 +1951,7 @@ JSONTEST_FIXTURE(CharReaderTest, parseWithStackLimit) {
|
||||
{
|
||||
b.settings_["stackLimit"] = 1;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
JSONTEST_ASSERT_THROWS(reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs));
|
||||
@@ -1899,7 +1969,7 @@ JSONTEST_FIXTURE(CharReaderStrictModeTest, dupKeys) {
|
||||
{
|
||||
b.strictMode(&b.settings_);
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -1923,7 +1993,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, issue164) {
|
||||
{
|
||||
b.settings_["failIfExtra"] = false;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -1935,7 +2005,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, issue164) {
|
||||
{
|
||||
b.settings_["failIfExtra"] = true;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -1950,7 +2020,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, issue164) {
|
||||
b.settings_["failIfExtra"] = false;
|
||||
b.strictMode(&b.settings_);
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -1970,7 +2040,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, issue107) {
|
||||
"1:2:3";
|
||||
b.settings_["failIfExtra"] = true;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -1990,7 +2060,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, commentAfterObject) {
|
||||
"{ \"property\" : \"value\" } //trailing\n//comment\n";
|
||||
b.settings_["failIfExtra"] = true;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -2007,7 +2077,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, commentAfterArray) {
|
||||
"[ \"property\" , \"value\" ] //trailing\n//comment\n";
|
||||
b.settings_["failIfExtra"] = true;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -2023,7 +2093,7 @@ JSONTEST_FIXTURE(CharReaderFailIfExtraTest, commentAfterBool) {
|
||||
" true /*trailing\ncomment*/";
|
||||
b.settings_["failIfExtra"] = true;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
bool ok = reader->parse(
|
||||
doc, doc + std::strlen(doc),
|
||||
&root, &errs);
|
||||
@@ -2038,7 +2108,7 @@ JSONTEST_FIXTURE(CharReaderAllowDropNullTest, issue178) {
|
||||
Json::CharReaderBuilder b;
|
||||
b.settings_["allowDroppedNullPlaceholders"] = true;
|
||||
Json::Value root;
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
{
|
||||
char const doc[] = "{\"a\":,\"b\":true}";
|
||||
@@ -2190,7 +2260,7 @@ JSONTEST_FIXTURE(CharReaderAllowSingleQuotesTest, issue182) {
|
||||
Json::CharReaderBuilder b;
|
||||
b.settings_["allowSingleQuotes"] = true;
|
||||
Json::Value root;
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
{
|
||||
char const doc[] = "{'a':true,\"b\":true}";
|
||||
@@ -2223,7 +2293,7 @@ JSONTEST_FIXTURE(CharReaderAllowZeroesTest, issue176) {
|
||||
Json::CharReaderBuilder b;
|
||||
b.settings_["allowSingleQuotes"] = true;
|
||||
Json::Value root;
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
{
|
||||
char const doc[] = "{'a':true,\"b\":true}";
|
||||
@@ -2256,7 +2326,7 @@ JSONTEST_FIXTURE(CharReaderAllowSpecialFloatsTest, issue209) {
|
||||
Json::CharReaderBuilder b;
|
||||
b.settings_["allowSpecialFloats"] = true;
|
||||
Json::Value root;
|
||||
std::string errs;
|
||||
JSONCPP_STRING errs;
|
||||
Json::CharReader* reader(b.newCharReader());
|
||||
{
|
||||
char const doc[] = "{\"a\":NaN,\"b\":Infinity,\"c\":-Infinity}";
|
||||
@@ -2275,7 +2345,7 @@ JSONTEST_FIXTURE(CharReaderAllowSpecialFloatsTest, issue209) {
|
||||
struct TestData {
|
||||
int line;
|
||||
bool ok;
|
||||
std::string in;
|
||||
JSONCPP_STRING in;
|
||||
};
|
||||
const TestData test_data[] = {
|
||||
{__LINE__, 1, "{\"a\":9}"},
|
||||
@@ -2355,7 +2425,7 @@ JSONTEST_FIXTURE(IteratorTest, distance) {
|
||||
json["k1"] = "a";
|
||||
json["k2"] = "b";
|
||||
int dist = 0;
|
||||
std::string str;
|
||||
JSONCPP_STRING str;
|
||||
for (Json::ValueIterator it = json.begin(); it != json.end(); ++it) {
|
||||
dist = it - json.begin();
|
||||
str = it->asString().c_str();
|
||||
@@ -2400,6 +2470,46 @@ JSONTEST_FIXTURE(IteratorTest, indexes) {
|
||||
JSONTEST_ASSERT(it == json.end());
|
||||
}
|
||||
|
||||
JSONTEST_FIXTURE(IteratorTest, const) {
|
||||
Json::Value const v;
|
||||
JSONTEST_ASSERT_THROWS(
|
||||
Json::Value::iterator it(v.begin()) // Compile, but throw.
|
||||
);
|
||||
|
||||
Json::Value value;
|
||||
|
||||
for(int i = 9; i < 12; ++i)
|
||||
{
|
||||
JSONCPP_OSTRINGSTREAM out;
|
||||
out << std::setw(2) << i;
|
||||
JSONCPP_STRING str = out.str();
|
||||
value[str] = str;
|
||||
}
|
||||
|
||||
JSONCPP_OSTRINGSTREAM out;
|
||||
//in old code, this will get a compile error
|
||||
Json::Value::const_iterator iter = value.begin();
|
||||
for(; iter != value.end(); ++iter)
|
||||
{
|
||||
out << *iter << ',';
|
||||
}
|
||||
JSONCPP_STRING expected = "\" 9\",\"10\",\"11\",";
|
||||
JSONTEST_ASSERT_STRING_EQUAL(expected, out.str());
|
||||
}
|
||||
|
||||
struct RValueTest : JsonTest::TestCase {};
|
||||
|
||||
JSONTEST_FIXTURE(RValueTest, moveConstruction) {
|
||||
#if JSON_HAS_RVALUE_REFERENCES
|
||||
Json::Value json;
|
||||
json["key"] = "value";
|
||||
Json::Value moved = std::move(json);
|
||||
JSONTEST_ASSERT(moved != json); // Possibly not nullValue; definitely not equal.
|
||||
JSONTEST_ASSERT_EQUAL(Json::objectValue, moved.type());
|
||||
JSONTEST_ASSERT_EQUAL(Json::stringValue, moved["key"].type());
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
JsonTest::Runner runner;
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, checkNormalizeFloatingPointStr);
|
||||
@@ -2421,6 +2531,7 @@ int main(int argc, const char* argv[]) {
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, compareArray);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, compareObject);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, compareType);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, offsetAccessors);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, typeChecksThrowExceptions);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, StaticString);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, CommentBefore);
|
||||
@@ -2430,6 +2541,7 @@ int main(int argc, const char* argv[]) {
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, specialFloats);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, precision);
|
||||
|
||||
JSONTEST_REGISTER_FIXTURE(runner, WriterTest, dropNullPlaceholders);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, dropNullPlaceholders);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, writeZeroes);
|
||||
|
||||
@@ -2469,6 +2581,9 @@ int main(int argc, const char* argv[]) {
|
||||
JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, distance);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, names);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, indexes);
|
||||
JSONTEST_REGISTER_FIXTURE(runner, IteratorTest, const);
|
||||
|
||||
JSONTEST_REGISTER_FIXTURE(runner, RValueTest, moveConstruction);
|
||||
|
||||
return runner.runCommandLine(argc, argv);
|
||||
}
|
||||
|
@@ -1,10 +0,0 @@
|
||||
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,4 +1,4 @@
|
||||
# Copyright 2007 Baptiste Lepilleur
|
||||
# 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
|
||||
|
1
test/data/fail_test_stack_limit.json
Normal file
1
test/data/fail_test_stack_limit.json
Normal file
@@ -0,0 +1 @@
|
||||
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
|
@@ -1,4 +1,4 @@
|
||||
# Copyright 2007 Baptiste Lepilleur
|
||||
# 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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright 2007 Baptiste Lepilleur
|
||||
# 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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright 2007 Baptiste Lepilleur
|
||||
# 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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright 2009 Baptiste Lepilleur
|
||||
# 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
|
||||
|
14
travis.sh
14
travis.sh
@@ -17,13 +17,7 @@ set -vex
|
||||
|
||||
env | sort
|
||||
|
||||
cmake -DJSONCPP_WITH_CMAKE_PACKAGE=$CMAKE_PKG -DBUILD_SHARED_LIBS=$SHARED_LIB -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_VERBOSE_MAKEFILE=$VERBOSE_MAKE .
|
||||
make
|
||||
|
||||
# Python is not available in Travis for osx.
|
||||
# https://github.com/travis-ci/travis-ci/issues/2320
|
||||
if [ "$TRAVIS_OS_NAME" != "osx" ]
|
||||
then
|
||||
make jsoncpp_check
|
||||
valgrind --error-exitcode=42 --leak-check=full ./src/test_lib_json/jsoncpp_test
|
||||
fi
|
||||
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}
|
||||
|
Reference in New Issue
Block a user