summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc-obj-c++-shared/GNUStep/CoreFoundation/CFDictionary.h
blob: adc0dd8c4b0e09a13638bdb5a613fd3874a2ac87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/* CFDictionary.h

   Copyright (C) 2010 Free Software Foundation, Inc.

   Written by: Stefan Bidigaray
   Date: January, 2010

   This file is part of the GNUstep CoreBase Library.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; see the file COPYING.LIB.
   If not, see <http://www.gnu.org/licenses/> or write to the 
   Free Software Foundation, 51 Franklin Street, Fifth Floor, 
   Boston, MA 02110-1301, USA.
*/

#ifndef __COREFOUNDATION_CFDICTIONARY_H__
#define __COREFOUNDATION_CFDICTIONARY_H__ 1

#include "CFBase.h"

CF_EXTERN_C_BEGIN
/** \ingroup CFDictionaryRef */
typedef const struct __CFDictionary *CFDictionaryRef;
/** \ingroup CFMutableDictionaryRef */
typedef struct __CFDictionary *CFMutableDictionaryRef;

/** \defgroup CFDictionaryRef CFDictionary Reference
    \{
 */
typedef void (*CFDictionaryApplierFunction) (const void *key,
                                             const void *value, void *context);

typedef CFStringRef (*CFDictionaryCopyDescriptionCallBack) (const void *value);
typedef Boolean (*CFDictionaryEqualCallBack) (const void *value1,
                                              const void *value2);
typedef CFHashCode (*CFDictionaryHashCallBack) (const void *value);
typedef void (*CFDictionaryReleaseCallBack) (CFAllocatorRef allocator,
                                             const void *value);
typedef const void *(*CFDictionaryRetainCallBack) (CFAllocatorRef allocator,
                                                   const void *value);

typedef struct _CFDictionaryKeyCallBacks CFDictionaryKeyCallBacks;
struct _CFDictionaryKeyCallBacks
{
  CFIndex version;
  CFDictionaryRetainCallBack retain;
  CFDictionaryReleaseCallBack release;
  CFDictionaryCopyDescriptionCallBack copyDescription;
  CFDictionaryEqualCallBack equal;
  CFDictionaryHashCallBack hash;
};

typedef struct _CFDictionaryValueCallBacks CFDictionaryValueCallBacks;
struct _CFDictionaryValueCallBacks
{
  CFIndex version;
  CFDictionaryRetainCallBack retain;
  CFDictionaryReleaseCallBack release;
  CFDictionaryCopyDescriptionCallBack copyDescription;
  CFDictionaryEqualCallBack equal;
};

CF_EXPORT const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks;
CF_EXPORT const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;
CF_EXPORT const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;

/** \name Creating a dictionary
    \{
 */
CF_EXPORT CFDictionaryRef
CFDictionaryCreate (CFAllocatorRef allocator, const void **keys,
                    const void **values, CFIndex numValues,
                    const CFDictionaryKeyCallBacks * keyCallBacks,
                    const CFDictionaryValueCallBacks * valueCallBacks);

CF_EXPORT CFDictionaryRef
CFDictionaryCreateCopy (CFAllocatorRef allocator, CFDictionaryRef theDict);
/** \} */

/** \name Examining a dictionary
    \{
 */
CF_EXPORT Boolean
CFDictionaryContainsKey (CFDictionaryRef theDict, const void *key);

CF_EXPORT Boolean
CFDictionaryContainsValue (CFDictionaryRef theDict, const void *value);

CF_EXPORT CFIndex CFDictionaryGetCount (CFDictionaryRef theDict);

CF_EXPORT CFIndex
CFDictionaryGetCountOfKey (CFDictionaryRef theDict, const void *key);

CF_EXPORT CFIndex
CFDictionaryGetCountOfValue (CFDictionaryRef theDict, const void *value);

CF_EXPORT void
CFDictionaryGetKeysAndValues (CFDictionaryRef theDict, const void **keys,
                              const void **values);

CF_EXPORT const void *CFDictionaryGetValue (CFDictionaryRef theDict,
                                            const void *key);

CF_EXPORT Boolean
CFDictionaryGetValueIfPresent (CFDictionaryRef theDict, const void *key,
                               const void **value);
/** \} */

/** \name Applying a funcation to a dictionary
    \{
 */
CF_EXPORT void
CFDictionaryApplyFunction (CFDictionaryRef theDict,
                           CFDictionaryApplierFunction applier, void *context);
/** \} */

/** \name Getting the CFDictionary type ID
    \{
 */
CF_EXPORT CFTypeID CFDictionaryGetTypeID (void);
/** \} */
/** \} */

/** \defgroup CFMutableDictionaryRef CFMutableDictionary Reference
    \{
 */
/** \name Creating a Mutable Dictionary
    \{
 */
CF_EXPORT CFMutableDictionaryRef
CFDictionaryCreateMutable (CFAllocatorRef allocator, CFIndex capacity,
                           const CFDictionaryKeyCallBacks * keyCallBacks,
                           const CFDictionaryValueCallBacks * valueCallBacks);

CF_EXPORT CFMutableDictionaryRef
CFDictionaryCreateMutableCopy (CFAllocatorRef allocator, CFIndex capacity,
                               CFDictionaryRef theDict);
/** \} */

/** \name Modifying a Dictionary
    \{
 */
CF_EXPORT void
CFDictionaryAddValue (CFMutableDictionaryRef theDict, const void *key,
                      const void *value);

CF_EXPORT void CFDictionaryRemoveAllValues (CFMutableDictionaryRef theDict);

CF_EXPORT void
CFDictionaryRemoveValue (CFMutableDictionaryRef theDict, const void *key);

CF_EXPORT void
CFDictionaryReplaceValue (CFMutableDictionaryRef theDict, const void *key,
                          const void *value);

CF_EXPORT void
CFDictionarySetValue (CFMutableDictionaryRef theDict, const void *key,
                      const void *value);
/** \} */
/** \} */

CF_EXTERN_C_END
#endif /* __COREFOUNDATION_CFDICTIONARY_H__ */