1use 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#[cfg(feature = "CFBase")]
14pub const kCFXMLNodeCurrentVersion: CFIndex = 1;
15
16#[repr(C)]
18pub struct CFXMLNode {
19 inner: [u8; 0],
20 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
21}
22
23cf_type!(
24 #[encoding_name = "__CFXMLNode"]
25 unsafe impl CFXMLNode {}
26);
27
28#[cfg(feature = "CFTree")]
30pub type CFXMLTree = CFTree;
31
32#[cfg(feature = "CFBase")]
35#[repr(transparent)]
36#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
37pub struct CFXMLNodeTypeCode(pub CFIndex);
38#[cfg(feature = "CFBase")]
39impl CFXMLNodeTypeCode {
40 #[doc(alias = "kCFXMLNodeTypeDocument")]
41 pub const Document: Self = Self(1);
42 #[doc(alias = "kCFXMLNodeTypeElement")]
43 pub const Element: Self = Self(2);
44 #[doc(alias = "kCFXMLNodeTypeAttribute")]
45 pub const Attribute: Self = Self(3);
46 #[doc(alias = "kCFXMLNodeTypeProcessingInstruction")]
47 pub const ProcessingInstruction: Self = Self(4);
48 #[doc(alias = "kCFXMLNodeTypeComment")]
49 pub const Comment: Self = Self(5);
50 #[doc(alias = "kCFXMLNodeTypeText")]
51 pub const Text: Self = Self(6);
52 #[doc(alias = "kCFXMLNodeTypeCDATASection")]
53 pub const CDATASection: Self = Self(7);
54 #[doc(alias = "kCFXMLNodeTypeDocumentFragment")]
55 pub const DocumentFragment: Self = Self(8);
56 #[doc(alias = "kCFXMLNodeTypeEntity")]
57 pub const Entity: Self = Self(9);
58 #[doc(alias = "kCFXMLNodeTypeEntityReference")]
59 pub const EntityReference: Self = Self(10);
60 #[doc(alias = "kCFXMLNodeTypeDocumentType")]
61 pub const DocumentType: Self = Self(11);
62 #[doc(alias = "kCFXMLNodeTypeWhitespace")]
63 pub const Whitespace: Self = Self(12);
64 #[doc(alias = "kCFXMLNodeTypeNotation")]
65 pub const Notation: Self = Self(13);
66 #[doc(alias = "kCFXMLNodeTypeElementTypeDeclaration")]
67 pub const ElementTypeDeclaration: Self = Self(14);
68 #[doc(alias = "kCFXMLNodeTypeAttributeListDeclaration")]
69 pub const AttributeListDeclaration: Self = Self(15);
70}
71
72#[cfg(all(feature = "CFBase", feature = "objc2"))]
73unsafe impl Encode for CFXMLNodeTypeCode {
74 const ENCODING: Encoding = CFIndex::ENCODING;
75}
76
77#[cfg(all(feature = "CFBase", feature = "objc2"))]
78unsafe impl RefEncode for CFXMLNodeTypeCode {
79 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
80}
81
82#[cfg(all(feature = "CFArray", feature = "CFDictionary"))]
84#[repr(C)]
85#[derive(Clone, Copy, Debug, PartialEq)]
86pub struct CFXMLElementInfo {
87 pub attributes: *const CFDictionary,
88 pub attributeOrder: *const CFArray,
89 pub isEmpty: Boolean,
90 pub(crate) _reserved: [c_char; 3],
91}
92
93#[cfg(all(feature = "CFArray", feature = "CFDictionary", feature = "objc2"))]
94unsafe impl Encode for CFXMLElementInfo {
95 const ENCODING: Encoding = Encoding::Struct(
96 "?",
97 &[
98 <*const CFDictionary>::ENCODING,
99 <*const CFArray>::ENCODING,
100 <Boolean>::ENCODING,
101 <[c_char; 3]>::ENCODING,
102 ],
103 );
104}
105
106#[cfg(all(feature = "CFArray", feature = "CFDictionary", feature = "objc2"))]
107unsafe impl RefEncode for CFXMLElementInfo {
108 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
109}
110
111#[cfg(feature = "CFBase")]
113#[repr(C)]
114#[derive(Clone, Copy, Debug, PartialEq)]
115pub struct CFXMLProcessingInstructionInfo {
116 pub dataString: *const CFString,
117}
118
119#[cfg(all(feature = "CFBase", feature = "objc2"))]
120unsafe impl Encode for CFXMLProcessingInstructionInfo {
121 const ENCODING: Encoding = Encoding::Struct("?", &[<*const CFString>::ENCODING]);
122}
123
124#[cfg(all(feature = "CFBase", feature = "objc2"))]
125unsafe impl RefEncode for CFXMLProcessingInstructionInfo {
126 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
127}
128
129#[cfg(all(feature = "CFString", feature = "CFURL"))]
131#[repr(C)]
132#[derive(Clone, Copy, Debug, PartialEq)]
133pub struct CFXMLDocumentInfo {
134 pub sourceURL: *const CFURL,
135 pub encoding: CFStringEncoding,
136}
137
138#[cfg(all(feature = "CFString", feature = "CFURL", feature = "objc2"))]
139unsafe impl Encode for CFXMLDocumentInfo {
140 const ENCODING: Encoding = Encoding::Struct(
141 "?",
142 &[<*const CFURL>::ENCODING, <CFStringEncoding>::ENCODING],
143 );
144}
145
146#[cfg(all(feature = "CFString", feature = "CFURL", feature = "objc2"))]
147unsafe impl RefEncode for CFXMLDocumentInfo {
148 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
149}
150
151#[cfg(all(feature = "CFBase", feature = "CFURL"))]
153#[repr(C)]
154#[derive(Clone, Copy, Debug, PartialEq)]
155pub struct CFXMLExternalID {
156 pub systemID: *const CFURL,
157 pub publicID: *const CFString,
158}
159
160#[cfg(all(feature = "CFBase", feature = "CFURL", feature = "objc2"))]
161unsafe impl Encode for CFXMLExternalID {
162 const ENCODING: Encoding = Encoding::Struct(
163 "?",
164 &[<*const CFURL>::ENCODING, <*const CFString>::ENCODING],
165 );
166}
167
168#[cfg(all(feature = "CFBase", feature = "CFURL", feature = "objc2"))]
169unsafe impl RefEncode for CFXMLExternalID {
170 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
171}
172
173#[cfg(all(feature = "CFBase", feature = "CFURL"))]
175#[repr(C)]
176#[derive(Clone, Copy, Debug, PartialEq)]
177pub struct CFXMLDocumentTypeInfo {
178 pub externalID: CFXMLExternalID,
179}
180
181#[cfg(all(feature = "CFBase", feature = "CFURL", feature = "objc2"))]
182unsafe impl Encode for CFXMLDocumentTypeInfo {
183 const ENCODING: Encoding = Encoding::Struct("?", &[<CFXMLExternalID>::ENCODING]);
184}
185
186#[cfg(all(feature = "CFBase", feature = "CFURL", feature = "objc2"))]
187unsafe impl RefEncode for CFXMLDocumentTypeInfo {
188 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
189}
190
191#[cfg(all(feature = "CFBase", feature = "CFURL"))]
193#[repr(C)]
194#[derive(Clone, Copy, Debug, PartialEq)]
195pub struct CFXMLNotationInfo {
196 pub externalID: CFXMLExternalID,
197}
198
199#[cfg(all(feature = "CFBase", feature = "CFURL", feature = "objc2"))]
200unsafe impl Encode for CFXMLNotationInfo {
201 const ENCODING: Encoding = Encoding::Struct("?", &[<CFXMLExternalID>::ENCODING]);
202}
203
204#[cfg(all(feature = "CFBase", feature = "CFURL", feature = "objc2"))]
205unsafe impl RefEncode for CFXMLNotationInfo {
206 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
207}
208
209#[cfg(feature = "CFBase")]
211#[repr(C)]
212#[derive(Clone, Copy, Debug, PartialEq)]
213pub struct CFXMLElementTypeDeclarationInfo {
214 pub contentDescription: *const CFString,
215}
216
217#[cfg(all(feature = "CFBase", feature = "objc2"))]
218unsafe impl Encode for CFXMLElementTypeDeclarationInfo {
219 const ENCODING: Encoding = Encoding::Struct("?", &[<*const CFString>::ENCODING]);
220}
221
222#[cfg(all(feature = "CFBase", feature = "objc2"))]
223unsafe impl RefEncode for CFXMLElementTypeDeclarationInfo {
224 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
225}
226
227#[cfg(feature = "CFBase")]
229#[repr(C)]
230#[derive(Clone, Copy, Debug, PartialEq)]
231pub struct CFXMLAttributeDeclarationInfo {
232 pub attributeName: *const CFString,
233 pub typeString: *const CFString,
234 pub defaultString: *const CFString,
235}
236
237#[cfg(all(feature = "CFBase", feature = "objc2"))]
238unsafe impl Encode for CFXMLAttributeDeclarationInfo {
239 const ENCODING: Encoding = Encoding::Struct(
240 "?",
241 &[
242 <*const CFString>::ENCODING,
243 <*const CFString>::ENCODING,
244 <*const CFString>::ENCODING,
245 ],
246 );
247}
248
249#[cfg(all(feature = "CFBase", feature = "objc2"))]
250unsafe impl RefEncode for CFXMLAttributeDeclarationInfo {
251 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
252}
253
254#[cfg(feature = "CFBase")]
256#[repr(C)]
257#[derive(Clone, Copy, Debug, PartialEq)]
258pub struct CFXMLAttributeListDeclarationInfo {
259 pub numberOfAttributes: CFIndex,
260 pub attributes: *mut CFXMLAttributeDeclarationInfo,
261}
262
263#[cfg(all(feature = "CFBase", feature = "objc2"))]
264unsafe impl Encode for CFXMLAttributeListDeclarationInfo {
265 const ENCODING: Encoding = Encoding::Struct(
266 "?",
267 &[
268 <CFIndex>::ENCODING,
269 <*mut CFXMLAttributeDeclarationInfo>::ENCODING,
270 ],
271 );
272}
273
274#[cfg(all(feature = "CFBase", feature = "objc2"))]
275unsafe impl RefEncode for CFXMLAttributeListDeclarationInfo {
276 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
277}
278
279#[cfg(feature = "CFBase")]
282#[repr(transparent)]
283#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
284pub struct CFXMLEntityTypeCode(pub CFIndex);
285#[cfg(feature = "CFBase")]
286impl CFXMLEntityTypeCode {
287 #[doc(alias = "kCFXMLEntityTypeParameter")]
288 pub const Parameter: Self = Self(0);
289 #[doc(alias = "kCFXMLEntityTypeParsedInternal")]
290 pub const ParsedInternal: Self = Self(1);
291 #[doc(alias = "kCFXMLEntityTypeParsedExternal")]
292 pub const ParsedExternal: Self = Self(2);
293 #[doc(alias = "kCFXMLEntityTypeUnparsed")]
294 pub const Unparsed: Self = Self(3);
295 #[doc(alias = "kCFXMLEntityTypeCharacter")]
296 pub const Character: Self = Self(4);
297}
298
299#[cfg(all(feature = "CFBase", feature = "objc2"))]
300unsafe impl Encode for CFXMLEntityTypeCode {
301 const ENCODING: Encoding = CFIndex::ENCODING;
302}
303
304#[cfg(all(feature = "CFBase", feature = "objc2"))]
305unsafe impl RefEncode for CFXMLEntityTypeCode {
306 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
307}
308
309#[cfg(all(feature = "CFBase", feature = "CFURL"))]
311#[repr(C)]
312#[derive(Clone, Copy, Debug, PartialEq)]
313pub struct CFXMLEntityInfo {
314 pub entityType: CFXMLEntityTypeCode,
315 pub replacementText: *const CFString,
316 pub entityID: CFXMLExternalID,
317 pub notationName: *const CFString,
318}
319
320#[cfg(all(feature = "CFBase", feature = "CFURL", feature = "objc2"))]
321unsafe impl Encode for CFXMLEntityInfo {
322 const ENCODING: Encoding = Encoding::Struct(
323 "?",
324 &[
325 <CFXMLEntityTypeCode>::ENCODING,
326 <*const CFString>::ENCODING,
327 <CFXMLExternalID>::ENCODING,
328 <*const CFString>::ENCODING,
329 ],
330 );
331}
332
333#[cfg(all(feature = "CFBase", feature = "CFURL", feature = "objc2"))]
334unsafe impl RefEncode for CFXMLEntityInfo {
335 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
336}
337
338#[cfg(feature = "CFBase")]
340#[repr(C)]
341#[derive(Clone, Copy, Debug, PartialEq)]
342pub struct CFXMLEntityReferenceInfo {
343 pub entityType: CFXMLEntityTypeCode,
344}
345
346#[cfg(all(feature = "CFBase", feature = "objc2"))]
347unsafe impl Encode for CFXMLEntityReferenceInfo {
348 const ENCODING: Encoding = Encoding::Struct("?", &[<CFXMLEntityTypeCode>::ENCODING]);
349}
350
351#[cfg(all(feature = "CFBase", feature = "objc2"))]
352unsafe impl RefEncode for CFXMLEntityReferenceInfo {
353 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
354}
355
356#[cfg(feature = "CFBase")]
357unsafe impl ConcreteType for CFXMLNode {
358 #[doc(alias = "CFXMLNodeGetTypeID")]
359 #[inline]
360 fn type_id() -> CFTypeID {
361 extern "C-unwind" {
362 fn CFXMLNodeGetTypeID() -> CFTypeID;
363 }
364 unsafe { CFXMLNodeGetTypeID() }
365 }
366}
367
368#[cfg(feature = "CFBase")]
369#[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
370#[inline]
371pub unsafe extern "C-unwind" fn CFXMLNodeCreate(
372 alloc: Option<&CFAllocator>,
373 xml_type: CFXMLNodeTypeCode,
374 data_string: Option<&CFString>,
375 additional_info_ptr: *const c_void,
376 version: CFIndex,
377) -> Option<CFRetained<CFXMLNode>> {
378 extern "C-unwind" {
379 fn CFXMLNodeCreate(
380 alloc: Option<&CFAllocator>,
381 xml_type: CFXMLNodeTypeCode,
382 data_string: Option<&CFString>,
383 additional_info_ptr: *const c_void,
384 version: CFIndex,
385 ) -> Option<NonNull<CFXMLNode>>;
386 }
387 let ret =
388 unsafe { CFXMLNodeCreate(alloc, xml_type, data_string, additional_info_ptr, version) };
389 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
390}
391
392#[cfg(feature = "CFBase")]
393#[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
394#[inline]
395pub unsafe extern "C-unwind" fn CFXMLNodeCreateCopy(
396 alloc: Option<&CFAllocator>,
397 orig_node: Option<&CFXMLNode>,
398) -> Option<CFRetained<CFXMLNode>> {
399 extern "C-unwind" {
400 fn CFXMLNodeCreateCopy(
401 alloc: Option<&CFAllocator>,
402 orig_node: Option<&CFXMLNode>,
403 ) -> Option<NonNull<CFXMLNode>>;
404 }
405 let ret = unsafe { CFXMLNodeCreateCopy(alloc, orig_node) };
406 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
407}
408
409extern "C-unwind" {
410 #[cfg(feature = "CFBase")]
411 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
412 pub fn CFXMLNodeGetTypeCode(node: &CFXMLNode) -> CFXMLNodeTypeCode;
413}
414
415#[cfg(feature = "CFBase")]
416#[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
417#[inline]
418pub unsafe extern "C-unwind" fn CFXMLNodeGetString(
419 node: &CFXMLNode,
420) -> Option<CFRetained<CFString>> {
421 extern "C-unwind" {
422 fn CFXMLNodeGetString(node: &CFXMLNode) -> Option<NonNull<CFString>>;
423 }
424 let ret = unsafe { CFXMLNodeGetString(node) };
425 ret.map(|ret| unsafe { CFRetained::retain(ret) })
426}
427
428extern "C-unwind" {
429 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
430 pub fn CFXMLNodeGetInfoPtr(node: &CFXMLNode) -> *const c_void;
431}
432
433extern "C-unwind" {
434 #[cfg(feature = "CFBase")]
435 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
436 pub fn CFXMLNodeGetVersion(node: &CFXMLNode) -> CFIndex;
437}
438
439#[cfg(all(feature = "CFBase", feature = "CFTree"))]
440#[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
441#[inline]
442pub unsafe extern "C-unwind" fn CFXMLTreeCreateWithNode(
443 allocator: Option<&CFAllocator>,
444 node: Option<&CFXMLNode>,
445) -> Option<CFRetained<CFXMLTree>> {
446 extern "C-unwind" {
447 fn CFXMLTreeCreateWithNode(
448 allocator: Option<&CFAllocator>,
449 node: Option<&CFXMLNode>,
450 ) -> Option<NonNull<CFXMLTree>>;
451 }
452 let ret = unsafe { CFXMLTreeCreateWithNode(allocator, node) };
453 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
454}
455
456#[cfg(feature = "CFTree")]
457#[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
458#[inline]
459pub unsafe extern "C-unwind" fn CFXMLTreeGetNode(
460 xml_tree: &CFXMLTree,
461) -> Option<CFRetained<CFXMLNode>> {
462 extern "C-unwind" {
463 fn CFXMLTreeGetNode(xml_tree: &CFXMLTree) -> Option<NonNull<CFXMLNode>>;
464 }
465 let ret = unsafe { CFXMLTreeGetNode(xml_tree) };
466 ret.map(|ret| unsafe { CFRetained::retain(ret) })
467}