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 
111 - init;
112 
120 - initWithDictionary: (OFDictionary*)dictionary;
121 
130 - initWithObject: (id)object
131  forKey: (id)key;
132 
141 - initWithObjects: (OFArray*)objects
142  forKeys: (OFArray*)keys;
143 
153 - initWithObjects: (id const*)objects
154  forKeys: (id const*)keys
155  count: (size_t)count;
156 
164 - initWithKeysAndObjects: (id)firstKey, ... OF_SENTINEL;
165 
174 - initWithKey: (id)firstKey
175  arguments: (va_list)arguments;
176 
186 - (id)objectForKey: (id)key;
187 - (id)objectForKeyedSubscript: (id)key;
188 
197 - (BOOL)containsObjectIdenticalTo: (id)object;
198 
204 - (OFArray*)allKeys;
205 
211 - (OFArray*)allObjects;
212 
219 
220 #ifdef OF_HAVE_BLOCKS
221 
226 - (void)enumerateKeysAndObjectsUsingBlock:
227  (of_dictionary_enumeration_block_t)block;
228 
236 - (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block;
237 
246 - (OFDictionary*)filteredDictionaryUsingBlock:
247  (of_dictionary_filter_block_t)block;
248 #endif
249 @end
250 
251 #import "OFMutableDictionary.h"
252 
253 #ifndef NSINTEGER_DEFINED
254 /* Required for dictionary literals to work */
255 @compatibility_alias NSDictionary OFDictionary;
256 #endif