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