6#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) 
   52static std::unique_ptr<T> 
cloneUnique(
const std::unique_ptr<T>& p) {
 
   55    r = std::unique_ptr<T>(
new T(*p));
 
 
   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) 
   86template <
typename T, 
typename U>
 
   87static inline bool InRange(
double d, T min, U max) {
 
   90  return d >= 
static_cast<double>(min) && d <= 
static_cast<double>(max);
 
 
   93static inline double integerToDouble(
Json::UInt64 value) {
 
   94  return static_cast<double>(
Int64(value / 2)) * 2.0 +
 
   95         static_cast<double>(
Int64(value & 1));
 
   98template <
typename T> 
static inline double integerToDouble(T value) {
 
   99  return static_cast<double>(value);
 
  102template <
typename T, 
typename U>
 
  103static inline bool InRange(
double d, T min, U max) {
 
  104  return d >= integerToDouble(min) && d <= integerToDouble(max);
 
  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);
 
  195#if !defined(JSON_IS_AMALGAMATION) 
  202#if JSON_USE_EXCEPTION 
  205char const* 
Exception::what() const noexcept { 
return msg_.c_str(); }
 
  212  throw LogicError(msg);
 
  216  std::cerr << msg << std::endl;
 
  220  std::cerr << msg << std::endl;
 
  236Value::CZString::CZString(
ArrayIndex index) : cstr_(nullptr), index_(index) {}
 
  238Value::CZString::CZString(
char const* str, 
unsigned length,
 
  239                          DuplicationPolicy allocate)
 
  242  storage_.policy_ = allocate & 0x3;
 
  243  storage_.length_ = length & 0x3FFFFFFF;
 
  246Value::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_;
 
  262Value::CZString::CZString(CZString&& other) noexcept
 
  263    : cstr_(other.cstr_), index_(other.index_) {
 
  264  other.cstr_ = 
nullptr;
 
  267Value::CZString::~CZString() {
 
  268  if (cstr_ && storage_.policy_ == duplicate) {
 
  270                       storage_.length_ + 1U); 
 
  277void Value::CZString::swap(CZString& other) {
 
  278  std::swap(cstr_, other.cstr_);
 
  279  std::swap(index_, other.index_);
 
  282Value::CZString& Value::CZString::operator=(
const CZString& other) {
 
  284  index_ = other.index_;
 
  288Value::CZString& Value::CZString::operator=(CZString&& other) 
noexcept {
 
  290  index_ = other.index_;
 
  291  other.cstr_ = 
nullptr;
 
  295bool 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);
 
  312bool Value::CZString::operator==(
const CZString& other)
 const {
 
  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);
 
  326ArrayIndex Value::CZString::index()
 const { 
return index_; }
 
  329const char* Value::CZString::data()
 const { 
return cstr_; }
 
  330unsigned Value::CZString::length()
 const { 
return storage_.length_; }
 
  331bool 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;
 
 
  396Value::Value(
double value) {
 
  398  value_.real_ = value;
 
 
  401Value::Value(
const char* value) {
 
  404                      "Null Value Passed to Value Constructor");
 
  406      value, 
static_cast<unsigned>(strlen(value)));
 
 
  409Value::Value(
const char* begin, 
const char* end) {
 
 
  418      value.data(), 
static_cast<unsigned>(value.length()));
 
 
  423  value_.string_ = 
const_cast<char*
>(value.
c_str());
 
 
  426Value::Value(
bool value) {
 
  428  value_.bool_ = value;
 
 
  436Value::Value(
Value&& other) 
noexcept {
 
 
  456void Value::swapPayload(
Value& other) {
 
  457  std::swap(bits_, other.bits_);
 
  458  std::swap(value_, other.value_);
 
 
  461void Value::copyPayload(
const Value& other) {
 
 
  468  std::swap(comments_, other.comments_);
 
  469  std::swap(start_, other.start_);
 
  470  std::swap(limit_, other.limit_);
 
 
  473void Value::copy(
const Value& other) {
 
 
  479  return static_cast<ValueType>(bits_.value_type_);
 
 
  482int Value::compare(
const Value& other)
 const {
 
 
  490bool Value::operator<(
const Value& other)
 const {
 
  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_);
 
 
  540bool Value::operator<=(
const Value& other)
 const { 
return !(other < *
this); }
 
  542bool Value::operator>=(
const Value& other)
 const { 
return !(*
this < other); }
 
  544bool Value::operator>(
const Value& other)
 const { 
return other < *
this; }
 
  546bool Value::operator==(
const Value& other)
 const {
 
  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_);
 
 
  588bool Value::operator!=(
const Value& other)
 const { 
return !(*
this == other); }
 
  590const char* Value::asCString()
 const {
 
  592                      "in Json::Value::asCString(): requires stringValue");
 
  593  if (value_.string_ == 
nullptr)
 
  596  char const* this_str;
 
 
  602#if JSONCPP_USING_SECURE_MEMORY 
  603unsigned Value::getCStringLength()
 const {
 
  605                      "in Json::Value::asCString(): requires stringValue");
 
  606  if (value_.string_ == 0)
 
  609  char const* this_str;
 
  616bool Value::getString(
char const** begin, 
char const** end)
 const {
 
  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;
 
 
  744#if defined(JSON_NO_INT64) 
 
  752#if defined(JSON_NO_INT64) 
 
  759double Value::asDouble()
 const {
 
  762    return static_cast<double>(value_.int_);
 
  764#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) 
  765    return static_cast<double>(value_.uint_);
 
  767    return integerToDouble(value_.uint_);
 
  774    return value_.bool_ ? 1.0 : 0.0;
 
 
  781float Value::asFloat()
 const {
 
  784    return static_cast<float>(value_.int_);
 
  786#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) 
  787    return static_cast<float>(value_.uint_);
 
  790    return static_cast<float>(integerToDouble(value_.uint_));
 
  793    return static_cast<float>(value_.real_);
 
  797    return value_.bool_ ? 1.0F : 0.0F;
 
 
  804bool Value::asBool()
 const {
 
  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;
 
 
  882bool Value::empty()
 const {
 
  883  if (isNull() || isArray() || isObject())
 
 
  888Value::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);
 
 
  941Value& Value::operator[](
int index) {
 
  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();
 
 
  961const Value& Value::operator[](
int index)
 const {
 
  964      "in Json::Value::operator[](int index) const: index cannot be negative");
 
 
  968void Value::initBasic(
ValueType type, 
bool allocated) {
 
  970  setIsAllocated(allocated);
 
  971  comments_ = Comments{};
 
  976void 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_);
 
 1008void Value::releasePayload() {
 
 1029void Value::dupMeta(
const Value& other) {
 
 1030  comments_ = other.comments_;
 
 1031  start_ = other.start_;
 
 1032  limit_ = other.limit_;
 
 1038Value& Value::resolveReference(
const char* key) {
 
 1040      type() == nullValue || type() == objectValue,
 
 1041      "in Json::Value::resolveReference(): requires objectValue");
 
 1042  if (type() == nullValue)
 
 1043    *
this = Value(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;
 
 1057Value& Value::resolveReference(
char const* key, 
char const* end) {
 
 1059      type() == nullValue || type() == objectValue,
 
 1060      "in Json::Value::resolveReference(key, end): requires objectValue");
 
 1061  if (type() == nullValue)
 
 1062    *
this = Value(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;
 
 
 1080bool Value::isValidIndex(
ArrayIndex index)
 const { 
return index < size(); }
 
 1082Value const* Value::find(
char const* begin, 
char const* end)
 const {
 
 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;
 
 
 1096  return find(key.data(), key.data() + key.length());
 
 
 1098Value* Value::demand(
char const* begin, 
char const* end) {
 
 1100                      "in Json::Value::demand(begin, end): requires " 
 1101                      "objectValue or nullValue");
 
 1102  return &resolveReference(begin, end);
 
 
 1104const Value& Value::operator[](
const char* key)
 const {
 
 1105  Value const* found = find(key, key + strlen(key));
 
 1107    return nullSingleton();
 
 
 1111  Value const* found = find(key);
 
 1113    return nullSingleton();
 
 
 1117Value& Value::operator[](
const char* key) {
 
 1118  return resolveReference(key, key + strlen(key));
 
 
 1122  return resolveReference(key.data(), key.data() + key.length());
 
 
 1126  return resolveReference(key.
c_str());
 
 
 1133                      "in Json::Value::append: requires arrayValue");
 
 1137  return this->value_.map_->emplace(size(), std::move(value)).first->second;
 
 
 1141  return insert(index, 
Value(newValue));
 
 
 1146                      "in Json::Value::insert: requires arrayValue");
 
 1148  if (index > length) {
 
 1151  for (
ArrayIndex i = length; i > index; i--) {
 
 1152    (*this)[i] = std::move((*
this)[i - 1]);
 
 1154  (*this)[index] = std::move(newValue);
 
 
 1158Value Value::get(
char const* begin, 
char const* end,
 
 1159                 Value const& defaultValue)
 const {
 
 1160  Value const* found = find(begin, end);
 
 1161  return !found ? defaultValue : *found;
 
 
 1163Value Value::get(
char const* key, 
Value const& defaultValue)
 const {
 
 1164  return get(key, key + strlen(key), defaultValue);
 
 
 1167  return get(key.data(), key.data() + key.length(), defaultValue);
 
 
 1170bool Value::removeMember(
const char* begin, 
const char* end, 
Value* removed) {
 
 1174  CZString actualKey(begin, 
static_cast<unsigned>(end - begin),
 
 1175                     CZString::noDuplication);
 
 1176  auto it = value_.map_->find(actualKey);
 
 1177  if (it == value_.map_->end())
 
 1180    *removed = std::move(it->second);
 
 1181  value_.map_->erase(it);
 
 
 1184bool Value::removeMember(
const char* key, 
Value* removed) {
 
 1185  return removeMember(key, key + strlen(key), removed);
 
 
 1188  return removeMember(key.data(), key.data() + key.length(), removed);
 
 
 1190void Value::removeMember(
const char* key) {
 
 1192                      "in Json::Value::removeMember(): requires objectValue");
 
 1196  CZString actualKey(key, 
unsigned(strlen(key)), CZString::noDuplication);
 
 1197  value_.map_->erase(actualKey);
 
 
 1199void Value::removeMember(
const String& key) { removeMember(key.c_str()); }
 
 1205  CZString key(index);
 
 1206  auto it = value_.map_->find(key);
 
 1207  if (it == value_.map_->end()) {
 
 1211    *removed = std::move(it->second);
 
 1214  for (
ArrayIndex i = index; i < (oldSize - 1); ++i) {
 
 1216    (*value_.map_)[keey] = (*
this)[i + 1];
 
 1219  CZString keyLast(oldSize - 1);
 
 1220  auto itLast = value_.map_->find(keyLast);
 
 1221  value_.map_->erase(itLast);
 
 
 1225bool Value::isMember(
char const* begin, 
char const* end)
 const {
 
 1226  Value const* value = find(begin, end);
 
 1227  return nullptr != value;
 
 
 1229bool Value::isMember(
char const* key)
 const {
 
 1230  return isMember(key, key + strlen(key));
 
 
 1232bool Value::isMember(
String const& key)
 const {
 
 1233  return isMember(key.data(), key.data() + key.length());
 
 
 1239      "in Json::Value::getMemberNames(), value must be objectValue");
 
 1243  members.reserve(value_.map_->size());
 
 1244  ObjectValues::const_iterator it = value_.map_->begin();
 
 1245  ObjectValues::const_iterator itEnd = value_.map_->end();
 
 1246  for (; it != itEnd; ++it) {
 
 1247    members.push_back(
String((*it).first.data(), (*it).first.length()));
 
 
 1253  double integral_part;
 
 1254  return modf(d, &integral_part) == 0.0;
 
 
 1261bool Value::isInt()
 const {
 
 1264#if defined(JSON_HAS_INT64) 
 1265    return value_.int_ >= minInt && value_.int_ <= maxInt;
 
 1270    return value_.uint_ <= 
UInt(maxInt);
 
 1272    return value_.real_ >= minInt && value_.real_ <= maxInt &&
 
 
 1280bool Value::isUInt()
 const {
 
 1283#if defined(JSON_HAS_INT64) 
 1286    return value_.int_ >= 0;
 
 1289#if defined(JSON_HAS_INT64) 
 1290    return value_.uint_ <= maxUInt;
 
 1295    return value_.real_ >= 0 && value_.real_ <= maxUInt &&
 
 
 1303bool Value::isInt64()
 const {
 
 1304#if defined(JSON_HAS_INT64) 
 1309    return value_.uint_ <= 
UInt64(maxInt64);
 
 1314    return value_.real_ >= double(minInt64) &&
 
 1315           value_.real_ < double(maxInt64) && 
IsIntegral(value_.real_);
 
 
 1323bool Value::isUInt64()
 const {
 
 1324#if defined(JSON_HAS_INT64) 
 1327    return value_.int_ >= 0;
 
 1334    return value_.real_ >= 0 && value_.real_ < maxUInt64AsDouble &&
 
 
 1343bool Value::isIntegral()
 const {
 
 1349#if defined(JSON_HAS_INT64) 
 1353    return value_.real_ >= double(minInt64) &&
 
 1354           value_.real_ < maxUInt64AsDouble && 
IsIntegral(value_.real_);
 
 1356    return value_.real_ >= minInt && value_.real_ <= maxUInt &&
 
 
 1365bool Value::isDouble()
 const {
 
 
 1369bool Value::isNumeric()
 const { 
return isDouble(); }
 
 1377Value::Comments::Comments(
const Comments& that)
 
 1380Value::Comments::Comments(Comments&& that) noexcept
 
 1381    : ptr_{std::move(that.ptr_)} {}
 
 1383Value::Comments& Value::Comments::operator=(
const Comments& that) {
 
 1388Value::Comments& Value::Comments::operator=(Comments&& that) 
noexcept {
 
 1389  ptr_ = std::move(that.ptr_);
 
 1393bool Value::Comments::has(CommentPlacement slot)
 const {
 
 1394  return ptr_ && !(*ptr_)[slot].empty();
 
 1397String Value::Comments::get(CommentPlacement slot)
 const {
 
 1400  return (*ptr_)[slot];
 
 1403void Value::Comments::set(CommentPlacement slot, 
String comment) {
 
 1407    ptr_ = std::unique_ptr<Array>(
new Array());
 
 1408  (*ptr_)[slot] = std::move(comment);
 
 1412  if (!comment.empty() && (comment.back() == 
'\n')) {
 
 1417      comment.empty() || comment[0] == 
'/',
 
 1418      "in Json::Value::setComment(): Comments must start with /");
 
 1419  comments_.set(
placement, std::move(comment));
 
 
 1479      return iterator(value_.map_->begin());
 
 
 1492      return iterator(value_.map_->end());
 
 
 1506    : index_(index), kind_(kindIndex) {}
 
 
 1528void Path::makePath(
const String& path, 
const InArgs& in) {
 
 1529  const char* current = path.c_str();
 
 1530  const char* end = current + path.length();
 
 1531  auto itInArg = in.begin();
 
 1532  while (current != end) {
 
 1533    if (*current == 
'[') {
 
 1535      if (*current == 
'%')
 
 1536        addPathInArg(path, in, itInArg, PathArgument::kindIndex);
 
 1539        for (; current != end && *current >= 
'0' && *current <= 
'9'; ++current)
 
 1540          index = index * 10 + 
ArrayIndex(*current - 
'0');
 
 1541        args_.push_back(index);
 
 1543      if (current == end || *++current != 
']')
 
 1544        invalidPath(path, 
int(current - path.c_str()));
 
 1545    } 
else if (*current == 
'%') {
 
 1546      addPathInArg(path, in, itInArg, PathArgument::kindKey);
 
 1548    } 
else if (*current == 
'.' || *current == 
']') {
 
 1551      const char* beginName = current;
 
 1552      while (current != end && !strchr(
"[.", *current))
 
 1554      args_.push_back(
String(beginName, current));
 
 1559void Path::addPathInArg(
const String& , 
const InArgs& in,
 
 1560                        InArgs::const_iterator& itInArg,
 
 1561                        PathArgument::Kind kind) {
 
 1562  if (itInArg == in.end()) {
 
 1564  } 
else if ((*itInArg)->kind_ != kind) {
 
 1567    args_.push_back(**itInArg++);
 
 1571void Path::invalidPath(
const String& , 
int ) {
 
 1576  const Value* node = &root;
 
 1577  for (
const auto& arg : args_) {
 
 1578    if (arg.kind_ == PathArgument::kindIndex) {
 
 1583      node = &((*node)[arg.index_]);
 
 1584    } 
else if (arg.kind_ == PathArgument::kindKey) {
 
 1589      node = &((*node)[arg.key_]);
 
 
 1601  const Value* node = &root;
 
 1602  for (
const auto& arg : args_) {
 
 1603    if (arg.kind_ == PathArgument::kindIndex) {
 
 1605        return defaultValue;
 
 1606      node = &((*node)[arg.index_]);
 
 1607    } 
else if (arg.kind_ == PathArgument::kindKey) {
 
 1609        return defaultValue;
 
 1610      node = &((*node)[arg.key_]);
 
 1612        return defaultValue;
 
 
 1619  Value* node = &root;
 
 1620  for (
const auto& arg : args_) {
 
 1621    if (arg.kind_ == PathArgument::kindIndex) {
 
 1625      node = &((*node)[arg.index_]);
 
 1626    } 
else if (arg.kind_ == PathArgument::kindKey) {
 
 1630      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)
Base class for all exceptions we throw.
~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 for object and array value.
const_iterator begin() const
Json::ArrayIndex ArrayIndex
static const Value & null
void setComment(const char *comment, size_t len, CommentPlacement placement)
Comments must be //... or /* ... */.
ptrdiff_t getOffsetLimit() const
std::vector< String > Members
const_iterator end() const
String getComment(CommentPlacement placement) const
Include delimiters and embedded newlines.
String toStyledString() const
CommentPlacement placement
void setOffsetLimit(ptrdiff_t limit)
bool hasComment(CommentPlacement placement) const
Json::LargestInt LargestInt
Json::LargestUInt LargestUInt
ValueConstIterator const_iterator
void setOffsetStart(ptrdiff_t start)
void swap(Value &other)
Swap everything.
static const Value & nullRef
static constexpr Int maxInt
Maximum signed int value that can be stored in a Json::Value.
bool isValidIndex(ArrayIndex index) const
Return true if index < size().
static Value const & nullSingleton()
ptrdiff_t getOffsetStart() const
Iterator for object and array 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)
void swap(Value &a, Value &b)
static bool InRange(double d, T min, U max)