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"))]
48unsafe impl NSCopying for NSXMLDocument {}
49
50#[cfg(all(feature = "NSObject", feature = "NSXMLNode"))]
51unsafe impl CopyingHelper for NSXMLDocument {
52    type Result = Self;
53}
54
55#[cfg(feature = "NSXMLNode")]
56unsafe impl NSObjectProtocol for NSXMLDocument {}
57
58#[cfg(feature = "NSXMLNode")]
59impl NSXMLDocument {
60    extern_methods!(
61        #[unsafe(method(init))]
62        #[unsafe(method_family = init)]
63        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
64
65        #[cfg(all(
66            feature = "NSError",
67            feature = "NSString",
68            feature = "NSXMLNodeOptions"
69        ))]
70        /// Returns a document created from either XML or HTML, if the HTMLTidy option is set. Parse errors are returned in
71        /// <tt>
72        /// error
73        /// </tt>
74        /// .
75        #[unsafe(method(initWithXMLString:options:error:_))]
76        #[unsafe(method_family = init)]
77        pub unsafe fn initWithXMLString_options_error(
78            this: Allocated<Self>,
79            string: &NSString,
80            mask: NSXMLNodeOptions,
81        ) -> Result<Retained<Self>, Retained<NSError>>;
82
83        #[cfg(all(feature = "NSError", feature = "NSURL", feature = "NSXMLNodeOptions"))]
84        /// Returns a document created from the contents of an XML or HTML URL. Connection problems such as 404, parse errors are returned in
85        /// <tt>
86        /// error
87        /// </tt>
88        /// .
89        #[unsafe(method(initWithContentsOfURL:options:error:_))]
90        #[unsafe(method_family = init)]
91        pub unsafe fn initWithContentsOfURL_options_error(
92            this: Allocated<Self>,
93            url: &NSURL,
94            mask: NSXMLNodeOptions,
95        ) -> Result<Retained<Self>, Retained<NSError>>;
96
97        #[cfg(all(feature = "NSData", feature = "NSError", feature = "NSXMLNodeOptions"))]
98        /// Returns a document created from data. Parse errors are returned in
99        /// <tt>
100        /// error
101        /// </tt>
102        /// .
103        #[unsafe(method(initWithData:options:error:_))]
104        #[unsafe(method_family = init)]
105        pub unsafe fn initWithData_options_error(
106            this: Allocated<Self>,
107            data: &NSData,
108            mask: NSXMLNodeOptions,
109        ) -> Result<Retained<Self>, Retained<NSError>>;
110
111        #[cfg(feature = "NSXMLElement")]
112        /// Returns a document with a single child, the root element.
113        #[unsafe(method(initWithRootElement:))]
114        #[unsafe(method_family = init)]
115        pub unsafe fn initWithRootElement(
116            this: Allocated<Self>,
117            element: Option<&NSXMLElement>,
118        ) -> Retained<Self>;
119
120        #[unsafe(method(replacementClassForClass:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn replacementClassForClass(cls: &AnyClass) -> &'static AnyClass;
123
124        #[cfg(feature = "NSString")]
125        /// Sets the character encoding to an IANA type.
126        #[unsafe(method(characterEncoding))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn characterEncoding(&self) -> Option<Retained<NSString>>;
129
130        #[cfg(feature = "NSString")]
131        /// Setter for [`characterEncoding`][Self::characterEncoding].
132        #[unsafe(method(setCharacterEncoding:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn setCharacterEncoding(&self, character_encoding: Option<&NSString>);
135
136        #[cfg(feature = "NSString")]
137        /// Sets the XML version. Should be 1.0 or 1.1.
138        #[unsafe(method(version))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn version(&self) -> Option<Retained<NSString>>;
141
142        #[cfg(feature = "NSString")]
143        /// Setter for [`version`][Self::version].
144        #[unsafe(method(setVersion:))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn setVersion(&self, version: Option<&NSString>);
147
148        /// Set whether this document depends on an external DTD. If this option is set the standalone declaration will appear on output.
149        #[unsafe(method(isStandalone))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn isStandalone(&self) -> bool;
152
153        /// Setter for [`isStandalone`][Self::isStandalone].
154        #[unsafe(method(setStandalone:))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn setStandalone(&self, standalone: bool);
157
158        /// The kind of document.
159        #[unsafe(method(documentContentKind))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn documentContentKind(&self) -> NSXMLDocumentContentKind;
162
163        /// Setter for [`documentContentKind`][Self::documentContentKind].
164        #[unsafe(method(setDocumentContentKind:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn setDocumentContentKind(
167            &self,
168            document_content_kind: NSXMLDocumentContentKind,
169        );
170
171        #[cfg(feature = "NSString")]
172        /// Set the MIME type, eg text/xml.
173        #[unsafe(method(MIMEType))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn MIMEType(&self) -> Option<Retained<NSString>>;
176
177        #[cfg(feature = "NSString")]
178        /// Setter for [`MIMEType`][Self::MIMEType].
179        #[unsafe(method(setMIMEType:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setMIMEType(&self, mime_type: Option<&NSString>);
182
183        #[cfg(feature = "NSXMLDTD")]
184        /// Set the associated DTD. This DTD will be output with the document.
185        #[unsafe(method(DTD))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn DTD(&self) -> Option<Retained<NSXMLDTD>>;
188
189        #[cfg(feature = "NSXMLDTD")]
190        /// Setter for [`DTD`][Self::DTD].
191        #[unsafe(method(setDTD:))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn setDTD(&self, dtd: Option<&NSXMLDTD>);
194
195        #[cfg(feature = "NSXMLElement")]
196        /// Set the root element. Removes all other children including comments and processing-instructions.
197        #[unsafe(method(setRootElement:))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn setRootElement(&self, root: &NSXMLElement);
200
201        #[cfg(feature = "NSXMLElement")]
202        /// The root element.
203        #[unsafe(method(rootElement))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn rootElement(&self) -> Option<Retained<NSXMLElement>>;
206
207        /// Inserts a child at a particular index.
208        #[unsafe(method(insertChild:atIndex:))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn insertChild_atIndex(&self, child: &NSXMLNode, index: NSUInteger);
211
212        #[cfg(feature = "NSArray")]
213        /// Insert several children at a particular index.
214        #[unsafe(method(insertChildren:atIndex:))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn insertChildren_atIndex(
217            &self,
218            children: &NSArray<NSXMLNode>,
219            index: NSUInteger,
220        );
221
222        /// Removes a child at a particular index.
223        #[unsafe(method(removeChildAtIndex:))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn removeChildAtIndex(&self, index: NSUInteger);
226
227        #[cfg(feature = "NSArray")]
228        /// Removes all existing children and replaces them with the new children. Set children to nil to simply remove all children.
229        #[unsafe(method(setChildren:))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn setChildren(&self, children: Option<&NSArray<NSXMLNode>>);
232
233        /// Adds a child to the end of the existing children.
234        #[unsafe(method(addChild:))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn addChild(&self, child: &NSXMLNode);
237
238        /// Replaces a child at a particular index with another child.
239        #[unsafe(method(replaceChildAtIndex:withNode:))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn replaceChildAtIndex_withNode(&self, index: NSUInteger, node: &NSXMLNode);
242
243        #[cfg(feature = "NSData")]
244        /// Invokes XMLDataWithOptions with NSXMLNodeOptionsNone.
245        #[unsafe(method(XMLData))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn XMLData(&self) -> Retained<NSData>;
248
249        #[cfg(all(feature = "NSData", feature = "NSXMLNodeOptions"))]
250        /// The representation of this node as it would appear in an XML document, encoded based on characterEncoding.
251        #[unsafe(method(XMLDataWithOptions:))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn XMLDataWithOptions(&self, options: NSXMLNodeOptions) -> Retained<NSData>;
254
255        #[cfg(all(
256            feature = "NSData",
257            feature = "NSDictionary",
258            feature = "NSError",
259            feature = "NSString"
260        ))]
261        /// Applies XSLT with arguments (NSString key/value pairs) to this document, returning a new document.
262        #[unsafe(method(objectByApplyingXSLT:arguments:error:_))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn objectByApplyingXSLT_arguments_error(
265            &self,
266            xslt: &NSData,
267            arguments: Option<&NSDictionary<NSString, NSString>>,
268        ) -> Result<Retained<AnyObject>, Retained<NSError>>;
269
270        #[cfg(all(feature = "NSDictionary", feature = "NSError", feature = "NSString"))]
271        /// Applies XSLT as expressed by a string with arguments (NSString key/value pairs) to this document, returning a new document.
272        #[unsafe(method(objectByApplyingXSLTString:arguments:error:_))]
273        #[unsafe(method_family = none)]
274        pub unsafe fn objectByApplyingXSLTString_arguments_error(
275            &self,
276            xslt: &NSString,
277            arguments: Option<&NSDictionary<NSString, NSString>>,
278        ) -> Result<Retained<AnyObject>, Retained<NSError>>;
279
280        #[cfg(all(
281            feature = "NSDictionary",
282            feature = "NSError",
283            feature = "NSString",
284            feature = "NSURL"
285        ))]
286        /// 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.
287        #[unsafe(method(objectByApplyingXSLTAtURL:arguments:error:_))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn objectByApplyingXSLTAtURL_arguments_error(
290            &self,
291            xslt_url: &NSURL,
292            argument: Option<&NSDictionary<NSString, NSString>>,
293        ) -> Result<Retained<AnyObject>, Retained<NSError>>;
294
295        #[cfg(feature = "NSError")]
296        #[unsafe(method(validateAndReturnError:_))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn validateAndReturnError(&self) -> Result<(), Retained<NSError>>;
299    );
300}
301
302/// Methods declared on superclass `NSXMLNode`.
303#[cfg(feature = "NSXMLNode")]
304impl NSXMLDocument {
305    extern_methods!(
306        /// Invokes
307        ///
308        /// ```text
309        ///  initWithKind:options:
310        /// ```
311        ///
312        /// with options set to NSXMLNodeOptionsNone
313        #[unsafe(method(initWithKind:))]
314        #[unsafe(method_family = init)]
315        pub unsafe fn initWithKind(this: Allocated<Self>, kind: NSXMLNodeKind) -> Retained<Self>;
316
317        #[cfg(feature = "NSXMLNodeOptions")]
318        /// Inits a node with fidelity options as description NSXMLNodeOptions.h
319        #[unsafe(method(initWithKind:options:))]
320        #[unsafe(method_family = init)]
321        pub unsafe fn initWithKind_options(
322            this: Allocated<Self>,
323            kind: NSXMLNodeKind,
324            options: NSXMLNodeOptions,
325        ) -> Retained<Self>;
326    );
327}
328
329/// Methods declared on superclass `NSObject`.
330#[cfg(feature = "NSXMLNode")]
331impl NSXMLDocument {
332    extern_methods!(
333        #[unsafe(method(new))]
334        #[unsafe(method_family = new)]
335        pub unsafe fn new() -> Retained<Self>;
336    );
337}