Mercurial > projects > dstep
annotate dstep/foundation/NSXMLNode.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 7ff919f595d5 |
children | b9de51448c6b |
rev | line source |
---|---|
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; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
12 import dstep.foundation.NSObjCRuntime; |
14 | 13 import dstep.foundation.NSObject; |
14 import dstep.foundation.NSString; | |
15 import dstep.foundation.NSURL; | |
16 import dstep.foundation.NSXMLDocument; | |
17 import dstep.foundation.NSXMLElement; | |
18 import dstep.foundation.NSXMLNodeOptions; | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
19 import dstep.foundation.NSZone; |
14 | 20 import dstep.objc.bridge.Bridge; |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
21 import dstep.objc.objc; |
14 | 22 |
23 alias NSUInteger NSXMLNodeKind; | |
24 | |
25 enum | |
26 { | |
27 NSXMLInvalidKind = 0, | |
28 NSXMLDocumentKind, | |
29 NSXMLElementKind, | |
30 NSXMLAttributeKind, | |
31 NSXMLNamespaceKind, | |
32 NSXMLProcessingInstructionKind, | |
33 NSXMLCommentKind, | |
34 NSXMLTextKind, | |
35 NSXMLDTDKind, | |
36 NSXMLEntityDeclarationKind, | |
37 NSXMLAttributeDeclarationKind, | |
38 NSXMLElementDeclarationKind, | |
39 NSXMLNotationDeclarationKind | |
40 } | |
41 | |
42 class NSXMLNode : NSObject, INSCopying | |
43 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
44 mixin (ObjcWrap); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
45 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
46 this () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
47 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
48 super(typeof(this).alloc.init.objcObject); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
49 } |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
50 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
51 typeof(this) init () |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
52 { |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
53 return invokeObjcSelf!(typeof(this), "init"); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
54 } |
14 | 55 |
56 Object initWithKind (uint kind) | |
57 { | |
58 return invokeObjcSelf!(Object, "initWithKind:", uint)(kind); | |
59 } | |
60 | |
61 this (uint kind) | |
62 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
63 typeof(this).alloc.initWithKind(kind); |
14 | 64 } |
65 | |
66 Object initWithKind (uint kind, NSUInteger options) | |
67 { | |
68 return invokeObjcSelf!(Object, "initWithKind:options:", uint, NSUInteger)(kind, options); | |
69 } | |
70 | |
71 this (uint kind, NSUInteger options) | |
72 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
73 typeof(this).alloc.initWithKind(kind, options); |
14 | 74 } |
75 | |
76 static Object document () | |
77 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
78 return invokeObjcSuperClass!(Object, "document"); |
14 | 79 } |
80 | |
81 static Object documentWithRootElement (NSXMLElement element) | |
82 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
83 return invokeObjcSuperClass!(Object, "documentWithRootElement:", NSXMLElement)(element); |
14 | 84 } |
85 | |
86 static Object elementWithName (NSString name) | |
87 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
88 return invokeObjcSuperClass!(Object, "elementWithName:", NSString)(name); |
14 | 89 } |
90 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
91 static Object elementWithName_URI (NSString name, NSString URI) |
14 | 92 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
93 return invokeObjcSuperClass!(Object, "elementWithName:URI:", NSString, NSString)(name, URI); |
14 | 94 } |
95 | |
96 static Object elementWithName (NSString name, NSString string) | |
97 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
98 return invokeObjcSuperClass!(Object, "elementWithName:stringValue:", NSString, NSString)(name, string); |
14 | 99 } |
100 | |
101 static Object elementWithName (NSString name, NSArray children, NSArray attributes) | |
102 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
103 return invokeObjcSuperClass!(Object, "elementWithName:children:attributes:", NSString, NSArray, NSArray)(name, children, attributes); |
14 | 104 } |
105 | |
106 static Object attributeWithName (NSString name, NSString stringValue) | |
107 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
108 return invokeObjcSuperClass!(Object, "attributeWithName:stringValue:", NSString, NSString)(name, stringValue); |
14 | 109 } |
110 | |
111 static Object attributeWithName (NSString name, NSString URI, NSString stringValue) | |
112 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
113 return invokeObjcSuperClass!(Object, "attributeWithName:URI:stringValue:", NSString, NSString, NSString)(name, URI, stringValue); |
14 | 114 } |
115 | |
116 static Object namespaceWithName (NSString name, NSString stringValue) | |
117 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
118 return invokeObjcSuperClass!(Object, "namespaceWithName:stringValue:", NSString, NSString)(name, stringValue); |
14 | 119 } |
120 | |
121 static Object processingInstructionWithName (NSString name, NSString stringValue) | |
122 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
123 return invokeObjcSuperClass!(Object, "processingInstructionWithName:stringValue:", NSString, NSString)(name, stringValue); |
14 | 124 } |
125 | |
126 static Object commentWithStringValue (NSString stringValue) | |
127 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
128 return invokeObjcSuperClass!(Object, "commentWithStringValue:", NSString)(stringValue); |
14 | 129 } |
130 | |
131 static Object textWithStringValue (NSString stringValue) | |
132 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
133 return invokeObjcSuperClass!(Object, "textWithStringValue:", NSString)(stringValue); |
14 | 134 } |
135 | |
136 static Object DTDNodeWithXMLString (NSString string) | |
137 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
138 return invokeObjcSuperClass!(Object, "DTDNodeWithXMLString:", NSString)(string); |
14 | 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 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
198 id result = invokeObjcSelf!(id, "parent"); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
199 return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
200 } |
14 | 201 |
202 NSUInteger childCount () | |
203 { | |
204 return invokeObjcSelf!(NSUInteger, "childCount"); | |
205 } | |
206 | |
207 NSArray children () | |
208 { | |
209 return invokeObjcSelf!(NSArray, "children"); | |
210 } | |
211 | |
212 NSXMLNode childAtIndex (NSUInteger index) | |
213 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
214 id result = invokeObjcSelf!(id, "childAtIndex:", NSUInteger)(index); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
215 return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
216 } |
14 | 217 |
218 NSXMLNode previousSibling () | |
219 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
220 id result = invokeObjcSelf!(id, "previousSibling"); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
221 return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
222 } |
14 | 223 |
224 NSXMLNode nextSibling () | |
225 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
226 id result = invokeObjcSelf!(id, "nextSibling"); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
227 return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
228 } |
14 | 229 |
230 NSXMLNode previousNode () | |
231 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
232 id result = invokeObjcSelf!(id, "previousNode"); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
233 return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
234 } |
14 | 235 |
236 NSXMLNode nextNode () | |
237 { | |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
238 id result = invokeObjcSelf!(id, "nextNode"); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
239 return result is this.objcObject ? this : (result !is null ? new NSXMLNode(result) : null); |
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
240 } |
14 | 241 |
242 void detach () | |
243 { | |
244 return invokeObjcSelf!(void, "detach"); | |
245 } | |
246 | |
247 NSString XPath () | |
248 { | |
249 return invokeObjcSelf!(NSString, "XPath"); | |
250 } | |
251 | |
252 NSString localName () | |
253 { | |
254 return invokeObjcSelf!(NSString, "localName"); | |
255 } | |
256 | |
257 NSString prefix () | |
258 { | |
259 return invokeObjcSelf!(NSString, "prefix"); | |
260 } | |
261 | |
262 void setURI (NSString URI) | |
263 { | |
264 return invokeObjcSelf!(void, "setURI:", NSString)(URI); | |
265 } | |
266 | |
267 NSString URI () | |
268 { | |
269 return invokeObjcSelf!(NSString, "URI"); | |
270 } | |
271 | |
272 static NSString localNameForName (NSString name) | |
273 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
274 return invokeObjcSuperClass!(NSString, "localNameForName:", NSString)(name); |
14 | 275 } |
276 | |
277 static NSString prefixForName (NSString name) | |
278 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
279 return invokeObjcSuperClass!(NSString, "prefixForName:", NSString)(name); |
14 | 280 } |
281 | |
282 static NSXMLNode predefinedNamespaceForPrefix (NSString name) | |
283 { | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
284 return invokeObjcSuperClass!(NSXMLNode, "predefinedNamespaceForPrefix:", NSString)(name); |
15
7ff919f595d5
Added the Foundation framework, again
Jacob Carlborg <doob@me.com>
parents:
14
diff
changeset
|
285 } |
14 | 286 |
287 NSString description () | |
288 { | |
289 return invokeObjcSelf!(NSString, "description"); | |
290 } | |
291 | |
292 NSString XMLString () | |
293 { | |
294 return invokeObjcSelf!(NSString, "XMLString"); | |
295 } | |
296 | |
297 NSString XMLStringWithOptions (NSUInteger options) | |
298 { | |
299 return invokeObjcSelf!(NSString, "XMLStringWithOptions:", NSUInteger)(options); | |
300 } | |
301 | |
302 NSString canonicalXMLStringPreservingComments (bool comments) | |
303 { | |
304 return invokeObjcSelf!(NSString, "canonicalXMLStringPreservingComments:", bool)(comments); | |
305 } | |
306 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
307 NSArray nodesForXPath (NSString xpath, ref NSError error) |
14 | 308 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
309 id err = error ? new objc_object : null; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
310 NSArray result = invokeObjcSelf!(NSArray, "nodesForXPath:error:", NSString, id*)(xpath, &err); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
311 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
312 if (err) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
313 error = new NSError(err); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
314 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
315 return result; |
14 | 316 } |
317 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
318 NSArray objectsForXQuery (NSString xquery, NSDictionary constants, ref NSError error) |
14 | 319 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
320 id err = error ? new objc_object : null; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
321 NSArray result = invokeObjcSelf!(NSArray, "objectsForXQuery:constants:error:", NSString, NSDictionary, id*)(xquery, constants, &err); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
322 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
323 if (err) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
324 error = new NSError(err); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
325 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
326 return result; |
14 | 327 } |
328 | |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
329 NSArray objectsForXQuery (NSString xquery, ref NSError error) |
14 | 330 { |
16
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
331 id err = error ? new objc_object : null; |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
332 NSArray result = invokeObjcSelf!(NSArray, "objectsForXQuery:error:", NSString, id*)(xquery, &err); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
333 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
334 if (err) |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
335 error = new NSError(err); |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
336 |
19885b43130e
Huge update, the bridge actually works now
Jacob Carlborg <doob@me.com>
parents:
15
diff
changeset
|
337 return result; |
14 | 338 } |
339 | |
340 Object copyWithZone (NSZone* zone) | |
341 { | |
342 return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); | |
343 } | |
344 } | |
345 |