Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
BaseAxisQuery.cs
Go to the documentation of this file.
3
5
6internal abstract class BaseAxisQuery : Query
7{
8 internal Query qyInput;
9
10 private readonly bool _nameTest;
11
12 private readonly string _name;
13
14 private readonly string _prefix;
15
16 private string _nsUri;
17
18 private readonly XPathNodeType _typeTest;
19
21
22 protected int position;
23
24 protected string Name => _name;
25
26 protected string Namespace => _nsUri;
27
28 protected bool NameTest => _nameTest;
29
31
32 public override int CurrentPosition => position;
33
35
36 public override double XsltDefaultPriority
37 {
38 get
39 {
40 if (qyInput.GetType() != typeof(ContextQuery))
41 {
42 return 0.5;
43 }
44 if (_name.Length != 0)
45 {
46 return 0.0;
47 }
48 if (_prefix.Length != 0)
49 {
50 return -0.25;
51 }
52 return -0.5;
53 }
54 }
55
56 public override XPathResultType StaticType => XPathResultType.NodeSet;
57
59 {
60 _name = string.Empty;
61 _prefix = string.Empty;
62 _nsUri = string.Empty;
63 this.qyInput = qyInput;
64 }
65
66 protected BaseAxisQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest)
67 {
68 this.qyInput = qyInput;
69 _name = name;
70 _prefix = prefix;
71 _typeTest = typeTest;
72 _nameTest = prefix.Length != 0 || name.Length != 0;
73 _nsUri = string.Empty;
74 }
75
77 : base(other)
78 {
79 qyInput = Query.Clone(other.qyInput);
80 _name = other._name;
81 _prefix = other._prefix;
82 _nsUri = other._nsUri;
83 _typeTest = other._typeTest;
84 _nameTest = other._nameTest;
85 position = other.position;
86 currentNode = other.currentNode;
87 }
88
89 public override void Reset()
90 {
91 position = 0;
92 currentNode = null;
93 qyInput.Reset();
94 }
95
96 public override void SetXsltContext(XsltContext context)
97 {
99 qyInput.SetXsltContext(context);
100 }
101
102 public virtual bool matches(XPathNavigator e)
103 {
104 if (TypeTest == e.NodeType || TypeTest == XPathNodeType.All || (TypeTest == XPathNodeType.Text && (e.NodeType == XPathNodeType.Whitespace || e.NodeType == XPathNodeType.SignificantWhitespace)))
105 {
106 if (!NameTest)
107 {
108 return true;
109 }
110 if ((_name.Equals(e.LocalName) || _name.Length == 0) && _nsUri.Equals(e.NamespaceURI))
111 {
112 return true;
113 }
114 }
115 return false;
116 }
117
118 public override object Evaluate(XPathNodeIterator nodeIterator)
119 {
120 ResetCount();
121 Reset();
122 qyInput.Evaluate(nodeIterator);
123 return this;
124 }
125}
override XPathResultType StaticType
virtual bool matches(XPathNavigator e)
override void SetXsltContext(XsltContext context)
BaseAxisQuery(Query qyInput, string name, string prefix, XPathNodeType typeTest)
override XPathNavigator Current
readonly XPathNodeType _typeTest
override object Evaluate(XPathNodeIterator nodeIterator)
object Evaluate(XPathNodeIterator nodeIterator)
virtual void SetXsltContext(XsltContext context)
Definition Query.cs:52
static Query Clone(Query input)
Definition Query.cs:66
virtual ? string LookupNamespace(string prefix)