GH #119: JSON::Object holds values in ordered map

- fixed GH #119: JSON::Object holds values in ordered map
- added PrintHandler
- renamed DefaultHandler to ParseHandler
- redefined DefaultHandler as typedef to ParseHandler
This commit is contained in:
aleks-f
2013-03-16 11:33:27 -05:00
parent fe6715890c
commit 42ff341cb9
34 changed files with 1249 additions and 328 deletions

View File

@@ -120,8 +120,10 @@ bool Array::isObject(unsigned int index) const
}
void Array::stringify(std::ostream& out, unsigned int indent) const
void Array::stringify(std::ostream& out, unsigned int indent, int step) const
{
if (step == -1) step = indent;
out << "[";
if (indent > 0) out << std::endl;
@@ -130,15 +132,22 @@ void Array::stringify(std::ostream& out, unsigned int indent) const
{
for(int i = 0; i < indent; i++) out << ' ';
Stringifier::stringify(*it, out, indent);
Stringifier::stringify(*it, out, indent + step, step);
if ( ++it != _values.end() )
{
out << ",";
if ( indent > 0 ) out << std::endl;
if (step > 0) out << '\n';
}
}
if (step > 0) out << '\n';
if (indent >= step) indent -= step;
for (int i = 0; i < indent; i++)
out << ' ';
out << "]";
}