//
void
-Kumu::XMLElement::Render(std::string& outbuf) const
+Kumu::XMLElement::Render(std::string& outbuf, const bool& pretty) const
{
outbuf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
- RenderElement(outbuf, 0);
+ RenderElement(outbuf, 0, pretty);
}
//
//
void
-Kumu::XMLElement::RenderElement(std::string& outbuf, ui32_t depth) const
+Kumu::XMLElement::RenderElement(std::string& outbuf, const ui32_t& depth, const bool& pretty) const
{
- add_spacer(outbuf, depth);
+ if ( pretty )
+ {
+ add_spacer(outbuf, depth);
+ }
outbuf += "<";
outbuf += m_Name;
// render attributes
- for ( Attr_i i = m_AttrList.begin(); i != m_AttrList.end(); i++ )
+ for ( Attr_i i = m_AttrList.begin(); i != m_AttrList.end(); ++i )
{
outbuf += " ";
outbuf += (*i).name;
// render body
if ( m_Body.length() > 0 )
- outbuf += m_Body;
+ {
+ outbuf += m_Body;
+ }
- for ( Elem_i i = m_ChildList.begin(); i != m_ChildList.end(); i++ )
- (*i)->RenderElement(outbuf, depth + 1);
+ for ( Elem_i i = m_ChildList.begin(); i != m_ChildList.end(); ++i )
+ {
+ (*i)->RenderElement(outbuf, depth + 1, pretty);
+ }
- add_spacer(outbuf, depth);
+ if ( pretty )
+ {
+ add_spacer(outbuf, depth);
+ }
}
else if ( m_Body.length() > 0 )
{
XMLElement* AddChildWithContent(const char* name, const std::string& value);
XMLElement* AddChildWithPrefixedContent(const char* name, const char* prefix, const char* value);
void AddComment(const char* value);
- void Render(std::string&) const;
- void RenderElement(std::string& outbuf, ui32_t depth) const;
+ void Render(std::string& str) const { Render(str, true); }
+ void Render(std::string&, const bool& pretty) const;
+ void RenderElement(std::string& outbuf, const ui32_t& depth, const bool& pretty) const;
// querying
inline const std::string& GetBody() const { return m_Body; }