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
12pub const kCFXMLNodeCurrentVersion: CFIndex = 1;
14
15#[doc(alias = "CFXMLNodeRef")]
17#[repr(C)]
18pub struct CFXMLNode {
19 inner: [u8; 0],
20 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
21}
22
23cf_type!(
24 unsafe impl CFXMLNode {}
25);
26#[cfg(feature = "objc2")]
27cf_objc2_type!(
28 unsafe impl RefEncode<"__CFXMLNode"> for CFXMLNode {}
29);
30
31#[doc(alias = "CFXMLTreeRef")]
33#[cfg(feature = "CFTree")]
34pub type CFXMLTree = CFTree;
35
36#[repr(transparent)]
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
40pub struct CFXMLNodeTypeCode(pub CFIndex);
41impl CFXMLNodeTypeCode {
42 #[doc(alias = "kCFXMLNodeTypeDocument")]
43 pub const Document: Self = Self(1);
44 #[doc(alias = "kCFXMLNodeTypeElement")]
45 pub const Element: Self = Self(2);
46 #[doc(alias = "kCFXMLNodeTypeAttribute")]
47 pub const Attribute: Self = Self(3);
48 #[doc(alias = "kCFXMLNodeTypeProcessingInstruction")]
49 pub const ProcessingInstruction: Self = Self(4);
50 #[doc(alias = "kCFXMLNodeTypeComment")]
51 pub const Comment: Self = Self(5);
52 #[doc(alias = "kCFXMLNodeTypeText")]
53 pub const Text: Self = Self(6);
54 #[doc(alias = "kCFXMLNodeTypeCDATASection")]
55 pub const CDATASection: Self = Self(7);
56 #[doc(alias = "kCFXMLNodeTypeDocumentFragment")]
57 pub const DocumentFragment: Self = Self(8);
58 #[doc(alias = "kCFXMLNodeTypeEntity")]
59 pub const Entity: Self = Self(9);
60 #[doc(alias = "kCFXMLNodeTypeEntityReference")]
61 pub const EntityReference: Self = Self(10);
62 #[doc(alias = "kCFXMLNodeTypeDocumentType")]
63 pub const DocumentType: Self = Self(11);
64 #[doc(alias = "kCFXMLNodeTypeWhitespace")]
65 pub const Whitespace: Self = Self(12);
66 #[doc(alias = "kCFXMLNodeTypeNotation")]
67 pub const Notation: Self = Self(13);
68 #[doc(alias = "kCFXMLNodeTypeElementTypeDeclaration")]
69 pub const ElementTypeDeclaration: Self = Self(14);
70 #[doc(alias = "kCFXMLNodeTypeAttributeListDeclaration")]
71 pub const AttributeListDeclaration: Self = Self(15);
72}
73
74#[cfg(feature = "objc2")]
75unsafe impl Encode for CFXMLNodeTypeCode {
76 const ENCODING: Encoding = CFIndex::ENCODING;
77}
78
79#[cfg(feature = "objc2")]
80unsafe impl RefEncode for CFXMLNodeTypeCode {
81 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
82}
83
84#[cfg(all(feature = "CFArray", feature = "CFDictionary"))]
86#[repr(C)]
87#[derive(Clone, Copy, Debug, PartialEq)]
88pub struct CFXMLElementInfo {
89 pub attributes: *const CFDictionary,
90 pub attributeOrder: *const CFArray,
91 pub isEmpty: Boolean,
92 pub(crate) _reserved: [c_char; 3],
93}
94
95#[cfg(all(feature = "CFArray", feature = "CFDictionary", feature = "objc2"))]
96unsafe impl Encode for CFXMLElementInfo {
97 const ENCODING: Encoding = Encoding::Struct(
98 "?",
99 &[
100 <*const CFDictionary>::ENCODING,
101 <*const CFArray>::ENCODING,
102 <Boolean>::ENCODING,
103 <[c_char; 3]>::ENCODING,
104 ],
105 );
106}
107
108#[cfg(all(feature = "CFArray", feature = "CFDictionary", feature = "objc2"))]
109unsafe impl RefEncode for CFXMLElementInfo {
110 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
111}
112
113#[repr(C)]
115#[derive(Clone, Copy, Debug, PartialEq)]
116pub struct CFXMLProcessingInstructionInfo {
117 pub dataString: *const CFString,
118}
119
120#[cfg(feature = "objc2")]
121unsafe impl Encode for CFXMLProcessingInstructionInfo {
122 const ENCODING: Encoding = Encoding::Struct("?", &[<*const CFString>::ENCODING]);
123}
124
125#[cfg(feature = "objc2")]
126unsafe impl RefEncode for CFXMLProcessingInstructionInfo {
127 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
128}
129
130#[cfg(all(feature = "CFString", feature = "CFURL"))]
132#[repr(C)]
133#[derive(Clone, Copy, Debug, PartialEq)]
134pub struct CFXMLDocumentInfo {
135 pub sourceURL: *const CFURL,
136 pub encoding: CFStringEncoding,
137}
138
139#[cfg(all(feature = "CFString", feature = "CFURL", feature = "objc2"))]
140unsafe impl Encode for CFXMLDocumentInfo {
141 const ENCODING: Encoding = Encoding::Struct(
142 "?",
143 &[<*const CFURL>::ENCODING, <CFStringEncoding>::ENCODING],
144 );
145}
146
147#[cfg(all(feature = "CFString", feature = "CFURL", feature = "objc2"))]
148unsafe impl RefEncode for CFXMLDocumentInfo {
149 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
150}
151
152#[cfg(feature = "CFURL")]
154#[repr(C)]
155#[derive(Clone, Copy, Debug, PartialEq)]
156pub struct CFXMLExternalID {
157 pub systemID: *const CFURL,
158 pub publicID: *const CFString,
159}
160
161#[cfg(all(feature = "CFURL", feature = "objc2"))]
162unsafe impl Encode for CFXMLExternalID {
163 const ENCODING: Encoding = Encoding::Struct(
164 "?",
165 &[<*const CFURL>::ENCODING, <*const CFString>::ENCODING],
166 );
167}
168
169#[cfg(all(feature = "CFURL", feature = "objc2"))]
170unsafe impl RefEncode for CFXMLExternalID {
171 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
172}
173
174#[cfg(feature = "CFURL")]
176#[repr(C)]
177#[derive(Clone, Copy, Debug, PartialEq)]
178pub struct CFXMLDocumentTypeInfo {
179 pub externalID: CFXMLExternalID,
180}
181
182#[cfg(all(feature = "CFURL", feature = "objc2"))]
183unsafe impl Encode for CFXMLDocumentTypeInfo {
184 const ENCODING: Encoding = Encoding::Struct("?", &[<CFXMLExternalID>::ENCODING]);
185}
186
187#[cfg(all(feature = "CFURL", feature = "objc2"))]
188unsafe impl RefEncode for CFXMLDocumentTypeInfo {
189 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
190}
191
192#[cfg(feature = "CFURL")]
194#[repr(C)]
195#[derive(Clone, Copy, Debug, PartialEq)]
196pub struct CFXMLNotationInfo {
197 pub externalID: CFXMLExternalID,
198}
199
200#[cfg(all(feature = "CFURL", feature = "objc2"))]
201unsafe impl Encode for CFXMLNotationInfo {
202 const ENCODING: Encoding = Encoding::Struct("?", &[<CFXMLExternalID>::ENCODING]);
203}
204
205#[cfg(all(feature = "CFURL", feature = "objc2"))]
206unsafe impl RefEncode for CFXMLNotationInfo {
207 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
208}
209
210#[repr(C)]
212#[derive(Clone, Copy, Debug, PartialEq)]
213pub struct CFXMLElementTypeDeclarationInfo {
214 pub contentDescription: *const CFString,
215}
216
217#[cfg(feature = "objc2")]
218unsafe impl Encode for CFXMLElementTypeDeclarationInfo {
219 const ENCODING: Encoding = Encoding::Struct("?", &[<*const CFString>::ENCODING]);
220}
221
222#[cfg(feature = "objc2")]
223unsafe impl RefEncode for CFXMLElementTypeDeclarationInfo {
224 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
225}
226
227#[repr(C)]
229#[derive(Clone, Copy, Debug, PartialEq)]
230pub struct CFXMLAttributeDeclarationInfo {
231 pub attributeName: *const CFString,
232 pub typeString: *const CFString,
233 pub defaultString: *const CFString,
234}
235
236#[cfg(feature = "objc2")]
237unsafe impl Encode for CFXMLAttributeDeclarationInfo {
238 const ENCODING: Encoding = Encoding::Struct(
239 "?",
240 &[
241 <*const CFString>::ENCODING,
242 <*const CFString>::ENCODING,
243 <*const CFString>::ENCODING,
244 ],
245 );
246}
247
248#[cfg(feature = "objc2")]
249unsafe impl RefEncode for CFXMLAttributeDeclarationInfo {
250 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
251}
252
253#[repr(C)]
255#[derive(Clone, Copy, Debug, PartialEq)]
256pub struct CFXMLAttributeListDeclarationInfo {
257 pub numberOfAttributes: CFIndex,
258 pub attributes: *mut CFXMLAttributeDeclarationInfo,
259}
260
261#[cfg(feature = "objc2")]
262unsafe impl Encode for CFXMLAttributeListDeclarationInfo {
263 const ENCODING: Encoding = Encoding::Struct(
264 "?",
265 &[
266 <CFIndex>::ENCODING,
267 <*mut CFXMLAttributeDeclarationInfo>::ENCODING,
268 ],
269 );
270}
271
272#[cfg(feature = "objc2")]
273unsafe impl RefEncode for CFXMLAttributeListDeclarationInfo {
274 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
275}
276
277#[repr(transparent)]
280#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
281pub struct CFXMLEntityTypeCode(pub CFIndex);
282impl CFXMLEntityTypeCode {
283 #[doc(alias = "kCFXMLEntityTypeParameter")]
284 pub const Parameter: Self = Self(0);
285 #[doc(alias = "kCFXMLEntityTypeParsedInternal")]
286 pub const ParsedInternal: Self = Self(1);
287 #[doc(alias = "kCFXMLEntityTypeParsedExternal")]
288 pub const ParsedExternal: Self = Self(2);
289 #[doc(alias = "kCFXMLEntityTypeUnparsed")]
290 pub const Unparsed: Self = Self(3);
291 #[doc(alias = "kCFXMLEntityTypeCharacter")]
292 pub const Character: Self = Self(4);
293}
294
295#[cfg(feature = "objc2")]
296unsafe impl Encode for CFXMLEntityTypeCode {
297 const ENCODING: Encoding = CFIndex::ENCODING;
298}
299
300#[cfg(feature = "objc2")]
301unsafe impl RefEncode for CFXMLEntityTypeCode {
302 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
303}
304
305#[cfg(feature = "CFURL")]
307#[repr(C)]
308#[derive(Clone, Copy, Debug, PartialEq)]
309pub struct CFXMLEntityInfo {
310 pub entityType: CFXMLEntityTypeCode,
311 pub replacementText: *const CFString,
312 pub entityID: CFXMLExternalID,
313 pub notationName: *const CFString,
314}
315
316#[cfg(all(feature = "CFURL", feature = "objc2"))]
317unsafe impl Encode for CFXMLEntityInfo {
318 const ENCODING: Encoding = Encoding::Struct(
319 "?",
320 &[
321 <CFXMLEntityTypeCode>::ENCODING,
322 <*const CFString>::ENCODING,
323 <CFXMLExternalID>::ENCODING,
324 <*const CFString>::ENCODING,
325 ],
326 );
327}
328
329#[cfg(all(feature = "CFURL", feature = "objc2"))]
330unsafe impl RefEncode for CFXMLEntityInfo {
331 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
332}
333
334#[repr(C)]
336#[derive(Clone, Copy, Debug, PartialEq)]
337pub struct CFXMLEntityReferenceInfo {
338 pub entityType: CFXMLEntityTypeCode,
339}
340
341#[cfg(feature = "objc2")]
342unsafe impl Encode for CFXMLEntityReferenceInfo {
343 const ENCODING: Encoding = Encoding::Struct("?", &[<CFXMLEntityTypeCode>::ENCODING]);
344}
345
346#[cfg(feature = "objc2")]
347unsafe impl RefEncode for CFXMLEntityReferenceInfo {
348 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
349}
350
351unsafe impl ConcreteType for CFXMLNode {
352 #[doc(alias = "CFXMLNodeGetTypeID")]
353 #[inline]
354 fn type_id() -> CFTypeID {
355 extern "C-unwind" {
356 fn CFXMLNodeGetTypeID() -> CFTypeID;
357 }
358 unsafe { CFXMLNodeGetTypeID() }
359 }
360}
361
362impl CFXMLNode {
363 #[doc(alias = "CFXMLNodeCreate")]
369 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
370 #[inline]
371 pub unsafe fn new(
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 #[doc(alias = "CFXMLNodeCreateCopy")]
397 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
398 #[inline]
399 pub unsafe fn new_copy(
400 alloc: Option<&CFAllocator>,
401 orig_node: Option<&CFXMLNode>,
402 ) -> Option<CFRetained<CFXMLNode>> {
403 extern "C-unwind" {
404 fn CFXMLNodeCreateCopy(
405 alloc: Option<&CFAllocator>,
406 orig_node: Option<&CFXMLNode>,
407 ) -> Option<NonNull<CFXMLNode>>;
408 }
409 let ret = unsafe { CFXMLNodeCreateCopy(alloc, orig_node) };
410 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
411 }
412
413 #[doc(alias = "CFXMLNodeGetTypeCode")]
414 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
415 #[inline]
416 pub fn type_code(&self) -> CFXMLNodeTypeCode {
417 extern "C-unwind" {
418 fn CFXMLNodeGetTypeCode(node: &CFXMLNode) -> CFXMLNodeTypeCode;
419 }
420 unsafe { CFXMLNodeGetTypeCode(self) }
421 }
422
423 #[doc(alias = "CFXMLNodeGetString")]
424 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
425 #[inline]
426 pub fn string(&self) -> Option<CFRetained<CFString>> {
427 extern "C-unwind" {
428 fn CFXMLNodeGetString(node: &CFXMLNode) -> Option<NonNull<CFString>>;
429 }
430 let ret = unsafe { CFXMLNodeGetString(self) };
431 ret.map(|ret| unsafe { CFRetained::retain(ret) })
432 }
433
434 #[doc(alias = "CFXMLNodeGetInfoPtr")]
435 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
436 #[inline]
437 pub fn info_ptr(&self) -> *const c_void {
438 extern "C-unwind" {
439 fn CFXMLNodeGetInfoPtr(node: &CFXMLNode) -> *const c_void;
440 }
441 unsafe { CFXMLNodeGetInfoPtr(self) }
442 }
443
444 #[doc(alias = "CFXMLNodeGetVersion")]
445 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
446 #[inline]
447 pub fn version(&self) -> CFIndex {
448 extern "C-unwind" {
449 fn CFXMLNodeGetVersion(node: &CFXMLNode) -> CFIndex;
450 }
451 unsafe { CFXMLNodeGetVersion(self) }
452 }
453}
454
455#[cfg(feature = "CFTree")]
460#[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
461#[inline]
462pub unsafe extern "C-unwind" fn CFXMLTreeCreateWithNode(
463 allocator: Option<&CFAllocator>,
464 node: Option<&CFXMLNode>,
465) -> Option<CFRetained<CFXMLTree>> {
466 extern "C-unwind" {
467 fn CFXMLTreeCreateWithNode(
468 allocator: Option<&CFAllocator>,
469 node: Option<&CFXMLNode>,
470 ) -> Option<NonNull<CFXMLTree>>;
471 }
472 let ret = unsafe { CFXMLTreeCreateWithNode(allocator, node) };
473 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
474}
475
476#[cfg(feature = "CFTree")]
477#[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
478#[inline]
479pub extern "C-unwind" fn CFXMLTreeGetNode(xml_tree: &CFXMLTree) -> Option<CFRetained<CFXMLNode>> {
480 extern "C-unwind" {
481 fn CFXMLTreeGetNode(xml_tree: &CFXMLTree) -> Option<NonNull<CFXMLNode>>;
482 }
483 let ret = unsafe { CFXMLTreeGetNode(xml_tree) };
484 ret.map(|ret| unsafe { CFRetained::retain(ret) })
485}
486
487#[deprecated = "renamed to `CFXMLNode::new`"]
488#[inline]
489pub unsafe extern "C-unwind" fn CFXMLNodeCreate(
490 alloc: Option<&CFAllocator>,
491 xml_type: CFXMLNodeTypeCode,
492 data_string: Option<&CFString>,
493 additional_info_ptr: *const c_void,
494 version: CFIndex,
495) -> Option<CFRetained<CFXMLNode>> {
496 extern "C-unwind" {
497 fn CFXMLNodeCreate(
498 alloc: Option<&CFAllocator>,
499 xml_type: CFXMLNodeTypeCode,
500 data_string: Option<&CFString>,
501 additional_info_ptr: *const c_void,
502 version: CFIndex,
503 ) -> Option<NonNull<CFXMLNode>>;
504 }
505 let ret =
506 unsafe { CFXMLNodeCreate(alloc, xml_type, data_string, additional_info_ptr, version) };
507 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
508}
509
510#[deprecated = "renamed to `CFXMLNode::new_copy`"]
511#[inline]
512pub unsafe extern "C-unwind" fn CFXMLNodeCreateCopy(
513 alloc: Option<&CFAllocator>,
514 orig_node: Option<&CFXMLNode>,
515) -> Option<CFRetained<CFXMLNode>> {
516 extern "C-unwind" {
517 fn CFXMLNodeCreateCopy(
518 alloc: Option<&CFAllocator>,
519 orig_node: Option<&CFXMLNode>,
520 ) -> Option<NonNull<CFXMLNode>>;
521 }
522 let ret = unsafe { CFXMLNodeCreateCopy(alloc, orig_node) };
523 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
524}
525
526#[deprecated = "renamed to `CFXMLNode::type_code`"]
527#[inline]
528pub extern "C-unwind" fn CFXMLNodeGetTypeCode(node: &CFXMLNode) -> CFXMLNodeTypeCode {
529 extern "C-unwind" {
530 fn CFXMLNodeGetTypeCode(node: &CFXMLNode) -> CFXMLNodeTypeCode;
531 }
532 unsafe { CFXMLNodeGetTypeCode(node) }
533}
534
535#[deprecated = "renamed to `CFXMLNode::string`"]
536#[inline]
537pub extern "C-unwind" fn CFXMLNodeGetString(node: &CFXMLNode) -> Option<CFRetained<CFString>> {
538 extern "C-unwind" {
539 fn CFXMLNodeGetString(node: &CFXMLNode) -> Option<NonNull<CFString>>;
540 }
541 let ret = unsafe { CFXMLNodeGetString(node) };
542 ret.map(|ret| unsafe { CFRetained::retain(ret) })
543}
544
545#[deprecated = "renamed to `CFXMLNode::info_ptr`"]
546#[inline]
547pub extern "C-unwind" fn CFXMLNodeGetInfoPtr(node: &CFXMLNode) -> *const c_void {
548 extern "C-unwind" {
549 fn CFXMLNodeGetInfoPtr(node: &CFXMLNode) -> *const c_void;
550 }
551 unsafe { CFXMLNodeGetInfoPtr(node) }
552}
553
554#[deprecated = "renamed to `CFXMLNode::version`"]
555#[inline]
556pub extern "C-unwind" fn CFXMLNodeGetVersion(node: &CFXMLNode) -> CFIndex {
557 extern "C-unwind" {
558 fn CFXMLNodeGetVersion(node: &CFXMLNode) -> CFIndex;
559 }
560 unsafe { CFXMLNodeGetVersion(node) }
561}