projects
/
asdcplib.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4dcacd5
)
allow suppression of xml formatting spaces
author
jhurst
<jhurst@cinecert.com>
Thu, 5 Dec 2013 01:35:52 +0000
(
01:35
+0000)
committer
jhurst
<>
Thu, 5 Dec 2013 01:35:52 +0000
(
01:35
+0000)
src/KM_xml.cpp
patch
|
blob
|
history
src/KM_xml.h
patch
|
blob
|
history
diff --git
a/src/KM_xml.cpp
b/src/KM_xml.cpp
index 8f41f9c07c38250edc90c0139b208548cba596ea..121f0a6ad02437d1a17b3b81dc596a51387e2f8a 100644
(file)
--- a/
src/KM_xml.cpp
+++ b/
src/KM_xml.cpp
@@
-186,10
+186,10
@@
Kumu::XMLElement::AddComment(const char* value)
//
void
//
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";
{
outbuf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
- RenderElement(outbuf, 0);
+ RenderElement(outbuf, 0
, pretty
);
}
//
}
//
@@
-202,15
+202,18
@@
add_spacer(std::string& outbuf, i32_t depth)
//
void
//
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
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;
{
outbuf += " ";
outbuf += (*i).name;
@@
-228,12
+231,19
@@
Kumu::XMLElement::RenderElement(std::string& outbuf, ui32_t depth) const
// render body
if ( m_Body.length() > 0 )
// 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 )
{
}
else if ( m_Body.length() > 0 )
{
diff --git
a/src/KM_xml.h
b/src/KM_xml.h
index 80db74babd9d729c009229390900e032aa63d606..5d499e5f2c1e501a5aabf53c486373281d761a87 100644
(file)
--- a/
src/KM_xml.h
+++ b/
src/KM_xml.h
@@
-112,8
+112,9
@@
namespace Kumu
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);
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; }
// querying
inline const std::string& GetBody() const { return m_Body; }