objc2_foundation/generated/
NSXMLDocument.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/// Define what type of document this is.
10///
11/// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsxmldocumentcontentkind?language=objc)
12// NS_ENUM
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct NSXMLDocumentContentKind(pub NSUInteger);
16impl NSXMLDocumentContentKind {
17    #[doc(alias = "NSXMLDocumentXMLKind")]
18    pub const XMLKind: Self = Self(0);
19    #[doc(alias = "NSXMLDocumentXHTMLKind")]
20    pub const XHTMLKind: Self = Self(1);
21    #[doc(alias = "NSXMLDocumentHTMLKind")]
22    pub const HTMLKind: Self = Self(2);
23    #[doc(alias = "NSXMLDocumentTextKind")]
24    pub const TextKind: Self = Self(3);
25}
26
27unsafe impl Encode for NSXMLDocumentContentKind {
28    const ENCODING: Encoding = NSUInteger::ENCODING;
29}
30
31unsafe impl RefEncode for NSXMLDocumentContentKind {
32    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35extern_class!(
36    /// An XML Document
37    ///
38    /// Note: if the application of a method would result in more than one element in the children array, an exception is thrown. Trying to add a document, namespace, attribute, or node with a parent also throws an exception. To add a node with a parent first detach or create a copy of it.
39    ///
40    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsxmldocument?language=objc)
41    #[unsafe(super(NSXMLNode, NSObject))]
42    #[derive(Debug, PartialEq, Eq, Hash)]
43    #[cfg(feature = "NSXMLNode")]
44    pub struct NSXMLDocument;
45);
46
47#[cfg(all(feature = "NSObject", feature = "NSXMLNode"))]
48extern_conformance!(
49    unsafe impl NSCopying for NSXMLDocument {}
50);
51
52#[cfg(all(feature = "NSObject", feature = "NSXMLNode"))]
53unsafe impl CopyingHelper for NSXMLDocument {
54    type Result = Self;
55}
56
57#[cfg(feature = "NSXMLNode")]
58extern_conformance!(
59    unsafe impl NSObjectProtocol for NSXMLDocument {}
60);
61
62#[cfg(feature = "NSXMLNode")]
63impl NSXMLDocument {
64    extern_methods!(
65        #[unsafe(method(init))]
66        #[unsafe(method_family = init)]
67        pub fn init(this: Allocated<Self>) -> Retained<Self>;
68
69        #[cfg(all(
70            feature = "NSError",
71            feature = "NSString",
72            feature = "NSXMLNodeOptions"
73        ))]
74        /// Returns a document created from either XML or HTML, if the HTMLTidy option is set. Parse errors are returned in
75        /// <tt>
76        /// error
77        /// </tt>
78        /// .
79        #[unsafe(method(initWithXMLString:options:error:_))]
80        #[unsafe(method_family = init)]
81        pub fn initWithXMLString_options_error(
82            this: Allocated<Self>,
83            string: &NSString,
84            mask: NSXMLNodeOptions,
85        ) -> Result<Retained<Self>, Retained<NSError>>;
86
87        #[cfg(all(feature = "NSError", feature = "NSURL", feature = "NSXMLNodeOptions"))]
88        /// Returns a document created from the contents of an XML or HTML URL. Connection problems such as 404, parse errors are returned in
89        /// <tt>
90        /// error
91        /// </tt>
92        /// .
93        #[unsafe(method(initWithContentsOfURL:options:error:_))]
94        #[unsafe(method_family = init)]
95        pub fn initWithContentsOfURL_options_error(
96            this: Allocated<Self>,
97            url: &NSURL,
98            mask: NSXMLNodeOptions,
99        ) -> Result<Retained<Self>, Retained<NSError>>;
100
101        #[cfg(all(feature = "NSData", feature = "NSError", feature = "NSXMLNodeOptions"))]
102        /// Returns a document created from data. Parse errors are returned in
103        /// <tt>
104        /// error
105        /// </tt>
106        /// .
107        #[unsafe(method(initWithData:options:error:_))]
108        #[unsafe(method_family = init)]
109        pub fn initWithData_options_error(
110            this: Allocated<Self>,
111            data: &NSData,
112            mask: NSXMLNodeOptions,
113        ) -> Result<Retained<Self>, Retained<NSError>>;
114
115        #[cfg(feature = "NSXMLElement")]
116        /// Returns a document with a single child, the root element.
117        #[unsafe(method(initWithRootElement:))]
118        #[unsafe(method_family = init)]
119        pub fn initWithRootElement(
120            this: Allocated<Self>,
121            element: Option<&NSXMLElement>,
122        ) -> Retained<Self>;
123
124        /// # Safety
125        ///
126        /// `cls` probably has further requirements.
127        #[unsafe(method(replacementClassForClass:))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn replacementClassForClass(cls: &AnyClass) -> &'static AnyClass;
130
131        #[cfg(feature = "NSString")]
132        /// Sets the character encoding to an IANA type.
133        #[unsafe(method(characterEncoding))]
134        #[unsafe(method_family = none)]
135        pub fn characterEncoding(&self) -> Option<Retained<NSString>>;
136
137        #[cfg(feature = "NSString")]
138        /// Setter for [`characterEncoding`][Self::characterEncoding].
139        ///
140        /// This is [copied][crate::NSCopying::copy] when set.
141        #[unsafe(method(setCharacterEncoding:))]
142        #[unsafe(method_family = none)]
143        pub fn setCharacterEncoding(&self, character_encoding: Option<&NSString>);
144
145        #[cfg(feature = "NSString")]
146        /// Sets the XML version. Should be 1.0 or 1.1.
147        #[unsafe(method(version))]
148        #[unsafe(method_family = none)]
149        pub fn version(&self) -> Option<Retained<NSString>>;
150
151        #[cfg(feature = "NSString")]
152        /// Setter for [`version`][Self::version].
153        ///
154        /// This is [copied][crate::NSCopying::copy] when set.
155        #[unsafe(method(setVersion:))]
156        #[unsafe(method_family = none)]
157        pub fn setVersion(&self, version: Option<&NSString>);
158
159        /// Set whether this document depends on an external DTD. If this option is set the standalone declaration will appear on output.
160        #[unsafe(method(isStandalone))]
161        #[unsafe(method_family = none)]
162        pub fn isStandalone(&self) -> bool;
163
164        /// Setter for [`isStandalone`][Self::isStandalone].
165        #[unsafe(method(setStandalone:))]
166        #[unsafe(method_family = none)]
167        pub fn setStandalone(&self, standalone: bool);
168
169        /// The kind of document.
170        #[unsafe(method(documentContentKind))]
171        #[unsafe(method_family = none)]
172        pub fn documentContentKind(&self) -> NSXMLDocumentContentKind;
173
174        /// Setter for [`documentContentKind`][Self::documentContentKind].
175        #[unsafe(method(setDocumentContentKind:))]
176        #[unsafe(method_family = none)]
177        pub fn setDocumentContentKind(&self, document_content_kind: NSXMLDocumentContentKind);
178
179        #[cfg(feature = "NSString")]
180        /// Set the MIME type, eg text/xml.
181        #[unsafe(method(MIMEType))]
182        #[unsafe(method_family = none)]
183        pub fn MIMEType(&self) -> Option<Retained<NSString>>;
184
185        #[cfg(feature = "NSString")]
186        /// Setter for [`MIMEType`][Self::MIMEType].
187        ///
188        /// This is [copied][crate::NSCopying::copy] when set.
189        #[unsafe(method(setMIMEType:))]
190        #[unsafe(method_family = none)]
191        pub fn setMIMEType(&self, mime_type: Option<&NSString>);
192
193        #[cfg(feature = "NSXMLDTD")]
194        /// Set the associated DTD. This DTD will be output with the document.
195        #[unsafe(method(DTD))]
196        #[unsafe(method_family = none)]
197        pub fn DTD(&self) -> Option<Retained<NSXMLDTD>>;
198
199        #[cfg(feature = "NSXMLDTD")]
200        /// Setter for [`DTD`][Self::DTD].
201        ///
202        /// This is [copied][crate::NSCopying::copy] when set.
203        #[unsafe(method(setDTD:))]
204        #[unsafe(method_family = none)]
205        pub fn setDTD(&self, dtd: Option<&NSXMLDTD>);
206
207        #[cfg(feature = "NSXMLElement")]
208        /// Set the root element. Removes all other children including comments and processing-instructions.
209        #[unsafe(method(setRootElement:))]
210        #[unsafe(method_family = none)]
211        pub fn setRootElement(&self, root: &NSXMLElement);
212
213        #[cfg(feature = "NSXMLElement")]
214        /// The root element.
215        #[unsafe(method(rootElement))]
216        #[unsafe(method_family = none)]
217        pub fn rootElement(&self) -> Option<Retained<NSXMLElement>>;
218
219        /// Inserts a child at a particular index.
220        #[unsafe(method(insertChild:atIndex:))]
221        #[unsafe(method_family = none)]
222        pub fn insertChild_atIndex(&self, child: &NSXMLNode, index: NSUInteger);
223
224        #[cfg(feature = "NSArray")]
225        /// Insert several children at a particular index.
226        #[unsafe(method(insertChildren:atIndex:))]
227        #[unsafe(method_family = none)]
228        pub fn insertChildren_atIndex(&self, children: &NSArray<NSXMLNode>, index: NSUInteger);
229
230        /// Removes a child at a particular index.
231        #[unsafe(method(removeChildAtIndex:))]
232        #[unsafe(method_family = none)]
233        pub fn removeChildAtIndex(&self, index: NSUInteger);
234
235        #[cfg(feature = "NSArray")]
236        /// Removes all existing children and replaces them with the new children. Set children to nil to simply remove all children.
237        #[unsafe(method(setChildren:))]
238        #[unsafe(method_family = none)]
239        pub fn setChildren(&self, children: Option<&NSArray<NSXMLNode>>);
240
241        /// Adds a child to the end of the existing children.
242        #[unsafe(method(addChild:))]
243        #[unsafe(method_family = none)]
244        pub fn addChild(&self, child: &NSXMLNode);
245
246        /// Replaces a child at a particular index with another child.
247        #[unsafe(method(replaceChildAtIndex:withNode:))]
248        #[unsafe(method_family = none)]
249        pub fn replaceChildAtIndex_withNode(&self, index: NSUInteger, node: &NSXMLNode);
250
251        #[cfg(feature = "NSData")]
252        /// Invokes XMLDataWithOptions with NSXMLNodeOptionsNone.
253        #[unsafe(method(XMLData))]
254        #[unsafe(method_family = none)]
255        pub fn XMLData(&self) -> Retained<NSData>;
256
257        #[cfg(all(feature = "NSData", feature = "NSXMLNodeOptions"))]
258        /// The representation of this node as it would appear in an XML document, encoded based on characterEncoding.
259        #[unsafe(method(XMLDataWithOptions:))]
260        #[unsafe(method_family = none)]
261        pub fn XMLDataWithOptions(&self, options: NSXMLNodeOptions) -> Retained<NSData>;
262
263        #[cfg(all(
264            feature = "NSData",
265            feature = "NSDictionary",
266            feature = "NSError",
267            feature = "NSString"
268        ))]
269        /// Applies XSLT with arguments (NSString key/value pairs) to this document, returning a new document.
270        #[unsafe(method(objectByApplyingXSLT:arguments:error:_))]
271        #[unsafe(method_family = none)]
272        pub fn objectByApplyingXSLT_arguments_error(
273            &self,
274            xslt: &NSData,
275            arguments: Option<&NSDictionary<NSString, NSString>>,
276        ) -> Result<Retained<AnyObject>, Retained<NSError>>;
277
278        #[cfg(all(feature = "NSDictionary", feature = "NSError", feature = "NSString"))]
279        /// Applies XSLT as expressed by a string with arguments (NSString key/value pairs) to this document, returning a new document.
280        #[unsafe(method(objectByApplyingXSLTString:arguments:error:_))]
281        #[unsafe(method_family = none)]
282        pub fn objectByApplyingXSLTString_arguments_error(
283            &self,
284            xslt: &NSString,
285            arguments: Option<&NSDictionary<NSString, NSString>>,
286        ) -> Result<Retained<AnyObject>, Retained<NSError>>;
287
288        #[cfg(all(
289            feature = "NSDictionary",
290            feature = "NSError",
291            feature = "NSString",
292            feature = "NSURL"
293        ))]
294        /// Applies the XSLT at a URL with arguments (NSString key/value pairs) to this document, returning a new document. Error may contain a connection error from the URL.
295        #[unsafe(method(objectByApplyingXSLTAtURL:arguments:error:_))]
296        #[unsafe(method_family = none)]
297        pub fn objectByApplyingXSLTAtURL_arguments_error(
298            &self,
299            xslt_url: &NSURL,
300            argument: Option<&NSDictionary<NSString, NSString>>,
301        ) -> Result<Retained<AnyObject>, Retained<NSError>>;
302
303        #[cfg(feature = "NSError")]
304        #[unsafe(method(validateAndReturnError:_))]
305        #[unsafe(method_family = none)]
306        pub fn validateAndReturnError(&self) -> Result<(), Retained<NSError>>;
307    );
308}
309
310/// Methods declared on superclass `NSXMLNode`.
311#[cfg(feature = "NSXMLNode")]
312impl NSXMLDocument {
313    extern_methods!(
314        /// Invokes
315        ///
316        /// ```text
317        ///  initWithKind:options:
318        /// ```
319        ///
320        /// with options set to NSXMLNodeOptionsNone
321        #[unsafe(method(initWithKind:))]
322        #[unsafe(method_family = init)]
323        pub fn initWithKind(this: Allocated<Self>, kind: NSXMLNodeKind) -> Retained<Self>;
324
325        #[cfg(feature = "NSXMLNodeOptions")]
326        /// Inits a node with fidelity options as description NSXMLNodeOptions.h
327        #[unsafe(method(initWithKind:options:))]
328        #[unsafe(method_family = init)]
329        pub fn initWithKind_options(
330            this: Allocated<Self>,
331            kind: NSXMLNodeKind,
332            options: NSXMLNodeOptions,
333        ) -> Retained<Self>;
334    );
335}
336
337/// Methods declared on superclass `NSObject`.
338#[cfg(feature = "NSXMLNode")]
339impl NSXMLDocument {
340    extern_methods!(
341        #[unsafe(method(new))]
342        #[unsafe(method_family = new)]
343        pub fn new() -> Retained<Self>;
344    );
345}
346
347#[cfg(feature = "NSXMLNode")]
348impl DefaultRetained for NSXMLDocument {
349    #[inline]
350    fn default_retained() -> Retained<Self> {
351        Self::new()
352    }
353}