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()));
444#ifdef JSONCPP_HAS_STRING_VIEW
448 value.data(),
static_cast<unsigned>(value.length()));
454 value_.string_ =
const_cast<char*
>(value.
c_str());
459 value_.bool_ = value;
478 Value(other).swap(*
this);
488 std::swap(bits_, other.bits_);
489 std::swap(value_, other.value_);
499 std::swap(comments_, other.comments_);
500 std::swap(start_, other.start_);
501 std::swap(limit_, other.limit_);
510 return static_cast<ValueType>(bits_.value_type_);
522 int typeDelta =
type() - other.
type();
524 return typeDelta < 0;
529 return value_.int_ < other.value_.int_;
531 return value_.uint_ < other.value_.uint_;
533 return value_.real_ < other.value_.real_;
535 return value_.bool_ < other.value_.bool_;
537 if ((value_.string_ ==
nullptr) || (other.value_.string_ ==
nullptr)) {
538 return other.value_.string_ !=
nullptr;
542 char const* this_str;
543 char const* other_str;
548 unsigned min_len = std::min<unsigned>(this_len, other_len);
550 int comp = memcmp(this_str, other_str, min_len);
555 return (this_len < other_len);
559 auto thisSize = value_.map_->size();
560 auto otherSize = other.value_.map_->size();
561 if (thisSize != otherSize)
562 return thisSize < otherSize;
563 return (*value_.map_) < (*other.value_.map_);
584 return value_.int_ == other.value_.int_;
586 return value_.uint_ == other.value_.uint_;
588 return value_.real_ == other.value_.real_;
590 return value_.bool_ == other.value_.bool_;
592 if ((value_.string_ ==
nullptr) || (other.value_.string_ ==
nullptr)) {
593 return (value_.string_ == other.value_.string_);
597 char const* this_str;
598 char const* other_str;
603 if (this_len != other_len)
606 int comp = memcmp(this_str, other_str, this_len);
611 return value_.map_->size() == other.value_.map_->size() &&
612 (*value_.map_) == (*other.value_.map_);
623 "in Json::Value::asCString(): requires stringValue");
624 if (value_.string_ ==
nullptr)
627 char const* this_str;
633#if JSONCPP_USE_SECURE_MEMORY
634unsigned Value::getCStringLength()
const {
636 "in Json::Value::asCString(): requires stringValue");
637 if (value_.string_ == 0)
640 char const* this_str;
650 if (value_.string_ ==
nullptr)
659#ifdef JSONCPP_HAS_STRING_VIEW
663 if (value_.string_ ==
nullptr)
669 *str = std::string_view(begin, length);
679 if (value_.string_ ==
nullptr)
682 char const* this_str;
685 return String(this_str, this_len);
688 return value_.bool_ ?
"true" :
"false";
704 return Int(value_.int_);
707 return Int(value_.uint_);
710 "double out of Int range");
711 return Int(value_.real_);
715 return value_.bool_ ? 1 : 0;
726 return UInt(value_.int_);
729 return UInt(value_.uint_);
732 "double out of UInt range");
733 return UInt(value_.real_);
737 return value_.bool_ ? 1 : 0;
744#if defined(JSON_HAS_INT64)
749 return Int64(value_.int_);
752 return Int64(value_.uint_);
758 "Double value is minInt64, precise value cannot be determined");
760 "double out of Int64 range");
761 return Int64(value_.real_);
765 return value_.bool_ ? 1 : 0;
776 return UInt64(value_.int_);
778 return UInt64(value_.uint_);
781 "double out of UInt64 range");
782 return UInt64(value_.real_);
786 return value_.bool_ ? 1 : 0;
795#if defined(JSON_NO_INT64)
803#if defined(JSON_NO_INT64)
813 return static_cast<double>(value_.int_);
815#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
816 return static_cast<double>(value_.uint_);
818 return integerToDouble(value_.uint_);
825 return value_.bool_ ? 1.0 : 0.0;
835 return static_cast<float>(value_.int_);
837#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
838 return static_cast<float>(value_.uint_);
841 return static_cast<float>(integerToDouble(value_.uint_));
844 return static_cast<float>(value_.real_);
848 return value_.bool_ ? 1.0F : 0.0F;
862 return value_.int_ != 0;
864 return value_.uint_ != 0;
867 const auto value_classification = std::fpclassify(value_.real_);
868 return value_classification != FP_ZERO && value_classification != FP_NAN;
920 if (!value_.map_->empty()) {
921 ObjectValues::const_iterator itLast = value_.map_->end();
923 return (*itLast).first.index() + 1;
939Value::operator bool()
const {
return !
isNull(); }
944 "in Json::Value::clear(): requires complex value");
950 value_.map_->clear();
959 "in Json::Value::resize(): requires arrayValue");
965 else if (newSize > oldSize)
966 for (
ArrayIndex i = oldSize; i < newSize; ++i)
969 for (
ArrayIndex index = newSize; index < oldSize; ++index) {
970 value_.map_->erase(index);
979 "in Json::Value::operator[](ArrayIndex): requires arrayValue");
983 auto it = value_.map_->lower_bound(key);
984 if (it != value_.map_->end() && (*it).first == key)
988 it = value_.map_->insert(it, defaultValue);
995 "in Json::Value::operator[](int index): index cannot be negative");
1002 "in Json::Value::operator[](ArrayIndex)const: requires arrayValue");
1005 CZString key(index);
1006 ObjectValues::const_iterator it = value_.map_->find(key);
1007 if (it == value_.map_->end())
1009 return (*it).second;
1015 "in Json::Value::operator[](int index) const: index cannot be negative");
1019void Value::initBasic(
ValueType type,
bool allocated) {
1021 setIsAllocated(allocated);
1022 comments_ = Comments{};
1027void Value::dupPayload(
const Value& other) {
1028 setType(other.type());
1029 setIsAllocated(
false);
1036 value_ = other.value_;
1039 if (other.value_.string_ && other.isAllocated()) {
1045 setIsAllocated(
true);
1047 value_.string_ = other.value_.string_;
1052 value_.map_ =
new ObjectValues(*other.value_.map_);
1059void Value::releasePayload() {
1080void Value::dupMeta(
const Value& other) {
1081 comments_ = other.comments_;
1082 start_ = other.start_;
1083 limit_ = other.limit_;
1089Value& Value::resolveReference(
const char* key) {
1091 type() == nullValue || type() == objectValue,
1092 "in Json::Value::resolveReference(): requires objectValue");
1093 if (type() == nullValue)
1094 *
this = Value(objectValue);
1095 CZString actualKey(key,
static_cast<unsigned>(strlen(key)),
1096 CZString::noDuplication);
1097 auto it = value_.map_->lower_bound(actualKey);
1098 if (it != value_.map_->end() && (*it).first == actualKey)
1099 return (*it).second;
1101 ObjectValues::value_type defaultValue(actualKey, nullSingleton());
1102 it = value_.map_->insert(it, defaultValue);
1103 Value& value = (*it).second;
1108Value& Value::resolveReference(
char const* key,
char const* end) {
1110 type() == nullValue || type() == objectValue,
1111 "in Json::Value::resolveReference(key, end): requires objectValue");
1112 if (type() == nullValue)
1113 *
this = Value(objectValue);
1114 CZString actualKey(key,
static_cast<unsigned>(end - key),
1115 CZString::duplicateOnCopy);
1116 auto it = value_.map_->lower_bound(actualKey);
1117 if (it != value_.map_->end() && (*it).first == actualKey)
1118 return (*it).second;
1120 ObjectValues::value_type defaultValue(actualKey, nullSingleton());
1121 it = value_.map_->insert(it, defaultValue);
1122 Value& value = (*it).second;
1127 const Value* value = &((*this)[index]);
1135 "in Json::Value::find(begin, end): requires "
1136 "objectValue or nullValue");
1139 CZString actualKey(
begin,
static_cast<unsigned>(
end -
begin),
1140 CZString::noDuplication);
1141 ObjectValues::const_iterator it = value_.map_->find(actualKey);
1142 if (it == value_.map_->end())
1144 return &(*it).second;
1147 return find(key.data(), key.data() + key.length());
1189 "in Json::Value::demand(begin, end): requires "
1190 "objectValue or nullValue");
1191 return &resolveReference(
begin,
end);
1193#ifdef JSONCPP_HAS_STRING_VIEW
1195 Value const* found = find(key.data(), key.data() + key.length());
1197 return nullSingleton();
1200Value& Value::operator[](std::string_view key) {
1201 return resolveReference(key.data(), key.data() + key.length());
1205 Value const* found =
find(key, key + strlen(key));
1218 return resolveReference(key, key + strlen(key));
1222 return resolveReference(key.data(), key.data() + key.length());
1227 return resolveReference(key.
c_str());
1234 "in Json::Value::append: requires arrayValue");
1238 return this->value_.map_->emplace(
size(), std::move(value)).first->second;
1247 "in Json::Value::insert: requires arrayValue");
1249 if (index > length) {
1252 for (
ArrayIndex i = length; i > index; i--) {
1253 (*this)[i] = std::move((*
this)[i - 1]);
1255 (*this)[index] = std::move(newValue);
1260 Value const& defaultValue)
const {
1262 return !found ? defaultValue : *found;
1264#ifdef JSONCPP_HAS_STRING_VIEW
1266 return get(key.data(), key.data() + key.length(), defaultValue);
1270 return get(key, key + strlen(key), defaultValue);
1273 return get(key.data(), key.data() + key.length(), defaultValue);
1281 CZString actualKey(
begin,
static_cast<unsigned>(
end -
begin),
1282 CZString::noDuplication);
1283 auto it = value_.map_->find(actualKey);
1284 if (it == value_.map_->end())
1287 *removed = std::move(it->second);
1288 value_.map_->erase(it);
1291#ifdef JSONCPP_HAS_STRING_VIEW
1293 return removeMember(key.data(), key.data() + key.length(), removed);
1300 return removeMember(key.data(), key.data() + key.length(), removed);
1304#ifdef JSONCPP_HAS_STRING_VIEW
1307 "in Json::Value::removeMember(): requires objectValue");
1311 CZString actualKey(key.data(),
unsigned(key.length()),
1312 CZString::noDuplication);
1313 value_.map_->erase(actualKey);
1318 "in Json::Value::removeMember(): requires objectValue");
1322 CZString actualKey(key,
unsigned(strlen(key)), CZString::noDuplication);
1323 value_.map_->erase(actualKey);
1332 CZString key(index);
1333 auto it = value_.map_->find(key);
1334 if (it == value_.map_->end()) {
1338 *removed = std::move(it->second);
1341 for (
ArrayIndex i = index; i < (oldSize - 1); ++i) {
1343 (*value_.map_)[keey] = (*
this)[i + 1];
1346 CZString keyLast(oldSize - 1);
1347 auto itLast = value_.map_->find(keyLast);
1348 value_.map_->erase(itLast);
1354 return nullptr != value;
1356#ifdef JSONCPP_HAS_STRING_VIEW
1358 return isMember(key.data(), key.data() + key.length());
1362 return isMember(key, key + strlen(key));
1365 return isMember(key.data(), key.data() + key.length());
1372 "in Json::Value::getMemberNames(), value must be objectValue");
1376 members.reserve(value_.map_->size());
1377 ObjectValues::const_iterator it = value_.map_->begin();
1378 ObjectValues::const_iterator itEnd = value_.map_->end();
1379 for (; it != itEnd; ++it) {
1380 members.push_back(
String((*it).first.data(), (*it).first.length()));
1386 double integral_part;
1387 return modf(d, &integral_part) == 0.0;
1397#if defined(JSON_HAS_INT64)
1405 return value_.real_ >=
minInt && value_.real_ <=
maxInt &&
1416#if defined(JSON_HAS_INT64)
1419 return value_.int_ >= 0;
1422#if defined(JSON_HAS_INT64)
1423 return value_.uint_ <=
maxUInt;
1428 return value_.real_ >= 0 && value_.real_ <=
maxUInt &&
1437#if defined(JSON_HAS_INT64)
1451 return value_.real_ > double(
minInt64) && value_.real_ < double(
maxInt64) &&
1461#if defined(JSON_HAS_INT64)
1464 return value_.int_ >= 0;
1486#if defined(JSON_HAS_INT64)
1494 return value_.real_ > double(
minInt64) &&
1518Value::Comments::Comments(
const Comments& that)
1521Value::Comments::Comments(Comments&& that) noexcept
1522 : ptr_{std::move(that.ptr_)} {}
1524Value::Comments& Value::Comments::operator=(
const Comments& that) {
1529Value::Comments& Value::Comments::operator=(Comments&& that)
noexcept {
1530 ptr_ = std::move(that.ptr_);
1535 return ptr_ && !(*ptr_)[slot].empty();
1541 return (*ptr_)[slot];
1548 ptr_ = std::unique_ptr<Array>(
new Array());
1549 (*ptr_)[slot] = std::move(comment);
1553 if (!comment.empty() && (comment.back() ==
'\n')) {
1558 comment.empty() || comment[0] ==
'/',
1559 "in Json::Value::setComment(): Comments must start with /");
1560 comments_.set(
placement, std::move(comment));
1620 return iterator(value_.map_->begin());
1633 return iterator(value_.map_->end());
1647 : index_(index), kind_(kindIndex) {}
1669void Path::makePath(
const String& path,
const InArgs& in) {
1670 const char* current = path.c_str();
1671 const char* end = current + path.length();
1672 auto itInArg = in.begin();
1673 while (current != end) {
1674 if (*current ==
'[') {
1676 if (*current ==
'%')
1677 addPathInArg(path, in, itInArg, PathArgument::kindIndex);
1680 for (; current != end && *current >=
'0' && *current <=
'9'; ++current)
1681 index = index * 10 +
ArrayIndex(*current -
'0');
1682 args_.push_back(index);
1684 if (current == end || *++current !=
']')
1685 invalidPath(path,
int(current - path.c_str()));
1686 }
else if (*current ==
'%') {
1687 addPathInArg(path, in, itInArg, PathArgument::kindKey);
1689 }
else if (*current ==
'.' || *current ==
']') {
1692 const char* beginName = current;
1693 while (current != end && !strchr(
"[.", *current))
1695 args_.push_back(
String(beginName, current));
1700void Path::addPathInArg(
const String& ,
const InArgs& in,
1701 InArgs::const_iterator& itInArg,
1702 PathArgument::Kind kind) {
1703 if (itInArg == in.end()) {
1705 }
else if ((*itInArg)->kind_ != kind) {
1708 args_.push_back(**itInArg++);
1712void Path::invalidPath(
const String& ,
int ) {
1717 const Value* node = &root;
1718 for (
const auto& arg : args_) {
1719 if (arg.kind_ == PathArgument::kindIndex) {
1724 node = &((*node)[arg.index_]);
1725 }
else if (arg.kind_ == PathArgument::kindKey) {
1730 node = &((*node)[arg.key_]);
1742 const Value* node = &root;
1743 for (
const auto& arg : args_) {
1744 if (arg.kind_ == PathArgument::kindIndex) {
1746 return defaultValue;
1747 node = &((*node)[arg.index_]);
1748 }
else if (arg.kind_ == PathArgument::kindKey) {
1750 return defaultValue;
1751 node = &((*node)[arg.key_]);
1753 return defaultValue;
1760 Value* node = &root;
1761 for (
const auto& arg : args_) {
1762 if (arg.kind_ == PathArgument::kindIndex) {
1766 node = &((*node)[arg.index_]);
1767 }
else if (arg.kind_ == PathArgument::kindKey) {
1771 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)