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 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 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 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 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 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 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 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 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 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 fn attributes(&self) -> Option<Retained<NSArray<NSXMLNode>>>;
133
134        #[cfg(feature = "NSArray")]
135        /// Setter for [`attributes`][Self::attributes].
136        ///
137        /// This is [copied][crate::NSCopying::copy] when set.
138        #[unsafe(method(setAttributes:))]
139        #[unsafe(method_family = none)]
140        pub fn setAttributes(&self, attributes: Option<&NSArray<NSXMLNode>>);
141
142        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
143        /// Set the attributes based on a name-value dictionary.
144        #[unsafe(method(setAttributesWithDictionary:))]
145        #[unsafe(method_family = none)]
146        pub fn setAttributesWithDictionary(&self, attributes: &NSDictionary<NSString, NSString>);
147
148        #[cfg(feature = "NSString")]
149        /// Returns an attribute matching this name.
150        #[unsafe(method(attributeForName:))]
151        #[unsafe(method_family = none)]
152        pub fn attributeForName(&self, name: &NSString) -> Option<Retained<NSXMLNode>>;
153
154        #[cfg(feature = "NSString")]
155        /// Returns an attribute matching this localname URI pair.
156        #[unsafe(method(attributeForLocalName:URI:))]
157        #[unsafe(method_family = none)]
158        pub fn attributeForLocalName_URI(
159            &self,
160            local_name: &NSString,
161            uri: Option<&NSString>,
162        ) -> Option<Retained<NSXMLNode>>;
163
164        /// Adds a namespace. Namespaces with duplicate names are not added.
165        #[unsafe(method(addNamespace:))]
166        #[unsafe(method_family = none)]
167        pub fn addNamespace(&self, a_namespace: &NSXMLNode);
168
169        #[cfg(feature = "NSString")]
170        /// Removes a namespace with a particular name.
171        #[unsafe(method(removeNamespaceForPrefix:))]
172        #[unsafe(method_family = none)]
173        pub fn removeNamespaceForPrefix(&self, name: &NSString);
174
175        #[cfg(feature = "NSArray")]
176        /// Set the namespaces. In the case of duplicate names, the first namespace with the name is used.
177        #[unsafe(method(namespaces))]
178        #[unsafe(method_family = none)]
179        pub fn namespaces(&self) -> Option<Retained<NSArray<NSXMLNode>>>;
180
181        #[cfg(feature = "NSArray")]
182        /// Setter for [`namespaces`][Self::namespaces].
183        ///
184        /// This is [copied][crate::NSCopying::copy] when set.
185        #[unsafe(method(setNamespaces:))]
186        #[unsafe(method_family = none)]
187        pub fn setNamespaces(&self, namespaces: Option<&NSArray<NSXMLNode>>);
188
189        #[cfg(feature = "NSString")]
190        /// Returns the namespace matching this prefix.
191        #[unsafe(method(namespaceForPrefix:))]
192        #[unsafe(method_family = none)]
193        pub fn namespaceForPrefix(&self, name: &NSString) -> Option<Retained<NSXMLNode>>;
194
195        #[cfg(feature = "NSString")]
196        /// Returns the namespace who matches the prefix of the name given. Looks in the entire namespace chain.
197        #[unsafe(method(resolveNamespaceForName:))]
198        #[unsafe(method_family = none)]
199        pub fn resolveNamespaceForName(&self, name: &NSString) -> Option<Retained<NSXMLNode>>;
200
201        #[cfg(feature = "NSString")]
202        /// Returns the URI of this prefix. Looks in the entire namespace chain.
203        #[unsafe(method(resolvePrefixForNamespaceURI:))]
204        #[unsafe(method_family = none)]
205        pub fn resolvePrefixForNamespaceURI(
206            &self,
207            namespace_uri: &NSString,
208        ) -> Option<Retained<NSString>>;
209
210        /// Inserts a child at a particular index.
211        #[unsafe(method(insertChild:atIndex:))]
212        #[unsafe(method_family = none)]
213        pub fn insertChild_atIndex(&self, child: &NSXMLNode, index: NSUInteger);
214
215        #[cfg(feature = "NSArray")]
216        /// Insert several children at a particular index.
217        #[unsafe(method(insertChildren:atIndex:))]
218        #[unsafe(method_family = none)]
219        pub fn insertChildren_atIndex(&self, children: &NSArray<NSXMLNode>, index: NSUInteger);
220
221        /// Removes a child at a particular index.
222        #[unsafe(method(removeChildAtIndex:))]
223        #[unsafe(method_family = none)]
224        pub fn removeChildAtIndex(&self, index: NSUInteger);
225
226        #[cfg(feature = "NSArray")]
227        /// Removes all existing children and replaces them with the new children. Set children to nil to simply remove all children.
228        #[unsafe(method(setChildren:))]
229        #[unsafe(method_family = none)]
230        pub fn setChildren(&self, children: Option<&NSArray<NSXMLNode>>);
231
232        /// Adds a child to the end of the existing children.
233        #[unsafe(method(addChild:))]
234        #[unsafe(method_family = none)]
235        pub fn addChild(&self, child: &NSXMLNode);
236
237        /// Replaces a child at a particular index with another child.
238        #[unsafe(method(replaceChildAtIndex:withNode:))]
239        #[unsafe(method_family = none)]
240        pub fn replaceChildAtIndex_withNode(&self, index: NSUInteger, node: &NSXMLNode);
241
242        /// 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.
243        #[unsafe(method(normalizeAdjacentTextNodesPreservingCDATA:))]
244        #[unsafe(method_family = none)]
245        pub fn normalizeAdjacentTextNodesPreservingCDATA(&self, preserve: bool);
246    );
247}
248
249/// Methods declared on superclass `NSXMLNode`.
250#[cfg(feature = "NSXMLNode")]
251impl NSXMLElement {
252    extern_methods!(
253        #[unsafe(method(init))]
254        #[unsafe(method_family = init)]
255        pub fn init(this: Allocated<Self>) -> Retained<Self>;
256
257        /// Invokes
258        ///
259        /// ```text
260        ///  initWithKind:options:
261        /// ```
262        ///
263        /// with options set to NSXMLNodeOptionsNone
264        #[unsafe(method(initWithKind:))]
265        #[unsafe(method_family = init)]
266        pub fn initWithKind(this: Allocated<Self>, kind: NSXMLNodeKind) -> Retained<Self>;
267    );
268}
269
270/// Methods declared on superclass `NSObject`.
271#[cfg(feature = "NSXMLNode")]
272impl NSXMLElement {
273    extern_methods!(
274        #[unsafe(method(new))]
275        #[unsafe(method_family = new)]
276        pub fn new() -> Retained<Self>;
277    );
278}
279
280#[cfg(feature = "NSXMLNode")]
281impl DefaultRetained for NSXMLElement {
282    #[inline]
283    fn default_retained() -> Retained<Self> {
284        Self::new()
285    }
286}
287
288/// NSDeprecated.
289#[cfg(feature = "NSXMLNode")]
290impl NSXMLElement {
291    extern_methods!(
292        #[cfg(feature = "NSDictionary")]
293        /// Set the attributes base on a name-value dictionary.
294        ///
295        /// This method is deprecated and does not function correctly. Use -setAttributesWithDictionary: instead.
296        ///
297        /// # Safety
298        ///
299        /// `attributes` generic should be of the correct type.
300        #[deprecated]
301        #[unsafe(method(setAttributesAsDictionary:))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn setAttributesAsDictionary(&self, attributes: &NSDictionary);
304    );
305}