summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2015-05-27 03:23:26 +0000
committerGreg Clayton <gclayton@apple.com>2015-05-27 03:23:26 +0000
commit66b8294caef14dcd29cc0a9cbed913e3cec1c091 (patch)
tree08e9b4cc79e28c3e5faa512b784c38274c0853f2
parentb1ca494b6e48b535544a4abf088853a5f7da42d2 (diff)
downloadbcm5719-llvm-66b8294caef14dcd29cc0a9cbed913e3cec1c091.tar.gz
bcm5719-llvm-66b8294caef14dcd29cc0a9cbed913e3cec1c091.zip
Make StructureData objects dump themselves with correct indentation.
llvm-svn: 238279
-rw-r--r--lldb/source/Core/StructuredData.cpp47
1 files changed, 28 insertions, 19 deletions
diff --git a/lldb/source/Core/StructuredData.cpp b/lldb/source/Core/StructuredData.cpp
index 7b1e3d95317..9286c3a2991 100644
--- a/lldb/source/Core/StructuredData.cpp
+++ b/lldb/source/Core/StructuredData.cpp
@@ -356,20 +356,28 @@ StructuredData::Object::DumpToStdout() const
{
StreamString stream;
Dump(stream);
- printf("%s", stream.GetString().c_str());
+ printf("%s\n", stream.GetString().c_str());
}
void
StructuredData::Array::Dump(Stream &s) const
{
- s << "[";
- const size_t arrsize = m_items.size();
- for (size_t i = 0; i < arrsize; ++i)
+ bool first = true;
+ s << "[\n";
+ s.IndentMore();
+ for (const auto &item_sp : m_items)
{
- m_items[i]->Dump(s);
- if (i + 1 < arrsize)
- s << ",";
+ if (first)
+ first = false;
+ else
+ s << ",\n";
+
+ s.Indent();
+ item_sp->Dump(s);
}
+ s.IndentLess();
+ s.EOL();
+ s.Indent();
s << "]";
}
@@ -414,21 +422,22 @@ StructuredData::String::Dump (Stream &s) const
void
StructuredData::Dictionary::Dump (Stream &s) const
{
- bool have_printed_one_elem = false;
- s << "{";
- for (collection::const_iterator iter = m_dict.begin(); iter != m_dict.end(); ++iter)
+ bool first = true;
+ s << "{\n";
+ s.IndentMore();
+ for (const auto &pair : m_dict)
{
- if (have_printed_one_elem == false)
- {
- have_printed_one_elem = true;
- }
+ if (first)
+ first = false;
else
- {
- s << ",";
- }
- s << "\"" << iter->first.AsCString() << "\":";
- iter->second->Dump(s);
+ s << ",\n";
+ s.Indent();
+ s << "\"" << pair.first.AsCString() << "\" : ";
+ pair.second->Dump(s);
}
+ s.IndentLess();
+ s.EOL();
+ s.Indent();
s << "}";
}
OpenPOWER on IntegriCloud