zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #05738
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
Ghislain Fourny has proposed merging lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba.
Requested reviews:
Markos Zaharioudakis (markos-za)
Matthias Brantner (matthias-brantner)
For more details, see:
https://code.launchpad.net/~28msec/zorba/get-descendant-node-by-ordpath/+merge/95902
Introduced function OrdPathNode::getDescendantNodeByOrdPath (from Sausalito).
--
https://code.launchpad.net/~28msec/zorba/get-descendant-node-by-ordpath/+merge/95902
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/store/naive/node_items.cpp'
--- src/store/naive/node_items.cpp 2012-03-02 13:50:06 +0000
+++ src/store/naive/node_items.cpp 2012-03-05 14:06:21 +0000
@@ -1052,6 +1052,118 @@
}
}
+/*******************************************************************************
+
+********************************************************************************/
+bool
+OrdPathNode::getDescendantNodeByOrdPath(
+ const OrdPath& aOrdPath,
+ store::Item_t& aResult,
+ bool aAttribute) const
+{
+#ifdef TEXT_ORDPATH
+ if (getOrdPath() == aOrdPath)
+ {
+ aResult = this;
+ return true;
+ }
+#else
+ if (getNodeKind() == store::StoreConsts::textNode)
+ {
+ aResult = NULL;
+ return false;
+ }
+ else if (getOrdPath() == aOrdPath)
+ {
+ aResult = this;
+ return true;
+ }
+#endif
+
+ const XmlNode* parent = static_cast<const XmlNode*>(this);
+ while (1)
+ {
+ ulong i;
+
+ if (parent->getNodeKind() != store::StoreConsts::documentNode &&
+ parent->getNodeKind() != store::StoreConsts::elementNode)
+ {
+ aResult = NULL;
+ return false;
+ }
+
+ if (aAttribute && parent->getNodeKind() == store::StoreConsts::elementNode)
+ {
+ const ElementNode* elemParent = reinterpret_cast<const ElementNode*>(parent);
+
+ ulong numAttrs = elemParent->numAttrs();
+ for (i = 0; i < numAttrs; i++)
+ {
+ AttributeNode* child = elemParent->getAttr(i);
+
+ OrdPath::RelativePosition pos = child->getOrdPath().getRelativePosition(aOrdPath);
+
+ if (pos == OrdPath::SELF)
+ {
+ aResult = child;
+ return true;
+ }
+ else if (pos == OrdPath::DESCENDANT)
+ {
+ parent = child;
+ break;
+ }
+ else if (pos != OrdPath::FOLLOWING)
+ {
+ aResult = NULL;
+ return false;
+ }
+ }
+ }
+
+ const InternalNode* this2 = reinterpret_cast<const InternalNode*>(parent);
+
+ ulong numChildren = this2->numChildren();
+ for (i = 0; i < numChildren; i++)
+ {
+#ifdef TEXT_ORDPATH
+ OrdPathNode* child = static_cast<OrdPathNode*>(this2->getChild(i));
+#else
+ XmlNode* c = this2->getChild(i);
+
+ if (c->getNodeKind() == store::StoreConsts::textNode)
+ continue;
+
+ OrdPathNode* child = static_cast<OrdPathNode*>(c);
+#endif
+
+ OrdPath::RelativePosition pos = child->getOrdPath().getRelativePosition(aOrdPath);
+
+ if (pos == OrdPath::SELF)
+ {
+ aResult = child;
+ return true;
+ }
+ else if (pos == OrdPath::DESCENDANT)
+ {
+ parent = child;
+ break;
+ }
+ else if (pos != OrdPath::FOLLOWING)
+ {
+ aResult = NULL;
+ return false;
+ }
+ }
+
+ if (i == numChildren)
+ {
+ aResult = NULL;
+ return false;
+ }
+ }
+}
+
/*******************************************************************************
Return true if "aOther" is an ancestore of "this".
=== modified file 'src/store/naive/node_items.h'
--- src/store/naive/node_items.h 2012-03-02 13:50:06 +0000
+++ src/store/naive/node_items.h 2012-03-05 14:06:21 +0000
@@ -664,6 +664,15 @@
csize pos,
store::StoreConsts::NodeKind nodeKind);
+ // Looks for a descendant node with the ordpath aOrdPath and puts it into the
+ // aResult variable. aAttribute specifies whether to look for an attribute or
+ // not.
+ bool
+ getDescendantNodeByOrdPath(
+ const OrdPath& aOrdPath,
+ store::Item_t& aResult,
+ bool aAttribute = false) const;
+
virtual bool
isAncestor(const store::Item_t&) const;
Follow ups
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: noreply, 2012-03-13
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Zorba Build Bot, 2012-03-13
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Zorba Build Bot, 2012-03-13
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Markos Zaharioudakis, 2012-03-13
-
Re: [Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Zorba Build Bot, 2012-03-13
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Zorba Build Bot, 2012-03-13
-
Re: [Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Ghislain Fourny, 2012-03-13
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Ghislain Fourny, 2012-03-13
-
Re: [Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Markos Zaharioudakis, 2012-03-12
-
Re: [Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Ghislain Fourny, 2012-03-12
-
Re: [Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Markos Zaharioudakis, 2012-03-07
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Zorba Build Bot, 2012-03-05
-
Re: [Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Zorba Build Bot, 2012-03-05
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Zorba Build Bot, 2012-03-05
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Zorba Build Bot, 2012-03-05
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Matthias Brantner, 2012-03-05
-
Re: [Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Matthias Brantner, 2012-03-05
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Zorba Build Bot, 2012-03-05
-
Re: [Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Zorba Build Bot, 2012-03-05
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Zorba Build Bot, 2012-03-05
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Zorba Build Bot, 2012-03-05
-
[Merge] lp:~28msec/zorba/get-descendant-node-by-ordpath into lp:zorba
From: Ghislain Fourny, 2012-03-05