mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-07-03 10:17:11 +02:00
Merge branch 'master' into master
This commit is contained in:
commit
4dea76dfaf
@ -62,11 +62,11 @@ project(jsoncpp
|
|||||||
# 2. ./include/json/version.h
|
# 2. ./include/json/version.h
|
||||||
# 3. ./CMakeLists.txt
|
# 3. ./CMakeLists.txt
|
||||||
# IMPORTANT: also update the PROJECT_SOVERSION!!
|
# IMPORTANT: also update the PROJECT_SOVERSION!!
|
||||||
VERSION 1.9.6 # <major>[.<minor>[.<patch>[.<tweak>]]]
|
VERSION 1.9.7 # <major>[.<minor>[.<patch>[.<tweak>]]]
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
|
|
||||||
message(STATUS "JsonCpp Version: ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
message(STATUS "JsonCpp Version: ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
||||||
set(PROJECT_SOVERSION 26)
|
set(PROJECT_SOVERSION 27)
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInSourceBuilds.cmake)
|
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInSourceBuilds.cmake)
|
||||||
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInBuildInstalls.cmake)
|
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInBuildInstalls.cmake)
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
// 3. /CMakeLists.txt
|
// 3. /CMakeLists.txt
|
||||||
// IMPORTANT: also update the SOVERSION!!
|
// IMPORTANT: also update the SOVERSION!!
|
||||||
|
|
||||||
#define JSONCPP_VERSION_STRING "1.9.6"
|
#define JSONCPP_VERSION_STRING "1.9.7"
|
||||||
#define JSONCPP_VERSION_MAJOR 1
|
#define JSONCPP_VERSION_MAJOR 1
|
||||||
#define JSONCPP_VERSION_MINOR 9
|
#define JSONCPP_VERSION_MINOR 9
|
||||||
#define JSONCPP_VERSION_PATCH 6
|
#define JSONCPP_VERSION_PATCH 7
|
||||||
#define JSONCPP_VERSION_QUALIFIER
|
#define JSONCPP_VERSION_QUALIFIER
|
||||||
#define JSONCPP_VERSION_HEXA \
|
#define JSONCPP_VERSION_HEXA \
|
||||||
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
|
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
|
||||||
|
@ -9,7 +9,7 @@ project(
|
|||||||
# 2. /include/json/version.h
|
# 2. /include/json/version.h
|
||||||
# 3. /CMakeLists.txt
|
# 3. /CMakeLists.txt
|
||||||
# IMPORTANT: also update the SOVERSION!!
|
# IMPORTANT: also update the SOVERSION!!
|
||||||
version : '1.9.6',
|
version : '1.9.7',
|
||||||
default_options : [
|
default_options : [
|
||||||
'buildtype=release',
|
'buildtype=release',
|
||||||
'cpp_std=c++11',
|
'cpp_std=c++11',
|
||||||
@ -50,7 +50,7 @@ jsoncpp_lib = library(
|
|||||||
'src/lib_json/json_value.cpp',
|
'src/lib_json/json_value.cpp',
|
||||||
'src/lib_json/json_writer.cpp',
|
'src/lib_json/json_writer.cpp',
|
||||||
]),
|
]),
|
||||||
soversion : 26,
|
soversion : 27,
|
||||||
install : true,
|
install : true,
|
||||||
include_directories : jsoncpp_include_directories,
|
include_directories : jsoncpp_include_directories,
|
||||||
cpp_args: dll_export_flag)
|
cpp_args: dll_export_flag)
|
||||||
|
@ -87,7 +87,8 @@ template <typename T, typename U>
|
|||||||
static inline bool InRange(double d, T min, U max) {
|
static inline bool InRange(double d, T min, U max) {
|
||||||
// The casts can lose precision, but we are looking only for
|
// The casts can lose precision, but we are looking only for
|
||||||
// an approximate range. Might fail on edge cases though. ~cdunn
|
// an approximate range. Might fail on edge cases though. ~cdunn
|
||||||
return d >= static_cast<double>(min) && d <= static_cast<double>(max);
|
return d >= static_cast<double>(min) && d <= static_cast<double>(max) &&
|
||||||
|
!(static_cast<U>(d) == min && d != static_cast<double>(min));
|
||||||
}
|
}
|
||||||
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||||
static inline double integerToDouble(Json::UInt64 value) {
|
static inline double integerToDouble(Json::UInt64 value) {
|
||||||
@ -101,7 +102,8 @@ template <typename T> static inline double integerToDouble(T value) {
|
|||||||
|
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
static inline bool InRange(double d, T min, U max) {
|
static inline bool InRange(double d, T min, U max) {
|
||||||
return d >= integerToDouble(min) && d <= integerToDouble(max);
|
return d >= integerToDouble(min) && d <= integerToDouble(max) &&
|
||||||
|
!(static_cast<U>(d) == min && d != integerToDouble(min));
|
||||||
}
|
}
|
||||||
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||||
|
|
||||||
@ -705,6 +707,11 @@ Value::Int64 Value::asInt64() const {
|
|||||||
JSON_ASSERT_MESSAGE(isInt64(), "LargestUInt out of Int64 range");
|
JSON_ASSERT_MESSAGE(isInt64(), "LargestUInt out of Int64 range");
|
||||||
return Int64(value_.uint_);
|
return Int64(value_.uint_);
|
||||||
case realValue:
|
case realValue:
|
||||||
|
// If the double value is in proximity to minInt64, it will be rounded to
|
||||||
|
// minInt64. The correct value in this scenario is indeterminable
|
||||||
|
JSON_ASSERT_MESSAGE(
|
||||||
|
value_.real_ != minInt64,
|
||||||
|
"Double value is minInt64, precise value cannot be determined");
|
||||||
JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt64, maxInt64),
|
JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt64, maxInt64),
|
||||||
"double out of Int64 range");
|
"double out of Int64 range");
|
||||||
return Int64(value_.real_);
|
return Int64(value_.real_);
|
||||||
|
@ -1191,15 +1191,13 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, integers) {
|
|||||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||||
JSONTEST_ASSERT_STRING_EQUAL("-9223372036854775808", val.asString());
|
JSONTEST_ASSERT_STRING_EQUAL("-9223372036854775808", val.asString());
|
||||||
|
|
||||||
// int64 min (floating point constructor). Note that kint64min *is* exactly
|
// int64 min (floating point constructor). Since double values in proximity of
|
||||||
// representable as a double.
|
// kint64min are rounded to kint64min, we don't check for conversion to int64.
|
||||||
val = Json::Value(double(kint64min));
|
val = Json::Value(double(kint64min));
|
||||||
|
|
||||||
JSONTEST_ASSERT_EQUAL(Json::realValue, val.type());
|
JSONTEST_ASSERT_EQUAL(Json::realValue, val.type());
|
||||||
|
|
||||||
checks = IsCheck();
|
checks = IsCheck();
|
||||||
checks.isInt64_ = true;
|
|
||||||
checks.isIntegral_ = true;
|
|
||||||
checks.isDouble_ = true;
|
checks.isDouble_ = true;
|
||||||
checks.isNumeric_ = true;
|
checks.isNumeric_ = true;
|
||||||
JSONTEST_ASSERT_PRED(checkIs(val, checks));
|
JSONTEST_ASSERT_PRED(checkIs(val, checks));
|
||||||
@ -1208,8 +1206,6 @@ JSONTEST_FIXTURE_LOCAL(ValueTest, integers) {
|
|||||||
JSONTEST_ASSERT(!val.isConvertibleTo(Json::intValue));
|
JSONTEST_ASSERT(!val.isConvertibleTo(Json::intValue));
|
||||||
JSONTEST_ASSERT(!val.isConvertibleTo(Json::uintValue));
|
JSONTEST_ASSERT(!val.isConvertibleTo(Json::uintValue));
|
||||||
|
|
||||||
JSONTEST_ASSERT_EQUAL(kint64min, val.asInt64());
|
|
||||||
JSONTEST_ASSERT_EQUAL(kint64min, val.asLargestInt());
|
|
||||||
JSONTEST_ASSERT_EQUAL(-9223372036854775808.0, val.asDouble());
|
JSONTEST_ASSERT_EQUAL(-9223372036854775808.0, val.asDouble());
|
||||||
JSONTEST_ASSERT_EQUAL(-9223372036854775808.0, val.asFloat());
|
JSONTEST_ASSERT_EQUAL(-9223372036854775808.0, val.asFloat());
|
||||||
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
JSONTEST_ASSERT_EQUAL(true, val.asBool());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user