From 0e12e1b18ae93362c8933714ee86003766abae11 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 28 Apr 2017 19:18:10 +0100 Subject: Upgrade to libxml++3 --- Jamroot.jam | 8 ++++---- project2/xml/Jamfile.jam | 7 ++----- project2/xml/mutators/copy.cpp | 2 +- project2/xml/mutators/copyToAttr.cpp | 4 ++-- project2/xml/mutators/create.cpp | 5 +++-- project2/xml/mutators/delete.cpp | 4 ++-- project2/xml/rawView.cpp | 4 ++-- project2/xml/sessionXml.cpp | 6 +++--- project2/xml/xmlPresenter.cpp | 4 ++-- project2/xml/xmlRawRows.cpp | 2 +- project2/xml/xmlScriptParser.cpp | 6 +++--- 11 files changed, 25 insertions(+), 27 deletions(-) diff --git a/Jamroot.jam b/Jamroot.jam index fc23554..3e015d5 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -38,7 +38,7 @@ build-project slicer ; # Some useful aliases -lib xml++-2.6 ; +lib xml++-3.0 ; lib xml2 ; lib glibmm-2.4 ; lib gobject-2.0 ; @@ -46,8 +46,8 @@ lib glib-2.0 ; lib sigc-2.0 ; alias libxmlpp : : : : - /usr/include/libxml++-2.6 - /usr/lib/libxml++-2.6/include + /usr/include/libxml++-3.0 + /usr/lib/libxml++-3.0/include /usr/include/libxml2 /usr/include/glibmm-2.4 /usr/lib/glibmm-2.4/include @@ -55,7 +55,7 @@ alias libxmlpp : : : : /usr/lib/glib-2.0/include /usr/include/sigc++-2.0 /usr/lib/sigc++-2.0/include - xml++-2.6 + xml++-3.0 xml2 glibmm-2.4 gobject-2.0 diff --git a/project2/xml/Jamfile.jam b/project2/xml/Jamfile.jam index d52bec8..e9bffca 100644 --- a/project2/xml/Jamfile.jam +++ b/project2/xml/Jamfile.jam @@ -1,6 +1,3 @@ -alias libxmlpp : : : : - "`pkg-config --cflags libxml++-2.6`" - "`pkg-config --libs libxml++-2.6`" ; alias libxslt : : : : "`pkg-config --cflags libexslt`" "`pkg-config --libs libexslt`" ; @@ -10,7 +7,7 @@ lib Ice ; lib IceUtil ; cpp-pch pch : pch.hpp : - libxmlpp + ../..//libxmlpp ../common//p2common ; lib p2xml : @@ -18,7 +15,7 @@ lib p2xml : [ glob-tree *.cpp : unittests ] : . - libxmlpp + ../..//libxmlpp ../common//p2common ../url//p2url ..//adhocutil diff --git a/project2/xml/mutators/copy.cpp b/project2/xml/mutators/copy.cpp index c94d76d..a40eaf6 100644 --- a/project2/xml/mutators/copy.cpp +++ b/project2/xml/mutators/copy.cpp @@ -17,7 +17,7 @@ class Copy : public XmlDocMutator { for (xmlpp::Node * t : e->find(to(NULL))) { t->import_node(e); if (delAfter(NULL)) { - e->get_parent()->remove_child(e); + e->get_parent()->remove_node(e); } } } diff --git a/project2/xml/mutators/copyToAttr.cpp b/project2/xml/mutators/copyToAttr.cpp index 6311f1a..a82920b 100644 --- a/project2/xml/mutators/copyToAttr.cpp +++ b/project2/xml/mutators/copyToAttr.cpp @@ -17,9 +17,9 @@ class CopyToAttr : public XmlDocMutator { if (xmlpp::Element * ee = dynamic_cast(e)) { for (xmlpp::Node * t : e->find(to(NULL))) { if (xmlpp::Element * te = dynamic_cast(t)) { - te->set_attribute(e->get_name(), ee->get_child_text()->get_content()); + te->set_attribute(e->get_name(), ee->get_first_child_text()->get_content()); if (delAfter(NULL)) { - e->get_parent()->remove_child(e); + e->get_parent()->remove_node(e); } } } diff --git a/project2/xml/mutators/create.cpp b/project2/xml/mutators/create.cpp index 645914f..6bb7940 100644 --- a/project2/xml/mutators/create.cpp +++ b/project2/xml/mutators/create.cpp @@ -12,8 +12,9 @@ class Create : public XmlDocMutator { } void mutateElement(xmlpp::Element * root) const { - for (xmlpp::Node * e : root->find(xpath(NULL))) { - e->add_child(name(NULL)); + for (xmlpp::Node * n : root->find(xpath(NULL))) { + if (auto e = dynamic_cast(n)) + e->add_child_element(name(NULL)); } } Variable xpath; diff --git a/project2/xml/mutators/delete.cpp b/project2/xml/mutators/delete.cpp index f1c3f61..d14b0ee 100644 --- a/project2/xml/mutators/delete.cpp +++ b/project2/xml/mutators/delete.cpp @@ -11,8 +11,8 @@ class Delete : public XmlDocMutator { } void mutateElement(xmlpp::Element * root) const { - for (xmlpp::Node * e : root->find(xpath(NULL))) { - e->get_parent()->remove_child(e); + for (xmlpp::Node * n : root->find(xpath(NULL))) { + n->get_parent()->remove_node(n); } } Variable xpath; diff --git a/project2/xml/rawView.cpp b/project2/xml/rawView.cpp index e5f7c50..1b0a9f6 100644 --- a/project2/xml/rawView.cpp +++ b/project2/xml/rawView.cpp @@ -35,14 +35,14 @@ class RawViewBase : public View { p->setNamespace(n->get_namespace_prefix(), n->get_namespace_uri()); } p->pushSub(n->get_name(), n->get_namespace_prefix()); - xmlpp::Element::AttributeList al = n->get_attributes(); + auto al = n->get_attributes(); for (const xmlpp::Attribute * a : al) { if (!a->get_namespace_uri().empty()) { p->setNamespace(a->get_namespace_prefix(), a->get_namespace_uri()); } p->addAttribute(a->get_name(), a->get_namespace_prefix(), a->get_value()); } - const xmlpp::Node::NodeList ch = n->get_children(); + auto ch = n->get_children(); for (const xmlpp::Node * c : ch) { if (const xmlpp::Element * e = dynamic_cast(c)) { copyNode(p, e); diff --git a/project2/xml/sessionXml.cpp b/project2/xml/sessionXml.cpp index 403e91a..756f676 100644 --- a/project2/xml/sessionXml.cpp +++ b/project2/xml/sessionXml.cpp @@ -52,7 +52,7 @@ static void appendToXmlNode(xmlpp::Element * sess, const Glib::ustring & name, const VariableType & value) { - xmlpp::Element * v = sess->add_child(name); + xmlpp::Element * v = sess->add_child_element(name); v->add_child_text(value); } @@ -83,8 +83,8 @@ SessionContainerXml::getSession(const boost::uuids::uuid & sid) const SessionPtr s = new Session(sid); for (const xmlpp::Node * n : sess->get_children()) { if (const xmlpp::Element * e = dynamic_cast(n)) { - if (e->get_child_text()) { - s->SetValue(e->get_name(), e->get_child_text()->get_content()); + if (e->get_first_child_text()) { + s->SetValue(e->get_name(), e->get_first_child_text()->get_content()); } else { s->SetValue(e->get_name(), Null()); diff --git a/project2/xml/xmlPresenter.cpp b/project2/xml/xmlPresenter.cpp index 59543e0..f6ada8c 100644 --- a/project2/xml/xmlPresenter.cpp +++ b/project2/xml/xmlPresenter.cpp @@ -127,7 +127,7 @@ XmlPresenter::setNamespace(const Glib::ustring & prefix, const Glib::ustring & n void XmlPresenter::pushSub(const Glib::ustring & name, const Glib::ustring & ns) const { - nodeStack.push_back(nodeStack.back()->add_child(name, ns)); + nodeStack.push_back(nodeStack.back()->add_child_element(name, ns)); } void @@ -234,7 +234,7 @@ void XmlPresenter::addNewArray(const Glib::ustring & name, bool objects) const { if (!objects) { - nodeStack.push_back(nodeStack.back()->add_child(name)); + nodeStack.push_back(nodeStack.back()->add_child_element(name)); } } diff --git a/project2/xml/xmlRawRows.cpp b/project2/xml/xmlRawRows.cpp index 6c3dd3a..cbc3b77 100644 --- a/project2/xml/xmlRawRows.cpp +++ b/project2/xml/xmlRawRows.cpp @@ -70,7 +70,7 @@ void XmlRawRowsBase::execute(const xmlpp::Document * doc, const RowProcessorCall unsigned int col = 0; for (const xmlpp::Node * in : rs.e->get_children()) { if (const xmlpp::Element * ie = dynamic_cast(in)) { - const xmlpp::TextNode * t = ie->get_child_text(); + const xmlpp::TextNode * t = ie->get_first_child_text(); if (t) { rs.fields[col] = VariableType::make(t->get_content(), VariableType::getTypeFromName(ie->get_attribute_value("type", Scripts::scriptNamespacePrefix))); diff --git a/project2/xml/xmlScriptParser.cpp b/project2/xml/xmlScriptParser.cpp index 33b464e..bb4bcb6 100644 --- a/project2/xml/xmlScriptParser.cpp +++ b/project2/xml/xmlScriptParser.cpp @@ -149,7 +149,7 @@ XmlScriptNode::children() const ScriptNodePtr XmlScriptNode::child(const Glib::ustring & n, bool required) const { - const xmlpp::Element::NodeList cs = element->get_children(n); + auto cs = element->get_children(n); if (cs.size() == 1) { if (const xmlpp::Element * c = dynamic_cast(cs.front())) { return new XmlScriptNode(c, script); @@ -183,7 +183,7 @@ XmlScriptNode::variable(const Glib::ustring & n) const if (const xmlpp::Attribute * a = element->get_attribute(n)) { return new VariableLiteral(a->get_value()); } - const xmlpp::Element::NodeList cs = element->get_children(n); + auto cs = element->get_children(n); if (cs.size() == 1) { if (const xmlpp::Element * c = dynamic_cast(cs.front())) { if (const xmlpp::Attribute * source = c->get_attribute("source")) { @@ -218,7 +218,7 @@ XmlScriptNode::applyValue(const Glib::ustring & n, VariableType & val, ExecConte val = a->get_value(); return true; } - const xmlpp::Element::NodeList cs = element->get_children(n); + auto cs = element->get_children(n); if (cs.size() == 1) { if (const xmlpp::Element * c = dynamic_cast(cs.front())) { boost::intrusive_ptr v; -- cgit v1.2.3