objc2_foundation/generated/
NSXMLNode.rs

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