add a valueToQuotedString overload to take a string length to support things like a string_view more directly.
This commit is contained in:
parent
42e892d96e
commit
1c0db7dae8
@ -354,6 +354,7 @@ String JSON_API valueToString(
|
|||||||
PrecisionType precisionType = PrecisionType::significantDigits);
|
PrecisionType precisionType = PrecisionType::significantDigits);
|
||||||
String JSON_API valueToString(bool value);
|
String JSON_API valueToString(bool value);
|
||||||
String JSON_API valueToQuotedString(const char* value);
|
String JSON_API valueToQuotedString(const char* value);
|
||||||
|
String JSON_API valueToQuotedString(const char* value, size_t length);
|
||||||
|
|
||||||
/// \brief Output using the StyledStreamWriter.
|
/// \brief Output using the StyledStreamWriter.
|
||||||
/// \see Json::operator>>()
|
/// \see Json::operator>>()
|
||||||
|
@ -353,6 +353,10 @@ String valueToQuotedString(const char* value) {
|
|||||||
return valueToQuotedStringN(value, strlen(value));
|
return valueToQuotedStringN(value, strlen(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String valueToQuotedString(const char* value, size_t length) {
|
||||||
|
return valueToQuotedStringN(value, length);
|
||||||
|
}
|
||||||
|
|
||||||
// Class Writer
|
// Class Writer
|
||||||
// //////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////
|
||||||
Writer::~Writer() = default;
|
Writer::~Writer() = default;
|
||||||
@ -490,7 +494,7 @@ void StyledWriter::writeValue(const Value& value) {
|
|||||||
const String& name = *it;
|
const String& name = *it;
|
||||||
const Value& childValue = value[name];
|
const Value& childValue = value[name];
|
||||||
writeCommentBeforeValue(childValue);
|
writeCommentBeforeValue(childValue);
|
||||||
writeWithIndent(valueToQuotedString(name.c_str()));
|
writeWithIndent(valueToQuotedString(name.c_str(),name.size()));
|
||||||
document_ += " : ";
|
document_ += " : ";
|
||||||
writeValue(childValue);
|
writeValue(childValue);
|
||||||
if (++it == members.end()) {
|
if (++it == members.end()) {
|
||||||
@ -708,7 +712,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
|
|||||||
const String& name = *it;
|
const String& name = *it;
|
||||||
const Value& childValue = value[name];
|
const Value& childValue = value[name];
|
||||||
writeCommentBeforeValue(childValue);
|
writeCommentBeforeValue(childValue);
|
||||||
writeWithIndent(valueToQuotedString(name.c_str()));
|
writeWithIndent(valueToQuotedString(name.c_str(),name.size()));
|
||||||
*document_ << " : ";
|
*document_ << " : ";
|
||||||
writeValue(childValue);
|
writeValue(childValue);
|
||||||
if (++it == members.end()) {
|
if (++it == members.end()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user