[Lldb-commits] [lldb] r238279 - Make StructureData objects dump themselves with correct indentation.
Greg Clayton
gclayton at apple.com
Tue May 26 20:23:26 PDT 2015
Author: gclayton
Date: Tue May 26 22:23:26 2015
New Revision: 238279
URL: http://llvm.org/viewvc/llvm-project?rev=238279&view=rev
Log:
Make StructureData objects dump themselves with correct indentation.
Modified:
lldb/trunk/source/Core/StructuredData.cpp
Modified: lldb/trunk/source/Core/StructuredData.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/StructuredData.cpp?rev=238279&r1=238278&r2=238279&view=diff
==============================================================================
--- lldb/trunk/source/Core/StructuredData.cpp (original)
+++ lldb/trunk/source/Core/StructuredData.cpp Tue May 26 22:23:26 2015
@@ -356,20 +356,28 @@ StructuredData::Object::DumpToStdout() c
{
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)
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 << "}";
}
More information about the lldb-commits
mailing list