Lines Matching refs:value
145 * @param value Unsigned interger to convert to string
149 static inline void uintToString(LargestUInt value, char*& current) {
152 *--current = char(value % 10) + '0';
153 value /= 10;
154 } while (value != 0);
196 #include <json/value.h>
324 "A valid JSON document must be either an array or an object value.",
392 // "Un-read" the current token and mark the current value as a null
404 return addError("Syntax error: value, object or array expected.", token);
663 Value& value = currentValue()[name];
664 nodes_.push(&value);
700 Value& value = currentValue()[index++];
701 nodes_.push(&value);
737 // larger than the maximum supported value of an integer then
748 Value::LargestUInt value = 0;
754 if (value >= threshold) {
755 // We've hit or exceeded the max value divided by 10 (rounded down). If
759 if (value > threshold || current != token.end_ ||
764 value = value * 10 + digit;
767 decoded = -Value::LargestInt(value);
768 else if (value <= Value::LargestUInt(Value::maxInt))
769 decoded = Value::LargestInt(value);
771 decoded = value;
786 double value = 0;
807 count = sscanf(buffer, format, &value);
810 count = sscanf(buffer.c_str(), format, &value);
817 decoded = value;
1055 bool Reader::pushError(const Value& value, const std::string& message) {
1057 if(value.getOffsetStart() > length
1058 || value.getOffsetLimit() > length)
1062 token.start_ = begin_ + value.getOffsetStart();
1063 token.end_ = end_ + value.getOffsetLimit();
1072 bool Reader::pushError(const Value& value, const std::string& message, const Value& extra) {
1074 if(value.getOffsetStart() > length
1075 || value.getOffsetLimit() > length
1080 token.start_ = begin_ + value.getOffsetStart();
1081 token.end_ = begin_ + value.getOffsetLimit();
1143 bool pushError(const Value& value, const std::string& message);
1144 bool pushError(const Value& value, const std::string& message, const Value& extra);
1273 addError("Extra non-whitespace after JSON value.", token);
1287 "A valid JSON document must be either an array or an object value.",
1350 // "Un-read" the current token and mark the current value as a null
1362 return addError("Syntax error: value, object or array expected.", token);
1626 Value& value = currentValue()[name];
1627 nodes_.push(&value);
1663 Value& value = currentValue()[index++];
1664 nodes_.push(&value);
1700 // larger than the maximum supported value of an integer then
1711 Value::LargestUInt value = 0;
1717 if (value >= threshold) {
1718 // We've hit or exceeded the max value divided by 10 (rounded down). If
1722 if (value > threshold || current != token.end_ ||
1727 value = value * 10 + digit;
1730 decoded = -Value::LargestInt(value);
1731 else if (value <= Value::LargestUInt(Value::maxInt))
1732 decoded = Value::LargestInt(value);
1734 decoded = value;
1749 double value = 0;
1770 count = sscanf(buffer, format, &value);
1773 count = sscanf(buffer.c_str(), format, &value);
1780 decoded = value;
2013 bool OurReader::pushError(const Value& value, const std::string& message) {
2015 if(value.getOffsetStart() > length
2016 || value.getOffsetLimit() > length)
2020 token.start_ = begin_ + value.getOffsetStart();
2021 token.end_ = end_ + value.getOffsetLimit();
2030 bool OurReader::pushError(const Value& value, const std::string& message, const Value& extra) {
2032 if(value.getOffsetStart() > length
2033 || value.getOffsetLimit() > length
2038 token.start_ = begin_ + value.getOffsetStart();
2039 token.end_ = begin_ + value.getOffsetLimit();
2245 // Iterator for null value are initialized using the default
2386 #include <json/value.h>
2439 static inline double integerToDouble(Json::UInt64 value) {
2440 return static_cast<double>(Int64(value / 2)) * 2.0 + Int64(value & 1);
2443 template <typename T> static inline double integerToDouble(T value) {
2444 return static_cast<double>(value);
2453 /** Duplicates the specified string value.
2454 * @param value Pointer to the string to duplicate. Must be zero-terminated if
2456 * @param length Length of the value. if equals to unknown, then it will be
2457 * computed using strlen(value).
2460 static inline char* duplicateStringValue(const char* value,
2463 // to a sane value.
2471 "Failed to allocate string value buffer");
2473 memcpy(newString, value, length);
2481 const char* value,
2485 // to a sane value.
2494 "Failed to allocate string value buffer");
2497 memcpy(newString + sizeof(unsigned), value, length);
2503 unsigned* length, char const** value)
2507 *value = prefixed;
2510 *value = prefixed + sizeof(unsigned);
2515 static inline void releaseStringValue(char* value) { free(value); }
2720 Value::Value(Int value) {
2722 value_.int_ = value;
2725 Value::Value(UInt value) {
2727 value_.uint_ = value;
2730 Value::Value(Int64 value) {
2732 value_.int_ = value;
2734 Value::Value(UInt64 value) {
2736 value_.uint_ = value;
2740 Value::Value(double value) {
2742 value_.real_ = value;
2745 Value::Value(const char* value) {
2747 value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));
2756 Value::Value(const std::string& value) {
2759 duplicateAndPrefixStringValue(value.data(), static_cast<unsigned>(value.length()));
2762 Value::Value(const StaticString& value) {
2764 value_.string_ = const_cast<char*>(value.c_str());
2768 Value::Value(const CppTL::ConstString& value) {
2770 value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(value.length()));
2774 Value::Value(bool value) {
2776 value_.bool_ = value;
3267 "in Json::Value::clear(): requires complex value");
3349 // Access an object value by name, create a null member if it does not exist.
3366 Value& value = (*it).second;
3367 return value;
3386 Value& value = (*it).second;
3387 return value;
3391 const Value* value = &((*this)[index]);
3392 return value == &nullRef ? defaultValue : *value;
3445 Value& Value::append(const Value& value) { return (*this)[size()] = value; }
3531 Value const* value = find(key, end);
3532 return NULL != value;
3552 "in Json::Value::getMemberNames(), value must be objectValue");
3640 // require the value to be strictly less than the limit.
3660 // require the value to be strictly less than the limit.
3867 // Error: unable to resolve path (array value expected at position...
3872 // Error: unable to resolve path (object value expected at position...)
4011 std::string valueToString(LargestInt value) {
4014 bool isNegative = value < 0;
4016 value = -value;
4017 uintToString(LargestUInt(value), current);
4024 std::string valueToString(LargestUInt value) {
4027 uintToString(value, current);
4034 std::string valueToString(Int value) {
4035 return valueToString(LargestInt(value));
4038 std::string valueToString(UInt value) {
4039 return valueToString(LargestUInt(value));
4044 std::string valueToString(double value) {
4057 len = _snprintf(buffer, sizeof(buffer), "%.17g", value);
4059 len = sprintf_s(buffer, sizeof(buffer), "%.17g", value);
4062 if (isfinite(value)) {
4063 len = snprintf(buffer, sizeof(buffer), "%.17g", value);
4066 if (value != value) {
4068 } else if (value < 0) {
4081 std::string valueToString(bool value) { return value ? "true" : "false"; }
4083 std::string valueToQuotedString(const char* value) {
4084 if (value == NULL)
4087 if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL &&
4088 !containsControlCharacter(value))
4089 return std::string("\"") + value + "\"";
4090 // We have to walk value and escape any special characters.
4094 strlen(value) * 2 + 3; // allescaped+quotes+NULL
4098 for (const char* c = value; *c != 0; ++c) {
4160 static std::string valueToQuotedStringN(const char* value, unsigned length) {
4161 if (value == NULL)
4164 if (strnpbrk(value, "\"\\\b\f\n\r\t", length) == NULL &&
4165 !containsControlCharacter0(value, length))
4166 return std::string("\"") + value + "\"";
4167 // We have to walk value and escape any special characters.
4175 char const* end = value + length;
4176 for (const char* c = value; c != end; ++c) {
4248 void FastWriter::writeValue(const Value& value) {
4249 switch (value.type()) {
4255 document_ += valueToString(value.asLargestInt());
4258 document_ += valueToString(value.asLargestUInt());
4261 document_ += valueToString(value.asDouble());
4265 // Is NULL possible for value.string_?
4268 bool ok = value.getString(&str, &end);
4273 document_ += valueToString(value.asBool());
4277 int size = value.size();
4281 writeValue(value[index]);
4286 Value::Members members(value.getMemberNames());
4295 writeValue(value[name]);
4319 void StyledWriter::writeValue(const Value& value) {
4320 switch (value.type()) {
4325 pushValue(valueToString(value.asLargestInt()));
4328 pushValue(valueToString(value.asLargestUInt()));
4331 pushValue(valueToString(value.asDouble()));
4335 // Is NULL possible for value.string_?
4338 bool ok = value.getString(&str, &end);
4344 pushValue(valueToString(value.asBool()));
4347 writeArrayValue(value);
4350 Value::Members members(value.getMemberNames());
4359 const Value& childValue = value[name];
4378 void StyledWriter::writeArrayValue(const Value& value) {
4379 unsigned size = value.size();
4383 bool isArrayMultiLine = isMultineArray(value);
4390 const Value& childValue = value[index];
4421 bool StyledWriter::isMultineArray(const Value& value) {
4422 int size = value.size();
4426 const Value& childValue = value[index];
4437 if (hasCommentForValue(value[index])) {
4440 writeValue(value[index]);
4449 void StyledWriter::pushValue(const std::string& value) {
4451 childValues_.push_back(value);
4453 document_ += value;
4467 void StyledWriter::writeWithIndent(const std::string& value) {
4469 document_ += value;
4510 bool StyledWriter::hasCommentForValue(const Value& value) {
4511 return value.hasComment(commentBefore) ||
4512 value.hasComment(commentAfterOnSameLine) ||
4513 value.hasComment(commentAfter);
4537 void StyledStreamWriter::writeValue(const Value& value) {
4538 switch (value.type()) {
4543 pushValue(valueToString(value.asLargestInt()));
4546 pushValue(valueToString(value.asLargestUInt()));
4549 pushValue(valueToString(value.asDouble()));
4553 // Is NULL possible for value.string_?
4556 bool ok = value.getString(&str, &end);
4562 pushValue(valueToString(value.asBool()));
4565 writeArrayValue(value);
4568 Value::Members members(value.getMemberNames());
4577 const Value& childValue = value[name];
4596 void StyledStreamWriter::writeArrayValue(const Value& value) {
4597 unsigned size = value.size();
4601 bool isArrayMultiLine = isMultineArray(value);
4608 const Value& childValue = value[index];
4641 bool StyledStreamWriter::isMultineArray(const Value& value) {
4642 int size = value.size();
4646 const Value& childValue = value[index];
4657 if (hasCommentForValue(value[index])) {
4660 writeValue(value[index]);
4669 void StyledStreamWriter::pushValue(const std::string& value) {
4671 childValues_.push_back(value);
4673 *document_ << value;
4684 void StyledStreamWriter::writeWithIndent(const std::string& value) {
4686 *document_ << value;
4726 bool StyledStreamWriter::hasCommentForValue(const Value& value) {
4727 return value.hasComment(commentBefore) ||
4728 value.hasComment(commentAfterOnSameLine) ||
4729 value.hasComment(commentAfter);
4755 void writeValue(Value const& value);
4756 void writeArrayValue(Value const& value);
4757 bool isMultineArray(Value const& value);
4758 void pushValue(std::string const& value);
4760 void writeWithIndent(std::string const& value);
4765 static bool hasCommentForValue(const Value& value);
4811 void BuiltStyledStreamWriter::writeValue(Value const& value) {
4812 switch (value.type()) {
4817 pushValue(valueToString(value.asLargestInt()));
4820 pushValue(valueToString(value.asLargestUInt()));
4823 pushValue(valueToString(value.asDouble()));
4827 // Is NULL is possible for value.string_?
4830 bool ok = value.getString(&str, &end);
4836 pushValue(valueToString(value.asBool()));
4839 writeArrayValue(value);
4842 Value::Members members(value.getMemberNames());
4851 Value const& childValue = value[name];
4870 void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
4871 unsigned size = value.size();
4875 bool isMultiLine = (cs_ == CommentStyle::All) || isMultineArray(value);
4882 Value const& childValue = value[index];
4917 bool BuiltStyledStreamWriter::isMultineArray(Value const& value) {
4918 int size = value.size();
4922 Value const& childValue = value[index];
4933 if (hasCommentForValue(value[index])) {
4936 writeValue(value[index]);
4945 void BuiltStyledStreamWriter::pushValue(std::string const& value) {
4947 childValues_.push_back(value);
4949 *sout_ << value;
4964 void BuiltStyledStreamWriter::writeWithIndent(std::string const& value) {
4966 *sout_ << value;
5008 bool BuiltStyledStreamWriter::hasCommentForValue(const Value& value) {
5009 return value.hasComment(commentBefore) ||
5010 value.hasComment(commentAfterOnSameLine) ||
5011 value.hasComment(commentAfter);