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 _Nonnull (^of_dictionary_map_block_t)(
id key,
id object);
57 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) 59 # define ObjectType id 74 + (instancetype)dictionaryWithDictionary:
75 (
OFDictionary OF_GENERIC(KeyType, ObjectType) *)dictionary;
84 + (instancetype)dictionaryWithObject: (ObjectType)object
95 dictionaryWithObjects: (
OFArray OF_GENERIC(ObjectType) *)objects
96 forKeys: (
OFArray OF_GENERIC(KeyType) *)keys;
107 dictionaryWithObjects: (ObjectType const _Nonnull *_Nonnull)objects
108 forKeys: (KeyType const _Nonnull *_Nonnull)keys
109 count: (
size_t)count;
117 + (instancetype)dictionaryWithKeysAndObjects: (KeyType)firstKey, ...
127 - initWithDictionary:
128 (
OFDictionary OF_GENERIC(KeyType, ObjectType) *)dictionary;
138 - initWithObject: (ObjectType)object
139 forKey: (KeyType)key;
149 - initWithObjects: (
OFArray OF_GENERIC(ObjectType) *)objects
150 forKeys: (
OFArray OF_GENERIC(KeyType) *)keys;
161 - initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects
162 forKeys: (KeyType const _Nonnull *_Nonnull)keys
163 count: (
size_t)count;
172 - initWithKeysAndObjects: (KeyType)firstKey, ... OF_SENTINEL;
182 - initWithKey: (KeyType)firstKey
183 arguments: (va_list)arguments;
195 - (nullable ObjectType)objectForKey: (KeyType)key;
196 - (nullable ObjectType)objectForKeyedSubscript: (KeyType)key;
210 - (nullable id)valueForKey: (
OFString *)key;
224 - (void)setValue: (
id)value
234 - (bool)containsObject: (ObjectType)object;
244 - (bool)containsObjectIdenticalTo: (ObjectType)object;
281 #ifdef OF_HAVE_BLOCKS 287 - (void)enumerateKeysAndObjectsUsingBlock:
288 (of_dictionary_enumeration_block_t)block;
297 - (
OFDictionary OF_GENERIC(KeyType, id) *)mappedDictionaryUsingBlock:
298 (of_dictionary_map_block_t)block;
308 - (
OFDictionary OF_GENERIC(KeyType, ObjectType) *)filteredDictionaryUsingBlock:
309 (of_dictionary_filter_block_t)block;
311 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) 317 OF_ASSUME_NONNULL_END
321 #if !defined(NSINTEGER_DEFINED) && !__has_feature(modules) OFString * stringByURLEncoding()
Creates a string by URL-encoding the contents of the dictionary.
Definition: OFDictionary.m:573
instancetype dictionary()
Creates a new OFDictionary.
Definition: OFDictionary.m:142
A protocol for the creation of mutable copies.
Definition: OFObject.h:935
OFArray * allObjects()
Returns an array of all objects.
Definition: OFDictionary.m:432
A class for handling strings.
Definition: OFString.h:114
A protocol implemented by classes that support encoding to a JSON representation. ...
Definition: OFJSONRepresentation.h:38
A class which provides methods to enumerate through collections.
Definition: OFEnumerator.h:44
A protocol with methods common for all collections.
A protocol implemented by classes that support encoding to a MessagePack representation.
Definition: OFMessagePackRepresentation.h:30
A protocol for the creation of copies.
Definition: OFObject.h:914
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:54
OFEnumerator * objectEnumerator()
Returns an OFEnumerator to enumerate through the dictionary's objects.
Definition: OFDictionary.m:454
The root class for all other classes inside ObjFW.
Definition: OFObject.h:379
OFEnumerator * keyEnumerator()
Returns an OFEnumerator to enumerate through the dictionary's keys.
Definition: OFDictionary.m:449
An abstract class for storing objects in an array.
Definition: OFArray.h:89
A protocol for serializing objects.
Definition: OFSerialization.h:30
OFArray * allKeys()
Returns an array of all keys.
Definition: OFDictionary.m:420