Fix indentation for nested dictionaries

refs #10527
This commit is contained in:
Gunnar Beutner 2015-11-04 16:42:19 +01:00
parent 5d46f661ea
commit 7378964f31
3 changed files with 9 additions and 10 deletions

View File

@ -216,6 +216,6 @@ Array::Ptr Array::Reverse(void) const
String Array::ToString(void) const
{
std::ostringstream msgbuf;
ConfigWriter::EmitArray(msgbuf, const_cast<Array *>(this));
ConfigWriter::EmitArray(msgbuf, 1, const_cast<Array *>(this));
return msgbuf.str();
}

View File

@ -50,14 +50,14 @@ void ConfigWriter::EmitEmpty(std::ostream& fp)
fp << "null";
}
void ConfigWriter::EmitArray(std::ostream& fp, const Array::Ptr& val)
void ConfigWriter::EmitArray(std::ostream& fp, int indentLevel, const Array::Ptr& val)
{
fp << "[ ";
EmitArrayItems(fp, val);
EmitArrayItems(fp, indentLevel, val);
fp << " ]";
}
void ConfigWriter::EmitArrayItems(std::ostream& fp, const Array::Ptr& val)
void ConfigWriter::EmitArrayItems(std::ostream& fp, int indentLevel, const Array::Ptr& val)
{
bool first = true;
@ -68,7 +68,7 @@ void ConfigWriter::EmitArrayItems(std::ostream& fp, const Array::Ptr& val)
else
fp << ", ";
EmitValue(fp, 0, item);
EmitValue(fp, indentLevel, item);
}
}
@ -117,7 +117,7 @@ void ConfigWriter::EmitScope(std::ostream& fp, int indentLevel, const Dictionary
void ConfigWriter::EmitValue(std::ostream& fp, int indentLevel, const Value& val)
{
if (val.IsObjectType<Array>())
EmitArray(fp, val);
EmitArray(fp, indentLevel, val);
else if (val.IsObjectType<Dictionary>())
EmitScope(fp, indentLevel, val);
else if (val.IsString())
@ -192,7 +192,7 @@ void ConfigWriter::EmitFunctionCall(std::ostream& fp, const String& name, const
{
EmitIdentifier(fp, name, false);
fp << "(";
EmitArrayItems(fp, arguments);
EmitArrayItems(fp, 0, arguments);
fp << ")";
}

View File

@ -40,9 +40,8 @@ public:
static void EmitNumber(std::ostream& fp, double val);
static void EmitString(std::ostream& fp, const String& val);
static void EmitEmpty(std::ostream& fp);
static void EmitArray(std::ostream& fp, const Array::Ptr& val);
static void EmitArrayItems(std::ostream& fp, const Array::Ptr& val);
static void EmitDictionary(std::ostream& fp, const Dictionary::Ptr& val);
static void EmitArray(std::ostream& fp, int indentLevel, const Array::Ptr& val);
static void EmitArrayItems(std::ostream& fp, int indentLevel, const Array::Ptr& val);
static void EmitScope(std::ostream& fp, int indentLevel, const Dictionary::Ptr& val, const Array::Ptr& imports = Array::Ptr());
static void EmitValue(std::ostream& fp, int indentLevel, const Value& val);
static void EmitRaw(std::ostream& fp, const String& val);