objc2_foundation/generated/
NSXMLElement.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
9extern_class!(
10    /// An XML element
11    ///
12    /// Note: Trying to add a document, namespace, attribute, or node with a parent throws an exception. To add a node with a parent first detach or create a copy of it.
13    ///
14    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsxmlelement?language=objc)
15    #[unsafe(super(NSXMLNode, NSObject))]
16    #[derive(Debug, PartialEq, Eq, Hash)]
17    #[cfg(feature = "NSXMLNode")]
18    pub struct NSXMLElement;
19);
20
21#[cfg(all(feature = "NSObject", feature = "NSXMLNode"))]
22extern_conformance!(
23    unsafe impl NSCopying for NSXMLElement {}
24);
25
26#[cfg(all(feature = "NSObject", feature = "NSXMLNode"))]
27unsafe impl CopyingHelper for NSXMLElement {
28    type Result = Self;
29}
30
31#[cfg(feature = "NSXMLNode")]
32extern_conformance!(
33    unsafe impl NSObjectProtocol for NSXMLElement {}
34);
35
36#[cfg(feature = "NSXMLNode")]
37impl NSXMLElement {
38    extern_methods!(
39        #[cfg(feature = "NSString")]
40        /// Returns an element
41        /// <tt>
42        /// <
43        /// name>
44        /// <
45        /// /name>
46        /// </tt>
47        /// .
48        #[unsafe(method(initWithName:))]
49        #[unsafe(method_family = init)]
50        pub unsafe fn initWithName(this: Allocated<Self>, name: &NSString) -> Retained<Self>;
51
52        #[cfg(feature = "NSString")]
53        /// Returns an element whose full QName is specified.
54        #[unsafe(method(initWithName:URI:))]
55        #[unsafe(method_family = init)]
56        pub unsafe fn initWithName_URI(
57            this: Allocated<Self>,
58            name: &NSString,
59            uri: Option<&NSString>,
60        ) -> Retained<Self>;
61
62        #[cfg(feature = "NSString")]
63        /// Returns an element with a single text node child
64        /// <tt>
65        /// <
66        /// name>string
67        /// <
68        /// /name>
69        /// </tt>
70        /// .
71        #[unsafe(method(initWithName:stringValue:))]
72        #[unsafe(method_family = init)]
73        pub unsafe fn initWithName_stringValue(
74            this: Allocated<Self>,
75            name: &NSString,
76            string: Option<&NSString>,
77        ) -> Retained<Self>;
78
79        #[cfg(all(feature = "NSError", feature = "NSString"))]
80        /// Returns an element created from a string. Parse errors are collected in
81        /// <tt>
82        /// error
83        /// </tt>
84        /// .
85        #[unsafe(method(initWithXMLString:error:_))]
86        #[unsafe(method_family = init)]
87        pub unsafe fn initWithXMLString_error(
88            this: Allocated<Self>,
89            string: &NSString,
90        ) -> Result<Retained<Self>, Retained<NSError>>;
91
92        #[cfg(feature = "NSXMLNodeOptions")]
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        #[cfg(all(feature = "NSArray", feature = "NSString"))]
102        /// Returns all of the child elements that match this name.
103        #[unsafe(method(elementsForName:))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn elementsForName(&self, name: &NSString) -> Retained<NSArray<NSXMLElement>>;
106
107        #[cfg(all(feature = "NSArray", feature = "NSString"))]
108        /// Returns all of the child elements that match this localname URI pair.
109        #[unsafe(method(elementsForLocalName:URI:))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn elementsForLocalName_URI(
112            &self,
113            local_name: &NSString,
114            uri: Option<&NSString>,
115        ) -> Retained<NSArray<NSXMLElement>>;
116
117        /// Adds an attribute. Attributes with duplicate names are not added.
118        #[unsafe(method(addAttribute:))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn addAttribute(&self, attribute: &NSXMLNode);
121
122        #[cfg(feature = "NSString")]
123        /// Removes an attribute based on its name.
124        #[unsafe(method(removeAttributeForName:))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn removeAttributeForName(&self, name: &NSString);
127
128        #[cfg(feature = "NSArray")]
129        /// Set the attributes. In the case of duplicate names, the first attribute with the name is used.
130        #[unsafe(method(attributes))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn attributes(&self) -> Option<Retained<NSArray<NSXMLNode>>>;
133
134        #[cfg(feature = "NSArray")]
135        /// Setter for [`attributes`][Self::attributes].
136        #[unsafe(method(setAttributes:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn setAttributes(&self, attributes: Option<&NSArray<NSXMLNode>>);
139
140        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
141        /// Set the attributes based on a name-value dictionary.
142        #[unsafe(method(setAttributesWithDictionary:))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn setAttributesWithDictionary(
145            &self,
146            attributes: &NSDictionary<NSString, NSString>,
147        );
148
149        #[cfg(feature = "NSString")]
150        /// Returns an attribute matching this name.
151        #[unsafe(method(attributeForName:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn attributeForName(&self, name: &NSString) -> Option<Retained<NSXMLNode>>;
154
155        #[cfg(feature = "NSString")]
156        /// Returns an attribute matching this localname URI pair.
157        #[unsafe(method(attributeForLocalName:URI:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn attributeForLocalName_URI(
160            &self,
161            local_name: &NSString,
162            uri: Option<&NSString>,
163        ) -> Option<Retained<NSXMLNode>>;
164
165        /// Adds a namespace. Namespaces with duplicate names are not added.
166        #[unsafe(method(addNamespace:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn addNamespace(&self, a_namespace: &NSXMLNode);
169
170        #[cfg(feature = "NSString")]
171        /// Removes a namespace with a particular name.
172        #[unsafe(method(removeNamespaceForPrefix:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn removeNamespaceForPrefix(&self, name: &NSString);
175
176        #[cfg(feature = "NSArray")]
177        /// Set the namespaces. In the case of duplicate names, the first namespace with the name is used.
178        #[unsafe(method(namespaces))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn namespaces(&self) -> Option<Retained<NSArray<NSXMLNode>>>;
181
182        #[cfg(feature = "NSArray")]
183        /// Setter for [`namespaces`][Self::namespaces].
184        #[unsafe(method(setNamespaces:))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn setNamespaces(&self, namespaces: Option<&NSArray<NSXMLNode>>);
187
188        #[cfg(feature = "NSString")]
189        /// Returns the namespace matching this prefix.
190        #[unsafe(method(namespaceForPrefix:))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn namespaceForPrefix(&self, name: &NSString) -> Option<Retained<NSXMLNode>>;
193
194        #[cfg(feature = "NSString")]
195        /// Returns the namespace who matches the prefix of the name given. Looks in the entire namespace chain.
196        #[unsafe(method(resolveNamespaceForName:))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn resolveNamespaceForName(
199            &self,
200            name: &NSString,
201        ) -> Option<Retained<NSXMLNode>>;
202
203        #[cfg(feature = "NSString")]
204        /// Returns the URI of this prefix. Looks in the entire namespace chain.
205        #[unsafe(method(resolvePrefixForNamespaceURI:))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn resolvePrefixForNamespaceURI(
208            &self,
209            namespace_uri: &NSString,
210        ) -> Option<Retained<NSString>>;
211
212        /// Inserts a child at a particular index.
213        #[unsafe(method(insertChild:atIndex:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn insertChild_atIndex(&self, child: &NSXMLNode, index: NSUInteger);
216
217        #[cfg(feature = "NSArray")]
218        /// Insert several children at a particular index.
219        #[unsafe(method(insertChildren:atIndex:))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn insertChildren_atIndex(
222            &self,
223            children: &NSArray<NSXMLNode>,
224            index: NSUInteger,
225        );
226
227        /// Removes a child at a particular index.
228        #[unsafe(method(removeChildAtIndex:))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn removeChildAtIndex(&self, index: NSUInteger);
231
232        #[cfg(feature = "NSArray")]
233        /// Removes all existing children and replaces them with the new children. Set children to nil to simply remove all children.
234        #[unsafe(method(setChildren:))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn setChildren(&self, children: Option<&NSArray<NSXMLNode>>);
237
238        /// Adds a child to the end of the existing children.
239        #[unsafe(method(addChild:))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn addChild(&self, child: &NSXMLNode);
242
243        /// Replaces a child at a particular index with another child.
244        #[unsafe(method(replaceChildAtIndex:withNode:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn replaceChildAtIndex_withNode(&self, index: NSUInteger, node: &NSXMLNode);
247
248        /// Adjacent text nodes are coalesced. If the node's value is the empty string, it is removed. This should be called with a value of NO before using XQuery or XPath.
249        #[unsafe(method(normalizeAdjacentTextNodesPreservingCDATA:))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn normalizeAdjacentTextNodesPreservingCDATA(&self, preserve: bool);
252    );
253}
254
255/// Methods declared on superclass `NSXMLNode`.
256#[cfg(feature = "NSXMLNode")]
257impl NSXMLElement {
258    extern_methods!(
259        #[unsafe(method(init))]
260        #[unsafe(method_family = init)]
261        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
262
263        /// Invokes
264        ///
265        /// ```text
266        ///  initWithKind:options:
267        /// ```
268        ///
269        /// with options set to NSXMLNodeOptionsNone
270        #[unsafe(method(initWithKind:))]
271        #[unsafe(method_family = init)]
272        pub unsafe fn initWithKind(this: Allocated<Self>, kind: NSXMLNodeKind) -> Retained<Self>;
273    );
274}
275
276/// Methods declared on superclass `NSObject`.
277#[cfg(feature = "NSXMLNode")]
278impl NSXMLElement {
279    extern_methods!(
280        #[unsafe(method(new))]
281        #[unsafe(method_family = new)]
282        pub unsafe fn new() -> Retained<Self>;
283    );
284}
285
286/// NSDeprecated.
287#[cfg(feature = "NSXMLNode")]
288impl NSXMLElement {
289    extern_methods!(
290        #[cfg(feature = "NSDictionary")]
291        /// Set the attributes base on a name-value dictionary.
292        ///
293        /// This method is deprecated and does not function correctly. Use -setAttributesWithDictionary: instead.
294        #[deprecated]
295        #[unsafe(method(setAttributesAsDictionary:))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn setAttributesAsDictionary(&self, attributes: &NSDictionary);
298    );
299}