#if !defined(JSON_IS_AMALGAMATION)
#include <json/assertions.h>
#include <json/value.h>
#include <json/writer.h>
#endif
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <cstring>
#include <iostream>
#include <sstream>
#include <utility>
#if defined(_MSC_VER) && _MSC_VER < 1900
#include <stdarg.h>
static int msvc_pre1900_c99_vsnprintf(char* outBuf, size_t size,
const char* format, va_list ap) {
int count = -1;
if (size != 0)
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
if (count == -1)
count = _vscprintf(format, ap);
return count;
}
int JSON_API msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
const char* format, ...) {
va_list ap;
va_start(ap, format);
const int count = msvc_pre1900_c99_vsnprintf(outBuf, size, format, ap);
va_end(ap);
return count;
}
#endif
#if defined(_MSC_VER)
#pragma warning(disable : 4702)
#endif
#define JSON_ASSERT_UNREACHABLE …
namespace Json {
template <typename T>
static std::unique_ptr<T> cloneUnique(const std::unique_ptr<T>& p) { … }
#if defined(__ARMEL__)
#define ALIGNAS …
#else
#define ALIGNAS(byte_alignment) …
#endif
Value const& Value::nullSingleton() { … }
#if JSON_USE_NULLREF
Value const& Value::null = …;
Value const& Value::nullRef = …;
#endif
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
template <typename T, typename U>
static inline bool InRange(double d, T min, U max) {
return d >= static_cast<double>(min) && d <= static_cast<double>(max);
}
#else
static inline double integerToDouble(Json::UInt64 value) { … }
template <typename T> static inline double integerToDouble(T value) { … }
template <typename T, typename U>
static inline bool InRange(double d, T min, U max) { … }
#endif
static inline char* duplicateStringValue(const char* value, size_t length) { … }
static inline char* duplicateAndPrefixStringValue(const char* value,
unsigned int length) { … }
inline static void decodePrefixedString(bool isPrefixed, char const* prefixed,
unsigned* length, char const** value) { … }
#if JSONCPP_USING_SECURE_MEMORY
static inline void releasePrefixedStringValue(char* value) {
unsigned length = 0;
char const* valueDecoded;
decodePrefixedString(true, value, &length, &valueDecoded);
size_t const size = sizeof(unsigned) + length + 1U;
memset(value, 0, size);
free(value);
}
static inline void releaseStringValue(char* value, unsigned length) {
size_t size = (length == 0) ? strlen(value) : length;
memset(value, 0, size);
free(value);
}
#else
static inline void releasePrefixedStringValue(char* value) { … }
static inline void releaseStringValue(char* value, unsigned) { … }
#endif
}
#if !defined(JSON_IS_AMALGAMATION)
#include "json_valueiterator.inl"
#endif
namespace Json {
#if JSON_USE_EXCEPTION
Exception::Exception(String msg) : msg_(std::move(msg)) {}
Exception::~Exception() noexcept = default;
char const* Exception::what() const noexcept { return msg_.c_str(); }
RuntimeError::RuntimeError(String const& msg) : Exception(msg) {}
LogicError::LogicError(String const& msg) : Exception(msg) {}
JSONCPP_NORETURN void throwRuntimeError(String const& msg) {
throw RuntimeError(msg);
}
JSONCPP_NORETURN void throwLogicError(String const& msg) {
throw LogicError(msg);
}
#else
JSONCPP_NORETURN void throwRuntimeError(String const& msg) { … }
JSONCPP_NORETURN void throwLogicError(String const& msg) { … }
#endif
Value::CZString::CZString(ArrayIndex index) : … { … }
Value::CZString::CZString(char const* str, unsigned length,
DuplicationPolicy allocate)
: … { … }
Value::CZString::CZString(const CZString& other) { … }
Value::CZString::CZString(CZString&& other) noexcept
: … { … }
Value::CZString::~CZString() { … }
void Value::CZString::swap(CZString& other) { … }
Value::CZString& Value::CZString::operator=(const CZString& other) { … }
Value::CZString& Value::CZString::operator=(CZString&& other) noexcept { … }
bool Value::CZString::operator<(const CZString& other) const { … }
bool Value::CZString::operator==(const CZString& other) const { … }
ArrayIndex Value::CZString::index() const { … }
const char* Value::CZString::data() const { … }
unsigned Value::CZString::length() const { … }
bool Value::CZString::isStaticString() const { … }
Value::Value(ValueType type) { … }
Value::Value(Int value) { … }
Value::Value(UInt value) { … }
#if defined(JSON_HAS_INT64)
Value::Value(Int64 value) { … }
Value::Value(UInt64 value) { … }
#endif
Value::Value(double value) { … }
Value::Value(const char* value) { … }
Value::Value(const char* begin, const char* end) { … }
Value::Value(const String& value) { … }
Value::Value(const StaticString& value) { … }
Value::Value(bool value) { … }
Value::Value(const Value& other) { … }
Value::Value(Value&& other) noexcept { … }
Value::~Value() { … }
Value& Value::operator=(const Value& other) { … }
Value& Value::operator=(Value&& other) noexcept { … }
void Value::swapPayload(Value& other) { … }
void Value::copyPayload(const Value& other) { … }
void Value::swap(Value& other) { … }
void Value::copy(const Value& other) { … }
ValueType Value::type() const { … }
int Value::compare(const Value& other) const { … }
bool Value::operator<(const Value& other) const { … }
bool Value::operator<=(const Value& other) const { … }
bool Value::operator>=(const Value& other) const { … }
bool Value::operator>(const Value& other) const { … }
bool Value::operator==(const Value& other) const { … }
bool Value::operator!=(const Value& other) const { … }
const char* Value::asCString() const { … }
#if JSONCPP_USING_SECURE_MEMORY
unsigned Value::getCStringLength() const {
JSON_ASSERT_MESSAGE(type() == stringValue,
"in Json::Value::asCString(): requires stringValue");
if (value_.string_ == 0)
return 0;
unsigned this_len;
char const* this_str;
decodePrefixedString(this->isAllocated(), this->value_.string_, &this_len,
&this_str);
return this_len;
}
#endif
bool Value::getString(char const** begin, char const** end) const { … }
String Value::asString() const { … }
Value::Int Value::asInt() const { … }
Value::UInt Value::asUInt() const { … }
#if defined(JSON_HAS_INT64)
Value::Int64 Value::asInt64() const { … }
Value::UInt64 Value::asUInt64() const { … }
#endif
LargestInt Value::asLargestInt() const { … }
LargestUInt Value::asLargestUInt() const { … }
double Value::asDouble() const { … }
float Value::asFloat() const { … }
bool Value::asBool() const { … }
bool Value::isConvertibleTo(ValueType other) const { … }
ArrayIndex Value::size() const { … }
bool Value::empty() const { … }
operator bool()
void Value::clear() { … }
void Value::resize(ArrayIndex newSize) { … }
Value& Value::operator[](ArrayIndex index) { … }
Value& Value::operator[](int index) { … }
const Value& Value::operator[](ArrayIndex index) const { … }
const Value& Value::operator[](int index) const { … }
void Value::initBasic(ValueType type, bool allocated) { … }
void Value::dupPayload(const Value& other) { … }
void Value::releasePayload() { … }
void Value::dupMeta(const Value& other) { … }
Value& Value::resolveReference(const char* key) { … }
Value& Value::resolveReference(char const* key, char const* end) { … }
Value Value::get(ArrayIndex index, const Value& defaultValue) const { … }
bool Value::isValidIndex(ArrayIndex index) const { … }
Value const* Value::find(char const* begin, char const* end) const { … }
Value* Value::demand(char const* begin, char const* end) { … }
const Value& Value::operator[](const char* key) const { … }
Value const& Value::operator[](const String& key) const { … }
Value& Value::operator[](const char* key) { … }
Value& Value::operator[](const String& key) { … }
Value& Value::operator[](const StaticString& key) { … }
Value& Value::append(const Value& value) { … }
Value& Value::append(Value&& value) { … }
bool Value::insert(ArrayIndex index, const Value& newValue) { … }
bool Value::insert(ArrayIndex index, Value&& newValue) { … }
Value Value::get(char const* begin, char const* end,
Value const& defaultValue) const { … }
Value Value::get(char const* key, Value const& defaultValue) const { … }
Value Value::get(String const& key, Value const& defaultValue) const { … }
bool Value::removeMember(const char* begin, const char* end, Value* removed) { … }
bool Value::removeMember(const char* key, Value* removed) { … }
bool Value::removeMember(String const& key, Value* removed) { … }
void Value::removeMember(const char* key) { … }
void Value::removeMember(const String& key) { … }
bool Value::removeIndex(ArrayIndex index, Value* removed) { … }
bool Value::isMember(char const* begin, char const* end) const { … }
bool Value::isMember(char const* key) const { … }
bool Value::isMember(String const& key) const { … }
Value::Members Value::getMemberNames() const { … }
static bool IsIntegral(double d) { … }
bool Value::isNull() const { … }
bool Value::isBool() const { … }
bool Value::isInt() const { … }
bool Value::isUInt() const { … }
bool Value::isInt64() const { … }
bool Value::isUInt64() const { … }
bool Value::isIntegral() const { … }
bool Value::isDouble() const { … }
bool Value::isNumeric() const { … }
bool Value::isString() const { … }
bool Value::isArray() const { … }
bool Value::isObject() const { … }
Value::Comments::Comments(const Comments& that)
: … { … }
Value::Comments::Comments(Comments&& that) noexcept
: … { … }
Value::Comments& Value::Comments::operator=(const Comments& that) { … }
Value::Comments& Value::Comments::operator=(Comments&& that) noexcept { … }
bool Value::Comments::has(CommentPlacement slot) const { … }
String Value::Comments::get(CommentPlacement slot) const { … }
void Value::Comments::set(CommentPlacement slot, String comment) { … }
void Value::setComment(String comment, CommentPlacement placement) { … }
bool Value::hasComment(CommentPlacement placement) const { … }
String Value::getComment(CommentPlacement placement) const { … }
void Value::setOffsetStart(ptrdiff_t start) { … }
void Value::setOffsetLimit(ptrdiff_t limit) { … }
ptrdiff_t Value::getOffsetStart() const { … }
ptrdiff_t Value::getOffsetLimit() const { … }
String Value::toStyledString() const { … }
Value::const_iterator Value::begin() const { … }
Value::const_iterator Value::end() const { … }
Value::iterator Value::begin() { … }
Value::iterator Value::end() { … }
PathArgument::PathArgument() = default;
PathArgument::PathArgument(ArrayIndex index)
: … { … }
PathArgument::PathArgument(const char* key) : … { … }
PathArgument::PathArgument(String key) : … { … }
Path::Path(const String& path, const PathArgument& a1, const PathArgument& a2,
const PathArgument& a3, const PathArgument& a4,
const PathArgument& a5) { … }
void Path::makePath(const String& path, const InArgs& in) { … }
void Path::addPathInArg(const String& , const InArgs& in,
InArgs::const_iterator& itInArg,
PathArgument::Kind kind) { … }
void Path::invalidPath(const String& , int ) { … }
const Value& Path::resolve(const Value& root) const { … }
Value Path::resolve(const Value& root, const Value& defaultValue) const { … }
Value& Path::make(Value& root) const { … }
}