17 #ifndef __STDC_LIMIT_MACROS
18 # define __STDC_LIMIT_MACROS
20 #ifndef __STDC_CONSTANT_MACROS
21 # define __STDC_CONSTANT_MACROS
27 #import "OFCollection.h"
28 #import "OFEnumerator.h"
29 #import "OFSerialization.h"
30 #import "OFJSONRepresentation.h"
31 #import "OFMessagePackRepresentation.h"
33 OF_ASSUME_NONNULL_BEGIN
35 @class OFArray OF_GENERIC(ObjectType);
38 typedef void (^of_dictionary_enumeration_block_t)(
id key,
id object,
40 typedef bool (^of_dictionary_filter_block_t)(
id key,
id object);
41 typedef id OF_NONNULL (^of_dictionary_map_block_t)(
id key,
id object);
54 #ifdef OF_HAVE_GENERICS
59 # define ObjectType id
78 + (instancetype)dictionaryWithDictionary:
79 (OFDictionary OF_GENERIC(KeyType, ObjectType)*)
dictionary;
88 + (instancetype)dictionaryWithObject: (ObjectType)object
99 dictionaryWithObjects: (OFArray OF_GENERIC(ObjectType)*)objects
100 forKeys: (OFArray OF_GENERIC(KeyType)*)keys;
111 dictionaryWithObjects: (ObjectType const OF_NONNULL *OF_NONNULL)objects
112 forKeys: (KeyType const OF_NONNULL *OF_NONNULL)keys
121 + (instancetype)dictionaryWithKeysAndObjects: (KeyType)firstKey, ...
131 - initWithDictionary: (OFDictionary OF_GENERIC(KeyType, ObjectType)*)
dictionary;
141 - initWithObject: (ObjectType)object
142 forKey: (KeyType)key;
152 - initWithObjects: (OFArray OF_GENERIC(ObjectType)*)objects
153 forKeys: (OFArray OF_GENERIC(KeyType)*)keys;
164 - initWithObjects: (ObjectType const OF_NONNULL *OF_NONNULL)objects
165 forKeys: (KeyType const OF_NONNULL *OF_NONNULL)keys
175 - initWithKeysAndObjects: (KeyType)firstKey, ... OF_SENTINEL;
185 - initWithKey: (KeyType)firstKey
186 arguments: (va_list)arguments;
197 - (nullable ObjectType)objectForKey: (KeyType)key;
198 - (nullable ObjectType)objectForKeyedSubscript: (KeyType)key;
207 - (bool)containsObject: (nullable ObjectType)object;
217 - (bool)containsObjectIdenticalTo: (nullable ObjectType)object;
224 - (OFArray OF_GENERIC(KeyType)*)
allKeys;
231 - (OFArray OF_GENERIC(ObjectType)*)
allObjects;
247 #ifdef OF_HAVE_BLOCKS
253 - (void)enumerateKeysAndObjectsUsingBlock:
254 (of_dictionary_enumeration_block_t)block;
263 - (OFDictionary OF_GENERIC(KeyType, id)*)mappedDictionaryUsingBlock:
264 (of_dictionary_map_block_t)block;
274 - (OFDictionary OF_GENERIC(KeyType, ObjectType)*)filteredDictionaryUsingBlock:
275 (of_dictionary_filter_block_t)block;
278 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
283 OF_ASSUME_NONNULL_END
287 #ifndef NSINTEGER_DEFINED
A protocol for serializing objects.
Definition: OFSerialization.h:30
An abstract class for storing objects in an array.
Definition: OFArray.h:95
instancetype dictionary()
Creates a new OFDictionary.
Definition: OFDictionary.m:144
The root class for all other classes inside ObjFW.
Definition: OFObject.h:364
A protocol implemented by classes that support encoding to a JSON representation. ...
Definition: OFJSONRepresentation.h:38
size_t count()
Returns the number of objects in the collection.
OFEnumerator OF_GENERIC(KeyType keyEnumerator()
Returns an OFEnumerator to enumerate through the dictionary's keys.
Definition: OFDictionary.m:415
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:61
A protocol with methods common for all collections.
Definition: OFCollection.h:26
A protocol implemented by classes that support encoding to a MessagePack representation.
Definition: OFMessagePackRepresentation.h:30
A protocol for the creation of mutable copies.
Definition: OFObject.h:917
A protocol for the creation of copies.
Definition: OFObject.h:896
OFArray OF_GENERIC(ObjectType allObjects()
Returns an array of all objects.
Definition: OFDictionary.m:398
OFEnumerator OF_GENERIC(ObjectType objectEnumerator()
Returns an OFEnumerator to enumerate through the dictionary's objects.
Definition: OFDictionary.m:420
OFArray OF_GENERIC(KeyType allKeys()
Returns an array of all keys.
Definition: OFDictionary.m:381