# CMake-generated files:
CMakeFiles/
-CTestTestFile.cmake
-cmake_install.cmake
+*.cmake
pkg-config/jsoncpp.pc
jsoncpp_lib_static.dir/
/src/lib_json/Makefile
/src/test_lib_json/Makefile
/src/test_lib_json/jsoncpp_test
+*.a
# eclipse project files
.project
install:
# /usr/bin/gcc is 4.6 always, but gcc-X.Y is available.
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
-# /usr/bin/clang is our version already, and clang-X.Y does not exist.
-#- if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi
+# /usr/bin/clang has a conflict with gcc, so use clang-X.Y.
+- if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.5" CC="clang-3.5"; fi
- echo ${PATH}
- ls /usr/local
- ls /usr/local/bin
apt:
sources:
- ubuntu-toolchain-r-test
+ - llvm-toolchain-precise-3.5
+ - george-edison55-precise-backports # cmake 3.2.3
packages:
+ - cmake
+ - cmake-data
- gcc-4.9
- g++-4.9
- - clang
+ - clang-3.5
- valgrind
os:
- linux
# 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()
SET(CMAKE_MACOSX_RPATH 1)
ENDIF()
+# 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(LIB_SUFFIX "" CACHE STRING "Optional arch-dependent suffix for the library installation directory")
-
-SET(RUNTIME_INSTALL_DIR bin
- CACHE PATH "Install dir for executables and dlls")
-SET(ARCHIVE_INSTALL_DIR lib${LIB_SUFFIX}
- CACHE PATH "Install dir for static libraries")
-SET(LIBRARY_INSTALL_DIR lib${LIB_SUFFIX}
- CACHE PATH "Install dir for shared libraries")
-SET(INCLUDE_INSTALL_DIR include
- CACHE PATH "Install dir for headers")
-SET(PACKAGE_INSTALL_DIR lib${LIB_SUFFIX}/cmake
- CACHE PATH "Install dir for cmake package config files")
-MARK_AS_ADVANCED( RUNTIME_INSTALL_DIR ARCHIVE_INSTALL_DIR INCLUDE_INSTALL_DIR PACKAGE_INSTALL_DIR )
# Set variable named ${VAR_NAME} to value ${VALUE}
FUNCTION(set_using_dynamic_name VAR_NAME VALUE)
#SET( JSONCPP_VERSION_MAJOR X )
#SET( JSONCPP_VERSION_MINOR Y )
#SET( JSONCPP_VERSION_PATCH Z )
-SET( JSONCPP_VERSION 1.7.7 )
+SET( JSONCPP_VERSION 1.8.0 )
jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION )
#IF(NOT JSONCPP_VERSION_FOUND)
# MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
"${PROJECT_SOURCE_DIR}/version"
NEWLINE_STYLE UNIX )
-macro(UseCompilationWarningAsError)
- if ( MSVC )
+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()
+ 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()
-
-if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- # using regular Clang or AppleClang
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Werror=conversion -Werror=sign-compare")
-elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
- # using GCC
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Wextra")
- # not yet ready for -Wsign-conversion
-
- if (JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=conversion -pedantic")
- endif ()
-elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
- # using Intel compiler
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wconversion -Wshadow -Wextra -Werror=conversion")
-
- if (JSONCPP_WITH_STRICT_ISO AND NOT JSONCPP_WITH_WARNING_AS_ERROR)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
- endif ()
-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)
+ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 ")
+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 AND NOT JSONCPP_WITH_WARNING_AS_ERROR)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=conversion -pedantic")
+ ENDIF()
+ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+ # using Intel compiler
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -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_CURRENT_BINARY_DIR}/pkg-config/jsoncpp.pc"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig")
+ 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()
FILE(GLOB INCLUDE_FILES "json/*.h")
-INSTALL(FILES ${INCLUDE_FILES} DESTINATION ${INCLUDE_INSTALL_DIR}/json)
+INSTALL(FILES ${INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json)
#include <cstring>
#include <memory>
+#pragma pack(push, 8)
+
namespace Json {
template<typename T>
class SecureAllocator {
} //namespace Json
+#pragma pack(pop)
+
#endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED
// managable and fixes a set of common hard-to-find bugs.
#if __cplusplus >= 201103L
# define JSONCPP_OVERRIDE override
-#elif defined(_MSC_VER) && _MSC_VER > 1600
+# define JSONCPP_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
#ifndef JSON_HAS_RVALUE_REFERENCES
#include "forwards.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
+#pragma pack(push, 8)
+
namespace Json {
/** \brief Configuration passed to reader and writer.
} // namespace Json
+#pragma pack(pop)
+
#endif // CPPTL_JSON_FEATURES_H_INCLUDED
#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
} // namespace Json
+#pragma pack(pop)
+
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(pop)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(disable : 4251)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
+#pragma pack(push, 8)
+
/** \brief JSON (JavaScript Object Notation).
*/
namespace Json {
class JSON_API Exception : public std::exception {
public:
Exception(JSONCPP_STRING const& msg);
- ~Exception() throw() JSONCPP_OVERRIDE;
- char const* what() const throw() JSONCPP_OVERRIDE;
+ ~Exception() JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
+ char const* what() const JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
protected:
JSONCPP_STRING msg_;
};
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)
#ifndef JSON_VERSION_H_INCLUDED
# define JSON_VERSION_H_INCLUDED
-# define JSONCPP_VERSION_STRING "1.7.7"
+# define JSONCPP_VERSION_STRING "1.8.0"
# define JSONCPP_VERSION_MAJOR 1
-# define JSONCPP_VERSION_MINOR 7
-# define JSONCPP_VERSION_PATCH 7
+# define JSONCPP_VERSION_MINOR 8
+# define JSONCPP_VERSION_PATCH 0
# define JSONCPP_VERSION_QUALIFIER
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
#pragma warning(disable : 4251)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
+#pragma pack(push, 8)
+
namespace Json {
class Value;
} // namespace Json
+#pragma pack(pop)
+
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(pop)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
-libdir=${exec_prefix}/@LIBRARY_INSTALL_DIR@
-includedir=${prefix}/@INCLUDE_INSTALL_DIR@
+libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: jsoncpp
Description: A C++ library for interacting with JSON
-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 )
ENDIF()
INSTALL( TARGETS jsoncpp_lib ${INSTALL_EXPORT}
- RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
- LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
- ARCHIVE DESTINATION ${ARCHIVE_INSTALL_DIR})
+ 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()
DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )
INSTALL( TARGETS jsoncpp_lib_static ${INSTALL_EXPORT}
- RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
- LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
- ARCHIVE DESTINATION ${ARCHIVE_INSTALL_DIR})
+ 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()
// Copyright 2007-2011 Baptiste Lepilleur
+// Copyright (C) 2016 InfoTeCS JSC. All rights reserved.
// 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
#pragma warning(disable : 4996)
#endif
-static int const stackLimit_g = 1000;
-static int stackDepth_g = 0; // see readValue()
+// Define JSONCPP_DEPRECATED_STACK_LIMIT as an appropriate integer at compile time to change the stack limit
+#if !defined(JSONCPP_DEPRECATED_STACK_LIMIT)
+#define JSONCPP_DEPRECATED_STACK_LIMIT 1000
+#endif
+
+static size_t const stackLimit_g = JSONCPP_DEPRECATED_STACK_LIMIT; // see readValue()
namespace Json {
nodes_.pop();
nodes_.push(&root);
- stackDepth_g = 0; // Yes, this is bad coding, but options are limited.
bool successful = readValue();
Token token;
skipCommentTokens(token);
}
bool Reader::readValue() {
- // This is a non-reentrant way to support a stackLimit. Terrible!
- // But this deprecated class has a security problem: Bad input can
- // cause a seg-fault. This seems like a fair, binary-compatible way
- // to prevent the problem.
- if (stackDepth_g >= stackLimit_g) throwRuntimeError("Exceeded stackLimit in readValue().");
- ++stackDepth_g;
+ // readValue() may call itself only if it calls readObject() or ReadArray().
+ // These methods execute nodes_.push() just before and nodes_.pop)() just after calling readValue().
+ // parse() executes one nodes_.push(), so > instead of >=.
+ if (nodes_.size() > stackLimit_g) throwRuntimeError("Exceeded stackLimit in readValue().");
Token token;
skipCommentTokens(token);
lastValue_ = ¤tValue();
}
- --stackDepth_g;
return successful;
}
Location lastValueEnd_;
Value* lastValue_;
JSONCPP_STRING commentsBefore_;
- int stackDepth_;
OurFeatures const features_;
bool collectComments_;
OurReader::OurReader(OurFeatures const& features)
: errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
lastValue_(), commentsBefore_(),
- stackDepth_(0),
features_(features), collectComments_() {
}
nodes_.pop();
nodes_.push(&root);
- stackDepth_ = 0;
bool successful = readValue();
Token token;
skipCommentTokens(token);
}
bool OurReader::readValue() {
- if (stackDepth_ >= features_.stackLimit_) throwRuntimeError("Exceeded stackLimit in readValue().");
- ++stackDepth_;
+ // To preserve the old behaviour we cast size_t to int.
+ if (static_cast<int>(nodes_.size()) > features_.stackLimit_) throwRuntimeError("Exceeded stackLimit in readValue().");
Token token;
skipCommentTokens(token);
bool successful = true;
lastValue_ = ¤tValue();
}
- --stackDepth_;
return successful;
}
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
-#ifndef NO_LOCALE_SUPPORT
+
+// 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
namespace Json {
static char getDecimalPoint() {
-#ifdef NO_LOCALE_SUPPORT
+#ifdef JSONCPP_NO_LOCALE_SUPPORT
return '\0';
#else
struct lconv* lc = localeconv();
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();
}
* This optimization is used in ValueInternalMap fast allocator.
*/
Value::Value(ValueType vtype) {
- static char const empty[] = "";
+ static char const emptyString[] = "";
initBasic(vtype);
switch (vtype) {
case nullValue:
break;
case stringValue:
// allocated_ == false, so this is safe.
- value_.string_ = const_cast<char*>(static_cast<char const*>(empty));
+ value_.string_ = const_cast<char*>(static_cast<char const*>(emptyString));
break;
case arrayValue:
case objectValue:
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:
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_);
#endif
}
-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; }
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];
// concepts of reals and integers.
if (isfinite(value)) {
len = snprintf(buffer, sizeof(buffer), formatString, value);
+
+ // try to ensure we preserve the fact that this was given to us as a double on input
+ if (!strstr(buffer, ".") && !strstr(buffer, "e")) {
+ strcat(buffer, ".0");
+ }
+
} else {
// IEEE standard states that NaN values will not compare to themselves
if (value != value) {
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);
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);
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",
+ JSONTEST_ASSERT_STRING_EQUAL("1048576.0",
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
// -2^20
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",
+ JSONTEST_ASSERT_STRING_EQUAL("1099511627776.0",
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
// -2^40
// A 16-digit floating point number.
val = Json::Value(2199023255552000.0f);
JSONTEST_ASSERT_EQUAL(float(2199023255552000.0f), val.asFloat());
- JSONTEST_ASSERT_STRING_EQUAL("2199023255552000",
+ JSONTEST_ASSERT_STRING_EQUAL("2199023255552000.0",
normalizeFloatingPointStr(JsonTest::ToJsonString(val.asString())));
// A very large floating point number.
--- /dev/null
+[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[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