6#ifndef NIM_CPP_WRAPPER_UTIL_JSON_H_INCLUDED
7#define NIM_CPP_WRAPPER_UTIL_JSON_H_INCLUDED
9#if !defined(JSON_IS_AMALGAMATION)
16#if !defined(JSONCPP_NORETURN)
17#if defined(_MSC_VER) && _MSC_VER == 1800
18#define JSONCPP_NORETURN __declspec(noreturn)
20#define JSONCPP_NORETURN [[noreturn]]
27#if !defined(JSONCPP_TEMPLATE_DELETE)
28#if defined(__clang__) && defined(__apple_build_version__)
29#if __apple_build_version__ <= 8000042
30#define JSONCPP_TEMPLATE_DELETE
32#elif defined(__clang__)
33#if __clang_major__ == 3 && __clang_minor__ <= 8
34#define JSONCPP_TEMPLATE_DELETE
37#if !defined(JSONCPP_TEMPLATE_DELETE)
38#define JSONCPP_TEMPLATE_DELETE = delete
51#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
53#pragma warning(disable : 4251)
72 char const* what() const noexcept override;
152 : c_str_(czstring) {}
154 operator const char*()
const {
return c_str_; }
156 const char*
c_str()
const {
return c_str_; }
205#if defined(JSON_HAS_INT64)
223 static Value const& nullSingleton();
239#if defined(JSON_HAS_INT64)
248 static constexpr UInt defaultRealPrecision = 17;
252 static constexpr double maxUInt64AsDouble = 18446744073709551615.0;
261#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
266 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
273 bool operator<(
CZString const& other)
const;
274 bool operator==(
CZString const& other)
const;
277 char const* data()
const;
278 unsigned length()
const;
279 bool isStaticString()
const;
320#if defined(JSON_HAS_INT64)
325 Value(
const char* value);
326 Value(
const char* begin,
const char* end);
360 void swapPayload(
Value& other);
363 void copy(
const Value& other);
365 void copyPayload(
const Value& other);
370 bool operator<(
const Value& other)
const;
371 bool operator<=(
const Value& other)
const;
372 bool operator>=(
const Value& other)
const;
373 bool operator>(
const Value& other)
const;
374 bool operator==(
const Value& other)
const;
376 int compare(
const Value& other)
const;
378 const char* asCString()
const;
379#if JSONCPP_USING_SECURE_MEMORY
380 unsigned getCStringLength()
const;
387 bool getString(
char const** begin,
char const** end)
const;
390#if defined(JSON_HAS_INT64)
396 float asFloat()
const;
397 double asDouble()
const;
403 bool isInt64()
const;
405 bool isUInt64()
const;
406 bool isIntegral()
const;
407 bool isDouble()
const;
408 bool isNumeric()
const;
409 bool isString()
const;
410 bool isArray()
const;
411 bool isObject()
const;
414 template <
typename T>
416 template <typename T>
419 bool isConvertibleTo(
ValueType other) const;
429 explicit operator
bool() const;
450 Value& operator[](
int index);
458 const
Value& operator[](
int index) const;
479 Value& operator[](const
char* key);
482 const
Value& operator[](const
char* key) const;
505 Value get(const
char* key, const
Value& defaultValue) const;
509 Value get(const
char* begin, const
char* end, const
Value& defaultValue) const;
517 Value const* find(
char const* begin,
char const* end) const;
521 Value* demand(
char const* begin,
char const* end);
527 void removeMember(const
char* key);
530 void removeMember(const
String& key);
533 bool removeMember(const
char* key,
Value* removed);
540 bool removeMember(
String const& key,
Value* removed);
542 bool removeMember(const
char* begin, const
char* end,
Value* removed);
553 bool isMember(const
char* key) const;
556 bool isMember(const
String& key) const;
558 bool isMember(const
char* begin, const
char* end) const;
565 Members getMemberNames() const;
569 setComment(
String(comment, strlen(comment)), placement);
573 setComment(
String(comment, len), placement);
581 String toStyledString()
const;
583 const_iterator begin()
const;
584 const_iterator end()
const;
591 void setOffsetStart(ptrdiff_t start);
592 void setOffsetLimit(ptrdiff_t limit);
593 ptrdiff_t getOffsetStart()
const;
594 ptrdiff_t getOffsetLimit()
const;
598 bits_.value_type_ =
static_cast<unsigned char>(v);
601 return bits_.allocated_;
604 bits_.allocated_ = v;
607 void initBasic(
ValueType type,
bool allocated =
false);
608 void dupPayload(
const Value& other);
609 void releasePayload();
610 void dupMeta(
const Value& other);
612 Value& resolveReference(
const char* key);
613 Value& resolveReference(
const char* key,
const char* end);
652 using Array = std::array<String, numberOfCommentPlacement>;
664inline bool Value::as<bool>()
const {
668inline bool Value::is<bool>()
const {
673inline Int Value::as<Int>()
const {
677inline bool Value::is<Int>()
const {
682inline UInt Value::as<UInt>()
const {
686inline bool Value::is<UInt>()
const {
690#if defined(JSON_HAS_INT64)
692inline Int64 Value::as<Int64>()
const {
696inline bool Value::is<Int64>()
const {
705inline bool Value::is<UInt64>()
const {
711inline double Value::as<double>()
const {
715inline bool Value::is<double>()
const {
724inline bool Value::is<String>()
const {
731inline float Value::as<float>()
const {
735inline const char* Value::as<const char*>()
const {
752 enum Kind { kindNone = 0, kindIndex, kindKey };
778 const Value& resolve(
const Value& root)
const;
785 using InArgs = std::vector<const PathArgument*>;
786 using Args = std::vector<PathArgument>;
790 static void invalidPath(
const String& path,
int location);
828 char const* memberName()
const;
832 char const* memberName(
char const** end)
const;
841 const Value& deref()
const;
848 difference_type computeDistance(
const SelfType& other)
const;
850 bool isEqual(
const SelfType& other)
const;
852 void copy(
const SelfType& other);
938 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
983#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
~Exception() noexcept override
LogicError(String const &msg)
Experimental and untested: represents an element of the "path" to access a node.
Definition: value.h:742
Kind
Definition: value.h:752
String key_
Definition: value.h:753
Experimental and untested: represents a "path" to access a node.
Definition: value.h:769
Args args_
Definition: value.h:792
std::vector< PathArgument > Args
Definition: value.h:786
std::vector< const PathArgument * > InArgs
Definition: value.h:785
RuntimeError(String const &msg)
Lightweight wrapper to tag static string.
Definition: value.h:149
const char * c_str_
Definition: value.h:159
StaticString(const char *czstring)
Definition: value.h:151
const char * c_str() const
Definition: value.h:156
StringStorage storage_
Definition: value.h:292
ArrayIndex index_
Definition: value.h:291
char const * cstr_
Definition: value.h:289
DuplicationPolicy
Definition: value.h:264
@ duplicate
Definition: value.h:264
const iterator for object and array value.
Definition: value.h:869
SelfType operator++(int)
Definition: value.h:891
reference operator*() const
Definition: value.h:913
SelfType & operator++()
Definition: value.h:908
SelfType operator--(int)
Definition: value.h:897
pointer operator->() const
Definition: value.h:915
SelfType & operator--()
Definition: value.h:903
Represents a JSON value.
Definition: value.h:196
void setComment(const char *comment, size_t len, CommentPlacement placement)
Comments must be //... or /* ... */
Definition: value.h:572
nim_cpp_wrapper_util::Json::UInt UInt
Definition: value.h:203
Value(std::nullptr_t ptr)=delete
nim_cpp_wrapper_util::Json::UInt64 UInt64
Definition: value.h:206
nim_cpp_wrapper_util::Json::LargestInt LargestInt
Definition: value.h:209
void setIsAllocated(bool v)
Definition: value.h:603
nim_cpp_wrapper_util::Json::ArrayIndex ArrayIndex
Definition: value.h:211
T as() const JSONCPP_TEMPLATE_DELETE
The as<T> and is<T> member function templates and specializations.
void swap(Value &other)
Swap everything.
Definition: json_value.cpp:472
unsigned int value_type_
Definition: value.h:635
void setType(ValueType v)
Definition: value.h:597
std::map< CZString, Value > ObjectValues
Definition: value.h:297
ptrdiff_t limit_
Definition: value.h:660
static const Value & nullRef
Definition: value.h:219
nim_cpp_wrapper_util::Json::Int64 Int64
Definition: value.h:207
std::string value_type
Definition: value.h:214
Comments comments_
Definition: value.h:655
nim_cpp_wrapper_util::Json::Int Int
Definition: value.h:204
ptrdiff_t start_
Definition: value.h:659
std::vector< String > Members
Definition: value.h:200
bool isAllocated() const
Definition: value.h:600
static const Value & null
Definition: value.h:218
unsigned int allocated_
Definition: value.h:637
nim_cpp_wrapper_util::Json::LargestUInt LargestUInt
Definition: value.h:210
base class for Value iterators.
Definition: value.h:798
bool operator==(const SelfType &other) const
Definition: value.h:805
difference_type operator-(const SelfType &other) const
Definition: value.h:809
Value::ObjectValues::iterator current_
Definition: value.h:855
std::bidirectional_iterator_tag iterator_category
Definition: value.h:800
bool operator!=(const SelfType &other) const
Definition: value.h:807
int difference_type
Definition: value.h:802
unsigned int size_t
Definition: value.h:801
difference_type computeDistance(const SelfType &other) const
Definition: json_valueiterator.inl:41
Iterator for object and array value.
Definition: value.h:920
SelfType & operator++()
Definition: value.h:960
int difference_type
Definition: value.h:926
reference operator*()
Definition: value.h:970
SelfType & operator--()
Definition: value.h:955
ValueIterator(const ValueIterator &other)
unsigned int size_t
Definition: value.h:925
SelfType operator--(int)
Definition: value.h:949
pointer operator->()
Definition: value.h:971
SelfType operator++(int)
Definition: value.h:943
#define JSON_API
Definition: config.h:50
void swap(Value &a, Value &b)
Definition: value.h:974
CommentPlacement
Definition: value.h:120
@ commentBefore
a comment placed on the line before a value
Definition: value.h:121
@ commentAfterOnSameLine
a comment just after a value on the same line
Definition: value.h:122
@ commentAfter
Definition: value.h:123
@ numberOfCommentPlacement
root value)
Definition: value.h:125
PrecisionType
Type of precision for formatting of real values.
Definition: value.h:130
@ decimalPlaces
we set max number of digits after "." in string
Definition: value.h:132
@ significantDigits
we set max number of significant digits in string
Definition: value.h:131
JSONCPP_NORETURN void throwRuntimeError(String const &msg)
used internally
Definition: json_value.cpp:223
UInt64 LargestUInt
Definition: config.h:104
uint64_t UInt64
Definition: config.h:101
unsigned int UInt
Definition: config.h:89
int Int
Definition: config.h:88
Int64 LargestInt
Definition: config.h:103
int64_t Int64
Definition: config.h:100
unsigned int ArrayIndex
Definition: forwards.h:33
ValueType
Type of the value held by a Value object.
Definition: value.h:108
@ booleanValue
bool value
Definition: value.h:114
@ objectValue
object value (collection of name/value pairs).
Definition: value.h:116
@ realValue
double value
Definition: value.h:112
@ stringValue
UTF-8 string value
Definition: value.h:113
@ intValue
signed integer value
Definition: value.h:110
@ arrayValue
array value (ordered list)
Definition: value.h:115
@ nullValue
'null' value
Definition: value.h:109
@ uintValue
unsigned integer value
Definition: value.h:111
std::basic_string< char, std::char_traits< char >, Allocator< char > > String
Definition: config.h:110
bool operator!=(const SecureAllocator< T > &, const SecureAllocator< U > &)
Definition: allocator.h:88
JSONCPP_NORETURN void throwLogicError(String const &msg)
used internally
Definition: json_value.cpp:227
JSON (JavaScript Object Notation).
Definition: allocator.h:14
unsigned length_
Definition: value.h:286
unsigned policy_
Definition: value.h:285
double real_
Definition: value.h:627
ObjectValues * map_
Definition: value.h:630
LargestUInt uint_
Definition: value.h:626
LargestInt int_
Definition: value.h:625
bool bool_
Definition: value.h:628
char * string_
Definition: value.h:629
#define JSONCPP_TEMPLATE_DELETE
Definition: value.h:38
#define JSONCPP_NORETURN
Definition: value.h:20