1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsxmlnodekind?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSXMLNodeKind(pub NSUInteger);
impl NSXMLNodeKind {
#[doc(alias = "NSXMLInvalidKind")]
pub const InvalidKind: Self = Self(0);
#[doc(alias = "NSXMLDocumentKind")]
pub const DocumentKind: Self = Self(1);
#[doc(alias = "NSXMLElementKind")]
pub const ElementKind: Self = Self(2);
#[doc(alias = "NSXMLAttributeKind")]
pub const AttributeKind: Self = Self(3);
#[doc(alias = "NSXMLNamespaceKind")]
pub const NamespaceKind: Self = Self(4);
#[doc(alias = "NSXMLProcessingInstructionKind")]
pub const ProcessingInstructionKind: Self = Self(5);
#[doc(alias = "NSXMLCommentKind")]
pub const CommentKind: Self = Self(6);
#[doc(alias = "NSXMLTextKind")]
pub const TextKind: Self = Self(7);
#[doc(alias = "NSXMLDTDKind")]
pub const DTDKind: Self = Self(8);
#[doc(alias = "NSXMLEntityDeclarationKind")]
pub const EntityDeclarationKind: Self = Self(9);
#[doc(alias = "NSXMLAttributeDeclarationKind")]
pub const AttributeDeclarationKind: Self = Self(10);
#[doc(alias = "NSXMLElementDeclarationKind")]
pub const ElementDeclarationKind: Self = Self(11);
#[doc(alias = "NSXMLNotationDeclarationKind")]
pub const NotationDeclarationKind: Self = Self(12);
}
unsafe impl Encode for NSXMLNodeKind {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSXMLNodeKind {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// The basic unit of an XML document.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsxmlnode?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSXMLNode;
);
#[cfg(feature = "NSObject")]
extern_conformance!(
unsafe impl NSCopying for NSXMLNode {}
);
#[cfg(feature = "NSObject")]
unsafe impl CopyingHelper for NSXMLNode {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for NSXMLNode {}
);
impl NSXMLNode {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
/// Invokes
///
/// ```text
/// initWithKind:options:
/// ```
///
/// with options set to NSXMLNodeOptionsNone
#[unsafe(method(initWithKind:))]
#[unsafe(method_family = init)]
pub fn initWithKind(this: Allocated<Self>, kind: NSXMLNodeKind) -> Retained<Self>;
#[cfg(feature = "NSXMLNodeOptions")]
/// Inits a node with fidelity options as description NSXMLNodeOptions.h
#[unsafe(method(initWithKind:options:))]
#[unsafe(method_family = init)]
pub fn initWithKind_options(
this: Allocated<Self>,
kind: NSXMLNodeKind,
options: NSXMLNodeOptions,
) -> Retained<Self>;
/// Returns an empty document.
#[unsafe(method(document))]
#[unsafe(method_family = none)]
pub fn document() -> Retained<AnyObject>;
#[cfg(feature = "NSXMLElement")]
/// Returns a document
///
/// Parameter `element`: The document's root node.
#[unsafe(method(documentWithRootElement:))]
#[unsafe(method_family = none)]
pub fn documentWithRootElement(element: &NSXMLElement) -> Retained<AnyObject>;
#[cfg(feature = "NSString")]
/// Returns an element
/// <tt>
/// <
/// name>
/// <
/// /name>
/// </tt>
/// .
#[unsafe(method(elementWithName:))]
#[unsafe(method_family = none)]
pub fn elementWithName(name: &NSString) -> Retained<AnyObject>;
#[cfg(feature = "NSString")]
/// Returns an element whose full QName is specified.
#[unsafe(method(elementWithName:URI:))]
#[unsafe(method_family = none)]
pub fn elementWithName_URI(name: &NSString, uri: &NSString) -> Retained<AnyObject>;
#[cfg(feature = "NSString")]
/// Returns an element with a single text node child
/// <tt>
/// <
/// name>string
/// <
/// /name>
/// </tt>
/// .
#[unsafe(method(elementWithName:stringValue:))]
#[unsafe(method_family = none)]
pub fn elementWithName_stringValue(
name: &NSString,
string: &NSString,
) -> Retained<AnyObject>;
#[cfg(all(feature = "NSArray", feature = "NSString"))]
/// Returns an element children and attributes
/// <tt>
/// <
/// name attr1="foo" attr2="bar">
/// <
/// -- child1 -->child2
/// <
/// /name>
/// </tt>
/// .
#[unsafe(method(elementWithName:children:attributes:))]
#[unsafe(method_family = none)]
pub fn elementWithName_children_attributes(
name: &NSString,
children: Option<&NSArray<NSXMLNode>>,
attributes: Option<&NSArray<NSXMLNode>>,
) -> Retained<AnyObject>;
#[cfg(feature = "NSString")]
/// Returns an attribute
/// <tt>
/// name="stringValue"
/// </tt>
/// .
#[unsafe(method(attributeWithName:stringValue:))]
#[unsafe(method_family = none)]
pub fn attributeWithName_stringValue(
name: &NSString,
string_value: &NSString,
) -> Retained<AnyObject>;
#[cfg(feature = "NSString")]
/// Returns an attribute whose full QName is specified.
#[unsafe(method(attributeWithName:URI:stringValue:))]
#[unsafe(method_family = none)]
pub fn attributeWithName_URI_stringValue(
name: &NSString,
uri: &NSString,
string_value: &NSString,
) -> Retained<AnyObject>;
#[cfg(feature = "NSString")]
/// Returns a namespace
/// <tt>
/// xmlns:name="stringValue"
/// </tt>
/// .
#[unsafe(method(namespaceWithName:stringValue:))]
#[unsafe(method_family = none)]
pub fn namespaceWithName_stringValue(
name: &NSString,
string_value: &NSString,
) -> Retained<AnyObject>;
#[cfg(feature = "NSString")]
/// Returns a processing instruction
/// <tt>
/// <
/// ?name stringValue>
/// </tt>
/// .
#[unsafe(method(processingInstructionWithName:stringValue:))]
#[unsafe(method_family = none)]
pub fn processingInstructionWithName_stringValue(
name: &NSString,
string_value: &NSString,
) -> Retained<AnyObject>;
#[cfg(feature = "NSString")]
/// Returns a comment
/// <tt>
/// <
/// --stringValue-->
/// </tt>
/// .
#[unsafe(method(commentWithStringValue:))]
#[unsafe(method_family = none)]
pub fn commentWithStringValue(string_value: &NSString) -> Retained<AnyObject>;
#[cfg(feature = "NSString")]
/// Returns a text node.
#[unsafe(method(textWithStringValue:))]
#[unsafe(method_family = none)]
pub fn textWithStringValue(string_value: &NSString) -> Retained<AnyObject>;
#[cfg(feature = "NSString")]
/// Returns an element, attribute, entity, or notation DTD node based on the full XML string.
#[unsafe(method(DTDNodeWithXMLString:))]
#[unsafe(method_family = none)]
pub fn DTDNodeWithXMLString(string: &NSString) -> Option<Retained<AnyObject>>;
/// Returns an element, attribute, entity, or notation DTD node based on the full XML string.
#[unsafe(method(kind))]
#[unsafe(method_family = none)]
pub fn kind(&self) -> NSXMLNodeKind;
#[cfg(feature = "NSString")]
/// Sets the nodes name. Applicable for element, attribute, namespace, processing-instruction, document type declaration, element declaration, attribute declaration, entity declaration, and notation declaration.
#[unsafe(method(name))]
#[unsafe(method_family = none)]
pub fn name(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
/// Setter for [`name`][Self::name].
///
/// This is [copied][crate::NSCopying::copy] when set.
#[unsafe(method(setName:))]
#[unsafe(method_family = none)]
pub fn setName(&self, name: Option<&NSString>);
/// Sets the content of the node. Setting the objectValue removes all existing children including processing instructions and comments. Setting the object value on an element creates a single text node child.
#[unsafe(method(objectValue))]
#[unsafe(method_family = none)]
pub fn objectValue(&self) -> Option<Retained<AnyObject>>;
/// Setter for [`objectValue`][Self::objectValue].
///
/// # Safety
///
/// `object_value` should be of the correct type.
#[unsafe(method(setObjectValue:))]
#[unsafe(method_family = none)]
pub unsafe fn setObjectValue(&self, object_value: Option<&AnyObject>);
#[cfg(feature = "NSString")]
/// Sets the content of the node. Setting the stringValue removes all existing children including processing instructions and comments. Setting the string value on an element creates a single text node child. The getter returns the string value of the node, which may be either its content or child text nodes, depending on the type of node. Elements are recursed and text nodes concatenated in document order with no intervening spaces.
#[unsafe(method(stringValue))]
#[unsafe(method_family = none)]
pub fn stringValue(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
/// Setter for [`stringValue`][Self::stringValue].
///
/// This is [copied][crate::NSCopying::copy] when set.
#[unsafe(method(setStringValue:))]
#[unsafe(method_family = none)]
pub fn setStringValue(&self, string_value: Option<&NSString>);
#[cfg(feature = "NSString")]
/// Sets the content as with
///
/// ```text
/// setStringValue:
/// ```
///
/// , but when "resolve" is true, character references, predefined entities and user entities available in the document's dtd are resolved. Entities not available in the dtd remain in their entity form.
#[unsafe(method(setStringValue:resolvingEntities:))]
#[unsafe(method_family = none)]
pub fn setStringValue_resolvingEntities(&self, string: &NSString, resolve: bool);
/// A node's index amongst its siblings.
#[unsafe(method(index))]
#[unsafe(method_family = none)]
pub fn index(&self) -> NSUInteger;
/// The depth of the node within the tree. Documents and standalone nodes are level 0.
#[unsafe(method(level))]
#[unsafe(method_family = none)]
pub fn level(&self) -> NSUInteger;
#[cfg(feature = "NSXMLDocument")]
/// The encompassing document or nil.
#[unsafe(method(rootDocument))]
#[unsafe(method_family = none)]
pub fn rootDocument(&self) -> Option<Retained<NSXMLDocument>>;
/// The parent of this node. Documents and standalone Nodes have a nil parent; there is not a 1-to-1 relationship between parent and children, eg a namespace cannot be a child but has a parent element.
#[unsafe(method(parent))]
#[unsafe(method_family = none)]
pub fn parent(&self) -> Option<Retained<NSXMLNode>>;
/// The amount of children, relevant for documents, elements, and document type declarations. Use this instead of [[self children] count].
#[unsafe(method(childCount))]
#[unsafe(method_family = none)]
pub fn childCount(&self) -> NSUInteger;
#[cfg(feature = "NSArray")]
/// An immutable array of child nodes. Relevant for documents, elements, and document type declarations.
#[unsafe(method(children))]
#[unsafe(method_family = none)]
pub fn children(&self) -> Option<Retained<NSArray<NSXMLNode>>>;
/// Returns the child node at a particular index.
#[unsafe(method(childAtIndex:))]
#[unsafe(method_family = none)]
pub fn childAtIndex(&self, index: NSUInteger) -> Option<Retained<NSXMLNode>>;
/// Returns the previous sibling, or nil if there isn't one.
#[unsafe(method(previousSibling))]
#[unsafe(method_family = none)]
pub fn previousSibling(&self) -> Option<Retained<NSXMLNode>>;
/// Returns the next sibling, or nil if there isn't one.
#[unsafe(method(nextSibling))]
#[unsafe(method_family = none)]
pub fn nextSibling(&self) -> Option<Retained<NSXMLNode>>;
/// Returns the previous node in document order. This can be used to walk the tree backwards.
#[unsafe(method(previousNode))]
#[unsafe(method_family = none)]
pub fn previousNode(&self) -> Option<Retained<NSXMLNode>>;
/// Returns the next node in document order. This can be used to walk the tree forwards.
#[unsafe(method(nextNode))]
#[unsafe(method_family = none)]
pub fn nextNode(&self) -> Option<Retained<NSXMLNode>>;
/// Detaches this node from its parent.
#[unsafe(method(detach))]
#[unsafe(method_family = none)]
pub fn detach(&self);
#[cfg(feature = "NSString")]
/// Returns the XPath to this node, for example foo/bar[2]/baz.
#[unsafe(method(XPath))]
#[unsafe(method_family = none)]
pub fn XPath(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
/// Returns the local name bar if this attribute or element's name is foo:bar
#[unsafe(method(localName))]
#[unsafe(method_family = none)]
pub fn localName(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
/// Returns the prefix foo if this attribute or element's name if foo:bar
#[unsafe(method(prefix))]
#[unsafe(method_family = none)]
pub fn prefix(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
/// Set the URI of this element, attribute, or document. For documents it is the URI of document origin. Getter returns the URI of this element, attribute, or document. For documents it is the URI of document origin and is automatically set when using initWithContentsOfURL.
#[unsafe(method(URI))]
#[unsafe(method_family = none)]
pub fn URI(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
/// Setter for [`URI`][Self::URI].
///
/// This is [copied][crate::NSCopying::copy] when set.
#[unsafe(method(setURI:))]
#[unsafe(method_family = none)]
pub fn setURI(&self, uri: Option<&NSString>);
#[cfg(feature = "NSString")]
/// Returns the local name bar in foo:bar.
#[unsafe(method(localNameForName:))]
#[unsafe(method_family = none)]
pub fn localNameForName(name: &NSString) -> Retained<NSString>;
#[cfg(feature = "NSString")]
/// Returns the prefix foo in the name foo:bar.
#[unsafe(method(prefixForName:))]
#[unsafe(method_family = none)]
pub fn prefixForName(name: &NSString) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
/// Returns the namespace belonging to one of the predefined namespaces xml, xs, or xsi
#[unsafe(method(predefinedNamespaceForPrefix:))]
#[unsafe(method_family = none)]
pub fn predefinedNamespaceForPrefix(name: &NSString) -> Option<Retained<NSXMLNode>>;
#[cfg(feature = "NSString")]
/// Used for debugging. May give more information than XMLString.
#[unsafe(method(description))]
#[unsafe(method_family = none)]
pub fn description(&self) -> Retained<NSString>;
#[cfg(feature = "NSString")]
/// The representation of this node as it would appear in an XML document.
#[unsafe(method(XMLString))]
#[unsafe(method_family = none)]
pub fn XMLString(&self) -> Retained<NSString>;
#[cfg(all(feature = "NSString", feature = "NSXMLNodeOptions"))]
/// The representation of this node as it would appear in an XML document, with various output options available.
#[unsafe(method(XMLStringWithOptions:))]
#[unsafe(method_family = none)]
pub fn XMLStringWithOptions(&self, options: NSXMLNodeOptions) -> Retained<NSString>;
#[cfg(feature = "NSString")]
/// W3 canonical form (http://www.w3.org/TR/xml-c14n). The input option NSXMLNodePreserveWhitespace should be set for true canonical form.
#[unsafe(method(canonicalXMLStringPreservingComments:))]
#[unsafe(method_family = none)]
pub fn canonicalXMLStringPreservingComments(&self, comments: bool) -> Retained<NSString>;
#[cfg(all(feature = "NSArray", feature = "NSError", feature = "NSString"))]
/// Returns the nodes resulting from applying an XPath to this node using the node as the context item ("."). normalizeAdjacentTextNodesPreservingCDATA:NO should be called if there are adjacent text nodes since they are not allowed under the XPath/XQuery Data Model.
///
/// Returns: An array whose elements are a kind of NSXMLNode.
#[unsafe(method(nodesForXPath:error:_))]
#[unsafe(method_family = none)]
pub fn nodesForXPath_error(
&self,
xpath: &NSString,
) -> Result<Retained<NSArray<NSXMLNode>>, Retained<NSError>>;
#[cfg(all(
feature = "NSArray",
feature = "NSDictionary",
feature = "NSError",
feature = "NSString"
))]
/// Returns the objects resulting from applying an XQuery to this node using the node as the context item ("."). Constants are a name-value dictionary for constants declared "external" in the query. normalizeAdjacentTextNodesPreservingCDATA:NO should be called if there are adjacent text nodes since they are not allowed under the XPath/XQuery Data Model.
///
/// Returns: An array whose elements are kinds of NSArray, NSData, NSDate, NSNumber, NSString, NSURL, or NSXMLNode.
///
/// # Safety
///
/// `constants` generic should be of the correct type.
#[unsafe(method(objectsForXQuery:constants:error:_))]
#[unsafe(method_family = none)]
pub unsafe fn objectsForXQuery_constants_error(
&self,
xquery: &NSString,
constants: Option<&NSDictionary<NSString, AnyObject>>,
) -> Result<Retained<NSArray>, Retained<NSError>>;
#[cfg(all(feature = "NSArray", feature = "NSError", feature = "NSString"))]
#[unsafe(method(objectsForXQuery:error:_))]
#[unsafe(method_family = none)]
pub fn objectsForXQuery_error(
&self,
xquery: &NSString,
) -> Result<Retained<NSArray>, Retained<NSError>>;
);
}
/// Methods declared on superclass `NSObject`.
impl NSXMLNode {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}
impl DefaultRetained for NSXMLNode {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}