#ifndef XML_TREE_INC_HPP_
#define XML_TREE_INC_HPP_
+#include <cstdio>
+
inline uint32_t xml_tree::size() const
{
return tag_seq_len / 2;
return !bp_inspect(this->par, x+1);
}
+inline bool xml_tree::is_open(xml_tree::node_t x) const
+{
+ return bp_inspect(this->par, x);
+}
+
inline bool xml_tree::is_ancestor(xml_tree::node_t x,
xml_tree::node_t y) const
{
inline xml_tree::node_t xml_tree::first_child(node_t x) const
{
- return bp_first_child(this->par, x);
+ xml_tree::node_t result = bp_first_child(this->par, x);
+ return result;
}
inline xml_tree::node_t xml_tree::last_child(xml_tree::node_t x) const
inline xml_tree::node_t xml_tree::next_sibling(xml_tree::node_t x) const
{
- return bp_next_sibling(this->par, x);
+ xml_tree::node_t result = bp_next_sibling(this->par, x);
+ return result;
}
inline xml_tree::node_t xml_tree::prev_sibling(xml_tree::node_t x) const
case PCDATA_OPEN_TAG_ID:
n = n + 2;
return bp_inspect(this->par, n) ? n : xml_tree::NIL;
+ default:
+ return n;
};
}
xml_tree::tag_t t) const
{
xml_tree::node_t c = first_child(x);
+ xml_tree::node_t result;
if (is_nil(c) || tag(c) == t)
return c;
else
- tagged_sibling(c, t);
+ return tagged_sibling(c, t);
}
inline xml_tree::node_t xml_tree::tagged_sibling(xml_tree::node_t x,
xml_tree::tag_t t) const
{
xml_tree::node_t sibling = next_sibling(x);
- while(!is_nil(sibling) && tag(sibling) != t) sibling = next_sibling(sibling);
+ xml_tree::tag_t stag;
+ while (sibling != xml_tree::NIL) {
+ stag = tag(sibling);
+ if (stag == t)
+ return sibling;
+ sibling = next_sibling(sibling);
+ };
return sibling;
}