|
@@ -68,7 +68,7 @@
|
|
|
|
|
|
#if !defined(isnan)
|
|
#if !defined(isnan)
|
|
// IEEE standard states that NaN values will not compare to themselves
|
|
// IEEE standard states that NaN values will not compare to themselves
|
|
-#define isnan(x) (x != x)
|
|
|
|
|
|
+#define isnan(x) ((x) != (x))
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#if !defined(__APPLE__)
|
|
#if !defined(__APPLE__)
|
|
@@ -154,16 +154,18 @@ String valueToString(double value, bool useSpecialFloats,
|
|
|
|
|
|
buffer.erase(fixNumericLocale(buffer.begin(), buffer.end()), buffer.end());
|
|
buffer.erase(fixNumericLocale(buffer.begin(), buffer.end()), buffer.end());
|
|
|
|
|
|
- // strip the zero padding from the right
|
|
|
|
- if (precisionType == PrecisionType::decimalPlaces) {
|
|
|
|
- buffer.erase(fixZerosInTheEnd(buffer.begin(), buffer.end()), buffer.end());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// try to ensure we preserve the fact that this was given to us as a double on
|
|
// try to ensure we preserve the fact that this was given to us as a double on
|
|
// input
|
|
// input
|
|
if (buffer.find('.') == buffer.npos && buffer.find('e') == buffer.npos) {
|
|
if (buffer.find('.') == buffer.npos && buffer.find('e') == buffer.npos) {
|
|
buffer += ".0";
|
|
buffer += ".0";
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // strip the zero padding from the right
|
|
|
|
+ if (precisionType == PrecisionType::decimalPlaces) {
|
|
|
|
+ buffer.erase(fixZerosInTheEnd(buffer.begin(), buffer.end(), precision),
|
|
|
|
+ buffer.end());
|
|
|
|
+ }
|
|
|
|
+
|
|
return buffer;
|
|
return buffer;
|
|
}
|
|
}
|
|
} // namespace
|
|
} // namespace
|
|
@@ -270,7 +272,7 @@ static void appendHex(String& result, unsigned ch) {
|
|
result.append("\\u").append(toHex16Bit(ch));
|
|
result.append("\\u").append(toHex16Bit(ch));
|
|
}
|
|
}
|
|
|
|
|
|
-static String valueToQuotedStringN(const char* value, unsigned length,
|
|
|
|
|
|
+static String valueToQuotedStringN(const char* value, size_t length,
|
|
bool emitUTF8 = false) {
|
|
bool emitUTF8 = false) {
|
|
if (value == nullptr)
|
|
if (value == nullptr)
|
|
return "";
|
|
return "";
|
|
@@ -348,7 +350,7 @@ static String valueToQuotedStringN(const char* value, unsigned length,
|
|
}
|
|
}
|
|
|
|
|
|
String valueToQuotedString(const char* value) {
|
|
String valueToQuotedString(const char* value) {
|
|
- return valueToQuotedStringN(value, static_cast<unsigned int>(strlen(value)));
|
|
|
|
|
|
+ return valueToQuotedStringN(value, strlen(value));
|
|
}
|
|
}
|
|
|
|
|
|
// Class Writer
|
|
// Class Writer
|
|
@@ -397,7 +399,7 @@ void FastWriter::writeValue(const Value& value) {
|
|
char const* end;
|
|
char const* end;
|
|
bool ok = value.getString(&str, &end);
|
|
bool ok = value.getString(&str, &end);
|
|
if (ok)
|
|
if (ok)
|
|
- document_ += valueToQuotedStringN(str, static_cast<unsigned>(end - str));
|
|
|
|
|
|
+ document_ += valueToQuotedStringN(str, static_cast<size_t>(end - str));
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case booleanValue:
|
|
case booleanValue:
|
|
@@ -420,8 +422,7 @@ void FastWriter::writeValue(const Value& value) {
|
|
const String& name = *it;
|
|
const String& name = *it;
|
|
if (it != members.begin())
|
|
if (it != members.begin())
|
|
document_ += ',';
|
|
document_ += ',';
|
|
- document_ += valueToQuotedStringN(name.data(),
|
|
|
|
- static_cast<unsigned>(name.length()));
|
|
|
|
|
|
+ document_ += valueToQuotedStringN(name.data(), name.length());
|
|
document_ += yamlCompatibilityEnabled_ ? ": " : ":";
|
|
document_ += yamlCompatibilityEnabled_ ? ": " : ":";
|
|
writeValue(value[name]);
|
|
writeValue(value[name]);
|
|
}
|
|
}
|
|
@@ -466,7 +467,7 @@ void StyledWriter::writeValue(const Value& value) {
|
|
char const* end;
|
|
char const* end;
|
|
bool ok = value.getString(&str, &end);
|
|
bool ok = value.getString(&str, &end);
|
|
if (ok)
|
|
if (ok)
|
|
- pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end - str)));
|
|
|
|
|
|
+ pushValue(valueToQuotedStringN(str, static_cast<size_t>(end - str)));
|
|
else
|
|
else
|
|
pushValue("");
|
|
pushValue("");
|
|
break;
|
|
break;
|
|
@@ -507,7 +508,7 @@ void StyledWriter::writeValue(const Value& value) {
|
|
}
|
|
}
|
|
|
|
|
|
void StyledWriter::writeArrayValue(const Value& value) {
|
|
void StyledWriter::writeArrayValue(const Value& value) {
|
|
- unsigned size = value.size();
|
|
|
|
|
|
+ size_t size = value.size();
|
|
if (size == 0)
|
|
if (size == 0)
|
|
pushValue("[]");
|
|
pushValue("[]");
|
|
else {
|
|
else {
|
|
@@ -516,7 +517,7 @@ void StyledWriter::writeArrayValue(const Value& value) {
|
|
writeWithIndent("[");
|
|
writeWithIndent("[");
|
|
indent();
|
|
indent();
|
|
bool hasChildValue = !childValues_.empty();
|
|
bool hasChildValue = !childValues_.empty();
|
|
- unsigned index = 0;
|
|
|
|
|
|
+ ArrayIndex index = 0;
|
|
for (;;) {
|
|
for (;;) {
|
|
const Value& childValue = value[index];
|
|
const Value& childValue = value[index];
|
|
writeCommentBeforeValue(childValue);
|
|
writeCommentBeforeValue(childValue);
|
|
@@ -539,7 +540,7 @@ void StyledWriter::writeArrayValue(const Value& value) {
|
|
{
|
|
{
|
|
assert(childValues_.size() == size);
|
|
assert(childValues_.size() == size);
|
|
document_ += "[ ";
|
|
document_ += "[ ";
|
|
- for (unsigned index = 0; index < size; ++index) {
|
|
|
|
|
|
+ for (size_t index = 0; index < size; ++index) {
|
|
if (index > 0)
|
|
if (index > 0)
|
|
document_ += ", ";
|
|
document_ += ", ";
|
|
document_ += childValues_[index];
|
|
document_ += childValues_[index];
|
|
@@ -684,7 +685,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
|
|
char const* end;
|
|
char const* end;
|
|
bool ok = value.getString(&str, &end);
|
|
bool ok = value.getString(&str, &end);
|
|
if (ok)
|
|
if (ok)
|
|
- pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end - str)));
|
|
|
|
|
|
+ pushValue(valueToQuotedStringN(str, static_cast<size_t>(end - str)));
|
|
else
|
|
else
|
|
pushValue("");
|
|
pushValue("");
|
|
break;
|
|
break;
|
|
@@ -958,8 +959,8 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
|
|
char const* end;
|
|
char const* end;
|
|
bool ok = value.getString(&str, &end);
|
|
bool ok = value.getString(&str, &end);
|
|
if (ok)
|
|
if (ok)
|
|
- pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end - str),
|
|
|
|
- emitUTF8_));
|
|
|
|
|
|
+ pushValue(
|
|
|
|
+ valueToQuotedStringN(str, static_cast<size_t>(end - str), emitUTF8_));
|
|
else
|
|
else
|
|
pushValue("");
|
|
pushValue("");
|
|
break;
|
|
break;
|
|
@@ -982,8 +983,8 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
|
|
String const& name = *it;
|
|
String const& name = *it;
|
|
Value const& childValue = value[name];
|
|
Value const& childValue = value[name];
|
|
writeCommentBeforeValue(childValue);
|
|
writeCommentBeforeValue(childValue);
|
|
- writeWithIndent(valueToQuotedStringN(
|
|
|
|
- name.data(), static_cast<unsigned>(name.length()), emitUTF8_));
|
|
|
|
|
|
+ writeWithIndent(
|
|
|
|
+ valueToQuotedStringN(name.data(), name.length(), emitUTF8_));
|
|
*sout_ << colonSymbol_;
|
|
*sout_ << colonSymbol_;
|
|
writeValue(childValue);
|
|
writeValue(childValue);
|
|
if (++it == members.end()) {
|
|
if (++it == members.end()) {
|
|
@@ -1217,7 +1218,7 @@ bool StreamWriterBuilder::validate(Json::Value* invalid) const {
|
|
if (valid_keys.count(key))
|
|
if (valid_keys.count(key))
|
|
continue;
|
|
continue;
|
|
if (invalid)
|
|
if (invalid)
|
|
- (*invalid)[std::move(key)] = *si;
|
|
|
|
|
|
+ (*invalid)[key] = *si;
|
|
else
|
|
else
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|