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")]
61extern_conformance!(
62    unsafe impl NSCopying for NSXMLNode {}
63);
64
65#[cfg(feature = "NSObject")]
66unsafe impl CopyingHelper for NSXMLNode {
67    type Result = Self;
68}
69
70extern_conformance!(
71    unsafe impl NSObjectProtocol for NSXMLNode {}
72);
73
74impl NSXMLNode {
75    extern_methods!(
76        #[unsafe(method(init))]
77        #[unsafe(method_family = init)]
78        pub fn init(this: Allocated<Self>) -> Retained<Self>;
79
80        /// Invokes
81        ///
82        /// ```text
83        ///  initWithKind:options:
84        /// ```
85        ///
86        /// with options set to NSXMLNodeOptionsNone
87        #[unsafe(method(initWithKind:))]
88        #[unsafe(method_family = init)]
89        pub fn initWithKind(this: Allocated<Self>, kind: NSXMLNodeKind) -> Retained<Self>;
90
91        #[cfg(feature = "NSXMLNodeOptions")]
92        /// Inits a node with fidelity options as description NSXMLNodeOptions.h
93        #[unsafe(method(initWithKind:options:))]
94        #[unsafe(method_family = init)]
95        pub fn initWithKind_options(
96            this: Allocated<Self>,
97            kind: NSXMLNodeKind,
98            options: NSXMLNodeOptions,
99        ) -> Retained<Self>;
100
101        /// Returns an empty document.
102        #[unsafe(method(document))]
103        #[unsafe(method_family = none)]
104        pub fn document() -> Retained<AnyObject>;
105
106        #[cfg(feature = "NSXMLElement")]
107        /// Returns a document
108        ///
109        /// Parameter `element`: The document's root node.
110        #[unsafe(method(documentWithRootElement:))]
111        #[unsafe(method_family = none)]
112        pub fn documentWithRootElement(element: &NSXMLElement) -> Retained<AnyObject>;
113
114        #[cfg(feature = "NSString")]
115        /// Returns an element
116        /// <tt>
117        /// <
118        /// name>
119        /// <
120        /// /name>
121        /// </tt>
122        /// .
123        #[unsafe(method(elementWithName:))]
124        #[unsafe(method_family = none)]
125        pub fn elementWithName(name: &NSString) -> Retained<AnyObject>;
126
127        #[cfg(feature = "NSString")]
128        /// Returns an element whose full QName is specified.
129        #[unsafe(method(elementWithName:URI:))]
130        #[unsafe(method_family = none)]
131        pub fn elementWithName_URI(name: &NSString, uri: &NSString) -> Retained<AnyObject>;
132
133        #[cfg(feature = "NSString")]
134        /// Returns an element with a single text node child
135        /// <tt>
136        /// <
137        /// name>string
138        /// <
139        /// /name>
140        /// </tt>
141        /// .
142        #[unsafe(method(elementWithName:stringValue:))]
143        #[unsafe(method_family = none)]
144        pub fn elementWithName_stringValue(
145            name: &NSString,
146            string: &NSString,
147        ) -> Retained<AnyObject>;
148
149        #[cfg(all(feature = "NSArray", feature = "NSString"))]
150        /// Returns an element children and attributes
151        /// <tt>
152        /// <
153        /// name attr1="foo" attr2="bar">
154        /// <
155        /// -- child1 -->child2
156        /// <
157        /// /name>
158        /// </tt>
159        /// .
160        #[unsafe(method(elementWithName:children:attributes:))]
161        #[unsafe(method_family = none)]
162        pub fn elementWithName_children_attributes(
163            name: &NSString,
164            children: Option<&NSArray<NSXMLNode>>,
165            attributes: Option<&NSArray<NSXMLNode>>,
166        ) -> Retained<AnyObject>;
167
168        #[cfg(feature = "NSString")]
169        /// Returns an attribute
170        /// <tt>
171        /// name="stringValue"
172        /// </tt>
173        /// .
174        #[unsafe(method(attributeWithName:stringValue:))]
175        #[unsafe(method_family = none)]
176        pub fn attributeWithName_stringValue(
177            name: &NSString,
178            string_value: &NSString,
179        ) -> Retained<AnyObject>;
180
181        #[cfg(feature = "NSString")]
182        /// Returns an attribute whose full QName is specified.
183        #[unsafe(method(attributeWithName:URI:stringValue:))]
184        #[unsafe(method_family = none)]
185        pub fn attributeWithName_URI_stringValue(
186            name: &NSString,
187            uri: &NSString,
188            string_value: &NSString,
189        ) -> Retained<AnyObject>;
190
191        #[cfg(feature = "NSString")]
192        /// Returns a namespace
193        /// <tt>
194        /// xmlns:name="stringValue"
195        /// </tt>
196        /// .
197        #[unsafe(method(namespaceWithName:stringValue:))]
198        #[unsafe(method_family = none)]
199        pub fn namespaceWithName_stringValue(
200            name: &NSString,
201            string_value: &NSString,
202        ) -> Retained<AnyObject>;
203
204        #[cfg(feature = "NSString")]
205        /// Returns a processing instruction
206        /// <tt>
207        /// <
208        /// ?name stringValue>
209        /// </tt>
210        /// .
211        #[unsafe(method(processingInstructionWithName:stringValue:))]
212        #[unsafe(method_family = none)]
213        pub fn processingInstructionWithName_stringValue(
214            name: &NSString,
215            string_value: &NSString,
216        ) -> Retained<AnyObject>;
217
218        #[cfg(feature = "NSString")]
219        /// Returns a comment
220        /// <tt>
221        /// <
222        /// --stringValue-->
223        /// </tt>
224        /// .
225        #[unsafe(method(commentWithStringValue:))]
226        #[unsafe(method_family = none)]
227        pub fn commentWithStringValue(string_value: &NSString) -> Retained<AnyObject>;
228
229        #[cfg(feature = "NSString")]
230        /// Returns a text node.
231        #[unsafe(method(textWithStringValue:))]
232        #[unsafe(method_family = none)]
233        pub fn textWithStringValue(string_value: &NSString) -> Retained<AnyObject>;
234
235        #[cfg(feature = "NSString")]
236        /// Returns an element, attribute, entity, or notation DTD node based on the full XML string.
237        #[unsafe(method(DTDNodeWithXMLString:))]
238        #[unsafe(method_family = none)]
239        pub fn DTDNodeWithXMLString(string: &NSString) -> Option<Retained<AnyObject>>;
240
241        /// Returns an element, attribute, entity, or notation DTD node based on the full XML string.
242        #[unsafe(method(kind))]
243        #[unsafe(method_family = none)]
244        pub fn kind(&self) -> NSXMLNodeKind;
245
246        #[cfg(feature = "NSString")]
247        /// Sets the nodes name. Applicable for element, attribute, namespace, processing-instruction, document type declaration, element declaration, attribute declaration, entity declaration, and notation declaration.
248        #[unsafe(method(name))]
249        #[unsafe(method_family = none)]
250        pub fn name(&self) -> Option<Retained<NSString>>;
251
252        #[cfg(feature = "NSString")]
253        /// Setter for [`name`][Self::name].
254        ///
255        /// This is [copied][crate::NSCopying::copy] when set.
256        #[unsafe(method(setName:))]
257        #[unsafe(method_family = none)]
258        pub fn setName(&self, name: Option<&NSString>);
259
260        /// 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.
261        #[unsafe(method(objectValue))]
262        #[unsafe(method_family = none)]
263        pub fn objectValue(&self) -> Option<Retained<AnyObject>>;
264
265        /// Setter for [`objectValue`][Self::objectValue].
266        ///
267        /// # Safety
268        ///
269        /// `object_value` should be of the correct type.
270        #[unsafe(method(setObjectValue:))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn setObjectValue(&self, object_value: Option<&AnyObject>);
273
274        #[cfg(feature = "NSString")]
275        /// 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.
276        #[unsafe(method(stringValue))]
277        #[unsafe(method_family = none)]
278        pub fn stringValue(&self) -> Option<Retained<NSString>>;
279
280        #[cfg(feature = "NSString")]
281        /// Setter for [`stringValue`][Self::stringValue].
282        ///
283        /// This is [copied][crate::NSCopying::copy] when set.
284        #[unsafe(method(setStringValue:))]
285        #[unsafe(method_family = none)]
286        pub fn setStringValue(&self, string_value: Option<&NSString>);
287
288        #[cfg(feature = "NSString")]
289        /// Sets the content as with
290        ///
291        /// ```text
292        ///  setStringValue:
293        /// ```
294        ///
295        /// , 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.
296        #[unsafe(method(setStringValue:resolvingEntities:))]
297        #[unsafe(method_family = none)]
298        pub fn setStringValue_resolvingEntities(&self, string: &NSString, resolve: bool);
299
300        /// A node's index amongst its siblings.
301        #[unsafe(method(index))]
302        #[unsafe(method_family = none)]
303        pub fn index(&self) -> NSUInteger;
304
305        /// The depth of the node within the tree. Documents and standalone nodes are level 0.
306        #[unsafe(method(level))]
307        #[unsafe(method_family = none)]
308        pub fn level(&self) -> NSUInteger;
309
310        #[cfg(feature = "NSXMLDocument")]
311        /// The encompassing document or nil.
312        #[unsafe(method(rootDocument))]
313        #[unsafe(method_family = none)]
314        pub fn rootDocument(&self) -> Option<Retained<NSXMLDocument>>;
315
316        /// 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.
317        #[unsafe(method(parent))]
318        #[unsafe(method_family = none)]
319        pub fn parent(&self) -> Option<Retained<NSXMLNode>>;
320
321        /// The amount of children, relevant for documents, elements, and document type declarations. Use this instead of [[self children] count].
322        #[unsafe(method(childCount))]
323        #[unsafe(method_family = none)]
324        pub fn childCount(&self) -> NSUInteger;
325
326        #[cfg(feature = "NSArray")]
327        /// An immutable array of child nodes. Relevant for documents, elements, and document type declarations.
328        #[unsafe(method(children))]
329        #[unsafe(method_family = none)]
330        pub fn children(&self) -> Option<Retained<NSArray<NSXMLNode>>>;
331
332        /// Returns the child node at a particular index.
333        #[unsafe(method(childAtIndex:))]
334        #[unsafe(method_family = none)]
335        pub fn childAtIndex(&self, index: NSUInteger) -> Option<Retained<NSXMLNode>>;
336
337        /// Returns the previous sibling, or nil if there isn't one.
338        #[unsafe(method(previousSibling))]
339        #[unsafe(method_family = none)]
340        pub fn previousSibling(&self) -> Option<Retained<NSXMLNode>>;
341
342        /// Returns the next sibling, or nil if there isn't one.
343        #[unsafe(method(nextSibling))]
344        #[unsafe(method_family = none)]
345        pub fn nextSibling(&self) -> Option<Retained<NSXMLNode>>;
346
347        /// Returns the previous node in document order. This can be used to walk the tree backwards.
348        #[unsafe(method(previousNode))]
349        #[unsafe(method_family = none)]
350        pub fn previousNode(&self) -> Option<Retained<NSXMLNode>>;
351
352        /// Returns the next node in document order. This can be used to walk the tree forwards.
353        #[unsafe(method(nextNode))]
354        #[unsafe(method_family = none)]
355        pub fn nextNode(&self) -> Option<Retained<NSXMLNode>>;
356
357        /// Detaches this node from its parent.
358        #[unsafe(method(detach))]
359        #[unsafe(method_family = none)]
360        pub fn detach(&self);
361
362        #[cfg(feature = "NSString")]
363        /// Returns the XPath to this node, for example foo/bar[2]/baz.
364        #[unsafe(method(XPath))]
365        #[unsafe(method_family = none)]
366        pub fn XPath(&self) -> Option<Retained<NSString>>;
367
368        #[cfg(feature = "NSString")]
369        /// Returns the local name bar if this attribute or element's name is foo:bar
370        #[unsafe(method(localName))]
371        #[unsafe(method_family = none)]
372        pub fn localName(&self) -> Option<Retained<NSString>>;
373
374        #[cfg(feature = "NSString")]
375        /// Returns the prefix foo if this attribute or element's name if foo:bar
376        #[unsafe(method(prefix))]
377        #[unsafe(method_family = none)]
378        pub fn prefix(&self) -> Option<Retained<NSString>>;
379
380        #[cfg(feature = "NSString")]
381        /// 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.
382        #[unsafe(method(URI))]
383        #[unsafe(method_family = none)]
384        pub fn URI(&self) -> Option<Retained<NSString>>;
385
386        #[cfg(feature = "NSString")]
387        /// Setter for [`URI`][Self::URI].
388        ///
389        /// This is [copied][crate::NSCopying::copy] when set.
390        #[unsafe(method(setURI:))]
391        #[unsafe(method_family = none)]
392        pub fn setURI(&self, uri: Option<&NSString>);
393
394        #[cfg(feature = "NSString")]
395        /// Returns the local name bar in foo:bar.
396        #[unsafe(method(localNameForName:))]
397        #[unsafe(method_family = none)]
398        pub fn localNameForName(name: &NSString) -> Retained<NSString>;
399
400        #[cfg(feature = "NSString")]
401        /// Returns the prefix foo in the name foo:bar.
402        #[unsafe(method(prefixForName:))]
403        #[unsafe(method_family = none)]
404        pub fn prefixForName(name: &NSString) -> Option<Retained<NSString>>;
405
406        #[cfg(feature = "NSString")]
407        /// Returns the namespace belonging to one of the predefined namespaces xml, xs, or xsi
408        #[unsafe(method(predefinedNamespaceForPrefix:))]
409        #[unsafe(method_family = none)]
410        pub fn predefinedNamespaceForPrefix(name: &NSString) -> Option<Retained<NSXMLNode>>;
411
412        #[cfg(feature = "NSString")]
413        /// Used for debugging. May give more information than XMLString.
414        #[unsafe(method(description))]
415        #[unsafe(method_family = none)]
416        pub fn description(&self) -> Retained<NSString>;
417
418        #[cfg(feature = "NSString")]
419        /// The representation of this node as it would appear in an XML document.
420        #[unsafe(method(XMLString))]
421        #[unsafe(method_family = none)]
422        pub fn XMLString(&self) -> Retained<NSString>;
423
424        #[cfg(all(feature = "NSString", feature = "NSXMLNodeOptions"))]
425        /// The representation of this node as it would appear in an XML document, with various output options available.
426        #[unsafe(method(XMLStringWithOptions:))]
427        #[unsafe(method_family = none)]
428        pub fn XMLStringWithOptions(&self, options: NSXMLNodeOptions) -> Retained<NSString>;
429
430        #[cfg(feature = "NSString")]
431        /// W3 canonical form (http://www.w3.org/TR/xml-c14n). The input option NSXMLNodePreserveWhitespace should be set for true canonical form.
432        #[unsafe(method(canonicalXMLStringPreservingComments:))]
433        #[unsafe(method_family = none)]
434        pub fn canonicalXMLStringPreservingComments(&self, comments: bool) -> Retained<NSString>;
435
436        #[cfg(all(feature = "NSArray", feature = "NSError", feature = "NSString"))]
437        /// 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.
438        ///
439        /// Returns: An array whose elements are a kind of NSXMLNode.
440        #[unsafe(method(nodesForXPath:error:_))]
441        #[unsafe(method_family = none)]
442        pub fn nodesForXPath_error(
443            &self,
444            xpath: &NSString,
445        ) -> Result<Retained<NSArray<NSXMLNode>>, Retained<NSError>>;
446
447        #[cfg(all(
448            feature = "NSArray",
449            feature = "NSDictionary",
450            feature = "NSError",
451            feature = "NSString"
452        ))]
453        /// 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.
454        ///
455        /// Returns: An array whose elements are kinds of NSArray, NSData, NSDate, NSNumber, NSString, NSURL, or NSXMLNode.
456        ///
457        /// # Safety
458        ///
459        /// `constants` generic should be of the correct type.
460        #[unsafe(method(objectsForXQuery:constants:error:_))]
461        #[unsafe(method_family = none)]
462        pub unsafe fn objectsForXQuery_constants_error(
463            &self,
464            xquery: &NSString,
465            constants: Option<&NSDictionary<NSString, AnyObject>>,
466        ) -> Result<Retained<NSArray>, Retained<NSError>>;
467
468        #[cfg(all(feature = "NSArray", feature = "NSError", feature = "NSString"))]
469        #[unsafe(method(objectsForXQuery:error:_))]
470        #[unsafe(method_family = none)]
471        pub fn objectsForXQuery_error(
472            &self,
473            xquery: &NSString,
474        ) -> Result<Retained<NSArray>, Retained<NSError>>;
475    );
476}
477
478/// Methods declared on superclass `NSObject`.
479impl NSXMLNode {
480    extern_methods!(
481        #[unsafe(method(new))]
482        #[unsafe(method_family = new)]
483        pub fn new() -> Retained<Self>;
484    );
485}
486
487impl DefaultRetained for NSXMLNode {
488    #[inline]
489    fn default_retained() -> Retained<Self> {
490        Self::new()
491    }
492}