mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-15 07:14:45 +02:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d8cd848ede | ||
![]() |
92259f7147 | ||
![]() |
4a431bcdac | ||
![]() |
7d868636de | ||
![]() |
ab0f1e234a | ||
![]() |
45a560a8c0 | ||
![]() |
4893a8f667 | ||
![]() |
f6d785fda8 | ||
![]() |
8d54e333ff | ||
![]() |
b063cf4ada | ||
![]() |
c4ab6d733f | ||
![]() |
2f97c0147b | ||
![]() |
52cfe5ae88 |
@@ -22,6 +22,11 @@ IF(NOT WIN32)
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
# Enable runtime search path support for dynamic libraries on OSX
|
||||||
|
IF(APPLE)
|
||||||
|
SET(CMAKE_MACOSX_RPATH 1)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
SET(DEBUG_LIBNAME_SUFFIX "" CACHE STRING "Optional suffix to append to the library name for a debug build")
|
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(LIB_SUFFIX "" CACHE STRING "Optional arch-dependent suffix for the library installation directory")
|
||||||
|
|
||||||
@@ -64,11 +69,12 @@ ENDMACRO()
|
|||||||
#SET( JSONCPP_VERSION_MAJOR X )
|
#SET( JSONCPP_VERSION_MAJOR X )
|
||||||
#SET( JSONCPP_VERSION_MINOR Y )
|
#SET( JSONCPP_VERSION_MINOR Y )
|
||||||
#SET( JSONCPP_VERSION_PATCH Z )
|
#SET( JSONCPP_VERSION_PATCH Z )
|
||||||
SET( JSONCPP_VERSION 1.7.5 )
|
SET( JSONCPP_VERSION 1.7.7 )
|
||||||
jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION )
|
jsoncpp_parse_version( ${JSONCPP_VERSION} JSONCPP_VERSION )
|
||||||
#IF(NOT JSONCPP_VERSION_FOUND)
|
#IF(NOT JSONCPP_VERSION_FOUND)
|
||||||
# MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
|
# MESSAGE(FATAL_ERROR "Failed to parse version string properly. Expect X.Y.Z")
|
||||||
#ENDIF(NOT JSONCPP_VERSION_FOUND)
|
#ENDIF(NOT JSONCPP_VERSION_FOUND)
|
||||||
|
SET( JSONCPP_SOVERSION 11 )
|
||||||
SET( JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL" )
|
SET( JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL" )
|
||||||
|
|
||||||
MESSAGE(STATUS "JsonCpp Version: ${JSONCPP_VERSION_MAJOR}.${JSONCPP_VERSION_MINOR}.${JSONCPP_VERSION_PATCH}")
|
MESSAGE(STATUS "JsonCpp Version: ${JSONCPP_VERSION_MAJOR}.${JSONCPP_VERSION_MINOR}.${JSONCPP_VERSION_PATCH}")
|
||||||
|
@@ -6,7 +6,8 @@
|
|||||||
#ifndef JSON_CONFIG_H_INCLUDED
|
#ifndef JSON_CONFIG_H_INCLUDED
|
||||||
#define JSON_CONFIG_H_INCLUDED
|
#define JSON_CONFIG_H_INCLUDED
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string> //typdef String
|
#include <string> //typedef String
|
||||||
|
#include <stdint.h> //typedef int64_t, uint64_t
|
||||||
|
|
||||||
/// If defined, indicates that json library is embedded in CppTL library.
|
/// If defined, indicates that json library is embedded in CppTL library.
|
||||||
//# define JSON_IN_CPPTL 1
|
//# define JSON_IN_CPPTL 1
|
||||||
|
@@ -3,10 +3,10 @@
|
|||||||
#ifndef JSON_VERSION_H_INCLUDED
|
#ifndef JSON_VERSION_H_INCLUDED
|
||||||
# define JSON_VERSION_H_INCLUDED
|
# define JSON_VERSION_H_INCLUDED
|
||||||
|
|
||||||
# define JSONCPP_VERSION_STRING "1.7.5"
|
# define JSONCPP_VERSION_STRING "1.7.7"
|
||||||
# define JSONCPP_VERSION_MAJOR 1
|
# define JSONCPP_VERSION_MAJOR 1
|
||||||
# define JSONCPP_VERSION_MINOR 7
|
# define JSONCPP_VERSION_MINOR 7
|
||||||
# define JSONCPP_VERSION_PATCH 5
|
# define JSONCPP_VERSION_PATCH 7
|
||||||
# define JSONCPP_VERSION_QUALIFIER
|
# define JSONCPP_VERSION_QUALIFIER
|
||||||
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
|
||||||
|
|
||||||
|
@@ -42,10 +42,15 @@ ENDIF()
|
|||||||
IF(BUILD_SHARED_LIBS)
|
IF(BUILD_SHARED_LIBS)
|
||||||
ADD_DEFINITIONS( -DJSON_DLL_BUILD )
|
ADD_DEFINITIONS( -DJSON_DLL_BUILD )
|
||||||
ADD_LIBRARY(jsoncpp_lib SHARED ${PUBLIC_HEADERS} ${jsoncpp_sources})
|
ADD_LIBRARY(jsoncpp_lib SHARED ${PUBLIC_HEADERS} ${jsoncpp_sources})
|
||||||
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_VERSION_MAJOR})
|
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_SOVERSION})
|
||||||
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES OUTPUT_NAME jsoncpp
|
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES OUTPUT_NAME jsoncpp
|
||||||
DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )
|
DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )
|
||||||
|
|
||||||
|
# Set library's runtime search path on OSX
|
||||||
|
IF(APPLE)
|
||||||
|
SET_TARGET_PROPERTIES( jsoncpp_lib PROPERTIES INSTALL_RPATH "@loader_path/." )
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
INSTALL( TARGETS jsoncpp_lib ${INSTALL_EXPORT}
|
INSTALL( TARGETS jsoncpp_lib ${INSTALL_EXPORT}
|
||||||
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
|
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
|
||||||
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
|
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
|
||||||
@@ -61,7 +66,7 @@ ENDIF()
|
|||||||
|
|
||||||
IF(BUILD_STATIC_LIBS)
|
IF(BUILD_STATIC_LIBS)
|
||||||
ADD_LIBRARY(jsoncpp_lib_static STATIC ${PUBLIC_HEADERS} ${jsoncpp_sources})
|
ADD_LIBRARY(jsoncpp_lib_static STATIC ${PUBLIC_HEADERS} ${jsoncpp_sources})
|
||||||
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_VERSION_MAJOR})
|
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES VERSION ${JSONCPP_VERSION} SOVERSION ${JSONCPP_SOVERSION})
|
||||||
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES OUTPUT_NAME jsoncpp
|
SET_TARGET_PROPERTIES( jsoncpp_lib_static PROPERTIES OUTPUT_NAME jsoncpp
|
||||||
DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )
|
DEBUG_OUTPUT_NAME jsoncpp${DEBUG_LIBNAME_SUFFIX} )
|
||||||
|
|
||||||
|
@@ -401,7 +401,7 @@ Reader::addComment(Location begin, Location end, CommentPlacement placement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Reader::readCStyleComment() {
|
bool Reader::readCStyleComment() {
|
||||||
while (current_ != end_) {
|
while ((current_ + 1) < end_) {
|
||||||
Char c = getNextChar();
|
Char c = getNextChar();
|
||||||
if (c == '*' && *current_ == '/')
|
if (c == '*' && *current_ == '/')
|
||||||
break;
|
break;
|
||||||
@@ -520,7 +520,7 @@ bool Reader::readArray(Token& tokenStart) {
|
|||||||
currentValue().swapPayload(init);
|
currentValue().swapPayload(init);
|
||||||
currentValue().setOffsetStart(tokenStart.start_ - begin_);
|
currentValue().setOffsetStart(tokenStart.start_ - begin_);
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
if (*current_ == ']') // empty array
|
if (current_ != end_ && *current_ == ']') // empty array
|
||||||
{
|
{
|
||||||
Token endArray;
|
Token endArray;
|
||||||
readToken(endArray);
|
readToken(endArray);
|
||||||
@@ -1361,7 +1361,7 @@ OurReader::addComment(Location begin, Location end, CommentPlacement placement)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OurReader::readCStyleComment() {
|
bool OurReader::readCStyleComment() {
|
||||||
while (current_ != end_) {
|
while ((current_ + 1) < end_) {
|
||||||
Char c = getNextChar();
|
Char c = getNextChar();
|
||||||
if (c == '*' && *current_ == '/')
|
if (c == '*' && *current_ == '/')
|
||||||
break;
|
break;
|
||||||
@@ -1503,7 +1503,7 @@ bool OurReader::readArray(Token& tokenStart) {
|
|||||||
currentValue().swapPayload(init);
|
currentValue().swapPayload(init);
|
||||||
currentValue().setOffsetStart(tokenStart.start_ - begin_);
|
currentValue().setOffsetStart(tokenStart.start_ - begin_);
|
||||||
skipSpaces();
|
skipSpaces();
|
||||||
if (*current_ == ']') // empty array
|
if (current_ != end_ && *current_ == ']') // empty array
|
||||||
{
|
{
|
||||||
Token endArray;
|
Token endArray;
|
||||||
readToken(endArray);
|
readToken(endArray);
|
||||||
|
@@ -5,7 +5,10 @@
|
|||||||
|
|
||||||
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||||
#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef NO_LOCALE_SUPPORT
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This header provides common string manipulation support, such as UTF-8,
|
/* This header provides common string manipulation support, such as UTF-8,
|
||||||
* portable conversion from/to string...
|
* portable conversion from/to string...
|
||||||
@@ -14,26 +17,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Json {
|
namespace Json {
|
||||||
|
static char getDecimalPoint() {
|
||||||
/// Fallback for decimal_point on android, where the lconv is an empty struct.
|
#ifdef NO_LOCALE_SUPPORT
|
||||||
template<typename Lconv, bool=(sizeof(Lconv) >= sizeof(char*))>
|
return '\0';
|
||||||
struct Locale {
|
#else
|
||||||
static char decimalPoint() {
|
struct lconv* lc = localeconv();
|
||||||
return '\0';
|
return lc ? *(lc->decimal_point) : '\0';
|
||||||
}
|
#endif
|
||||||
};
|
}
|
||||||
|
|
||||||
/// Return decimal_point for the current locale.
|
|
||||||
template<typename Lconv>
|
|
||||||
struct Locale<Lconv, true> {
|
|
||||||
static char decimalPoint() {
|
|
||||||
Lconv* lc = localeconv();
|
|
||||||
if (lc == NULL) {
|
|
||||||
return '\0';
|
|
||||||
}
|
|
||||||
return *(lc->decimal_point);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Converts a unicode code-point to UTF-8.
|
/// Converts a unicode code-point to UTF-8.
|
||||||
static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
|
||||||
@@ -104,7 +95,7 @@ static inline void fixNumericLocale(char* begin, char* end) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void fixNumericLocaleInput(char* begin, char* end) {
|
static inline void fixNumericLocaleInput(char* begin, char* end) {
|
||||||
char decimalPoint = Locale<struct lconv>::decimalPoint();
|
char decimalPoint = getDecimalPoint();
|
||||||
if (decimalPoint != '\0' && decimalPoint != '.') {
|
if (decimalPoint != '\0' && decimalPoint != '.') {
|
||||||
while (begin < end) {
|
while (begin < end) {
|
||||||
if (*begin == '.') {
|
if (*begin == '.') {
|
||||||
|
@@ -1504,12 +1504,12 @@ void Path::makePath(const JSONCPP_STRING& path, const InArgs& in) {
|
|||||||
index = index * 10 + ArrayIndex(*current - '0');
|
index = index * 10 + ArrayIndex(*current - '0');
|
||||||
args_.push_back(index);
|
args_.push_back(index);
|
||||||
}
|
}
|
||||||
if (current == end || *current++ != ']')
|
if (current == end || *++current != ']')
|
||||||
invalidPath(path, int(current - path.c_str()));
|
invalidPath(path, int(current - path.c_str()));
|
||||||
} else if (*current == '%') {
|
} else if (*current == '%') {
|
||||||
addPathInArg(path, in, itInArg, PathArgument::kindKey);
|
addPathInArg(path, in, itInArg, PathArgument::kindKey);
|
||||||
++current;
|
++current;
|
||||||
} else if (*current == '.') {
|
} else if (*current == '.' || *current == ']') {
|
||||||
++current;
|
++current;
|
||||||
} else {
|
} else {
|
||||||
const char* beginName = current;
|
const char* beginName = current;
|
||||||
@@ -1529,7 +1529,7 @@ void Path::addPathInArg(const JSONCPP_STRING& /*path*/,
|
|||||||
} else if ((*itInArg)->kind_ != kind) {
|
} else if ((*itInArg)->kind_ != kind) {
|
||||||
// Error: bad argument type
|
// Error: bad argument type
|
||||||
} else {
|
} else {
|
||||||
args_.push_back(**itInArg);
|
args_.push_back(**itInArg++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1544,16 +1544,19 @@ const Value& Path::resolve(const Value& root) const {
|
|||||||
if (arg.kind_ == PathArgument::kindIndex) {
|
if (arg.kind_ == PathArgument::kindIndex) {
|
||||||
if (!node->isArray() || !node->isValidIndex(arg.index_)) {
|
if (!node->isArray() || !node->isValidIndex(arg.index_)) {
|
||||||
// Error: unable to resolve path (array value expected at position...
|
// Error: unable to resolve path (array value expected at position...
|
||||||
|
return Value::null;
|
||||||
}
|
}
|
||||||
node = &((*node)[arg.index_]);
|
node = &((*node)[arg.index_]);
|
||||||
} else if (arg.kind_ == PathArgument::kindKey) {
|
} else if (arg.kind_ == PathArgument::kindKey) {
|
||||||
if (!node->isObject()) {
|
if (!node->isObject()) {
|
||||||
// Error: unable to resolve path (object value expected at position...)
|
// Error: unable to resolve path (object value expected at position...)
|
||||||
|
return Value::null;
|
||||||
}
|
}
|
||||||
node = &((*node)[arg.key_]);
|
node = &((*node)[arg.key_]);
|
||||||
if (node == &Value::nullSingleton()) {
|
if (node == &Value::nullSingleton()) {
|
||||||
// Error: unable to resolve path (object has no member named '' at
|
// Error: unable to resolve path (object has no member named '' at
|
||||||
// position...)
|
// position...)
|
||||||
|
return Value::null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user