* Modified for Ardour and released under the same terms.
*/
+#include <iostream>
#include "pbd/xml++.h"
#include <libxml/debugXML.h>
#include <libxml/xpath.h>
XMLNode::add_property(const char* n, const string& v)
{
string ns(n);
- if (_propmap.find(ns) != _propmap.end()) {
- remove_property(ns);
+ map<string,XMLProperty*>::iterator iter;
+
+ if ((iter = _propmap.find(ns)) != _propmap.end()) {
+ iter->second->set_value (v);
+ return iter->second;
}
XMLProperty* tmp = new XMLProperty(ns, v);
XMLProperty*
XMLNode::add_property(const char* name, const long value)
{
- static char str[1024];
- snprintf(str, 1024, "%ld", value);
+ char str[64];
+ snprintf(str, sizeof(str), "%ld", value);
return add_property(name, str);
}
return nodes;
}
+/** Dump a node, its properties and children to a stream */
+void
+XMLNode::dump (ostream& s, string p) const
+{
+ s << p << _name << " ";
+ for (XMLPropertyList::const_iterator i = _proplist.begin(); i != _proplist.end(); ++i) {
+ s << (*i)->name() << "=" << (*i)->value() << " ";
+ }
+ s << "\n";
+
+ for (XMLNodeList::const_iterator i = _children.begin(); i != _children.end(); ++i) {
+ (*i)->dump (s, p + " ");
+ }
+}