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#[repr(C)]
17pub struct CFXMLNode {
18 inner: [u8; 0],
19 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
20}
21
22cf_type!(
23 unsafe impl CFXMLNode {}
24);
25#[cfg(feature = "objc2")]
26cf_objc2_type!(
27 unsafe impl RefEncode<"__CFXMLNode"> for CFXMLNode {}
28);
29
30#[cfg(feature = "CFTree")]
32pub type CFXMLTree = CFTree;
33
34#[repr(transparent)]
37#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
38pub struct CFXMLNodeTypeCode(pub CFIndex);
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(feature = "objc2")]
73unsafe impl Encode for CFXMLNodeTypeCode {
74 const ENCODING: Encoding = CFIndex::ENCODING;
75}
76
77#[cfg(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#[repr(C)]
113#[derive(Clone, Copy, Debug, PartialEq)]
114pub struct CFXMLProcessingInstructionInfo {
115 pub dataString: *const CFString,
116}
117
118#[cfg(feature = "objc2")]
119unsafe impl Encode for CFXMLProcessingInstructionInfo {
120 const ENCODING: Encoding = Encoding::Struct("?", &[<*const CFString>::ENCODING]);
121}
122
123#[cfg(feature = "objc2")]
124unsafe impl RefEncode for CFXMLProcessingInstructionInfo {
125 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
126}
127
128#[cfg(all(feature = "CFString", feature = "CFURL"))]
130#[repr(C)]
131#[derive(Clone, Copy, Debug, PartialEq)]
132pub struct CFXMLDocumentInfo {
133 pub sourceURL: *const CFURL,
134 pub encoding: CFStringEncoding,
135}
136
137#[cfg(all(feature = "CFString", feature = "CFURL", feature = "objc2"))]
138unsafe impl Encode for CFXMLDocumentInfo {
139 const ENCODING: Encoding = Encoding::Struct(
140 "?",
141 &[<*const CFURL>::ENCODING, <CFStringEncoding>::ENCODING],
142 );
143}
144
145#[cfg(all(feature = "CFString", feature = "CFURL", feature = "objc2"))]
146unsafe impl RefEncode for CFXMLDocumentInfo {
147 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
148}
149
150#[cfg(feature = "CFURL")]
152#[repr(C)]
153#[derive(Clone, Copy, Debug, PartialEq)]
154pub struct CFXMLExternalID {
155 pub systemID: *const CFURL,
156 pub publicID: *const CFString,
157}
158
159#[cfg(all(feature = "CFURL", feature = "objc2"))]
160unsafe impl Encode for CFXMLExternalID {
161 const ENCODING: Encoding = Encoding::Struct(
162 "?",
163 &[<*const CFURL>::ENCODING, <*const CFString>::ENCODING],
164 );
165}
166
167#[cfg(all(feature = "CFURL", feature = "objc2"))]
168unsafe impl RefEncode for CFXMLExternalID {
169 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
170}
171
172#[cfg(feature = "CFURL")]
174#[repr(C)]
175#[derive(Clone, Copy, Debug, PartialEq)]
176pub struct CFXMLDocumentTypeInfo {
177 pub externalID: CFXMLExternalID,
178}
179
180#[cfg(all(feature = "CFURL", feature = "objc2"))]
181unsafe impl Encode for CFXMLDocumentTypeInfo {
182 const ENCODING: Encoding = Encoding::Struct("?", &[<CFXMLExternalID>::ENCODING]);
183}
184
185#[cfg(all(feature = "CFURL", feature = "objc2"))]
186unsafe impl RefEncode for CFXMLDocumentTypeInfo {
187 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
188}
189
190#[cfg(feature = "CFURL")]
192#[repr(C)]
193#[derive(Clone, Copy, Debug, PartialEq)]
194pub struct CFXMLNotationInfo {
195 pub externalID: CFXMLExternalID,
196}
197
198#[cfg(all(feature = "CFURL", feature = "objc2"))]
199unsafe impl Encode for CFXMLNotationInfo {
200 const ENCODING: Encoding = Encoding::Struct("?", &[<CFXMLExternalID>::ENCODING]);
201}
202
203#[cfg(all(feature = "CFURL", feature = "objc2"))]
204unsafe impl RefEncode for CFXMLNotationInfo {
205 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
206}
207
208#[repr(C)]
210#[derive(Clone, Copy, Debug, PartialEq)]
211pub struct CFXMLElementTypeDeclarationInfo {
212 pub contentDescription: *const CFString,
213}
214
215#[cfg(feature = "objc2")]
216unsafe impl Encode for CFXMLElementTypeDeclarationInfo {
217 const ENCODING: Encoding = Encoding::Struct("?", &[<*const CFString>::ENCODING]);
218}
219
220#[cfg(feature = "objc2")]
221unsafe impl RefEncode for CFXMLElementTypeDeclarationInfo {
222 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
223}
224
225#[repr(C)]
227#[derive(Clone, Copy, Debug, PartialEq)]
228pub struct CFXMLAttributeDeclarationInfo {
229 pub attributeName: *const CFString,
230 pub typeString: *const CFString,
231 pub defaultString: *const CFString,
232}
233
234#[cfg(feature = "objc2")]
235unsafe impl Encode for CFXMLAttributeDeclarationInfo {
236 const ENCODING: Encoding = Encoding::Struct(
237 "?",
238 &[
239 <*const CFString>::ENCODING,
240 <*const CFString>::ENCODING,
241 <*const CFString>::ENCODING,
242 ],
243 );
244}
245
246#[cfg(feature = "objc2")]
247unsafe impl RefEncode for CFXMLAttributeDeclarationInfo {
248 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
249}
250
251#[repr(C)]
253#[derive(Clone, Copy, Debug, PartialEq)]
254pub struct CFXMLAttributeListDeclarationInfo {
255 pub numberOfAttributes: CFIndex,
256 pub attributes: *mut CFXMLAttributeDeclarationInfo,
257}
258
259#[cfg(feature = "objc2")]
260unsafe impl Encode for CFXMLAttributeListDeclarationInfo {
261 const ENCODING: Encoding = Encoding::Struct(
262 "?",
263 &[
264 <CFIndex>::ENCODING,
265 <*mut CFXMLAttributeDeclarationInfo>::ENCODING,
266 ],
267 );
268}
269
270#[cfg(feature = "objc2")]
271unsafe impl RefEncode for CFXMLAttributeListDeclarationInfo {
272 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
273}
274
275#[repr(transparent)]
278#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
279pub struct CFXMLEntityTypeCode(pub CFIndex);
280impl CFXMLEntityTypeCode {
281 #[doc(alias = "kCFXMLEntityTypeParameter")]
282 pub const Parameter: Self = Self(0);
283 #[doc(alias = "kCFXMLEntityTypeParsedInternal")]
284 pub const ParsedInternal: Self = Self(1);
285 #[doc(alias = "kCFXMLEntityTypeParsedExternal")]
286 pub const ParsedExternal: Self = Self(2);
287 #[doc(alias = "kCFXMLEntityTypeUnparsed")]
288 pub const Unparsed: Self = Self(3);
289 #[doc(alias = "kCFXMLEntityTypeCharacter")]
290 pub const Character: Self = Self(4);
291}
292
293#[cfg(feature = "objc2")]
294unsafe impl Encode for CFXMLEntityTypeCode {
295 const ENCODING: Encoding = CFIndex::ENCODING;
296}
297
298#[cfg(feature = "objc2")]
299unsafe impl RefEncode for CFXMLEntityTypeCode {
300 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
301}
302
303#[cfg(feature = "CFURL")]
305#[repr(C)]
306#[derive(Clone, Copy, Debug, PartialEq)]
307pub struct CFXMLEntityInfo {
308 pub entityType: CFXMLEntityTypeCode,
309 pub replacementText: *const CFString,
310 pub entityID: CFXMLExternalID,
311 pub notationName: *const CFString,
312}
313
314#[cfg(all(feature = "CFURL", feature = "objc2"))]
315unsafe impl Encode for CFXMLEntityInfo {
316 const ENCODING: Encoding = Encoding::Struct(
317 "?",
318 &[
319 <CFXMLEntityTypeCode>::ENCODING,
320 <*const CFString>::ENCODING,
321 <CFXMLExternalID>::ENCODING,
322 <*const CFString>::ENCODING,
323 ],
324 );
325}
326
327#[cfg(all(feature = "CFURL", feature = "objc2"))]
328unsafe impl RefEncode for CFXMLEntityInfo {
329 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
330}
331
332#[repr(C)]
334#[derive(Clone, Copy, Debug, PartialEq)]
335pub struct CFXMLEntityReferenceInfo {
336 pub entityType: CFXMLEntityTypeCode,
337}
338
339#[cfg(feature = "objc2")]
340unsafe impl Encode for CFXMLEntityReferenceInfo {
341 const ENCODING: Encoding = Encoding::Struct("?", &[<CFXMLEntityTypeCode>::ENCODING]);
342}
343
344#[cfg(feature = "objc2")]
345unsafe impl RefEncode for CFXMLEntityReferenceInfo {
346 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
347}
348
349unsafe impl ConcreteType for CFXMLNode {
350 #[doc(alias = "CFXMLNodeGetTypeID")]
351 #[inline]
352 fn type_id() -> CFTypeID {
353 extern "C-unwind" {
354 fn CFXMLNodeGetTypeID() -> CFTypeID;
355 }
356 unsafe { CFXMLNodeGetTypeID() }
357 }
358}
359
360impl CFXMLNode {
361 #[doc(alias = "CFXMLNodeCreate")]
362 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
363 #[inline]
364 pub unsafe fn new(
365 alloc: Option<&CFAllocator>,
366 xml_type: CFXMLNodeTypeCode,
367 data_string: Option<&CFString>,
368 additional_info_ptr: *const c_void,
369 version: CFIndex,
370 ) -> Option<CFRetained<CFXMLNode>> {
371 extern "C-unwind" {
372 fn CFXMLNodeCreate(
373 alloc: Option<&CFAllocator>,
374 xml_type: CFXMLNodeTypeCode,
375 data_string: Option<&CFString>,
376 additional_info_ptr: *const c_void,
377 version: CFIndex,
378 ) -> Option<NonNull<CFXMLNode>>;
379 }
380 let ret =
381 unsafe { CFXMLNodeCreate(alloc, xml_type, data_string, additional_info_ptr, version) };
382 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
383 }
384
385 #[doc(alias = "CFXMLNodeCreateCopy")]
386 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
387 #[inline]
388 pub unsafe fn new_copy(
389 alloc: Option<&CFAllocator>,
390 orig_node: Option<&CFXMLNode>,
391 ) -> Option<CFRetained<CFXMLNode>> {
392 extern "C-unwind" {
393 fn CFXMLNodeCreateCopy(
394 alloc: Option<&CFAllocator>,
395 orig_node: Option<&CFXMLNode>,
396 ) -> Option<NonNull<CFXMLNode>>;
397 }
398 let ret = unsafe { CFXMLNodeCreateCopy(alloc, orig_node) };
399 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
400 }
401
402 #[doc(alias = "CFXMLNodeGetTypeCode")]
403 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
404 #[inline]
405 pub unsafe fn type_code(self: &CFXMLNode) -> CFXMLNodeTypeCode {
406 extern "C-unwind" {
407 fn CFXMLNodeGetTypeCode(node: &CFXMLNode) -> CFXMLNodeTypeCode;
408 }
409 unsafe { CFXMLNodeGetTypeCode(self) }
410 }
411
412 #[doc(alias = "CFXMLNodeGetString")]
413 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
414 #[inline]
415 pub unsafe fn string(self: &CFXMLNode) -> Option<CFRetained<CFString>> {
416 extern "C-unwind" {
417 fn CFXMLNodeGetString(node: &CFXMLNode) -> Option<NonNull<CFString>>;
418 }
419 let ret = unsafe { CFXMLNodeGetString(self) };
420 ret.map(|ret| unsafe { CFRetained::retain(ret) })
421 }
422
423 #[doc(alias = "CFXMLNodeGetInfoPtr")]
424 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
425 #[inline]
426 pub unsafe fn info_ptr(self: &CFXMLNode) -> *const c_void {
427 extern "C-unwind" {
428 fn CFXMLNodeGetInfoPtr(node: &CFXMLNode) -> *const c_void;
429 }
430 unsafe { CFXMLNodeGetInfoPtr(self) }
431 }
432
433 #[doc(alias = "CFXMLNodeGetVersion")]
434 #[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
435 #[inline]
436 pub unsafe fn version(self: &CFXMLNode) -> CFIndex {
437 extern "C-unwind" {
438 fn CFXMLNodeGetVersion(node: &CFXMLNode) -> CFIndex;
439 }
440 unsafe { CFXMLNodeGetVersion(self) }
441 }
442}
443
444#[cfg(feature = "CFTree")]
445#[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
446#[inline]
447pub unsafe extern "C-unwind" fn CFXMLTreeCreateWithNode(
448 allocator: Option<&CFAllocator>,
449 node: Option<&CFXMLNode>,
450) -> Option<CFRetained<CFXMLTree>> {
451 extern "C-unwind" {
452 fn CFXMLTreeCreateWithNode(
453 allocator: Option<&CFAllocator>,
454 node: Option<&CFXMLNode>,
455 ) -> Option<NonNull<CFXMLTree>>;
456 }
457 let ret = unsafe { CFXMLTreeCreateWithNode(allocator, node) };
458 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
459}
460
461#[cfg(feature = "CFTree")]
462#[deprecated = "CFXMLNode is deprecated, use NSXMLParser, NSXMLDocument or libxml2 library instead"]
463#[inline]
464pub unsafe extern "C-unwind" fn CFXMLTreeGetNode(
465 xml_tree: &CFXMLTree,
466) -> Option<CFRetained<CFXMLNode>> {
467 extern "C-unwind" {
468 fn CFXMLTreeGetNode(xml_tree: &CFXMLTree) -> Option<NonNull<CFXMLNode>>;
469 }
470 let ret = unsafe { CFXMLTreeGetNode(xml_tree) };
471 ret.map(|ret| unsafe { CFRetained::retain(ret) })
472}
473
474#[deprecated = "renamed to `CFXMLNode::new`"]
475#[inline]
476pub unsafe extern "C-unwind" fn CFXMLNodeCreate(
477 alloc: Option<&CFAllocator>,
478 xml_type: CFXMLNodeTypeCode,
479 data_string: Option<&CFString>,
480 additional_info_ptr: *const c_void,
481 version: CFIndex,
482) -> Option<CFRetained<CFXMLNode>> {
483 extern "C-unwind" {
484 fn CFXMLNodeCreate(
485 alloc: Option<&CFAllocator>,
486 xml_type: CFXMLNodeTypeCode,
487 data_string: Option<&CFString>,
488 additional_info_ptr: *const c_void,
489 version: CFIndex,
490 ) -> Option<NonNull<CFXMLNode>>;
491 }
492 let ret =
493 unsafe { CFXMLNodeCreate(alloc, xml_type, data_string, additional_info_ptr, version) };
494 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
495}
496
497#[deprecated = "renamed to `CFXMLNode::new_copy`"]
498#[inline]
499pub unsafe extern "C-unwind" fn CFXMLNodeCreateCopy(
500 alloc: Option<&CFAllocator>,
501 orig_node: Option<&CFXMLNode>,
502) -> Option<CFRetained<CFXMLNode>> {
503 extern "C-unwind" {
504 fn CFXMLNodeCreateCopy(
505 alloc: Option<&CFAllocator>,
506 orig_node: Option<&CFXMLNode>,
507 ) -> Option<NonNull<CFXMLNode>>;
508 }
509 let ret = unsafe { CFXMLNodeCreateCopy(alloc, orig_node) };
510 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
511}
512
513extern "C-unwind" {
514 #[deprecated = "renamed to `CFXMLNode::type_code`"]
515 pub fn CFXMLNodeGetTypeCode(node: &CFXMLNode) -> CFXMLNodeTypeCode;
516}
517
518#[deprecated = "renamed to `CFXMLNode::string`"]
519#[inline]
520pub unsafe extern "C-unwind" fn CFXMLNodeGetString(
521 node: &CFXMLNode,
522) -> Option<CFRetained<CFString>> {
523 extern "C-unwind" {
524 fn CFXMLNodeGetString(node: &CFXMLNode) -> Option<NonNull<CFString>>;
525 }
526 let ret = unsafe { CFXMLNodeGetString(node) };
527 ret.map(|ret| unsafe { CFRetained::retain(ret) })
528}
529
530extern "C-unwind" {
531 #[deprecated = "renamed to `CFXMLNode::info_ptr`"]
532 pub fn CFXMLNodeGetInfoPtr(node: &CFXMLNode) -> *const c_void;
533}
534
535extern "C-unwind" {
536 #[deprecated = "renamed to `CFXMLNode::version`"]
537 pub fn CFXMLNodeGetVersion(node: &CFXMLNode) -> CFIndex;
538}