6 #if !defined(JSON_IS_AMALGAMATION) 10 #endif // if !defined(JSON_IS_AMALGAMATION) 21 #if defined(_MSC_VER) && _MSC_VER < 1900 24 const char* format, va_list ap) {
27 count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
29 count = _vscprintf(format, ap);
34 const char* format, ...) {
45 #pragma warning(disable : 4702) 48 #define JSON_ASSERT_UNREACHABLE assert(false) 52 static std::unique_ptr<T>
cloneUnique(
const std::unique_ptr<T>& p) {
55 r = std::unique_ptr<T>(
new T(*p));
63 #if defined(__ARMEL__) 64 #define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) 66 #define ALIGNAS(byte_alignment) 71 static Value const nullStatic;
85 #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) 86 template <
typename T,
typename U>
87 static inline bool InRange(
double d, T min, U max) {
90 return d >=
static_cast<double>(min) && d <= static_cast<double>(max);
92 #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) 93 static inline double integerToDouble(
Json::UInt64 value) {
94 return static_cast<double>(
Int64(value / 2)) * 2.0 +
95 static_cast<double>(
Int64(value & 1));
98 template <
typename T>
static inline double integerToDouble(T value) {
99 return static_cast<double>(value);
102 template <
typename T,
typename U>
103 static inline bool InRange(
double d, T min, U max) {
104 return d >= integerToDouble(min) && d <= integerToDouble(max);
106 #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) 121 auto newString =
static_cast<char*
>(malloc(length + 1));
122 if (newString ==
nullptr) {
123 throwRuntimeError(
"in Json::Value::duplicateStringValue(): " 124 "Failed to allocate string value buffer");
126 memcpy(newString, value, length);
127 newString[length] = 0;
134 unsigned int length) {
138 sizeof(
unsigned) - 1U,
139 "in Json::Value::duplicateAndPrefixStringValue(): " 140 "length too big for prefixing");
141 size_t actualLength =
sizeof(length) + length + 1;
142 auto newString =
static_cast<char*
>(malloc(actualLength));
143 if (newString ==
nullptr) {
144 throwRuntimeError(
"in Json::Value::duplicateAndPrefixStringValue(): " 145 "Failed to allocate string value buffer");
147 *
reinterpret_cast<unsigned*
>(newString) = length;
148 memcpy(newString +
sizeof(
unsigned), value, length);
149 newString[actualLength - 1U] =
154 unsigned* length,
char const** value) {
156 *length =
static_cast<unsigned>(strlen(prefixed));
159 *length = *
reinterpret_cast<unsigned const*
>(prefixed);
160 *value = prefixed +
sizeof(unsigned);
166 #if JSONCPP_USING_SECURE_MEMORY 169 char const* valueDecoded;
171 size_t const size =
sizeof(unsigned) + length + 1U;
172 memset(value, 0, size);
177 size_t size = (length == 0) ? strlen(value) : length;
178 memset(value, 0, size);
181 #else // !JSONCPP_USING_SECURE_MEMORY 184 #endif // JSONCPP_USING_SECURE_MEMORY 195 #if !defined(JSON_IS_AMALGAMATION) 198 #endif // if !defined(JSON_IS_AMALGAMATION) 202 #if JSON_USE_EXCEPTION 214 #else // !JSON_USE_EXCEPTION 216 std::cerr << msg << std::endl;
220 std::cerr << msg << std::endl;
236 Value::CZString::CZString(
ArrayIndex index) : cstr_(
nullptr), index_(index) {}
238 Value::CZString::CZString(
char const* str,
unsigned length,
239 DuplicationPolicy allocate)
242 storage_.policy_ = allocate & 0x3;
243 storage_.length_ = length & 0x3FFFFFFF;
246 Value::CZString::CZString(
const CZString& other) {
247 cstr_ = (other.storage_.policy_ != noDuplication && other.cstr_ !=
nullptr 251 static_cast<unsigned>(
253 ? (
static_cast<DuplicationPolicy
>(other.storage_.policy_) ==
257 :
static_cast<DuplicationPolicy
>(other.storage_.policy_)) &
259 storage_.length_ = other.storage_.length_;
262 Value::CZString::CZString(CZString&& other) noexcept
263 : cstr_(other.cstr_), index_(other.index_) {
264 other.cstr_ =
nullptr;
267 Value::CZString::~CZString() {
268 if (cstr_ && storage_.policy_ == duplicate) {
270 storage_.length_ + 1U);
282 Value::CZString& Value::CZString::operator=(
const CZString& other) {
284 index_ = other.index_;
288 Value::CZString& Value::CZString::operator=(CZString&& other) noexcept {
290 index_ = other.index_;
291 other.cstr_ =
nullptr;
295 bool Value::CZString::operator<(
const CZString& other)
const {
297 return index_ < other.index_;
300 unsigned this_len = this->storage_.length_;
301 unsigned other_len = other.storage_.length_;
302 unsigned min_len = std::min<unsigned>(this_len, other_len);
304 int comp = memcmp(this->cstr_, other.cstr_, min_len);
309 return (this_len < other_len);
314 return index_ == other.index_;
317 unsigned this_len = this->storage_.length_;
318 unsigned other_len = other.storage_.length_;
319 if (this_len != other_len)
322 int comp = memcmp(this->cstr_, other.cstr_, this_len);
326 ArrayIndex Value::CZString::index()
const {
return index_; }
329 const char* Value::CZString::data()
const {
return cstr_; }
330 unsigned Value::CZString::length()
const {
return storage_.length_; }
331 bool Value::CZString::isStaticString()
const {
332 return storage_.policy_ == noDuplication;
348 static char const emptyString[] =
"";
362 value_.string_ =
const_cast<char*
>(
static_cast<char const*
>(emptyString));
366 value_.map_ =
new ObjectValues();
369 value_.bool_ =
false;
383 value_.uint_ = value;
385 #if defined(JSON_HAS_INT64) 392 value_.uint_ = value;
394 #endif // defined(JSON_HAS_INT64) 398 value_.real_ = value;
404 "Null Value Passed to Value Constructor");
406 value, static_cast<unsigned>(strlen(value)));
418 value.data(),
static_cast<unsigned>(value.length()));
423 value_.string_ =
const_cast<char*
>(value.
c_str());
428 value_.bool_ = value;
479 return static_cast<ValueType>(bits_.value_type_);
491 int typeDelta = type() - other.
type();
493 return typeDelta < 0;
498 return value_.int_ < other.value_.int_;
500 return value_.uint_ < other.value_.uint_;
502 return value_.real_ < other.value_.real_;
504 return value_.bool_ < other.value_.bool_;
506 if ((value_.string_ ==
nullptr) || (other.value_.string_ ==
nullptr)) {
507 return other.value_.string_ !=
nullptr;
511 char const* this_str;
512 char const* other_str;
517 unsigned min_len = std::min<unsigned>(this_len, other_len);
519 int comp = memcmp(this_str, other_str, min_len);
524 return (this_len < other_len);
528 auto thisSize = value_.map_->size();
529 auto otherSize = other.value_.map_->size();
530 if (thisSize != otherSize)
531 return thisSize < otherSize;
532 return (*value_.map_) < (*other.value_.map_);
547 if (type() != other.
type())
553 return value_.int_ == other.value_.int_;
555 return value_.uint_ == other.value_.uint_;
557 return value_.real_ == other.value_.real_;
559 return value_.bool_ == other.value_.bool_;
561 if ((value_.string_ ==
nullptr) || (other.value_.string_ ==
nullptr)) {
562 return (value_.string_ == other.value_.string_);
566 char const* this_str;
567 char const* other_str;
572 if (this_len != other_len)
575 int comp = memcmp(this_str, other_str, this_len);
580 return value_.map_->size() == other.value_.map_->size() &&
581 (*value_.map_) == (*other.value_.map_);
592 "in Json::Value::asCString(): requires stringValue");
593 if (value_.string_ ==
nullptr)
596 char const* this_str;
602 #if JSONCPP_USING_SECURE_MEMORY 603 unsigned Value::getCStringLength()
const {
605 "in Json::Value::asCString(): requires stringValue");
606 if (value_.string_ == 0)
609 char const* this_str;
619 if (value_.string_ ==
nullptr)
624 *end = *begin + length;
633 if (value_.string_ ==
nullptr)
636 char const* this_str;
639 return String(this_str, this_len);
642 return value_.bool_ ?
"true" :
"false";
658 return Int(value_.int_);
661 return Int(value_.uint_);
664 "double out of Int range");
665 return Int(value_.real_);
669 return value_.bool_ ? 1 : 0;
680 return UInt(value_.int_);
683 return UInt(value_.uint_);
686 "double out of UInt range");
687 return UInt(value_.real_);
691 return value_.bool_ ? 1 : 0;
698 #if defined(JSON_HAS_INT64) 703 return Int64(value_.int_);
706 return Int64(value_.uint_);
709 "double out of Int64 range");
710 return Int64(value_.real_);
714 return value_.bool_ ? 1 : 0;
725 return UInt64(value_.int_);
727 return UInt64(value_.uint_);
730 "double out of UInt64 range");
731 return UInt64(value_.real_);
735 return value_.bool_ ? 1 : 0;
741 #endif // if defined(JSON_HAS_INT64) 744 #if defined(JSON_NO_INT64) 752 #if defined(JSON_NO_INT64) 762 return static_cast<double>(value_.int_);
764 #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) 765 return static_cast<double>(value_.uint_);
766 #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) 767 return integerToDouble(value_.uint_);
768 #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) 774 return value_.bool_ ? 1.0 : 0.0;
784 return static_cast<float>(value_.int_);
786 #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) 787 return static_cast<float>(value_.uint_);
788 #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) 790 return static_cast<float>(integerToDouble(value_.uint_));
791 #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) 793 return static_cast<float>(value_.real_);
797 return value_.bool_ ? 1.0F : 0.0F;
811 return value_.int_ != 0;
813 return value_.uint_ != 0;
816 const auto value_classification = std::fpclassify(value_.real_);
817 return value_classification != FP_ZERO && value_classification != FP_NAN;
828 return (isNumeric() && asDouble() == 0.0) ||
831 (type() ==
arrayValue && value_.map_->empty()) ||
869 if (!value_.map_->empty()) {
870 ObjectValues::const_iterator itLast = value_.map_->end();
872 return (*itLast).first.index() + 1;
883 if (isNull() || isArray() || isObject())
888 Value::operator bool()
const {
return !isNull(); }
893 "in Json::Value::clear(): requires complex value");
899 value_.map_->clear();
908 "in Json::Value::resize(): requires arrayValue");
914 else if (newSize > oldSize)
915 for (
ArrayIndex i = oldSize; i < newSize; ++i)
918 for (
ArrayIndex index = newSize; index < oldSize; ++index) {
919 value_.map_->erase(index);
928 "in Json::Value::operator[](ArrayIndex): requires arrayValue");
932 auto it = value_.map_->lower_bound(key);
933 if (it != value_.map_->end() && (*it).first == key)
936 ObjectValues::value_type defaultValue(key, nullSingleton());
937 it = value_.map_->insert(it, defaultValue);
944 "in Json::Value::operator[](int index): index cannot be negative");
951 "in Json::Value::operator[](ArrayIndex)const: requires arrayValue");
953 return nullSingleton();
955 ObjectValues::const_iterator it = value_.map_->find(key);
956 if (it == value_.map_->end())
957 return nullSingleton();
964 "in Json::Value::operator[](int index) const: index cannot be negative");
968 void Value::initBasic(
ValueType type,
bool allocated) {
970 setIsAllocated(allocated);
971 comments_ = Comments{};
976 void Value::dupPayload(
const Value& other) {
977 setType(other.
type());
978 setIsAllocated(
false);
985 value_ = other.value_;
988 if (other.value_.string_ && other.isAllocated()) {
994 setIsAllocated(
true);
996 value_.string_ = other.value_.string_;
1001 value_.map_ =
new ObjectValues(*other.value_.map_);
1008 void Value::releasePayload() {
1029 void Value::dupMeta(
const Value& other) {
1030 comments_ = other.comments_;
1031 start_ = other.start_;
1032 limit_ = other.limit_;
1038 Value& Value::resolveReference(
const char* key) {
1041 "in Json::Value::resolveReference(): requires objectValue");
1044 CZString actualKey(key, static_cast<unsigned>(strlen(key)),
1045 CZString::noDuplication);
1046 auto it = value_.map_->lower_bound(actualKey);
1047 if (it != value_.map_->end() && (*it).first == actualKey)
1048 return (*it).second;
1050 ObjectValues::value_type defaultValue(actualKey, nullSingleton());
1051 it = value_.map_->insert(it, defaultValue);
1052 Value& value = (*it).second;
1057 Value& Value::resolveReference(
char const* key,
char const* end) {
1060 "in Json::Value::resolveReference(key, end): requires objectValue");
1063 CZString actualKey(key, static_cast<unsigned>(end - key),
1064 CZString::duplicateOnCopy);
1065 auto it = value_.map_->lower_bound(actualKey);
1066 if (it != value_.map_->end() && (*it).first == actualKey)
1067 return (*it).second;
1069 ObjectValues::value_type defaultValue(actualKey, nullSingleton());
1070 it = value_.map_->insert(it, defaultValue);
1071 Value& value = (*it).second;
1076 const Value* value = &((*this)[index]);
1077 return value == &nullSingleton() ? defaultValue : *value;
1084 "in Json::Value::find(begin, end): requires " 1085 "objectValue or nullValue");
1088 CZString actualKey(begin, static_cast<unsigned>(end - begin),
1089 CZString::noDuplication);
1090 ObjectValues::const_iterator it = value_.map_->find(actualKey);
1091 if (it == value_.map_->end())
1093 return &(*it).second;
1097 "in Json::Value::demand(begin, end): requires " 1098 "objectValue or nullValue");
1099 return &resolveReference(begin, end);
1102 Value const* found = find(key, key + strlen(key));
1104 return nullSingleton();
1108 Value const* found = find(key.data(), key.data() + key.length());
1110 return nullSingleton();
1115 return resolveReference(key, key + strlen(key));
1119 return resolveReference(key.data(), key.data() + key.length());
1123 return resolveReference(key.
c_str());
1130 "in Json::Value::append: requires arrayValue");
1134 return this->value_.map_->emplace(size(), std::move(value)).first->second;
1138 return insert(index,
Value(newValue));
1143 "in Json::Value::insert: requires arrayValue");
1145 if (index > length) {
1148 for (
ArrayIndex i = length; i > index; i--) {
1149 (*this)[i] = std::move((*
this)[i - 1]);
1151 (*this)[index] = std::move(newValue);
1156 Value const& defaultValue)
const {
1157 Value const* found = find(begin, end);
1158 return !found ? defaultValue : *found;
1161 return get(key, key + strlen(key), defaultValue);
1164 return get(key.data(), key.data() + key.length(), defaultValue);
1171 CZString actualKey(begin, static_cast<unsigned>(end - begin),
1172 CZString::noDuplication);
1173 auto it = value_.map_->find(actualKey);
1174 if (it == value_.map_->end())
1177 *removed = std::move(it->second);
1178 value_.map_->erase(it);
1182 return removeMember(key, key + strlen(key), removed);
1185 return removeMember(key.data(), key.data() + key.length(), removed);
1189 "in Json::Value::removeMember(): requires objectValue");
1193 CZString actualKey(key,
unsigned(strlen(key)), CZString::noDuplication);
1194 value_.map_->erase(actualKey);
1202 CZString key(index);
1203 auto it = value_.map_->find(key);
1204 if (it == value_.map_->end()) {
1208 *removed = it->second;
1211 for (
ArrayIndex i = index; i < (oldSize - 1); ++i) {
1213 (*value_.map_)[keey] = (*
this)[i + 1];
1216 CZString keyLast(oldSize - 1);
1217 auto itLast = value_.map_->find(keyLast);
1218 value_.map_->erase(itLast);
1223 Value const* value = find(begin, end);
1224 return nullptr != value;
1227 return isMember(key, key + strlen(key));
1230 return isMember(key.data(), key.data() + key.length());
1236 "in Json::Value::getMemberNames(), value must be objectValue");
1240 members.reserve(value_.map_->size());
1241 ObjectValues::const_iterator it = value_.map_->begin();
1242 ObjectValues::const_iterator itEnd = value_.map_->end();
1243 for (; it != itEnd; ++it) {
1244 members.push_back(
String((*it).first.data(), (*it).first.length()));
1250 double integral_part;
1251 return modf(d, &integral_part) == 0.0;
1261 #if defined(JSON_HAS_INT64) 1262 return value_.int_ >= minInt && value_.int_ <= maxInt;
1267 return value_.uint_ <=
UInt(maxInt);
1269 return value_.real_ >= minInt && value_.real_ <= maxInt &&
1280 #if defined(JSON_HAS_INT64) 1283 return value_.int_ >= 0;
1286 #if defined(JSON_HAS_INT64) 1287 return value_.uint_ <= maxUInt;
1292 return value_.real_ >= 0 && value_.real_ <= maxUInt &&
1301 #if defined(JSON_HAS_INT64) 1306 return value_.uint_ <=
UInt64(maxInt64);
1311 return value_.real_ >= double(minInt64) &&
1312 value_.real_ < double(maxInt64) &&
IsIntegral(value_.real_);
1316 #endif // JSON_HAS_INT64 1321 #if defined(JSON_HAS_INT64) 1324 return value_.int_ >= 0;
1331 return value_.real_ >= 0 && value_.real_ < maxUInt64AsDouble &&
1336 #endif // JSON_HAS_INT64 1346 #if defined(JSON_HAS_INT64) 1350 return value_.real_ >= double(minInt64) &&
1351 value_.real_ < maxUInt64AsDouble &&
IsIntegral(value_.real_);
1353 return value_.real_ >= minInt && value_.real_ <= maxUInt &&
1355 #endif // JSON_HAS_INT64 1374 Value::Comments::Comments(
const Comments& that)
1377 Value::Comments::Comments(Comments&& that) noexcept
1378 : ptr_{std::move(that.ptr_)} {}
1380 Value::Comments& Value::Comments::operator=(
const Comments& that) {
1385 Value::Comments& Value::Comments::operator=(Comments&& that) noexcept {
1386 ptr_ = std::move(that.ptr_);
1391 return ptr_ && !(*ptr_)[slot].empty();
1397 return (*ptr_)[slot];
1404 ptr_ = std::unique_ptr<Array>(
new Array());
1405 (*ptr_)[slot] = std::move(comment);
1409 if (!comment.empty() && (comment.back() ==
'\n')) {
1415 comment[0] ==
'\0' || comment[0] ==
'/',
1416 "in Json::Value::setComment(): Comments must start with /");
1417 comments_.set(placement, std::move(comment));
1421 return comments_.has(placement);
1425 return comments_.get(placement);
1477 return iterator(value_.map_->begin());
1490 return iterator(value_.map_->end());
1504 : index_(index), kind_(kindIndex) {}
1526 void Path::makePath(
const String& path,
const InArgs& in) {
1527 const char* current = path.c_str();
1528 const char* end = current + path.length();
1529 auto itInArg = in.begin();
1530 while (current != end) {
1531 if (*current ==
'[') {
1533 if (*current ==
'%')
1534 addPathInArg(path, in, itInArg, PathArgument::kindIndex);
1537 for (; current != end && *current >=
'0' && *current <=
'9'; ++current)
1538 index = index * 10 +
ArrayIndex(*current -
'0');
1539 args_.push_back(index);
1541 if (current == end || *++current !=
']')
1542 invalidPath(path,
int(current - path.c_str()));
1543 }
else if (*current ==
'%') {
1544 addPathInArg(path, in, itInArg, PathArgument::kindKey);
1546 }
else if (*current ==
'.' || *current ==
']') {
1549 const char* beginName = current;
1550 while (current != end && !strchr(
"[.", *current))
1552 args_.push_back(
String(beginName, current));
1557 void Path::addPathInArg(
const String& ,
const InArgs& in,
1558 InArgs::const_iterator& itInArg,
1559 PathArgument::Kind kind) {
1560 if (itInArg == in.end()) {
1562 }
else if ((*itInArg)->kind_ != kind) {
1565 args_.push_back(**itInArg++);
1569 void Path::invalidPath(
const String& ,
int ) {
1574 const Value* node = &root;
1575 for (
const auto& arg : args_) {
1576 if (arg.kind_ == PathArgument::kindIndex) {
1581 node = &((*node)[arg.index_]);
1582 }
else if (arg.kind_ == PathArgument::kindKey) {
1587 node = &((*node)[arg.key_]);
1599 const Value* node = &root;
1600 for (
const auto& arg : args_) {
1601 if (arg.kind_ == PathArgument::kindIndex) {
1603 return defaultValue;
1604 node = &((*node)[arg.index_]);
1605 }
else if (arg.kind_ == PathArgument::kindKey) {
1607 return defaultValue;
1608 node = &((*node)[arg.key_]);
1610 return defaultValue;
1617 Value* node = &root;
1618 for (
const auto& arg : args_) {
1619 if (arg.kind_ == PathArgument::kindIndex) {
1623 node = &((*node)[arg.index_]);
1624 }
else if (arg.kind_ == PathArgument::kindKey) {
1628 node = &((*node)[arg.key_]);
LogicError(String const &msg)
static bool IsIntegral(double d)
int compare(const Value &other) const
#define JSON_API
If defined, indicates that the source file is amalgamated to prevent private header inclusion...
Value const * find(char const *begin, char const *end) const
Most general and efficient version of isMember()const, get()const, and operator[]const.
Value & make(Value &root) const
Creates the "path" to access the specified node and returns a reference on the node.
LargestUInt asLargestUInt() const
~Exception() noexcept override
array value (ordered list)
String valueToString(Int value)
int msvc_pre1900_c99_snprintf(char *outBuf, size_t size, const char *format,...)
void copy(const Value &other)
copy everything.
Json::LargestUInt LargestUInt
#define JSON_ASSERT_MESSAGE(condition, message)
static Value const & nullSingleton()
bool empty() const
Return true if empty array, empty object, or null; otherwise, false.
Members getMemberNames() const
Return a list of the member names.
void setComment(const char *comment, size_t len, CommentPlacement placement)
Comments must be //... or /* ... */.
object value (collection of name/value pairs).
bool getString(char const **begin, char const **end) const
Get raw char* of string-value.
static std::unique_ptr< T > cloneUnique(const std::unique_ptr< T > &p)
void swapPayload(Value &other)
Swap values but leave comments and source offsets in place.
ptrdiff_t getOffsetStart() const
static constexpr Int maxInt
Maximum signed int value that can be stored in a Json::Value.
static const Value & null
Lightweight wrapper to tag static string.
#define JSON_ASSERT(condition)
It should not be possible for a maliciously designed file to cause an abort() or seg-fault, so these macros are used only for pre-condition violations and internal logic errors.
static const Value & nullRef
static void releaseStringValue(char *value, unsigned)
const iterator for object and array value.
String toStyledString() const
bool removeIndex(ArrayIndex index, Value *removed)
Remove the indexed array element.
Value(ValueType type=nullValue)
Create a default Value of the given type.
Experimental and untested: represents an element of the "path" to access a node.
static bool InRange(double d, T min, U max)
void resize(ArrayIndex newSize)
Resize the array to newSize elements.
static void decodePrefixedString(bool isPrefixed, char const *prefixed, unsigned *length, char const **value)
std::vector< String > Members
Value & operator[](ArrayIndex index)
Access an array element (zero based index).
ArrayIndex size() const
Number of values in array or object.
void swap(Value &a, Value &b)
const char * asCString() const
Embedded zeroes could cause you trouble!
bool operator==(const Value &other) const
LargestInt asLargestInt() const
bool operator>(const Value &other) const
String writeString(StreamWriter::Factory const &factory, Value const &root)
Write into stringstream, then return string, for convenience.
bool isValidIndex(ArrayIndex index) const
Return true if index < size().
bool operator>=(const Value &other) const
String asString() const
Embedded zeroes are possible.
JSON (JavaScript Object Notation).
void removeMember(const char *key)
Remove and return the named member.
bool operator==(const SecureAllocator< T > &, const SecureAllocator< U > &)
#define JSON_FAIL_MESSAGE(message)
String getComment(CommentPlacement placement) const
Include delimiters and embedded newlines.
void swap(Value &other)
Swap everything.
ptrdiff_t getOffsetLimit() const
const char * c_str() 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...
const_iterator begin() const
char const * what() const noexcept override
Value & append(const Value &value)
Append value to array at the end.
Value & operator=(const Value &other)
Json::LargestInt LargestInt
static char * duplicateAndPrefixStringValue(const char *value, unsigned int length)
#define JSON_ASSERT_UNREACHABLE
void setOffsetStart(ptrdiff_t start)
static char * duplicateStringValue(const char *value, size_t length)
Duplicates the specified string value.
Exceptions which the user cannot easily avoid.
bool hasComment(CommentPlacement placement) const
bool insert(ArrayIndex index, const Value &newValue)
Insert value in array at specific index.
void clear()
Remove all object members and array elements.
bool operator!=(const Value &other) const
Iterator for object and array value.
static void releasePrefixedStringValue(char *value)
Free the string duplicated by duplicateStringValue()/duplicateAndPrefixStringValue().
Value * demand(char const *begin, char const *end)
Most general and efficient version of object-mutators.
void setOffsetLimit(ptrdiff_t limit)
RuntimeError(String const &msg)
bool isMember(const char *key) const
Return true if the object has a member named key.
ValueType
Type of the value held by a Value object.
bool operator<=(const Value &other) const
const Value & resolve(const Value &root) const
bool isConvertibleTo(ValueType other) const
bool operator<(const Value &other) const
Compare payload only, not comments etc.
static int msvc_pre1900_c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
Json::ArrayIndex ArrayIndex
Path(const String &path, const PathArgument &a1=PathArgument(), const PathArgument &a2=PathArgument(), const PathArgument &a3=PathArgument(), const PathArgument &a4=PathArgument(), const PathArgument &a5=PathArgument())
void copyPayload(const Value &other)
copy values but leave comments and source offsets in place.
a comment placed on the line before a value
Build a StreamWriter implementation.
Base class for all exceptions we throw.
const_iterator end() const
std::basic_string< char, std::char_traits< char >, Allocator< char > > String