core_foundation_sys/
dictionary.rs1use std::os::raw::c_void;
11
12use crate::base::{Boolean, CFAllocatorRef, CFHashCode, CFIndex, CFTypeID};
13use crate::string::CFStringRef;
14
15pub type CFDictionaryApplierFunction =
16 extern "C" fn(key: *const c_void, value: *const c_void, context: *mut c_void);
17
18pub type CFDictionaryRetainCallBack =
19 extern "C" fn(allocator: CFAllocatorRef, value: *const c_void) -> *const c_void;
20pub type CFDictionaryReleaseCallBack =
21 extern "C" fn(allocator: CFAllocatorRef, value: *const c_void);
22pub type CFDictionaryCopyDescriptionCallBack = extern "C" fn(value: *const c_void) -> CFStringRef;
23pub type CFDictionaryEqualCallBack =
24 extern "C" fn(value1: *const c_void, value2: *const c_void) -> Boolean;
25pub type CFDictionaryHashCallBack = extern "C" fn(value: *const c_void) -> CFHashCode;
26
27#[repr(C)]
28#[derive(Clone, Copy)]
29pub struct CFDictionaryKeyCallBacks {
30 pub version: CFIndex,
31 pub retain: CFDictionaryRetainCallBack,
32 pub release: CFDictionaryReleaseCallBack,
33 pub copyDescription: CFDictionaryCopyDescriptionCallBack,
34 pub equal: CFDictionaryEqualCallBack,
35 pub hash: CFDictionaryHashCallBack,
36}
37
38#[repr(C)]
39#[derive(Clone, Copy)]
40pub struct CFDictionaryValueCallBacks {
41 pub version: CFIndex,
42 pub retain: CFDictionaryRetainCallBack,
43 pub release: CFDictionaryReleaseCallBack,
44 pub copyDescription: CFDictionaryCopyDescriptionCallBack,
45 pub equal: CFDictionaryEqualCallBack,
46}
47
48#[repr(C)]
49pub struct __CFDictionary(c_void);
50
51pub type CFDictionaryRef = *const __CFDictionary;
52pub type CFMutableDictionaryRef = *mut __CFDictionary;
53
54extern "C" {
55 pub static kCFTypeDictionaryKeyCallBacks: CFDictionaryKeyCallBacks;
60 pub static kCFCopyStringDictionaryKeyCallBacks: CFDictionaryKeyCallBacks;
61 pub static kCFTypeDictionaryValueCallBacks: CFDictionaryValueCallBacks;
62
63 pub fn CFDictionaryCreate(
66 allocator: CFAllocatorRef,
67 keys: *const *const c_void,
68 values: *const *const c_void,
69 numValues: CFIndex,
70 keyCallBacks: *const CFDictionaryKeyCallBacks,
71 valueCallBacks: *const CFDictionaryValueCallBacks,
72 ) -> CFDictionaryRef;
73 pub fn CFDictionaryCreateCopy(
74 allocator: CFAllocatorRef,
75 theDict: CFDictionaryRef,
76 ) -> CFDictionaryRef;
77
78 pub fn CFDictionaryContainsKey(theDict: CFDictionaryRef, key: *const c_void) -> Boolean;
80 pub fn CFDictionaryContainsValue(theDict: CFDictionaryRef, value: *const c_void) -> Boolean;
81 pub fn CFDictionaryGetCount(theDict: CFDictionaryRef) -> CFIndex;
82 pub fn CFDictionaryGetCountOfKey(theDict: CFDictionaryRef, key: *const c_void) -> CFIndex;
83 pub fn CFDictionaryGetCountOfValue(heDict: CFDictionaryRef, value: *const c_void) -> CFIndex;
84 pub fn CFDictionaryGetKeysAndValues(
85 theDict: CFDictionaryRef,
86 keys: *mut *const c_void,
87 values: *mut *const c_void,
88 );
89 pub fn CFDictionaryGetValue(theDict: CFDictionaryRef, key: *const c_void) -> *const c_void;
90 pub fn CFDictionaryGetValueIfPresent(
91 theDict: CFDictionaryRef,
92 key: *const c_void,
93 value: *mut *const c_void,
94 ) -> Boolean;
95
96 pub fn CFDictionaryApplyFunction(
98 theDict: CFDictionaryRef,
99 applier: CFDictionaryApplierFunction,
100 context: *mut c_void,
101 );
102
103 pub fn CFDictionaryGetTypeID() -> CFTypeID;
105
106 pub fn CFDictionaryCreateMutable(
109 allocator: CFAllocatorRef,
110 capacity: CFIndex,
111 keyCallbacks: *const CFDictionaryKeyCallBacks,
112 valueCallbacks: *const CFDictionaryValueCallBacks,
113 ) -> CFMutableDictionaryRef;
114 pub fn CFDictionaryCreateMutableCopy(
115 allocator: CFAllocatorRef,
116 capacity: CFIndex,
117 theDict: CFDictionaryRef,
118 ) -> CFMutableDictionaryRef;
119
120 pub fn CFDictionaryAddValue(
122 theDict: CFMutableDictionaryRef,
123 key: *const c_void,
124 value: *const c_void,
125 );
126 pub fn CFDictionaryRemoveAllValues(theDict: CFMutableDictionaryRef);
127 pub fn CFDictionaryRemoveValue(theDict: CFMutableDictionaryRef, key: *const c_void);
128 pub fn CFDictionaryReplaceValue(
129 theDict: CFMutableDictionaryRef,
130 key: *const c_void,
131 value: *const c_void,
132 );
133 pub fn CFDictionarySetValue(
134 theDict: CFMutableDictionaryRef,
135 key: *const c_void,
136 value: *const c_void,
137 );
138
139}