14
|
1 /**
|
|
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
|
|
3 * Authors: Jacob Carlborg
|
|
4 * Version: Initial created: Aug 3, 2009
|
|
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
|
|
6 */
|
|
7 module dstep.foundation.NSXMLNode;
|
|
8
|
|
9 import dstep.foundation.NSArray;
|
|
10 import dstep.foundation.NSDictionary;
|
|
11 import dstep.foundation.NSError;
|
|
12 import dstep.foundation.NSObject;
|
|
13 import dstep.foundation.NSString;
|
|
14 import dstep.foundation.NSURL;
|
|
15 import dstep.foundation.NSXMLDocument;
|
|
16 import dstep.foundation.NSXMLElement;
|
|
17 import dstep.foundation.NSXMLNodeOptions;
|
|
18 import dstep.objc.bridge.Bridge;
|
|
19 import dstep.objc.objc : id;
|
|
20
|
|
21 alias NSUInteger NSXMLNodeKind;
|
|
22
|
|
23 enum
|
|
24 {
|
|
25 NSXMLInvalidKind = 0,
|
|
26 NSXMLDocumentKind,
|
|
27 NSXMLElementKind,
|
|
28 NSXMLAttributeKind,
|
|
29 NSXMLNamespaceKind,
|
|
30 NSXMLProcessingInstructionKind,
|
|
31 NSXMLCommentKind,
|
|
32 NSXMLTextKind,
|
|
33 NSXMLDTDKind,
|
|
34 NSXMLEntityDeclarationKind,
|
|
35 NSXMLAttributeDeclarationKind,
|
|
36 NSXMLElementDeclarationKind,
|
|
37 NSXMLNotationDeclarationKind
|
|
38 }
|
|
39
|
|
40 class NSXMLNode : NSObject, INSCopying
|
|
41 {
|
|
42 mixin ObjcWrap;
|
|
43
|
|
44 Object initWithKind (uint kind)
|
|
45 {
|
|
46 return invokeObjcSelf!(Object, "initWithKind:", uint)(kind);
|
|
47 }
|
|
48
|
|
49 this (uint kind)
|
|
50 {
|
|
51 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
52 id result = Bridge.invokeObjcMethod!(id, "initWithKind:", uint)(objcObject, kind);
|
|
53
|
|
54 if (result)
|
|
55 objcObject = ret;
|
|
56
|
|
57 dObject = this;
|
|
58 }
|
|
59
|
|
60 Object initWithKind (uint kind, NSUInteger options)
|
|
61 {
|
|
62 return invokeObjcSelf!(Object, "initWithKind:options:", uint, NSUInteger)(kind, options);
|
|
63 }
|
|
64
|
|
65 this (uint kind, NSUInteger options)
|
|
66 {
|
|
67 objcObject = Bridge.invokeObjcClassMethod!(id, "alloc")(objcClass);
|
|
68 id result = Bridge.invokeObjcMethod!(id, "initWithKind:options:", uint, NSUInteger)(objcObject, kind, options);
|
|
69
|
|
70 if (result)
|
|
71 objcObject = ret;
|
|
72
|
|
73 dObject = this;
|
|
74 }
|
|
75
|
|
76 static Object document ()
|
|
77 {
|
|
78 return invokeObjcSelfClass!(Object, "document");
|
|
79 }
|
|
80
|
|
81 static Object documentWithRootElement (NSXMLElement element)
|
|
82 {
|
|
83 return invokeObjcSelfClass!(Object, "documentWithRootElement:", NSXMLElement)(element);
|
|
84 }
|
|
85
|
|
86 static Object elementWithName (NSString name)
|
|
87 {
|
|
88 return invokeObjcSelfClass!(Object, "elementWithName:", NSString)(name);
|
|
89 }
|
|
90
|
|
91 static Object elementWithName (NSString name, NSString URI)
|
|
92 {
|
|
93 return invokeObjcSelfClass!(Object, "elementWithName:URI:", NSString, NSString)(name, URI);
|
|
94 }
|
|
95
|
|
96 static Object elementWithName (NSString name, NSString string)
|
|
97 {
|
|
98 return invokeObjcSelfClass!(Object, "elementWithName:stringValue:", NSString, NSString)(name, string);
|
|
99 }
|
|
100
|
|
101 static Object elementWithName (NSString name, NSArray children, NSArray attributes)
|
|
102 {
|
|
103 return invokeObjcSelfClass!(Object, "elementWithName:children:attributes:", NSString, NSArray, NSArray)(name, children, attributes);
|
|
104 }
|
|
105
|
|
106 static Object attributeWithName (NSString name, NSString stringValue)
|
|
107 {
|
|
108 return invokeObjcSelfClass!(Object, "attributeWithName:stringValue:", NSString, NSString)(name, stringValue);
|
|
109 }
|
|
110
|
|
111 static Object attributeWithName (NSString name, NSString URI, NSString stringValue)
|
|
112 {
|
|
113 return invokeObjcSelfClass!(Object, "attributeWithName:URI:stringValue:", NSString, NSString, NSString)(name, URI, stringValue);
|
|
114 }
|
|
115
|
|
116 static Object namespaceWithName (NSString name, NSString stringValue)
|
|
117 {
|
|
118 return invokeObjcSelfClass!(Object, "namespaceWithName:stringValue:", NSString, NSString)(name, stringValue);
|
|
119 }
|
|
120
|
|
121 static Object processingInstructionWithName (NSString name, NSString stringValue)
|
|
122 {
|
|
123 return invokeObjcSelfClass!(Object, "processingInstructionWithName:stringValue:", NSString, NSString)(name, stringValue);
|
|
124 }
|
|
125
|
|
126 static Object commentWithStringValue (NSString stringValue)
|
|
127 {
|
|
128 return invokeObjcSelfClass!(Object, "commentWithStringValue:", NSString)(stringValue);
|
|
129 }
|
|
130
|
|
131 static Object textWithStringValue (NSString stringValue)
|
|
132 {
|
|
133 return invokeObjcSelfClass!(Object, "textWithStringValue:", NSString)(stringValue);
|
|
134 }
|
|
135
|
|
136 static Object DTDNodeWithXMLString (NSString string)
|
|
137 {
|
|
138 return invokeObjcSelfClass!(Object, "DTDNodeWithXMLString:", NSString)(string);
|
|
139 }
|
|
140
|
|
141 uint kind ()
|
|
142 {
|
|
143 return invokeObjcSelf!(uint, "kind");
|
|
144 }
|
|
145
|
|
146 void setName (NSString name)
|
|
147 {
|
|
148 return invokeObjcSelf!(void, "setName:", NSString)(name);
|
|
149 }
|
|
150
|
|
151 NSString name ()
|
|
152 {
|
|
153 return invokeObjcSelf!(NSString, "name");
|
|
154 }
|
|
155
|
|
156 void setObjectValue (Object value)
|
|
157 {
|
|
158 return invokeObjcSelf!(void, "setObjectValue:", Object)(value);
|
|
159 }
|
|
160
|
|
161 Object objectValue ()
|
|
162 {
|
|
163 return invokeObjcSelf!(Object, "objectValue");
|
|
164 }
|
|
165
|
|
166 void setStringValue (NSString string)
|
|
167 {
|
|
168 return invokeObjcSelf!(void, "setStringValue:", NSString)(string);
|
|
169 }
|
|
170
|
|
171 void setStringValue (NSString string, bool resolve)
|
|
172 {
|
|
173 return invokeObjcSelf!(void, "setStringValue:resolvingEntities:", NSString, bool)(string, resolve);
|
|
174 }
|
|
175
|
|
176 NSString stringValue ()
|
|
177 {
|
|
178 return invokeObjcSelf!(NSString, "stringValue");
|
|
179 }
|
|
180
|
|
181 NSUInteger index ()
|
|
182 {
|
|
183 return invokeObjcSelf!(NSUInteger, "index");
|
|
184 }
|
|
185
|
|
186 NSUInteger level ()
|
|
187 {
|
|
188 return invokeObjcSelf!(NSUInteger, "level");
|
|
189 }
|
|
190
|
|
191 NSXMLDocument rootDocument ()
|
|
192 {
|
|
193 return invokeObjcSelf!(NSXMLDocument, "rootDocument");
|
|
194 }
|
|
195
|
|
196 NSXMLNode parent ()
|
|
197 {
|
|
198 id result = invokeObjcSelf!(id, "parent"return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null); }
|
|
199
|
|
200 NSUInteger childCount ()
|
|
201 {
|
|
202 return invokeObjcSelf!(NSUInteger, "childCount");
|
|
203 }
|
|
204
|
|
205 NSArray children ()
|
|
206 {
|
|
207 return invokeObjcSelf!(NSArray, "children");
|
|
208 }
|
|
209
|
|
210 NSXMLNode childAtIndex (NSUInteger index)
|
|
211 {
|
|
212 id result = invokeObjcSelf!(id, "childAtIndex:", NSUInteger)(indexreturn result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null); }
|
|
213
|
|
214 NSXMLNode previousSibling ()
|
|
215 {
|
|
216 id result = invokeObjcSelf!(id, "previousSibling"return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null); }
|
|
217
|
|
218 NSXMLNode nextSibling ()
|
|
219 {
|
|
220 id result = invokeObjcSelf!(id, "nextSibling"return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null); }
|
|
221
|
|
222 NSXMLNode previousNode ()
|
|
223 {
|
|
224 id result = invokeObjcSelf!(id, "previousNode"return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null); }
|
|
225
|
|
226 NSXMLNode nextNode ()
|
|
227 {
|
|
228 id result = invokeObjcSelf!(id, "nextNode"return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null); }
|
|
229
|
|
230 void detach ()
|
|
231 {
|
|
232 return invokeObjcSelf!(void, "detach");
|
|
233 }
|
|
234
|
|
235 NSString XPath ()
|
|
236 {
|
|
237 return invokeObjcSelf!(NSString, "XPath");
|
|
238 }
|
|
239
|
|
240 NSString localName ()
|
|
241 {
|
|
242 return invokeObjcSelf!(NSString, "localName");
|
|
243 }
|
|
244
|
|
245 NSString prefix ()
|
|
246 {
|
|
247 return invokeObjcSelf!(NSString, "prefix");
|
|
248 }
|
|
249
|
|
250 void setURI (NSString URI)
|
|
251 {
|
|
252 return invokeObjcSelf!(void, "setURI:", NSString)(URI);
|
|
253 }
|
|
254
|
|
255 NSString URI ()
|
|
256 {
|
|
257 return invokeObjcSelf!(NSString, "URI");
|
|
258 }
|
|
259
|
|
260 static NSString localNameForName (NSString name)
|
|
261 {
|
|
262 return invokeObjcSelfClass!(NSString, "localNameForName:", NSString)(name);
|
|
263 }
|
|
264
|
|
265 static NSString prefixForName (NSString name)
|
|
266 {
|
|
267 return invokeObjcSelfClass!(NSString, "prefixForName:", NSString)(name);
|
|
268 }
|
|
269
|
|
270 static NSXMLNode predefinedNamespaceForPrefix (NSString name)
|
|
271 {
|
|
272 return invokeObjcSelfClass!(NSXMLNode, "predefinedNamespaceForPrefix:", NSString)(namereturn result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null); }
|
|
273
|
|
274 NSString description ()
|
|
275 {
|
|
276 return invokeObjcSelf!(NSString, "description");
|
|
277 }
|
|
278
|
|
279 NSString XMLString ()
|
|
280 {
|
|
281 return invokeObjcSelf!(NSString, "XMLString");
|
|
282 }
|
|
283
|
|
284 NSString XMLStringWithOptions (NSUInteger options)
|
|
285 {
|
|
286 return invokeObjcSelf!(NSString, "XMLStringWithOptions:", NSUInteger)(options);
|
|
287 }
|
|
288
|
|
289 NSString canonicalXMLStringPreservingComments (bool comments)
|
|
290 {
|
|
291 return invokeObjcSelf!(NSString, "canonicalXMLStringPreservingComments:", bool)(comments);
|
|
292 }
|
|
293
|
|
294 NSArray nodesForXPath (NSString xpath, NSError** error)
|
|
295 {
|
|
296 return invokeObjcSelf!(NSArray, "nodesForXPath:error:", NSString, NSError**)(xpath, error);
|
|
297 }
|
|
298
|
|
299 NSArray objectsForXQuery (NSString xquery, NSDictionary constants, NSError** error)
|
|
300 {
|
|
301 return invokeObjcSelf!(NSArray, "objectsForXQuery:constants:error:", NSString, NSDictionary, NSError**)(xquery, constants, error);
|
|
302 }
|
|
303
|
|
304 NSArray objectsForXQuery (NSString xquery, NSError** error)
|
|
305 {
|
|
306 return invokeObjcSelf!(NSArray, "objectsForXQuery:error:", NSString, NSError**)(xquery, error);
|
|
307 }
|
|
308
|
|
309 Object copyWithZone (NSZone* zone)
|
|
310 {
|
|
311 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone);
|
|
312 }
|
|
313 }
|
|
314
|