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 "OFSerialization.h"
29 #import "OFJSONRepresentation.h"
30 #import "OFMessagePackRepresentation.h"
32 OF_ASSUME_NONNULL_BEGIN
34 @class OFArray OF_GENERIC(ObjectType);
37 typedef void (^of_dictionary_enumeration_block_t)(
id key,
id object,
39 typedef bool (^of_dictionary_filter_block_t)(
id key,
id object);
40 typedef id _Nonnull (^of_dictionary_map_block_t)(
id key,
id object);
59 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
61 # define ObjectType id
91 + (instancetype)dictionaryWithDictionary:
92 (
OFDictionary OF_GENERIC(KeyType, ObjectType) *)dictionary;
101 + (instancetype)dictionaryWithObject: (ObjectType)object forKey: (KeyType)key;
111 dictionaryWithObjects: (
OFArray OF_GENERIC(ObjectType) *)objects
112 forKeys: (
OFArray OF_GENERIC(KeyType) *)keys;
123 dictionaryWithObjects: (ObjectType const _Nonnull *_Nonnull)objects
124 forKeys: (KeyType const _Nonnull *_Nonnull)keys
125 count: (
size_t)count;
133 + (instancetype)dictionaryWithKeysAndObjects: (KeyType)firstKey, ...
143 - (instancetype)initWithDictionary:
144 (
OFDictionary OF_GENERIC(KeyType, ObjectType) *)dictionary;
154 - (instancetype)initWithObject: (ObjectType)object forKey: (KeyType)key;
164 - (instancetype)initWithObjects: (
OFArray OF_GENERIC(ObjectType) *)objects
165 forKeys: (
OFArray OF_GENERIC(KeyType) *)keys;
176 - (instancetype)initWithObjects: (ObjectType const _Nonnull *_Nonnull)objects
177 forKeys: (KeyType const _Nonnull *_Nonnull)keys
178 count: (
size_t)count;
187 - (instancetype)initWithKeysAndObjects: (KeyType)firstKey, ... OF_SENTINEL;
197 - (instancetype)initWithKey: (KeyType)firstKey arguments: (va_list)arguments;
209 - (nullable ObjectType)objectForKey: (KeyType)key;
210 - (nullable ObjectType)objectForKeyedSubscript: (KeyType)key;
234 - (void)setValue: (nullable
id)value forKey: (
OFString *)key;
243 - (bool)containsObject: (ObjectType)object;
253 - (bool)containsObjectIdenticalTo: (ObjectType)object;
269 #ifdef OF_HAVE_BLOCKS
275 - (void)enumerateKeysAndObjectsUsingBlock:
276 (of_dictionary_enumeration_block_t)block;
285 - (
OFDictionary OF_GENERIC(KeyType,
id) *)mappedDictionaryUsingBlock:
286 (of_dictionary_map_block_t)block;
296 - (
OFDictionary OF_GENERIC(KeyType, ObjectType) *)filteredDictionaryUsingBlock:
297 (of_dictionary_filter_block_t)block;
299 #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN)
305 OF_ASSUME_NONNULL_END
309 #if !defined(NSINTEGER_DEFINED) && !__has_feature(modules)
struct objc_object * id
A pointer to any object.
Definition: ObjFWRT.h:90
An abstract class for storing objects in an array.
Definition: OFArray.h:92
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:58
OFArray * allObjects
An array of all objects.
Definition: OFDictionary.h:71
OFArray * allKeys
An array of all keys.
Definition: OFDictionary.h:66
instancetype dictionary()
Creates a new OFDictionary.
Definition: OFDictionary.m:218
OFEnumerator * keyEnumerator()
Returns an OFEnumerator to enumerate through the dictionary's keys.
Definition: OFDictionary.m:499
OFString * stringByURLEncoding
A URL-encoded string with the contents of the dictionary.
Definition: OFDictionary.h:76
OFEnumerator * objectEnumerator()
Returns an OFEnumerator to enumerate through the dictionary's objects.
Definition: OFDictionary.m:504
A class which provides methods to enumerate through collections.
Definition: OFEnumerator.h:101
The root class for all other classes inside ObjFW.
Definition: OFObject.h:520
A class for handling strings.
Definition: OFString.h:132
A protocol with methods common for all collections.
Definition: OFCollection.h:25
A protocol for the creation of copies.
Definition: OFObject.h:1187
A protocol implemented by classes that support encoding to a JSON representation.
Definition: OFJSONRepresentation.h:39
A protocol implemented by classes that support encoding to a MessagePack representation.
Definition: OFMessagePackRepresentation.h:29
A protocol for the creation of mutable copies.
Definition: OFObject.h:1208
A protocol for serializing objects.
Definition: OFSerialization.h:29