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 4275)
71 char const*
what() const noexcept override;
151 operator const char*()
const {
return c_str_; }
153 const char*
c_str()
const {
return c_str_; }
202#if defined(JSON_HAS_INT64)
237#if defined(JSON_HAS_INT64)
246 static constexpr UInt defaultRealPrecision = 17;
259#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
262 enum DuplicationPolicy { noDuplication = 0, duplicate, duplicateOnCopy };
264 CZString(
char const* str,
unsigned length, DuplicationPolicy allocate);
265 CZString(CZString
const& other);
266 CZString(CZString&& other)
noexcept;
268 CZString&
operator=(
const CZString& other);
269 CZString&
operator=(CZString&& other)
noexcept;
271 bool operator<(CZString
const& other)
const;
275 char const* data()
const;
276 unsigned length()
const;
277 bool isStaticString()
const;
280 void swap(CZString& other);
282 struct StringStorage {
283 unsigned policy_ : 2;
284 unsigned length_ : 30;
290 StringStorage storage_;
295 typedef std::map<CZString, Value> ObjectValues;
318#if defined(JSON_HAS_INT64)
323 Value(
const char* value);
324 Value(
const char* begin,
const char* end);
377#if JSONCPP_USING_SECURE_MEMORY
378 unsigned getCStringLength()
const;
388#if defined(JSON_HAS_INT64)
425 explicit operator
bool() const;
446 Value& operator[](
int index);
454 const
Value& operator[](
int index) const;
475 Value& operator[](const
char* key);
478 const
Value& operator[](const
char* key) const;
506 const
Value& defaultValue) const;
550 bool isMember(const
char* key) const;
579 String toStyledString()
const;
581 const_iterator begin()
const;
582 const_iterator end()
const;
589 void setOffsetStart(ptrdiff_t start);
590 void setOffsetLimit(ptrdiff_t limit);
591 ptrdiff_t getOffsetStart()
const;
592 ptrdiff_t getOffsetLimit()
const;
596 bits_.value_type_ =
static_cast<unsigned char>(v);
598 bool isAllocated()
const {
return bits_.allocated_; }
599 void setIsAllocated(
bool v) { bits_.allocated_ = v; }
601 void initBasic(ValueType type,
bool allocated =
false);
602 void dupPayload(
const Value& other);
603 void releasePayload();
604 void dupMeta(
const Value& other);
606 Value& resolveReference(
const char* key);
607 Value& resolveReference(
const char* key,
const char* end);
636 Comments() =
default;
637 Comments(
const Comments& that);
638 Comments(Comments&& that)
noexcept;
639 Comments& operator=(
const Comments& that);
640 Comments& operator=(Comments&& that)
noexcept;
646 using Array = std::array<String, numberOfCommentPlacement>;
647 std::unique_ptr<Array> ptr_;
666#if defined(JSON_HAS_INT64)
700 enum Kind { kindNone = 0, kindIndex, kindKey };
703 Kind kind_{kindNone};
732 using InArgs = std::vector<const PathArgument*>;
733 using Args = std::vector<PathArgument>;
735 void makePath(
const String& path,
const InArgs& in);
736 void addPathInArg(
const String& path,
const InArgs& in,
737 InArgs::const_iterator& itInArg, PathArgument::Kind kind);
738 static void invalidPath(
const String& path,
int location);
783 char const*
memberName(
char const** end) const;
806 Value::ObjectValues::iterator current_;
889 explicit ValueIterator(
const Value::ObjectValues::iterator& current);
931#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
char const * what() const noexcept override
~Exception() noexcept override
LogicError(String const &msg)
Experimental and untested: represents an element of the "path" to access a node.
Path(const String &path, const PathArgument &a1=PathArgument(), const PathArgument &a2=PathArgument(), const PathArgument &a3=PathArgument(), const PathArgument &a4=PathArgument(), const PathArgument &a5=PathArgument())
Value & make(Value &root) const
Creates the "path" to access the specified node and returns a reference on the node.
const Value & resolve(const Value &root) const
RuntimeError(String const &msg)
Lightweight wrapper to tag static string.
const char * c_str() const
StaticString(const char *czstring)
const iterator for object and array value.
pointer operator->() const
ValueConstIterator SelfType
SelfType & operator=(const ValueIteratorBase &other)
reference operator*() const
const_iterator begin() const
Value get(ArrayIndex index, const Value &defaultValue) const
If the array contains at least index+1 elements, returns the element value, otherwise returns default...
bool empty() const
Return true if empty array, empty object, or null; otherwise, false.
Value(std::nullptr_t ptr)=delete
static constexpr LargestInt maxLargestInt
Maximum signed integer value that can be stored in a Json::Value.
Json::ArrayIndex ArrayIndex
ArrayIndex size() const
Number of values in array or object.
const char * asCString() const
Embedded zeroes could cause you trouble!
bool operator==(const Value &other) const
static constexpr Int64 maxInt64
Maximum signed 64 bits int value that can be stored in a Json::Value.
void copy(const Value &other)
copy everything.
static const Value & null
void setComment(const char *comment, size_t len, CommentPlacement placement)
Comments must be //... or /* ... */.
bool getString(char const **begin, char const **end) const
Get raw char* of string-value.
T as() const =delete
The as<T> and is<T> member function templates and specializations.
static constexpr double maxUInt64AsDouble
std::vector< String > Members
const_iterator end() const
bool operator<=(const Value &other) const
bool operator>(const Value &other) const
void clear()
Remove all object members and array elements.
String asString() const
Embedded zeroes are possible.
void swapPayload(Value &other)
Swap values but leave comments and source offsets in place.
CommentPlacement placement
bool removeIndex(ArrayIndex index, Value *removed)
Remove the indexed array element.
Json::LargestInt LargestInt
Json::LargestUInt LargestUInt
ValueConstIterator const_iterator
Members getMemberNames() const
Return a list of the member names.
void resize(ArrayIndex newSize)
Resize the array to newSize elements.
Value & append(const Value &value)
Append value to array at the end.
bool operator!=(const Value &other) const
void removeMember(const char *key)
Remove and return the named member.
Value * demand(char const *begin, char const *end)
Most general and efficient version of object-mutators.
void swap(Value &other)
Swap everything.
bool operator<(const Value &other) const
Compare payload only, not comments etc.
static const Value & nullRef
LargestInt asLargestInt() const
void copyPayload(const Value &other)
copy values but leave comments and source offsets in place.
static constexpr Int maxInt
Maximum signed int value that can be stored in a Json::Value.
static constexpr LargestUInt maxLargestUInt
Maximum unsigned integer value that can be stored in a Json::Value.
bool isValidIndex(ArrayIndex index) const
Return true if index < size().
friend class ValueIteratorBase
LargestUInt asLargestUInt() const
bool isMember(const char *key) const
Return true if the object has a member named key.
Value(ValueType type=nullValue)
Create a default Value of the given type.
static constexpr UInt64 maxUInt64
Maximum unsigned 64 bits int value that can be stored in a Json::Value.
Value & operator=(const Value &other)
static constexpr Int minInt
Minimum signed int value that can be stored in a Json::Value.
bool insert(ArrayIndex index, const Value &newValue)
Insert value in array at specific index.
static constexpr Int64 minInt64
Minimum signed 64 bits int value that can be stored in a Json::Value.
int compare(const Value &other) const
static constexpr LargestInt minLargestInt
Minimum signed integer value that can be stored in a Json::Value.
bool isConvertibleTo(ValueType other) const
static Value const & nullSingleton()
Value const * find(char const *begin, char const *end) const
Most general and efficient version of isMember()const, get()const, and operator[]const.
bool operator>=(const Value &other) const
static constexpr UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
base class for Value iterators.
bool isEqual(const SelfType &other) const
bool operator==(const SelfType &other) const
char const * memberName(char const **end) const
Return the member name of the referenced Value, or NULL if it is not an objectValue.
void copy(const SelfType &other)
std::bidirectional_iterator_tag iterator_category
difference_type operator-(const SelfType &other) const
bool operator!=(const SelfType &other) const
const Value & deref() const
ValueIteratorBase SelfType
difference_type computeDistance(const SelfType &other) const
Iterator for object and array value.
reference operator*() const
ValueIterator(const ValueIterator &other)
pointer operator->() const
SelfType & operator=(const SelfType &other)
#define JSON_API
If defined, indicates that the source file is amalgamated to prevent private header inclusion.
#define JSONCPP_DEPRECATED(message)
JSON (JavaScript Object Notation).
@ commentAfterOnSameLine
a comment just after a value on the same line
@ commentBefore
a comment placed on the line before a value
@ numberOfCommentPlacement
root value)
@ commentAfter
a comment on the line after a value (only make sense for
ValueType
Type of the value held by a Value object.
@ stringValue
UTF-8 string value.
@ arrayValue
array value (ordered list)
@ intValue
signed integer value
@ objectValue
object value (collection of name/value pairs).
@ uintValue
unsigned integer value
std::basic_string< char, std::char_traits< char >, Allocator< char > > String
PrecisionType
Type of precision for formatting of real values.
@ decimalPlaces
we set max number of digits after "." in string
@ significantDigits
we set max number of significant digits in string
void swap(Value &a, Value &b)
#define JSONCPP_TEMPLATE_DELETE