ObjFW
 All Classes Functions Variables
OFDictionary.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012
3  * Jonathan Schleifer <js@webkeks.org>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #ifndef __STDC_LIMIT_MACROS
18 # define __STDC_LIMIT_MACROS
19 #endif
20 #ifndef __STDC_CONSTANT_MACROS
21 # define __STDC_CONSTANT_MACROS
22 #endif
23 
24 #include <stdarg.h>
25 
26 #import "OFObject.h"
27 #import "OFCollection.h"
28 #import "OFEnumerator.h"
29 #import "OFSerialization.h"
30 #import "OFJSONRepresentation.h"
31 
32 @class OFArray;
33 
34 #ifdef OF_HAVE_BLOCKS
35 typedef void (^of_dictionary_enumeration_block_t)(id key, id object,
36  BOOL *stop);
37 typedef BOOL (^of_dictionary_filter_block_t)(id key, id object);
38 typedef id (^of_dictionary_map_block_t)(id key, id object);
39 #endif
40 
56 + (instancetype)dictionary;
57 
64 + (instancetype)dictionaryWithDictionary: (OFDictionary*)dictionary;
65 
73 + (instancetype)dictionaryWithObject: (id)object
74  forKey: (id)key;
75 
83 + (instancetype)dictionaryWithObjects: (OFArray*)objects
84  forKeys: (OFArray*)keys;
85 
94 + (instancetype)dictionaryWithObjects: (id const*)objects
95  forKeys: (id const*)keys
96  count: (size_t)count;
97 
104 + (instancetype)dictionaryWithKeysAndObjects: (id)firstKey, ... OF_SENTINEL;
105 
113 - initWithDictionary: (OFDictionary*)dictionary;
114 
123 - initWithObject: (id)object
124  forKey: (id)key;
125 
134 - initWithObjects: (OFArray*)objects
135  forKeys: (OFArray*)keys;
136 
146 - initWithObjects: (id const*)objects
147  forKeys: (id const*)keys
148  count: (size_t)count;
149 
157 - initWithKeysAndObjects: (id)firstKey, ... OF_SENTINEL;
158 
167 - initWithKey: (id)firstKey
168  arguments: (va_list)arguments;
169 
179 - (id)objectForKey: (id)key;
180 - (id)objectForKeyedSubscript: (id)key;
181 
190 - (BOOL)containsObjectIdenticalTo: (id)object;
191 
197 - (OFArray*)allKeys;
198 
204 - (OFArray*)allObjects;
205 
212 
213 #ifdef OF_HAVE_BLOCKS
214 
219 - (void)enumerateKeysAndObjectsUsingBlock:
220  (of_dictionary_enumeration_block_t)block;
221 
229 - (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block;
230 
239 - (OFDictionary*)filteredDictionaryUsingBlock:
240  (of_dictionary_filter_block_t)block;
241 #endif
242 @end
243 
244 #import "OFMutableDictionary.h"
245 
246 #ifndef NSINTEGER_DEFINED
247 /* Required for dictionary literals to work */
248 @compatibility_alias NSDictionary OFDictionary;
249 #endif