summaryrefslogtreecommitdiff
path: root/project2/xmlObjectLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/xmlObjectLoader.cpp')
-rw-r--r--project2/xmlObjectLoader.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/project2/xmlObjectLoader.cpp b/project2/xmlObjectLoader.cpp
new file mode 100644
index 0000000..1eb85f9
--- /dev/null
+++ b/project2/xmlObjectLoader.cpp
@@ -0,0 +1,32 @@
+#include "xmlObjectLoader.h"
+
+_LoaderBase::_LoaderBase()
+{
+}
+_LoaderBase::~_LoaderBase()
+{
+}
+
+void
+_LoaderBase::collectAll(const Loaders & ls, const Glib::ustring & ns, const xmlpp::Element * node, bool recursive, bool childrenOnly)
+{
+ if (!node) {
+ return;
+ }
+ if (!childrenOnly && ns == node->get_namespace_prefix()) {
+ Glib::ustring name = node->get_name();
+ unsigned int created = 0;
+ for(Loaders::const_iterator i = ls.lower_bound(name); i != ls.upper_bound(name); i++) {
+ i->second->go(node);
+ created += 1;
+ }
+ if (created < 1) {
+ fprintf(stderr, "Didn't create any objects for %s:%s\n", ns.c_str(), name.c_str());
+ }
+ }
+ else if (recursive || childrenOnly) {
+ BOOST_FOREACH(xmlpp::Node * child, node->get_children()) {
+ collectAll(ls, ns, dynamic_cast<const xmlpp::Element *>(child), recursive, false);
+ }
+ }
+}