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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe fn name(&self) -> Option<Retained<NSString>>;
251
252        #[cfg(feature = "NSString")]
253        /// Setter for [`name`][Self::name].
254        #[unsafe(method(setName:))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn setName(&self, name: Option<&NSString>);
257
258        /// 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.
259        #[unsafe(method(objectValue))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn objectValue(&self) -> Option<Retained<AnyObject>>;
262
263        /// Setter for [`objectValue`][Self::objectValue].
264        #[unsafe(method(setObjectValue:))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn setObjectValue(&self, object_value: Option<&AnyObject>);
267
268        #[cfg(feature = "NSString")]
269        /// 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.
270        #[unsafe(method(stringValue))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn stringValue(&self) -> Option<Retained<NSString>>;
273
274        #[cfg(feature = "NSString")]
275        /// Setter for [`stringValue`][Self::stringValue].
276        #[unsafe(method(setStringValue:))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn setStringValue(&self, string_value: Option<&NSString>);
279
280        #[cfg(feature = "NSString")]
281        /// Sets the content as with
282        ///
283        /// ```text
284        ///  setStringValue:
285        /// ```
286        ///
287        /// , 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.
288        #[unsafe(method(setStringValue:resolvingEntities:))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn setStringValue_resolvingEntities(&self, string: &NSString, resolve: bool);
291
292        /// A node's index amongst its siblings.
293        #[unsafe(method(index))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn index(&self) -> NSUInteger;
296
297        /// The depth of the node within the tree. Documents and standalone nodes are level 0.
298        #[unsafe(method(level))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn level(&self) -> NSUInteger;
301
302        #[cfg(feature = "NSXMLDocument")]
303        /// The encompassing document or nil.
304        #[unsafe(method(rootDocument))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn rootDocument(&self) -> Option<Retained<NSXMLDocument>>;
307
308        /// 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.
309        #[unsafe(method(parent))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn parent(&self) -> Option<Retained<NSXMLNode>>;
312
313        /// The amount of children, relevant for documents, elements, and document type declarations. Use this instead of [[self children] count].
314        #[unsafe(method(childCount))]
315        #[unsafe(method_family = none)]
316        pub unsafe fn childCount(&self) -> NSUInteger;
317
318        #[cfg(feature = "NSArray")]
319        /// An immutable array of child nodes. Relevant for documents, elements, and document type declarations.
320        #[unsafe(method(children))]
321        #[unsafe(method_family = none)]
322        pub unsafe fn children(&self) -> Option<Retained<NSArray<NSXMLNode>>>;
323
324        /// Returns the child node at a particular index.
325        #[unsafe(method(childAtIndex:))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn childAtIndex(&self, index: NSUInteger) -> Option<Retained<NSXMLNode>>;
328
329        /// Returns the previous sibling, or nil if there isn't one.
330        #[unsafe(method(previousSibling))]
331        #[unsafe(method_family = none)]
332        pub unsafe fn previousSibling(&self) -> Option<Retained<NSXMLNode>>;
333
334        /// Returns the next sibling, or nil if there isn't one.
335        #[unsafe(method(nextSibling))]
336        #[unsafe(method_family = none)]
337        pub unsafe fn nextSibling(&self) -> Option<Retained<NSXMLNode>>;
338
339        /// Returns the previous node in document order. This can be used to walk the tree backwards.
340        #[unsafe(method(previousNode))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn previousNode(&self) -> Option<Retained<NSXMLNode>>;
343
344        /// Returns the next node in document order. This can be used to walk the tree forwards.
345        #[unsafe(method(nextNode))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn nextNode(&self) -> Option<Retained<NSXMLNode>>;
348
349        /// Detaches this node from its parent.
350        #[unsafe(method(detach))]
351        #[unsafe(method_family = none)]
352        pub unsafe fn detach(&self);
353
354        #[cfg(feature = "NSString")]
355        /// Returns the XPath to this node, for example foo/bar[2]/baz.
356        #[unsafe(method(XPath))]
357        #[unsafe(method_family = none)]
358        pub unsafe fn XPath(&self) -> Option<Retained<NSString>>;
359
360        #[cfg(feature = "NSString")]
361        /// Returns the local name bar if this attribute or element's name is foo:bar
362        #[unsafe(method(localName))]
363        #[unsafe(method_family = none)]
364        pub unsafe fn localName(&self) -> Option<Retained<NSString>>;
365
366        #[cfg(feature = "NSString")]
367        /// Returns the prefix foo if this attribute or element's name if foo:bar
368        #[unsafe(method(prefix))]
369        #[unsafe(method_family = none)]
370        pub unsafe fn prefix(&self) -> Option<Retained<NSString>>;
371
372        #[cfg(feature = "NSString")]
373        /// 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.
374        #[unsafe(method(URI))]
375        #[unsafe(method_family = none)]
376        pub unsafe fn URI(&self) -> Option<Retained<NSString>>;
377
378        #[cfg(feature = "NSString")]
379        /// Setter for [`URI`][Self::URI].
380        #[unsafe(method(setURI:))]
381        #[unsafe(method_family = none)]
382        pub unsafe fn setURI(&self, uri: Option<&NSString>);
383
384        #[cfg(feature = "NSString")]
385        /// Returns the local name bar in foo:bar.
386        #[unsafe(method(localNameForName:))]
387        #[unsafe(method_family = none)]
388        pub unsafe fn localNameForName(name: &NSString) -> Retained<NSString>;
389
390        #[cfg(feature = "NSString")]
391        /// Returns the prefix foo in the name foo:bar.
392        #[unsafe(method(prefixForName:))]
393        #[unsafe(method_family = none)]
394        pub unsafe fn prefixForName(name: &NSString) -> Option<Retained<NSString>>;
395
396        #[cfg(feature = "NSString")]
397        /// Returns the namespace belonging to one of the predefined namespaces xml, xs, or xsi
398        #[unsafe(method(predefinedNamespaceForPrefix:))]
399        #[unsafe(method_family = none)]
400        pub unsafe fn predefinedNamespaceForPrefix(name: &NSString) -> Option<Retained<NSXMLNode>>;
401
402        #[cfg(feature = "NSString")]
403        /// Used for debugging. May give more information than XMLString.
404        #[unsafe(method(description))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn description(&self) -> Retained<NSString>;
407
408        #[cfg(feature = "NSString")]
409        /// The representation of this node as it would appear in an XML document.
410        #[unsafe(method(XMLString))]
411        #[unsafe(method_family = none)]
412        pub unsafe fn XMLString(&self) -> Retained<NSString>;
413
414        #[cfg(all(feature = "NSString", feature = "NSXMLNodeOptions"))]
415        /// The representation of this node as it would appear in an XML document, with various output options available.
416        #[unsafe(method(XMLStringWithOptions:))]
417        #[unsafe(method_family = none)]
418        pub unsafe fn XMLStringWithOptions(&self, options: NSXMLNodeOptions) -> Retained<NSString>;
419
420        #[cfg(feature = "NSString")]
421        /// W3 canonical form (http://www.w3.org/TR/xml-c14n). The input option NSXMLNodePreserveWhitespace should be set for true canonical form.
422        #[unsafe(method(canonicalXMLStringPreservingComments:))]
423        #[unsafe(method_family = none)]
424        pub unsafe fn canonicalXMLStringPreservingComments(
425            &self,
426            comments: bool,
427        ) -> Retained<NSString>;
428
429        #[cfg(all(feature = "NSArray", feature = "NSError", feature = "NSString"))]
430        /// 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.
431        ///
432        /// Returns: An array whose elements are a kind of NSXMLNode.
433        #[unsafe(method(nodesForXPath:error:_))]
434        #[unsafe(method_family = none)]
435        pub unsafe fn nodesForXPath_error(
436            &self,
437            xpath: &NSString,
438        ) -> Result<Retained<NSArray<NSXMLNode>>, Retained<NSError>>;
439
440        #[cfg(all(
441            feature = "NSArray",
442            feature = "NSDictionary",
443            feature = "NSError",
444            feature = "NSString"
445        ))]
446        /// 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.
447        ///
448        /// Returns: An array whose elements are kinds of NSArray, NSData, NSDate, NSNumber, NSString, NSURL, or NSXMLNode.
449        #[unsafe(method(objectsForXQuery:constants:error:_))]
450        #[unsafe(method_family = none)]
451        pub unsafe fn objectsForXQuery_constants_error(
452            &self,
453            xquery: &NSString,
454            constants: Option<&NSDictionary<NSString, AnyObject>>,
455        ) -> Result<Retained<NSArray>, Retained<NSError>>;
456
457        #[cfg(all(feature = "NSArray", feature = "NSError", feature = "NSString"))]
458        #[unsafe(method(objectsForXQuery:error:_))]
459        #[unsafe(method_family = none)]
460        pub unsafe fn objectsForXQuery_error(
461            &self,
462            xquery: &NSString,
463        ) -> Result<Retained<NSArray>, Retained<NSError>>;
464    );
465}
466
467/// Methods declared on superclass `NSObject`.
468impl NSXMLNode {
469    extern_methods!(
470        #[unsafe(method(new))]
471        #[unsafe(method_family = new)]
472        pub unsafe fn new() -> Retained<Self>;
473    );
474}