From 6597c2306cd1720c87cfebf5f855d0fedff3c585 Mon Sep 17 00:00:00 2001 From: kim Date: Fri, 18 Feb 2011 12:59:13 +0000 Subject: [PATCH] Add auxiliary function to export tag symbol git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/XMLTree@1009 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- XMLTree.h | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/XMLTree.h b/XMLTree.h index 93999a6..90f6b15 100644 --- a/XMLTree.h +++ b/XMLTree.h @@ -228,6 +228,11 @@ public: return TagName->size(); } + int TagsBinaryLength(){ return tags_blen; }; + unsigned int TagStructLength(){ return uint_len(tags_blen,tags_len); }; + unsigned int * TagStruct() { return tags_fix; }; + + /** SubtreeSize(x): the number of nodes (and attributes) in the subtree of * node x. */ int SubtreeSize(treeNode x); @@ -340,7 +345,7 @@ public: treeNode SelectFollowingBelow(treeNode x, TagIdSet * tags, treeNode ancestor); - treeNode TaggedFollowingBefore(treeNode x, TagType tag,treeNode closing); + // treeNode TaggedFollowingBefore(treeNode x, TagType tag,treeNode closing); treeNode SelectFollowingBefore(treeNode x, TagIdSet * tags, treeNode closing); @@ -530,7 +535,10 @@ public: inline TagType Tag(treeNode x) const throw () { if (tags_blen == 8) return (TagType) (((uchar*)tags_fix)[(int) x]); - else { + else + return get_field(tags_fix, tags_blen, x); + /* + { size_t idxlen = x * tags_blen; size_t j = idxlen % W; size_t i = idxlen / W; @@ -540,7 +548,7 @@ public: return (offset2 >= 0) ? ( w << offset2 ) >> offset : ( w >> j) | (tags_fix[i+1] << (W+offset2)) >> offset; - }; + }; */ } @@ -615,7 +623,7 @@ public: return (fast_is_ancestor(Par,x,y) ? y : NULLT); }; - inline treeNode TaggedFollowingBelow(treeNode x, TagType tag,treeNode ancestor) + inline treeNode TaggedFollowingBelow(treeNode x, TagType tag, treeNode ancestor) { treeNode close = fast_find_close(Par, x); treeNode s = tagpos2node(Tags->select_next(tag, close)); @@ -623,6 +631,15 @@ public: if (ancestor == Root() || s == NULLT || s < fast_find_close(Par,ancestor)) return s; else return NULLT; }; + + inline treeNode TaggedFollowingBefore(treeNode x, TagType tag, treeNode ancestor_closing) + { + treeNode close = fast_find_close(Par, x); + treeNode s = tagpos2node(Tags->select_next(tag, close)); + + if (ancestor_closing == Root() || s == NULLT || s < ancestor_closing) return s; + else return NULLT; + }; }; -- 2.17.1