Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CacheChildrenQuery.cs
Go to the documentation of this file.
1using System.Xml;
3
5
6internal sealed class CacheChildrenQuery : ChildrenQuery
7{
9
11
13
14 private bool _needInput;
15
16 public CacheChildrenQuery(Query qyInput, string name, string prefix, XPathNodeType type)
17 : base(qyInput, name, prefix, type)
18 {
21 _needInput = true;
22 }
23
25 : base(other)
26 {
27 _nextInput = Query.Clone(other._nextInput);
28 _elementStk = other._elementStk.Clone();
29 _positionStk = other._positionStk.Clone();
30 _needInput = other._needInput;
31 }
32
33 public override void Reset()
34 {
35 _nextInput = null;
36 _elementStk.Clear();
37 _positionStk.Clear();
38 _needInput = true;
39 base.Reset();
40 }
41
42 public override XPathNavigator Advance()
43 {
44 do
45 {
46 IL_0000:
47 if (_needInput)
48 {
49 if (_elementStk.Count == 0)
50 {
52 if (currentNode == null)
53 {
54 return null;
55 }
57 {
58 goto IL_0000;
59 }
60 position = 0;
61 }
62 else
63 {
66 if (!DecideNextNode())
67 {
68 goto IL_0000;
69 }
70 }
71 _needInput = false;
72 }
73 else if (!currentNode.MoveToNext() || !DecideNextNode())
74 {
75 _needInput = true;
76 goto IL_0000;
77 }
78 }
79 while (!matches(currentNode));
80 position++;
81 return currentNode;
82 }
83
84 private bool DecideNextNode()
85 {
88 {
92 _nextInput = null;
94 {
95 return false;
96 }
97 position = 0;
98 }
99 return true;
100 }
101
103 {
105 if (_nextInput != null)
106 {
108 _nextInput = null;
109 }
110 else
111 {
113 if (xPathNavigator != null)
114 {
116 }
117 }
118 return xPathNavigator;
119 }
120
121 public override XPathNodeIterator Clone()
122 {
123 return new CacheChildrenQuery(this);
124 }
125}
virtual bool matches(XPathNavigator e)
readonly ClonableStack< int > _positionStk
readonly ClonableStack< XPathNavigator > _elementStk
CacheChildrenQuery(Query qyInput, string name, string prefix, XPathNodeType type)
static XmlNodeOrder CompareNodes(XPathNavigator l, XPathNavigator r)
Definition Query.cs:127
XPathNavigator Advance()
static Query Clone(Query input)
Definition Query.cs:66