Skip to content

Commit cf8a11e

Browse files
authored
Merge branch 'master' into master
2 parents dcd7aea + 76ff1db commit cf8a11e

File tree

13 files changed

+108
-29
lines changed

13 files changed

+108
-29
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ project(jsoncpp
6262
# 2. ./include/json/version.h
6363
# 3. ./CMakeLists.txt
6464
# IMPORTANT: also update the PROJECT_SOVERSION!!
65-
VERSION 1.9.5 # <major>[.<minor>[.<patch>[.<tweak>]]]
65+
VERSION 1.9.6 # <major>[.<minor>[.<patch>[.<tweak>]]]
6666
LANGUAGES CXX)
6767

6868
message(STATUS "JsonCpp Version: ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
69-
set(PROJECT_SOVERSION 25)
69+
set(PROJECT_SOVERSION 26)
7070

7171
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInSourceBuilds.cmake)
7272
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInBuildInstalls.cmake)

include/PreventInSourceBuilds.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# This function will prevent in-source builds
33
function(AssureOutOfSourceBuilds)
44
# make sure the user doesn't play dirty with symlinks
5-
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
6-
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
5+
get_filename_component(srcdir "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)
6+
get_filename_component(bindir "${CMAKE_CURRENT_BINARY_DIR}" REALPATH)
77

88
# disallow in-source builds
99
if("${srcdir}" STREQUAL "${bindir}")

include/json/reader.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,12 @@ class JSON_API CharReaderBuilder : public CharReader::Factory {
385385
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
386386
*/
387387
static void strictMode(Json::Value* settings);
388+
/** ECMA-404 mode.
389+
* \pre 'settings' != NULL (but Json::null is fine)
390+
* \remark Defaults:
391+
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderECMA404Mode
392+
*/
393+
static void ecma404Mode(Json::Value* settings);
388394
};
389395

390396
/** Consume entire stream and use its begin/end.

include/json/value.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// recognized in your jurisdiction.
44
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
55

6-
#ifndef JSON_H_INCLUDED
7-
#define JSON_H_INCLUDED
6+
#ifndef JSON_VALUE_H_INCLUDED
7+
#define JSON_VALUE_H_INCLUDED
88

99
#if !defined(JSON_IS_AMALGAMATION)
1010
#include "forwards.h"
@@ -513,6 +513,9 @@ class JSON_API Value {
513513
/// and operator[]const
514514
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
515515
Value const* find(char const* begin, char const* end) const;
516+
/// Most general and efficient version of isMember()const, get()const,
517+
/// and operator[]const
518+
Value const* find(const String& key) const;
516519
/// Most general and efficient version of object-mutators.
517520
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
518521
/// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.

include/json/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
// 3. /CMakeLists.txt
1010
// IMPORTANT: also update the SOVERSION!!
1111

12-
#define JSONCPP_VERSION_STRING "1.9.5"
12+
#define JSONCPP_VERSION_STRING "1.9.6"
1313
#define JSONCPP_VERSION_MAJOR 1
1414
#define JSONCPP_VERSION_MINOR 9
15-
#define JSONCPP_VERSION_PATCH 5
15+
#define JSONCPP_VERSION_PATCH 6
1616
#define JSONCPP_VERSION_QUALIFIER
1717
#define JSONCPP_VERSION_HEXA \
1818
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \

jsoncpp-namespaced-targets.cmake

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
if (TARGET jsoncpp_static)
2-
add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
3-
set_target_properties(JsonCpp::JsonCpp PROPERTIES INTERFACE_LINK_LIBRARIES "jsoncpp_static")
4-
elseif (TARGET jsoncpp_lib)
5-
add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
6-
set_target_properties(JsonCpp::JsonCpp PROPERTIES INTERFACE_LINK_LIBRARIES "jsoncpp_lib")
7-
endif ()
1+
if (NOT TARGET JsonCpp::JsonCpp)
2+
if (TARGET jsoncpp_static)
3+
add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
4+
set_target_properties(JsonCpp::JsonCpp PROPERTIES INTERFACE_LINK_LIBRARIES "jsoncpp_static")
5+
elseif (TARGET jsoncpp_lib)
6+
add_library(JsonCpp::JsonCpp INTERFACE IMPORTED)
7+
set_target_properties(JsonCpp::JsonCpp PROPERTIES INTERFACE_LINK_LIBRARIES "jsoncpp_lib")
8+
endif ()
9+
endif ()

jsoncppConfig.cmake.meson.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@PACKAGE_INIT@
2+
3+
@MESON_SHARED_TARGET@
4+
@MESON_STATIC_TARGET@
5+
6+
include ( "${CMAKE_CURRENT_LIST_DIR}/jsoncpp-namespaced-targets.cmake" )
7+
8+
check_required_components(JsonCpp)

meson.build

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ project(
99
# 2. /include/json/version.h
1010
# 3. /CMakeLists.txt
1111
# IMPORTANT: also update the SOVERSION!!
12-
version : '1.9.4',
12+
version : '1.9.6',
1313
default_options : [
1414
'buildtype=release',
1515
'cpp_std=c++11',
1616
'warning_level=1'],
1717
license : 'Public Domain',
18-
meson_version : '>= 0.49.0')
18+
meson_version : '>= 0.54.0')
1919

2020

2121
jsoncpp_headers = files([
@@ -50,7 +50,7 @@ jsoncpp_lib = library(
5050
'src/lib_json/json_value.cpp',
5151
'src/lib_json/json_writer.cpp',
5252
]),
53-
soversion : 25,
53+
soversion : 26,
5454
install : true,
5555
include_directories : jsoncpp_include_directories,
5656
cpp_args: dll_export_flag)
@@ -62,6 +62,43 @@ import('pkgconfig').generate(
6262
filebase : 'jsoncpp',
6363
description : 'A C++ library for interacting with JSON')
6464

65+
cmakeconf = configuration_data()
66+
cmakeconf.set('MESON_LIB_DIR', get_option('libdir'))
67+
cmakeconf.set('MESON_INCLUDE_DIR', get_option('includedir'))
68+
69+
fs = import('fs')
70+
if get_option('default_library') == 'shared'
71+
shared_name = fs.name(jsoncpp_lib.full_path())
72+
endif
73+
if get_option('default_library') == 'static'
74+
static_name = fs.name(jsoncpp_lib.full_path())
75+
endif
76+
if get_option('default_library') == 'both'
77+
shared_name = fs.name(jsoncpp_lib.get_shared_lib().full_path())
78+
static_name = fs.name(jsoncpp_lib.get_static_lib().full_path())
79+
endif
80+
81+
if get_option('default_library') == 'shared' or get_option('default_library') == 'both'
82+
cmakeconf.set('MESON_SHARED_TARGET', '''
83+
add_library(jsoncpp_lib IMPORTED SHARED)
84+
set_target_properties(jsoncpp_lib PROPERTIES
85+
IMPORTED_LOCATION "''' + join_paths('${PACKAGE_PREFIX_DIR}', get_option('libdir'), shared_name) + '''"
86+
INTERFACE_INCLUDE_DIRECTORIES "''' + join_paths('${PACKAGE_PREFIX_DIR}', get_option('includedir')) + '")')
87+
endif
88+
if get_option('default_library') == 'static' or get_option('default_library') == 'both'
89+
cmakeconf.set('MESON_STATIC_TARGET', '''
90+
add_library(jsoncpp_static IMPORTED STATIC)
91+
set_target_properties(jsoncpp_static PROPERTIES
92+
IMPORTED_LOCATION "''' + join_paths('${PACKAGE_PREFIX_DIR}', get_option('libdir'), static_name) + '''"
93+
INTERFACE_INCLUDE_DIRECTORIES "''' + join_paths('${PACKAGE_PREFIX_DIR}', get_option('includedir')) + '")')
94+
endif
95+
96+
import('cmake').configure_package_config_file(
97+
name: 'jsoncpp',
98+
input: 'jsoncppConfig.cmake.meson.in',
99+
configuration: cmakeconf)
100+
install_data('jsoncpp-namespaced-targets.cmake', install_dir : join_paths(get_option('libdir'), 'cmake', jsoncpp_lib.name()))
101+
65102
# for libraries bundling jsoncpp
66103
jsoncpp_dep = declare_dependency(
67104
include_directories : jsoncpp_include_directories,

src/lib_json/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ if(BUILD_SHARED_LIBS)
132132
target_include_directories(${SHARED_LIB} PUBLIC
133133
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
134134
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
135-
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/json>
136135
)
137136

138137
list(APPEND CMAKE_TARGETS ${SHARED_LIB})
@@ -166,7 +165,6 @@ if(BUILD_STATIC_LIBS)
166165
target_include_directories(${STATIC_LIB} PUBLIC
167166
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
168167
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
169-
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/json>
170168
)
171169

172170
list(APPEND CMAKE_TARGETS ${STATIC_LIB})
@@ -193,7 +191,6 @@ if(BUILD_OBJECT_LIBS)
193191
target_include_directories(${OBJECT_LIB} PUBLIC
194192
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
195193
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
196-
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/json>
197194
)
198195

199196
list(APPEND CMAKE_TARGETS ${OBJECT_LIB})

src/lib_json/json_reader.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,7 @@ bool Reader::decodeDouble(Token& token) {
587587

588588
bool Reader::decodeDouble(Token& token, Value& decoded) {
589589
double value = 0;
590-
String buffer(token.start_, token.end_);
591-
IStringStream is(buffer);
590+
IStringStream is(String(token.start_, token.end_));
592591
if (!(is >> value)) {
593592
if (value == std::numeric_limits<double>::max())
594593
value = std::numeric_limits<double>::infinity();
@@ -1622,8 +1621,7 @@ bool OurReader::decodeDouble(Token& token) {
16221621

16231622
bool OurReader::decodeDouble(Token& token, Value& decoded) {
16241623
double value = 0;
1625-
const String buffer(token.start_, token.end_);
1626-
IStringStream is(buffer);
1624+
IStringStream is(String(token.start_, token.end_));
16271625
if (!(is >> value)) {
16281626
if (value == std::numeric_limits<double>::max())
16291627
value = std::numeric_limits<double>::infinity();
@@ -1963,6 +1961,22 @@ void CharReaderBuilder::setDefaults(Json::Value* settings) {
19631961
(*settings)["skipBom"] = true;
19641962
//! [CharReaderBuilderDefaults]
19651963
}
1964+
// static
1965+
void CharReaderBuilder::ecma404Mode(Json::Value* settings) {
1966+
//! [CharReaderBuilderECMA404Mode]
1967+
(*settings)["allowComments"] = false;
1968+
(*settings)["allowTrailingCommas"] = false;
1969+
(*settings)["strictRoot"] = false;
1970+
(*settings)["allowDroppedNullPlaceholders"] = false;
1971+
(*settings)["allowNumericKeys"] = false;
1972+
(*settings)["allowSingleQuotes"] = false;
1973+
(*settings)["stackLimit"] = 1000;
1974+
(*settings)["failIfExtra"] = true;
1975+
(*settings)["rejectDupKeys"] = false;
1976+
(*settings)["allowSpecialFloats"] = false;
1977+
(*settings)["skipBom"] = false;
1978+
//! [CharReaderBuilderECMA404Mode]
1979+
}
19661980

19671981
std::vector<CharReader::StructuredError>
19681982
CharReader::getStructuredErrors() const {
@@ -1981,7 +1995,7 @@ bool parseFromStream(CharReader::Factory const& fact, IStream& sin, Value* root,
19811995
String* errs) {
19821996
OStringStream ssin;
19831997
ssin << sin.rdbuf();
1984-
String doc = ssin.str();
1998+
String doc = std::move(ssin).str();
19851999
char const* begin = doc.data();
19862000
char const* end = begin + doc.size();
19872001
// Note that we do not actually need a null-terminator.

0 commit comments

Comments
 (0)