Add debug() method to dump XML nodes.
authorCarl Hetherington <carl@carlh.net>
Sun, 9 May 2010 00:46:33 +0000 (00:46 +0000)
committerCarl Hetherington <carl@carlh.net>
Sun, 9 May 2010 00:46:33 +0000 (00:46 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7083 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/pbd/pbd/xml++.h
libs/pbd/xml++.cc

index 65ab0f2c03ac4d2eb105f893482678df9d70c8a8..18bb3e013e5dc66e88843a71a66730b5e9a85c79 100644 (file)
@@ -110,6 +110,8 @@ public:
        /** Remove and delete all nodes with property prop matching val */
        void remove_nodes_and_delete(const std::string& propname, const std::string& val);
 
+       void debug (std::ostream &, std::string p = "");
+
 private:
        std::string         _name;
        bool                _is_content;
index 91d169d8bf50353be030e57d39495cb9cf8c80a6..d691b0bd8224687eb1d62bf30ae52490aaf6d8cd 100644 (file)
@@ -5,6 +5,7 @@
  * Modified for Ardour and released under the same terms.
  */
 
+#include <iostream>
 #include "pbd/xml++.h"
 #include <libxml/debugXML.h>
 #include <libxml/xpath.h>
@@ -589,3 +590,17 @@ static XMLSharedNodeList* find_impl(xmlXPathContext* ctxt, const string& xpath)
        return nodes;
 }
 
+/** Dump a node, its properties and children to a stream */
+void
+XMLNode::debug (ostream& s, string p)
+{
+       s << p << _name << " ";
+       for (XMLPropertyList::iterator i = _proplist.begin(); i != _proplist.end(); ++i) {
+               s << (*i)->name() << "=" << (*i)->value() << " ";
+       }
+       s << "\n";
+       
+       for (XMLNodeList::iterator i = _children.begin(); i != _children.end(); ++i) {
+               (*i)->debug (s, p + "  ");
+       }
+}