X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fcxml.cc;h=d3ec9e7fd95f6a27efa9a6eeae6543345cc57da9;hb=5532b044b33f40205c3fed2cd3d1c21dd718507b;hp=77770f93b0fb7ad943de5863cc72a151d79db518;hpb=25e945fa6aab2c3e5e26a806e55e3cba63e4c9ed;p=libcxml.git diff --git a/src/cxml.cc b/src/cxml.cc index 77770f9..d3ec9e7 100644 --- a/src/cxml.cc +++ b/src/cxml.cc @@ -43,7 +43,9 @@ cxml::Node::Node (xmlpp::Node* node) string cxml::Node::name () const { - assert (_node); + if (!_node) { + throw Error ("No node to read name from"); + } return _node->get_name (); } @@ -76,6 +78,9 @@ cxml::Node::optional_node_child (string name) const list > cxml::Node::node_children () const { + if (!_node) { + throw Error ("No node to read children from"); + } xmlpp::Node::NodeList c = _node->get_children (); list > n; @@ -220,7 +225,7 @@ cxml::Node::content () const xmlpp::Node::NodeList c = _node->get_children (); for (xmlpp::Node::NodeList::const_iterator i = c.begin(); i != c.end(); ++i) { xmlpp::ContentNode const * v = dynamic_cast (*i); - if (v) { + if (v && dynamic_cast(v)) { content += v->get_content (); } }