Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XPathNode.cs
Go to the documentation of this file.
2
4
5internal struct XPathNode
6{
8
9 private ushort _idxSibling;
10
11 private ushort _idxParent;
12
13 private ushort _idxSimilar;
14
15 private ushort _posOffset;
16
17 private uint _props;
18
19 private string _value;
20
21 public XPathNodeType NodeType => (XPathNodeType)((int)_props & 0xF);
22
23 public string Prefix => _info.Prefix;
24
25 public string LocalName => _info.LocalName;
26
27 public string Name
28 {
29 get
30 {
31 if (Prefix.Length == 0)
32 {
33 return LocalName;
34 }
35 return Prefix + ":" + LocalName;
36 }
37 }
38
40
42
43 public string BaseUri => _info.BaseUri ?? string.Empty;
44
45 public int LineNumber => _info.LineNumberBase + (int)((_props & 0xFFFC00) >> 10);
46
47 public int LinePosition => _info.LinePositionBase + _posOffset;
48
49 public int CollapsedLinePosition => LinePosition + (int)(_props >> 24);
50
52
54 {
55 get
56 {
57 string localName = _info.LocalName;
58 if (NodeType == XPathNodeType.Namespace && localName.Length == 3)
59 {
60 return localName == "xml";
61 }
62 return false;
63 }
64 }
65
66 public bool HasSibling => _idxSibling != 0;
67
68 public bool HasCollapsedText => (_props & 0x80) != 0;
69
70 public bool HasAttribute => (_props & 0x10) != 0;
71
72 public bool HasContentChild => (_props & 0x20) != 0;
73
74 public bool HasElementChild => (_props & 0x40) != 0;
75
76 public bool IsAttrNmsp
77 {
78 get
79 {
80 XPathNodeType nodeType = NodeType;
81 if (nodeType != XPathNodeType.Attribute)
82 {
83 return nodeType == XPathNodeType.Namespace;
84 }
85 return true;
86 }
87 }
88
90
92 {
93 get
94 {
95 return (_props & 0x200) != 0;
96 }
97 set
98 {
99 if (value)
100 {
101 _props |= 512u;
102 }
103 else
104 {
105 _props &= 255u;
106 }
107 }
108 }
109
110 public bool AllowShortcutTag => (_props & 0x100) != 0;
111
113
114 public string Value => _value;
115
116 public int GetRoot(out XPathNode[] pageNode)
117 {
118 return _info.Document.GetRootNode(out pageNode);
119 }
120
121 public int GetParent(out XPathNode[] pageNode)
122 {
123 pageNode = _info.ParentPage;
124 return _idxParent;
125 }
126
127 public int GetSibling(out XPathNode[] pageNode)
128 {
129 pageNode = _info.SiblingPage;
130 return _idxSibling;
131 }
132
133 public int GetSimilarElement(out XPathNode[] pageNode)
134 {
135 pageNode = _info.SimilarElementPage;
136 return _idxSimilar;
137 }
138
139 public bool NameMatch(string localName, string namespaceName)
140 {
141 if ((object)_info.LocalName == localName)
142 {
143 return _info.NamespaceUri == namespaceName;
144 }
145 return false;
146 }
147
148 public bool ElementMatch(string localName, string namespaceName)
149 {
150 if (NodeType == XPathNodeType.Element && (object)_info.LocalName == localName)
151 {
152 return _info.NamespaceUri == namespaceName;
153 }
154 return false;
155 }
156
157 public void Create(XPathNodePageInfo pageInfo)
158 {
159 _info = new XPathNodeInfoAtom(pageInfo);
160 }
161
162 public void Create(XPathNodeInfoAtom info, XPathNodeType xptyp, int idxParent)
163 {
164 _info = info;
165 _props = (uint)xptyp;
166 _idxParent = (ushort)idxParent;
167 }
168
169 public void SetLineInfoOffsets(int lineNumOffset, int linePosOffset)
170 {
171 _props |= (uint)(lineNumOffset << 10);
172 _posOffset = (ushort)linePosOffset;
173 }
174
175 public void SetCollapsedLineInfoOffset(int posOffset)
176 {
177 _props |= (uint)(posOffset << 24);
178 }
179
180 public void SetValue(string value)
181 {
182 _value = value;
183 }
184
185 public void SetEmptyValue(bool allowShortcutTag)
186 {
187 _value = string.Empty;
188 if (allowShortcutTag)
189 {
190 _props |= 256u;
191 }
192 }
193
194 public void SetCollapsedValue(string value)
195 {
196 _value = value;
197 _props |= 160u;
198 }
199
201 {
202 if (xptyp == XPathNodeType.Attribute)
203 {
204 _props |= 16u;
205 return;
206 }
207 _props |= 32u;
208 if (xptyp == XPathNodeType.Element)
209 {
210 _props |= 64u;
211 }
212 }
213
214 public void SetSibling(XPathNodeInfoTable infoTable, XPathNode[] pageSibling, int idxSibling)
215 {
216 _idxSibling = (ushort)idxSibling;
217 if (pageSibling != _info.SiblingPage)
218 {
220 }
221 }
222
223 public void SetSimilarElement(XPathNodeInfoTable infoTable, XPathNode[] pageSimilar, int idxSimilar)
224 {
225 _idxSimilar = (ushort)idxSimilar;
226 if (pageSimilar != _info.SimilarElementPage)
227 {
229 }
230 }
231}
XPathNodeInfoAtom Create(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase)
int GetRootNode(out XPathNode[] pageRoot)
static bool IsText(XPathNodeType type)
void SetEmptyValue(bool allowShortcutTag)
Definition XPathNode.cs:185
void Create(XPathNodeInfoAtom info, XPathNodeType xptyp, int idxParent)
Definition XPathNode.cs:162
void SetCollapsedValue(string value)
Definition XPathNode.cs:194
XPathNodePageInfo PageInfo
Definition XPathNode.cs:51
void SetValue(string value)
Definition XPathNode.cs:180
void SetSibling(XPathNodeInfoTable infoTable, XPathNode[] pageSibling, int idxSibling)
Definition XPathNode.cs:214
void SetLineInfoOffsets(int lineNumOffset, int linePosOffset)
Definition XPathNode.cs:169
void Create(XPathNodePageInfo pageInfo)
Definition XPathNode.cs:157
int GetParent(out XPathNode[] pageNode)
Definition XPathNode.cs:121
int GetRoot(out XPathNode[] pageNode)
Definition XPathNode.cs:116
int GetSibling(out XPathNode[] pageNode)
Definition XPathNode.cs:127
int GetSimilarElement(out XPathNode[] pageNode)
Definition XPathNode.cs:133
void SetSimilarElement(XPathNodeInfoTable infoTable, XPathNode[] pageSimilar, int idxSimilar)
Definition XPathNode.cs:223
bool ElementMatch(string localName, string namespaceName)
Definition XPathNode.cs:148
void SetParentProperties(XPathNodeType xptyp)
Definition XPathNode.cs:200
void SetCollapsedLineInfoOffset(int posOffset)
Definition XPathNode.cs:175
XPathNodeInfoAtom _info
Definition XPathNode.cs:7
bool NameMatch(string localName, string namespaceName)
Definition XPathNode.cs:139