diff options
Diffstat (limited to 'project2/xml/rawView.cpp')
-rw-r--r-- | project2/xml/rawView.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/project2/xml/rawView.cpp b/project2/xml/rawView.cpp new file mode 100644 index 0000000..90569c9 --- /dev/null +++ b/project2/xml/rawView.cpp @@ -0,0 +1,55 @@ +#include "exceptions.h" +#include "rawView.h" +#include "xml.h" +#include "xmlObjectLoader.h" +#include "environment.h" +#include "appEngine.h" +#include <boost/foreach.hpp> +#include <libxml++/nodes/textnode.h> + +DECLARE_LOADER("rawview", RawView); + +RawView::RawView(const xmlpp::Element * p) : + SourceObject(p), + View(p), + copyRoot(p) +{ +} + +void +RawView::loadComplete(const CommonObjects *) +{ +} + +void +RawView::execute(const Presenter * p) const +{ + BOOST_FOREACH(xmlpp::Node * node, copyRoot->get_children()) { + const xmlpp::Element * e = dynamic_cast<const xmlpp::Element *>(node); + if (e) { + copyNode(p, e); + } + } +} + +void +RawView::copyNode(const Presenter * p, const xmlpp::Element * n) const +{ + p->pushSub(n->get_name()); + p->setNamespace(n->get_namespace_prefix(), n->get_namespace_uri()); + xmlpp::Element::AttributeList al = n->get_attributes(); + BOOST_FOREACH(const xmlpp::Attribute * a, al) { + p->addAttr(a->get_name(), a->get_value()); + } + const xmlpp::Node::NodeList ch = n->get_children(); + BOOST_FOREACH(const xmlpp::Node * c, ch) { + if (const xmlpp::Element * e = dynamic_cast<const xmlpp::Element *>(c)) { + copyNode(p, e); + } + else if (const xmlpp::TextNode * t = dynamic_cast<const xmlpp::TextNode *>(c)) { + p->addText(t->get_content()); + } + } + p->popSub(); +} + |