From dbcf32baf0af10eeaac33460dd617bf1de3075ca Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 8 Jan 2021 14:09:08 +0100 Subject: Use std::vector instead of std::list. --- src/cxml.cc | 12 ++++++------ src/cxml.h | 8 ++++---- test/tests.cc | 5 ++--- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/cxml.cc b/src/cxml.cc index 356e1df..c21bd19 100644 --- a/src/cxml.cc +++ b/src/cxml.cc @@ -24,9 +24,9 @@ #include #include -using std::string; -using std::list; using std::shared_ptr; +using std::string; +using std::vector; using boost::optional; cxml::Node::Node () @@ -76,14 +76,14 @@ cxml::Node::optional_node_child (string name) const return n.front (); } -list> +vector> cxml::Node::node_children () const { if (!_node) { throw Error ("No node to read children from"); } - list > n; + vector > n; for (auto i: _node->get_children()) { n.push_back (shared_ptr (new Node (i))); } @@ -91,14 +91,14 @@ cxml::Node::node_children () const return n; } -list> +vector> cxml::Node::node_children (string name) const { /* XXX: using find / get_path should work here, but I can't follow how get_path works. */ - list > n; + vector > n; for (auto i: _node->get_children()) { if (i->get_name() == name) { n.push_back (shared_ptr (new Node (i))); diff --git a/src/cxml.h b/src/cxml.h index 2bdde74..4fccbae 100644 --- a/src/cxml.h +++ b/src/cxml.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include /* Hack for OS X compile failure; see https://bugs.launchpad.net/hugin/+bug/910160 */ #ifdef check @@ -223,8 +223,8 @@ public: std::shared_ptr node_child (std::string) const; std::shared_ptr optional_node_child (std::string) const; - std::list > node_children () const; - std::list > node_children (std::string) const; + std::vector> node_children () const; + std::vector> node_children (std::string) const; xmlpp::Node* node () const { return _node; @@ -234,7 +234,7 @@ protected: xmlpp::Node* _node; private: - mutable std::list _taken; + mutable std::vector _taken; }; typedef std::shared_ptr NodePtr; diff --git a/test/tests.cc b/test/tests.cc index 6867ac0..633aaa2 100644 --- a/test/tests.cc +++ b/test/tests.cc @@ -27,10 +27,9 @@ #define BOOST_TEST_MODULE libcxml_test #include +using std::shared_ptr; using std::string; using std::vector; -using std::list; -using std::shared_ptr; BOOST_AUTO_TEST_CASE (test) { @@ -68,7 +67,7 @@ BOOST_AUTO_TEST_CASE (test) BOOST_CHECK (!document.optional_bool_child("G")); - list > h = document.node_children ("H"); + vector> h = document.node_children ("H"); BOOST_CHECK_EQUAL (h.size(), 1); BOOST_CHECK_EQUAL (h.front()->node_children("I").size(), 2); BOOST_CHECK_EQUAL (h.front()->node_children("I").front()->content(), "testing"); -- cgit v1.2.3