added operator<< overloads for dynamic::Value

This commit is contained in:
MihailRis
2024-05-09 22:01:38 +03:00
parent debdec1dc2
commit 76f52037b5
4 changed files with 40 additions and 3 deletions
+13 -3
View File
@@ -52,7 +52,7 @@ void stringifyObj(
bool nice
);
void stringify(
void stringifyValue(
const Value& value,
std::stringstream& ss,
int indent,
@@ -74,7 +74,7 @@ void stringify(
if (i > 0 || nice) {
newline(ss, nice, indent, indentstr);
}
stringify(value, ss, indent+1, indentstr, nice);
stringifyValue(value, ss, indent+1, indentstr, nice);
if (i + 1 < list->size()) {
ss << ',';
}
@@ -114,7 +114,7 @@ void stringifyObj(
}
const Value& value = entry.second;
ss << util::escape(key) << ": ";
stringify(value, ss, indent+1, indentstr, nice);
stringifyValue(value, ss, indent+1, indentstr, nice);
index++;
if (index < obj->values.size()) {
ss << ',';
@@ -136,6 +136,16 @@ std::string json::stringify(
return ss.str();
}
std::string json::stringify(
const dynamic::Value& value,
bool nice,
const std::string& indent
) {
std::stringstream ss;
stringifyValue(value, ss, 1, indent, nice);
return ss.str();
}
Parser::Parser(std::string_view filename, std::string_view source)
: BasicParser(filename, source) {
}