godot/thirdparty/openxr/src/external/jsoncpp/src/lib_json/json_value.cpp

// Copyright 2011 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

#if !defined(JSON_IS_AMALGAMATION)
#include <json/assertions.h>
#include <json/value.h>
#include <json/writer.h>
#endif // if !defined(JSON_IS_AMALGAMATION)
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <cstring>
#include <iostream>
#include <sstream>
#include <utility>

// Provide implementation equivalent of std::snprintf for older _MSC compilers
#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

// Disable warning C4702 : unreachable code
#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) {}

// This is a walkaround to avoid the static initialization of Value::null.
// kNull must be word-aligned to avoid crashing on ARM.  We use an alignment of
// 8 (instead of 4) as a bit of future-proofing.
#if defined(__ARMEL__)
#define ALIGNAS
#else
#define ALIGNAS(byte_alignment)
#endif

// static
Value const& Value::nullSingleton() {}

#if JSON_USE_NULLREF
// for backwards compatibility, we'll leave these global references around, but
// DO NOT use them in JSONCPP library code any more!
// static
Value const& Value::null =;

// static
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) {
  // The casts can lose precision, but we are looking only for
  // an approximate range. Might fail on edge cases though. ~cdunn
  return d >= static_cast<double>(min) && d <= static_cast<double>(max);
}
#else  // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
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 // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)

/** Duplicates the specified string value.
 * @param value Pointer to the string to duplicate. Must be zero-terminated if
 *              length is "unknown".
 * @param length Length of the value. if equals to unknown, then it will be
 *               computed using strlen(value).
 * @return Pointer on the duplicate instance of string.
 */
static inline char* duplicateStringValue(const char* value, size_t length) {}

/* Record the length as a prefix.
 */
static inline char* duplicateAndPrefixStringValue(const char* value,
                                                  unsigned int length) {}
inline static void decodePrefixedString(bool isPrefixed, char const* prefixed,
                                        unsigned* length, char const** value) {}
/** Free the string duplicated by
 * duplicateStringValue()/duplicateAndPrefixStringValue().
 */
#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) {
  // length==0 => we allocated the strings memory
  size_t size = (length == 0) ? strlen(value) : length;
  memset(value, 0, size);
  free(value);
}
#else  // !JSONCPP_USING_SECURE_MEMORY
static inline void releasePrefixedStringValue(char* value) {}
static inline void releaseStringValue(char* value, unsigned) {}
#endif // JSONCPP_USING_SECURE_MEMORY

} // namespace Json

// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// ValueInternals...
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
#if !defined(JSON_IS_AMALGAMATION)

#include "json_valueiterator.inl"
#endif // if !defined(JSON_IS_AMALGAMATION)

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 // !JSON_USE_EXCEPTION
JSONCPP_NORETURN void throwRuntimeError(String const& msg) {}
JSONCPP_NORETURN void throwLogicError(String const& msg) {}
#endif

// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// class Value::CZString
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////

// Notes: policy_ indicates if the string was allocated when
// a string is stored.

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::c_str() const { return cstr_; }
const char* Value::CZString::data() const {}
unsigned Value::CZString::length() const {}
bool Value::CZString::isStaticString() const {}

// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// class Value::Value
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////

/*! \internal Default constructor initialization must be equivalent to:
 * memset( this, 0, sizeof(Value) )
 * This optimization is used in ValueInternalMap fast allocator.
 */
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 // defined(JSON_HAS_INT64)

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 // if defined(JSON_HAS_INT64)

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 {}

/// Number of values in array or object
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) {}

// Access an object value by name, create a null member if it does not exist.
// @pre Type of '*this' is object or null.
// @param key is null-terminated.
Value& Value::resolveReference(const char* key) {}

// @param key is not null-terminated.
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() {}

// class PathArgument
// //////////////////////////////////////////////////////////////////

PathArgument::PathArgument() = default;

PathArgument::PathArgument(ArrayIndex index)
    :{}

PathArgument::PathArgument(const char* key) :{}

PathArgument::PathArgument(String key) :{}

// class Path
// //////////////////////////////////////////////////////////////////

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& /*path*/, const InArgs& in,
                        InArgs::const_iterator& itInArg,
                        PathArgument::Kind kind) {}

void Path::invalidPath(const String& /*path*/, int /*location*/) {}

const Value& Path::resolve(const Value& root) const {}

Value Path::resolve(const Value& root, const Value& defaultValue) const {}

Value& Path::make(Value& root) const {}

} // namespace Json