forked from Mirrorlandia_minetest/minetest
Update JsonCPP to 1.8.3 (#6466)
* Update JsonCPP to 1.8.3 * Fix deprecated functions Json::FastWriter, Json::StyledWriter and Json::Reader are marked deprecated since 1.1 and are deprecated in 0.8 but not shown at compilation time. Use new methods to serialize/deserialize
This commit is contained in:
parent
f7e57a0d20
commit
50423d8c72
@ -1,16 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd ..
|
cd ..
|
||||||
svn co https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/jsoncpp jsoncpp
|
git clone https://github.com/open-source-parsers/jsoncpp -b 1.8.3 --depth 1
|
||||||
svn up jsoncpp
|
|
||||||
cd jsoncpp
|
cd jsoncpp
|
||||||
python amalgamate.py
|
python amalgamate.py
|
||||||
cp -R dist/json ..
|
cp -R dist/json ../json
|
||||||
cp dist/jsoncpp.cpp ../json
|
cp dist/jsoncpp.cpp ..
|
||||||
|
|
||||||
# maybe you need to patch:
|
|
||||||
# src/json/jsoncpp.cpp:
|
|
||||||
# -#include <json/json.h>
|
|
||||||
# +#include "json/json.h"
|
|
||||||
|
|
||||||
#svn export --force https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/jsoncpp/src/lib_json json
|
|
||||||
#svn export --force https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/jsoncpp/include/json json
|
|
||||||
|
333
lib/jsoncpp/json/json-forwards.h
Normal file
333
lib/jsoncpp/json/json-forwards.h
Normal file
@ -0,0 +1,333 @@
|
|||||||
|
/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).
|
||||||
|
/// It is intended to be used with #include "json/json-forwards.h"
|
||||||
|
/// This header provides forward declaration for all JsonCpp types.
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
// Beginning of content of file: LICENSE
|
||||||
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
The JsonCpp library's source code, including accompanying documentation,
|
||||||
|
tests and demonstration applications, are licensed under the following
|
||||||
|
conditions...
|
||||||
|
|
||||||
|
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
|
||||||
|
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
|
||||||
|
conditions of the MIT License (see below), or 3) under the terms of dual
|
||||||
|
Public Domain/MIT License conditions described here, as they choose.
|
||||||
|
|
||||||
|
The MIT License is about as close to Public Domain as a license can get, and is
|
||||||
|
described in clear, concise terms at:
|
||||||
|
|
||||||
|
http://en.wikipedia.org/wiki/MIT_License
|
||||||
|
|
||||||
|
The full text of the MIT License follows:
|
||||||
|
|
||||||
|
========================================================================
|
||||||
|
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
|
||||||
|
files (the "Software"), to deal in the Software without
|
||||||
|
restriction, including without limitation the rights to use, copy,
|
||||||
|
modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||||
|
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
========================================================================
|
||||||
|
(END LICENSE TEXT)
|
||||||
|
|
||||||
|
The MIT license is compatible with both the GPL and commercial
|
||||||
|
software, affording one all of the rights of Public Domain with the
|
||||||
|
minor nuisance of being required to keep the above copyright notice
|
||||||
|
and license text in the source code. Note also that by accepting the
|
||||||
|
Public Domain "license" you can re-license your copy using whatever
|
||||||
|
license you like.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
// End of content of file: LICENSE
|
||||||
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
|
||||||
|
# define JSON_FORWARD_AMALGATED_H_INCLUDED
|
||||||
|
/// If defined, indicates that the source file is amalgated
|
||||||
|
/// to prevent private header inclusion.
|
||||||
|
#define JSON_IS_AMALGAMATION
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
// Beginning of content of file: include/json/config.h
|
||||||
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
/// If defined, indicates that json may leverage CppTL library
|
||||||
|
//# define JSON_USE_CPPTL 1
|
||||||
|
/// If defined, indicates that cpptl vector based map should be used instead of
|
||||||
|
/// std::map
|
||||||
|
/// as Value container.
|
||||||
|
//# define JSON_USE_CPPTL_SMALLMAP 1
|
||||||
|
|
||||||
|
// If non-zero, the library uses exceptions to report bad input instead of C
|
||||||
|
// assertion macros. The default is to use exceptions.
|
||||||
|
#ifndef JSON_USE_EXCEPTION
|
||||||
|
#define JSON_USE_EXCEPTION 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// If defined, indicates that the source file is amalgated
|
||||||
|
/// to prevent private header inclusion.
|
||||||
|
/// Remarks: it is automatically defined in the generated amalgated header.
|
||||||
|
// #define JSON_IS_AMALGAMATION
|
||||||
|
|
||||||
|
#ifdef JSON_IN_CPPTL
|
||||||
|
#include <cpptl/config.h>
|
||||||
|
#ifndef JSON_USE_CPPTL
|
||||||
|
#define JSON_USE_CPPTL 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JSON_IN_CPPTL
|
||||||
|
#define JSON_API CPPTL_API
|
||||||
|
#elif defined(JSON_DLL_BUILD)
|
||||||
|
#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) || defined(__MINGW32__)
|
||||||
|
#define JSON_API __declspec(dllimport)
|
||||||
|
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||||
|
#endif // if defined(_MSC_VER)
|
||||||
|
#endif // ifdef JSON_IN_CPPTL
|
||||||
|
#if !defined(JSON_API)
|
||||||
|
#define JSON_API
|
||||||
|
#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) // 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 _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
|
||||||
|
|
||||||
|
#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;
|
||||||
|
#if defined(JSON_NO_INT64)
|
||||||
|
typedef int LargestInt;
|
||||||
|
typedef unsigned int LargestUInt;
|
||||||
|
#undef JSON_HAS_INT64
|
||||||
|
#else // if defined(JSON_NO_INT64)
|
||||||
|
// For Microsoft Visual use specific types as long long is not supported
|
||||||
|
#if defined(_MSC_VER) // Microsoft Visual Studio
|
||||||
|
typedef __int64 Int64;
|
||||||
|
typedef unsigned __int64 UInt64;
|
||||||
|
#else // if defined(_MSC_VER) // Other platforms, use long long
|
||||||
|
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
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
// End of content of file: include/json/config.h
|
||||||
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
// Beginning of content of file: include/json/forwards.h
|
||||||
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// 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_FORWARDS_H_INCLUDED
|
||||||
|
#define JSON_FORWARDS_H_INCLUDED
|
||||||
|
|
||||||
|
#if !defined(JSON_IS_AMALGAMATION)
|
||||||
|
#include "config.h"
|
||||||
|
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||||
|
|
||||||
|
namespace Json {
|
||||||
|
|
||||||
|
// writer.h
|
||||||
|
class FastWriter;
|
||||||
|
class StyledWriter;
|
||||||
|
|
||||||
|
// reader.h
|
||||||
|
class Reader;
|
||||||
|
|
||||||
|
// features.h
|
||||||
|
class Features;
|
||||||
|
|
||||||
|
// value.h
|
||||||
|
typedef unsigned int ArrayIndex;
|
||||||
|
class StaticString;
|
||||||
|
class Path;
|
||||||
|
class PathArgument;
|
||||||
|
class Value;
|
||||||
|
class ValueIteratorBase;
|
||||||
|
class ValueIterator;
|
||||||
|
class ValueConstIterator;
|
||||||
|
|
||||||
|
} // namespace Json
|
||||||
|
|
||||||
|
#endif // JSON_FORWARDS_H_INCLUDED
|
||||||
|
|
||||||
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
// End of content of file: include/json/forwards.h
|
||||||
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
|
@ -10,13 +10,13 @@ The JsonCpp library's source code, including accompanying documentation,
|
|||||||
tests and demonstration applications, are licensed under the following
|
tests and demonstration applications, are licensed under the following
|
||||||
conditions...
|
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,
|
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||||
this software is released into the Public Domain.
|
this software is released into the Public Domain.
|
||||||
|
|
||||||
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
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
|
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
|
||||||
released under the terms of the MIT License (see below).
|
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
|
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
|
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||||
@ -31,7 +31,7 @@ described in clear, concise terms at:
|
|||||||
The full text of the MIT License follows:
|
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
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation
|
obtaining a copy of this software and associated documentation
|
||||||
@ -87,10 +87,10 @@ license you like.
|
|||||||
#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.8.0"
|
# define JSONCPP_VERSION_STRING "1.8.3"
|
||||||
# define JSONCPP_VERSION_MAJOR 1
|
# define JSONCPP_VERSION_MAJOR 1
|
||||||
# define JSONCPP_VERSION_MINOR 8
|
# define JSONCPP_VERSION_MINOR 8
|
||||||
# define JSONCPP_VERSION_PATCH 0
|
# define JSONCPP_VERSION_PATCH 3
|
||||||
# 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))
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ license you like.
|
|||||||
// Beginning of content of file: include/json/config.h
|
// Beginning of content of file: include/json/config.h
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2007-2010 Baptiste Lepilleur
|
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@ -238,6 +238,9 @@ license you like.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __clang__
|
#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)
|
#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
|
||||||
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||||
# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
|
||||||
@ -314,7 +317,7 @@ typedef UInt64 LargestUInt;
|
|||||||
// Beginning of content of file: include/json/forwards.h
|
// Beginning of content of file: include/json/forwards.h
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2007-2010 Baptiste Lepilleur
|
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@ -365,7 +368,7 @@ class ValueConstIterator;
|
|||||||
// Beginning of content of file: include/json/features.h
|
// Beginning of content of file: include/json/features.h
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2007-2010 Baptiste Lepilleur
|
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@ -440,7 +443,7 @@ public:
|
|||||||
// Beginning of content of file: include/json/value.h
|
// Beginning of content of file: include/json/value.h
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2007-2010 Baptiste Lepilleur
|
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@ -465,7 +468,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Conditional NORETURN attribute on the throw functions would:
|
//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.
|
// b) possibly improve optimization opportunities.
|
||||||
#if !defined(JSONCPP_NORETURN)
|
#if !defined(JSONCPP_NORETURN)
|
||||||
# if defined(_MSC_VER)
|
# if defined(_MSC_VER)
|
||||||
@ -506,7 +509,7 @@ protected:
|
|||||||
/** Exceptions which the user cannot easily avoid.
|
/** Exceptions which the user cannot easily avoid.
|
||||||
*
|
*
|
||||||
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
|
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
|
||||||
*
|
*
|
||||||
* \remark derived from Json::Exception
|
* \remark derived from Json::Exception
|
||||||
*/
|
*/
|
||||||
class JSON_API RuntimeError : public Exception {
|
class JSON_API RuntimeError : public Exception {
|
||||||
@ -517,7 +520,7 @@ public:
|
|||||||
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
|
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
|
||||||
*
|
*
|
||||||
* These are precondition-violations (user bugs) and internal errors (our bugs).
|
* These are precondition-violations (user bugs) and internal errors (our bugs).
|
||||||
*
|
*
|
||||||
* \remark derived from Json::Exception
|
* \remark derived from Json::Exception
|
||||||
*/
|
*/
|
||||||
class JSON_API LogicError : public Exception {
|
class JSON_API LogicError : public Exception {
|
||||||
@ -675,7 +678,12 @@ private:
|
|||||||
CZString(CZString&& other);
|
CZString(CZString&& other);
|
||||||
#endif
|
#endif
|
||||||
~CZString();
|
~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;
|
||||||
bool operator==(CZString const& other) const;
|
bool operator==(CZString const& other) const;
|
||||||
ArrayIndex index() const;
|
ArrayIndex index() const;
|
||||||
@ -765,11 +773,17 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
/// Deep copy, then swap(other).
|
/// Deep copy, then swap(other).
|
||||||
/// \note Over-write existing comments. To preserve comments, use #swapPayload().
|
/// \note Over-write existing comments. To preserve comments, use #swapPayload().
|
||||||
Value& operator=(Value other);
|
Value& operator=(Value other);
|
||||||
|
|
||||||
/// Swap everything.
|
/// Swap everything.
|
||||||
void swap(Value& other);
|
void swap(Value& other);
|
||||||
/// Swap values but leave comments and source offsets in place.
|
/// Swap values but leave comments and source offsets in place.
|
||||||
void swapPayload(Value& other);
|
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;
|
ValueType type() const;
|
||||||
|
|
||||||
/// Compare payload only, not comments etc.
|
/// Compare payload only, not comments etc.
|
||||||
@ -880,6 +894,10 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
/// Equivalent to jsonvalue[jsonvalue.size()] = value;
|
/// Equivalent to jsonvalue[jsonvalue.size()] = value;
|
||||||
Value& append(const Value& 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.
|
/// 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.
|
/// \note Because of our implementation, keys are limited to 2^30 -1 chars.
|
||||||
/// Exceeding that will cause an exception.
|
/// Exceeding that will cause an exception.
|
||||||
@ -945,10 +963,12 @@ Json::Value obj_value(Json::objectValue); // {}
|
|||||||
/// \pre type() is objectValue or nullValue
|
/// \pre type() is objectValue or nullValue
|
||||||
/// \post type() is unchanged
|
/// \post type() is unchanged
|
||||||
/// \deprecated
|
/// \deprecated
|
||||||
|
JSONCPP_DEPRECATED("")
|
||||||
Value removeMember(const char* key);
|
Value removeMember(const char* key);
|
||||||
/// Same as removeMember(const char*)
|
/// Same as removeMember(const char*)
|
||||||
/// \param key may contain embedded nulls.
|
/// \param key may contain embedded nulls.
|
||||||
/// \deprecated
|
/// \deprecated
|
||||||
|
JSONCPP_DEPRECATED("")
|
||||||
Value removeMember(const JSONCPP_STRING& key);
|
Value removeMember(const JSONCPP_STRING& key);
|
||||||
/// Same as removeMember(const char* begin, const char* end, Value* removed),
|
/// Same as removeMember(const char* begin, const char* end, Value* removed),
|
||||||
/// but 'key' is null-terminated.
|
/// but 'key' is null-terminated.
|
||||||
@ -1324,7 +1344,7 @@ inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
|
|||||||
// Beginning of content of file: include/json/reader.h
|
// Beginning of content of file: include/json/reader.h
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2007-2010 Baptiste Lepilleur
|
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@ -1358,7 +1378,7 @@ namespace Json {
|
|||||||
*
|
*
|
||||||
* \deprecated Use CharReader and CharReaderBuilder.
|
* \deprecated Use CharReader and CharReaderBuilder.
|
||||||
*/
|
*/
|
||||||
class JSON_API Reader {
|
class JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead") JSON_API Reader {
|
||||||
public:
|
public:
|
||||||
typedef char Char;
|
typedef char Char;
|
||||||
typedef const Char* Location;
|
typedef const Char* Location;
|
||||||
@ -1556,6 +1576,9 @@ private:
|
|||||||
void addComment(Location begin, Location end, CommentPlacement placement);
|
void addComment(Location begin, Location end, CommentPlacement placement);
|
||||||
void skipCommentTokens(Token& token);
|
void skipCommentTokens(Token& token);
|
||||||
|
|
||||||
|
static bool containsNewLine(Location begin, Location end);
|
||||||
|
static JSONCPP_STRING normalizeEOL(Location begin, Location end);
|
||||||
|
|
||||||
typedef std::stack<Value*> Nodes;
|
typedef std::stack<Value*> Nodes;
|
||||||
Nodes nodes_;
|
Nodes nodes_;
|
||||||
Errors errors_;
|
Errors errors_;
|
||||||
@ -1746,7 +1769,7 @@ JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
|
|||||||
// Beginning of content of file: include/json/writer.h
|
// Beginning of content of file: include/json/writer.h
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2007-2010 Baptiste Lepilleur
|
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@ -1888,7 +1911,7 @@ public:
|
|||||||
/** \brief Abstract class for writers.
|
/** \brief Abstract class for writers.
|
||||||
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
|
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
|
||||||
*/
|
*/
|
||||||
class JSON_API Writer {
|
class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer {
|
||||||
public:
|
public:
|
||||||
virtual ~Writer();
|
virtual ~Writer();
|
||||||
|
|
||||||
@ -1904,7 +1927,7 @@ public:
|
|||||||
* \sa Reader, Value
|
* \sa Reader, Value
|
||||||
* \deprecated Use StreamWriterBuilder.
|
* \deprecated Use StreamWriterBuilder.
|
||||||
*/
|
*/
|
||||||
class JSON_API FastWriter : public Writer {
|
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter : public Writer {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FastWriter();
|
FastWriter();
|
||||||
@ -1957,7 +1980,7 @@ private:
|
|||||||
* \sa Reader, Value, Value::setComment()
|
* \sa Reader, Value, Value::setComment()
|
||||||
* \deprecated Use StreamWriterBuilder.
|
* \deprecated Use StreamWriterBuilder.
|
||||||
*/
|
*/
|
||||||
class JSON_API StyledWriter : public Writer {
|
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledWriter : public Writer {
|
||||||
public:
|
public:
|
||||||
StyledWriter();
|
StyledWriter();
|
||||||
~StyledWriter() JSONCPP_OVERRIDE {}
|
~StyledWriter() JSONCPP_OVERRIDE {}
|
||||||
@ -2015,12 +2038,14 @@ private:
|
|||||||
* If the Value have comments then they are outputed according to their
|
* If the Value have comments then they are outputed according to their
|
||||||
#CommentPlacement.
|
#CommentPlacement.
|
||||||
*
|
*
|
||||||
* \param indentation Each level will be indented by this amount extra.
|
|
||||||
* \sa Reader, Value, Value::setComment()
|
* \sa Reader, Value, Value::setComment()
|
||||||
* \deprecated Use StreamWriterBuilder.
|
* \deprecated Use StreamWriterBuilder.
|
||||||
*/
|
*/
|
||||||
class JSON_API StyledStreamWriter {
|
class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledStreamWriter {
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* \param indentation Each level will be indented by this amount extra.
|
||||||
|
*/
|
||||||
StyledStreamWriter(JSONCPP_STRING indentation = "\t");
|
StyledStreamWriter(JSONCPP_STRING indentation = "\t");
|
||||||
~StyledStreamWriter() {}
|
~StyledStreamWriter() {}
|
||||||
|
|
||||||
@ -2095,7 +2120,7 @@ JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
|
|||||||
// Beginning of content of file: include/json/assertions.h
|
// Beginning of content of file: include/json/assertions.h
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2007-2010 Baptiste Lepilleur
|
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
|
@ -10,13 +10,13 @@ The JsonCpp library's source code, including accompanying documentation,
|
|||||||
tests and demonstration applications, are licensed under the following
|
tests and demonstration applications, are licensed under the following
|
||||||
conditions...
|
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,
|
jurisdictions which recognize such a disclaimer. In such jurisdictions,
|
||||||
this software is released into the Public Domain.
|
this software is released into the Public Domain.
|
||||||
|
|
||||||
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
|
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
|
2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
|
||||||
released under the terms of the MIT License (see below).
|
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
|
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
|
software may choose to accept it either as 1) Public Domain, 2) under the
|
||||||
@ -31,7 +31,7 @@ described in clear, concise terms at:
|
|||||||
The full text of the MIT License follows:
|
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
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation
|
obtaining a copy of this software and associated documentation
|
||||||
@ -84,7 +84,7 @@ license you like.
|
|||||||
// Beginning of content of file: src/lib_json/json_tool.h
|
// Beginning of content of file: src/lib_json/json_tool.h
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2007-2010 Baptiste Lepilleur
|
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@ -215,7 +215,7 @@ static inline void fixNumericLocaleInput(char* begin, char* end) {
|
|||||||
// Beginning of content of file: src/lib_json/json_reader.cpp
|
// Beginning of content of file: src/lib_json/json_reader.cpp
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2007-2011 Baptiste Lepilleur
|
// Copyright 2007-2011 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Copyright (C) 2016 InfoTeCS JSC. All rights reserved.
|
// Copyright (C) 2016 InfoTeCS JSC. All rights reserved.
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
@ -298,7 +298,7 @@ Features Features::strictMode() {
|
|||||||
// Implementation of class Reader
|
// Implementation of class Reader
|
||||||
// ////////////////////////////////
|
// ////////////////////////////////
|
||||||
|
|
||||||
static bool containsNewLine(Reader::Location begin, Reader::Location end) {
|
bool Reader::containsNewLine(Reader::Location begin, Reader::Location end) {
|
||||||
for (; begin < end; ++begin)
|
for (; begin < end; ++begin)
|
||||||
if (*begin == '\n' || *begin == '\r')
|
if (*begin == '\n' || *begin == '\r')
|
||||||
return true;
|
return true;
|
||||||
@ -320,8 +320,7 @@ Reader::Reader(const Features& features)
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
Reader::parse(const std::string& document, Value& root, bool collectComments) {
|
Reader::parse(const std::string& document, Value& root, bool collectComments) {
|
||||||
JSONCPP_STRING documentCopy(document.data(), document.data() + document.capacity());
|
document_.assign(document.begin(), document.end());
|
||||||
std::swap(documentCopy, document_);
|
|
||||||
const char* begin = document_.c_str();
|
const char* begin = document_.c_str();
|
||||||
const char* end = begin + document_.length();
|
const char* end = begin + document_.length();
|
||||||
return parse(begin, end, root, collectComments);
|
return parse(begin, end, root, collectComments);
|
||||||
@ -354,7 +353,7 @@ bool Reader::parse(const char* beginDoc,
|
|||||||
current_ = begin_;
|
current_ = begin_;
|
||||||
lastValueEnd_ = 0;
|
lastValueEnd_ = 0;
|
||||||
lastValue_ = 0;
|
lastValue_ = 0;
|
||||||
commentsBefore_ = "";
|
commentsBefore_.clear();
|
||||||
errors_.clear();
|
errors_.clear();
|
||||||
while (!nodes_.empty())
|
while (!nodes_.empty())
|
||||||
nodes_.pop();
|
nodes_.pop();
|
||||||
@ -393,7 +392,7 @@ bool Reader::readValue() {
|
|||||||
|
|
||||||
if (collectComments_ && !commentsBefore_.empty()) {
|
if (collectComments_ && !commentsBefore_.empty()) {
|
||||||
currentValue().setComment(commentsBefore_, commentBefore);
|
currentValue().setComment(commentsBefore_, commentBefore);
|
||||||
commentsBefore_ = "";
|
commentsBefore_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (token.type_) {
|
switch (token.type_) {
|
||||||
@ -587,7 +586,7 @@ bool Reader::readComment() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSONCPP_STRING normalizeEOL(Reader::Location begin, Reader::Location end) {
|
JSONCPP_STRING Reader::normalizeEOL(Reader::Location begin, Reader::Location end) {
|
||||||
JSONCPP_STRING normalized;
|
JSONCPP_STRING normalized;
|
||||||
normalized.reserve(static_cast<size_t>(end - begin));
|
normalized.reserve(static_cast<size_t>(end - begin));
|
||||||
Reader::Location current = begin;
|
Reader::Location current = begin;
|
||||||
@ -691,7 +690,7 @@ bool Reader::readObject(Token& tokenStart) {
|
|||||||
break;
|
break;
|
||||||
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
|
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
|
||||||
return true;
|
return true;
|
||||||
name = "";
|
name.clear();
|
||||||
if (tokenName.type_ == tokenString) {
|
if (tokenName.type_ == tokenString) {
|
||||||
if (!decodeString(tokenName, name))
|
if (!decodeString(tokenName, name))
|
||||||
return recoverFromError(tokenObjectEnd);
|
return recoverFromError(tokenObjectEnd);
|
||||||
@ -1236,6 +1235,9 @@ private:
|
|||||||
void addComment(Location begin, Location end, CommentPlacement placement);
|
void addComment(Location begin, Location end, CommentPlacement placement);
|
||||||
void skipCommentTokens(Token& token);
|
void skipCommentTokens(Token& token);
|
||||||
|
|
||||||
|
static JSONCPP_STRING normalizeEOL(Location begin, Location end);
|
||||||
|
static bool containsNewLine(Location begin, Location end);
|
||||||
|
|
||||||
typedef std::stack<Value*> Nodes;
|
typedef std::stack<Value*> Nodes;
|
||||||
Nodes nodes_;
|
Nodes nodes_;
|
||||||
Errors errors_;
|
Errors errors_;
|
||||||
@ -1253,6 +1255,13 @@ private:
|
|||||||
|
|
||||||
// complete copy of Read impl, for OurReader
|
// complete copy of Read impl, for OurReader
|
||||||
|
|
||||||
|
bool OurReader::containsNewLine(OurReader::Location begin, OurReader::Location end) {
|
||||||
|
for (; begin < end; ++begin)
|
||||||
|
if (*begin == '\n' || *begin == '\r')
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
OurReader::OurReader(OurFeatures const& features)
|
OurReader::OurReader(OurFeatures const& features)
|
||||||
: errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
|
: errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
|
||||||
lastValue_(), commentsBefore_(),
|
lastValue_(), commentsBefore_(),
|
||||||
@ -1273,7 +1282,7 @@ bool OurReader::parse(const char* beginDoc,
|
|||||||
current_ = begin_;
|
current_ = begin_;
|
||||||
lastValueEnd_ = 0;
|
lastValueEnd_ = 0;
|
||||||
lastValue_ = 0;
|
lastValue_ = 0;
|
||||||
commentsBefore_ = "";
|
commentsBefore_.clear();
|
||||||
errors_.clear();
|
errors_.clear();
|
||||||
while (!nodes_.empty())
|
while (!nodes_.empty())
|
||||||
nodes_.pop();
|
nodes_.pop();
|
||||||
@ -1315,7 +1324,7 @@ bool OurReader::readValue() {
|
|||||||
|
|
||||||
if (collectComments_ && !commentsBefore_.empty()) {
|
if (collectComments_ && !commentsBefore_.empty()) {
|
||||||
currentValue().setComment(commentsBefore_, commentBefore);
|
currentValue().setComment(commentsBefore_, commentBefore);
|
||||||
commentsBefore_ = "";
|
commentsBefore_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (token.type_) {
|
switch (token.type_) {
|
||||||
@ -1562,6 +1571,25 @@ bool OurReader::readComment() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSONCPP_STRING OurReader::normalizeEOL(OurReader::Location begin, OurReader::Location end) {
|
||||||
|
JSONCPP_STRING normalized;
|
||||||
|
normalized.reserve(static_cast<size_t>(end - begin));
|
||||||
|
OurReader::Location current = begin;
|
||||||
|
while (current != end) {
|
||||||
|
char c = *current++;
|
||||||
|
if (c == '\r') {
|
||||||
|
if (current != end && *current == '\n')
|
||||||
|
// convert dos EOL
|
||||||
|
++current;
|
||||||
|
// convert Mac EOL
|
||||||
|
normalized += '\n';
|
||||||
|
} else {
|
||||||
|
normalized += c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return normalized;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OurReader::addComment(Location begin, Location end, CommentPlacement placement) {
|
OurReader::addComment(Location begin, Location end, CommentPlacement placement) {
|
||||||
assert(collectComments_);
|
assert(collectComments_);
|
||||||
@ -1664,7 +1692,7 @@ bool OurReader::readObject(Token& tokenStart) {
|
|||||||
break;
|
break;
|
||||||
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
|
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
|
||||||
return true;
|
return true;
|
||||||
name = "";
|
name.clear();
|
||||||
if (tokenName.type_ == tokenString) {
|
if (tokenName.type_ == tokenString) {
|
||||||
if (!decodeString(tokenName, name))
|
if (!decodeString(tokenName, name))
|
||||||
return recoverFromError(tokenObjectEnd);
|
return recoverFromError(tokenObjectEnd);
|
||||||
@ -2265,7 +2293,7 @@ JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM& sin, Value& root) {
|
|||||||
// Beginning of content of file: src/lib_json/json_valueiterator.inl
|
// Beginning of content of file: src/lib_json/json_valueiterator.inl
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2007-2010 Baptiste Lepilleur
|
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@ -2446,7 +2474,7 @@ ValueIterator& ValueIterator::operator=(const SelfType& other) {
|
|||||||
// Beginning of content of file: src/lib_json/json_value.cpp
|
// Beginning of content of file: src/lib_json/json_value.cpp
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2011 Baptiste Lepilleur
|
// Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@ -2740,18 +2768,28 @@ void Value::CZString::swap(CZString& other) {
|
|||||||
std::swap(index_, other.index_);
|
std::swap(index_, other.index_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::CZString& Value::CZString::operator=(CZString other) {
|
Value::CZString& Value::CZString::operator=(const CZString& other) {
|
||||||
swap(other);
|
cstr_ = other.cstr_;
|
||||||
|
index_ = other.index_;
|
||||||
return *this;
|
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 {
|
bool Value::CZString::operator<(const CZString& other) const {
|
||||||
if (!cstr_) return index_ < other.index_;
|
if (!cstr_) return index_ < other.index_;
|
||||||
//return strcmp(cstr_, other.cstr_) < 0;
|
//return strcmp(cstr_, other.cstr_) < 0;
|
||||||
// Assume both are strings.
|
// Assume both are strings.
|
||||||
unsigned this_len = this->storage_.length_;
|
unsigned this_len = this->storage_.length_;
|
||||||
unsigned other_len = other.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_);
|
JSON_ASSERT(this->cstr_ && other.cstr_);
|
||||||
int comp = memcmp(this->cstr_, other.cstr_, min_len);
|
int comp = memcmp(this->cstr_, other.cstr_, min_len);
|
||||||
if (comp < 0) return true;
|
if (comp < 0) return true;
|
||||||
@ -2846,6 +2884,7 @@ Value::Value(double value) {
|
|||||||
|
|
||||||
Value::Value(const char* value) {
|
Value::Value(const char* value) {
|
||||||
initBasic(stringValue, true);
|
initBasic(stringValue, true);
|
||||||
|
JSON_ASSERT_MESSAGE(value != NULL, "Null Value Passed to Value Constructor");
|
||||||
value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));
|
value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2970,6 +3009,12 @@ void Value::swapPayload(Value& other) {
|
|||||||
other.allocated_ = temp2 & 0x1;
|
other.allocated_ = temp2 & 0x1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Value::copyPayload(const Value& other) {
|
||||||
|
type_ = other.type_;
|
||||||
|
value_ = other.value_;
|
||||||
|
allocated_ = other.allocated_;
|
||||||
|
}
|
||||||
|
|
||||||
void Value::swap(Value& other) {
|
void Value::swap(Value& other) {
|
||||||
swapPayload(other);
|
swapPayload(other);
|
||||||
std::swap(comments_, other.comments_);
|
std::swap(comments_, other.comments_);
|
||||||
@ -2977,6 +3022,13 @@ void Value::swap(Value& other) {
|
|||||||
std::swap(limit_, other.limit_);
|
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_; }
|
ValueType Value::type() const { return type_; }
|
||||||
|
|
||||||
int Value::compare(const Value& other) const {
|
int Value::compare(const Value& other) const {
|
||||||
@ -3014,7 +3066,7 @@ bool Value::operator<(const Value& other) const {
|
|||||||
char const* other_str;
|
char const* other_str;
|
||||||
decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
|
decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
|
||||||
decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_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);
|
JSON_ASSERT(this_str && other_str);
|
||||||
int comp = memcmp(this_str, other_str, min_len);
|
int comp = memcmp(this_str, other_str, min_len);
|
||||||
if (comp < 0) return true;
|
if (comp < 0) return true;
|
||||||
@ -3327,7 +3379,7 @@ bool Value::isConvertibleTo(ValueType other) const {
|
|||||||
case nullValue:
|
case nullValue:
|
||||||
return (isNumeric() && asDouble() == 0.0) ||
|
return (isNumeric() && asDouble() == 0.0) ||
|
||||||
(type_ == booleanValue && value_.bool_ == false) ||
|
(type_ == booleanValue && value_.bool_ == false) ||
|
||||||
(type_ == stringValue && asString() == "") ||
|
(type_ == stringValue && asString().empty()) ||
|
||||||
(type_ == arrayValue && value_.map_->size() == 0) ||
|
(type_ == arrayValue && value_.map_->size() == 0) ||
|
||||||
(type_ == objectValue && value_.map_->size() == 0) ||
|
(type_ == objectValue && value_.map_->size() == 0) ||
|
||||||
type_ == nullValue;
|
type_ == nullValue;
|
||||||
@ -3571,6 +3623,10 @@ Value const& Value::operator[](CppTL::ConstString const& key) const
|
|||||||
|
|
||||||
Value& Value::append(const Value& value) { return (*this)[size()] = value; }
|
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 Value::get(char const* key, char const* cend, Value const& defaultValue) const
|
||||||
{
|
{
|
||||||
Value const* found = find(key, cend);
|
Value const* found = find(key, cend);
|
||||||
@ -3807,11 +3863,23 @@ bool Value::isUInt64() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Value::isIntegral() const {
|
bool Value::isIntegral() const {
|
||||||
|
switch (type_) {
|
||||||
|
case intValue:
|
||||||
|
case uintValue:
|
||||||
|
return true;
|
||||||
|
case realValue:
|
||||||
#if defined(JSON_HAS_INT64)
|
#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
|
#else
|
||||||
return isInt() || isUInt();
|
return value_.real_ >= minInt && value_.real_ <= maxUInt && IsIntegral(value_.real_);
|
||||||
#endif
|
#endif // JSON_HAS_INT64
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Value::isDouble() const { return type_ == intValue || type_ == uintValue || type_ == realValue; }
|
bool Value::isDouble() const { return type_ == intValue || type_ == uintValue || type_ == realValue; }
|
||||||
@ -3861,8 +3929,13 @@ ptrdiff_t Value::getOffsetStart() const { return start_; }
|
|||||||
ptrdiff_t Value::getOffsetLimit() const { return limit_; }
|
ptrdiff_t Value::getOffsetLimit() const { return limit_; }
|
||||||
|
|
||||||
JSONCPP_STRING Value::toStyledString() const {
|
JSONCPP_STRING Value::toStyledString() const {
|
||||||
StyledWriter writer;
|
StreamWriterBuilder builder;
|
||||||
return writer.write(*this);
|
|
||||||
|
JSONCPP_STRING out = this->hasComment(commentBefore) ? "\n" : "";
|
||||||
|
out += Json::writeString(builder, *this);
|
||||||
|
out += "\n";
|
||||||
|
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::const_iterator Value::begin() const {
|
Value::const_iterator Value::begin() const {
|
||||||
@ -3941,6 +4014,7 @@ Path::Path(const JSONCPP_STRING& path,
|
|||||||
const PathArgument& a4,
|
const PathArgument& a4,
|
||||||
const PathArgument& a5) {
|
const PathArgument& a5) {
|
||||||
InArgs in;
|
InArgs in;
|
||||||
|
in.reserve(5);
|
||||||
in.push_back(&a1);
|
in.push_back(&a1);
|
||||||
in.push_back(&a2);
|
in.push_back(&a2);
|
||||||
in.push_back(&a3);
|
in.push_back(&a3);
|
||||||
@ -4076,7 +4150,7 @@ Value& Path::make(Value& root) const {
|
|||||||
// Beginning of content of file: src/lib_json/json_writer.cpp
|
// Beginning of content of file: src/lib_json/json_writer.cpp
|
||||||
// //////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Copyright 2011 Baptiste Lepilleur
|
// Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors
|
||||||
// Distributed under MIT license, or public domain if desired and
|
// Distributed under MIT license, or public domain if desired and
|
||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
@ -4220,17 +4294,18 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p
|
|||||||
char buffer[36];
|
char buffer[36];
|
||||||
int len = -1;
|
int len = -1;
|
||||||
|
|
||||||
char formatString[6];
|
char formatString[15];
|
||||||
sprintf(formatString, "%%.%dg", precision);
|
snprintf(formatString, sizeof(formatString), "%%.%dg", precision);
|
||||||
|
|
||||||
// Print into the buffer. We need not request the alternative representation
|
// Print into the buffer. We need not request the alternative representation
|
||||||
// that always has a decimal point because JSON doesn't distingish the
|
// that always has a decimal point because JSON doesn't distingish the
|
||||||
// concepts of reals and integers.
|
// concepts of reals and integers.
|
||||||
if (isfinite(value)) {
|
if (isfinite(value)) {
|
||||||
len = snprintf(buffer, sizeof(buffer), formatString, 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
|
// try to ensure we preserve the fact that this was given to us as a double on input
|
||||||
if (!strstr(buffer, ".") && !strstr(buffer, "e")) {
|
if (!strchr(buffer, '.') && !strchr(buffer, 'e')) {
|
||||||
strcat(buffer, ".0");
|
strcat(buffer, ".0");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4243,10 +4318,8 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p
|
|||||||
} else {
|
} else {
|
||||||
len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "Infinity" : "1e+9999");
|
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);
|
assert(len >= 0);
|
||||||
fixNumericLocale(buffer, buffer + len);
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4413,7 +4486,7 @@ void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
|
|||||||
void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
|
void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
|
||||||
|
|
||||||
JSONCPP_STRING FastWriter::write(const Value& root) {
|
JSONCPP_STRING FastWriter::write(const Value& root) {
|
||||||
document_ = "";
|
document_.clear();
|
||||||
writeValue(root);
|
writeValue(root);
|
||||||
if (!omitEndingLineFeed_)
|
if (!omitEndingLineFeed_)
|
||||||
document_ += "\n";
|
document_ += "\n";
|
||||||
@ -4481,9 +4554,9 @@ StyledWriter::StyledWriter()
|
|||||||
: rightMargin_(74), indentSize_(3), addChildValues_() {}
|
: rightMargin_(74), indentSize_(3), addChildValues_() {}
|
||||||
|
|
||||||
JSONCPP_STRING StyledWriter::write(const Value& root) {
|
JSONCPP_STRING StyledWriter::write(const Value& root) {
|
||||||
document_ = "";
|
document_.clear();
|
||||||
addChildValues_ = false;
|
addChildValues_ = false;
|
||||||
indentString_ = "";
|
indentString_.clear();
|
||||||
writeCommentBeforeValue(root);
|
writeCommentBeforeValue(root);
|
||||||
writeValue(root);
|
writeValue(root);
|
||||||
writeCommentAfterValueOnSameLine(root);
|
writeCommentAfterValueOnSameLine(root);
|
||||||
@ -4661,7 +4734,7 @@ void StyledWriter::writeCommentBeforeValue(const Value& root) {
|
|||||||
while (iter != comment.end()) {
|
while (iter != comment.end()) {
|
||||||
document_ += *iter;
|
document_ += *iter;
|
||||||
if (*iter == '\n' &&
|
if (*iter == '\n' &&
|
||||||
(iter != comment.end() && *(iter + 1) == '/'))
|
((iter+1) != comment.end() && *(iter + 1) == '/'))
|
||||||
writeIndent();
|
writeIndent();
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
@ -4697,7 +4770,7 @@ StyledStreamWriter::StyledStreamWriter(JSONCPP_STRING indentation)
|
|||||||
void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
|
void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
|
||||||
document_ = &out;
|
document_ = &out;
|
||||||
addChildValues_ = false;
|
addChildValues_ = false;
|
||||||
indentString_ = "";
|
indentString_.clear();
|
||||||
indented_ = true;
|
indented_ = true;
|
||||||
writeCommentBeforeValue(root);
|
writeCommentBeforeValue(root);
|
||||||
if (!indented_) writeIndent();
|
if (!indented_) writeIndent();
|
||||||
@ -4877,7 +4950,7 @@ void StyledStreamWriter::writeCommentBeforeValue(const Value& root) {
|
|||||||
while (iter != comment.end()) {
|
while (iter != comment.end()) {
|
||||||
*document_ << *iter;
|
*document_ << *iter;
|
||||||
if (*iter == '\n' &&
|
if (*iter == '\n' &&
|
||||||
(iter != comment.end() && *(iter + 1) == '/'))
|
((iter+1) != comment.end() && *(iter + 1) == '/'))
|
||||||
// writeIndent(); // would include newline
|
// writeIndent(); // would include newline
|
||||||
*document_ << indentString_;
|
*document_ << indentString_;
|
||||||
++iter;
|
++iter;
|
||||||
@ -4979,7 +5052,7 @@ int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout)
|
|||||||
sout_ = sout;
|
sout_ = sout;
|
||||||
addChildValues_ = false;
|
addChildValues_ = false;
|
||||||
indented_ = true;
|
indented_ = true;
|
||||||
indentString_ = "";
|
indentString_.clear();
|
||||||
writeCommentBeforeValue(root);
|
writeCommentBeforeValue(root);
|
||||||
if (!indented_) writeIndent();
|
if (!indented_) writeIndent();
|
||||||
indented_ = true;
|
indented_ = true;
|
||||||
@ -5165,7 +5238,7 @@ void BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root) {
|
|||||||
while (iter != comment.end()) {
|
while (iter != comment.end()) {
|
||||||
*sout_ << *iter;
|
*sout_ << *iter;
|
||||||
if (*iter == '\n' &&
|
if (*iter == '\n' &&
|
||||||
(iter != comment.end() && *(iter + 1) == '/'))
|
((iter+1) != comment.end() && *(iter + 1) == '/'))
|
||||||
// writeIndent(); // would write extra newline
|
// writeIndent(); // would write extra newline
|
||||||
*sout_ << indentString_;
|
*sout_ << indentString_;
|
||||||
++iter;
|
++iter;
|
||||||
@ -5233,10 +5306,10 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const
|
|||||||
}
|
}
|
||||||
JSONCPP_STRING nullSymbol = "null";
|
JSONCPP_STRING nullSymbol = "null";
|
||||||
if (dnp) {
|
if (dnp) {
|
||||||
nullSymbol = "";
|
nullSymbol.clear();
|
||||||
}
|
}
|
||||||
if (pre > 17) pre = 17;
|
if (pre > 17) pre = 17;
|
||||||
JSONCPP_STRING endingLineFeedSymbol = "";
|
JSONCPP_STRING endingLineFeedSymbol;
|
||||||
return new BuiltStyledStreamWriter(
|
return new BuiltStyledStreamWriter(
|
||||||
indentation, cs,
|
indentation, cs,
|
||||||
colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);
|
colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);
|
||||||
|
@ -46,12 +46,15 @@ Json::Value fetchJsonValue(const std::string &url,
|
|||||||
return Json::Value();
|
return Json::Value();
|
||||||
}
|
}
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
Json::Reader reader;
|
|
||||||
std::istringstream stream(fetch_result.data);
|
std::istringstream stream(fetch_result.data);
|
||||||
|
|
||||||
if (!reader.parse(stream, root)) {
|
Json::CharReaderBuilder builder;
|
||||||
|
builder.settings_["collectComments"] = false;
|
||||||
|
std::string errs;
|
||||||
|
|
||||||
|
if (!Json::parseFromStream(builder, stream, &root, &errs)) {
|
||||||
errorstream << "URL: " << url << std::endl;
|
errorstream << "URL: " << url << std::endl;
|
||||||
errorstream << "Failed to parse json data " << reader.getFormattedErrorMessages();
|
errorstream << "Failed to parse json data " << errs << std::endl;
|
||||||
if (fetch_result.data.size() > 100) {
|
if (fetch_result.data.size() > 100) {
|
||||||
errorstream << "Data (" << fetch_result.data.size()
|
errorstream << "Data (" << fetch_result.data.size()
|
||||||
<< " bytes) printed to warningstream." << std::endl;
|
<< " bytes) printed to warningstream." << std::endl;
|
||||||
@ -64,3 +67,13 @@ Json::Value fetchJsonValue(const std::string &url,
|
|||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string fastWriteJson(const Json::Value &value)
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
Json::StreamWriterBuilder builder;
|
||||||
|
builder["indentation"] = "";
|
||||||
|
std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
|
||||||
|
writer->write(value, &oss);
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
@ -23,3 +23,5 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
Json::Value fetchJsonValue(const std::string &url,
|
Json::Value fetchJsonValue(const std::string &url,
|
||||||
std::vector<std::string> *extra_headers);
|
std::vector<std::string> *extra_headers);
|
||||||
|
|
||||||
|
std::string fastWriteJson(const Json::Value &value);
|
||||||
|
12
src/mods.cpp
12
src/mods.cpp
@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "subgame.h"
|
#include "subgame.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
|
#include "convert_json.h"
|
||||||
|
|
||||||
static bool parseDependsLine(std::istream &is,
|
static bool parseDependsLine(std::istream &is,
|
||||||
std::string &dep, std::set<char> &symbols)
|
std::string &dep, std::set<char> &symbols)
|
||||||
@ -374,7 +375,7 @@ bool ModMetadata::save(const std::string &root_path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool w_ok = fs::safeWriteToFile(root_path + DIR_DELIM + m_mod_name,
|
bool w_ok = fs::safeWriteToFile(root_path + DIR_DELIM + m_mod_name,
|
||||||
Json::FastWriter().write(json));
|
fastWriteJson(json));
|
||||||
|
|
||||||
if (w_ok) {
|
if (w_ok) {
|
||||||
m_modified = false;
|
m_modified = false;
|
||||||
@ -393,11 +394,14 @@ bool ModMetadata::load(const std::string &root_path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Reader reader;
|
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
if (!reader.parse(is, root)) {
|
Json::CharReaderBuilder builder;
|
||||||
|
builder.settings_["collectComments"] = false;
|
||||||
|
std::string errs;
|
||||||
|
|
||||||
|
if (!Json::parseFromStream(builder, is, &root, &errs)) {
|
||||||
errorstream << "ModMetadata[" << m_mod_name << "]: failed read data "
|
errorstream << "ModMetadata[" << m_mod_name << "]: failed read data "
|
||||||
"(Json decoding failure)." << std::endl;
|
"(Json decoding failure). Message: " << errs << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "porting.h" // strlcpy
|
#include "porting.h" // strlcpy
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "convert_json.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
RemotePlayer
|
RemotePlayer
|
||||||
@ -76,8 +77,8 @@ void RemotePlayer::serializeExtraAttributes(std::string &output)
|
|||||||
json_root[attr.first] = attr.second;
|
json_root[attr.first] = attr.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::FastWriter writer;
|
output = fastWriteJson(json_root);
|
||||||
output = writer.write(json_root);
|
|
||||||
m_sao->setExtendedAttributeModified(false);
|
m_sao->setExtendedAttributeModified(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,9 +121,13 @@ void RemotePlayer::deSerialize(std::istream &is, const std::string &playername,
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const std::string &extended_attributes = args.get("extended_attributes");
|
const std::string &extended_attributes = args.get("extended_attributes");
|
||||||
Json::Reader reader;
|
std::istringstream iss(extended_attributes);
|
||||||
|
Json::CharReaderBuilder builder;
|
||||||
|
builder.settings_["collectComments"] = false;
|
||||||
|
std::string errs;
|
||||||
|
|
||||||
Json::Value attr_root;
|
Json::Value attr_root;
|
||||||
reader.parse(extended_attributes, attr_root);
|
Json::parseFromStream(builder, iss, &attr_root, &errs);
|
||||||
|
|
||||||
const Json::Value::Members attr_list = attr_root.getMemberNames();
|
const Json::Value::Members attr_list = attr_root.getMemberNames();
|
||||||
for (const auto &it : attr_list) {
|
for (const auto &it : attr_list) {
|
||||||
|
@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
#include "cpp_api/s_security.h"
|
#include "cpp_api/s_security.h"
|
||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
|
#include "convert_json.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "tool.h"
|
#include "tool.h"
|
||||||
@ -95,12 +96,14 @@ int ModApiUtil::l_parse_json(lua_State *L)
|
|||||||
Json::Value root;
|
Json::Value root;
|
||||||
|
|
||||||
{
|
{
|
||||||
Json::Reader reader;
|
|
||||||
std::istringstream stream(jsonstr);
|
std::istringstream stream(jsonstr);
|
||||||
|
|
||||||
if (!reader.parse(stream, root)) {
|
Json::CharReaderBuilder builder;
|
||||||
errorstream << "Failed to parse json data "
|
builder.settings_["collectComments"] = false;
|
||||||
<< reader.getFormattedErrorMessages();
|
std::string errs;
|
||||||
|
|
||||||
|
if (!Json::parseFromStream(builder, stream, &root, &errs)) {
|
||||||
|
errorstream << "Failed to parse json data " << errs << std::endl;
|
||||||
size_t jlen = strlen(jsonstr);
|
size_t jlen = strlen(jsonstr);
|
||||||
if (jlen > 100) {
|
if (jlen > 100) {
|
||||||
errorstream << "Data (" << jlen
|
errorstream << "Data (" << jlen
|
||||||
@ -145,11 +148,9 @@ int ModApiUtil::l_write_json(lua_State *L)
|
|||||||
|
|
||||||
std::string out;
|
std::string out;
|
||||||
if (styled) {
|
if (styled) {
|
||||||
Json::StyledWriter writer;
|
out = root.toStyledString();
|
||||||
out = writer.write(root);
|
|
||||||
} else {
|
} else {
|
||||||
Json::FastWriter writer;
|
out = fastWriteJson(root);
|
||||||
out = writer.write(root);
|
|
||||||
}
|
}
|
||||||
lua_pushlstring(L, out.c_str(), out.size());
|
lua_pushlstring(L, out.c_str(), out.size());
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -185,8 +185,8 @@ const std::string serializeJson(const std::vector<ServerListSpec> &serverlist)
|
|||||||
list.append(it);
|
list.append(it);
|
||||||
}
|
}
|
||||||
root["list"] = list;
|
root["list"] = list;
|
||||||
Json::FastWriter writer;
|
|
||||||
return writer.write(root);
|
return fastWriteJson(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -249,10 +249,9 @@ void sendAnnounce(AnnounceAction action,
|
|||||||
server["lag"] = lag;
|
server["lag"] = lag;
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::FastWriter writer;
|
|
||||||
HTTPFetchRequest fetch_request;
|
HTTPFetchRequest fetch_request;
|
||||||
fetch_request.url = g_settings->get("serverlist_url") + std::string("/announce");
|
fetch_request.url = g_settings->get("serverlist_url") + std::string("/announce");
|
||||||
fetch_request.post_fields["json"] = writer.write(server);
|
fetch_request.post_fields["json"] = fastWriteJson(server);
|
||||||
fetch_request.multipart = true;
|
fetch_request.multipart = true;
|
||||||
httpfetch_async(fetch_request);
|
httpfetch_async(fetch_request);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user