6#if !defined(JSON_IS_AMALGAMATION)
20#ifdef JSONCPP_HAS_STRING_VIEW
25#if defined(_MSC_VER) && _MSC_VER < 1900
28 const char* format, va_list ap) {
31 count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
33 count = _vscprintf(format, ap);
38 const char* format, ...) {
49#pragma warning(disable : 4702)
52#define JSON_ASSERT_UNREACHABLE assert(false)
56static std::unique_ptr<T>
cloneUnique(
const std::unique_ptr<T>& p) {
59 r = std::unique_ptr<T>(
new T(*p));
68#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
70#define ALIGNAS(byte_alignment)
75 static Value const nullStatic;
89#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
90template <
typename T,
typename U>
91static inline bool InRange(
double d, T min, U max) {
94 return d >=
static_cast<double>(min) && d <=
static_cast<double>(max) &&
95 !(
static_cast<U
>(d) == min && d !=
static_cast<double>(min));
98static inline double integerToDouble(
Json::UInt64 value) {
99 return static_cast<double>(
Int64(value / 2)) * 2.0 +
100 static_cast<double>(
Int64(value & 1));
103template <
typename T>
static inline double integerToDouble(T value) {
104 return static_cast<double>(value);
107template <
typename T,
typename U>
108static inline bool InRange(
double d, T min, U max) {
109 return d >= integerToDouble(min) && d <= integerToDouble(max) &&
110 !(
static_cast<U
>(d) == min && d != integerToDouble(min));
127 auto newString =
static_cast<char*
>(malloc(length + 1));
128 if (newString ==
nullptr) {
129 throwRuntimeError(
"in Json::Value::duplicateStringValue(): "
130 "Failed to allocate string value buffer");
132 memcpy(newString, value, length);
133 newString[length] = 0;
140 unsigned int length) {
144 sizeof(
unsigned) - 1U,
145 "in Json::Value::duplicateAndPrefixStringValue(): "
146 "length too big for prefixing");
147 size_t actualLength =
sizeof(length) + length + 1;
148 auto newString =
static_cast<char*
>(malloc(actualLength));
149 if (newString ==
nullptr) {
150 throwRuntimeError(
"in Json::Value::duplicateAndPrefixStringValue(): "
151 "Failed to allocate string value buffer");
153 *
reinterpret_cast<unsigned*
>(newString) = length;
154 memcpy(newString +
sizeof(
unsigned), value, length);
155 newString[actualLength - 1U] =
160 unsigned* length,
char const** value) {
162 *length =
static_cast<unsigned>(strlen(prefixed));
165 *length = *
reinterpret_cast<unsigned const*
>(prefixed);
166 *value = prefixed +
sizeof(unsigned);
172#if JSONCPP_USE_SECURE_MEMORY
175 char const* valueDecoded;
177 size_t const size =
sizeof(unsigned) + length + 1U;
178 memset(value, 0, size);
183 size_t size = (length == 0) ? strlen(value) : length;
184 memset(value, 0, size);
201#if !defined(JSON_IS_AMALGAMATION)
208#if JSON_USE_EXCEPTION
218 throw LogicError(msg);
222 std::cerr << msg << std::endl;
226 std::cerr << msg << std::endl;
242Value::CZString::CZString(
ArrayIndex index) : cstr_(nullptr), index_(index) {}
244Value::CZString::CZString(
char const* str,
unsigned length,
245 DuplicationPolicy allocate)
248 storage_.policy_ = allocate & 0x3;
249 storage_.length_ = length & 0x3FFFFFFF;
252Value::CZString::CZString(
const CZString& other) {
253 cstr_ = (other.storage_.policy_ != noDuplication && other.cstr_ !=
nullptr
258 static_cast<unsigned>(
260 ? (static_cast<DuplicationPolicy>(other.storage_.policy_) ==
264 : static_cast<DuplicationPolicy>(other.storage_.policy_)) &
266 storage_.length_ = other.storage_.length_;
268 index_ = other.index_;
272Value::CZString::CZString(CZString&& other) noexcept : cstr_(other.cstr_) {
274 storage_.policy_ = other.storage_.policy_;
275 storage_.length_ = other.storage_.length_;
277 index_ = other.index_;
279 other.cstr_ =
nullptr;
282Value::CZString::~CZString() {
283 if (cstr_ && storage_.policy_ == duplicate) {
285 storage_.length_ + 1U);
292void Value::CZString::swap(CZString& other) {
293 std::swap(cstr_, other.cstr_);
294 std::swap(index_, other.index_);
297Value::CZString& Value::CZString::operator=(
const CZString& other) {
299 index_ = other.index_;
303Value::CZString& Value::CZString::operator=(CZString&& other)
noexcept {
304 if (cstr_ && storage_.policy_ == duplicate) {
309 storage_.policy_ = other.storage_.policy_;
310 storage_.length_ = other.storage_.length_;
312 index_ = other.index_;
314 other.cstr_ =
nullptr;
318bool Value::CZString::operator<(
const CZString& other)
const {
320 return index_ < other.index_;
323 unsigned this_len = this->storage_.length_;
324 unsigned other_len = other.storage_.length_;
325 unsigned min_len = std::min<unsigned>(this_len, other_len);
327 int comp = memcmp(this->cstr_, other.cstr_, min_len);
332 return (this_len < other_len);
335bool Value::CZString::operator==(
const CZString& other)
const {
337 return index_ == other.index_;
340 unsigned this_len = this->storage_.length_;
341 unsigned other_len = other.storage_.length_;
342 if (this_len != other_len)
345 int comp = memcmp(this->cstr_, other.cstr_, this_len);
349ArrayIndex Value::CZString::index()
const {
return index_; }
352const char* Value::CZString::data()
const {
return cstr_; }
353unsigned Value::CZString::length()
const {
return storage_.length_; }
354bool Value::CZString::isStaticString()
const {
355 return storage_.policy_ == noDuplication;
371 static char const emptyString[] =
"";
385 value_.string_ =
const_cast<char*
>(
static_cast<char const*
>(emptyString));
389 value_.map_ =
new ObjectValues();
392 value_.bool_ =
false;
406 value_.uint_ = value;
408#if defined(JSON_HAS_INT64)
415 value_.uint_ = value;
421 value_.real_ = value;
427 "Null Value Passed to Value Constructor");
429 value,
static_cast<unsigned>(strlen(value)));
441 value.data(),
static_cast<unsigned>(value.length()));
446 value_.string_ =
const_cast<char*
>(value.
c_str());
451 value_.bool_ = value;
470 Value(other).swap(*
this);
480 std::swap(bits_, other.bits_);
481 std::swap(value_, other.value_);
491 std::swap(comments_, other.comments_);
492 std::swap(start_, other.start_);
493 std::swap(limit_, other.limit_);
502 return static_cast<ValueType>(bits_.value_type_);
514 int typeDelta =
type() - other.
type();
516 return typeDelta < 0;
521 return value_.int_ < other.value_.int_;
523 return value_.uint_ < other.value_.uint_;
525 return value_.real_ < other.value_.real_;
527 return value_.bool_ < other.value_.bool_;
529 if ((value_.string_ ==
nullptr) || (other.value_.string_ ==
nullptr)) {
530 return other.value_.string_ !=
nullptr;
534 char const* this_str;
535 char const* other_str;
540 unsigned min_len = std::min<unsigned>(this_len, other_len);
542 int comp = memcmp(this_str, other_str, min_len);
547 return (this_len < other_len);
551 auto thisSize = value_.map_->size();
552 auto otherSize = other.value_.map_->size();
553 if (thisSize != otherSize)
554 return thisSize < otherSize;
555 return (*value_.map_) < (*other.value_.map_);
576 return value_.int_ == other.value_.int_;
578 return value_.uint_ == other.value_.uint_;
580 return value_.real_ == other.value_.real_;
582 return value_.bool_ == other.value_.bool_;
584 if ((value_.string_ ==
nullptr) || (other.value_.string_ ==
nullptr)) {
585 return (value_.string_ == other.value_.string_);
589 char const* this_str;
590 char const* other_str;
595 if (this_len != other_len)
598 int comp = memcmp(this_str, other_str, this_len);
603 return value_.map_->size() == other.value_.map_->size() &&
604 (*value_.map_) == (*other.value_.map_);
615 "in Json::Value::asCString(): requires stringValue");
616 if (value_.string_ ==
nullptr)
619 char const* this_str;
625#if JSONCPP_USE_SECURE_MEMORY
626unsigned Value::getCStringLength()
const {
628 "in Json::Value::asCString(): requires stringValue");
629 if (value_.string_ == 0)
632 char const* this_str;
642 if (value_.string_ ==
nullptr)
656 if (value_.string_ ==
nullptr)
659 char const* this_str;
662 return String(this_str, this_len);
665 return value_.bool_ ?
"true" :
"false";
681 return Int(value_.int_);
684 return Int(value_.uint_);
687 "double out of Int range");
688 return Int(value_.real_);
692 return value_.bool_ ? 1 : 0;
703 return UInt(value_.int_);
706 return UInt(value_.uint_);
709 "double out of UInt range");
710 return UInt(value_.real_);
714 return value_.bool_ ? 1 : 0;
721#if defined(JSON_HAS_INT64)
726 return Int64(value_.int_);
729 return Int64(value_.uint_);
735 "Double value is minInt64, precise value cannot be determined");
737 "double out of Int64 range");
738 return Int64(value_.real_);
742 return value_.bool_ ? 1 : 0;
753 return UInt64(value_.int_);
755 return UInt64(value_.uint_);
758 "double out of UInt64 range");
759 return UInt64(value_.real_);
763 return value_.bool_ ? 1 : 0;
772#if defined(JSON_NO_INT64)
780#if defined(JSON_NO_INT64)
790 return static_cast<double>(value_.int_);
792#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
793 return static_cast<double>(value_.uint_);
795 return integerToDouble(value_.uint_);
802 return value_.bool_ ? 1.0 : 0.0;
812 return static_cast<float>(value_.int_);
814#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
815 return static_cast<float>(value_.uint_);
818 return static_cast<float>(integerToDouble(value_.uint_));
821 return static_cast<float>(value_.real_);
825 return value_.bool_ ? 1.0F : 0.0F;
839 return value_.int_ != 0;
841 return value_.uint_ != 0;
844 const auto value_classification = std::fpclassify(value_.real_);
845 return value_classification != FP_ZERO && value_classification != FP_NAN;
897 if (!value_.map_->empty()) {
898 ObjectValues::const_iterator itLast = value_.map_->end();
900 return (*itLast).first.index() + 1;
916Value::operator bool()
const {
return !
isNull(); }
921 "in Json::Value::clear(): requires complex value");
927 value_.map_->clear();
936 "in Json::Value::resize(): requires arrayValue");
942 else if (newSize > oldSize)
943 for (
ArrayIndex i = oldSize; i < newSize; ++i)
946 for (
ArrayIndex index = newSize; index < oldSize; ++index) {
947 value_.map_->erase(index);
956 "in Json::Value::operator[](ArrayIndex): requires arrayValue");
960 auto it = value_.map_->lower_bound(key);
961 if (it != value_.map_->end() && (*it).first == key)
965 it = value_.map_->insert(it, defaultValue);
972 "in Json::Value::operator[](int index): index cannot be negative");
979 "in Json::Value::operator[](ArrayIndex)const: requires arrayValue");
983 ObjectValues::const_iterator it = value_.map_->find(key);
984 if (it == value_.map_->end())
992 "in Json::Value::operator[](int index) const: index cannot be negative");
996void Value::initBasic(
ValueType type,
bool allocated) {
998 setIsAllocated(allocated);
999 comments_ = Comments{};
1004void Value::dupPayload(
const Value& other) {
1005 setType(other.type());
1006 setIsAllocated(
false);
1013 value_ = other.value_;
1016 if (other.value_.string_ && other.isAllocated()) {
1022 setIsAllocated(
true);
1024 value_.string_ = other.value_.string_;
1029 value_.map_ =
new ObjectValues(*other.value_.map_);
1036void Value::releasePayload() {
1057void Value::dupMeta(
const Value& other) {
1058 comments_ = other.comments_;
1059 start_ = other.start_;
1060 limit_ = other.limit_;
1066Value& Value::resolveReference(
const char* key) {
1068 type() == nullValue || type() == objectValue,
1069 "in Json::Value::resolveReference(): requires objectValue");
1070 if (type() == nullValue)
1071 *
this = Value(objectValue);
1072 CZString actualKey(key,
static_cast<unsigned>(strlen(key)),
1073 CZString::noDuplication);
1074 auto it = value_.map_->lower_bound(actualKey);
1075 if (it != value_.map_->end() && (*it).first == actualKey)
1076 return (*it).second;
1078 ObjectValues::value_type defaultValue(actualKey, nullSingleton());
1079 it = value_.map_->insert(it, defaultValue);
1080 Value& value = (*it).second;
1085Value& Value::resolveReference(
char const* key,
char const* end) {
1087 type() == nullValue || type() == objectValue,
1088 "in Json::Value::resolveReference(key, end): requires objectValue");
1089 if (type() == nullValue)
1090 *
this = Value(objectValue);
1091 CZString actualKey(key,
static_cast<unsigned>(end - key),
1092 CZString::duplicateOnCopy);
1093 auto it = value_.map_->lower_bound(actualKey);
1094 if (it != value_.map_->end() && (*it).first == actualKey)
1095 return (*it).second;
1097 ObjectValues::value_type defaultValue(actualKey, nullSingleton());
1098 it = value_.map_->insert(it, defaultValue);
1099 Value& value = (*it).second;
1104 const Value* value = &((*this)[index]);
1112 "in Json::Value::find(begin, end): requires "
1113 "objectValue or nullValue");
1116 CZString actualKey(
begin,
static_cast<unsigned>(
end -
begin),
1117 CZString::noDuplication);
1118 ObjectValues::const_iterator it = value_.map_->find(actualKey);
1119 if (it == value_.map_->end())
1121 return &(*it).second;
1124 return find(key.data(), key.data() + key.length());
1166 "in Json::Value::demand(begin, end): requires "
1167 "objectValue or nullValue");
1168 return &resolveReference(
begin,
end);
1171 Value const* found =
find(key, key + strlen(key));
1184 return resolveReference(key, key + strlen(key));
1188 return resolveReference(key.data(), key.data() + key.length());
1192 return resolveReference(key.
c_str());
1199 "in Json::Value::append: requires arrayValue");
1203 return this->value_.map_->emplace(
size(), std::move(value)).first->second;
1212 "in Json::Value::insert: requires arrayValue");
1214 if (index > length) {
1217 for (
ArrayIndex i = length; i > index; i--) {
1218 (*this)[i] = std::move((*
this)[i - 1]);
1220 (*this)[index] = std::move(newValue);
1225 Value const& defaultValue)
const {
1227 return !found ? defaultValue : *found;
1230 return get(key, key + strlen(key), defaultValue);
1233 return get(key.data(), key.data() + key.length(), defaultValue);
1240 CZString actualKey(
begin,
static_cast<unsigned>(
end -
begin),
1241 CZString::noDuplication);
1242 auto it = value_.map_->find(actualKey);
1243 if (it == value_.map_->end())
1246 *removed = std::move(it->second);
1247 value_.map_->erase(it);
1254 return removeMember(key.data(), key.data() + key.length(), removed);
1259 "in Json::Value::removeMember(): requires objectValue");
1263 CZString actualKey(key,
unsigned(strlen(key)), CZString::noDuplication);
1264 value_.map_->erase(actualKey);
1272 CZString key(index);
1273 auto it = value_.map_->find(key);
1274 if (it == value_.map_->end()) {
1278 *removed = std::move(it->second);
1281 for (
ArrayIndex i = index; i < (oldSize - 1); ++i) {
1283 (*value_.map_)[keey] = (*
this)[i + 1];
1286 CZString keyLast(oldSize - 1);
1287 auto itLast = value_.map_->find(keyLast);
1288 value_.map_->erase(itLast);
1294 return nullptr != value;
1297 return isMember(key, key + strlen(key));
1300 return isMember(key.data(), key.data() + key.length());
1306 "in Json::Value::getMemberNames(), value must be objectValue");
1310 members.reserve(value_.map_->size());
1311 ObjectValues::const_iterator it = value_.map_->begin();
1312 ObjectValues::const_iterator itEnd = value_.map_->end();
1313 for (; it != itEnd; ++it) {
1314 members.push_back(
String((*it).first.data(), (*it).first.length()));
1320 double integral_part;
1321 return modf(d, &integral_part) == 0.0;
1331#if defined(JSON_HAS_INT64)
1339 return value_.real_ >=
minInt && value_.real_ <=
maxInt &&
1350#if defined(JSON_HAS_INT64)
1353 return value_.int_ >= 0;
1356#if defined(JSON_HAS_INT64)
1357 return value_.uint_ <=
maxUInt;
1362 return value_.real_ >= 0 && value_.real_ <=
maxUInt &&
1371#if defined(JSON_HAS_INT64)
1385 return value_.real_ > double(
minInt64) && value_.real_ < double(
maxInt64) &&
1395#if defined(JSON_HAS_INT64)
1398 return value_.int_ >= 0;
1420#if defined(JSON_HAS_INT64)
1428 return value_.real_ > double(
minInt64) &&
1452Value::Comments::Comments(
const Comments& that)
1455Value::Comments::Comments(Comments&& that) noexcept
1456 : ptr_{std::move(that.ptr_)} {}
1458Value::Comments& Value::Comments::operator=(
const Comments& that) {
1463Value::Comments& Value::Comments::operator=(Comments&& that)
noexcept {
1464 ptr_ = std::move(that.ptr_);
1469 return ptr_ && !(*ptr_)[slot].empty();
1475 return (*ptr_)[slot];
1482 ptr_ = std::unique_ptr<Array>(
new Array());
1483 (*ptr_)[slot] = std::move(comment);
1487 if (!comment.empty() && (comment.back() ==
'\n')) {
1492 comment.empty() || comment[0] ==
'/',
1493 "in Json::Value::setComment(): Comments must start with /");
1494 comments_.set(
placement, std::move(comment));
1554 return iterator(value_.map_->begin());
1567 return iterator(value_.map_->end());
1581 : index_(index), kind_(kindIndex) {}
1603void Path::makePath(
const String& path,
const InArgs& in) {
1604 const char* current = path.c_str();
1605 const char* end = current + path.length();
1606 auto itInArg = in.begin();
1607 while (current != end) {
1608 if (*current ==
'[') {
1610 if (*current ==
'%')
1611 addPathInArg(path, in, itInArg, PathArgument::kindIndex);
1614 for (; current != end && *current >=
'0' && *current <=
'9'; ++current)
1615 index = index * 10 +
ArrayIndex(*current -
'0');
1616 args_.push_back(index);
1618 if (current == end || *++current !=
']')
1619 invalidPath(path,
int(current - path.c_str()));
1620 }
else if (*current ==
'%') {
1621 addPathInArg(path, in, itInArg, PathArgument::kindKey);
1623 }
else if (*current ==
'.' || *current ==
']') {
1626 const char* beginName = current;
1627 while (current != end && !strchr(
"[.", *current))
1629 args_.push_back(
String(beginName, current));
1634void Path::addPathInArg(
const String& ,
const InArgs& in,
1635 InArgs::const_iterator& itInArg,
1636 PathArgument::Kind kind) {
1637 if (itInArg == in.end()) {
1639 }
else if ((*itInArg)->kind_ != kind) {
1642 args_.push_back(**itInArg++);
1646void Path::invalidPath(
const String& ,
int ) {
1651 const Value* node = &root;
1652 for (
const auto& arg : args_) {
1653 if (arg.kind_ == PathArgument::kindIndex) {
1658 node = &((*node)[arg.index_]);
1659 }
else if (arg.kind_ == PathArgument::kindKey) {
1664 node = &((*node)[arg.key_]);
1676 const Value* node = &root;
1677 for (
const auto& arg : args_) {
1678 if (arg.kind_ == PathArgument::kindIndex) {
1680 return defaultValue;
1681 node = &((*node)[arg.index_]);
1682 }
else if (arg.kind_ == PathArgument::kindKey) {
1684 return defaultValue;
1685 node = &((*node)[arg.key_]);
1687 return defaultValue;
1694 Value* node = &root;
1695 for (
const auto& arg : args_) {
1696 if (arg.kind_ == PathArgument::kindIndex) {
1700 node = &((*node)[arg.index_]);
1701 }
else if (arg.kind_ == PathArgument::kindKey) {
1705 node = &((*node)[arg.key_]);
#define JSON_ASSERT(condition)
It should not be possible for a maliciously designed file to cause an abort() or seg-fault,...
#define JSON_FAIL_MESSAGE(message)
#define JSON_ASSERT_MESSAGE(condition, message)
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
Exceptions which the user cannot easily avoid.
RuntimeError(String const &msg)
Lightweight wrapper to tag static string.
const char * c_str() const
Build a StreamWriter implementation.
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.
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
Value const * findDouble(const String &key) const
void setComment(const char *comment, size_t len, CommentPlacement placement)
Comments must be //... or /* ... */.
ptrdiff_t getOffsetLimit() const
bool getString(char const **begin, char const **end) const
Get raw char* of string-value.
Value const * findString(const String &key) const
static constexpr double maxUInt64AsDouble
std::vector< String > Members
const_iterator end() const
bool operator<=(const Value &other) const
String getComment(CommentPlacement placement) const
Include delimiters and embedded newlines.
bool operator>(const Value &other) const
String toStyledString() 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
void setOffsetLimit(ptrdiff_t limit)
bool removeIndex(ArrayIndex index, Value *removed)
Remove the indexed array element.
Value const * findArray(const String &key) const
bool hasComment(CommentPlacement placement) const
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 & operator[](ArrayIndex index)
Value & append(const Value &value)
Append value to array at the end.
Value const * findBool(const String &key) const
bool operator!=(const Value &other) const
Value const * findValue(const String &key) const
Calls find and only returns a valid pointer if the type is found.
Value const * findInt64(const String &key) const
void removeMember(const char *key)
Remove and return the named member.
void setOffsetStart(ptrdiff_t start)
Value const * findNull(const String &key) const
Value const * findUInt(const String &key) const
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.
Value const * findInt(const String &key) const
static const Value & nullRef
LargestInt asLargestInt() const
void copyPayload(const Value &other)
copy values but leave comments and source offsets in place.
Value const * findIntegral(const String &key) const
static constexpr Int maxInt
Maximum signed int value that can be stored in a Json::Value.
Value const * findNumeric(const String &key) const
bool isValidIndex(ArrayIndex index) const
Return true if index < size().
Value const * findUInt64(const String &key) const
LargestUInt asLargestUInt() const
Value const * findObject(const String &key) 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
bool isConvertibleTo(ValueType other) const
static Value const & nullSingleton()
ptrdiff_t getOffsetStart() const
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.
#define JSON_API
If defined, indicates that the source file is amalgamated to prevent private header inclusion.
int msvc_pre1900_c99_snprintf(char *outBuf, size_t size, const char *format,...)
#define JSON_ASSERT_UNREACHABLE
static int msvc_pre1900_c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
JSON (JavaScript Object Notation).
static char * duplicateStringValue(const char *value, size_t length)
Duplicates the specified string value.
static bool IsIntegral(double d)
static void releaseStringValue(char *value, unsigned)
static void releasePrefixedStringValue(char *value)
Free the string duplicated by duplicateStringValue()/duplicateAndPrefixStringValue().
String writeString(StreamWriter::Factory const &factory, Value const &root)
Write into stringstream, then return string, for convenience.
@ commentBefore
a comment placed on the line before a value
@ numberOfCommentPlacement
root value)
String valueToString(Int value)
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
static void decodePrefixedString(bool isPrefixed, char const *prefixed, unsigned *length, char const **value)
std::basic_string< char, std::char_traits< char >, Allocator< char > > String
static std::unique_ptr< T > cloneUnique(const std::unique_ptr< T > &p)
static char * duplicateAndPrefixStringValue(const char *value, unsigned int length)
static bool InRange(double d, T min, U max)