Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PrecedingQuery.cs
Go to the documentation of this file.
2
4
5internal sealed class PrecedingQuery : BaseAxisQuery
6{
8
10
11 public override QueryProps Properties => base.Properties | QueryProps.Reverse;
12
13 public PrecedingQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest)
14 : base(qyInput, name, prefix, typeTest)
15 {
17 }
18
20 : base(other)
21 {
22 _workIterator = Query.Clone(other._workIterator);
23 _ancestorStk = other._ancestorStk.Clone();
24 }
25
26 public override void Reset()
27 {
28 _workIterator = null;
29 _ancestorStk.Clear();
30 base.Reset();
31 }
32
33 public override XPathNavigator Advance()
34 {
35 if (_workIterator == null)
36 {
37 XPathNavigator xPathNavigator = qyInput.Advance();
38 if (xPathNavigator == null)
39 {
40 return null;
41 }
42 XPathNavigator xPathNavigator2 = xPathNavigator.Clone();
43 do
44 {
45 xPathNavigator2.MoveTo(xPathNavigator);
46 }
47 while ((xPathNavigator = qyInput.Advance()) != null);
48 if (xPathNavigator2.NodeType == XPathNodeType.Attribute || xPathNavigator2.NodeType == XPathNodeType.Namespace)
49 {
50 xPathNavigator2.MoveToParent();
51 }
52 do
53 {
54 _ancestorStk.Push(xPathNavigator2.Clone());
55 }
56 while (xPathNavigator2.MoveToParent());
57 _workIterator = xPathNavigator2.SelectDescendants(XPathNodeType.All, matchSelf: true);
58 }
59 while (_workIterator.MoveNext())
60 {
63 {
65 if (_ancestorStk.Count == 0)
66 {
67 currentNode = null;
68 _workIterator = null;
69 return null;
70 }
71 }
72 else if (matches(currentNode))
73 {
74 position++;
75 return currentNode;
76 }
77 }
78 return null;
79 }
80
81 public override XPathNodeIterator Clone()
82 {
83 return new PrecedingQuery(this);
84 }
85}
virtual bool matches(XPathNavigator e)
PrecedingQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest)
override XPathNavigator Advance()
override XPathNodeIterator Clone()
readonly ClonableStack< XPathNavigator > _ancestorStk
XPathNavigator Advance()
static Query Clone(Query input)
Definition Query.cs:66
bool MoveTo(XPathNavigator other)
bool IsSamePosition(XPathNavigator other)
virtual XPathNodeIterator SelectDescendants(XPathNodeType type, bool matchSelf)