objc2_core_foundation/generated/
CFXMLParser.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfxmlparser?language=objc)
13#[doc(alias = "CFXMLParserRef")]
14#[repr(C)]
15pub struct CFXMLParser {
16    inner: [u8; 0],
17    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
18}
19
20cf_type!(
21    unsafe impl CFXMLParser {}
22);
23#[cfg(feature = "objc2")]
24cf_objc2_type!(
25    unsafe impl RefEncode<"__CFXMLParser"> for CFXMLParser {}
26);
27
28/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfxmlparseroptions?language=objc)
29// NS_OPTIONS
30#[repr(transparent)]
31#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
32pub struct CFXMLParserOptions(pub CFOptionFlags);
33bitflags::bitflags! {
34    impl CFXMLParserOptions: CFOptionFlags {
35        #[doc(alias = "kCFXMLParserValidateDocument")]
36        const ValidateDocument = 1<<0;
37        #[doc(alias = "kCFXMLParserSkipMetaData")]
38        const SkipMetaData = 1<<1;
39        #[doc(alias = "kCFXMLParserReplacePhysicalEntities")]
40        const ReplacePhysicalEntities = 1<<2;
41        #[doc(alias = "kCFXMLParserSkipWhitespace")]
42        const SkipWhitespace = 1<<3;
43        #[doc(alias = "kCFXMLParserResolveExternalEntities")]
44        const ResolveExternalEntities = 1<<4;
45        #[doc(alias = "kCFXMLParserAddImpliedAttributes")]
46        const AddImpliedAttributes = 1<<5;
47        #[doc(alias = "kCFXMLParserAllOptions")]
48        const AllOptions = 0x00FFFFFF;
49        #[doc(alias = "kCFXMLParserNoOptions")]
50        const NoOptions = 0;
51    }
52}
53
54#[cfg(feature = "objc2")]
55unsafe impl Encode for CFXMLParserOptions {
56    const ENCODING: Encoding = CFOptionFlags::ENCODING;
57}
58
59#[cfg(feature = "objc2")]
60unsafe impl RefEncode for CFXMLParserOptions {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfxmlparserstatuscode?language=objc)
65// NS_OPTIONS
66#[repr(transparent)]
67#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
68pub struct CFXMLParserStatusCode(pub CFIndex);
69bitflags::bitflags! {
70    impl CFXMLParserStatusCode: CFIndex {
71        #[doc(alias = "kCFXMLStatusParseNotBegun")]
72        const StatusParseNotBegun = -2;
73        #[doc(alias = "kCFXMLStatusParseInProgress")]
74        const StatusParseInProgress = -1;
75        #[doc(alias = "kCFXMLStatusParseSuccessful")]
76        const StatusParseSuccessful = 0;
77        #[doc(alias = "kCFXMLErrorUnexpectedEOF")]
78        const ErrorUnexpectedEOF = 1;
79        #[doc(alias = "kCFXMLErrorUnknownEncoding")]
80        const ErrorUnknownEncoding = 2;
81        #[doc(alias = "kCFXMLErrorEncodingConversionFailure")]
82        const ErrorEncodingConversionFailure = 3;
83        #[doc(alias = "kCFXMLErrorMalformedProcessingInstruction")]
84        const ErrorMalformedProcessingInstruction = 4;
85        #[doc(alias = "kCFXMLErrorMalformedDTD")]
86        const ErrorMalformedDTD = 5;
87        #[doc(alias = "kCFXMLErrorMalformedName")]
88        const ErrorMalformedName = 6;
89        #[doc(alias = "kCFXMLErrorMalformedCDSect")]
90        const ErrorMalformedCDSect = 7;
91        #[doc(alias = "kCFXMLErrorMalformedCloseTag")]
92        const ErrorMalformedCloseTag = 8;
93        #[doc(alias = "kCFXMLErrorMalformedStartTag")]
94        const ErrorMalformedStartTag = 9;
95        #[doc(alias = "kCFXMLErrorMalformedDocument")]
96        const ErrorMalformedDocument = 10;
97        #[doc(alias = "kCFXMLErrorElementlessDocument")]
98        const ErrorElementlessDocument = 11;
99        #[doc(alias = "kCFXMLErrorMalformedComment")]
100        const ErrorMalformedComment = 12;
101        #[doc(alias = "kCFXMLErrorMalformedCharacterReference")]
102        const ErrorMalformedCharacterReference = 13;
103        #[doc(alias = "kCFXMLErrorMalformedParsedCharacterData")]
104        const ErrorMalformedParsedCharacterData = 14;
105        #[doc(alias = "kCFXMLErrorNoData")]
106        const ErrorNoData = 15;
107    }
108}
109
110#[cfg(feature = "objc2")]
111unsafe impl Encode for CFXMLParserStatusCode {
112    const ENCODING: Encoding = CFIndex::ENCODING;
113}
114
115#[cfg(feature = "objc2")]
116unsafe impl RefEncode for CFXMLParserStatusCode {
117    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
118}
119
120/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfxmlparsercreatexmlstructurecallback?language=objc)
121#[cfg(feature = "CFXMLNode")]
122pub type CFXMLParserCreateXMLStructureCallBack = Option<
123    unsafe extern "C-unwind" fn(*mut CFXMLParser, *const CFXMLNode, *mut c_void) -> *mut c_void,
124>;
125
126/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfxmlparseraddchildcallback?language=objc)
127pub type CFXMLParserAddChildCallBack =
128    Option<unsafe extern "C-unwind" fn(*mut CFXMLParser, *mut c_void, *mut c_void, *mut c_void)>;
129
130/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfxmlparserendxmlstructurecallback?language=objc)
131pub type CFXMLParserEndXMLStructureCallBack =
132    Option<unsafe extern "C-unwind" fn(*mut CFXMLParser, *mut c_void, *mut c_void)>;
133
134/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfxmlparserresolveexternalentitycallback?language=objc)
135#[cfg(all(feature = "CFData", feature = "CFURL", feature = "CFXMLNode"))]
136pub type CFXMLParserResolveExternalEntityCallBack = Option<
137    unsafe extern "C-unwind" fn(
138        *mut CFXMLParser,
139        *mut CFXMLExternalID,
140        *mut c_void,
141    ) -> *const CFData,
142>;
143
144/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfxmlparserhandleerrorcallback?language=objc)
145pub type CFXMLParserHandleErrorCallBack = Option<
146    unsafe extern "C-unwind" fn(*mut CFXMLParser, CFXMLParserStatusCode, *mut c_void) -> Boolean,
147>;
148
149/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfxmlparsercallbacks?language=objc)
150#[cfg(all(feature = "CFData", feature = "CFURL", feature = "CFXMLNode"))]
151#[repr(C)]
152#[allow(unpredictable_function_pointer_comparisons)]
153#[derive(Clone, Copy, Debug, PartialEq)]
154pub struct CFXMLParserCallBacks {
155    pub version: CFIndex,
156    pub createXMLStructure: CFXMLParserCreateXMLStructureCallBack,
157    pub addChild: CFXMLParserAddChildCallBack,
158    pub endXMLStructure: CFXMLParserEndXMLStructureCallBack,
159    pub resolveExternalEntity: CFXMLParserResolveExternalEntityCallBack,
160    pub handleError: CFXMLParserHandleErrorCallBack,
161}
162
163#[cfg(all(
164    feature = "CFData",
165    feature = "CFURL",
166    feature = "CFXMLNode",
167    feature = "objc2"
168))]
169unsafe impl Encode for CFXMLParserCallBacks {
170    const ENCODING: Encoding = Encoding::Struct(
171        "?",
172        &[
173            <CFIndex>::ENCODING,
174            <CFXMLParserCreateXMLStructureCallBack>::ENCODING,
175            <CFXMLParserAddChildCallBack>::ENCODING,
176            <CFXMLParserEndXMLStructureCallBack>::ENCODING,
177            <CFXMLParserResolveExternalEntityCallBack>::ENCODING,
178            <CFXMLParserHandleErrorCallBack>::ENCODING,
179        ],
180    );
181}
182
183#[cfg(all(
184    feature = "CFData",
185    feature = "CFURL",
186    feature = "CFXMLNode",
187    feature = "objc2"
188))]
189unsafe impl RefEncode for CFXMLParserCallBacks {
190    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
191}
192
193/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfxmlparserretaincallback?language=objc)
194pub type CFXMLParserRetainCallBack =
195    Option<unsafe extern "C-unwind" fn(*const c_void) -> *const c_void>;
196
197/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfxmlparserreleasecallback?language=objc)
198pub type CFXMLParserReleaseCallBack = Option<unsafe extern "C-unwind" fn(*const c_void)>;
199
200/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfxmlparsercopydescriptioncallback?language=objc)
201pub type CFXMLParserCopyDescriptionCallBack =
202    Option<unsafe extern "C-unwind" fn(*const c_void) -> *const CFString>;
203
204/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfxmlparsercontext?language=objc)
205#[repr(C)]
206#[allow(unpredictable_function_pointer_comparisons)]
207#[derive(Clone, Copy, Debug, PartialEq)]
208pub struct CFXMLParserContext {
209    pub version: CFIndex,
210    pub info: *mut c_void,
211    pub retain: CFXMLParserRetainCallBack,
212    pub release: CFXMLParserReleaseCallBack,
213    pub copyDescription: CFXMLParserCopyDescriptionCallBack,
214}
215
216#[cfg(feature = "objc2")]
217unsafe impl Encode for CFXMLParserContext {
218    const ENCODING: Encoding = Encoding::Struct(
219        "?",
220        &[
221            <CFIndex>::ENCODING,
222            <*mut c_void>::ENCODING,
223            <CFXMLParserRetainCallBack>::ENCODING,
224            <CFXMLParserReleaseCallBack>::ENCODING,
225            <CFXMLParserCopyDescriptionCallBack>::ENCODING,
226        ],
227    );
228}
229
230#[cfg(feature = "objc2")]
231unsafe impl RefEncode for CFXMLParserContext {
232    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
233}
234
235unsafe impl ConcreteType for CFXMLParser {
236    #[doc(alias = "CFXMLParserGetTypeID")]
237    #[inline]
238    fn type_id() -> CFTypeID {
239        extern "C-unwind" {
240            fn CFXMLParserGetTypeID() -> CFTypeID;
241        }
242        unsafe { CFXMLParserGetTypeID() }
243    }
244}
245
246impl CFXMLParser {
247    /// # Safety
248    ///
249    /// - `allocator` might not allow `None`.
250    /// - `xml_data` might not allow `None`.
251    /// - `data_source` might not allow `None`.
252    /// - `call_backs` must be a valid pointer.
253    /// - `context` must be a valid pointer.
254    #[doc(alias = "CFXMLParserCreate")]
255    #[cfg(all(feature = "CFData", feature = "CFURL", feature = "CFXMLNode"))]
256    #[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
257    #[inline]
258    pub unsafe fn new(
259        allocator: Option<&CFAllocator>,
260        xml_data: Option<&CFData>,
261        data_source: Option<&CFURL>,
262        parse_options: CFOptionFlags,
263        version_of_nodes: CFIndex,
264        call_backs: *mut CFXMLParserCallBacks,
265        context: *mut CFXMLParserContext,
266    ) -> Option<CFRetained<CFXMLParser>> {
267        extern "C-unwind" {
268            fn CFXMLParserCreate(
269                allocator: Option<&CFAllocator>,
270                xml_data: Option<&CFData>,
271                data_source: Option<&CFURL>,
272                parse_options: CFOptionFlags,
273                version_of_nodes: CFIndex,
274                call_backs: *mut CFXMLParserCallBacks,
275                context: *mut CFXMLParserContext,
276            ) -> Option<NonNull<CFXMLParser>>;
277        }
278        let ret = unsafe {
279            CFXMLParserCreate(
280                allocator,
281                xml_data,
282                data_source,
283                parse_options,
284                version_of_nodes,
285                call_backs,
286                context,
287            )
288        };
289        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
290    }
291
292    /// # Safety
293    ///
294    /// - `allocator` might not allow `None`.
295    /// - `data_source` might not allow `None`.
296    /// - `call_backs` must be a valid pointer.
297    /// - `context` must be a valid pointer.
298    #[doc(alias = "CFXMLParserCreateWithDataFromURL")]
299    #[cfg(all(feature = "CFData", feature = "CFURL", feature = "CFXMLNode"))]
300    #[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
301    #[inline]
302    pub unsafe fn with_data_from_url(
303        allocator: Option<&CFAllocator>,
304        data_source: Option<&CFURL>,
305        parse_options: CFOptionFlags,
306        version_of_nodes: CFIndex,
307        call_backs: *mut CFXMLParserCallBacks,
308        context: *mut CFXMLParserContext,
309    ) -> Option<CFRetained<CFXMLParser>> {
310        extern "C-unwind" {
311            fn CFXMLParserCreateWithDataFromURL(
312                allocator: Option<&CFAllocator>,
313                data_source: Option<&CFURL>,
314                parse_options: CFOptionFlags,
315                version_of_nodes: CFIndex,
316                call_backs: *mut CFXMLParserCallBacks,
317                context: *mut CFXMLParserContext,
318            ) -> Option<NonNull<CFXMLParser>>;
319        }
320        let ret = unsafe {
321            CFXMLParserCreateWithDataFromURL(
322                allocator,
323                data_source,
324                parse_options,
325                version_of_nodes,
326                call_backs,
327                context,
328            )
329        };
330        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
331    }
332
333    /// # Safety
334    ///
335    /// `context` must be a valid pointer.
336    #[doc(alias = "CFXMLParserGetContext")]
337    #[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
338    #[inline]
339    pub unsafe fn context(&self, context: *mut CFXMLParserContext) {
340        extern "C-unwind" {
341            fn CFXMLParserGetContext(parser: &CFXMLParser, context: *mut CFXMLParserContext);
342        }
343        unsafe { CFXMLParserGetContext(self, context) }
344    }
345
346    /// # Safety
347    ///
348    /// `call_backs` must be a valid pointer.
349    #[doc(alias = "CFXMLParserGetCallBacks")]
350    #[cfg(all(feature = "CFData", feature = "CFURL", feature = "CFXMLNode"))]
351    #[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
352    #[inline]
353    pub unsafe fn call_backs(&self, call_backs: *mut CFXMLParserCallBacks) {
354        extern "C-unwind" {
355            fn CFXMLParserGetCallBacks(parser: &CFXMLParser, call_backs: *mut CFXMLParserCallBacks);
356        }
357        unsafe { CFXMLParserGetCallBacks(self, call_backs) }
358    }
359
360    #[doc(alias = "CFXMLParserGetSourceURL")]
361    #[cfg(feature = "CFURL")]
362    #[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
363    #[inline]
364    pub fn source_url(&self) -> Option<CFRetained<CFURL>> {
365        extern "C-unwind" {
366            fn CFXMLParserGetSourceURL(parser: &CFXMLParser) -> Option<NonNull<CFURL>>;
367        }
368        let ret = unsafe { CFXMLParserGetSourceURL(self) };
369        ret.map(|ret| unsafe { CFRetained::retain(ret) })
370    }
371
372    #[doc(alias = "CFXMLParserGetLocation")]
373    #[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
374    #[inline]
375    pub fn location(&self) -> CFIndex {
376        extern "C-unwind" {
377            fn CFXMLParserGetLocation(parser: &CFXMLParser) -> CFIndex;
378        }
379        unsafe { CFXMLParserGetLocation(self) }
380    }
381
382    #[doc(alias = "CFXMLParserGetLineNumber")]
383    #[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
384    #[inline]
385    pub fn line_number(&self) -> CFIndex {
386        extern "C-unwind" {
387            fn CFXMLParserGetLineNumber(parser: &CFXMLParser) -> CFIndex;
388        }
389        unsafe { CFXMLParserGetLineNumber(self) }
390    }
391
392    #[doc(alias = "CFXMLParserGetDocument")]
393    #[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
394    #[inline]
395    pub fn document(&self) -> *mut c_void {
396        extern "C-unwind" {
397            fn CFXMLParserGetDocument(parser: &CFXMLParser) -> *mut c_void;
398        }
399        unsafe { CFXMLParserGetDocument(self) }
400    }
401
402    #[doc(alias = "CFXMLParserGetStatusCode")]
403    #[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
404    #[inline]
405    pub fn status_code(&self) -> CFXMLParserStatusCode {
406        extern "C-unwind" {
407            fn CFXMLParserGetStatusCode(parser: &CFXMLParser) -> CFXMLParserStatusCode;
408        }
409        unsafe { CFXMLParserGetStatusCode(self) }
410    }
411
412    #[doc(alias = "CFXMLParserCopyErrorDescription")]
413    #[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
414    #[inline]
415    pub fn error_description(&self) -> Option<CFRetained<CFString>> {
416        extern "C-unwind" {
417            fn CFXMLParserCopyErrorDescription(parser: &CFXMLParser) -> Option<NonNull<CFString>>;
418        }
419        let ret = unsafe { CFXMLParserCopyErrorDescription(self) };
420        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
421    }
422
423    /// # Safety
424    ///
425    /// `error_description` might not allow `None`.
426    #[doc(alias = "CFXMLParserAbort")]
427    #[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
428    #[inline]
429    pub unsafe fn abort(
430        &self,
431        error_code: CFXMLParserStatusCode,
432        error_description: Option<&CFString>,
433    ) {
434        extern "C-unwind" {
435            fn CFXMLParserAbort(
436                parser: &CFXMLParser,
437                error_code: CFXMLParserStatusCode,
438                error_description: Option<&CFString>,
439            );
440        }
441        unsafe { CFXMLParserAbort(self, error_code, error_description) }
442    }
443
444    #[doc(alias = "CFXMLParserParse")]
445    #[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
446    #[inline]
447    pub fn parse(&self) -> bool {
448        extern "C-unwind" {
449            fn CFXMLParserParse(parser: &CFXMLParser) -> Boolean;
450        }
451        let ret = unsafe { CFXMLParserParse(self) };
452        ret != 0
453    }
454}
455
456/// # Safety
457///
458/// - `allocator` might not allow `None`.
459/// - `xml_data` might not allow `None`.
460/// - `data_source` might not allow `None`.
461#[cfg(all(
462    feature = "CFData",
463    feature = "CFTree",
464    feature = "CFURL",
465    feature = "CFXMLNode"
466))]
467#[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
468#[inline]
469pub unsafe extern "C-unwind" fn CFXMLTreeCreateFromData(
470    allocator: Option<&CFAllocator>,
471    xml_data: Option<&CFData>,
472    data_source: Option<&CFURL>,
473    parse_options: CFOptionFlags,
474    version_of_nodes: CFIndex,
475) -> Option<CFRetained<CFXMLTree>> {
476    extern "C-unwind" {
477        fn CFXMLTreeCreateFromData(
478            allocator: Option<&CFAllocator>,
479            xml_data: Option<&CFData>,
480            data_source: Option<&CFURL>,
481            parse_options: CFOptionFlags,
482            version_of_nodes: CFIndex,
483        ) -> Option<NonNull<CFXMLTree>>;
484    }
485    let ret = unsafe {
486        CFXMLTreeCreateFromData(
487            allocator,
488            xml_data,
489            data_source,
490            parse_options,
491            version_of_nodes,
492        )
493    };
494    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
495}
496
497/// # Safety
498///
499/// - `allocator` might not allow `None`.
500/// - `xml_data` might not allow `None`.
501/// - `data_source` might not allow `None`.
502/// - `error_dict` must be a valid pointer.
503#[cfg(all(
504    feature = "CFData",
505    feature = "CFDictionary",
506    feature = "CFTree",
507    feature = "CFURL",
508    feature = "CFXMLNode"
509))]
510#[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
511#[inline]
512pub unsafe extern "C-unwind" fn CFXMLTreeCreateFromDataWithError(
513    allocator: Option<&CFAllocator>,
514    xml_data: Option<&CFData>,
515    data_source: Option<&CFURL>,
516    parse_options: CFOptionFlags,
517    version_of_nodes: CFIndex,
518    error_dict: *mut *const CFDictionary,
519) -> Option<CFRetained<CFXMLTree>> {
520    extern "C-unwind" {
521        fn CFXMLTreeCreateFromDataWithError(
522            allocator: Option<&CFAllocator>,
523            xml_data: Option<&CFData>,
524            data_source: Option<&CFURL>,
525            parse_options: CFOptionFlags,
526            version_of_nodes: CFIndex,
527            error_dict: *mut *const CFDictionary,
528        ) -> Option<NonNull<CFXMLTree>>;
529    }
530    let ret = unsafe {
531        CFXMLTreeCreateFromDataWithError(
532            allocator,
533            xml_data,
534            data_source,
535            parse_options,
536            version_of_nodes,
537            error_dict,
538        )
539    };
540    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
541}
542
543/// # Safety
544///
545/// - `allocator` might not allow `None`.
546/// - `data_source` might not allow `None`.
547#[cfg(all(feature = "CFTree", feature = "CFURL", feature = "CFXMLNode"))]
548#[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
549#[inline]
550pub unsafe extern "C-unwind" fn CFXMLTreeCreateWithDataFromURL(
551    allocator: Option<&CFAllocator>,
552    data_source: Option<&CFURL>,
553    parse_options: CFOptionFlags,
554    version_of_nodes: CFIndex,
555) -> Option<CFRetained<CFXMLTree>> {
556    extern "C-unwind" {
557        fn CFXMLTreeCreateWithDataFromURL(
558            allocator: Option<&CFAllocator>,
559            data_source: Option<&CFURL>,
560            parse_options: CFOptionFlags,
561            version_of_nodes: CFIndex,
562        ) -> Option<NonNull<CFXMLTree>>;
563    }
564    let ret = unsafe {
565        CFXMLTreeCreateWithDataFromURL(allocator, data_source, parse_options, version_of_nodes)
566    };
567    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
568}
569
570/// # Safety
571///
572/// - `allocator` might not allow `None`.
573/// - `xml_tree` might not allow `None`.
574#[cfg(all(feature = "CFData", feature = "CFTree", feature = "CFXMLNode"))]
575#[deprecated = "CFXMLParser is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
576#[inline]
577pub unsafe extern "C-unwind" fn CFXMLTreeCreateXMLData(
578    allocator: Option<&CFAllocator>,
579    xml_tree: Option<&CFXMLTree>,
580) -> Option<CFRetained<CFData>> {
581    extern "C-unwind" {
582        fn CFXMLTreeCreateXMLData(
583            allocator: Option<&CFAllocator>,
584            xml_tree: Option<&CFXMLTree>,
585        ) -> Option<NonNull<CFData>>;
586    }
587    let ret = unsafe { CFXMLTreeCreateXMLData(allocator, xml_tree) };
588    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
589}
590
591/// # Safety
592///
593/// - `allocator` might not allow `None`.
594/// - `string` might not allow `None`.
595/// - `entities_dictionary` generics must be of the correct type.
596/// - `entities_dictionary` might not allow `None`.
597#[cfg(feature = "CFDictionary")]
598#[inline]
599pub unsafe extern "C-unwind" fn CFXMLCreateStringByEscapingEntities(
600    allocator: Option<&CFAllocator>,
601    string: Option<&CFString>,
602    entities_dictionary: Option<&CFDictionary>,
603) -> Option<CFRetained<CFString>> {
604    extern "C-unwind" {
605        fn CFXMLCreateStringByEscapingEntities(
606            allocator: Option<&CFAllocator>,
607            string: Option<&CFString>,
608            entities_dictionary: Option<&CFDictionary>,
609        ) -> Option<NonNull<CFString>>;
610    }
611    let ret =
612        unsafe { CFXMLCreateStringByEscapingEntities(allocator, string, entities_dictionary) };
613    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
614}
615
616/// # Safety
617///
618/// - `allocator` might not allow `None`.
619/// - `string` might not allow `None`.
620/// - `entities_dictionary` generics must be of the correct type.
621/// - `entities_dictionary` might not allow `None`.
622#[cfg(feature = "CFDictionary")]
623#[inline]
624pub unsafe extern "C-unwind" fn CFXMLCreateStringByUnescapingEntities(
625    allocator: Option<&CFAllocator>,
626    string: Option<&CFString>,
627    entities_dictionary: Option<&CFDictionary>,
628) -> Option<CFRetained<CFString>> {
629    extern "C-unwind" {
630        fn CFXMLCreateStringByUnescapingEntities(
631            allocator: Option<&CFAllocator>,
632            string: Option<&CFString>,
633            entities_dictionary: Option<&CFDictionary>,
634        ) -> Option<NonNull<CFString>>;
635    }
636    let ret =
637        unsafe { CFXMLCreateStringByUnescapingEntities(allocator, string, entities_dictionary) };
638    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
639}
640
641extern "C" {
642    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfxmltreeerrordescription?language=objc)
643    pub static kCFXMLTreeErrorDescription: Option<&'static CFString>;
644}
645
646extern "C" {
647    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfxmltreeerrorlinenumber?language=objc)
648    pub static kCFXMLTreeErrorLineNumber: Option<&'static CFString>;
649}
650
651extern "C" {
652    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfxmltreeerrorlocation?language=objc)
653    pub static kCFXMLTreeErrorLocation: Option<&'static CFString>;
654}
655
656extern "C" {
657    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfxmltreeerrorstatuscode?language=objc)
658    pub static kCFXMLTreeErrorStatusCode: Option<&'static CFString>;
659}
660
661#[cfg(all(feature = "CFData", feature = "CFURL", feature = "CFXMLNode"))]
662#[deprecated = "renamed to `CFXMLParser::new`"]
663#[inline]
664pub unsafe extern "C-unwind" fn CFXMLParserCreate(
665    allocator: Option<&CFAllocator>,
666    xml_data: Option<&CFData>,
667    data_source: Option<&CFURL>,
668    parse_options: CFOptionFlags,
669    version_of_nodes: CFIndex,
670    call_backs: *mut CFXMLParserCallBacks,
671    context: *mut CFXMLParserContext,
672) -> Option<CFRetained<CFXMLParser>> {
673    extern "C-unwind" {
674        fn CFXMLParserCreate(
675            allocator: Option<&CFAllocator>,
676            xml_data: Option<&CFData>,
677            data_source: Option<&CFURL>,
678            parse_options: CFOptionFlags,
679            version_of_nodes: CFIndex,
680            call_backs: *mut CFXMLParserCallBacks,
681            context: *mut CFXMLParserContext,
682        ) -> Option<NonNull<CFXMLParser>>;
683    }
684    let ret = unsafe {
685        CFXMLParserCreate(
686            allocator,
687            xml_data,
688            data_source,
689            parse_options,
690            version_of_nodes,
691            call_backs,
692            context,
693        )
694    };
695    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
696}
697
698#[cfg(all(feature = "CFData", feature = "CFURL", feature = "CFXMLNode"))]
699#[deprecated = "renamed to `CFXMLParser::with_data_from_url`"]
700#[inline]
701pub unsafe extern "C-unwind" fn CFXMLParserCreateWithDataFromURL(
702    allocator: Option<&CFAllocator>,
703    data_source: Option<&CFURL>,
704    parse_options: CFOptionFlags,
705    version_of_nodes: CFIndex,
706    call_backs: *mut CFXMLParserCallBacks,
707    context: *mut CFXMLParserContext,
708) -> Option<CFRetained<CFXMLParser>> {
709    extern "C-unwind" {
710        fn CFXMLParserCreateWithDataFromURL(
711            allocator: Option<&CFAllocator>,
712            data_source: Option<&CFURL>,
713            parse_options: CFOptionFlags,
714            version_of_nodes: CFIndex,
715            call_backs: *mut CFXMLParserCallBacks,
716            context: *mut CFXMLParserContext,
717        ) -> Option<NonNull<CFXMLParser>>;
718    }
719    let ret = unsafe {
720        CFXMLParserCreateWithDataFromURL(
721            allocator,
722            data_source,
723            parse_options,
724            version_of_nodes,
725            call_backs,
726            context,
727        )
728    };
729    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
730}
731
732extern "C-unwind" {
733    #[deprecated = "renamed to `CFXMLParser::context`"]
734    pub fn CFXMLParserGetContext(parser: &CFXMLParser, context: *mut CFXMLParserContext);
735}
736
737extern "C-unwind" {
738    #[cfg(all(feature = "CFData", feature = "CFURL", feature = "CFXMLNode"))]
739    #[deprecated = "renamed to `CFXMLParser::call_backs`"]
740    pub fn CFXMLParserGetCallBacks(parser: &CFXMLParser, call_backs: *mut CFXMLParserCallBacks);
741}
742
743#[cfg(feature = "CFURL")]
744#[deprecated = "renamed to `CFXMLParser::source_url`"]
745#[inline]
746pub extern "C-unwind" fn CFXMLParserGetSourceURL(
747    parser: &CFXMLParser,
748) -> Option<CFRetained<CFURL>> {
749    extern "C-unwind" {
750        fn CFXMLParserGetSourceURL(parser: &CFXMLParser) -> Option<NonNull<CFURL>>;
751    }
752    let ret = unsafe { CFXMLParserGetSourceURL(parser) };
753    ret.map(|ret| unsafe { CFRetained::retain(ret) })
754}
755
756#[deprecated = "renamed to `CFXMLParser::location`"]
757#[inline]
758pub extern "C-unwind" fn CFXMLParserGetLocation(parser: &CFXMLParser) -> CFIndex {
759    extern "C-unwind" {
760        fn CFXMLParserGetLocation(parser: &CFXMLParser) -> CFIndex;
761    }
762    unsafe { CFXMLParserGetLocation(parser) }
763}
764
765#[deprecated = "renamed to `CFXMLParser::line_number`"]
766#[inline]
767pub extern "C-unwind" fn CFXMLParserGetLineNumber(parser: &CFXMLParser) -> CFIndex {
768    extern "C-unwind" {
769        fn CFXMLParserGetLineNumber(parser: &CFXMLParser) -> CFIndex;
770    }
771    unsafe { CFXMLParserGetLineNumber(parser) }
772}
773
774#[deprecated = "renamed to `CFXMLParser::document`"]
775#[inline]
776pub extern "C-unwind" fn CFXMLParserGetDocument(parser: &CFXMLParser) -> *mut c_void {
777    extern "C-unwind" {
778        fn CFXMLParserGetDocument(parser: &CFXMLParser) -> *mut c_void;
779    }
780    unsafe { CFXMLParserGetDocument(parser) }
781}
782
783#[deprecated = "renamed to `CFXMLParser::status_code`"]
784#[inline]
785pub extern "C-unwind" fn CFXMLParserGetStatusCode(parser: &CFXMLParser) -> CFXMLParserStatusCode {
786    extern "C-unwind" {
787        fn CFXMLParserGetStatusCode(parser: &CFXMLParser) -> CFXMLParserStatusCode;
788    }
789    unsafe { CFXMLParserGetStatusCode(parser) }
790}
791
792#[deprecated = "renamed to `CFXMLParser::error_description`"]
793#[inline]
794pub extern "C-unwind" fn CFXMLParserCopyErrorDescription(
795    parser: &CFXMLParser,
796) -> Option<CFRetained<CFString>> {
797    extern "C-unwind" {
798        fn CFXMLParserCopyErrorDescription(parser: &CFXMLParser) -> Option<NonNull<CFString>>;
799    }
800    let ret = unsafe { CFXMLParserCopyErrorDescription(parser) };
801    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
802}
803
804extern "C-unwind" {
805    #[deprecated = "renamed to `CFXMLParser::abort`"]
806    pub fn CFXMLParserAbort(
807        parser: &CFXMLParser,
808        error_code: CFXMLParserStatusCode,
809        error_description: Option<&CFString>,
810    );
811}
812
813#[deprecated = "renamed to `CFXMLParser::parse`"]
814#[inline]
815pub extern "C-unwind" fn CFXMLParserParse(parser: &CFXMLParser) -> bool {
816    extern "C-unwind" {
817        fn CFXMLParserParse(parser: &CFXMLParser) -> Boolean;
818    }
819    let ret = unsafe { CFXMLParserParse(parser) };
820    ret != 0
821}