objc2_core_foundation/generated/
CFSet.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/// Type of the callback function used by CFSets for retaining values.
13///
14/// Parameter `allocator`: The allocator of the CFSet.
15///
16/// Parameter `value`: The value to retain.
17///
18/// Returns: The value to store in the set, which is usually the value
19/// parameter passed to this callback, but may be a different
20/// value if a different value should be stored in the set.
21///
22/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfsetretaincallback?language=objc)
23pub type CFSetRetainCallBack =
24    Option<unsafe extern "C-unwind" fn(*const CFAllocator, *const c_void) -> *const c_void>;
25
26/// Type of the callback function used by CFSets for releasing a retain on values.
27///
28/// Parameter `allocator`: The allocator of the CFSet.
29///
30/// Parameter `value`: The value to release.
31///
32/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfsetreleasecallback?language=objc)
33pub type CFSetReleaseCallBack =
34    Option<unsafe extern "C-unwind" fn(*const CFAllocator, *const c_void)>;
35
36/// Type of the callback function used by CFSets for describing values.
37///
38/// Parameter `value`: The value to describe.
39///
40/// Returns: A description of the specified value.
41///
42/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfsetcopydescriptioncallback?language=objc)
43pub type CFSetCopyDescriptionCallBack =
44    Option<unsafe extern "C-unwind" fn(*const c_void) -> *const CFString>;
45
46/// Type of the callback function used by CFSets for comparing values.
47///
48/// Parameter `value1`: The first value to compare.
49///
50/// Parameter `value2`: The second value to compare.
51///
52/// Returns: True if the values are equal, otherwise false.
53///
54/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfsetequalcallback?language=objc)
55pub type CFSetEqualCallBack =
56    Option<unsafe extern "C-unwind" fn(*const c_void, *const c_void) -> Boolean>;
57
58/// Type of the callback function used by CFSets for hashing values.
59///
60/// Parameter `value`: The value to hash.
61///
62/// Returns: The hash of the value.
63///
64/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfsethashcallback?language=objc)
65pub type CFSetHashCallBack = Option<unsafe extern "C-unwind" fn(*const c_void) -> CFHashCode>;
66
67/// Structure containing the callbacks of a CFSet.
68/// Field: version The version number of the structure type being passed
69/// in as a parameter to the CFSet creation functions. This
70/// structure is version 0.
71/// Field: retain The callback used to add a retain for the set on
72/// values as they are put into the set. This callback returns
73/// the value to store in the set, which is usually the value
74/// parameter passed to this callback, but may be a different
75/// value if a different value should be stored in the set.
76/// The set's allocator is passed as the first argument.
77/// Field: release The callback used to remove a retain previously added
78/// for the set from values as they are removed from the
79/// set. The set's allocator is passed as the first
80/// argument.
81/// Field: copyDescription The callback used to create a descriptive
82/// string representation of each value in the set. This is
83/// used by the CFCopyDescription() function.
84/// Field: equal The callback used to compare values in the set for
85/// equality for some operations.
86/// Field: hash The callback used to compare values in the set for
87/// uniqueness for some operations.
88///
89/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfsetcallbacks?language=objc)
90#[repr(C)]
91#[derive(Clone, Copy, Debug, PartialEq)]
92pub struct CFSetCallBacks {
93    pub version: CFIndex,
94    pub retain: CFSetRetainCallBack,
95    pub release: CFSetReleaseCallBack,
96    pub copyDescription: CFSetCopyDescriptionCallBack,
97    pub equal: CFSetEqualCallBack,
98    pub hash: CFSetHashCallBack,
99}
100
101#[cfg(feature = "objc2")]
102unsafe impl Encode for CFSetCallBacks {
103    const ENCODING: Encoding = Encoding::Struct(
104        "?",
105        &[
106            <CFIndex>::ENCODING,
107            <CFSetRetainCallBack>::ENCODING,
108            <CFSetReleaseCallBack>::ENCODING,
109            <CFSetCopyDescriptionCallBack>::ENCODING,
110            <CFSetEqualCallBack>::ENCODING,
111            <CFSetHashCallBack>::ENCODING,
112        ],
113    );
114}
115
116#[cfg(feature = "objc2")]
117unsafe impl RefEncode for CFSetCallBacks {
118    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
119}
120
121extern "C" {
122    /// Predefined CFSetCallBacks structure containing a set of callbacks
123    /// appropriate for use when the values in a CFSet are all CFTypes.
124    ///
125    /// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcftypesetcallbacks?language=objc)
126    pub static kCFTypeSetCallBacks: CFSetCallBacks;
127}
128
129extern "C" {
130    /// Predefined CFSetCallBacks structure containing a set of callbacks
131    /// appropriate for use when the values in a CFSet should be copies
132    /// of a CFString.
133    ///
134    /// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfcopystringsetcallbacks?language=objc)
135    pub static kCFCopyStringSetCallBacks: CFSetCallBacks;
136}
137
138/// Type of the callback function used by the apply functions of
139/// CFSets.
140///
141/// Parameter `value`: The current value from the set.
142///
143/// Parameter `context`: The user-defined context parameter given to the apply
144/// function.
145///
146/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfsetapplierfunction?language=objc)
147pub type CFSetApplierFunction = Option<unsafe extern "C-unwind" fn(*const c_void, *mut c_void)>;
148
149/// This is the type of a reference to immutable CFSets.
150///
151/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfset?language=objc)
152#[repr(C)]
153pub struct CFSet<T: ?Sized = Opaque> {
154    inner: [u8; 0],
155    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
156    _generics: PhantomData<(*mut T,)>,
157}
158
159cf_type!(
160    unsafe impl<T: ?Sized> CFSet<T> {}
161);
162#[cfg(feature = "objc2")]
163cf_objc2_type!(
164    unsafe impl<T: ?Sized> RefEncode<"__CFSet"> for CFSet<T> {}
165);
166
167/// This is the type of a reference to mutable CFSets.
168///
169/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfmutableset?language=objc)
170#[repr(C)]
171pub struct CFMutableSet<T: ?Sized = Opaque> {
172    inner: [u8; 0],
173    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
174    _generics: PhantomData<(*mut T,)>,
175}
176
177cf_type!(
178    unsafe impl<T: ?Sized> CFMutableSet<T>: CFSet<T> {}
179);
180#[cfg(feature = "objc2")]
181cf_objc2_type!(
182    unsafe impl<T: ?Sized> RefEncode<"__CFSet"> for CFMutableSet<T> {}
183);
184
185unsafe impl ConcreteType for CFSet {
186    /// Returns the type identifier of all CFSet instances.
187    #[doc(alias = "CFSetGetTypeID")]
188    #[inline]
189    fn type_id() -> CFTypeID {
190        extern "C-unwind" {
191            fn CFSetGetTypeID() -> CFTypeID;
192        }
193        unsafe { CFSetGetTypeID() }
194    }
195}
196
197impl CFSet {
198    /// Creates a new immutable set with the given values.
199    ///
200    /// Parameter `allocator`: The CFAllocator which should be used to allocate
201    /// memory for the set and its storage for values. This
202    /// parameter may be NULL in which case the current default
203    /// CFAllocator is used. If this reference is not a valid
204    /// CFAllocator, the behavior is undefined.
205    ///
206    /// Parameter `values`: A C array of the pointer-sized values to be in the
207    /// set.  This C array is not changed or freed by this function.
208    /// If this parameter is not a valid pointer to a C array of at
209    /// least numValues pointers, the behavior is undefined.
210    ///
211    /// Parameter `numValues`: The number of values to copy from the values C
212    /// array into the CFSet. This number will be the count of the
213    /// set.  If this parameter is zero, negative, or greater than
214    /// the number of values actually in the values C array, the
215    /// behavior is undefined.
216    ///
217    /// Parameter `callBacks`: A C pointer to a CFSetCallBacks structure
218    /// initialized with the callbacks for the set to use on each
219    /// value in the set. A copy of the contents of the
220    /// callbacks structure is made, so that a pointer to a
221    /// structure on the stack can be passed in, or can be reused
222    /// for multiple set creations. If the version field of this
223    /// callbacks structure is not one of the defined ones for
224    /// CFSet, the behavior is undefined. The retain field may be
225    /// NULL, in which case the CFSet will do nothing to add a
226    /// retain to the contained values for the set. The release
227    /// field may be NULL, in which case the CFSet will do nothing
228    /// to remove the set's retain (if any) on the values when the
229    /// set is destroyed. If the copyDescription field is NULL,
230    /// the set will create a simple description for the value. If
231    /// the equal field is NULL, the set will use pointer equality
232    /// to test for equality of values. The hash field may be NULL,
233    /// in which case the CFSet will determine uniqueness by pointer
234    /// equality. This callbacks parameter
235    /// itself may be NULL, which is treated as if a valid structure
236    /// of version 0 with all fields NULL had been passed in.
237    /// Otherwise, if any of the fields are not valid pointers to
238    /// functions of the correct type, or this parameter is not a
239    /// valid pointer to a  CFSetCallBacks callbacks structure,
240    /// the behavior is undefined. If any of the values put into the
241    /// set is not one understood by one of the callback functions
242    /// the behavior when that callback function is used is
243    /// undefined.
244    ///
245    /// Returns: A reference to the new immutable CFSet.
246    #[doc(alias = "CFSetCreate")]
247    #[inline]
248    pub unsafe fn new(
249        allocator: Option<&CFAllocator>,
250        values: *mut *const c_void,
251        num_values: CFIndex,
252        call_backs: *const CFSetCallBacks,
253    ) -> Option<CFRetained<CFSet>> {
254        extern "C-unwind" {
255            fn CFSetCreate(
256                allocator: Option<&CFAllocator>,
257                values: *mut *const c_void,
258                num_values: CFIndex,
259                call_backs: *const CFSetCallBacks,
260            ) -> Option<NonNull<CFSet>>;
261        }
262        let ret = unsafe { CFSetCreate(allocator, values, num_values, call_backs) };
263        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
264    }
265
266    /// Creates a new immutable set with the values from the given set.
267    ///
268    /// Parameter `allocator`: The CFAllocator which should be used to allocate
269    /// memory for the set and its storage for values. This
270    /// parameter may be NULL in which case the current default
271    /// CFAllocator is used. If this reference is not a valid
272    /// CFAllocator, the behavior is undefined.
273    ///
274    /// Parameter `theSet`: The set which is to be copied. The values from the
275    /// set are copied as pointers into the new set (that is,
276    /// the values themselves are copied, not that which the values
277    /// point to, if anything). However, the values are also
278    /// retained by the new set. The count of the new set will
279    /// be the same as the copied set. The new set uses the same
280    /// callbacks as the set to be copied. If this parameter is
281    /// not a valid CFSet, the behavior is undefined.
282    ///
283    /// Returns: A reference to the new immutable CFSet.
284    #[doc(alias = "CFSetCreateCopy")]
285    #[inline]
286    pub fn new_copy(
287        allocator: Option<&CFAllocator>,
288        the_set: Option<&CFSet>,
289    ) -> Option<CFRetained<CFSet>> {
290        extern "C-unwind" {
291            fn CFSetCreateCopy(
292                allocator: Option<&CFAllocator>,
293                the_set: Option<&CFSet>,
294            ) -> Option<NonNull<CFSet>>;
295        }
296        let ret = unsafe { CFSetCreateCopy(allocator, the_set) };
297        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
298    }
299}
300
301impl CFMutableSet {
302    /// Creates a new empty mutable set.
303    ///
304    /// Parameter `allocator`: The CFAllocator which should be used to allocate
305    /// memory for the set and its storage for values. This
306    /// parameter may be NULL in which case the current default
307    /// CFAllocator is used. If this reference is not a valid
308    /// CFAllocator, the behavior is undefined.
309    ///
310    /// Parameter `capacity`: A hint about the number of values that will be held
311    /// by the CFSet. Pass 0 for no hint. The implementation may
312    /// ignore this hint, or may use it to optimize various
313    /// operations. A set's actual capacity is only limited by
314    /// address space and available memory constraints). If this
315    /// parameter is negative, the behavior is undefined.
316    ///
317    /// Parameter `callBacks`: A C pointer to a CFSetCallBacks structure
318    /// initialized with the callbacks for the set to use on each
319    /// value in the set. A copy of the contents of the
320    /// callbacks structure is made, so that a pointer to a
321    /// structure on the stack can be passed in, or can be reused
322    /// for multiple set creations. If the version field of this
323    /// callbacks structure is not one of the defined ones for
324    /// CFSet, the behavior is undefined. The retain field may be
325    /// NULL, in which case the CFSet will do nothing to add a
326    /// retain to the contained values for the set. The release
327    /// field may be NULL, in which case the CFSet will do nothing
328    /// to remove the set's retain (if any) on the values when the
329    /// set is destroyed. If the copyDescription field is NULL,
330    /// the set will create a simple description for the value. If
331    /// the equal field is NULL, the set will use pointer equality
332    /// to test for equality of values. The hash field may be NULL,
333    /// in which case the CFSet will determine uniqueness by pointer
334    /// equality. This callbacks parameter
335    /// itself may be NULL, which is treated as if a valid structure
336    /// of version 0 with all fields NULL had been passed in.
337    /// Otherwise, if any of the fields are not valid pointers to
338    /// functions of the correct type, or this parameter is not a
339    /// valid pointer to a  CFSetCallBacks callbacks structure,
340    /// the behavior is undefined. If any of the values put into the
341    /// set is not one understood by one of the callback functions
342    /// the behavior when that callback function is used is
343    /// undefined.
344    ///
345    /// Returns: A reference to the new mutable CFSet.
346    #[doc(alias = "CFSetCreateMutable")]
347    #[inline]
348    pub unsafe fn new(
349        allocator: Option<&CFAllocator>,
350        capacity: CFIndex,
351        call_backs: *const CFSetCallBacks,
352    ) -> Option<CFRetained<CFMutableSet>> {
353        extern "C-unwind" {
354            fn CFSetCreateMutable(
355                allocator: Option<&CFAllocator>,
356                capacity: CFIndex,
357                call_backs: *const CFSetCallBacks,
358            ) -> Option<NonNull<CFMutableSet>>;
359        }
360        let ret = unsafe { CFSetCreateMutable(allocator, capacity, call_backs) };
361        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
362    }
363
364    /// Creates a new immutable set with the values from the given set.
365    ///
366    /// Parameter `allocator`: The CFAllocator which should be used to allocate
367    /// memory for the set and its storage for values. This
368    /// parameter may be NULL in which case the current default
369    /// CFAllocator is used. If this reference is not a valid
370    /// CFAllocator, the behavior is undefined.
371    ///
372    /// Parameter `capacity`: A hint about the number of values that will be held
373    /// by the CFSet. Pass 0 for no hint. The implementation may
374    /// ignore this hint, or may use it to optimize various
375    /// operations. A set's actual capacity is only limited by
376    /// address space and available memory constraints).
377    /// This parameter must be greater than or equal
378    /// to the count of the set which is to be copied, or the
379    /// behavior is undefined. If this parameter is negative, the
380    /// behavior is undefined.
381    ///
382    /// Parameter `theSet`: The set which is to be copied. The values from the
383    /// set are copied as pointers into the new set (that is,
384    /// the values themselves are copied, not that which the values
385    /// point to, if anything). However, the values are also
386    /// retained by the new set. The count of the new set will
387    /// be the same as the copied set. The new set uses the same
388    /// callbacks as the set to be copied. If this parameter is
389    /// not a valid CFSet, the behavior is undefined.
390    ///
391    /// Returns: A reference to the new mutable CFSet.
392    #[doc(alias = "CFSetCreateMutableCopy")]
393    #[inline]
394    pub unsafe fn new_copy(
395        allocator: Option<&CFAllocator>,
396        capacity: CFIndex,
397        the_set: Option<&CFSet>,
398    ) -> Option<CFRetained<CFMutableSet>> {
399        extern "C-unwind" {
400            fn CFSetCreateMutableCopy(
401                allocator: Option<&CFAllocator>,
402                capacity: CFIndex,
403                the_set: Option<&CFSet>,
404            ) -> Option<NonNull<CFMutableSet>>;
405        }
406        let ret = unsafe { CFSetCreateMutableCopy(allocator, capacity, the_set) };
407        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
408    }
409}
410
411impl CFSet {
412    /// Returns the number of values currently in the set.
413    ///
414    /// Parameter `theSet`: The set to be queried. If this parameter is not a valid
415    /// CFSet, the behavior is undefined.
416    ///
417    /// Returns: The number of values in the set.
418    #[doc(alias = "CFSetGetCount")]
419    #[inline]
420    pub fn count(self: &CFSet) -> CFIndex {
421        extern "C-unwind" {
422            fn CFSetGetCount(the_set: &CFSet) -> CFIndex;
423        }
424        unsafe { CFSetGetCount(self) }
425    }
426
427    /// Counts the number of times the given value occurs in the set. Since
428    /// sets by definition contain only one instance of a value, this function
429    /// is synonymous to CFSetContainsValue.
430    ///
431    /// Parameter `theSet`: The set to be searched. If this parameter is not a
432    /// valid CFSet, the behavior is undefined.
433    ///
434    /// Parameter `value`: The value for which to find matches in the set. The
435    /// equal() callback provided when the set was created is
436    /// used to compare. If the equal() callback was NULL, pointer
437    /// equality (in C, ==) is used. If value, or any of the values
438    /// in the set, are not understood by the equal() callback,
439    /// the behavior is undefined.
440    ///
441    /// Returns: The number of times the given value occurs in the set.
442    #[doc(alias = "CFSetGetCountOfValue")]
443    #[inline]
444    pub unsafe fn count_of_value(self: &CFSet, value: *const c_void) -> CFIndex {
445        extern "C-unwind" {
446            fn CFSetGetCountOfValue(the_set: &CFSet, value: *const c_void) -> CFIndex;
447        }
448        unsafe { CFSetGetCountOfValue(self, value) }
449    }
450
451    /// Reports whether or not the value is in the set.
452    ///
453    /// Parameter `theSet`: The set to be searched. If this parameter is not a
454    /// valid CFSet, the behavior is undefined.
455    ///
456    /// Parameter `value`: The value for which to find matches in the set. The
457    /// equal() callback provided when the set was created is
458    /// used to compare. If the equal() callback was NULL, pointer
459    /// equality (in C, ==) is used. If value, or any of the values
460    /// in the set, are not understood by the equal() callback,
461    /// the behavior is undefined.
462    ///
463    /// Returns: true, if the value is in the set, otherwise false.
464    #[doc(alias = "CFSetContainsValue")]
465    #[inline]
466    pub unsafe fn contains_value(self: &CFSet, value: *const c_void) -> bool {
467        extern "C-unwind" {
468            fn CFSetContainsValue(the_set: &CFSet, value: *const c_void) -> Boolean;
469        }
470        let ret = unsafe { CFSetContainsValue(self, value) };
471        ret != 0
472    }
473
474    /// Retrieves a value in the set which hashes the same as the specified value.
475    ///
476    /// Parameter `theSet`: The set to be queried. If this parameter is not a
477    /// valid CFSet, the behavior is undefined.
478    ///
479    /// Parameter `value`: The value to retrieve. The equal() callback provided when
480    /// the set was created is used to compare. If the equal() callback
481    /// was NULL, pointer equality (in C, ==) is used. If a value, or
482    /// any of the values in the set, are not understood by the equal()
483    /// callback, the behavior is undefined.
484    ///
485    /// Returns: The value in the set with the given hash.
486    #[doc(alias = "CFSetGetValue")]
487    #[inline]
488    pub unsafe fn value(self: &CFSet, value: *const c_void) -> *const c_void {
489        extern "C-unwind" {
490            fn CFSetGetValue(the_set: &CFSet, value: *const c_void) -> *const c_void;
491        }
492        unsafe { CFSetGetValue(self, value) }
493    }
494
495    /// Retrieves a value in the set which hashes the same as the specified value,
496    /// if present.
497    ///
498    /// Parameter `theSet`: The set to be queried. If this parameter is not a
499    /// valid CFSet, the behavior is undefined.
500    ///
501    /// Parameter `candidate`: This value is hashed and compared with values in the
502    /// set to determine which value to retrieve. The equal() callback provided when
503    /// the set was created is used to compare. If the equal() callback
504    /// was NULL, pointer equality (in C, ==) is used. If a value, or
505    /// any of the values in the set, are not understood by the equal()
506    /// callback, the behavior is undefined.
507    ///
508    /// Parameter `value`: A pointer to memory which should be filled with the
509    /// pointer-sized value if a matching value is found. If no
510    /// match is found, the contents of the storage pointed to by
511    /// this parameter are undefined. This parameter may be NULL,
512    /// in which case the value from the dictionary is not returned
513    /// (but the return value of this function still indicates
514    /// whether or not the value was present).
515    ///
516    /// Returns: True if the value was present in the set, otherwise false.
517    #[doc(alias = "CFSetGetValueIfPresent")]
518    #[inline]
519    pub unsafe fn value_if_present(
520        self: &CFSet,
521        candidate: *const c_void,
522        value: *mut *const c_void,
523    ) -> bool {
524        extern "C-unwind" {
525            fn CFSetGetValueIfPresent(
526                the_set: &CFSet,
527                candidate: *const c_void,
528                value: *mut *const c_void,
529            ) -> Boolean;
530        }
531        let ret = unsafe { CFSetGetValueIfPresent(self, candidate, value) };
532        ret != 0
533    }
534
535    /// Fills the buffer with values from the set.
536    ///
537    /// Parameter `theSet`: The set to be queried. If this parameter is not a
538    /// valid CFSet, the behavior is undefined.
539    ///
540    /// Parameter `values`: A C array of pointer-sized values to be filled with
541    /// values from the set. The values in the C array are ordered
542    /// in the same order in which they appear in the set. If this
543    /// parameter is not a valid pointer to a C array of at least
544    /// CFSetGetCount() pointers, the behavior is undefined.
545    #[doc(alias = "CFSetGetValues")]
546    #[inline]
547    pub unsafe fn values(self: &CFSet, values: *mut *const c_void) {
548        extern "C-unwind" {
549            fn CFSetGetValues(the_set: &CFSet, values: *mut *const c_void);
550        }
551        unsafe { CFSetGetValues(self, values) }
552    }
553
554    /// Calls a function once for each value in the set.
555    ///
556    /// Parameter `theSet`: The set to be operated upon. If this parameter is not
557    /// a valid CFSet, the behavior is undefined.
558    ///
559    /// Parameter `applier`: The callback function to call once for each value in
560    /// the given set. If this parameter is not a
561    /// pointer to a function of the correct prototype, the behavior
562    /// is undefined. If there are values in the set which the
563    /// applier function does not expect or cannot properly apply
564    /// to, the behavior is undefined.
565    ///
566    /// Parameter `context`: A pointer-sized user-defined value, which is passed
567    /// as the second parameter to the applier function, but is
568    /// otherwise unused by this function. If the context is not
569    /// what is expected by the applier function, the behavior is
570    /// undefined.
571    #[doc(alias = "CFSetApplyFunction")]
572    #[inline]
573    pub unsafe fn apply_function(
574        self: &CFSet,
575        applier: CFSetApplierFunction,
576        context: *mut c_void,
577    ) {
578        extern "C-unwind" {
579            fn CFSetApplyFunction(
580                the_set: &CFSet,
581                applier: CFSetApplierFunction,
582                context: *mut c_void,
583            );
584        }
585        unsafe { CFSetApplyFunction(self, applier, context) }
586    }
587}
588
589impl CFMutableSet {
590    /// Adds the value to the set if it is not already present.
591    ///
592    /// Parameter `theSet`: The set to which the value is to be added. If this
593    /// parameter is not a valid mutable CFSet, the behavior is
594    /// undefined.
595    ///
596    /// Parameter `value`: The value to add to the set. The value is retained by
597    /// the set using the retain callback provided when the set
598    /// was created. If the value is not of the sort expected by the
599    /// retain callback, the behavior is undefined. The count of the
600    /// set is increased by one.
601    #[doc(alias = "CFSetAddValue")]
602    #[inline]
603    pub unsafe fn add_value(the_set: Option<&CFMutableSet>, value: *const c_void) {
604        extern "C-unwind" {
605            fn CFSetAddValue(the_set: Option<&CFMutableSet>, value: *const c_void);
606        }
607        unsafe { CFSetAddValue(the_set, value) }
608    }
609
610    /// Replaces the value in the set if it is present.
611    ///
612    /// Parameter `theSet`: The set to which the value is to be replaced. If this
613    /// parameter is not a valid mutable CFSet, the behavior is
614    /// undefined.
615    ///
616    /// Parameter `value`: The value to replace in the set. The equal() callback provided when
617    /// the set was created is used to compare. If the equal() callback
618    /// was NULL, pointer equality (in C, ==) is used. If a value, or
619    /// any of the values in the set, are not understood by the equal()
620    /// callback, the behavior is undefined. The value is retained by
621    /// the set using the retain callback provided when the set
622    /// was created. If the value is not of the sort expected by the
623    /// retain callback, the behavior is undefined. The count of the
624    /// set is increased by one.
625    #[doc(alias = "CFSetReplaceValue")]
626    #[inline]
627    pub unsafe fn replace_value(the_set: Option<&CFMutableSet>, value: *const c_void) {
628        extern "C-unwind" {
629            fn CFSetReplaceValue(the_set: Option<&CFMutableSet>, value: *const c_void);
630        }
631        unsafe { CFSetReplaceValue(the_set, value) }
632    }
633
634    /// Replaces the value in the set if it is present, or adds the value to
635    /// the set if it is absent.
636    ///
637    /// Parameter `theSet`: The set to which the value is to be replaced. If this
638    /// parameter is not a valid mutable CFSet, the behavior is
639    /// undefined.
640    ///
641    /// Parameter `value`: The value to set in the CFSet. The equal() callback provided when
642    /// the set was created is used to compare. If the equal() callback
643    /// was NULL, pointer equality (in C, ==) is used. If a value, or
644    /// any of the values in the set, are not understood by the equal()
645    /// callback, the behavior is undefined. The value is retained by
646    /// the set using the retain callback provided when the set
647    /// was created. If the value is not of the sort expected by the
648    /// retain callback, the behavior is undefined. The count of the
649    /// set is increased by one.
650    #[doc(alias = "CFSetSetValue")]
651    #[inline]
652    pub unsafe fn set_value(the_set: Option<&CFMutableSet>, value: *const c_void) {
653        extern "C-unwind" {
654            fn CFSetSetValue(the_set: Option<&CFMutableSet>, value: *const c_void);
655        }
656        unsafe { CFSetSetValue(the_set, value) }
657    }
658
659    /// Removes the specified value from the set.
660    ///
661    /// Parameter `theSet`: The set from which the value is to be removed.
662    /// If this parameter is not a valid mutable CFSet,
663    /// the behavior is undefined.
664    ///
665    /// Parameter `value`: The value to remove. The equal() callback provided when
666    /// the set was created is used to compare. If the equal() callback
667    /// was NULL, pointer equality (in C, ==) is used. If a value, or
668    /// any of the values in the set, are not understood by the equal()
669    /// callback, the behavior is undefined.
670    #[doc(alias = "CFSetRemoveValue")]
671    #[inline]
672    pub unsafe fn remove_value(the_set: Option<&CFMutableSet>, value: *const c_void) {
673        extern "C-unwind" {
674            fn CFSetRemoveValue(the_set: Option<&CFMutableSet>, value: *const c_void);
675        }
676        unsafe { CFSetRemoveValue(the_set, value) }
677    }
678
679    /// Removes all the values from the set, making it empty.
680    ///
681    /// Parameter `theSet`: The set from which all of the values are to be
682    /// removed. If this parameter is not a valid mutable CFSet,
683    /// the behavior is undefined.
684    #[doc(alias = "CFSetRemoveAllValues")]
685    #[inline]
686    pub fn remove_all_values(the_set: Option<&CFMutableSet>) {
687        extern "C-unwind" {
688            fn CFSetRemoveAllValues(the_set: Option<&CFMutableSet>);
689        }
690        unsafe { CFSetRemoveAllValues(the_set) }
691    }
692}
693
694#[deprecated = "renamed to `CFSet::new`"]
695#[inline]
696pub unsafe extern "C-unwind" fn CFSetCreate(
697    allocator: Option<&CFAllocator>,
698    values: *mut *const c_void,
699    num_values: CFIndex,
700    call_backs: *const CFSetCallBacks,
701) -> Option<CFRetained<CFSet>> {
702    extern "C-unwind" {
703        fn CFSetCreate(
704            allocator: Option<&CFAllocator>,
705            values: *mut *const c_void,
706            num_values: CFIndex,
707            call_backs: *const CFSetCallBacks,
708        ) -> Option<NonNull<CFSet>>;
709    }
710    let ret = unsafe { CFSetCreate(allocator, values, num_values, call_backs) };
711    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
712}
713
714#[deprecated = "renamed to `CFSet::new_copy`"]
715#[inline]
716pub extern "C-unwind" fn CFSetCreateCopy(
717    allocator: Option<&CFAllocator>,
718    the_set: Option<&CFSet>,
719) -> Option<CFRetained<CFSet>> {
720    extern "C-unwind" {
721        fn CFSetCreateCopy(
722            allocator: Option<&CFAllocator>,
723            the_set: Option<&CFSet>,
724        ) -> Option<NonNull<CFSet>>;
725    }
726    let ret = unsafe { CFSetCreateCopy(allocator, the_set) };
727    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
728}
729
730#[deprecated = "renamed to `CFMutableSet::new`"]
731#[inline]
732pub unsafe extern "C-unwind" fn CFSetCreateMutable(
733    allocator: Option<&CFAllocator>,
734    capacity: CFIndex,
735    call_backs: *const CFSetCallBacks,
736) -> Option<CFRetained<CFMutableSet>> {
737    extern "C-unwind" {
738        fn CFSetCreateMutable(
739            allocator: Option<&CFAllocator>,
740            capacity: CFIndex,
741            call_backs: *const CFSetCallBacks,
742        ) -> Option<NonNull<CFMutableSet>>;
743    }
744    let ret = unsafe { CFSetCreateMutable(allocator, capacity, call_backs) };
745    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
746}
747
748#[deprecated = "renamed to `CFMutableSet::new_copy`"]
749#[inline]
750pub unsafe extern "C-unwind" fn CFSetCreateMutableCopy(
751    allocator: Option<&CFAllocator>,
752    capacity: CFIndex,
753    the_set: Option<&CFSet>,
754) -> Option<CFRetained<CFMutableSet>> {
755    extern "C-unwind" {
756        fn CFSetCreateMutableCopy(
757            allocator: Option<&CFAllocator>,
758            capacity: CFIndex,
759            the_set: Option<&CFSet>,
760        ) -> Option<NonNull<CFMutableSet>>;
761    }
762    let ret = unsafe { CFSetCreateMutableCopy(allocator, capacity, the_set) };
763    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
764}
765
766#[deprecated = "renamed to `CFSet::count`"]
767#[inline]
768pub extern "C-unwind" fn CFSetGetCount(the_set: &CFSet) -> CFIndex {
769    extern "C-unwind" {
770        fn CFSetGetCount(the_set: &CFSet) -> CFIndex;
771    }
772    unsafe { CFSetGetCount(the_set) }
773}
774
775extern "C-unwind" {
776    #[deprecated = "renamed to `CFSet::count_of_value`"]
777    pub fn CFSetGetCountOfValue(the_set: &CFSet, value: *const c_void) -> CFIndex;
778}
779
780#[deprecated = "renamed to `CFSet::contains_value`"]
781#[inline]
782pub unsafe extern "C-unwind" fn CFSetContainsValue(the_set: &CFSet, value: *const c_void) -> bool {
783    extern "C-unwind" {
784        fn CFSetContainsValue(the_set: &CFSet, value: *const c_void) -> Boolean;
785    }
786    let ret = unsafe { CFSetContainsValue(the_set, value) };
787    ret != 0
788}
789
790extern "C-unwind" {
791    #[deprecated = "renamed to `CFSet::value`"]
792    pub fn CFSetGetValue(the_set: &CFSet, value: *const c_void) -> *const c_void;
793}
794
795#[deprecated = "renamed to `CFSet::value_if_present`"]
796#[inline]
797pub unsafe extern "C-unwind" fn CFSetGetValueIfPresent(
798    the_set: &CFSet,
799    candidate: *const c_void,
800    value: *mut *const c_void,
801) -> bool {
802    extern "C-unwind" {
803        fn CFSetGetValueIfPresent(
804            the_set: &CFSet,
805            candidate: *const c_void,
806            value: *mut *const c_void,
807        ) -> Boolean;
808    }
809    let ret = unsafe { CFSetGetValueIfPresent(the_set, candidate, value) };
810    ret != 0
811}
812
813extern "C-unwind" {
814    #[deprecated = "renamed to `CFSet::values`"]
815    pub fn CFSetGetValues(the_set: &CFSet, values: *mut *const c_void);
816}
817
818extern "C-unwind" {
819    #[deprecated = "renamed to `CFSet::apply_function`"]
820    pub fn CFSetApplyFunction(the_set: &CFSet, applier: CFSetApplierFunction, context: *mut c_void);
821}
822
823extern "C-unwind" {
824    #[deprecated = "renamed to `CFMutableSet::add_value`"]
825    pub fn CFSetAddValue(the_set: Option<&CFMutableSet>, value: *const c_void);
826}
827
828extern "C-unwind" {
829    #[deprecated = "renamed to `CFMutableSet::replace_value`"]
830    pub fn CFSetReplaceValue(the_set: Option<&CFMutableSet>, value: *const c_void);
831}
832
833extern "C-unwind" {
834    #[deprecated = "renamed to `CFMutableSet::set_value`"]
835    pub fn CFSetSetValue(the_set: Option<&CFMutableSet>, value: *const c_void);
836}
837
838extern "C-unwind" {
839    #[deprecated = "renamed to `CFMutableSet::remove_value`"]
840    pub fn CFSetRemoveValue(the_set: Option<&CFMutableSet>, value: *const c_void);
841}
842
843#[deprecated = "renamed to `CFMutableSet::remove_all_values`"]
844#[inline]
845pub extern "C-unwind" fn CFSetRemoveAllValues(the_set: Option<&CFMutableSet>) {
846    extern "C-unwind" {
847        fn CFSetRemoveAllValues(the_set: Option<&CFMutableSet>);
848    }
849    unsafe { CFSetRemoveAllValues(the_set) }
850}