16 #ifndef __STDC_LIMIT_MACROS 17 # define __STDC_LIMIT_MACROS 19 #ifndef __STDC_CONSTANT_MACROS 20 # define __STDC_CONSTANT_MACROS 26 #import "OFCollection.h" 27 #import "OFEnumerator.h" 28 #import "OFJSONRepresentation.h" 29 #import "OFMessagePackRepresentation.h" 31 OF_ASSUME_NONNULL_BEGIN
33 @class OFArray OF_GENERIC(ObjectType);
44 typedef void (^OFDictionaryEnumerationBlock)(
id key,
id object,
bool *stop);
53 typedef bool (^OFDictionaryFilterBlock)(
id key,
id object);
62 typedef id _Nonnull (^OFDictionaryMapBlock)(
id key,
id object);
81 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) 83 # define ObjectType id 108 + (instancetype)dictionaryWithDictionary:
109 (
OFDictionary OF_GENERIC(KeyType, ObjectType) *)dictionary;
118 + (instancetype)dictionaryWithObject: (ObjectType)object forKey: (KeyType)key;
127 + (instancetype)dictionaryWithObjects: (
OFArray OF_GENERIC(ObjectType) *)objects
128 forKeys: (
OFArray OF_GENERIC(KeyType) *)keys;
139 dictionaryWithObjects: (ObjectType const _Nonnull *_Nonnull)objects
140 forKeys: (KeyType const _Nonnull *_Nonnull)keys
141 count: (
size_t)count;
149 + (instancetype)dictionaryWithKeysAndObjects: (KeyType)firstKey, ...
157 - (instancetype)
init OF_DESIGNATED_INITIALIZER;
166 - (instancetype)initWithDictionary:
167 (
OFDictionary OF_GENERIC(KeyType, ObjectType) *)dictionary;
177 - (instancetype)initWithObject: (ObjectType)object forKey: (KeyType)key;
187 - (instancetype)initWithObjects: (
OFArray OF_GENERIC(ObjectType) *)objects
188 forKeys: (
OFArray OF_GENERIC(KeyType) *)keys;
199 - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects
200 forKeys: (KeyType const _Nonnull *_Nonnull)keys
201 count: (
size_t)count OF_DESIGNATED_INITIALIZER;
210 - (instancetype)initWithKeysAndObjects: (KeyType)firstKey, ... OF_SENTINEL;
220 - (instancetype)initWithKey: (KeyType)firstKey arguments: (va_list)arguments;
232 - (nullable ObjectType)objectForKey: (KeyType)key;
233 - (nullable ObjectType)objectForKeyedSubscript: (KeyType)key;
246 - (nullable id)valueForKey: (
OFString *)key;
257 - (void)setValue: (nullable
id)value forKey: (
OFString *)key;
266 - (bool)containsObject: (ObjectType)object;
276 - (bool)containsObjectIdenticalTo: (ObjectType)object;
292 #ifdef OF_HAVE_BLOCKS 298 - (void)enumerateKeysAndObjectsUsingBlock: (OFDictionaryEnumerationBlock)block;
308 mappedDictionaryUsingBlock: (OFDictionaryMapBlock)block;
319 filteredDictionaryUsingBlock: (OFDictionaryFilterBlock)block;
321 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) 327 OF_ASSUME_NONNULL_END
331 #if !defined(NSINTEGER_DEFINED) && !__has_feature(modules) An abstract class for storing objects in an array.
Definition: OFArray.h:103
OFArray * allObjects
An array of all objects.
Definition: OFDictionary.h:93
instancetype dictionary()
Creates a new OFDictionary.
Definition: OFDictionary.m:136
The root class for all other classes inside ObjFW.
Definition: OFObject.h:686
A protocol implemented by classes that support encoding to a JSON representation. ...
Definition: OFJSONRepresentation.h:44
A class for handling strings.
Definition: OFString.h:134
OFEnumerator * keyEnumerator()
Returns an OFEnumerator to enumerate through the dictionary's keys.
Definition: OFDictionary.m:517
instancetype init()
Initializes an already allocated OFDictionary to be empty.
Definition: OFDictionary.m:181
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:78
A protocol with methods common for all collections.
A protocol implemented by classes that support encoding to a MessagePack representation.
Definition: OFMessagePackRepresentation.h:29
OFArray * allKeys
An array of all keys.
Definition: OFDictionary.h:88
A protocol for the creation of mutable copies.
Definition: OFObject.h:1367
A protocol for the creation of copies.
Definition: OFObject.h:1346
A class which provides methods to enumerate through collections.
Definition: OFEnumerator.h:99
OFEnumerator * objectEnumerator()
Returns an OFEnumerator to enumerate through the dictionary's objects.
Definition: OFDictionary.m:522