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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe fn initWithRootElement(
120            this: Allocated<Self>,
121            element: Option<&NSXMLElement>,
122        ) -> Retained<Self>;
123
124        #[unsafe(method(replacementClassForClass:))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn replacementClassForClass(cls: &AnyClass) -> &'static AnyClass;
127
128        #[cfg(feature = "NSString")]
129        /// Sets the character encoding to an IANA type.
130        #[unsafe(method(characterEncoding))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn characterEncoding(&self) -> Option<Retained<NSString>>;
133
134        #[cfg(feature = "NSString")]
135        /// Setter for [`characterEncoding`][Self::characterEncoding].
136        #[unsafe(method(setCharacterEncoding:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn setCharacterEncoding(&self, character_encoding: Option<&NSString>);
139
140        #[cfg(feature = "NSString")]
141        /// Sets the XML version. Should be 1.0 or 1.1.
142        #[unsafe(method(version))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn version(&self) -> Option<Retained<NSString>>;
145
146        #[cfg(feature = "NSString")]
147        /// Setter for [`version`][Self::version].
148        #[unsafe(method(setVersion:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn setVersion(&self, version: Option<&NSString>);
151
152        /// Set whether this document depends on an external DTD. If this option is set the standalone declaration will appear on output.
153        #[unsafe(method(isStandalone))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn isStandalone(&self) -> bool;
156
157        /// Setter for [`isStandalone`][Self::isStandalone].
158        #[unsafe(method(setStandalone:))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn setStandalone(&self, standalone: bool);
161
162        /// The kind of document.
163        #[unsafe(method(documentContentKind))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn documentContentKind(&self) -> NSXMLDocumentContentKind;
166
167        /// Setter for [`documentContentKind`][Self::documentContentKind].
168        #[unsafe(method(setDocumentContentKind:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn setDocumentContentKind(
171            &self,
172            document_content_kind: NSXMLDocumentContentKind,
173        );
174
175        #[cfg(feature = "NSString")]
176        /// Set the MIME type, eg text/xml.
177        #[unsafe(method(MIMEType))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn MIMEType(&self) -> Option<Retained<NSString>>;
180
181        #[cfg(feature = "NSString")]
182        /// Setter for [`MIMEType`][Self::MIMEType].
183        #[unsafe(method(setMIMEType:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn setMIMEType(&self, mime_type: Option<&NSString>);
186
187        #[cfg(feature = "NSXMLDTD")]
188        /// Set the associated DTD. This DTD will be output with the document.
189        #[unsafe(method(DTD))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn DTD(&self) -> Option<Retained<NSXMLDTD>>;
192
193        #[cfg(feature = "NSXMLDTD")]
194        /// Setter for [`DTD`][Self::DTD].
195        #[unsafe(method(setDTD:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn setDTD(&self, dtd: Option<&NSXMLDTD>);
198
199        #[cfg(feature = "NSXMLElement")]
200        /// Set the root element. Removes all other children including comments and processing-instructions.
201        #[unsafe(method(setRootElement:))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn setRootElement(&self, root: &NSXMLElement);
204
205        #[cfg(feature = "NSXMLElement")]
206        /// The root element.
207        #[unsafe(method(rootElement))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn rootElement(&self) -> Option<Retained<NSXMLElement>>;
210
211        /// Inserts a child at a particular index.
212        #[unsafe(method(insertChild:atIndex:))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn insertChild_atIndex(&self, child: &NSXMLNode, index: NSUInteger);
215
216        #[cfg(feature = "NSArray")]
217        /// Insert several children at a particular index.
218        #[unsafe(method(insertChildren:atIndex:))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn insertChildren_atIndex(
221            &self,
222            children: &NSArray<NSXMLNode>,
223            index: NSUInteger,
224        );
225
226        /// Removes a child at a particular index.
227        #[unsafe(method(removeChildAtIndex:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn removeChildAtIndex(&self, index: NSUInteger);
230
231        #[cfg(feature = "NSArray")]
232        /// Removes all existing children and replaces them with the new children. Set children to nil to simply remove all children.
233        #[unsafe(method(setChildren:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn setChildren(&self, children: Option<&NSArray<NSXMLNode>>);
236
237        /// Adds a child to the end of the existing children.
238        #[unsafe(method(addChild:))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn addChild(&self, child: &NSXMLNode);
241
242        /// Replaces a child at a particular index with another child.
243        #[unsafe(method(replaceChildAtIndex:withNode:))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn replaceChildAtIndex_withNode(&self, index: NSUInteger, node: &NSXMLNode);
246
247        #[cfg(feature = "NSData")]
248        /// Invokes XMLDataWithOptions with NSXMLNodeOptionsNone.
249        #[unsafe(method(XMLData))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn XMLData(&self) -> Retained<NSData>;
252
253        #[cfg(all(feature = "NSData", feature = "NSXMLNodeOptions"))]
254        /// The representation of this node as it would appear in an XML document, encoded based on characterEncoding.
255        #[unsafe(method(XMLDataWithOptions:))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn XMLDataWithOptions(&self, options: NSXMLNodeOptions) -> Retained<NSData>;
258
259        #[cfg(all(
260            feature = "NSData",
261            feature = "NSDictionary",
262            feature = "NSError",
263            feature = "NSString"
264        ))]
265        /// Applies XSLT with arguments (NSString key/value pairs) to this document, returning a new document.
266        #[unsafe(method(objectByApplyingXSLT:arguments:error:_))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn objectByApplyingXSLT_arguments_error(
269            &self,
270            xslt: &NSData,
271            arguments: Option<&NSDictionary<NSString, NSString>>,
272        ) -> Result<Retained<AnyObject>, Retained<NSError>>;
273
274        #[cfg(all(feature = "NSDictionary", feature = "NSError", feature = "NSString"))]
275        /// Applies XSLT as expressed by a string with arguments (NSString key/value pairs) to this document, returning a new document.
276        #[unsafe(method(objectByApplyingXSLTString:arguments:error:_))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn objectByApplyingXSLTString_arguments_error(
279            &self,
280            xslt: &NSString,
281            arguments: Option<&NSDictionary<NSString, NSString>>,
282        ) -> Result<Retained<AnyObject>, Retained<NSError>>;
283
284        #[cfg(all(
285            feature = "NSDictionary",
286            feature = "NSError",
287            feature = "NSString",
288            feature = "NSURL"
289        ))]
290        /// 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.
291        #[unsafe(method(objectByApplyingXSLTAtURL:arguments:error:_))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn objectByApplyingXSLTAtURL_arguments_error(
294            &self,
295            xslt_url: &NSURL,
296            argument: Option<&NSDictionary<NSString, NSString>>,
297        ) -> Result<Retained<AnyObject>, Retained<NSError>>;
298
299        #[cfg(feature = "NSError")]
300        #[unsafe(method(validateAndReturnError:_))]
301        #[unsafe(method_family = none)]
302        pub unsafe fn validateAndReturnError(&self) -> Result<(), Retained<NSError>>;
303    );
304}
305
306/// Methods declared on superclass `NSXMLNode`.
307#[cfg(feature = "NSXMLNode")]
308impl NSXMLDocument {
309    extern_methods!(
310        /// Invokes
311        ///
312        /// ```text
313        ///  initWithKind:options:
314        /// ```
315        ///
316        /// with options set to NSXMLNodeOptionsNone
317        #[unsafe(method(initWithKind:))]
318        #[unsafe(method_family = init)]
319        pub unsafe fn initWithKind(this: Allocated<Self>, kind: NSXMLNodeKind) -> Retained<Self>;
320
321        #[cfg(feature = "NSXMLNodeOptions")]
322        /// Inits a node with fidelity options as description NSXMLNodeOptions.h
323        #[unsafe(method(initWithKind:options:))]
324        #[unsafe(method_family = init)]
325        pub unsafe fn initWithKind_options(
326            this: Allocated<Self>,
327            kind: NSXMLNodeKind,
328            options: NSXMLNodeOptions,
329        ) -> Retained<Self>;
330    );
331}
332
333/// Methods declared on superclass `NSObject`.
334#[cfg(feature = "NSXMLNode")]
335impl NSXMLDocument {
336    extern_methods!(
337        #[unsafe(method(new))]
338        #[unsafe(method_family = new)]
339        pub unsafe fn new() -> Retained<Self>;
340    );
341}