| 1 |
/* CFDictionary.h |
| 2 |
|
| 3 |
Copyright (C) 2010 Free Software Foundation, Inc. |
| 4 |
|
| 5 |
Written by: Stefan Bidigaray |
| 6 |
Date: January, 2010 |
| 7 |
|
| 8 |
This file is part of the GNUstep CoreBase Library. |
| 9 |
|
| 10 |
This library is free software; you can redistribute it and/or |
| 11 |
modify it under the terms of the GNU Lesser General Public |
| 12 |
License as published by the Free Software Foundation; either |
| 13 |
version 2.1 of the License, or (at your option) any later version. |
| 14 |
|
| 15 |
This library is distributed in the hope that it will be useful, |
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 |
Lesser General Public License for more details. |
| 19 |
|
| 20 |
You should have received a copy of the GNU Lesser General Public |
| 21 |
License along with this library; see the file COPYING.LIB. |
| 22 |
If not, see <http://www.gnu.org/licenses/> or write to the |
| 23 |
Free Software Foundation, 51 Franklin Street, Fifth Floor, |
| 24 |
Boston, MA 02110-1301, USA. |
| 25 |
*/ |
| 26 |
|
| 27 |
#ifndef __COREFOUNDATION_CFDICTIONARY_H__ |
| 28 |
#define __COREFOUNDATION_CFDICTIONARY_H__ 1 |
| 29 |
|
| 30 |
#include "CFBase.h" |
| 31 |
|
| 32 |
CF_EXTERN_C_BEGIN |
| 33 |
/** \ingroup CFDictionaryRef */ |
| 34 |
typedef const struct __CFDictionary *CFDictionaryRef; |
| 35 |
/** \ingroup CFMutableDictionaryRef */ |
| 36 |
typedef struct __CFDictionary *CFMutableDictionaryRef; |
| 37 |
|
| 38 |
/** \defgroup CFDictionaryRef CFDictionary Reference |
| 39 |
\{ |
| 40 |
*/ |
| 41 |
typedef void (*CFDictionaryApplierFunction) (const void *key, |
| 42 |
const void *value, void *context); |
| 43 |
|
| 44 |
typedef CFStringRef (*CFDictionaryCopyDescriptionCallBack) (const void *value); |
| 45 |
typedef Boolean (*CFDictionaryEqualCallBack) (const void *value1, |
| 46 |
const void *value2); |
| 47 |
typedef CFHashCode (*CFDictionaryHashCallBack) (const void *value); |
| 48 |
typedef void (*CFDictionaryReleaseCallBack) (CFAllocatorRef allocator, |
| 49 |
const void *value); |
| 50 |
typedef const void *(*CFDictionaryRetainCallBack) (CFAllocatorRef allocator, |
| 51 |
const void *value); |
| 52 |
|
| 53 |
typedef struct _CFDictionaryKeyCallBacks CFDictionaryKeyCallBacks; |
| 54 |
struct _CFDictionaryKeyCallBacks |
| 55 |
{ |
| 56 |
CFIndex version; |
| 57 |
CFDictionaryRetainCallBack retain; |
| 58 |
CFDictionaryReleaseCallBack release; |
| 59 |
CFDictionaryCopyDescriptionCallBack copyDescription; |
| 60 |
CFDictionaryEqualCallBack equal; |
| 61 |
CFDictionaryHashCallBack hash; |
| 62 |
}; |
| 63 |
|
| 64 |
typedef struct _CFDictionaryValueCallBacks CFDictionaryValueCallBacks; |
| 65 |
struct _CFDictionaryValueCallBacks |
| 66 |
{ |
| 67 |
CFIndex version; |
| 68 |
CFDictionaryRetainCallBack retain; |
| 69 |
CFDictionaryReleaseCallBack release; |
| 70 |
CFDictionaryCopyDescriptionCallBack copyDescription; |
| 71 |
CFDictionaryEqualCallBack equal; |
| 72 |
}; |
| 73 |
|
| 74 |
CF_EXPORT const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks; |
| 75 |
CF_EXPORT const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; |
| 76 |
CF_EXPORT const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; |
| 77 |
|
| 78 |
/** \name Creating a dictionary |
| 79 |
\{ |
| 80 |
*/ |
| 81 |
CF_EXPORT CFDictionaryRef |
| 82 |
CFDictionaryCreate (CFAllocatorRef allocator, const void **keys, |
| 83 |
const void **values, CFIndex numValues, |
| 84 |
const CFDictionaryKeyCallBacks * keyCallBacks, |
| 85 |
const CFDictionaryValueCallBacks * valueCallBacks); |
| 86 |
|
| 87 |
CF_EXPORT CFDictionaryRef |
| 88 |
CFDictionaryCreateCopy (CFAllocatorRef allocator, CFDictionaryRef theDict); |
| 89 |
/** \} */ |
| 90 |
|
| 91 |
/** \name Examining a dictionary |
| 92 |
\{ |
| 93 |
*/ |
| 94 |
CF_EXPORT Boolean |
| 95 |
CFDictionaryContainsKey (CFDictionaryRef theDict, const void *key); |
| 96 |
|
| 97 |
CF_EXPORT Boolean |
| 98 |
CFDictionaryContainsValue (CFDictionaryRef theDict, const void *value); |
| 99 |
|
| 100 |
CF_EXPORT CFIndex CFDictionaryGetCount (CFDictionaryRef theDict); |
| 101 |
|
| 102 |
CF_EXPORT CFIndex |
| 103 |
CFDictionaryGetCountOfKey (CFDictionaryRef theDict, const void *key); |
| 104 |
|
| 105 |
CF_EXPORT CFIndex |
| 106 |
CFDictionaryGetCountOfValue (CFDictionaryRef theDict, const void *value); |
| 107 |
|
| 108 |
CF_EXPORT void |
| 109 |
CFDictionaryGetKeysAndValues (CFDictionaryRef theDict, const void **keys, |
| 110 |
const void **values); |
| 111 |
|
| 112 |
CF_EXPORT const void *CFDictionaryGetValue (CFDictionaryRef theDict, |
| 113 |
const void *key); |
| 114 |
|
| 115 |
CF_EXPORT Boolean |
| 116 |
CFDictionaryGetValueIfPresent (CFDictionaryRef theDict, const void *key, |
| 117 |
const void **value); |
| 118 |
/** \} */ |
| 119 |
|
| 120 |
/** \name Applying a funcation to a dictionary |
| 121 |
\{ |
| 122 |
*/ |
| 123 |
CF_EXPORT void |
| 124 |
CFDictionaryApplyFunction (CFDictionaryRef theDict, |
| 125 |
CFDictionaryApplierFunction applier, void *context); |
| 126 |
/** \} */ |
| 127 |
|
| 128 |
/** \name Getting the CFDictionary type ID |
| 129 |
\{ |
| 130 |
*/ |
| 131 |
CF_EXPORT CFTypeID CFDictionaryGetTypeID (void); |
| 132 |
/** \} */ |
| 133 |
/** \} */ |
| 134 |
|
| 135 |
/** \defgroup CFMutableDictionaryRef CFMutableDictionary Reference |
| 136 |
\{ |
| 137 |
*/ |
| 138 |
/** \name Creating a Mutable Dictionary |
| 139 |
\{ |
| 140 |
*/ |
| 141 |
CF_EXPORT CFMutableDictionaryRef |
| 142 |
CFDictionaryCreateMutable (CFAllocatorRef allocator, CFIndex capacity, |
| 143 |
const CFDictionaryKeyCallBacks * keyCallBacks, |
| 144 |
const CFDictionaryValueCallBacks * valueCallBacks); |
| 145 |
|
| 146 |
CF_EXPORT CFMutableDictionaryRef |
| 147 |
CFDictionaryCreateMutableCopy (CFAllocatorRef allocator, CFIndex capacity, |
| 148 |
CFDictionaryRef theDict); |
| 149 |
/** \} */ |
| 150 |
|
| 151 |
/** \name Modifying a Dictionary |
| 152 |
\{ |
| 153 |
*/ |
| 154 |
CF_EXPORT void |
| 155 |
CFDictionaryAddValue (CFMutableDictionaryRef theDict, const void *key, |
| 156 |
const void *value); |
| 157 |
|
| 158 |
CF_EXPORT void CFDictionaryRemoveAllValues (CFMutableDictionaryRef theDict); |
| 159 |
|
| 160 |
CF_EXPORT void |
| 161 |
CFDictionaryRemoveValue (CFMutableDictionaryRef theDict, const void *key); |
| 162 |
|
| 163 |
CF_EXPORT void |
| 164 |
CFDictionaryReplaceValue (CFMutableDictionaryRef theDict, const void *key, |
| 165 |
const void *value); |
| 166 |
|
| 167 |
CF_EXPORT void |
| 168 |
CFDictionarySetValue (CFMutableDictionaryRef theDict, const void *key, |
| 169 |
const void *value); |
| 170 |
/** \} */ |
| 171 |
/** \} */ |
| 172 |
|
| 173 |
CF_EXTERN_C_END |
| 174 |
#endif /* __COREFOUNDATION_CFDICTIONARY_H__ */ |