blob: a81165e815a3d43c07e32157a727b1102dd3dc36 [file] [log] [blame]
Brian Silverman9c614bc2016-02-15 20:20:02 -05001// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc. All rights reserved.
3// https://developers.google.com/protocol-buffers/
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions are
7// met:
8//
9// * Redistributions of source code must retain the above copyright
10// notice, this list of conditions and the following disclaimer.
11// * Redistributions in binary form must reproduce the above
12// copyright notice, this list of conditions and the following disclaimer
13// in the documentation and/or other materials provided with the
14// distribution.
15// * Neither the name of Google Inc. nor the names of its
16// contributors may be used to endorse or promote products derived from
17// this software without specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31#import <Foundation/Foundation.h>
32
33#import "GPBRuntimeTypes.h"
34
Austin Schuh40c16522018-10-28 20:27:54 -070035// Note on naming: for the classes holding numeric values, a more natural
36// naming of the method might be things like "-valueForKey:",
37// "-setValue:forKey:"; etc. But those selectors are also defined by Key Value
38// Coding (KVC) as categories on NSObject. So "overloading" the selectors with
39// other meanings can cause warnings (based on compiler settings), but more
40// importantly, some of those selector get called as KVC breaks up keypaths.
41// So if those selectors are used, using KVC will compile cleanly, but could
42// crash as it invokes those selectors with the wrong types of arguments.
Brian Silverman9c614bc2016-02-15 20:20:02 -050043
44NS_ASSUME_NONNULL_BEGIN
45
46//%PDDM-EXPAND DECLARE_DICTIONARIES()
47// This block of code is generated, do not edit it directly.
48
49#pragma mark - UInt32 -> UInt32
50
Austin Schuh40c16522018-10-28 20:27:54 -070051/**
52 * Class used for map fields of <uint32_t, uint32_t>
53 * values. This performs better than boxing into NSNumbers in NSDictionaries.
54 *
55 * @note This class is not meant to be subclassed.
56 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -050057@interface GPBUInt32UInt32Dictionary : NSObject <NSCopying>
58
Austin Schuh40c16522018-10-28 20:27:54 -070059/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -050060@property(nonatomic, readonly) NSUInteger count;
61
Austin Schuh40c16522018-10-28 20:27:54 -070062/**
63 * Initializes this dictionary, copying the given values and keys.
64 *
65 * @param values The values to be placed in this dictionary.
66 * @param keys The keys under which to store the values.
67 * @param count The number of elements to copy into the dictionary.
68 *
69 * @return A newly initialized dictionary with a copy of the values and keys.
70 **/
71- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
72 forKeys:(const uint32_t [__nullable])keys
73 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -050074
Austin Schuh40c16522018-10-28 20:27:54 -070075/**
76 * Initializes this dictionary, copying the entries from the given dictionary.
77 *
78 * @param dictionary Dictionary containing the entries to add to this dictionary.
79 *
80 * @return A newly initialized dictionary with the entries of the given dictionary.
81 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -050082- (instancetype)initWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -070083
84/**
85 * Initializes this dictionary with the requested capacity.
86 *
87 * @param numItems Number of items needed for this dictionary.
88 *
89 * @return A newly initialized dictionary with the requested capacity.
90 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -050091- (instancetype)initWithCapacity:(NSUInteger)numItems;
92
Austin Schuh40c16522018-10-28 20:27:54 -070093/**
94 * Gets the value for the given key.
95 *
96 * @param value Pointer into which the value will be set, if found.
97 * @param key Key under which the value is stored, if present.
98 *
99 * @return YES if the key was found and the value was copied, NO otherwise.
100 **/
101- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500102
Austin Schuh40c16522018-10-28 20:27:54 -0700103/**
104 * Enumerates the keys and values on this dictionary with the given block.
105 *
106 * @param block The block to enumerate with.
107 * **key**: The key for the current entry.
108 * **value**: The value for the current entry
109 * **stop**: A pointer to a boolean that when set stops the enumeration.
110 **/
111- (void)enumerateKeysAndUInt32sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -0500112 (void (^)(uint32_t key, uint32_t value, BOOL *stop))block;
113
Austin Schuh40c16522018-10-28 20:27:54 -0700114/**
115 * Adds the keys and values from another dictionary.
116 *
117 * @param otherDictionary Dictionary containing entries to be added to this
118 * dictionary.
119 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500120- (void)addEntriesFromDictionary:(GPBUInt32UInt32Dictionary *)otherDictionary;
121
Austin Schuh40c16522018-10-28 20:27:54 -0700122/**
123 * Sets the value for the given key.
124 *
125 * @param value The value to set.
126 * @param key The key under which to store the value.
127 **/
128- (void)setUInt32:(uint32_t)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500129
Austin Schuh40c16522018-10-28 20:27:54 -0700130/**
131 * Removes the entry for the given key.
132 *
133 * @param aKey Key to be removed from this dictionary.
134 **/
135- (void)removeUInt32ForKey:(uint32_t)aKey;
136
137/**
138 * Removes all entries in this dictionary.
139 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500140- (void)removeAll;
141
142@end
143
144#pragma mark - UInt32 -> Int32
145
Austin Schuh40c16522018-10-28 20:27:54 -0700146/**
147 * Class used for map fields of <uint32_t, int32_t>
148 * values. This performs better than boxing into NSNumbers in NSDictionaries.
149 *
150 * @note This class is not meant to be subclassed.
151 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500152@interface GPBUInt32Int32Dictionary : NSObject <NSCopying>
153
Austin Schuh40c16522018-10-28 20:27:54 -0700154/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -0500155@property(nonatomic, readonly) NSUInteger count;
156
Austin Schuh40c16522018-10-28 20:27:54 -0700157/**
158 * Initializes this dictionary, copying the given values and keys.
159 *
160 * @param values The values to be placed in this dictionary.
161 * @param keys The keys under which to store the values.
162 * @param count The number of elements to copy into the dictionary.
163 *
164 * @return A newly initialized dictionary with a copy of the values and keys.
165 **/
166- (instancetype)initWithInt32s:(const int32_t [__nullable])values
167 forKeys:(const uint32_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -0500168 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -0700169
170/**
171 * Initializes this dictionary, copying the entries from the given dictionary.
172 *
173 * @param dictionary Dictionary containing the entries to add to this dictionary.
174 *
175 * @return A newly initialized dictionary with the entries of the given dictionary.
176 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500177- (instancetype)initWithDictionary:(GPBUInt32Int32Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -0700178
179/**
180 * Initializes this dictionary with the requested capacity.
181 *
182 * @param numItems Number of items needed for this dictionary.
183 *
184 * @return A newly initialized dictionary with the requested capacity.
185 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500186- (instancetype)initWithCapacity:(NSUInteger)numItems;
187
Austin Schuh40c16522018-10-28 20:27:54 -0700188/**
189 * Gets the value for the given key.
190 *
191 * @param value Pointer into which the value will be set, if found.
192 * @param key Key under which the value is stored, if present.
193 *
194 * @return YES if the key was found and the value was copied, NO otherwise.
195 **/
196- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500197
Austin Schuh40c16522018-10-28 20:27:54 -0700198/**
199 * Enumerates the keys and values on this dictionary with the given block.
200 *
201 * @param block The block to enumerate with.
202 * **key**: The key for the current entry.
203 * **value**: The value for the current entry
204 * **stop**: A pointer to a boolean that when set stops the enumeration.
205 **/
206- (void)enumerateKeysAndInt32sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -0500207 (void (^)(uint32_t key, int32_t value, BOOL *stop))block;
208
Austin Schuh40c16522018-10-28 20:27:54 -0700209/**
210 * Adds the keys and values from another dictionary.
211 *
212 * @param otherDictionary Dictionary containing entries to be added to this
213 * dictionary.
214 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500215- (void)addEntriesFromDictionary:(GPBUInt32Int32Dictionary *)otherDictionary;
216
Austin Schuh40c16522018-10-28 20:27:54 -0700217/**
218 * Sets the value for the given key.
219 *
220 * @param value The value to set.
221 * @param key The key under which to store the value.
222 **/
223- (void)setInt32:(int32_t)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500224
Austin Schuh40c16522018-10-28 20:27:54 -0700225/**
226 * Removes the entry for the given key.
227 *
228 * @param aKey Key to be removed from this dictionary.
229 **/
230- (void)removeInt32ForKey:(uint32_t)aKey;
231
232/**
233 * Removes all entries in this dictionary.
234 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500235- (void)removeAll;
236
237@end
238
239#pragma mark - UInt32 -> UInt64
240
Austin Schuh40c16522018-10-28 20:27:54 -0700241/**
242 * Class used for map fields of <uint32_t, uint64_t>
243 * values. This performs better than boxing into NSNumbers in NSDictionaries.
244 *
245 * @note This class is not meant to be subclassed.
246 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500247@interface GPBUInt32UInt64Dictionary : NSObject <NSCopying>
248
Austin Schuh40c16522018-10-28 20:27:54 -0700249/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -0500250@property(nonatomic, readonly) NSUInteger count;
251
Austin Schuh40c16522018-10-28 20:27:54 -0700252/**
253 * Initializes this dictionary, copying the given values and keys.
254 *
255 * @param values The values to be placed in this dictionary.
256 * @param keys The keys under which to store the values.
257 * @param count The number of elements to copy into the dictionary.
258 *
259 * @return A newly initialized dictionary with a copy of the values and keys.
260 **/
261- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
262 forKeys:(const uint32_t [__nullable])keys
263 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500264
Austin Schuh40c16522018-10-28 20:27:54 -0700265/**
266 * Initializes this dictionary, copying the entries from the given dictionary.
267 *
268 * @param dictionary Dictionary containing the entries to add to this dictionary.
269 *
270 * @return A newly initialized dictionary with the entries of the given dictionary.
271 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500272- (instancetype)initWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -0700273
274/**
275 * Initializes this dictionary with the requested capacity.
276 *
277 * @param numItems Number of items needed for this dictionary.
278 *
279 * @return A newly initialized dictionary with the requested capacity.
280 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500281- (instancetype)initWithCapacity:(NSUInteger)numItems;
282
Austin Schuh40c16522018-10-28 20:27:54 -0700283/**
284 * Gets the value for the given key.
285 *
286 * @param value Pointer into which the value will be set, if found.
287 * @param key Key under which the value is stored, if present.
288 *
289 * @return YES if the key was found and the value was copied, NO otherwise.
290 **/
291- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500292
Austin Schuh40c16522018-10-28 20:27:54 -0700293/**
294 * Enumerates the keys and values on this dictionary with the given block.
295 *
296 * @param block The block to enumerate with.
297 * **key**: The key for the current entry.
298 * **value**: The value for the current entry
299 * **stop**: A pointer to a boolean that when set stops the enumeration.
300 **/
301- (void)enumerateKeysAndUInt64sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -0500302 (void (^)(uint32_t key, uint64_t value, BOOL *stop))block;
303
Austin Schuh40c16522018-10-28 20:27:54 -0700304/**
305 * Adds the keys and values from another dictionary.
306 *
307 * @param otherDictionary Dictionary containing entries to be added to this
308 * dictionary.
309 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500310- (void)addEntriesFromDictionary:(GPBUInt32UInt64Dictionary *)otherDictionary;
311
Austin Schuh40c16522018-10-28 20:27:54 -0700312/**
313 * Sets the value for the given key.
314 *
315 * @param value The value to set.
316 * @param key The key under which to store the value.
317 **/
318- (void)setUInt64:(uint64_t)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500319
Austin Schuh40c16522018-10-28 20:27:54 -0700320/**
321 * Removes the entry for the given key.
322 *
323 * @param aKey Key to be removed from this dictionary.
324 **/
325- (void)removeUInt64ForKey:(uint32_t)aKey;
326
327/**
328 * Removes all entries in this dictionary.
329 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500330- (void)removeAll;
331
332@end
333
334#pragma mark - UInt32 -> Int64
335
Austin Schuh40c16522018-10-28 20:27:54 -0700336/**
337 * Class used for map fields of <uint32_t, int64_t>
338 * values. This performs better than boxing into NSNumbers in NSDictionaries.
339 *
340 * @note This class is not meant to be subclassed.
341 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500342@interface GPBUInt32Int64Dictionary : NSObject <NSCopying>
343
Austin Schuh40c16522018-10-28 20:27:54 -0700344/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -0500345@property(nonatomic, readonly) NSUInteger count;
346
Austin Schuh40c16522018-10-28 20:27:54 -0700347/**
348 * Initializes this dictionary, copying the given values and keys.
349 *
350 * @param values The values to be placed in this dictionary.
351 * @param keys The keys under which to store the values.
352 * @param count The number of elements to copy into the dictionary.
353 *
354 * @return A newly initialized dictionary with a copy of the values and keys.
355 **/
356- (instancetype)initWithInt64s:(const int64_t [__nullable])values
357 forKeys:(const uint32_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -0500358 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -0700359
360/**
361 * Initializes this dictionary, copying the entries from the given dictionary.
362 *
363 * @param dictionary Dictionary containing the entries to add to this dictionary.
364 *
365 * @return A newly initialized dictionary with the entries of the given dictionary.
366 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500367- (instancetype)initWithDictionary:(GPBUInt32Int64Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -0700368
369/**
370 * Initializes this dictionary with the requested capacity.
371 *
372 * @param numItems Number of items needed for this dictionary.
373 *
374 * @return A newly initialized dictionary with the requested capacity.
375 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500376- (instancetype)initWithCapacity:(NSUInteger)numItems;
377
Austin Schuh40c16522018-10-28 20:27:54 -0700378/**
379 * Gets the value for the given key.
380 *
381 * @param value Pointer into which the value will be set, if found.
382 * @param key Key under which the value is stored, if present.
383 *
384 * @return YES if the key was found and the value was copied, NO otherwise.
385 **/
386- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500387
Austin Schuh40c16522018-10-28 20:27:54 -0700388/**
389 * Enumerates the keys and values on this dictionary with the given block.
390 *
391 * @param block The block to enumerate with.
392 * **key**: The key for the current entry.
393 * **value**: The value for the current entry
394 * **stop**: A pointer to a boolean that when set stops the enumeration.
395 **/
396- (void)enumerateKeysAndInt64sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -0500397 (void (^)(uint32_t key, int64_t value, BOOL *stop))block;
398
Austin Schuh40c16522018-10-28 20:27:54 -0700399/**
400 * Adds the keys and values from another dictionary.
401 *
402 * @param otherDictionary Dictionary containing entries to be added to this
403 * dictionary.
404 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500405- (void)addEntriesFromDictionary:(GPBUInt32Int64Dictionary *)otherDictionary;
406
Austin Schuh40c16522018-10-28 20:27:54 -0700407/**
408 * Sets the value for the given key.
409 *
410 * @param value The value to set.
411 * @param key The key under which to store the value.
412 **/
413- (void)setInt64:(int64_t)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500414
Austin Schuh40c16522018-10-28 20:27:54 -0700415/**
416 * Removes the entry for the given key.
417 *
418 * @param aKey Key to be removed from this dictionary.
419 **/
420- (void)removeInt64ForKey:(uint32_t)aKey;
421
422/**
423 * Removes all entries in this dictionary.
424 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500425- (void)removeAll;
426
427@end
428
429#pragma mark - UInt32 -> Bool
430
Austin Schuh40c16522018-10-28 20:27:54 -0700431/**
432 * Class used for map fields of <uint32_t, BOOL>
433 * values. This performs better than boxing into NSNumbers in NSDictionaries.
434 *
435 * @note This class is not meant to be subclassed.
436 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500437@interface GPBUInt32BoolDictionary : NSObject <NSCopying>
438
Austin Schuh40c16522018-10-28 20:27:54 -0700439/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -0500440@property(nonatomic, readonly) NSUInteger count;
441
Austin Schuh40c16522018-10-28 20:27:54 -0700442/**
443 * Initializes this dictionary, copying the given values and keys.
444 *
445 * @param values The values to be placed in this dictionary.
446 * @param keys The keys under which to store the values.
447 * @param count The number of elements to copy into the dictionary.
448 *
449 * @return A newly initialized dictionary with a copy of the values and keys.
450 **/
451- (instancetype)initWithBools:(const BOOL [__nullable])values
452 forKeys:(const uint32_t [__nullable])keys
453 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500454
Austin Schuh40c16522018-10-28 20:27:54 -0700455/**
456 * Initializes this dictionary, copying the entries from the given dictionary.
457 *
458 * @param dictionary Dictionary containing the entries to add to this dictionary.
459 *
460 * @return A newly initialized dictionary with the entries of the given dictionary.
461 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500462- (instancetype)initWithDictionary:(GPBUInt32BoolDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -0700463
464/**
465 * Initializes this dictionary with the requested capacity.
466 *
467 * @param numItems Number of items needed for this dictionary.
468 *
469 * @return A newly initialized dictionary with the requested capacity.
470 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500471- (instancetype)initWithCapacity:(NSUInteger)numItems;
472
Austin Schuh40c16522018-10-28 20:27:54 -0700473/**
474 * Gets the value for the given key.
475 *
476 * @param value Pointer into which the value will be set, if found.
477 * @param key Key under which the value is stored, if present.
478 *
479 * @return YES if the key was found and the value was copied, NO otherwise.
480 **/
481- (BOOL)getBool:(nullable BOOL *)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500482
Austin Schuh40c16522018-10-28 20:27:54 -0700483/**
484 * Enumerates the keys and values on this dictionary with the given block.
485 *
486 * @param block The block to enumerate with.
487 * **key**: The key for the current entry.
488 * **value**: The value for the current entry
489 * **stop**: A pointer to a boolean that when set stops the enumeration.
490 **/
491- (void)enumerateKeysAndBoolsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -0500492 (void (^)(uint32_t key, BOOL value, BOOL *stop))block;
493
Austin Schuh40c16522018-10-28 20:27:54 -0700494/**
495 * Adds the keys and values from another dictionary.
496 *
497 * @param otherDictionary Dictionary containing entries to be added to this
498 * dictionary.
499 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500500- (void)addEntriesFromDictionary:(GPBUInt32BoolDictionary *)otherDictionary;
501
Austin Schuh40c16522018-10-28 20:27:54 -0700502/**
503 * Sets the value for the given key.
504 *
505 * @param value The value to set.
506 * @param key The key under which to store the value.
507 **/
508- (void)setBool:(BOOL)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500509
Austin Schuh40c16522018-10-28 20:27:54 -0700510/**
511 * Removes the entry for the given key.
512 *
513 * @param aKey Key to be removed from this dictionary.
514 **/
515- (void)removeBoolForKey:(uint32_t)aKey;
516
517/**
518 * Removes all entries in this dictionary.
519 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500520- (void)removeAll;
521
522@end
523
524#pragma mark - UInt32 -> Float
525
Austin Schuh40c16522018-10-28 20:27:54 -0700526/**
527 * Class used for map fields of <uint32_t, float>
528 * values. This performs better than boxing into NSNumbers in NSDictionaries.
529 *
530 * @note This class is not meant to be subclassed.
531 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500532@interface GPBUInt32FloatDictionary : NSObject <NSCopying>
533
Austin Schuh40c16522018-10-28 20:27:54 -0700534/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -0500535@property(nonatomic, readonly) NSUInteger count;
536
Austin Schuh40c16522018-10-28 20:27:54 -0700537/**
538 * Initializes this dictionary, copying the given values and keys.
539 *
540 * @param values The values to be placed in this dictionary.
541 * @param keys The keys under which to store the values.
542 * @param count The number of elements to copy into the dictionary.
543 *
544 * @return A newly initialized dictionary with a copy of the values and keys.
545 **/
546- (instancetype)initWithFloats:(const float [__nullable])values
547 forKeys:(const uint32_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -0500548 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -0700549
550/**
551 * Initializes this dictionary, copying the entries from the given dictionary.
552 *
553 * @param dictionary Dictionary containing the entries to add to this dictionary.
554 *
555 * @return A newly initialized dictionary with the entries of the given dictionary.
556 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500557- (instancetype)initWithDictionary:(GPBUInt32FloatDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -0700558
559/**
560 * Initializes this dictionary with the requested capacity.
561 *
562 * @param numItems Number of items needed for this dictionary.
563 *
564 * @return A newly initialized dictionary with the requested capacity.
565 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500566- (instancetype)initWithCapacity:(NSUInteger)numItems;
567
Austin Schuh40c16522018-10-28 20:27:54 -0700568/**
569 * Gets the value for the given key.
570 *
571 * @param value Pointer into which the value will be set, if found.
572 * @param key Key under which the value is stored, if present.
573 *
574 * @return YES if the key was found and the value was copied, NO otherwise.
575 **/
576- (BOOL)getFloat:(nullable float *)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500577
Austin Schuh40c16522018-10-28 20:27:54 -0700578/**
579 * Enumerates the keys and values on this dictionary with the given block.
580 *
581 * @param block The block to enumerate with.
582 * **key**: The key for the current entry.
583 * **value**: The value for the current entry
584 * **stop**: A pointer to a boolean that when set stops the enumeration.
585 **/
586- (void)enumerateKeysAndFloatsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -0500587 (void (^)(uint32_t key, float value, BOOL *stop))block;
588
Austin Schuh40c16522018-10-28 20:27:54 -0700589/**
590 * Adds the keys and values from another dictionary.
591 *
592 * @param otherDictionary Dictionary containing entries to be added to this
593 * dictionary.
594 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500595- (void)addEntriesFromDictionary:(GPBUInt32FloatDictionary *)otherDictionary;
596
Austin Schuh40c16522018-10-28 20:27:54 -0700597/**
598 * Sets the value for the given key.
599 *
600 * @param value The value to set.
601 * @param key The key under which to store the value.
602 **/
603- (void)setFloat:(float)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500604
Austin Schuh40c16522018-10-28 20:27:54 -0700605/**
606 * Removes the entry for the given key.
607 *
608 * @param aKey Key to be removed from this dictionary.
609 **/
610- (void)removeFloatForKey:(uint32_t)aKey;
611
612/**
613 * Removes all entries in this dictionary.
614 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500615- (void)removeAll;
616
617@end
618
619#pragma mark - UInt32 -> Double
620
Austin Schuh40c16522018-10-28 20:27:54 -0700621/**
622 * Class used for map fields of <uint32_t, double>
623 * values. This performs better than boxing into NSNumbers in NSDictionaries.
624 *
625 * @note This class is not meant to be subclassed.
626 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500627@interface GPBUInt32DoubleDictionary : NSObject <NSCopying>
628
Austin Schuh40c16522018-10-28 20:27:54 -0700629/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -0500630@property(nonatomic, readonly) NSUInteger count;
631
Austin Schuh40c16522018-10-28 20:27:54 -0700632/**
633 * Initializes this dictionary, copying the given values and keys.
634 *
635 * @param values The values to be placed in this dictionary.
636 * @param keys The keys under which to store the values.
637 * @param count The number of elements to copy into the dictionary.
638 *
639 * @return A newly initialized dictionary with a copy of the values and keys.
640 **/
641- (instancetype)initWithDoubles:(const double [__nullable])values
642 forKeys:(const uint32_t [__nullable])keys
643 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500644
Austin Schuh40c16522018-10-28 20:27:54 -0700645/**
646 * Initializes this dictionary, copying the entries from the given dictionary.
647 *
648 * @param dictionary Dictionary containing the entries to add to this dictionary.
649 *
650 * @return A newly initialized dictionary with the entries of the given dictionary.
651 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500652- (instancetype)initWithDictionary:(GPBUInt32DoubleDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -0700653
654/**
655 * Initializes this dictionary with the requested capacity.
656 *
657 * @param numItems Number of items needed for this dictionary.
658 *
659 * @return A newly initialized dictionary with the requested capacity.
660 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500661- (instancetype)initWithCapacity:(NSUInteger)numItems;
662
Austin Schuh40c16522018-10-28 20:27:54 -0700663/**
664 * Gets the value for the given key.
665 *
666 * @param value Pointer into which the value will be set, if found.
667 * @param key Key under which the value is stored, if present.
668 *
669 * @return YES if the key was found and the value was copied, NO otherwise.
670 **/
671- (BOOL)getDouble:(nullable double *)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500672
Austin Schuh40c16522018-10-28 20:27:54 -0700673/**
674 * Enumerates the keys and values on this dictionary with the given block.
675 *
676 * @param block The block to enumerate with.
677 * **key**: The key for the current entry.
678 * **value**: The value for the current entry
679 * **stop**: A pointer to a boolean that when set stops the enumeration.
680 **/
681- (void)enumerateKeysAndDoublesUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -0500682 (void (^)(uint32_t key, double value, BOOL *stop))block;
683
Austin Schuh40c16522018-10-28 20:27:54 -0700684/**
685 * Adds the keys and values from another dictionary.
686 *
687 * @param otherDictionary Dictionary containing entries to be added to this
688 * dictionary.
689 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500690- (void)addEntriesFromDictionary:(GPBUInt32DoubleDictionary *)otherDictionary;
691
Austin Schuh40c16522018-10-28 20:27:54 -0700692/**
693 * Sets the value for the given key.
694 *
695 * @param value The value to set.
696 * @param key The key under which to store the value.
697 **/
698- (void)setDouble:(double)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500699
Austin Schuh40c16522018-10-28 20:27:54 -0700700/**
701 * Removes the entry for the given key.
702 *
703 * @param aKey Key to be removed from this dictionary.
704 **/
705- (void)removeDoubleForKey:(uint32_t)aKey;
706
707/**
708 * Removes all entries in this dictionary.
709 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500710- (void)removeAll;
711
712@end
713
714#pragma mark - UInt32 -> Enum
715
Austin Schuh40c16522018-10-28 20:27:54 -0700716/**
717 * Class used for map fields of <uint32_t, int32_t>
718 * values. This performs better than boxing into NSNumbers in NSDictionaries.
719 *
720 * @note This class is not meant to be subclassed.
721 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500722@interface GPBUInt32EnumDictionary : NSObject <NSCopying>
723
Austin Schuh40c16522018-10-28 20:27:54 -0700724/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -0500725@property(nonatomic, readonly) NSUInteger count;
Austin Schuh40c16522018-10-28 20:27:54 -0700726/** The validation function to check if the enums are valid. */
Brian Silverman9c614bc2016-02-15 20:20:02 -0500727@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
728
Austin Schuh40c16522018-10-28 20:27:54 -0700729/**
730 * Initializes a dictionary with the given validation function.
731 *
732 * @param func The enum validation function for the dictionary.
733 *
734 * @return A newly initialized dictionary.
735 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500736- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Austin Schuh40c16522018-10-28 20:27:54 -0700737
738/**
739 * Initializes a dictionary with the entries given.
740 *
741 * @param func The enum validation function for the dictionary.
742 * @param values The raw enum values values to be placed in the dictionary.
743 * @param keys The keys under which to store the values.
744 * @param count The number of entries to store in the dictionary.
745 *
746 * @return A newly initialized dictionary with the keys and values in it.
747 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500748- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Austin Schuh40c16522018-10-28 20:27:54 -0700749 rawValues:(const int32_t [__nullable])values
750 forKeys:(const uint32_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -0500751 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -0700752
753/**
754 * Initializes a dictionary with the entries from the given.
755 * dictionary.
756 *
757 * @param dictionary Dictionary containing the entries to add to the dictionary.
758 *
759 * @return A newly initialized dictionary with the entries from the given
760 * dictionary in it.
761 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500762- (instancetype)initWithDictionary:(GPBUInt32EnumDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -0700763
764/**
765 * Initializes a dictionary with the given capacity.
766 *
767 * @param func The enum validation function for the dictionary.
768 * @param numItems Capacity needed for the dictionary.
769 *
770 * @return A newly initialized dictionary with the given capacity.
771 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500772- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
773 capacity:(NSUInteger)numItems;
774
775// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
776// is not a valid enumerator as defined by validationFunc. If the actual value is
777// desired, use "raw" version of the method.
778
Austin Schuh40c16522018-10-28 20:27:54 -0700779/**
780 * Gets the value for the given key.
781 *
782 * @param value Pointer into which the value will be set, if found.
783 * @param key Key under which the value is stored, if present.
784 *
785 * @return YES if the key was found and the value was copied, NO otherwise.
786 **/
787- (BOOL)getEnum:(nullable int32_t *)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500788
Austin Schuh40c16522018-10-28 20:27:54 -0700789/**
790 * Enumerates the keys and values on this dictionary with the given block.
791 *
792 * @param block The block to enumerate with.
793 * **key**: The key for the current entry.
794 * **value**: The value for the current entry
795 * **stop**: A pointer to a boolean that when set stops the enumeration.
796 **/
797- (void)enumerateKeysAndEnumsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -0500798 (void (^)(uint32_t key, int32_t value, BOOL *stop))block;
799
Austin Schuh40c16522018-10-28 20:27:54 -0700800/**
801 * Gets the raw enum value for the given key.
802 *
803 * @note This method bypass the validationFunc to enable the access of values that
804 * were not known at the time the binary was compiled.
805 *
806 * @param rawValue Pointer into which the value will be set, if found.
807 * @param key Key under which the value is stored, if present.
808 *
809 * @return YES if the key was found and the value was copied, NO otherwise.
810 **/
811- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500812
Austin Schuh40c16522018-10-28 20:27:54 -0700813/**
814 * Enumerates the keys and values on this dictionary with the given block.
815 *
816 * @note This method bypass the validationFunc to enable the access of values that
817 * were not known at the time the binary was compiled.
818 *
819 * @param block The block to enumerate with.
820 * **key**: The key for the current entry.
821 * **rawValue**: The value for the current entry
822 * **stop**: A pointer to a boolean that when set stops the enumeration.
823 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500824- (void)enumerateKeysAndRawValuesUsingBlock:
825 (void (^)(uint32_t key, int32_t rawValue, BOOL *stop))block;
826
Austin Schuh40c16522018-10-28 20:27:54 -0700827/**
828 * Adds the keys and raw enum values from another dictionary.
829 *
830 * @note This method bypass the validationFunc to enable the setting of values that
831 * were not known at the time the binary was compiled.
832 *
833 * @param otherDictionary Dictionary containing entries to be added to this
834 * dictionary.
835 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500836- (void)addRawEntriesFromDictionary:(GPBUInt32EnumDictionary *)otherDictionary;
837
838// If value is not a valid enumerator as defined by validationFunc, these
839// methods will assert in debug, and will log in release and assign the value
840// to the default value. Use the rawValue methods below to assign non enumerator
841// values.
842
Austin Schuh40c16522018-10-28 20:27:54 -0700843/**
844 * Sets the value for the given key.
845 *
846 * @param value The value to set.
847 * @param key The key under which to store the value.
848 **/
849- (void)setEnum:(int32_t)value forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500850
Austin Schuh40c16522018-10-28 20:27:54 -0700851/**
852 * Sets the raw enum value for the given key.
853 *
854 * @note This method bypass the validationFunc to enable the setting of values that
855 * were not known at the time the binary was compiled.
856 *
857 * @param rawValue The raw enum value to set.
858 * @param key The key under which to store the raw enum value.
859 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500860- (void)setRawValue:(int32_t)rawValue forKey:(uint32_t)key;
861
Austin Schuh40c16522018-10-28 20:27:54 -0700862/**
863 * Removes the entry for the given key.
864 *
865 * @param aKey Key to be removed from this dictionary.
866 **/
867- (void)removeEnumForKey:(uint32_t)aKey;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500868
Austin Schuh40c16522018-10-28 20:27:54 -0700869/**
870 * Removes all entries in this dictionary.
871 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500872- (void)removeAll;
873
874@end
875
876#pragma mark - UInt32 -> Object
877
Austin Schuh40c16522018-10-28 20:27:54 -0700878/**
879 * Class used for map fields of <uint32_t, ObjectType>
880 * values. This performs better than boxing into NSNumbers in NSDictionaries.
881 *
882 * @note This class is not meant to be subclassed.
883 **/
884@interface GPBUInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
Brian Silverman9c614bc2016-02-15 20:20:02 -0500885
Austin Schuh40c16522018-10-28 20:27:54 -0700886/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -0500887@property(nonatomic, readonly) NSUInteger count;
888
Austin Schuh40c16522018-10-28 20:27:54 -0700889/**
890 * Initializes this dictionary, copying the given values and keys.
891 *
892 * @param objects The values to be placed in this dictionary.
893 * @param keys The keys under which to store the values.
894 * @param count The number of elements to copy into the dictionary.
895 *
896 * @return A newly initialized dictionary with a copy of the values and keys.
897 **/
898- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
899 forKeys:(const uint32_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -0500900 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -0700901
902/**
903 * Initializes this dictionary, copying the entries from the given dictionary.
904 *
905 * @param dictionary Dictionary containing the entries to add to this dictionary.
906 *
907 * @return A newly initialized dictionary with the entries of the given dictionary.
908 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500909- (instancetype)initWithDictionary:(GPBUInt32ObjectDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -0700910
911/**
912 * Initializes this dictionary with the requested capacity.
913 *
914 * @param numItems Number of items needed for this dictionary.
915 *
916 * @return A newly initialized dictionary with the requested capacity.
917 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500918- (instancetype)initWithCapacity:(NSUInteger)numItems;
919
Austin Schuh40c16522018-10-28 20:27:54 -0700920/**
921 * Fetches the object stored under the given key.
922 *
923 * @param key Key under which the value is stored, if present.
924 *
925 * @return The object if found, nil otherwise.
926 **/
927- (ObjectType)objectForKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500928
Austin Schuh40c16522018-10-28 20:27:54 -0700929/**
930 * Enumerates the keys and values on this dictionary with the given block.
931 *
932 * @param block The block to enumerate with.
933 * **key**: The key for the current entry.
934 * **object**: The value for the current entry
935 * **stop**: A pointer to a boolean that when set stops the enumeration.
936 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500937- (void)enumerateKeysAndObjectsUsingBlock:
Austin Schuh40c16522018-10-28 20:27:54 -0700938 (void (^)(uint32_t key, ObjectType object, BOOL *stop))block;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500939
Austin Schuh40c16522018-10-28 20:27:54 -0700940/**
941 * Adds the keys and values from another dictionary.
942 *
943 * @param otherDictionary Dictionary containing entries to be added to this
944 * dictionary.
945 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500946- (void)addEntriesFromDictionary:(GPBUInt32ObjectDictionary *)otherDictionary;
947
Austin Schuh40c16522018-10-28 20:27:54 -0700948/**
949 * Sets the value for the given key.
950 *
951 * @param object The value to set.
952 * @param key The key under which to store the value.
953 **/
954- (void)setObject:(ObjectType)object forKey:(uint32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500955
Austin Schuh40c16522018-10-28 20:27:54 -0700956/**
957 * Removes the entry for the given key.
958 *
959 * @param aKey Key to be removed from this dictionary.
960 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500961- (void)removeObjectForKey:(uint32_t)aKey;
Austin Schuh40c16522018-10-28 20:27:54 -0700962
963/**
964 * Removes all entries in this dictionary.
965 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500966- (void)removeAll;
967
968@end
969
970#pragma mark - Int32 -> UInt32
971
Austin Schuh40c16522018-10-28 20:27:54 -0700972/**
973 * Class used for map fields of <int32_t, uint32_t>
974 * values. This performs better than boxing into NSNumbers in NSDictionaries.
975 *
976 * @note This class is not meant to be subclassed.
977 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -0500978@interface GPBInt32UInt32Dictionary : NSObject <NSCopying>
979
Austin Schuh40c16522018-10-28 20:27:54 -0700980/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -0500981@property(nonatomic, readonly) NSUInteger count;
982
Austin Schuh40c16522018-10-28 20:27:54 -0700983/**
984 * Initializes this dictionary, copying the given values and keys.
985 *
986 * @param values The values to be placed in this dictionary.
987 * @param keys The keys under which to store the values.
988 * @param count The number of elements to copy into the dictionary.
989 *
990 * @return A newly initialized dictionary with a copy of the values and keys.
991 **/
992- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
993 forKeys:(const int32_t [__nullable])keys
994 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -0500995
Austin Schuh40c16522018-10-28 20:27:54 -0700996/**
997 * Initializes this dictionary, copying the entries from the given dictionary.
998 *
999 * @param dictionary Dictionary containing the entries to add to this dictionary.
1000 *
1001 * @return A newly initialized dictionary with the entries of the given dictionary.
1002 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001003- (instancetype)initWithDictionary:(GPBInt32UInt32Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07001004
1005/**
1006 * Initializes this dictionary with the requested capacity.
1007 *
1008 * @param numItems Number of items needed for this dictionary.
1009 *
1010 * @return A newly initialized dictionary with the requested capacity.
1011 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001012- (instancetype)initWithCapacity:(NSUInteger)numItems;
1013
Austin Schuh40c16522018-10-28 20:27:54 -07001014/**
1015 * Gets the value for the given key.
1016 *
1017 * @param value Pointer into which the value will be set, if found.
1018 * @param key Key under which the value is stored, if present.
1019 *
1020 * @return YES if the key was found and the value was copied, NO otherwise.
1021 **/
1022- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001023
Austin Schuh40c16522018-10-28 20:27:54 -07001024/**
1025 * Enumerates the keys and values on this dictionary with the given block.
1026 *
1027 * @param block The block to enumerate with.
1028 * **key**: The key for the current entry.
1029 * **value**: The value for the current entry
1030 * **stop**: A pointer to a boolean that when set stops the enumeration.
1031 **/
1032- (void)enumerateKeysAndUInt32sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05001033 (void (^)(int32_t key, uint32_t value, BOOL *stop))block;
1034
Austin Schuh40c16522018-10-28 20:27:54 -07001035/**
1036 * Adds the keys and values from another dictionary.
1037 *
1038 * @param otherDictionary Dictionary containing entries to be added to this
1039 * dictionary.
1040 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001041- (void)addEntriesFromDictionary:(GPBInt32UInt32Dictionary *)otherDictionary;
1042
Austin Schuh40c16522018-10-28 20:27:54 -07001043/**
1044 * Sets the value for the given key.
1045 *
1046 * @param value The value to set.
1047 * @param key The key under which to store the value.
1048 **/
1049- (void)setUInt32:(uint32_t)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001050
Austin Schuh40c16522018-10-28 20:27:54 -07001051/**
1052 * Removes the entry for the given key.
1053 *
1054 * @param aKey Key to be removed from this dictionary.
1055 **/
1056- (void)removeUInt32ForKey:(int32_t)aKey;
1057
1058/**
1059 * Removes all entries in this dictionary.
1060 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001061- (void)removeAll;
1062
1063@end
1064
1065#pragma mark - Int32 -> Int32
1066
Austin Schuh40c16522018-10-28 20:27:54 -07001067/**
1068 * Class used for map fields of <int32_t, int32_t>
1069 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1070 *
1071 * @note This class is not meant to be subclassed.
1072 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001073@interface GPBInt32Int32Dictionary : NSObject <NSCopying>
1074
Austin Schuh40c16522018-10-28 20:27:54 -07001075/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05001076@property(nonatomic, readonly) NSUInteger count;
1077
Austin Schuh40c16522018-10-28 20:27:54 -07001078/**
1079 * Initializes this dictionary, copying the given values and keys.
1080 *
1081 * @param values The values to be placed in this dictionary.
1082 * @param keys The keys under which to store the values.
1083 * @param count The number of elements to copy into the dictionary.
1084 *
1085 * @return A newly initialized dictionary with a copy of the values and keys.
1086 **/
1087- (instancetype)initWithInt32s:(const int32_t [__nullable])values
1088 forKeys:(const int32_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05001089 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07001090
1091/**
1092 * Initializes this dictionary, copying the entries from the given dictionary.
1093 *
1094 * @param dictionary Dictionary containing the entries to add to this dictionary.
1095 *
1096 * @return A newly initialized dictionary with the entries of the given dictionary.
1097 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001098- (instancetype)initWithDictionary:(GPBInt32Int32Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07001099
1100/**
1101 * Initializes this dictionary with the requested capacity.
1102 *
1103 * @param numItems Number of items needed for this dictionary.
1104 *
1105 * @return A newly initialized dictionary with the requested capacity.
1106 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001107- (instancetype)initWithCapacity:(NSUInteger)numItems;
1108
Austin Schuh40c16522018-10-28 20:27:54 -07001109/**
1110 * Gets the value for the given key.
1111 *
1112 * @param value Pointer into which the value will be set, if found.
1113 * @param key Key under which the value is stored, if present.
1114 *
1115 * @return YES if the key was found and the value was copied, NO otherwise.
1116 **/
1117- (BOOL)getInt32:(nullable int32_t *)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001118
Austin Schuh40c16522018-10-28 20:27:54 -07001119/**
1120 * Enumerates the keys and values on this dictionary with the given block.
1121 *
1122 * @param block The block to enumerate with.
1123 * **key**: The key for the current entry.
1124 * **value**: The value for the current entry
1125 * **stop**: A pointer to a boolean that when set stops the enumeration.
1126 **/
1127- (void)enumerateKeysAndInt32sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05001128 (void (^)(int32_t key, int32_t value, BOOL *stop))block;
1129
Austin Schuh40c16522018-10-28 20:27:54 -07001130/**
1131 * Adds the keys and values from another dictionary.
1132 *
1133 * @param otherDictionary Dictionary containing entries to be added to this
1134 * dictionary.
1135 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001136- (void)addEntriesFromDictionary:(GPBInt32Int32Dictionary *)otherDictionary;
1137
Austin Schuh40c16522018-10-28 20:27:54 -07001138/**
1139 * Sets the value for the given key.
1140 *
1141 * @param value The value to set.
1142 * @param key The key under which to store the value.
1143 **/
1144- (void)setInt32:(int32_t)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001145
Austin Schuh40c16522018-10-28 20:27:54 -07001146/**
1147 * Removes the entry for the given key.
1148 *
1149 * @param aKey Key to be removed from this dictionary.
1150 **/
1151- (void)removeInt32ForKey:(int32_t)aKey;
1152
1153/**
1154 * Removes all entries in this dictionary.
1155 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001156- (void)removeAll;
1157
1158@end
1159
1160#pragma mark - Int32 -> UInt64
1161
Austin Schuh40c16522018-10-28 20:27:54 -07001162/**
1163 * Class used for map fields of <int32_t, uint64_t>
1164 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1165 *
1166 * @note This class is not meant to be subclassed.
1167 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001168@interface GPBInt32UInt64Dictionary : NSObject <NSCopying>
1169
Austin Schuh40c16522018-10-28 20:27:54 -07001170/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05001171@property(nonatomic, readonly) NSUInteger count;
1172
Austin Schuh40c16522018-10-28 20:27:54 -07001173/**
1174 * Initializes this dictionary, copying the given values and keys.
1175 *
1176 * @param values The values to be placed in this dictionary.
1177 * @param keys The keys under which to store the values.
1178 * @param count The number of elements to copy into the dictionary.
1179 *
1180 * @return A newly initialized dictionary with a copy of the values and keys.
1181 **/
1182- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
1183 forKeys:(const int32_t [__nullable])keys
1184 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001185
Austin Schuh40c16522018-10-28 20:27:54 -07001186/**
1187 * Initializes this dictionary, copying the entries from the given dictionary.
1188 *
1189 * @param dictionary Dictionary containing the entries to add to this dictionary.
1190 *
1191 * @return A newly initialized dictionary with the entries of the given dictionary.
1192 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001193- (instancetype)initWithDictionary:(GPBInt32UInt64Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07001194
1195/**
1196 * Initializes this dictionary with the requested capacity.
1197 *
1198 * @param numItems Number of items needed for this dictionary.
1199 *
1200 * @return A newly initialized dictionary with the requested capacity.
1201 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001202- (instancetype)initWithCapacity:(NSUInteger)numItems;
1203
Austin Schuh40c16522018-10-28 20:27:54 -07001204/**
1205 * Gets the value for the given key.
1206 *
1207 * @param value Pointer into which the value will be set, if found.
1208 * @param key Key under which the value is stored, if present.
1209 *
1210 * @return YES if the key was found and the value was copied, NO otherwise.
1211 **/
1212- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001213
Austin Schuh40c16522018-10-28 20:27:54 -07001214/**
1215 * Enumerates the keys and values on this dictionary with the given block.
1216 *
1217 * @param block The block to enumerate with.
1218 * **key**: The key for the current entry.
1219 * **value**: The value for the current entry
1220 * **stop**: A pointer to a boolean that when set stops the enumeration.
1221 **/
1222- (void)enumerateKeysAndUInt64sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05001223 (void (^)(int32_t key, uint64_t value, BOOL *stop))block;
1224
Austin Schuh40c16522018-10-28 20:27:54 -07001225/**
1226 * Adds the keys and values from another dictionary.
1227 *
1228 * @param otherDictionary Dictionary containing entries to be added to this
1229 * dictionary.
1230 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001231- (void)addEntriesFromDictionary:(GPBInt32UInt64Dictionary *)otherDictionary;
1232
Austin Schuh40c16522018-10-28 20:27:54 -07001233/**
1234 * Sets the value for the given key.
1235 *
1236 * @param value The value to set.
1237 * @param key The key under which to store the value.
1238 **/
1239- (void)setUInt64:(uint64_t)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001240
Austin Schuh40c16522018-10-28 20:27:54 -07001241/**
1242 * Removes the entry for the given key.
1243 *
1244 * @param aKey Key to be removed from this dictionary.
1245 **/
1246- (void)removeUInt64ForKey:(int32_t)aKey;
1247
1248/**
1249 * Removes all entries in this dictionary.
1250 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001251- (void)removeAll;
1252
1253@end
1254
1255#pragma mark - Int32 -> Int64
1256
Austin Schuh40c16522018-10-28 20:27:54 -07001257/**
1258 * Class used for map fields of <int32_t, int64_t>
1259 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1260 *
1261 * @note This class is not meant to be subclassed.
1262 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001263@interface GPBInt32Int64Dictionary : NSObject <NSCopying>
1264
Austin Schuh40c16522018-10-28 20:27:54 -07001265/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05001266@property(nonatomic, readonly) NSUInteger count;
1267
Austin Schuh40c16522018-10-28 20:27:54 -07001268/**
1269 * Initializes this dictionary, copying the given values and keys.
1270 *
1271 * @param values The values to be placed in this dictionary.
1272 * @param keys The keys under which to store the values.
1273 * @param count The number of elements to copy into the dictionary.
1274 *
1275 * @return A newly initialized dictionary with a copy of the values and keys.
1276 **/
1277- (instancetype)initWithInt64s:(const int64_t [__nullable])values
1278 forKeys:(const int32_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05001279 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07001280
1281/**
1282 * Initializes this dictionary, copying the entries from the given dictionary.
1283 *
1284 * @param dictionary Dictionary containing the entries to add to this dictionary.
1285 *
1286 * @return A newly initialized dictionary with the entries of the given dictionary.
1287 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001288- (instancetype)initWithDictionary:(GPBInt32Int64Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07001289
1290/**
1291 * Initializes this dictionary with the requested capacity.
1292 *
1293 * @param numItems Number of items needed for this dictionary.
1294 *
1295 * @return A newly initialized dictionary with the requested capacity.
1296 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001297- (instancetype)initWithCapacity:(NSUInteger)numItems;
1298
Austin Schuh40c16522018-10-28 20:27:54 -07001299/**
1300 * Gets the value for the given key.
1301 *
1302 * @param value Pointer into which the value will be set, if found.
1303 * @param key Key under which the value is stored, if present.
1304 *
1305 * @return YES if the key was found and the value was copied, NO otherwise.
1306 **/
1307- (BOOL)getInt64:(nullable int64_t *)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001308
Austin Schuh40c16522018-10-28 20:27:54 -07001309/**
1310 * Enumerates the keys and values on this dictionary with the given block.
1311 *
1312 * @param block The block to enumerate with.
1313 * **key**: The key for the current entry.
1314 * **value**: The value for the current entry
1315 * **stop**: A pointer to a boolean that when set stops the enumeration.
1316 **/
1317- (void)enumerateKeysAndInt64sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05001318 (void (^)(int32_t key, int64_t value, BOOL *stop))block;
1319
Austin Schuh40c16522018-10-28 20:27:54 -07001320/**
1321 * Adds the keys and values from another dictionary.
1322 *
1323 * @param otherDictionary Dictionary containing entries to be added to this
1324 * dictionary.
1325 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001326- (void)addEntriesFromDictionary:(GPBInt32Int64Dictionary *)otherDictionary;
1327
Austin Schuh40c16522018-10-28 20:27:54 -07001328/**
1329 * Sets the value for the given key.
1330 *
1331 * @param value The value to set.
1332 * @param key The key under which to store the value.
1333 **/
1334- (void)setInt64:(int64_t)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001335
Austin Schuh40c16522018-10-28 20:27:54 -07001336/**
1337 * Removes the entry for the given key.
1338 *
1339 * @param aKey Key to be removed from this dictionary.
1340 **/
1341- (void)removeInt64ForKey:(int32_t)aKey;
1342
1343/**
1344 * Removes all entries in this dictionary.
1345 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001346- (void)removeAll;
1347
1348@end
1349
1350#pragma mark - Int32 -> Bool
1351
Austin Schuh40c16522018-10-28 20:27:54 -07001352/**
1353 * Class used for map fields of <int32_t, BOOL>
1354 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1355 *
1356 * @note This class is not meant to be subclassed.
1357 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001358@interface GPBInt32BoolDictionary : NSObject <NSCopying>
1359
Austin Schuh40c16522018-10-28 20:27:54 -07001360/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05001361@property(nonatomic, readonly) NSUInteger count;
1362
Austin Schuh40c16522018-10-28 20:27:54 -07001363/**
1364 * Initializes this dictionary, copying the given values and keys.
1365 *
1366 * @param values The values to be placed in this dictionary.
1367 * @param keys The keys under which to store the values.
1368 * @param count The number of elements to copy into the dictionary.
1369 *
1370 * @return A newly initialized dictionary with a copy of the values and keys.
1371 **/
1372- (instancetype)initWithBools:(const BOOL [__nullable])values
1373 forKeys:(const int32_t [__nullable])keys
1374 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001375
Austin Schuh40c16522018-10-28 20:27:54 -07001376/**
1377 * Initializes this dictionary, copying the entries from the given dictionary.
1378 *
1379 * @param dictionary Dictionary containing the entries to add to this dictionary.
1380 *
1381 * @return A newly initialized dictionary with the entries of the given dictionary.
1382 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001383- (instancetype)initWithDictionary:(GPBInt32BoolDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07001384
1385/**
1386 * Initializes this dictionary with the requested capacity.
1387 *
1388 * @param numItems Number of items needed for this dictionary.
1389 *
1390 * @return A newly initialized dictionary with the requested capacity.
1391 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001392- (instancetype)initWithCapacity:(NSUInteger)numItems;
1393
Austin Schuh40c16522018-10-28 20:27:54 -07001394/**
1395 * Gets the value for the given key.
1396 *
1397 * @param value Pointer into which the value will be set, if found.
1398 * @param key Key under which the value is stored, if present.
1399 *
1400 * @return YES if the key was found and the value was copied, NO otherwise.
1401 **/
1402- (BOOL)getBool:(nullable BOOL *)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001403
Austin Schuh40c16522018-10-28 20:27:54 -07001404/**
1405 * Enumerates the keys and values on this dictionary with the given block.
1406 *
1407 * @param block The block to enumerate with.
1408 * **key**: The key for the current entry.
1409 * **value**: The value for the current entry
1410 * **stop**: A pointer to a boolean that when set stops the enumeration.
1411 **/
1412- (void)enumerateKeysAndBoolsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05001413 (void (^)(int32_t key, BOOL value, BOOL *stop))block;
1414
Austin Schuh40c16522018-10-28 20:27:54 -07001415/**
1416 * Adds the keys and values from another dictionary.
1417 *
1418 * @param otherDictionary Dictionary containing entries to be added to this
1419 * dictionary.
1420 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001421- (void)addEntriesFromDictionary:(GPBInt32BoolDictionary *)otherDictionary;
1422
Austin Schuh40c16522018-10-28 20:27:54 -07001423/**
1424 * Sets the value for the given key.
1425 *
1426 * @param value The value to set.
1427 * @param key The key under which to store the value.
1428 **/
1429- (void)setBool:(BOOL)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001430
Austin Schuh40c16522018-10-28 20:27:54 -07001431/**
1432 * Removes the entry for the given key.
1433 *
1434 * @param aKey Key to be removed from this dictionary.
1435 **/
1436- (void)removeBoolForKey:(int32_t)aKey;
1437
1438/**
1439 * Removes all entries in this dictionary.
1440 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001441- (void)removeAll;
1442
1443@end
1444
1445#pragma mark - Int32 -> Float
1446
Austin Schuh40c16522018-10-28 20:27:54 -07001447/**
1448 * Class used for map fields of <int32_t, float>
1449 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1450 *
1451 * @note This class is not meant to be subclassed.
1452 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001453@interface GPBInt32FloatDictionary : NSObject <NSCopying>
1454
Austin Schuh40c16522018-10-28 20:27:54 -07001455/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05001456@property(nonatomic, readonly) NSUInteger count;
1457
Austin Schuh40c16522018-10-28 20:27:54 -07001458/**
1459 * Initializes this dictionary, copying the given values and keys.
1460 *
1461 * @param values The values to be placed in this dictionary.
1462 * @param keys The keys under which to store the values.
1463 * @param count The number of elements to copy into the dictionary.
1464 *
1465 * @return A newly initialized dictionary with a copy of the values and keys.
1466 **/
1467- (instancetype)initWithFloats:(const float [__nullable])values
1468 forKeys:(const int32_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05001469 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07001470
1471/**
1472 * Initializes this dictionary, copying the entries from the given dictionary.
1473 *
1474 * @param dictionary Dictionary containing the entries to add to this dictionary.
1475 *
1476 * @return A newly initialized dictionary with the entries of the given dictionary.
1477 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001478- (instancetype)initWithDictionary:(GPBInt32FloatDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07001479
1480/**
1481 * Initializes this dictionary with the requested capacity.
1482 *
1483 * @param numItems Number of items needed for this dictionary.
1484 *
1485 * @return A newly initialized dictionary with the requested capacity.
1486 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001487- (instancetype)initWithCapacity:(NSUInteger)numItems;
1488
Austin Schuh40c16522018-10-28 20:27:54 -07001489/**
1490 * Gets the value for the given key.
1491 *
1492 * @param value Pointer into which the value will be set, if found.
1493 * @param key Key under which the value is stored, if present.
1494 *
1495 * @return YES if the key was found and the value was copied, NO otherwise.
1496 **/
1497- (BOOL)getFloat:(nullable float *)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001498
Austin Schuh40c16522018-10-28 20:27:54 -07001499/**
1500 * Enumerates the keys and values on this dictionary with the given block.
1501 *
1502 * @param block The block to enumerate with.
1503 * **key**: The key for the current entry.
1504 * **value**: The value for the current entry
1505 * **stop**: A pointer to a boolean that when set stops the enumeration.
1506 **/
1507- (void)enumerateKeysAndFloatsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05001508 (void (^)(int32_t key, float value, BOOL *stop))block;
1509
Austin Schuh40c16522018-10-28 20:27:54 -07001510/**
1511 * Adds the keys and values from another dictionary.
1512 *
1513 * @param otherDictionary Dictionary containing entries to be added to this
1514 * dictionary.
1515 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001516- (void)addEntriesFromDictionary:(GPBInt32FloatDictionary *)otherDictionary;
1517
Austin Schuh40c16522018-10-28 20:27:54 -07001518/**
1519 * Sets the value for the given key.
1520 *
1521 * @param value The value to set.
1522 * @param key The key under which to store the value.
1523 **/
1524- (void)setFloat:(float)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001525
Austin Schuh40c16522018-10-28 20:27:54 -07001526/**
1527 * Removes the entry for the given key.
1528 *
1529 * @param aKey Key to be removed from this dictionary.
1530 **/
1531- (void)removeFloatForKey:(int32_t)aKey;
1532
1533/**
1534 * Removes all entries in this dictionary.
1535 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001536- (void)removeAll;
1537
1538@end
1539
1540#pragma mark - Int32 -> Double
1541
Austin Schuh40c16522018-10-28 20:27:54 -07001542/**
1543 * Class used for map fields of <int32_t, double>
1544 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1545 *
1546 * @note This class is not meant to be subclassed.
1547 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001548@interface GPBInt32DoubleDictionary : NSObject <NSCopying>
1549
Austin Schuh40c16522018-10-28 20:27:54 -07001550/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05001551@property(nonatomic, readonly) NSUInteger count;
1552
Austin Schuh40c16522018-10-28 20:27:54 -07001553/**
1554 * Initializes this dictionary, copying the given values and keys.
1555 *
1556 * @param values The values to be placed in this dictionary.
1557 * @param keys The keys under which to store the values.
1558 * @param count The number of elements to copy into the dictionary.
1559 *
1560 * @return A newly initialized dictionary with a copy of the values and keys.
1561 **/
1562- (instancetype)initWithDoubles:(const double [__nullable])values
1563 forKeys:(const int32_t [__nullable])keys
1564 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001565
Austin Schuh40c16522018-10-28 20:27:54 -07001566/**
1567 * Initializes this dictionary, copying the entries from the given dictionary.
1568 *
1569 * @param dictionary Dictionary containing the entries to add to this dictionary.
1570 *
1571 * @return A newly initialized dictionary with the entries of the given dictionary.
1572 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001573- (instancetype)initWithDictionary:(GPBInt32DoubleDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07001574
1575/**
1576 * Initializes this dictionary with the requested capacity.
1577 *
1578 * @param numItems Number of items needed for this dictionary.
1579 *
1580 * @return A newly initialized dictionary with the requested capacity.
1581 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001582- (instancetype)initWithCapacity:(NSUInteger)numItems;
1583
Austin Schuh40c16522018-10-28 20:27:54 -07001584/**
1585 * Gets the value for the given key.
1586 *
1587 * @param value Pointer into which the value will be set, if found.
1588 * @param key Key under which the value is stored, if present.
1589 *
1590 * @return YES if the key was found and the value was copied, NO otherwise.
1591 **/
1592- (BOOL)getDouble:(nullable double *)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001593
Austin Schuh40c16522018-10-28 20:27:54 -07001594/**
1595 * Enumerates the keys and values on this dictionary with the given block.
1596 *
1597 * @param block The block to enumerate with.
1598 * **key**: The key for the current entry.
1599 * **value**: The value for the current entry
1600 * **stop**: A pointer to a boolean that when set stops the enumeration.
1601 **/
1602- (void)enumerateKeysAndDoublesUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05001603 (void (^)(int32_t key, double value, BOOL *stop))block;
1604
Austin Schuh40c16522018-10-28 20:27:54 -07001605/**
1606 * Adds the keys and values from another dictionary.
1607 *
1608 * @param otherDictionary Dictionary containing entries to be added to this
1609 * dictionary.
1610 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001611- (void)addEntriesFromDictionary:(GPBInt32DoubleDictionary *)otherDictionary;
1612
Austin Schuh40c16522018-10-28 20:27:54 -07001613/**
1614 * Sets the value for the given key.
1615 *
1616 * @param value The value to set.
1617 * @param key The key under which to store the value.
1618 **/
1619- (void)setDouble:(double)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001620
Austin Schuh40c16522018-10-28 20:27:54 -07001621/**
1622 * Removes the entry for the given key.
1623 *
1624 * @param aKey Key to be removed from this dictionary.
1625 **/
1626- (void)removeDoubleForKey:(int32_t)aKey;
1627
1628/**
1629 * Removes all entries in this dictionary.
1630 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001631- (void)removeAll;
1632
1633@end
1634
1635#pragma mark - Int32 -> Enum
1636
Austin Schuh40c16522018-10-28 20:27:54 -07001637/**
1638 * Class used for map fields of <int32_t, int32_t>
1639 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1640 *
1641 * @note This class is not meant to be subclassed.
1642 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001643@interface GPBInt32EnumDictionary : NSObject <NSCopying>
1644
Austin Schuh40c16522018-10-28 20:27:54 -07001645/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05001646@property(nonatomic, readonly) NSUInteger count;
Austin Schuh40c16522018-10-28 20:27:54 -07001647/** The validation function to check if the enums are valid. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05001648@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
1649
Austin Schuh40c16522018-10-28 20:27:54 -07001650/**
1651 * Initializes a dictionary with the given validation function.
1652 *
1653 * @param func The enum validation function for the dictionary.
1654 *
1655 * @return A newly initialized dictionary.
1656 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001657- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Austin Schuh40c16522018-10-28 20:27:54 -07001658
1659/**
1660 * Initializes a dictionary with the entries given.
1661 *
1662 * @param func The enum validation function for the dictionary.
1663 * @param values The raw enum values values to be placed in the dictionary.
1664 * @param keys The keys under which to store the values.
1665 * @param count The number of entries to store in the dictionary.
1666 *
1667 * @return A newly initialized dictionary with the keys and values in it.
1668 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001669- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Austin Schuh40c16522018-10-28 20:27:54 -07001670 rawValues:(const int32_t [__nullable])values
1671 forKeys:(const int32_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05001672 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07001673
1674/**
1675 * Initializes a dictionary with the entries from the given.
1676 * dictionary.
1677 *
1678 * @param dictionary Dictionary containing the entries to add to the dictionary.
1679 *
1680 * @return A newly initialized dictionary with the entries from the given
1681 * dictionary in it.
1682 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001683- (instancetype)initWithDictionary:(GPBInt32EnumDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07001684
1685/**
1686 * Initializes a dictionary with the given capacity.
1687 *
1688 * @param func The enum validation function for the dictionary.
1689 * @param numItems Capacity needed for the dictionary.
1690 *
1691 * @return A newly initialized dictionary with the given capacity.
1692 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001693- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
1694 capacity:(NSUInteger)numItems;
1695
1696// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
1697// is not a valid enumerator as defined by validationFunc. If the actual value is
1698// desired, use "raw" version of the method.
1699
Austin Schuh40c16522018-10-28 20:27:54 -07001700/**
1701 * Gets the value for the given key.
1702 *
1703 * @param value Pointer into which the value will be set, if found.
1704 * @param key Key under which the value is stored, if present.
1705 *
1706 * @return YES if the key was found and the value was copied, NO otherwise.
1707 **/
1708- (BOOL)getEnum:(nullable int32_t *)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001709
Austin Schuh40c16522018-10-28 20:27:54 -07001710/**
1711 * Enumerates the keys and values on this dictionary with the given block.
1712 *
1713 * @param block The block to enumerate with.
1714 * **key**: The key for the current entry.
1715 * **value**: The value for the current entry
1716 * **stop**: A pointer to a boolean that when set stops the enumeration.
1717 **/
1718- (void)enumerateKeysAndEnumsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05001719 (void (^)(int32_t key, int32_t value, BOOL *stop))block;
1720
Austin Schuh40c16522018-10-28 20:27:54 -07001721/**
1722 * Gets the raw enum value for the given key.
1723 *
1724 * @note This method bypass the validationFunc to enable the access of values that
1725 * were not known at the time the binary was compiled.
1726 *
1727 * @param rawValue Pointer into which the value will be set, if found.
1728 * @param key Key under which the value is stored, if present.
1729 *
1730 * @return YES if the key was found and the value was copied, NO otherwise.
1731 **/
1732- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001733
Austin Schuh40c16522018-10-28 20:27:54 -07001734/**
1735 * Enumerates the keys and values on this dictionary with the given block.
1736 *
1737 * @note This method bypass the validationFunc to enable the access of values that
1738 * were not known at the time the binary was compiled.
1739 *
1740 * @param block The block to enumerate with.
1741 * **key**: The key for the current entry.
1742 * **rawValue**: The value for the current entry
1743 * **stop**: A pointer to a boolean that when set stops the enumeration.
1744 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001745- (void)enumerateKeysAndRawValuesUsingBlock:
1746 (void (^)(int32_t key, int32_t rawValue, BOOL *stop))block;
1747
Austin Schuh40c16522018-10-28 20:27:54 -07001748/**
1749 * Adds the keys and raw enum values from another dictionary.
1750 *
1751 * @note This method bypass the validationFunc to enable the setting of values that
1752 * were not known at the time the binary was compiled.
1753 *
1754 * @param otherDictionary Dictionary containing entries to be added to this
1755 * dictionary.
1756 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001757- (void)addRawEntriesFromDictionary:(GPBInt32EnumDictionary *)otherDictionary;
1758
1759// If value is not a valid enumerator as defined by validationFunc, these
1760// methods will assert in debug, and will log in release and assign the value
1761// to the default value. Use the rawValue methods below to assign non enumerator
1762// values.
1763
Austin Schuh40c16522018-10-28 20:27:54 -07001764/**
1765 * Sets the value for the given key.
1766 *
1767 * @param value The value to set.
1768 * @param key The key under which to store the value.
1769 **/
1770- (void)setEnum:(int32_t)value forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001771
Austin Schuh40c16522018-10-28 20:27:54 -07001772/**
1773 * Sets the raw enum value for the given key.
1774 *
1775 * @note This method bypass the validationFunc to enable the setting of values that
1776 * were not known at the time the binary was compiled.
1777 *
1778 * @param rawValue The raw enum value to set.
1779 * @param key The key under which to store the raw enum value.
1780 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001781- (void)setRawValue:(int32_t)rawValue forKey:(int32_t)key;
1782
Austin Schuh40c16522018-10-28 20:27:54 -07001783/**
1784 * Removes the entry for the given key.
1785 *
1786 * @param aKey Key to be removed from this dictionary.
1787 **/
1788- (void)removeEnumForKey:(int32_t)aKey;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001789
Austin Schuh40c16522018-10-28 20:27:54 -07001790/**
1791 * Removes all entries in this dictionary.
1792 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001793- (void)removeAll;
1794
1795@end
1796
1797#pragma mark - Int32 -> Object
1798
Austin Schuh40c16522018-10-28 20:27:54 -07001799/**
1800 * Class used for map fields of <int32_t, ObjectType>
1801 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1802 *
1803 * @note This class is not meant to be subclassed.
1804 **/
1805@interface GPBInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
Brian Silverman9c614bc2016-02-15 20:20:02 -05001806
Austin Schuh40c16522018-10-28 20:27:54 -07001807/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05001808@property(nonatomic, readonly) NSUInteger count;
1809
Austin Schuh40c16522018-10-28 20:27:54 -07001810/**
1811 * Initializes this dictionary, copying the given values and keys.
1812 *
1813 * @param objects The values to be placed in this dictionary.
1814 * @param keys The keys under which to store the values.
1815 * @param count The number of elements to copy into the dictionary.
1816 *
1817 * @return A newly initialized dictionary with a copy of the values and keys.
1818 **/
1819- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
1820 forKeys:(const int32_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05001821 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07001822
1823/**
1824 * Initializes this dictionary, copying the entries from the given dictionary.
1825 *
1826 * @param dictionary Dictionary containing the entries to add to this dictionary.
1827 *
1828 * @return A newly initialized dictionary with the entries of the given dictionary.
1829 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001830- (instancetype)initWithDictionary:(GPBInt32ObjectDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07001831
1832/**
1833 * Initializes this dictionary with the requested capacity.
1834 *
1835 * @param numItems Number of items needed for this dictionary.
1836 *
1837 * @return A newly initialized dictionary with the requested capacity.
1838 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001839- (instancetype)initWithCapacity:(NSUInteger)numItems;
1840
Austin Schuh40c16522018-10-28 20:27:54 -07001841/**
1842 * Fetches the object stored under the given key.
1843 *
1844 * @param key Key under which the value is stored, if present.
1845 *
1846 * @return The object if found, nil otherwise.
1847 **/
1848- (ObjectType)objectForKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001849
Austin Schuh40c16522018-10-28 20:27:54 -07001850/**
1851 * Enumerates the keys and values on this dictionary with the given block.
1852 *
1853 * @param block The block to enumerate with.
1854 * **key**: The key for the current entry.
1855 * **object**: The value for the current entry
1856 * **stop**: A pointer to a boolean that when set stops the enumeration.
1857 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001858- (void)enumerateKeysAndObjectsUsingBlock:
Austin Schuh40c16522018-10-28 20:27:54 -07001859 (void (^)(int32_t key, ObjectType object, BOOL *stop))block;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001860
Austin Schuh40c16522018-10-28 20:27:54 -07001861/**
1862 * Adds the keys and values from another dictionary.
1863 *
1864 * @param otherDictionary Dictionary containing entries to be added to this
1865 * dictionary.
1866 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001867- (void)addEntriesFromDictionary:(GPBInt32ObjectDictionary *)otherDictionary;
1868
Austin Schuh40c16522018-10-28 20:27:54 -07001869/**
1870 * Sets the value for the given key.
1871 *
1872 * @param object The value to set.
1873 * @param key The key under which to store the value.
1874 **/
1875- (void)setObject:(ObjectType)object forKey:(int32_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001876
Austin Schuh40c16522018-10-28 20:27:54 -07001877/**
1878 * Removes the entry for the given key.
1879 *
1880 * @param aKey Key to be removed from this dictionary.
1881 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001882- (void)removeObjectForKey:(int32_t)aKey;
Austin Schuh40c16522018-10-28 20:27:54 -07001883
1884/**
1885 * Removes all entries in this dictionary.
1886 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001887- (void)removeAll;
1888
1889@end
1890
1891#pragma mark - UInt64 -> UInt32
1892
Austin Schuh40c16522018-10-28 20:27:54 -07001893/**
1894 * Class used for map fields of <uint64_t, uint32_t>
1895 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1896 *
1897 * @note This class is not meant to be subclassed.
1898 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001899@interface GPBUInt64UInt32Dictionary : NSObject <NSCopying>
1900
Austin Schuh40c16522018-10-28 20:27:54 -07001901/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05001902@property(nonatomic, readonly) NSUInteger count;
1903
Austin Schuh40c16522018-10-28 20:27:54 -07001904/**
1905 * Initializes this dictionary, copying the given values and keys.
1906 *
1907 * @param values The values to be placed in this dictionary.
1908 * @param keys The keys under which to store the values.
1909 * @param count The number of elements to copy into the dictionary.
1910 *
1911 * @return A newly initialized dictionary with a copy of the values and keys.
1912 **/
1913- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
1914 forKeys:(const uint64_t [__nullable])keys
1915 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001916
Austin Schuh40c16522018-10-28 20:27:54 -07001917/**
1918 * Initializes this dictionary, copying the entries from the given dictionary.
1919 *
1920 * @param dictionary Dictionary containing the entries to add to this dictionary.
1921 *
1922 * @return A newly initialized dictionary with the entries of the given dictionary.
1923 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001924- (instancetype)initWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07001925
1926/**
1927 * Initializes this dictionary with the requested capacity.
1928 *
1929 * @param numItems Number of items needed for this dictionary.
1930 *
1931 * @return A newly initialized dictionary with the requested capacity.
1932 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001933- (instancetype)initWithCapacity:(NSUInteger)numItems;
1934
Austin Schuh40c16522018-10-28 20:27:54 -07001935/**
1936 * Gets the value for the given key.
1937 *
1938 * @param value Pointer into which the value will be set, if found.
1939 * @param key Key under which the value is stored, if present.
1940 *
1941 * @return YES if the key was found and the value was copied, NO otherwise.
1942 **/
1943- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001944
Austin Schuh40c16522018-10-28 20:27:54 -07001945/**
1946 * Enumerates the keys and values on this dictionary with the given block.
1947 *
1948 * @param block The block to enumerate with.
1949 * **key**: The key for the current entry.
1950 * **value**: The value for the current entry
1951 * **stop**: A pointer to a boolean that when set stops the enumeration.
1952 **/
1953- (void)enumerateKeysAndUInt32sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05001954 (void (^)(uint64_t key, uint32_t value, BOOL *stop))block;
1955
Austin Schuh40c16522018-10-28 20:27:54 -07001956/**
1957 * Adds the keys and values from another dictionary.
1958 *
1959 * @param otherDictionary Dictionary containing entries to be added to this
1960 * dictionary.
1961 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001962- (void)addEntriesFromDictionary:(GPBUInt64UInt32Dictionary *)otherDictionary;
1963
Austin Schuh40c16522018-10-28 20:27:54 -07001964/**
1965 * Sets the value for the given key.
1966 *
1967 * @param value The value to set.
1968 * @param key The key under which to store the value.
1969 **/
1970- (void)setUInt32:(uint32_t)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05001971
Austin Schuh40c16522018-10-28 20:27:54 -07001972/**
1973 * Removes the entry for the given key.
1974 *
1975 * @param aKey Key to be removed from this dictionary.
1976 **/
1977- (void)removeUInt32ForKey:(uint64_t)aKey;
1978
1979/**
1980 * Removes all entries in this dictionary.
1981 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001982- (void)removeAll;
1983
1984@end
1985
1986#pragma mark - UInt64 -> Int32
1987
Austin Schuh40c16522018-10-28 20:27:54 -07001988/**
1989 * Class used for map fields of <uint64_t, int32_t>
1990 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1991 *
1992 * @note This class is not meant to be subclassed.
1993 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05001994@interface GPBUInt64Int32Dictionary : NSObject <NSCopying>
1995
Austin Schuh40c16522018-10-28 20:27:54 -07001996/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05001997@property(nonatomic, readonly) NSUInteger count;
1998
Austin Schuh40c16522018-10-28 20:27:54 -07001999/**
2000 * Initializes this dictionary, copying the given values and keys.
2001 *
2002 * @param values The values to be placed in this dictionary.
2003 * @param keys The keys under which to store the values.
2004 * @param count The number of elements to copy into the dictionary.
2005 *
2006 * @return A newly initialized dictionary with a copy of the values and keys.
2007 **/
2008- (instancetype)initWithInt32s:(const int32_t [__nullable])values
2009 forKeys:(const uint64_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05002010 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07002011
2012/**
2013 * Initializes this dictionary, copying the entries from the given dictionary.
2014 *
2015 * @param dictionary Dictionary containing the entries to add to this dictionary.
2016 *
2017 * @return A newly initialized dictionary with the entries of the given dictionary.
2018 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002019- (instancetype)initWithDictionary:(GPBUInt64Int32Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07002020
2021/**
2022 * Initializes this dictionary with the requested capacity.
2023 *
2024 * @param numItems Number of items needed for this dictionary.
2025 *
2026 * @return A newly initialized dictionary with the requested capacity.
2027 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002028- (instancetype)initWithCapacity:(NSUInteger)numItems;
2029
Austin Schuh40c16522018-10-28 20:27:54 -07002030/**
2031 * Gets the value for the given key.
2032 *
2033 * @param value Pointer into which the value will be set, if found.
2034 * @param key Key under which the value is stored, if present.
2035 *
2036 * @return YES if the key was found and the value was copied, NO otherwise.
2037 **/
2038- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002039
Austin Schuh40c16522018-10-28 20:27:54 -07002040/**
2041 * Enumerates the keys and values on this dictionary with the given block.
2042 *
2043 * @param block The block to enumerate with.
2044 * **key**: The key for the current entry.
2045 * **value**: The value for the current entry
2046 * **stop**: A pointer to a boolean that when set stops the enumeration.
2047 **/
2048- (void)enumerateKeysAndInt32sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05002049 (void (^)(uint64_t key, int32_t value, BOOL *stop))block;
2050
Austin Schuh40c16522018-10-28 20:27:54 -07002051/**
2052 * Adds the keys and values from another dictionary.
2053 *
2054 * @param otherDictionary Dictionary containing entries to be added to this
2055 * dictionary.
2056 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002057- (void)addEntriesFromDictionary:(GPBUInt64Int32Dictionary *)otherDictionary;
2058
Austin Schuh40c16522018-10-28 20:27:54 -07002059/**
2060 * Sets the value for the given key.
2061 *
2062 * @param value The value to set.
2063 * @param key The key under which to store the value.
2064 **/
2065- (void)setInt32:(int32_t)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002066
Austin Schuh40c16522018-10-28 20:27:54 -07002067/**
2068 * Removes the entry for the given key.
2069 *
2070 * @param aKey Key to be removed from this dictionary.
2071 **/
2072- (void)removeInt32ForKey:(uint64_t)aKey;
2073
2074/**
2075 * Removes all entries in this dictionary.
2076 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002077- (void)removeAll;
2078
2079@end
2080
2081#pragma mark - UInt64 -> UInt64
2082
Austin Schuh40c16522018-10-28 20:27:54 -07002083/**
2084 * Class used for map fields of <uint64_t, uint64_t>
2085 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2086 *
2087 * @note This class is not meant to be subclassed.
2088 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002089@interface GPBUInt64UInt64Dictionary : NSObject <NSCopying>
2090
Austin Schuh40c16522018-10-28 20:27:54 -07002091/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05002092@property(nonatomic, readonly) NSUInteger count;
2093
Austin Schuh40c16522018-10-28 20:27:54 -07002094/**
2095 * Initializes this dictionary, copying the given values and keys.
2096 *
2097 * @param values The values to be placed in this dictionary.
2098 * @param keys The keys under which to store the values.
2099 * @param count The number of elements to copy into the dictionary.
2100 *
2101 * @return A newly initialized dictionary with a copy of the values and keys.
2102 **/
2103- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
2104 forKeys:(const uint64_t [__nullable])keys
2105 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002106
Austin Schuh40c16522018-10-28 20:27:54 -07002107/**
2108 * Initializes this dictionary, copying the entries from the given dictionary.
2109 *
2110 * @param dictionary Dictionary containing the entries to add to this dictionary.
2111 *
2112 * @return A newly initialized dictionary with the entries of the given dictionary.
2113 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002114- (instancetype)initWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07002115
2116/**
2117 * Initializes this dictionary with the requested capacity.
2118 *
2119 * @param numItems Number of items needed for this dictionary.
2120 *
2121 * @return A newly initialized dictionary with the requested capacity.
2122 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002123- (instancetype)initWithCapacity:(NSUInteger)numItems;
2124
Austin Schuh40c16522018-10-28 20:27:54 -07002125/**
2126 * Gets the value for the given key.
2127 *
2128 * @param value Pointer into which the value will be set, if found.
2129 * @param key Key under which the value is stored, if present.
2130 *
2131 * @return YES if the key was found and the value was copied, NO otherwise.
2132 **/
2133- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002134
Austin Schuh40c16522018-10-28 20:27:54 -07002135/**
2136 * Enumerates the keys and values on this dictionary with the given block.
2137 *
2138 * @param block The block to enumerate with.
2139 * **key**: The key for the current entry.
2140 * **value**: The value for the current entry
2141 * **stop**: A pointer to a boolean that when set stops the enumeration.
2142 **/
2143- (void)enumerateKeysAndUInt64sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05002144 (void (^)(uint64_t key, uint64_t value, BOOL *stop))block;
2145
Austin Schuh40c16522018-10-28 20:27:54 -07002146/**
2147 * Adds the keys and values from another dictionary.
2148 *
2149 * @param otherDictionary Dictionary containing entries to be added to this
2150 * dictionary.
2151 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002152- (void)addEntriesFromDictionary:(GPBUInt64UInt64Dictionary *)otherDictionary;
2153
Austin Schuh40c16522018-10-28 20:27:54 -07002154/**
2155 * Sets the value for the given key.
2156 *
2157 * @param value The value to set.
2158 * @param key The key under which to store the value.
2159 **/
2160- (void)setUInt64:(uint64_t)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002161
Austin Schuh40c16522018-10-28 20:27:54 -07002162/**
2163 * Removes the entry for the given key.
2164 *
2165 * @param aKey Key to be removed from this dictionary.
2166 **/
2167- (void)removeUInt64ForKey:(uint64_t)aKey;
2168
2169/**
2170 * Removes all entries in this dictionary.
2171 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002172- (void)removeAll;
2173
2174@end
2175
2176#pragma mark - UInt64 -> Int64
2177
Austin Schuh40c16522018-10-28 20:27:54 -07002178/**
2179 * Class used for map fields of <uint64_t, int64_t>
2180 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2181 *
2182 * @note This class is not meant to be subclassed.
2183 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002184@interface GPBUInt64Int64Dictionary : NSObject <NSCopying>
2185
Austin Schuh40c16522018-10-28 20:27:54 -07002186/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05002187@property(nonatomic, readonly) NSUInteger count;
2188
Austin Schuh40c16522018-10-28 20:27:54 -07002189/**
2190 * Initializes this dictionary, copying the given values and keys.
2191 *
2192 * @param values The values to be placed in this dictionary.
2193 * @param keys The keys under which to store the values.
2194 * @param count The number of elements to copy into the dictionary.
2195 *
2196 * @return A newly initialized dictionary with a copy of the values and keys.
2197 **/
2198- (instancetype)initWithInt64s:(const int64_t [__nullable])values
2199 forKeys:(const uint64_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05002200 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07002201
2202/**
2203 * Initializes this dictionary, copying the entries from the given dictionary.
2204 *
2205 * @param dictionary Dictionary containing the entries to add to this dictionary.
2206 *
2207 * @return A newly initialized dictionary with the entries of the given dictionary.
2208 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002209- (instancetype)initWithDictionary:(GPBUInt64Int64Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07002210
2211/**
2212 * Initializes this dictionary with the requested capacity.
2213 *
2214 * @param numItems Number of items needed for this dictionary.
2215 *
2216 * @return A newly initialized dictionary with the requested capacity.
2217 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002218- (instancetype)initWithCapacity:(NSUInteger)numItems;
2219
Austin Schuh40c16522018-10-28 20:27:54 -07002220/**
2221 * Gets the value for the given key.
2222 *
2223 * @param value Pointer into which the value will be set, if found.
2224 * @param key Key under which the value is stored, if present.
2225 *
2226 * @return YES if the key was found and the value was copied, NO otherwise.
2227 **/
2228- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002229
Austin Schuh40c16522018-10-28 20:27:54 -07002230/**
2231 * Enumerates the keys and values on this dictionary with the given block.
2232 *
2233 * @param block The block to enumerate with.
2234 * **key**: The key for the current entry.
2235 * **value**: The value for the current entry
2236 * **stop**: A pointer to a boolean that when set stops the enumeration.
2237 **/
2238- (void)enumerateKeysAndInt64sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05002239 (void (^)(uint64_t key, int64_t value, BOOL *stop))block;
2240
Austin Schuh40c16522018-10-28 20:27:54 -07002241/**
2242 * Adds the keys and values from another dictionary.
2243 *
2244 * @param otherDictionary Dictionary containing entries to be added to this
2245 * dictionary.
2246 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002247- (void)addEntriesFromDictionary:(GPBUInt64Int64Dictionary *)otherDictionary;
2248
Austin Schuh40c16522018-10-28 20:27:54 -07002249/**
2250 * Sets the value for the given key.
2251 *
2252 * @param value The value to set.
2253 * @param key The key under which to store the value.
2254 **/
2255- (void)setInt64:(int64_t)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002256
Austin Schuh40c16522018-10-28 20:27:54 -07002257/**
2258 * Removes the entry for the given key.
2259 *
2260 * @param aKey Key to be removed from this dictionary.
2261 **/
2262- (void)removeInt64ForKey:(uint64_t)aKey;
2263
2264/**
2265 * Removes all entries in this dictionary.
2266 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002267- (void)removeAll;
2268
2269@end
2270
2271#pragma mark - UInt64 -> Bool
2272
Austin Schuh40c16522018-10-28 20:27:54 -07002273/**
2274 * Class used for map fields of <uint64_t, BOOL>
2275 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2276 *
2277 * @note This class is not meant to be subclassed.
2278 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002279@interface GPBUInt64BoolDictionary : NSObject <NSCopying>
2280
Austin Schuh40c16522018-10-28 20:27:54 -07002281/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05002282@property(nonatomic, readonly) NSUInteger count;
2283
Austin Schuh40c16522018-10-28 20:27:54 -07002284/**
2285 * Initializes this dictionary, copying the given values and keys.
2286 *
2287 * @param values The values to be placed in this dictionary.
2288 * @param keys The keys under which to store the values.
2289 * @param count The number of elements to copy into the dictionary.
2290 *
2291 * @return A newly initialized dictionary with a copy of the values and keys.
2292 **/
2293- (instancetype)initWithBools:(const BOOL [__nullable])values
2294 forKeys:(const uint64_t [__nullable])keys
2295 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002296
Austin Schuh40c16522018-10-28 20:27:54 -07002297/**
2298 * Initializes this dictionary, copying the entries from the given dictionary.
2299 *
2300 * @param dictionary Dictionary containing the entries to add to this dictionary.
2301 *
2302 * @return A newly initialized dictionary with the entries of the given dictionary.
2303 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002304- (instancetype)initWithDictionary:(GPBUInt64BoolDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07002305
2306/**
2307 * Initializes this dictionary with the requested capacity.
2308 *
2309 * @param numItems Number of items needed for this dictionary.
2310 *
2311 * @return A newly initialized dictionary with the requested capacity.
2312 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002313- (instancetype)initWithCapacity:(NSUInteger)numItems;
2314
Austin Schuh40c16522018-10-28 20:27:54 -07002315/**
2316 * Gets the value for the given key.
2317 *
2318 * @param value Pointer into which the value will be set, if found.
2319 * @param key Key under which the value is stored, if present.
2320 *
2321 * @return YES if the key was found and the value was copied, NO otherwise.
2322 **/
2323- (BOOL)getBool:(nullable BOOL *)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002324
Austin Schuh40c16522018-10-28 20:27:54 -07002325/**
2326 * Enumerates the keys and values on this dictionary with the given block.
2327 *
2328 * @param block The block to enumerate with.
2329 * **key**: The key for the current entry.
2330 * **value**: The value for the current entry
2331 * **stop**: A pointer to a boolean that when set stops the enumeration.
2332 **/
2333- (void)enumerateKeysAndBoolsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05002334 (void (^)(uint64_t key, BOOL value, BOOL *stop))block;
2335
Austin Schuh40c16522018-10-28 20:27:54 -07002336/**
2337 * Adds the keys and values from another dictionary.
2338 *
2339 * @param otherDictionary Dictionary containing entries to be added to this
2340 * dictionary.
2341 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002342- (void)addEntriesFromDictionary:(GPBUInt64BoolDictionary *)otherDictionary;
2343
Austin Schuh40c16522018-10-28 20:27:54 -07002344/**
2345 * Sets the value for the given key.
2346 *
2347 * @param value The value to set.
2348 * @param key The key under which to store the value.
2349 **/
2350- (void)setBool:(BOOL)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002351
Austin Schuh40c16522018-10-28 20:27:54 -07002352/**
2353 * Removes the entry for the given key.
2354 *
2355 * @param aKey Key to be removed from this dictionary.
2356 **/
2357- (void)removeBoolForKey:(uint64_t)aKey;
2358
2359/**
2360 * Removes all entries in this dictionary.
2361 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002362- (void)removeAll;
2363
2364@end
2365
2366#pragma mark - UInt64 -> Float
2367
Austin Schuh40c16522018-10-28 20:27:54 -07002368/**
2369 * Class used for map fields of <uint64_t, float>
2370 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2371 *
2372 * @note This class is not meant to be subclassed.
2373 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002374@interface GPBUInt64FloatDictionary : NSObject <NSCopying>
2375
Austin Schuh40c16522018-10-28 20:27:54 -07002376/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05002377@property(nonatomic, readonly) NSUInteger count;
2378
Austin Schuh40c16522018-10-28 20:27:54 -07002379/**
2380 * Initializes this dictionary, copying the given values and keys.
2381 *
2382 * @param values The values to be placed in this dictionary.
2383 * @param keys The keys under which to store the values.
2384 * @param count The number of elements to copy into the dictionary.
2385 *
2386 * @return A newly initialized dictionary with a copy of the values and keys.
2387 **/
2388- (instancetype)initWithFloats:(const float [__nullable])values
2389 forKeys:(const uint64_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05002390 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07002391
2392/**
2393 * Initializes this dictionary, copying the entries from the given dictionary.
2394 *
2395 * @param dictionary Dictionary containing the entries to add to this dictionary.
2396 *
2397 * @return A newly initialized dictionary with the entries of the given dictionary.
2398 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002399- (instancetype)initWithDictionary:(GPBUInt64FloatDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07002400
2401/**
2402 * Initializes this dictionary with the requested capacity.
2403 *
2404 * @param numItems Number of items needed for this dictionary.
2405 *
2406 * @return A newly initialized dictionary with the requested capacity.
2407 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002408- (instancetype)initWithCapacity:(NSUInteger)numItems;
2409
Austin Schuh40c16522018-10-28 20:27:54 -07002410/**
2411 * Gets the value for the given key.
2412 *
2413 * @param value Pointer into which the value will be set, if found.
2414 * @param key Key under which the value is stored, if present.
2415 *
2416 * @return YES if the key was found and the value was copied, NO otherwise.
2417 **/
2418- (BOOL)getFloat:(nullable float *)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002419
Austin Schuh40c16522018-10-28 20:27:54 -07002420/**
2421 * Enumerates the keys and values on this dictionary with the given block.
2422 *
2423 * @param block The block to enumerate with.
2424 * **key**: The key for the current entry.
2425 * **value**: The value for the current entry
2426 * **stop**: A pointer to a boolean that when set stops the enumeration.
2427 **/
2428- (void)enumerateKeysAndFloatsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05002429 (void (^)(uint64_t key, float value, BOOL *stop))block;
2430
Austin Schuh40c16522018-10-28 20:27:54 -07002431/**
2432 * Adds the keys and values from another dictionary.
2433 *
2434 * @param otherDictionary Dictionary containing entries to be added to this
2435 * dictionary.
2436 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002437- (void)addEntriesFromDictionary:(GPBUInt64FloatDictionary *)otherDictionary;
2438
Austin Schuh40c16522018-10-28 20:27:54 -07002439/**
2440 * Sets the value for the given key.
2441 *
2442 * @param value The value to set.
2443 * @param key The key under which to store the value.
2444 **/
2445- (void)setFloat:(float)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002446
Austin Schuh40c16522018-10-28 20:27:54 -07002447/**
2448 * Removes the entry for the given key.
2449 *
2450 * @param aKey Key to be removed from this dictionary.
2451 **/
2452- (void)removeFloatForKey:(uint64_t)aKey;
2453
2454/**
2455 * Removes all entries in this dictionary.
2456 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002457- (void)removeAll;
2458
2459@end
2460
2461#pragma mark - UInt64 -> Double
2462
Austin Schuh40c16522018-10-28 20:27:54 -07002463/**
2464 * Class used for map fields of <uint64_t, double>
2465 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2466 *
2467 * @note This class is not meant to be subclassed.
2468 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002469@interface GPBUInt64DoubleDictionary : NSObject <NSCopying>
2470
Austin Schuh40c16522018-10-28 20:27:54 -07002471/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05002472@property(nonatomic, readonly) NSUInteger count;
2473
Austin Schuh40c16522018-10-28 20:27:54 -07002474/**
2475 * Initializes this dictionary, copying the given values and keys.
2476 *
2477 * @param values The values to be placed in this dictionary.
2478 * @param keys The keys under which to store the values.
2479 * @param count The number of elements to copy into the dictionary.
2480 *
2481 * @return A newly initialized dictionary with a copy of the values and keys.
2482 **/
2483- (instancetype)initWithDoubles:(const double [__nullable])values
2484 forKeys:(const uint64_t [__nullable])keys
2485 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002486
Austin Schuh40c16522018-10-28 20:27:54 -07002487/**
2488 * Initializes this dictionary, copying the entries from the given dictionary.
2489 *
2490 * @param dictionary Dictionary containing the entries to add to this dictionary.
2491 *
2492 * @return A newly initialized dictionary with the entries of the given dictionary.
2493 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002494- (instancetype)initWithDictionary:(GPBUInt64DoubleDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07002495
2496/**
2497 * Initializes this dictionary with the requested capacity.
2498 *
2499 * @param numItems Number of items needed for this dictionary.
2500 *
2501 * @return A newly initialized dictionary with the requested capacity.
2502 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002503- (instancetype)initWithCapacity:(NSUInteger)numItems;
2504
Austin Schuh40c16522018-10-28 20:27:54 -07002505/**
2506 * Gets the value for the given key.
2507 *
2508 * @param value Pointer into which the value will be set, if found.
2509 * @param key Key under which the value is stored, if present.
2510 *
2511 * @return YES if the key was found and the value was copied, NO otherwise.
2512 **/
2513- (BOOL)getDouble:(nullable double *)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002514
Austin Schuh40c16522018-10-28 20:27:54 -07002515/**
2516 * Enumerates the keys and values on this dictionary with the given block.
2517 *
2518 * @param block The block to enumerate with.
2519 * **key**: The key for the current entry.
2520 * **value**: The value for the current entry
2521 * **stop**: A pointer to a boolean that when set stops the enumeration.
2522 **/
2523- (void)enumerateKeysAndDoublesUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05002524 (void (^)(uint64_t key, double value, BOOL *stop))block;
2525
Austin Schuh40c16522018-10-28 20:27:54 -07002526/**
2527 * Adds the keys and values from another dictionary.
2528 *
2529 * @param otherDictionary Dictionary containing entries to be added to this
2530 * dictionary.
2531 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002532- (void)addEntriesFromDictionary:(GPBUInt64DoubleDictionary *)otherDictionary;
2533
Austin Schuh40c16522018-10-28 20:27:54 -07002534/**
2535 * Sets the value for the given key.
2536 *
2537 * @param value The value to set.
2538 * @param key The key under which to store the value.
2539 **/
2540- (void)setDouble:(double)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002541
Austin Schuh40c16522018-10-28 20:27:54 -07002542/**
2543 * Removes the entry for the given key.
2544 *
2545 * @param aKey Key to be removed from this dictionary.
2546 **/
2547- (void)removeDoubleForKey:(uint64_t)aKey;
2548
2549/**
2550 * Removes all entries in this dictionary.
2551 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002552- (void)removeAll;
2553
2554@end
2555
2556#pragma mark - UInt64 -> Enum
2557
Austin Schuh40c16522018-10-28 20:27:54 -07002558/**
2559 * Class used for map fields of <uint64_t, int32_t>
2560 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2561 *
2562 * @note This class is not meant to be subclassed.
2563 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002564@interface GPBUInt64EnumDictionary : NSObject <NSCopying>
2565
Austin Schuh40c16522018-10-28 20:27:54 -07002566/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05002567@property(nonatomic, readonly) NSUInteger count;
Austin Schuh40c16522018-10-28 20:27:54 -07002568/** The validation function to check if the enums are valid. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05002569@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
2570
Austin Schuh40c16522018-10-28 20:27:54 -07002571/**
2572 * Initializes a dictionary with the given validation function.
2573 *
2574 * @param func The enum validation function for the dictionary.
2575 *
2576 * @return A newly initialized dictionary.
2577 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002578- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Austin Schuh40c16522018-10-28 20:27:54 -07002579
2580/**
2581 * Initializes a dictionary with the entries given.
2582 *
2583 * @param func The enum validation function for the dictionary.
2584 * @param values The raw enum values values to be placed in the dictionary.
2585 * @param keys The keys under which to store the values.
2586 * @param count The number of entries to store in the dictionary.
2587 *
2588 * @return A newly initialized dictionary with the keys and values in it.
2589 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002590- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Austin Schuh40c16522018-10-28 20:27:54 -07002591 rawValues:(const int32_t [__nullable])values
2592 forKeys:(const uint64_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05002593 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07002594
2595/**
2596 * Initializes a dictionary with the entries from the given.
2597 * dictionary.
2598 *
2599 * @param dictionary Dictionary containing the entries to add to the dictionary.
2600 *
2601 * @return A newly initialized dictionary with the entries from the given
2602 * dictionary in it.
2603 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002604- (instancetype)initWithDictionary:(GPBUInt64EnumDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07002605
2606/**
2607 * Initializes a dictionary with the given capacity.
2608 *
2609 * @param func The enum validation function for the dictionary.
2610 * @param numItems Capacity needed for the dictionary.
2611 *
2612 * @return A newly initialized dictionary with the given capacity.
2613 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002614- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
2615 capacity:(NSUInteger)numItems;
2616
2617// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
2618// is not a valid enumerator as defined by validationFunc. If the actual value is
2619// desired, use "raw" version of the method.
2620
Austin Schuh40c16522018-10-28 20:27:54 -07002621/**
2622 * Gets the value for the given key.
2623 *
2624 * @param value Pointer into which the value will be set, if found.
2625 * @param key Key under which the value is stored, if present.
2626 *
2627 * @return YES if the key was found and the value was copied, NO otherwise.
2628 **/
2629- (BOOL)getEnum:(nullable int32_t *)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002630
Austin Schuh40c16522018-10-28 20:27:54 -07002631/**
2632 * Enumerates the keys and values on this dictionary with the given block.
2633 *
2634 * @param block The block to enumerate with.
2635 * **key**: The key for the current entry.
2636 * **value**: The value for the current entry
2637 * **stop**: A pointer to a boolean that when set stops the enumeration.
2638 **/
2639- (void)enumerateKeysAndEnumsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05002640 (void (^)(uint64_t key, int32_t value, BOOL *stop))block;
2641
Austin Schuh40c16522018-10-28 20:27:54 -07002642/**
2643 * Gets the raw enum value for the given key.
2644 *
2645 * @note This method bypass the validationFunc to enable the access of values that
2646 * were not known at the time the binary was compiled.
2647 *
2648 * @param rawValue Pointer into which the value will be set, if found.
2649 * @param key Key under which the value is stored, if present.
2650 *
2651 * @return YES if the key was found and the value was copied, NO otherwise.
2652 **/
2653- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002654
Austin Schuh40c16522018-10-28 20:27:54 -07002655/**
2656 * Enumerates the keys and values on this dictionary with the given block.
2657 *
2658 * @note This method bypass the validationFunc to enable the access of values that
2659 * were not known at the time the binary was compiled.
2660 *
2661 * @param block The block to enumerate with.
2662 * **key**: The key for the current entry.
2663 * **rawValue**: The value for the current entry
2664 * **stop**: A pointer to a boolean that when set stops the enumeration.
2665 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002666- (void)enumerateKeysAndRawValuesUsingBlock:
2667 (void (^)(uint64_t key, int32_t rawValue, BOOL *stop))block;
2668
Austin Schuh40c16522018-10-28 20:27:54 -07002669/**
2670 * Adds the keys and raw enum values from another dictionary.
2671 *
2672 * @note This method bypass the validationFunc to enable the setting of values that
2673 * were not known at the time the binary was compiled.
2674 *
2675 * @param otherDictionary Dictionary containing entries to be added to this
2676 * dictionary.
2677 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002678- (void)addRawEntriesFromDictionary:(GPBUInt64EnumDictionary *)otherDictionary;
2679
2680// If value is not a valid enumerator as defined by validationFunc, these
2681// methods will assert in debug, and will log in release and assign the value
2682// to the default value. Use the rawValue methods below to assign non enumerator
2683// values.
2684
Austin Schuh40c16522018-10-28 20:27:54 -07002685/**
2686 * Sets the value for the given key.
2687 *
2688 * @param value The value to set.
2689 * @param key The key under which to store the value.
2690 **/
2691- (void)setEnum:(int32_t)value forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002692
Austin Schuh40c16522018-10-28 20:27:54 -07002693/**
2694 * Sets the raw enum value for the given key.
2695 *
2696 * @note This method bypass the validationFunc to enable the setting of values that
2697 * were not known at the time the binary was compiled.
2698 *
2699 * @param rawValue The raw enum value to set.
2700 * @param key The key under which to store the raw enum value.
2701 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002702- (void)setRawValue:(int32_t)rawValue forKey:(uint64_t)key;
2703
Austin Schuh40c16522018-10-28 20:27:54 -07002704/**
2705 * Removes the entry for the given key.
2706 *
2707 * @param aKey Key to be removed from this dictionary.
2708 **/
2709- (void)removeEnumForKey:(uint64_t)aKey;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002710
Austin Schuh40c16522018-10-28 20:27:54 -07002711/**
2712 * Removes all entries in this dictionary.
2713 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002714- (void)removeAll;
2715
2716@end
2717
2718#pragma mark - UInt64 -> Object
2719
Austin Schuh40c16522018-10-28 20:27:54 -07002720/**
2721 * Class used for map fields of <uint64_t, ObjectType>
2722 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2723 *
2724 * @note This class is not meant to be subclassed.
2725 **/
2726@interface GPBUInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
Brian Silverman9c614bc2016-02-15 20:20:02 -05002727
Austin Schuh40c16522018-10-28 20:27:54 -07002728/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05002729@property(nonatomic, readonly) NSUInteger count;
2730
Austin Schuh40c16522018-10-28 20:27:54 -07002731/**
2732 * Initializes this dictionary, copying the given values and keys.
2733 *
2734 * @param objects The values to be placed in this dictionary.
2735 * @param keys The keys under which to store the values.
2736 * @param count The number of elements to copy into the dictionary.
2737 *
2738 * @return A newly initialized dictionary with a copy of the values and keys.
2739 **/
2740- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
2741 forKeys:(const uint64_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05002742 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07002743
2744/**
2745 * Initializes this dictionary, copying the entries from the given dictionary.
2746 *
2747 * @param dictionary Dictionary containing the entries to add to this dictionary.
2748 *
2749 * @return A newly initialized dictionary with the entries of the given dictionary.
2750 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002751- (instancetype)initWithDictionary:(GPBUInt64ObjectDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07002752
2753/**
2754 * Initializes this dictionary with the requested capacity.
2755 *
2756 * @param numItems Number of items needed for this dictionary.
2757 *
2758 * @return A newly initialized dictionary with the requested capacity.
2759 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002760- (instancetype)initWithCapacity:(NSUInteger)numItems;
2761
Austin Schuh40c16522018-10-28 20:27:54 -07002762/**
2763 * Fetches the object stored under the given key.
2764 *
2765 * @param key Key under which the value is stored, if present.
2766 *
2767 * @return The object if found, nil otherwise.
2768 **/
2769- (ObjectType)objectForKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002770
Austin Schuh40c16522018-10-28 20:27:54 -07002771/**
2772 * Enumerates the keys and values on this dictionary with the given block.
2773 *
2774 * @param block The block to enumerate with.
2775 * **key**: The key for the current entry.
2776 * **object**: The value for the current entry
2777 * **stop**: A pointer to a boolean that when set stops the enumeration.
2778 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002779- (void)enumerateKeysAndObjectsUsingBlock:
Austin Schuh40c16522018-10-28 20:27:54 -07002780 (void (^)(uint64_t key, ObjectType object, BOOL *stop))block;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002781
Austin Schuh40c16522018-10-28 20:27:54 -07002782/**
2783 * Adds the keys and values from another dictionary.
2784 *
2785 * @param otherDictionary Dictionary containing entries to be added to this
2786 * dictionary.
2787 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002788- (void)addEntriesFromDictionary:(GPBUInt64ObjectDictionary *)otherDictionary;
2789
Austin Schuh40c16522018-10-28 20:27:54 -07002790/**
2791 * Sets the value for the given key.
2792 *
2793 * @param object The value to set.
2794 * @param key The key under which to store the value.
2795 **/
2796- (void)setObject:(ObjectType)object forKey:(uint64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002797
Austin Schuh40c16522018-10-28 20:27:54 -07002798/**
2799 * Removes the entry for the given key.
2800 *
2801 * @param aKey Key to be removed from this dictionary.
2802 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002803- (void)removeObjectForKey:(uint64_t)aKey;
Austin Schuh40c16522018-10-28 20:27:54 -07002804
2805/**
2806 * Removes all entries in this dictionary.
2807 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002808- (void)removeAll;
2809
2810@end
2811
2812#pragma mark - Int64 -> UInt32
2813
Austin Schuh40c16522018-10-28 20:27:54 -07002814/**
2815 * Class used for map fields of <int64_t, uint32_t>
2816 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2817 *
2818 * @note This class is not meant to be subclassed.
2819 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002820@interface GPBInt64UInt32Dictionary : NSObject <NSCopying>
2821
Austin Schuh40c16522018-10-28 20:27:54 -07002822/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05002823@property(nonatomic, readonly) NSUInteger count;
2824
Austin Schuh40c16522018-10-28 20:27:54 -07002825/**
2826 * Initializes this dictionary, copying the given values and keys.
2827 *
2828 * @param values The values to be placed in this dictionary.
2829 * @param keys The keys under which to store the values.
2830 * @param count The number of elements to copy into the dictionary.
2831 *
2832 * @return A newly initialized dictionary with a copy of the values and keys.
2833 **/
2834- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
2835 forKeys:(const int64_t [__nullable])keys
2836 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002837
Austin Schuh40c16522018-10-28 20:27:54 -07002838/**
2839 * Initializes this dictionary, copying the entries from the given dictionary.
2840 *
2841 * @param dictionary Dictionary containing the entries to add to this dictionary.
2842 *
2843 * @return A newly initialized dictionary with the entries of the given dictionary.
2844 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002845- (instancetype)initWithDictionary:(GPBInt64UInt32Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07002846
2847/**
2848 * Initializes this dictionary with the requested capacity.
2849 *
2850 * @param numItems Number of items needed for this dictionary.
2851 *
2852 * @return A newly initialized dictionary with the requested capacity.
2853 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002854- (instancetype)initWithCapacity:(NSUInteger)numItems;
2855
Austin Schuh40c16522018-10-28 20:27:54 -07002856/**
2857 * Gets the value for the given key.
2858 *
2859 * @param value Pointer into which the value will be set, if found.
2860 * @param key Key under which the value is stored, if present.
2861 *
2862 * @return YES if the key was found and the value was copied, NO otherwise.
2863 **/
2864- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002865
Austin Schuh40c16522018-10-28 20:27:54 -07002866/**
2867 * Enumerates the keys and values on this dictionary with the given block.
2868 *
2869 * @param block The block to enumerate with.
2870 * **key**: The key for the current entry.
2871 * **value**: The value for the current entry
2872 * **stop**: A pointer to a boolean that when set stops the enumeration.
2873 **/
2874- (void)enumerateKeysAndUInt32sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05002875 (void (^)(int64_t key, uint32_t value, BOOL *stop))block;
2876
Austin Schuh40c16522018-10-28 20:27:54 -07002877/**
2878 * Adds the keys and values from another dictionary.
2879 *
2880 * @param otherDictionary Dictionary containing entries to be added to this
2881 * dictionary.
2882 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002883- (void)addEntriesFromDictionary:(GPBInt64UInt32Dictionary *)otherDictionary;
2884
Austin Schuh40c16522018-10-28 20:27:54 -07002885/**
2886 * Sets the value for the given key.
2887 *
2888 * @param value The value to set.
2889 * @param key The key under which to store the value.
2890 **/
2891- (void)setUInt32:(uint32_t)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002892
Austin Schuh40c16522018-10-28 20:27:54 -07002893/**
2894 * Removes the entry for the given key.
2895 *
2896 * @param aKey Key to be removed from this dictionary.
2897 **/
2898- (void)removeUInt32ForKey:(int64_t)aKey;
2899
2900/**
2901 * Removes all entries in this dictionary.
2902 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002903- (void)removeAll;
2904
2905@end
2906
2907#pragma mark - Int64 -> Int32
2908
Austin Schuh40c16522018-10-28 20:27:54 -07002909/**
2910 * Class used for map fields of <int64_t, int32_t>
2911 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2912 *
2913 * @note This class is not meant to be subclassed.
2914 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002915@interface GPBInt64Int32Dictionary : NSObject <NSCopying>
2916
Austin Schuh40c16522018-10-28 20:27:54 -07002917/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05002918@property(nonatomic, readonly) NSUInteger count;
2919
Austin Schuh40c16522018-10-28 20:27:54 -07002920/**
2921 * Initializes this dictionary, copying the given values and keys.
2922 *
2923 * @param values The values to be placed in this dictionary.
2924 * @param keys The keys under which to store the values.
2925 * @param count The number of elements to copy into the dictionary.
2926 *
2927 * @return A newly initialized dictionary with a copy of the values and keys.
2928 **/
2929- (instancetype)initWithInt32s:(const int32_t [__nullable])values
2930 forKeys:(const int64_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05002931 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07002932
2933/**
2934 * Initializes this dictionary, copying the entries from the given dictionary.
2935 *
2936 * @param dictionary Dictionary containing the entries to add to this dictionary.
2937 *
2938 * @return A newly initialized dictionary with the entries of the given dictionary.
2939 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002940- (instancetype)initWithDictionary:(GPBInt64Int32Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07002941
2942/**
2943 * Initializes this dictionary with the requested capacity.
2944 *
2945 * @param numItems Number of items needed for this dictionary.
2946 *
2947 * @return A newly initialized dictionary with the requested capacity.
2948 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002949- (instancetype)initWithCapacity:(NSUInteger)numItems;
2950
Austin Schuh40c16522018-10-28 20:27:54 -07002951/**
2952 * Gets the value for the given key.
2953 *
2954 * @param value Pointer into which the value will be set, if found.
2955 * @param key Key under which the value is stored, if present.
2956 *
2957 * @return YES if the key was found and the value was copied, NO otherwise.
2958 **/
2959- (BOOL)getInt32:(nullable int32_t *)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002960
Austin Schuh40c16522018-10-28 20:27:54 -07002961/**
2962 * Enumerates the keys and values on this dictionary with the given block.
2963 *
2964 * @param block The block to enumerate with.
2965 * **key**: The key for the current entry.
2966 * **value**: The value for the current entry
2967 * **stop**: A pointer to a boolean that when set stops the enumeration.
2968 **/
2969- (void)enumerateKeysAndInt32sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05002970 (void (^)(int64_t key, int32_t value, BOOL *stop))block;
2971
Austin Schuh40c16522018-10-28 20:27:54 -07002972/**
2973 * Adds the keys and values from another dictionary.
2974 *
2975 * @param otherDictionary Dictionary containing entries to be added to this
2976 * dictionary.
2977 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002978- (void)addEntriesFromDictionary:(GPBInt64Int32Dictionary *)otherDictionary;
2979
Austin Schuh40c16522018-10-28 20:27:54 -07002980/**
2981 * Sets the value for the given key.
2982 *
2983 * @param value The value to set.
2984 * @param key The key under which to store the value.
2985 **/
2986- (void)setInt32:(int32_t)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05002987
Austin Schuh40c16522018-10-28 20:27:54 -07002988/**
2989 * Removes the entry for the given key.
2990 *
2991 * @param aKey Key to be removed from this dictionary.
2992 **/
2993- (void)removeInt32ForKey:(int64_t)aKey;
2994
2995/**
2996 * Removes all entries in this dictionary.
2997 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05002998- (void)removeAll;
2999
3000@end
3001
3002#pragma mark - Int64 -> UInt64
3003
Austin Schuh40c16522018-10-28 20:27:54 -07003004/**
3005 * Class used for map fields of <int64_t, uint64_t>
3006 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3007 *
3008 * @note This class is not meant to be subclassed.
3009 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003010@interface GPBInt64UInt64Dictionary : NSObject <NSCopying>
3011
Austin Schuh40c16522018-10-28 20:27:54 -07003012/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05003013@property(nonatomic, readonly) NSUInteger count;
3014
Austin Schuh40c16522018-10-28 20:27:54 -07003015/**
3016 * Initializes this dictionary, copying the given values and keys.
3017 *
3018 * @param values The values to be placed in this dictionary.
3019 * @param keys The keys under which to store the values.
3020 * @param count The number of elements to copy into the dictionary.
3021 *
3022 * @return A newly initialized dictionary with a copy of the values and keys.
3023 **/
3024- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
3025 forKeys:(const int64_t [__nullable])keys
3026 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003027
Austin Schuh40c16522018-10-28 20:27:54 -07003028/**
3029 * Initializes this dictionary, copying the entries from the given dictionary.
3030 *
3031 * @param dictionary Dictionary containing the entries to add to this dictionary.
3032 *
3033 * @return A newly initialized dictionary with the entries of the given dictionary.
3034 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003035- (instancetype)initWithDictionary:(GPBInt64UInt64Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07003036
3037/**
3038 * Initializes this dictionary with the requested capacity.
3039 *
3040 * @param numItems Number of items needed for this dictionary.
3041 *
3042 * @return A newly initialized dictionary with the requested capacity.
3043 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003044- (instancetype)initWithCapacity:(NSUInteger)numItems;
3045
Austin Schuh40c16522018-10-28 20:27:54 -07003046/**
3047 * Gets the value for the given key.
3048 *
3049 * @param value Pointer into which the value will be set, if found.
3050 * @param key Key under which the value is stored, if present.
3051 *
3052 * @return YES if the key was found and the value was copied, NO otherwise.
3053 **/
3054- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003055
Austin Schuh40c16522018-10-28 20:27:54 -07003056/**
3057 * Enumerates the keys and values on this dictionary with the given block.
3058 *
3059 * @param block The block to enumerate with.
3060 * **key**: The key for the current entry.
3061 * **value**: The value for the current entry
3062 * **stop**: A pointer to a boolean that when set stops the enumeration.
3063 **/
3064- (void)enumerateKeysAndUInt64sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05003065 (void (^)(int64_t key, uint64_t value, BOOL *stop))block;
3066
Austin Schuh40c16522018-10-28 20:27:54 -07003067/**
3068 * Adds the keys and values from another dictionary.
3069 *
3070 * @param otherDictionary Dictionary containing entries to be added to this
3071 * dictionary.
3072 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003073- (void)addEntriesFromDictionary:(GPBInt64UInt64Dictionary *)otherDictionary;
3074
Austin Schuh40c16522018-10-28 20:27:54 -07003075/**
3076 * Sets the value for the given key.
3077 *
3078 * @param value The value to set.
3079 * @param key The key under which to store the value.
3080 **/
3081- (void)setUInt64:(uint64_t)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003082
Austin Schuh40c16522018-10-28 20:27:54 -07003083/**
3084 * Removes the entry for the given key.
3085 *
3086 * @param aKey Key to be removed from this dictionary.
3087 **/
3088- (void)removeUInt64ForKey:(int64_t)aKey;
3089
3090/**
3091 * Removes all entries in this dictionary.
3092 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003093- (void)removeAll;
3094
3095@end
3096
3097#pragma mark - Int64 -> Int64
3098
Austin Schuh40c16522018-10-28 20:27:54 -07003099/**
3100 * Class used for map fields of <int64_t, int64_t>
3101 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3102 *
3103 * @note This class is not meant to be subclassed.
3104 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003105@interface GPBInt64Int64Dictionary : NSObject <NSCopying>
3106
Austin Schuh40c16522018-10-28 20:27:54 -07003107/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05003108@property(nonatomic, readonly) NSUInteger count;
3109
Austin Schuh40c16522018-10-28 20:27:54 -07003110/**
3111 * Initializes this dictionary, copying the given values and keys.
3112 *
3113 * @param values The values to be placed in this dictionary.
3114 * @param keys The keys under which to store the values.
3115 * @param count The number of elements to copy into the dictionary.
3116 *
3117 * @return A newly initialized dictionary with a copy of the values and keys.
3118 **/
3119- (instancetype)initWithInt64s:(const int64_t [__nullable])values
3120 forKeys:(const int64_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05003121 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07003122
3123/**
3124 * Initializes this dictionary, copying the entries from the given dictionary.
3125 *
3126 * @param dictionary Dictionary containing the entries to add to this dictionary.
3127 *
3128 * @return A newly initialized dictionary with the entries of the given dictionary.
3129 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003130- (instancetype)initWithDictionary:(GPBInt64Int64Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07003131
3132/**
3133 * Initializes this dictionary with the requested capacity.
3134 *
3135 * @param numItems Number of items needed for this dictionary.
3136 *
3137 * @return A newly initialized dictionary with the requested capacity.
3138 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003139- (instancetype)initWithCapacity:(NSUInteger)numItems;
3140
Austin Schuh40c16522018-10-28 20:27:54 -07003141/**
3142 * Gets the value for the given key.
3143 *
3144 * @param value Pointer into which the value will be set, if found.
3145 * @param key Key under which the value is stored, if present.
3146 *
3147 * @return YES if the key was found and the value was copied, NO otherwise.
3148 **/
3149- (BOOL)getInt64:(nullable int64_t *)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003150
Austin Schuh40c16522018-10-28 20:27:54 -07003151/**
3152 * Enumerates the keys and values on this dictionary with the given block.
3153 *
3154 * @param block The block to enumerate with.
3155 * **key**: The key for the current entry.
3156 * **value**: The value for the current entry
3157 * **stop**: A pointer to a boolean that when set stops the enumeration.
3158 **/
3159- (void)enumerateKeysAndInt64sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05003160 (void (^)(int64_t key, int64_t value, BOOL *stop))block;
3161
Austin Schuh40c16522018-10-28 20:27:54 -07003162/**
3163 * Adds the keys and values from another dictionary.
3164 *
3165 * @param otherDictionary Dictionary containing entries to be added to this
3166 * dictionary.
3167 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003168- (void)addEntriesFromDictionary:(GPBInt64Int64Dictionary *)otherDictionary;
3169
Austin Schuh40c16522018-10-28 20:27:54 -07003170/**
3171 * Sets the value for the given key.
3172 *
3173 * @param value The value to set.
3174 * @param key The key under which to store the value.
3175 **/
3176- (void)setInt64:(int64_t)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003177
Austin Schuh40c16522018-10-28 20:27:54 -07003178/**
3179 * Removes the entry for the given key.
3180 *
3181 * @param aKey Key to be removed from this dictionary.
3182 **/
3183- (void)removeInt64ForKey:(int64_t)aKey;
3184
3185/**
3186 * Removes all entries in this dictionary.
3187 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003188- (void)removeAll;
3189
3190@end
3191
3192#pragma mark - Int64 -> Bool
3193
Austin Schuh40c16522018-10-28 20:27:54 -07003194/**
3195 * Class used for map fields of <int64_t, BOOL>
3196 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3197 *
3198 * @note This class is not meant to be subclassed.
3199 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003200@interface GPBInt64BoolDictionary : NSObject <NSCopying>
3201
Austin Schuh40c16522018-10-28 20:27:54 -07003202/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05003203@property(nonatomic, readonly) NSUInteger count;
3204
Austin Schuh40c16522018-10-28 20:27:54 -07003205/**
3206 * Initializes this dictionary, copying the given values and keys.
3207 *
3208 * @param values The values to be placed in this dictionary.
3209 * @param keys The keys under which to store the values.
3210 * @param count The number of elements to copy into the dictionary.
3211 *
3212 * @return A newly initialized dictionary with a copy of the values and keys.
3213 **/
3214- (instancetype)initWithBools:(const BOOL [__nullable])values
3215 forKeys:(const int64_t [__nullable])keys
3216 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003217
Austin Schuh40c16522018-10-28 20:27:54 -07003218/**
3219 * Initializes this dictionary, copying the entries from the given dictionary.
3220 *
3221 * @param dictionary Dictionary containing the entries to add to this dictionary.
3222 *
3223 * @return A newly initialized dictionary with the entries of the given dictionary.
3224 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003225- (instancetype)initWithDictionary:(GPBInt64BoolDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07003226
3227/**
3228 * Initializes this dictionary with the requested capacity.
3229 *
3230 * @param numItems Number of items needed for this dictionary.
3231 *
3232 * @return A newly initialized dictionary with the requested capacity.
3233 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003234- (instancetype)initWithCapacity:(NSUInteger)numItems;
3235
Austin Schuh40c16522018-10-28 20:27:54 -07003236/**
3237 * Gets the value for the given key.
3238 *
3239 * @param value Pointer into which the value will be set, if found.
3240 * @param key Key under which the value is stored, if present.
3241 *
3242 * @return YES if the key was found and the value was copied, NO otherwise.
3243 **/
3244- (BOOL)getBool:(nullable BOOL *)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003245
Austin Schuh40c16522018-10-28 20:27:54 -07003246/**
3247 * Enumerates the keys and values on this dictionary with the given block.
3248 *
3249 * @param block The block to enumerate with.
3250 * **key**: The key for the current entry.
3251 * **value**: The value for the current entry
3252 * **stop**: A pointer to a boolean that when set stops the enumeration.
3253 **/
3254- (void)enumerateKeysAndBoolsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05003255 (void (^)(int64_t key, BOOL value, BOOL *stop))block;
3256
Austin Schuh40c16522018-10-28 20:27:54 -07003257/**
3258 * Adds the keys and values from another dictionary.
3259 *
3260 * @param otherDictionary Dictionary containing entries to be added to this
3261 * dictionary.
3262 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003263- (void)addEntriesFromDictionary:(GPBInt64BoolDictionary *)otherDictionary;
3264
Austin Schuh40c16522018-10-28 20:27:54 -07003265/**
3266 * Sets the value for the given key.
3267 *
3268 * @param value The value to set.
3269 * @param key The key under which to store the value.
3270 **/
3271- (void)setBool:(BOOL)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003272
Austin Schuh40c16522018-10-28 20:27:54 -07003273/**
3274 * Removes the entry for the given key.
3275 *
3276 * @param aKey Key to be removed from this dictionary.
3277 **/
3278- (void)removeBoolForKey:(int64_t)aKey;
3279
3280/**
3281 * Removes all entries in this dictionary.
3282 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003283- (void)removeAll;
3284
3285@end
3286
3287#pragma mark - Int64 -> Float
3288
Austin Schuh40c16522018-10-28 20:27:54 -07003289/**
3290 * Class used for map fields of <int64_t, float>
3291 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3292 *
3293 * @note This class is not meant to be subclassed.
3294 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003295@interface GPBInt64FloatDictionary : NSObject <NSCopying>
3296
Austin Schuh40c16522018-10-28 20:27:54 -07003297/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05003298@property(nonatomic, readonly) NSUInteger count;
3299
Austin Schuh40c16522018-10-28 20:27:54 -07003300/**
3301 * Initializes this dictionary, copying the given values and keys.
3302 *
3303 * @param values The values to be placed in this dictionary.
3304 * @param keys The keys under which to store the values.
3305 * @param count The number of elements to copy into the dictionary.
3306 *
3307 * @return A newly initialized dictionary with a copy of the values and keys.
3308 **/
3309- (instancetype)initWithFloats:(const float [__nullable])values
3310 forKeys:(const int64_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05003311 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07003312
3313/**
3314 * Initializes this dictionary, copying the entries from the given dictionary.
3315 *
3316 * @param dictionary Dictionary containing the entries to add to this dictionary.
3317 *
3318 * @return A newly initialized dictionary with the entries of the given dictionary.
3319 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003320- (instancetype)initWithDictionary:(GPBInt64FloatDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07003321
3322/**
3323 * Initializes this dictionary with the requested capacity.
3324 *
3325 * @param numItems Number of items needed for this dictionary.
3326 *
3327 * @return A newly initialized dictionary with the requested capacity.
3328 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003329- (instancetype)initWithCapacity:(NSUInteger)numItems;
3330
Austin Schuh40c16522018-10-28 20:27:54 -07003331/**
3332 * Gets the value for the given key.
3333 *
3334 * @param value Pointer into which the value will be set, if found.
3335 * @param key Key under which the value is stored, if present.
3336 *
3337 * @return YES if the key was found and the value was copied, NO otherwise.
3338 **/
3339- (BOOL)getFloat:(nullable float *)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003340
Austin Schuh40c16522018-10-28 20:27:54 -07003341/**
3342 * Enumerates the keys and values on this dictionary with the given block.
3343 *
3344 * @param block The block to enumerate with.
3345 * **key**: The key for the current entry.
3346 * **value**: The value for the current entry
3347 * **stop**: A pointer to a boolean that when set stops the enumeration.
3348 **/
3349- (void)enumerateKeysAndFloatsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05003350 (void (^)(int64_t key, float value, BOOL *stop))block;
3351
Austin Schuh40c16522018-10-28 20:27:54 -07003352/**
3353 * Adds the keys and values from another dictionary.
3354 *
3355 * @param otherDictionary Dictionary containing entries to be added to this
3356 * dictionary.
3357 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003358- (void)addEntriesFromDictionary:(GPBInt64FloatDictionary *)otherDictionary;
3359
Austin Schuh40c16522018-10-28 20:27:54 -07003360/**
3361 * Sets the value for the given key.
3362 *
3363 * @param value The value to set.
3364 * @param key The key under which to store the value.
3365 **/
3366- (void)setFloat:(float)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003367
Austin Schuh40c16522018-10-28 20:27:54 -07003368/**
3369 * Removes the entry for the given key.
3370 *
3371 * @param aKey Key to be removed from this dictionary.
3372 **/
3373- (void)removeFloatForKey:(int64_t)aKey;
3374
3375/**
3376 * Removes all entries in this dictionary.
3377 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003378- (void)removeAll;
3379
3380@end
3381
3382#pragma mark - Int64 -> Double
3383
Austin Schuh40c16522018-10-28 20:27:54 -07003384/**
3385 * Class used for map fields of <int64_t, double>
3386 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3387 *
3388 * @note This class is not meant to be subclassed.
3389 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003390@interface GPBInt64DoubleDictionary : NSObject <NSCopying>
3391
Austin Schuh40c16522018-10-28 20:27:54 -07003392/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05003393@property(nonatomic, readonly) NSUInteger count;
3394
Austin Schuh40c16522018-10-28 20:27:54 -07003395/**
3396 * Initializes this dictionary, copying the given values and keys.
3397 *
3398 * @param values The values to be placed in this dictionary.
3399 * @param keys The keys under which to store the values.
3400 * @param count The number of elements to copy into the dictionary.
3401 *
3402 * @return A newly initialized dictionary with a copy of the values and keys.
3403 **/
3404- (instancetype)initWithDoubles:(const double [__nullable])values
3405 forKeys:(const int64_t [__nullable])keys
3406 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003407
Austin Schuh40c16522018-10-28 20:27:54 -07003408/**
3409 * Initializes this dictionary, copying the entries from the given dictionary.
3410 *
3411 * @param dictionary Dictionary containing the entries to add to this dictionary.
3412 *
3413 * @return A newly initialized dictionary with the entries of the given dictionary.
3414 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003415- (instancetype)initWithDictionary:(GPBInt64DoubleDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07003416
3417/**
3418 * Initializes this dictionary with the requested capacity.
3419 *
3420 * @param numItems Number of items needed for this dictionary.
3421 *
3422 * @return A newly initialized dictionary with the requested capacity.
3423 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003424- (instancetype)initWithCapacity:(NSUInteger)numItems;
3425
Austin Schuh40c16522018-10-28 20:27:54 -07003426/**
3427 * Gets the value for the given key.
3428 *
3429 * @param value Pointer into which the value will be set, if found.
3430 * @param key Key under which the value is stored, if present.
3431 *
3432 * @return YES if the key was found and the value was copied, NO otherwise.
3433 **/
3434- (BOOL)getDouble:(nullable double *)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003435
Austin Schuh40c16522018-10-28 20:27:54 -07003436/**
3437 * Enumerates the keys and values on this dictionary with the given block.
3438 *
3439 * @param block The block to enumerate with.
3440 * **key**: The key for the current entry.
3441 * **value**: The value for the current entry
3442 * **stop**: A pointer to a boolean that when set stops the enumeration.
3443 **/
3444- (void)enumerateKeysAndDoublesUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05003445 (void (^)(int64_t key, double value, BOOL *stop))block;
3446
Austin Schuh40c16522018-10-28 20:27:54 -07003447/**
3448 * Adds the keys and values from another dictionary.
3449 *
3450 * @param otherDictionary Dictionary containing entries to be added to this
3451 * dictionary.
3452 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003453- (void)addEntriesFromDictionary:(GPBInt64DoubleDictionary *)otherDictionary;
3454
Austin Schuh40c16522018-10-28 20:27:54 -07003455/**
3456 * Sets the value for the given key.
3457 *
3458 * @param value The value to set.
3459 * @param key The key under which to store the value.
3460 **/
3461- (void)setDouble:(double)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003462
Austin Schuh40c16522018-10-28 20:27:54 -07003463/**
3464 * Removes the entry for the given key.
3465 *
3466 * @param aKey Key to be removed from this dictionary.
3467 **/
3468- (void)removeDoubleForKey:(int64_t)aKey;
3469
3470/**
3471 * Removes all entries in this dictionary.
3472 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003473- (void)removeAll;
3474
3475@end
3476
3477#pragma mark - Int64 -> Enum
3478
Austin Schuh40c16522018-10-28 20:27:54 -07003479/**
3480 * Class used for map fields of <int64_t, int32_t>
3481 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3482 *
3483 * @note This class is not meant to be subclassed.
3484 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003485@interface GPBInt64EnumDictionary : NSObject <NSCopying>
3486
Austin Schuh40c16522018-10-28 20:27:54 -07003487/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05003488@property(nonatomic, readonly) NSUInteger count;
Austin Schuh40c16522018-10-28 20:27:54 -07003489/** The validation function to check if the enums are valid. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05003490@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
3491
Austin Schuh40c16522018-10-28 20:27:54 -07003492/**
3493 * Initializes a dictionary with the given validation function.
3494 *
3495 * @param func The enum validation function for the dictionary.
3496 *
3497 * @return A newly initialized dictionary.
3498 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003499- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Austin Schuh40c16522018-10-28 20:27:54 -07003500
3501/**
3502 * Initializes a dictionary with the entries given.
3503 *
3504 * @param func The enum validation function for the dictionary.
3505 * @param values The raw enum values values to be placed in the dictionary.
3506 * @param keys The keys under which to store the values.
3507 * @param count The number of entries to store in the dictionary.
3508 *
3509 * @return A newly initialized dictionary with the keys and values in it.
3510 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003511- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Austin Schuh40c16522018-10-28 20:27:54 -07003512 rawValues:(const int32_t [__nullable])values
3513 forKeys:(const int64_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05003514 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07003515
3516/**
3517 * Initializes a dictionary with the entries from the given.
3518 * dictionary.
3519 *
3520 * @param dictionary Dictionary containing the entries to add to the dictionary.
3521 *
3522 * @return A newly initialized dictionary with the entries from the given
3523 * dictionary in it.
3524 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003525- (instancetype)initWithDictionary:(GPBInt64EnumDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07003526
3527/**
3528 * Initializes a dictionary with the given capacity.
3529 *
3530 * @param func The enum validation function for the dictionary.
3531 * @param numItems Capacity needed for the dictionary.
3532 *
3533 * @return A newly initialized dictionary with the given capacity.
3534 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003535- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
3536 capacity:(NSUInteger)numItems;
3537
3538// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
3539// is not a valid enumerator as defined by validationFunc. If the actual value is
3540// desired, use "raw" version of the method.
3541
Austin Schuh40c16522018-10-28 20:27:54 -07003542/**
3543 * Gets the value for the given key.
3544 *
3545 * @param value Pointer into which the value will be set, if found.
3546 * @param key Key under which the value is stored, if present.
3547 *
3548 * @return YES if the key was found and the value was copied, NO otherwise.
3549 **/
3550- (BOOL)getEnum:(nullable int32_t *)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003551
Austin Schuh40c16522018-10-28 20:27:54 -07003552/**
3553 * Enumerates the keys and values on this dictionary with the given block.
3554 *
3555 * @param block The block to enumerate with.
3556 * **key**: The key for the current entry.
3557 * **value**: The value for the current entry
3558 * **stop**: A pointer to a boolean that when set stops the enumeration.
3559 **/
3560- (void)enumerateKeysAndEnumsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05003561 (void (^)(int64_t key, int32_t value, BOOL *stop))block;
3562
Austin Schuh40c16522018-10-28 20:27:54 -07003563/**
3564 * Gets the raw enum value for the given key.
3565 *
3566 * @note This method bypass the validationFunc to enable the access of values that
3567 * were not known at the time the binary was compiled.
3568 *
3569 * @param rawValue Pointer into which the value will be set, if found.
3570 * @param key Key under which the value is stored, if present.
3571 *
3572 * @return YES if the key was found and the value was copied, NO otherwise.
3573 **/
3574- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003575
Austin Schuh40c16522018-10-28 20:27:54 -07003576/**
3577 * Enumerates the keys and values on this dictionary with the given block.
3578 *
3579 * @note This method bypass the validationFunc to enable the access of values that
3580 * were not known at the time the binary was compiled.
3581 *
3582 * @param block The block to enumerate with.
3583 * **key**: The key for the current entry.
3584 * **rawValue**: The value for the current entry
3585 * **stop**: A pointer to a boolean that when set stops the enumeration.
3586 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003587- (void)enumerateKeysAndRawValuesUsingBlock:
3588 (void (^)(int64_t key, int32_t rawValue, BOOL *stop))block;
3589
Austin Schuh40c16522018-10-28 20:27:54 -07003590/**
3591 * Adds the keys and raw enum values from another dictionary.
3592 *
3593 * @note This method bypass the validationFunc to enable the setting of values that
3594 * were not known at the time the binary was compiled.
3595 *
3596 * @param otherDictionary Dictionary containing entries to be added to this
3597 * dictionary.
3598 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003599- (void)addRawEntriesFromDictionary:(GPBInt64EnumDictionary *)otherDictionary;
3600
3601// If value is not a valid enumerator as defined by validationFunc, these
3602// methods will assert in debug, and will log in release and assign the value
3603// to the default value. Use the rawValue methods below to assign non enumerator
3604// values.
3605
Austin Schuh40c16522018-10-28 20:27:54 -07003606/**
3607 * Sets the value for the given key.
3608 *
3609 * @param value The value to set.
3610 * @param key The key under which to store the value.
3611 **/
3612- (void)setEnum:(int32_t)value forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003613
Austin Schuh40c16522018-10-28 20:27:54 -07003614/**
3615 * Sets the raw enum value for the given key.
3616 *
3617 * @note This method bypass the validationFunc to enable the setting of values that
3618 * were not known at the time the binary was compiled.
3619 *
3620 * @param rawValue The raw enum value to set.
3621 * @param key The key under which to store the raw enum value.
3622 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003623- (void)setRawValue:(int32_t)rawValue forKey:(int64_t)key;
3624
Austin Schuh40c16522018-10-28 20:27:54 -07003625/**
3626 * Removes the entry for the given key.
3627 *
3628 * @param aKey Key to be removed from this dictionary.
3629 **/
3630- (void)removeEnumForKey:(int64_t)aKey;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003631
Austin Schuh40c16522018-10-28 20:27:54 -07003632/**
3633 * Removes all entries in this dictionary.
3634 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003635- (void)removeAll;
3636
3637@end
3638
3639#pragma mark - Int64 -> Object
3640
Austin Schuh40c16522018-10-28 20:27:54 -07003641/**
3642 * Class used for map fields of <int64_t, ObjectType>
3643 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3644 *
3645 * @note This class is not meant to be subclassed.
3646 **/
3647@interface GPBInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
Brian Silverman9c614bc2016-02-15 20:20:02 -05003648
Austin Schuh40c16522018-10-28 20:27:54 -07003649/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05003650@property(nonatomic, readonly) NSUInteger count;
3651
Austin Schuh40c16522018-10-28 20:27:54 -07003652/**
3653 * Initializes this dictionary, copying the given values and keys.
3654 *
3655 * @param objects The values to be placed in this dictionary.
3656 * @param keys The keys under which to store the values.
3657 * @param count The number of elements to copy into the dictionary.
3658 *
3659 * @return A newly initialized dictionary with a copy of the values and keys.
3660 **/
3661- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
3662 forKeys:(const int64_t [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05003663 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07003664
3665/**
3666 * Initializes this dictionary, copying the entries from the given dictionary.
3667 *
3668 * @param dictionary Dictionary containing the entries to add to this dictionary.
3669 *
3670 * @return A newly initialized dictionary with the entries of the given dictionary.
3671 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003672- (instancetype)initWithDictionary:(GPBInt64ObjectDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07003673
3674/**
3675 * Initializes this dictionary with the requested capacity.
3676 *
3677 * @param numItems Number of items needed for this dictionary.
3678 *
3679 * @return A newly initialized dictionary with the requested capacity.
3680 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003681- (instancetype)initWithCapacity:(NSUInteger)numItems;
3682
Austin Schuh40c16522018-10-28 20:27:54 -07003683/**
3684 * Fetches the object stored under the given key.
3685 *
3686 * @param key Key under which the value is stored, if present.
3687 *
3688 * @return The object if found, nil otherwise.
3689 **/
3690- (ObjectType)objectForKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003691
Austin Schuh40c16522018-10-28 20:27:54 -07003692/**
3693 * Enumerates the keys and values on this dictionary with the given block.
3694 *
3695 * @param block The block to enumerate with.
3696 * **key**: The key for the current entry.
3697 * **object**: The value for the current entry
3698 * **stop**: A pointer to a boolean that when set stops the enumeration.
3699 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003700- (void)enumerateKeysAndObjectsUsingBlock:
Austin Schuh40c16522018-10-28 20:27:54 -07003701 (void (^)(int64_t key, ObjectType object, BOOL *stop))block;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003702
Austin Schuh40c16522018-10-28 20:27:54 -07003703/**
3704 * Adds the keys and values from another dictionary.
3705 *
3706 * @param otherDictionary Dictionary containing entries to be added to this
3707 * dictionary.
3708 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003709- (void)addEntriesFromDictionary:(GPBInt64ObjectDictionary *)otherDictionary;
3710
Austin Schuh40c16522018-10-28 20:27:54 -07003711/**
3712 * Sets the value for the given key.
3713 *
3714 * @param object The value to set.
3715 * @param key The key under which to store the value.
3716 **/
3717- (void)setObject:(ObjectType)object forKey:(int64_t)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003718
Austin Schuh40c16522018-10-28 20:27:54 -07003719/**
3720 * Removes the entry for the given key.
3721 *
3722 * @param aKey Key to be removed from this dictionary.
3723 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003724- (void)removeObjectForKey:(int64_t)aKey;
Austin Schuh40c16522018-10-28 20:27:54 -07003725
3726/**
3727 * Removes all entries in this dictionary.
3728 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003729- (void)removeAll;
3730
3731@end
3732
3733#pragma mark - Bool -> UInt32
3734
Austin Schuh40c16522018-10-28 20:27:54 -07003735/**
3736 * Class used for map fields of <BOOL, uint32_t>
3737 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3738 *
3739 * @note This class is not meant to be subclassed.
3740 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003741@interface GPBBoolUInt32Dictionary : NSObject <NSCopying>
3742
Austin Schuh40c16522018-10-28 20:27:54 -07003743/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05003744@property(nonatomic, readonly) NSUInteger count;
3745
Austin Schuh40c16522018-10-28 20:27:54 -07003746/**
3747 * Initializes this dictionary, copying the given values and keys.
3748 *
3749 * @param values The values to be placed in this dictionary.
3750 * @param keys The keys under which to store the values.
3751 * @param count The number of elements to copy into the dictionary.
3752 *
3753 * @return A newly initialized dictionary with a copy of the values and keys.
3754 **/
3755- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
3756 forKeys:(const BOOL [__nullable])keys
3757 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003758
Austin Schuh40c16522018-10-28 20:27:54 -07003759/**
3760 * Initializes this dictionary, copying the entries from the given dictionary.
3761 *
3762 * @param dictionary Dictionary containing the entries to add to this dictionary.
3763 *
3764 * @return A newly initialized dictionary with the entries of the given dictionary.
3765 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003766- (instancetype)initWithDictionary:(GPBBoolUInt32Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07003767
3768/**
3769 * Initializes this dictionary with the requested capacity.
3770 *
3771 * @param numItems Number of items needed for this dictionary.
3772 *
3773 * @return A newly initialized dictionary with the requested capacity.
3774 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003775- (instancetype)initWithCapacity:(NSUInteger)numItems;
3776
Austin Schuh40c16522018-10-28 20:27:54 -07003777/**
3778 * Gets the value for the given key.
3779 *
3780 * @param value Pointer into which the value will be set, if found.
3781 * @param key Key under which the value is stored, if present.
3782 *
3783 * @return YES if the key was found and the value was copied, NO otherwise.
3784 **/
3785- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003786
Austin Schuh40c16522018-10-28 20:27:54 -07003787/**
3788 * Enumerates the keys and values on this dictionary with the given block.
3789 *
3790 * @param block The block to enumerate with.
3791 * **key**: The key for the current entry.
3792 * **value**: The value for the current entry
3793 * **stop**: A pointer to a boolean that when set stops the enumeration.
3794 **/
3795- (void)enumerateKeysAndUInt32sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05003796 (void (^)(BOOL key, uint32_t value, BOOL *stop))block;
3797
Austin Schuh40c16522018-10-28 20:27:54 -07003798/**
3799 * Adds the keys and values from another dictionary.
3800 *
3801 * @param otherDictionary Dictionary containing entries to be added to this
3802 * dictionary.
3803 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003804- (void)addEntriesFromDictionary:(GPBBoolUInt32Dictionary *)otherDictionary;
3805
Austin Schuh40c16522018-10-28 20:27:54 -07003806/**
3807 * Sets the value for the given key.
3808 *
3809 * @param value The value to set.
3810 * @param key The key under which to store the value.
3811 **/
3812- (void)setUInt32:(uint32_t)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003813
Austin Schuh40c16522018-10-28 20:27:54 -07003814/**
3815 * Removes the entry for the given key.
3816 *
3817 * @param aKey Key to be removed from this dictionary.
3818 **/
3819- (void)removeUInt32ForKey:(BOOL)aKey;
3820
3821/**
3822 * Removes all entries in this dictionary.
3823 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003824- (void)removeAll;
3825
3826@end
3827
3828#pragma mark - Bool -> Int32
3829
Austin Schuh40c16522018-10-28 20:27:54 -07003830/**
3831 * Class used for map fields of <BOOL, int32_t>
3832 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3833 *
3834 * @note This class is not meant to be subclassed.
3835 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003836@interface GPBBoolInt32Dictionary : NSObject <NSCopying>
3837
Austin Schuh40c16522018-10-28 20:27:54 -07003838/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05003839@property(nonatomic, readonly) NSUInteger count;
3840
Austin Schuh40c16522018-10-28 20:27:54 -07003841/**
3842 * Initializes this dictionary, copying the given values and keys.
3843 *
3844 * @param values The values to be placed in this dictionary.
3845 * @param keys The keys under which to store the values.
3846 * @param count The number of elements to copy into the dictionary.
3847 *
3848 * @return A newly initialized dictionary with a copy of the values and keys.
3849 **/
3850- (instancetype)initWithInt32s:(const int32_t [__nullable])values
3851 forKeys:(const BOOL [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05003852 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07003853
3854/**
3855 * Initializes this dictionary, copying the entries from the given dictionary.
3856 *
3857 * @param dictionary Dictionary containing the entries to add to this dictionary.
3858 *
3859 * @return A newly initialized dictionary with the entries of the given dictionary.
3860 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003861- (instancetype)initWithDictionary:(GPBBoolInt32Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07003862
3863/**
3864 * Initializes this dictionary with the requested capacity.
3865 *
3866 * @param numItems Number of items needed for this dictionary.
3867 *
3868 * @return A newly initialized dictionary with the requested capacity.
3869 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003870- (instancetype)initWithCapacity:(NSUInteger)numItems;
3871
Austin Schuh40c16522018-10-28 20:27:54 -07003872/**
3873 * Gets the value for the given key.
3874 *
3875 * @param value Pointer into which the value will be set, if found.
3876 * @param key Key under which the value is stored, if present.
3877 *
3878 * @return YES if the key was found and the value was copied, NO otherwise.
3879 **/
3880- (BOOL)getInt32:(nullable int32_t *)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003881
Austin Schuh40c16522018-10-28 20:27:54 -07003882/**
3883 * Enumerates the keys and values on this dictionary with the given block.
3884 *
3885 * @param block The block to enumerate with.
3886 * **key**: The key for the current entry.
3887 * **value**: The value for the current entry
3888 * **stop**: A pointer to a boolean that when set stops the enumeration.
3889 **/
3890- (void)enumerateKeysAndInt32sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05003891 (void (^)(BOOL key, int32_t value, BOOL *stop))block;
3892
Austin Schuh40c16522018-10-28 20:27:54 -07003893/**
3894 * Adds the keys and values from another dictionary.
3895 *
3896 * @param otherDictionary Dictionary containing entries to be added to this
3897 * dictionary.
3898 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003899- (void)addEntriesFromDictionary:(GPBBoolInt32Dictionary *)otherDictionary;
3900
Austin Schuh40c16522018-10-28 20:27:54 -07003901/**
3902 * Sets the value for the given key.
3903 *
3904 * @param value The value to set.
3905 * @param key The key under which to store the value.
3906 **/
3907- (void)setInt32:(int32_t)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003908
Austin Schuh40c16522018-10-28 20:27:54 -07003909/**
3910 * Removes the entry for the given key.
3911 *
3912 * @param aKey Key to be removed from this dictionary.
3913 **/
3914- (void)removeInt32ForKey:(BOOL)aKey;
3915
3916/**
3917 * Removes all entries in this dictionary.
3918 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003919- (void)removeAll;
3920
3921@end
3922
3923#pragma mark - Bool -> UInt64
3924
Austin Schuh40c16522018-10-28 20:27:54 -07003925/**
3926 * Class used for map fields of <BOOL, uint64_t>
3927 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3928 *
3929 * @note This class is not meant to be subclassed.
3930 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003931@interface GPBBoolUInt64Dictionary : NSObject <NSCopying>
3932
Austin Schuh40c16522018-10-28 20:27:54 -07003933/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05003934@property(nonatomic, readonly) NSUInteger count;
3935
Austin Schuh40c16522018-10-28 20:27:54 -07003936/**
3937 * Initializes this dictionary, copying the given values and keys.
3938 *
3939 * @param values The values to be placed in this dictionary.
3940 * @param keys The keys under which to store the values.
3941 * @param count The number of elements to copy into the dictionary.
3942 *
3943 * @return A newly initialized dictionary with a copy of the values and keys.
3944 **/
3945- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
3946 forKeys:(const BOOL [__nullable])keys
3947 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003948
Austin Schuh40c16522018-10-28 20:27:54 -07003949/**
3950 * Initializes this dictionary, copying the entries from the given dictionary.
3951 *
3952 * @param dictionary Dictionary containing the entries to add to this dictionary.
3953 *
3954 * @return A newly initialized dictionary with the entries of the given dictionary.
3955 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003956- (instancetype)initWithDictionary:(GPBBoolUInt64Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07003957
3958/**
3959 * Initializes this dictionary with the requested capacity.
3960 *
3961 * @param numItems Number of items needed for this dictionary.
3962 *
3963 * @return A newly initialized dictionary with the requested capacity.
3964 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003965- (instancetype)initWithCapacity:(NSUInteger)numItems;
3966
Austin Schuh40c16522018-10-28 20:27:54 -07003967/**
3968 * Gets the value for the given key.
3969 *
3970 * @param value Pointer into which the value will be set, if found.
3971 * @param key Key under which the value is stored, if present.
3972 *
3973 * @return YES if the key was found and the value was copied, NO otherwise.
3974 **/
3975- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05003976
Austin Schuh40c16522018-10-28 20:27:54 -07003977/**
3978 * Enumerates the keys and values on this dictionary with the given block.
3979 *
3980 * @param block The block to enumerate with.
3981 * **key**: The key for the current entry.
3982 * **value**: The value for the current entry
3983 * **stop**: A pointer to a boolean that when set stops the enumeration.
3984 **/
3985- (void)enumerateKeysAndUInt64sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05003986 (void (^)(BOOL key, uint64_t value, BOOL *stop))block;
3987
Austin Schuh40c16522018-10-28 20:27:54 -07003988/**
3989 * Adds the keys and values from another dictionary.
3990 *
3991 * @param otherDictionary Dictionary containing entries to be added to this
3992 * dictionary.
3993 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05003994- (void)addEntriesFromDictionary:(GPBBoolUInt64Dictionary *)otherDictionary;
3995
Austin Schuh40c16522018-10-28 20:27:54 -07003996/**
3997 * Sets the value for the given key.
3998 *
3999 * @param value The value to set.
4000 * @param key The key under which to store the value.
4001 **/
4002- (void)setUInt64:(uint64_t)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004003
Austin Schuh40c16522018-10-28 20:27:54 -07004004/**
4005 * Removes the entry for the given key.
4006 *
4007 * @param aKey Key to be removed from this dictionary.
4008 **/
4009- (void)removeUInt64ForKey:(BOOL)aKey;
4010
4011/**
4012 * Removes all entries in this dictionary.
4013 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004014- (void)removeAll;
4015
4016@end
4017
4018#pragma mark - Bool -> Int64
4019
Austin Schuh40c16522018-10-28 20:27:54 -07004020/**
4021 * Class used for map fields of <BOOL, int64_t>
4022 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4023 *
4024 * @note This class is not meant to be subclassed.
4025 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004026@interface GPBBoolInt64Dictionary : NSObject <NSCopying>
4027
Austin Schuh40c16522018-10-28 20:27:54 -07004028/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05004029@property(nonatomic, readonly) NSUInteger count;
4030
Austin Schuh40c16522018-10-28 20:27:54 -07004031/**
4032 * Initializes this dictionary, copying the given values and keys.
4033 *
4034 * @param values The values to be placed in this dictionary.
4035 * @param keys The keys under which to store the values.
4036 * @param count The number of elements to copy into the dictionary.
4037 *
4038 * @return A newly initialized dictionary with a copy of the values and keys.
4039 **/
4040- (instancetype)initWithInt64s:(const int64_t [__nullable])values
4041 forKeys:(const BOOL [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05004042 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07004043
4044/**
4045 * Initializes this dictionary, copying the entries from the given dictionary.
4046 *
4047 * @param dictionary Dictionary containing the entries to add to this dictionary.
4048 *
4049 * @return A newly initialized dictionary with the entries of the given dictionary.
4050 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004051- (instancetype)initWithDictionary:(GPBBoolInt64Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07004052
4053/**
4054 * Initializes this dictionary with the requested capacity.
4055 *
4056 * @param numItems Number of items needed for this dictionary.
4057 *
4058 * @return A newly initialized dictionary with the requested capacity.
4059 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004060- (instancetype)initWithCapacity:(NSUInteger)numItems;
4061
Austin Schuh40c16522018-10-28 20:27:54 -07004062/**
4063 * Gets the value for the given key.
4064 *
4065 * @param value Pointer into which the value will be set, if found.
4066 * @param key Key under which the value is stored, if present.
4067 *
4068 * @return YES if the key was found and the value was copied, NO otherwise.
4069 **/
4070- (BOOL)getInt64:(nullable int64_t *)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004071
Austin Schuh40c16522018-10-28 20:27:54 -07004072/**
4073 * Enumerates the keys and values on this dictionary with the given block.
4074 *
4075 * @param block The block to enumerate with.
4076 * **key**: The key for the current entry.
4077 * **value**: The value for the current entry
4078 * **stop**: A pointer to a boolean that when set stops the enumeration.
4079 **/
4080- (void)enumerateKeysAndInt64sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05004081 (void (^)(BOOL key, int64_t value, BOOL *stop))block;
4082
Austin Schuh40c16522018-10-28 20:27:54 -07004083/**
4084 * Adds the keys and values from another dictionary.
4085 *
4086 * @param otherDictionary Dictionary containing entries to be added to this
4087 * dictionary.
4088 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004089- (void)addEntriesFromDictionary:(GPBBoolInt64Dictionary *)otherDictionary;
4090
Austin Schuh40c16522018-10-28 20:27:54 -07004091/**
4092 * Sets the value for the given key.
4093 *
4094 * @param value The value to set.
4095 * @param key The key under which to store the value.
4096 **/
4097- (void)setInt64:(int64_t)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004098
Austin Schuh40c16522018-10-28 20:27:54 -07004099/**
4100 * Removes the entry for the given key.
4101 *
4102 * @param aKey Key to be removed from this dictionary.
4103 **/
4104- (void)removeInt64ForKey:(BOOL)aKey;
4105
4106/**
4107 * Removes all entries in this dictionary.
4108 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004109- (void)removeAll;
4110
4111@end
4112
4113#pragma mark - Bool -> Bool
4114
Austin Schuh40c16522018-10-28 20:27:54 -07004115/**
4116 * Class used for map fields of <BOOL, BOOL>
4117 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4118 *
4119 * @note This class is not meant to be subclassed.
4120 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004121@interface GPBBoolBoolDictionary : NSObject <NSCopying>
4122
Austin Schuh40c16522018-10-28 20:27:54 -07004123/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05004124@property(nonatomic, readonly) NSUInteger count;
4125
Austin Schuh40c16522018-10-28 20:27:54 -07004126/**
4127 * Initializes this dictionary, copying the given values and keys.
4128 *
4129 * @param values The values to be placed in this dictionary.
4130 * @param keys The keys under which to store the values.
4131 * @param count The number of elements to copy into the dictionary.
4132 *
4133 * @return A newly initialized dictionary with a copy of the values and keys.
4134 **/
4135- (instancetype)initWithBools:(const BOOL [__nullable])values
4136 forKeys:(const BOOL [__nullable])keys
4137 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004138
Austin Schuh40c16522018-10-28 20:27:54 -07004139/**
4140 * Initializes this dictionary, copying the entries from the given dictionary.
4141 *
4142 * @param dictionary Dictionary containing the entries to add to this dictionary.
4143 *
4144 * @return A newly initialized dictionary with the entries of the given dictionary.
4145 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004146- (instancetype)initWithDictionary:(GPBBoolBoolDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07004147
4148/**
4149 * Initializes this dictionary with the requested capacity.
4150 *
4151 * @param numItems Number of items needed for this dictionary.
4152 *
4153 * @return A newly initialized dictionary with the requested capacity.
4154 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004155- (instancetype)initWithCapacity:(NSUInteger)numItems;
4156
Austin Schuh40c16522018-10-28 20:27:54 -07004157/**
4158 * Gets the value for the given key.
4159 *
4160 * @param value Pointer into which the value will be set, if found.
4161 * @param key Key under which the value is stored, if present.
4162 *
4163 * @return YES if the key was found and the value was copied, NO otherwise.
4164 **/
4165- (BOOL)getBool:(nullable BOOL *)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004166
Austin Schuh40c16522018-10-28 20:27:54 -07004167/**
4168 * Enumerates the keys and values on this dictionary with the given block.
4169 *
4170 * @param block The block to enumerate with.
4171 * **key**: The key for the current entry.
4172 * **value**: The value for the current entry
4173 * **stop**: A pointer to a boolean that when set stops the enumeration.
4174 **/
4175- (void)enumerateKeysAndBoolsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05004176 (void (^)(BOOL key, BOOL value, BOOL *stop))block;
4177
Austin Schuh40c16522018-10-28 20:27:54 -07004178/**
4179 * Adds the keys and values from another dictionary.
4180 *
4181 * @param otherDictionary Dictionary containing entries to be added to this
4182 * dictionary.
4183 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004184- (void)addEntriesFromDictionary:(GPBBoolBoolDictionary *)otherDictionary;
4185
Austin Schuh40c16522018-10-28 20:27:54 -07004186/**
4187 * Sets the value for the given key.
4188 *
4189 * @param value The value to set.
4190 * @param key The key under which to store the value.
4191 **/
4192- (void)setBool:(BOOL)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004193
Austin Schuh40c16522018-10-28 20:27:54 -07004194/**
4195 * Removes the entry for the given key.
4196 *
4197 * @param aKey Key to be removed from this dictionary.
4198 **/
4199- (void)removeBoolForKey:(BOOL)aKey;
4200
4201/**
4202 * Removes all entries in this dictionary.
4203 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004204- (void)removeAll;
4205
4206@end
4207
4208#pragma mark - Bool -> Float
4209
Austin Schuh40c16522018-10-28 20:27:54 -07004210/**
4211 * Class used for map fields of <BOOL, float>
4212 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4213 *
4214 * @note This class is not meant to be subclassed.
4215 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004216@interface GPBBoolFloatDictionary : NSObject <NSCopying>
4217
Austin Schuh40c16522018-10-28 20:27:54 -07004218/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05004219@property(nonatomic, readonly) NSUInteger count;
4220
Austin Schuh40c16522018-10-28 20:27:54 -07004221/**
4222 * Initializes this dictionary, copying the given values and keys.
4223 *
4224 * @param values The values to be placed in this dictionary.
4225 * @param keys The keys under which to store the values.
4226 * @param count The number of elements to copy into the dictionary.
4227 *
4228 * @return A newly initialized dictionary with a copy of the values and keys.
4229 **/
4230- (instancetype)initWithFloats:(const float [__nullable])values
4231 forKeys:(const BOOL [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05004232 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07004233
4234/**
4235 * Initializes this dictionary, copying the entries from the given dictionary.
4236 *
4237 * @param dictionary Dictionary containing the entries to add to this dictionary.
4238 *
4239 * @return A newly initialized dictionary with the entries of the given dictionary.
4240 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004241- (instancetype)initWithDictionary:(GPBBoolFloatDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07004242
4243/**
4244 * Initializes this dictionary with the requested capacity.
4245 *
4246 * @param numItems Number of items needed for this dictionary.
4247 *
4248 * @return A newly initialized dictionary with the requested capacity.
4249 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004250- (instancetype)initWithCapacity:(NSUInteger)numItems;
4251
Austin Schuh40c16522018-10-28 20:27:54 -07004252/**
4253 * Gets the value for the given key.
4254 *
4255 * @param value Pointer into which the value will be set, if found.
4256 * @param key Key under which the value is stored, if present.
4257 *
4258 * @return YES if the key was found and the value was copied, NO otherwise.
4259 **/
4260- (BOOL)getFloat:(nullable float *)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004261
Austin Schuh40c16522018-10-28 20:27:54 -07004262/**
4263 * Enumerates the keys and values on this dictionary with the given block.
4264 *
4265 * @param block The block to enumerate with.
4266 * **key**: The key for the current entry.
4267 * **value**: The value for the current entry
4268 * **stop**: A pointer to a boolean that when set stops the enumeration.
4269 **/
4270- (void)enumerateKeysAndFloatsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05004271 (void (^)(BOOL key, float value, BOOL *stop))block;
4272
Austin Schuh40c16522018-10-28 20:27:54 -07004273/**
4274 * Adds the keys and values from another dictionary.
4275 *
4276 * @param otherDictionary Dictionary containing entries to be added to this
4277 * dictionary.
4278 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004279- (void)addEntriesFromDictionary:(GPBBoolFloatDictionary *)otherDictionary;
4280
Austin Schuh40c16522018-10-28 20:27:54 -07004281/**
4282 * Sets the value for the given key.
4283 *
4284 * @param value The value to set.
4285 * @param key The key under which to store the value.
4286 **/
4287- (void)setFloat:(float)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004288
Austin Schuh40c16522018-10-28 20:27:54 -07004289/**
4290 * Removes the entry for the given key.
4291 *
4292 * @param aKey Key to be removed from this dictionary.
4293 **/
4294- (void)removeFloatForKey:(BOOL)aKey;
4295
4296/**
4297 * Removes all entries in this dictionary.
4298 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004299- (void)removeAll;
4300
4301@end
4302
4303#pragma mark - Bool -> Double
4304
Austin Schuh40c16522018-10-28 20:27:54 -07004305/**
4306 * Class used for map fields of <BOOL, double>
4307 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4308 *
4309 * @note This class is not meant to be subclassed.
4310 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004311@interface GPBBoolDoubleDictionary : NSObject <NSCopying>
4312
Austin Schuh40c16522018-10-28 20:27:54 -07004313/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05004314@property(nonatomic, readonly) NSUInteger count;
4315
Austin Schuh40c16522018-10-28 20:27:54 -07004316/**
4317 * Initializes this dictionary, copying the given values and keys.
4318 *
4319 * @param values The values to be placed in this dictionary.
4320 * @param keys The keys under which to store the values.
4321 * @param count The number of elements to copy into the dictionary.
4322 *
4323 * @return A newly initialized dictionary with a copy of the values and keys.
4324 **/
4325- (instancetype)initWithDoubles:(const double [__nullable])values
4326 forKeys:(const BOOL [__nullable])keys
4327 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004328
Austin Schuh40c16522018-10-28 20:27:54 -07004329/**
4330 * Initializes this dictionary, copying the entries from the given dictionary.
4331 *
4332 * @param dictionary Dictionary containing the entries to add to this dictionary.
4333 *
4334 * @return A newly initialized dictionary with the entries of the given dictionary.
4335 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004336- (instancetype)initWithDictionary:(GPBBoolDoubleDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07004337
4338/**
4339 * Initializes this dictionary with the requested capacity.
4340 *
4341 * @param numItems Number of items needed for this dictionary.
4342 *
4343 * @return A newly initialized dictionary with the requested capacity.
4344 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004345- (instancetype)initWithCapacity:(NSUInteger)numItems;
4346
Austin Schuh40c16522018-10-28 20:27:54 -07004347/**
4348 * Gets the value for the given key.
4349 *
4350 * @param value Pointer into which the value will be set, if found.
4351 * @param key Key under which the value is stored, if present.
4352 *
4353 * @return YES if the key was found and the value was copied, NO otherwise.
4354 **/
4355- (BOOL)getDouble:(nullable double *)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004356
Austin Schuh40c16522018-10-28 20:27:54 -07004357/**
4358 * Enumerates the keys and values on this dictionary with the given block.
4359 *
4360 * @param block The block to enumerate with.
4361 * **key**: The key for the current entry.
4362 * **value**: The value for the current entry
4363 * **stop**: A pointer to a boolean that when set stops the enumeration.
4364 **/
4365- (void)enumerateKeysAndDoublesUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05004366 (void (^)(BOOL key, double value, BOOL *stop))block;
4367
Austin Schuh40c16522018-10-28 20:27:54 -07004368/**
4369 * Adds the keys and values from another dictionary.
4370 *
4371 * @param otherDictionary Dictionary containing entries to be added to this
4372 * dictionary.
4373 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004374- (void)addEntriesFromDictionary:(GPBBoolDoubleDictionary *)otherDictionary;
4375
Austin Schuh40c16522018-10-28 20:27:54 -07004376/**
4377 * Sets the value for the given key.
4378 *
4379 * @param value The value to set.
4380 * @param key The key under which to store the value.
4381 **/
4382- (void)setDouble:(double)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004383
Austin Schuh40c16522018-10-28 20:27:54 -07004384/**
4385 * Removes the entry for the given key.
4386 *
4387 * @param aKey Key to be removed from this dictionary.
4388 **/
4389- (void)removeDoubleForKey:(BOOL)aKey;
4390
4391/**
4392 * Removes all entries in this dictionary.
4393 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004394- (void)removeAll;
4395
4396@end
4397
4398#pragma mark - Bool -> Enum
4399
Austin Schuh40c16522018-10-28 20:27:54 -07004400/**
4401 * Class used for map fields of <BOOL, int32_t>
4402 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4403 *
4404 * @note This class is not meant to be subclassed.
4405 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004406@interface GPBBoolEnumDictionary : NSObject <NSCopying>
4407
Austin Schuh40c16522018-10-28 20:27:54 -07004408/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05004409@property(nonatomic, readonly) NSUInteger count;
Austin Schuh40c16522018-10-28 20:27:54 -07004410/** The validation function to check if the enums are valid. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05004411@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
4412
Austin Schuh40c16522018-10-28 20:27:54 -07004413/**
4414 * Initializes a dictionary with the given validation function.
4415 *
4416 * @param func The enum validation function for the dictionary.
4417 *
4418 * @return A newly initialized dictionary.
4419 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004420- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Austin Schuh40c16522018-10-28 20:27:54 -07004421
4422/**
4423 * Initializes a dictionary with the entries given.
4424 *
4425 * @param func The enum validation function for the dictionary.
4426 * @param values The raw enum values values to be placed in the dictionary.
4427 * @param keys The keys under which to store the values.
4428 * @param count The number of entries to store in the dictionary.
4429 *
4430 * @return A newly initialized dictionary with the keys and values in it.
4431 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004432- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Austin Schuh40c16522018-10-28 20:27:54 -07004433 rawValues:(const int32_t [__nullable])values
4434 forKeys:(const BOOL [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05004435 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07004436
4437/**
4438 * Initializes a dictionary with the entries from the given.
4439 * dictionary.
4440 *
4441 * @param dictionary Dictionary containing the entries to add to the dictionary.
4442 *
4443 * @return A newly initialized dictionary with the entries from the given
4444 * dictionary in it.
4445 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004446- (instancetype)initWithDictionary:(GPBBoolEnumDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07004447
4448/**
4449 * Initializes a dictionary with the given capacity.
4450 *
4451 * @param func The enum validation function for the dictionary.
4452 * @param numItems Capacity needed for the dictionary.
4453 *
4454 * @return A newly initialized dictionary with the given capacity.
4455 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004456- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
4457 capacity:(NSUInteger)numItems;
4458
4459// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
4460// is not a valid enumerator as defined by validationFunc. If the actual value is
4461// desired, use "raw" version of the method.
4462
Austin Schuh40c16522018-10-28 20:27:54 -07004463/**
4464 * Gets the value for the given key.
4465 *
4466 * @param value Pointer into which the value will be set, if found.
4467 * @param key Key under which the value is stored, if present.
4468 *
4469 * @return YES if the key was found and the value was copied, NO otherwise.
4470 **/
4471- (BOOL)getEnum:(nullable int32_t *)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004472
Austin Schuh40c16522018-10-28 20:27:54 -07004473/**
4474 * Enumerates the keys and values on this dictionary with the given block.
4475 *
4476 * @param block The block to enumerate with.
4477 * **key**: The key for the current entry.
4478 * **value**: The value for the current entry
4479 * **stop**: A pointer to a boolean that when set stops the enumeration.
4480 **/
4481- (void)enumerateKeysAndEnumsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05004482 (void (^)(BOOL key, int32_t value, BOOL *stop))block;
4483
Austin Schuh40c16522018-10-28 20:27:54 -07004484/**
4485 * Gets the raw enum value for the given key.
4486 *
4487 * @note This method bypass the validationFunc to enable the access of values that
4488 * were not known at the time the binary was compiled.
4489 *
4490 * @param rawValue Pointer into which the value will be set, if found.
4491 * @param key Key under which the value is stored, if present.
4492 *
4493 * @return YES if the key was found and the value was copied, NO otherwise.
4494 **/
4495- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004496
Austin Schuh40c16522018-10-28 20:27:54 -07004497/**
4498 * Enumerates the keys and values on this dictionary with the given block.
4499 *
4500 * @note This method bypass the validationFunc to enable the access of values that
4501 * were not known at the time the binary was compiled.
4502 *
4503 * @param block The block to enumerate with.
4504 * **key**: The key for the current entry.
4505 * **rawValue**: The value for the current entry
4506 * **stop**: A pointer to a boolean that when set stops the enumeration.
4507 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004508- (void)enumerateKeysAndRawValuesUsingBlock:
4509 (void (^)(BOOL key, int32_t rawValue, BOOL *stop))block;
4510
Austin Schuh40c16522018-10-28 20:27:54 -07004511/**
4512 * Adds the keys and raw enum values from another dictionary.
4513 *
4514 * @note This method bypass the validationFunc to enable the setting of values that
4515 * were not known at the time the binary was compiled.
4516 *
4517 * @param otherDictionary Dictionary containing entries to be added to this
4518 * dictionary.
4519 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004520- (void)addRawEntriesFromDictionary:(GPBBoolEnumDictionary *)otherDictionary;
4521
4522// If value is not a valid enumerator as defined by validationFunc, these
4523// methods will assert in debug, and will log in release and assign the value
4524// to the default value. Use the rawValue methods below to assign non enumerator
4525// values.
4526
Austin Schuh40c16522018-10-28 20:27:54 -07004527/**
4528 * Sets the value for the given key.
4529 *
4530 * @param value The value to set.
4531 * @param key The key under which to store the value.
4532 **/
4533- (void)setEnum:(int32_t)value forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004534
Austin Schuh40c16522018-10-28 20:27:54 -07004535/**
4536 * Sets the raw enum value for the given key.
4537 *
4538 * @note This method bypass the validationFunc to enable the setting of values that
4539 * were not known at the time the binary was compiled.
4540 *
4541 * @param rawValue The raw enum value to set.
4542 * @param key The key under which to store the raw enum value.
4543 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004544- (void)setRawValue:(int32_t)rawValue forKey:(BOOL)key;
4545
Austin Schuh40c16522018-10-28 20:27:54 -07004546/**
4547 * Removes the entry for the given key.
4548 *
4549 * @param aKey Key to be removed from this dictionary.
4550 **/
4551- (void)removeEnumForKey:(BOOL)aKey;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004552
Austin Schuh40c16522018-10-28 20:27:54 -07004553/**
4554 * Removes all entries in this dictionary.
4555 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004556- (void)removeAll;
4557
4558@end
4559
4560#pragma mark - Bool -> Object
4561
Austin Schuh40c16522018-10-28 20:27:54 -07004562/**
4563 * Class used for map fields of <BOOL, ObjectType>
4564 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4565 *
4566 * @note This class is not meant to be subclassed.
4567 **/
4568@interface GPBBoolObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
Brian Silverman9c614bc2016-02-15 20:20:02 -05004569
Austin Schuh40c16522018-10-28 20:27:54 -07004570/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05004571@property(nonatomic, readonly) NSUInteger count;
4572
Austin Schuh40c16522018-10-28 20:27:54 -07004573/**
4574 * Initializes this dictionary, copying the given values and keys.
4575 *
4576 * @param objects The values to be placed in this dictionary.
4577 * @param keys The keys under which to store the values.
4578 * @param count The number of elements to copy into the dictionary.
4579 *
4580 * @return A newly initialized dictionary with a copy of the values and keys.
4581 **/
4582- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
4583 forKeys:(const BOOL [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05004584 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07004585
4586/**
4587 * Initializes this dictionary, copying the entries from the given dictionary.
4588 *
4589 * @param dictionary Dictionary containing the entries to add to this dictionary.
4590 *
4591 * @return A newly initialized dictionary with the entries of the given dictionary.
4592 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004593- (instancetype)initWithDictionary:(GPBBoolObjectDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07004594
4595/**
4596 * Initializes this dictionary with the requested capacity.
4597 *
4598 * @param numItems Number of items needed for this dictionary.
4599 *
4600 * @return A newly initialized dictionary with the requested capacity.
4601 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004602- (instancetype)initWithCapacity:(NSUInteger)numItems;
4603
Austin Schuh40c16522018-10-28 20:27:54 -07004604/**
4605 * Fetches the object stored under the given key.
4606 *
4607 * @param key Key under which the value is stored, if present.
4608 *
4609 * @return The object if found, nil otherwise.
4610 **/
4611- (ObjectType)objectForKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004612
Austin Schuh40c16522018-10-28 20:27:54 -07004613/**
4614 * Enumerates the keys and values on this dictionary with the given block.
4615 *
4616 * @param block The block to enumerate with.
4617 * **key**: The key for the current entry.
4618 * **object**: The value for the current entry
4619 * **stop**: A pointer to a boolean that when set stops the enumeration.
4620 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004621- (void)enumerateKeysAndObjectsUsingBlock:
Austin Schuh40c16522018-10-28 20:27:54 -07004622 (void (^)(BOOL key, ObjectType object, BOOL *stop))block;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004623
Austin Schuh40c16522018-10-28 20:27:54 -07004624/**
4625 * Adds the keys and values from another dictionary.
4626 *
4627 * @param otherDictionary Dictionary containing entries to be added to this
4628 * dictionary.
4629 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004630- (void)addEntriesFromDictionary:(GPBBoolObjectDictionary *)otherDictionary;
4631
Austin Schuh40c16522018-10-28 20:27:54 -07004632/**
4633 * Sets the value for the given key.
4634 *
4635 * @param object The value to set.
4636 * @param key The key under which to store the value.
4637 **/
4638- (void)setObject:(ObjectType)object forKey:(BOOL)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004639
Austin Schuh40c16522018-10-28 20:27:54 -07004640/**
4641 * Removes the entry for the given key.
4642 *
4643 * @param aKey Key to be removed from this dictionary.
4644 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004645- (void)removeObjectForKey:(BOOL)aKey;
Austin Schuh40c16522018-10-28 20:27:54 -07004646
4647/**
4648 * Removes all entries in this dictionary.
4649 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004650- (void)removeAll;
4651
4652@end
4653
4654#pragma mark - String -> UInt32
4655
Austin Schuh40c16522018-10-28 20:27:54 -07004656/**
4657 * Class used for map fields of <NSString, uint32_t>
4658 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4659 *
4660 * @note This class is not meant to be subclassed.
4661 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004662@interface GPBStringUInt32Dictionary : NSObject <NSCopying>
4663
Austin Schuh40c16522018-10-28 20:27:54 -07004664/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05004665@property(nonatomic, readonly) NSUInteger count;
4666
Austin Schuh40c16522018-10-28 20:27:54 -07004667/**
4668 * Initializes this dictionary, copying the given values and keys.
4669 *
4670 * @param values The values to be placed in this dictionary.
4671 * @param keys The keys under which to store the values.
4672 * @param count The number of elements to copy into the dictionary.
4673 *
4674 * @return A newly initialized dictionary with a copy of the values and keys.
4675 **/
4676- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
4677 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
4678 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004679
Austin Schuh40c16522018-10-28 20:27:54 -07004680/**
4681 * Initializes this dictionary, copying the entries from the given dictionary.
4682 *
4683 * @param dictionary Dictionary containing the entries to add to this dictionary.
4684 *
4685 * @return A newly initialized dictionary with the entries of the given dictionary.
4686 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004687- (instancetype)initWithDictionary:(GPBStringUInt32Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07004688
4689/**
4690 * Initializes this dictionary with the requested capacity.
4691 *
4692 * @param numItems Number of items needed for this dictionary.
4693 *
4694 * @return A newly initialized dictionary with the requested capacity.
4695 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004696- (instancetype)initWithCapacity:(NSUInteger)numItems;
4697
Austin Schuh40c16522018-10-28 20:27:54 -07004698/**
4699 * Gets the value for the given key.
4700 *
4701 * @param value Pointer into which the value will be set, if found.
4702 * @param key Key under which the value is stored, if present.
4703 *
4704 * @return YES if the key was found and the value was copied, NO otherwise.
4705 **/
4706- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004707
Austin Schuh40c16522018-10-28 20:27:54 -07004708/**
4709 * Enumerates the keys and values on this dictionary with the given block.
4710 *
4711 * @param block The block to enumerate with.
4712 * **key**: The key for the current entry.
4713 * **value**: The value for the current entry
4714 * **stop**: A pointer to a boolean that when set stops the enumeration.
4715 **/
4716- (void)enumerateKeysAndUInt32sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05004717 (void (^)(NSString *key, uint32_t value, BOOL *stop))block;
4718
Austin Schuh40c16522018-10-28 20:27:54 -07004719/**
4720 * Adds the keys and values from another dictionary.
4721 *
4722 * @param otherDictionary Dictionary containing entries to be added to this
4723 * dictionary.
4724 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004725- (void)addEntriesFromDictionary:(GPBStringUInt32Dictionary *)otherDictionary;
4726
Austin Schuh40c16522018-10-28 20:27:54 -07004727/**
4728 * Sets the value for the given key.
4729 *
4730 * @param value The value to set.
4731 * @param key The key under which to store the value.
4732 **/
4733- (void)setUInt32:(uint32_t)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004734
Austin Schuh40c16522018-10-28 20:27:54 -07004735/**
4736 * Removes the entry for the given key.
4737 *
4738 * @param aKey Key to be removed from this dictionary.
4739 **/
4740- (void)removeUInt32ForKey:(NSString *)aKey;
4741
4742/**
4743 * Removes all entries in this dictionary.
4744 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004745- (void)removeAll;
4746
4747@end
4748
4749#pragma mark - String -> Int32
4750
Austin Schuh40c16522018-10-28 20:27:54 -07004751/**
4752 * Class used for map fields of <NSString, int32_t>
4753 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4754 *
4755 * @note This class is not meant to be subclassed.
4756 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004757@interface GPBStringInt32Dictionary : NSObject <NSCopying>
4758
Austin Schuh40c16522018-10-28 20:27:54 -07004759/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05004760@property(nonatomic, readonly) NSUInteger count;
4761
Austin Schuh40c16522018-10-28 20:27:54 -07004762/**
4763 * Initializes this dictionary, copying the given values and keys.
4764 *
4765 * @param values The values to be placed in this dictionary.
4766 * @param keys The keys under which to store the values.
4767 * @param count The number of elements to copy into the dictionary.
4768 *
4769 * @return A newly initialized dictionary with a copy of the values and keys.
4770 **/
4771- (instancetype)initWithInt32s:(const int32_t [__nullable])values
4772 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05004773 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07004774
4775/**
4776 * Initializes this dictionary, copying the entries from the given dictionary.
4777 *
4778 * @param dictionary Dictionary containing the entries to add to this dictionary.
4779 *
4780 * @return A newly initialized dictionary with the entries of the given dictionary.
4781 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004782- (instancetype)initWithDictionary:(GPBStringInt32Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07004783
4784/**
4785 * Initializes this dictionary with the requested capacity.
4786 *
4787 * @param numItems Number of items needed for this dictionary.
4788 *
4789 * @return A newly initialized dictionary with the requested capacity.
4790 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004791- (instancetype)initWithCapacity:(NSUInteger)numItems;
4792
Austin Schuh40c16522018-10-28 20:27:54 -07004793/**
4794 * Gets the value for the given key.
4795 *
4796 * @param value Pointer into which the value will be set, if found.
4797 * @param key Key under which the value is stored, if present.
4798 *
4799 * @return YES if the key was found and the value was copied, NO otherwise.
4800 **/
4801- (BOOL)getInt32:(nullable int32_t *)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004802
Austin Schuh40c16522018-10-28 20:27:54 -07004803/**
4804 * Enumerates the keys and values on this dictionary with the given block.
4805 *
4806 * @param block The block to enumerate with.
4807 * **key**: The key for the current entry.
4808 * **value**: The value for the current entry
4809 * **stop**: A pointer to a boolean that when set stops the enumeration.
4810 **/
4811- (void)enumerateKeysAndInt32sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05004812 (void (^)(NSString *key, int32_t value, BOOL *stop))block;
4813
Austin Schuh40c16522018-10-28 20:27:54 -07004814/**
4815 * Adds the keys and values from another dictionary.
4816 *
4817 * @param otherDictionary Dictionary containing entries to be added to this
4818 * dictionary.
4819 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004820- (void)addEntriesFromDictionary:(GPBStringInt32Dictionary *)otherDictionary;
4821
Austin Schuh40c16522018-10-28 20:27:54 -07004822/**
4823 * Sets the value for the given key.
4824 *
4825 * @param value The value to set.
4826 * @param key The key under which to store the value.
4827 **/
4828- (void)setInt32:(int32_t)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004829
Austin Schuh40c16522018-10-28 20:27:54 -07004830/**
4831 * Removes the entry for the given key.
4832 *
4833 * @param aKey Key to be removed from this dictionary.
4834 **/
4835- (void)removeInt32ForKey:(NSString *)aKey;
4836
4837/**
4838 * Removes all entries in this dictionary.
4839 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004840- (void)removeAll;
4841
4842@end
4843
4844#pragma mark - String -> UInt64
4845
Austin Schuh40c16522018-10-28 20:27:54 -07004846/**
4847 * Class used for map fields of <NSString, uint64_t>
4848 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4849 *
4850 * @note This class is not meant to be subclassed.
4851 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004852@interface GPBStringUInt64Dictionary : NSObject <NSCopying>
4853
Austin Schuh40c16522018-10-28 20:27:54 -07004854/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05004855@property(nonatomic, readonly) NSUInteger count;
4856
Austin Schuh40c16522018-10-28 20:27:54 -07004857/**
4858 * Initializes this dictionary, copying the given values and keys.
4859 *
4860 * @param values The values to be placed in this dictionary.
4861 * @param keys The keys under which to store the values.
4862 * @param count The number of elements to copy into the dictionary.
4863 *
4864 * @return A newly initialized dictionary with a copy of the values and keys.
4865 **/
4866- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
4867 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
4868 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004869
Austin Schuh40c16522018-10-28 20:27:54 -07004870/**
4871 * Initializes this dictionary, copying the entries from the given dictionary.
4872 *
4873 * @param dictionary Dictionary containing the entries to add to this dictionary.
4874 *
4875 * @return A newly initialized dictionary with the entries of the given dictionary.
4876 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004877- (instancetype)initWithDictionary:(GPBStringUInt64Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07004878
4879/**
4880 * Initializes this dictionary with the requested capacity.
4881 *
4882 * @param numItems Number of items needed for this dictionary.
4883 *
4884 * @return A newly initialized dictionary with the requested capacity.
4885 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004886- (instancetype)initWithCapacity:(NSUInteger)numItems;
4887
Austin Schuh40c16522018-10-28 20:27:54 -07004888/**
4889 * Gets the value for the given key.
4890 *
4891 * @param value Pointer into which the value will be set, if found.
4892 * @param key Key under which the value is stored, if present.
4893 *
4894 * @return YES if the key was found and the value was copied, NO otherwise.
4895 **/
4896- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004897
Austin Schuh40c16522018-10-28 20:27:54 -07004898/**
4899 * Enumerates the keys and values on this dictionary with the given block.
4900 *
4901 * @param block The block to enumerate with.
4902 * **key**: The key for the current entry.
4903 * **value**: The value for the current entry
4904 * **stop**: A pointer to a boolean that when set stops the enumeration.
4905 **/
4906- (void)enumerateKeysAndUInt64sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05004907 (void (^)(NSString *key, uint64_t value, BOOL *stop))block;
4908
Austin Schuh40c16522018-10-28 20:27:54 -07004909/**
4910 * Adds the keys and values from another dictionary.
4911 *
4912 * @param otherDictionary Dictionary containing entries to be added to this
4913 * dictionary.
4914 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004915- (void)addEntriesFromDictionary:(GPBStringUInt64Dictionary *)otherDictionary;
4916
Austin Schuh40c16522018-10-28 20:27:54 -07004917/**
4918 * Sets the value for the given key.
4919 *
4920 * @param value The value to set.
4921 * @param key The key under which to store the value.
4922 **/
4923- (void)setUInt64:(uint64_t)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004924
Austin Schuh40c16522018-10-28 20:27:54 -07004925/**
4926 * Removes the entry for the given key.
4927 *
4928 * @param aKey Key to be removed from this dictionary.
4929 **/
4930- (void)removeUInt64ForKey:(NSString *)aKey;
4931
4932/**
4933 * Removes all entries in this dictionary.
4934 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004935- (void)removeAll;
4936
4937@end
4938
4939#pragma mark - String -> Int64
4940
Austin Schuh40c16522018-10-28 20:27:54 -07004941/**
4942 * Class used for map fields of <NSString, int64_t>
4943 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4944 *
4945 * @note This class is not meant to be subclassed.
4946 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004947@interface GPBStringInt64Dictionary : NSObject <NSCopying>
4948
Austin Schuh40c16522018-10-28 20:27:54 -07004949/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05004950@property(nonatomic, readonly) NSUInteger count;
4951
Austin Schuh40c16522018-10-28 20:27:54 -07004952/**
4953 * Initializes this dictionary, copying the given values and keys.
4954 *
4955 * @param values The values to be placed in this dictionary.
4956 * @param keys The keys under which to store the values.
4957 * @param count The number of elements to copy into the dictionary.
4958 *
4959 * @return A newly initialized dictionary with a copy of the values and keys.
4960 **/
4961- (instancetype)initWithInt64s:(const int64_t [__nullable])values
4962 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05004963 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07004964
4965/**
4966 * Initializes this dictionary, copying the entries from the given dictionary.
4967 *
4968 * @param dictionary Dictionary containing the entries to add to this dictionary.
4969 *
4970 * @return A newly initialized dictionary with the entries of the given dictionary.
4971 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004972- (instancetype)initWithDictionary:(GPBStringInt64Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07004973
4974/**
4975 * Initializes this dictionary with the requested capacity.
4976 *
4977 * @param numItems Number of items needed for this dictionary.
4978 *
4979 * @return A newly initialized dictionary with the requested capacity.
4980 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05004981- (instancetype)initWithCapacity:(NSUInteger)numItems;
4982
Austin Schuh40c16522018-10-28 20:27:54 -07004983/**
4984 * Gets the value for the given key.
4985 *
4986 * @param value Pointer into which the value will be set, if found.
4987 * @param key Key under which the value is stored, if present.
4988 *
4989 * @return YES if the key was found and the value was copied, NO otherwise.
4990 **/
4991- (BOOL)getInt64:(nullable int64_t *)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05004992
Austin Schuh40c16522018-10-28 20:27:54 -07004993/**
4994 * Enumerates the keys and values on this dictionary with the given block.
4995 *
4996 * @param block The block to enumerate with.
4997 * **key**: The key for the current entry.
4998 * **value**: The value for the current entry
4999 * **stop**: A pointer to a boolean that when set stops the enumeration.
5000 **/
5001- (void)enumerateKeysAndInt64sUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05005002 (void (^)(NSString *key, int64_t value, BOOL *stop))block;
5003
Austin Schuh40c16522018-10-28 20:27:54 -07005004/**
5005 * Adds the keys and values from another dictionary.
5006 *
5007 * @param otherDictionary Dictionary containing entries to be added to this
5008 * dictionary.
5009 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005010- (void)addEntriesFromDictionary:(GPBStringInt64Dictionary *)otherDictionary;
5011
Austin Schuh40c16522018-10-28 20:27:54 -07005012/**
5013 * Sets the value for the given key.
5014 *
5015 * @param value The value to set.
5016 * @param key The key under which to store the value.
5017 **/
5018- (void)setInt64:(int64_t)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005019
Austin Schuh40c16522018-10-28 20:27:54 -07005020/**
5021 * Removes the entry for the given key.
5022 *
5023 * @param aKey Key to be removed from this dictionary.
5024 **/
5025- (void)removeInt64ForKey:(NSString *)aKey;
5026
5027/**
5028 * Removes all entries in this dictionary.
5029 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005030- (void)removeAll;
5031
5032@end
5033
5034#pragma mark - String -> Bool
5035
Austin Schuh40c16522018-10-28 20:27:54 -07005036/**
5037 * Class used for map fields of <NSString, BOOL>
5038 * values. This performs better than boxing into NSNumbers in NSDictionaries.
5039 *
5040 * @note This class is not meant to be subclassed.
5041 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005042@interface GPBStringBoolDictionary : NSObject <NSCopying>
5043
Austin Schuh40c16522018-10-28 20:27:54 -07005044/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05005045@property(nonatomic, readonly) NSUInteger count;
5046
Austin Schuh40c16522018-10-28 20:27:54 -07005047/**
5048 * Initializes this dictionary, copying the given values and keys.
5049 *
5050 * @param values The values to be placed in this dictionary.
5051 * @param keys The keys under which to store the values.
5052 * @param count The number of elements to copy into the dictionary.
5053 *
5054 * @return A newly initialized dictionary with a copy of the values and keys.
5055 **/
5056- (instancetype)initWithBools:(const BOOL [__nullable])values
5057 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
5058 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005059
Austin Schuh40c16522018-10-28 20:27:54 -07005060/**
5061 * Initializes this dictionary, copying the entries from the given dictionary.
5062 *
5063 * @param dictionary Dictionary containing the entries to add to this dictionary.
5064 *
5065 * @return A newly initialized dictionary with the entries of the given dictionary.
5066 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005067- (instancetype)initWithDictionary:(GPBStringBoolDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07005068
5069/**
5070 * Initializes this dictionary with the requested capacity.
5071 *
5072 * @param numItems Number of items needed for this dictionary.
5073 *
5074 * @return A newly initialized dictionary with the requested capacity.
5075 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005076- (instancetype)initWithCapacity:(NSUInteger)numItems;
5077
Austin Schuh40c16522018-10-28 20:27:54 -07005078/**
5079 * Gets the value for the given key.
5080 *
5081 * @param value Pointer into which the value will be set, if found.
5082 * @param key Key under which the value is stored, if present.
5083 *
5084 * @return YES if the key was found and the value was copied, NO otherwise.
5085 **/
5086- (BOOL)getBool:(nullable BOOL *)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005087
Austin Schuh40c16522018-10-28 20:27:54 -07005088/**
5089 * Enumerates the keys and values on this dictionary with the given block.
5090 *
5091 * @param block The block to enumerate with.
5092 * **key**: The key for the current entry.
5093 * **value**: The value for the current entry
5094 * **stop**: A pointer to a boolean that when set stops the enumeration.
5095 **/
5096- (void)enumerateKeysAndBoolsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05005097 (void (^)(NSString *key, BOOL value, BOOL *stop))block;
5098
Austin Schuh40c16522018-10-28 20:27:54 -07005099/**
5100 * Adds the keys and values from another dictionary.
5101 *
5102 * @param otherDictionary Dictionary containing entries to be added to this
5103 * dictionary.
5104 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005105- (void)addEntriesFromDictionary:(GPBStringBoolDictionary *)otherDictionary;
5106
Austin Schuh40c16522018-10-28 20:27:54 -07005107/**
5108 * Sets the value for the given key.
5109 *
5110 * @param value The value to set.
5111 * @param key The key under which to store the value.
5112 **/
5113- (void)setBool:(BOOL)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005114
Austin Schuh40c16522018-10-28 20:27:54 -07005115/**
5116 * Removes the entry for the given key.
5117 *
5118 * @param aKey Key to be removed from this dictionary.
5119 **/
5120- (void)removeBoolForKey:(NSString *)aKey;
5121
5122/**
5123 * Removes all entries in this dictionary.
5124 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005125- (void)removeAll;
5126
5127@end
5128
5129#pragma mark - String -> Float
5130
Austin Schuh40c16522018-10-28 20:27:54 -07005131/**
5132 * Class used for map fields of <NSString, float>
5133 * values. This performs better than boxing into NSNumbers in NSDictionaries.
5134 *
5135 * @note This class is not meant to be subclassed.
5136 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005137@interface GPBStringFloatDictionary : NSObject <NSCopying>
5138
Austin Schuh40c16522018-10-28 20:27:54 -07005139/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05005140@property(nonatomic, readonly) NSUInteger count;
5141
Austin Schuh40c16522018-10-28 20:27:54 -07005142/**
5143 * Initializes this dictionary, copying the given values and keys.
5144 *
5145 * @param values The values to be placed in this dictionary.
5146 * @param keys The keys under which to store the values.
5147 * @param count The number of elements to copy into the dictionary.
5148 *
5149 * @return A newly initialized dictionary with a copy of the values and keys.
5150 **/
5151- (instancetype)initWithFloats:(const float [__nullable])values
5152 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05005153 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07005154
5155/**
5156 * Initializes this dictionary, copying the entries from the given dictionary.
5157 *
5158 * @param dictionary Dictionary containing the entries to add to this dictionary.
5159 *
5160 * @return A newly initialized dictionary with the entries of the given dictionary.
5161 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005162- (instancetype)initWithDictionary:(GPBStringFloatDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07005163
5164/**
5165 * Initializes this dictionary with the requested capacity.
5166 *
5167 * @param numItems Number of items needed for this dictionary.
5168 *
5169 * @return A newly initialized dictionary with the requested capacity.
5170 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005171- (instancetype)initWithCapacity:(NSUInteger)numItems;
5172
Austin Schuh40c16522018-10-28 20:27:54 -07005173/**
5174 * Gets the value for the given key.
5175 *
5176 * @param value Pointer into which the value will be set, if found.
5177 * @param key Key under which the value is stored, if present.
5178 *
5179 * @return YES if the key was found and the value was copied, NO otherwise.
5180 **/
5181- (BOOL)getFloat:(nullable float *)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005182
Austin Schuh40c16522018-10-28 20:27:54 -07005183/**
5184 * Enumerates the keys and values on this dictionary with the given block.
5185 *
5186 * @param block The block to enumerate with.
5187 * **key**: The key for the current entry.
5188 * **value**: The value for the current entry
5189 * **stop**: A pointer to a boolean that when set stops the enumeration.
5190 **/
5191- (void)enumerateKeysAndFloatsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05005192 (void (^)(NSString *key, float value, BOOL *stop))block;
5193
Austin Schuh40c16522018-10-28 20:27:54 -07005194/**
5195 * Adds the keys and values from another dictionary.
5196 *
5197 * @param otherDictionary Dictionary containing entries to be added to this
5198 * dictionary.
5199 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005200- (void)addEntriesFromDictionary:(GPBStringFloatDictionary *)otherDictionary;
5201
Austin Schuh40c16522018-10-28 20:27:54 -07005202/**
5203 * Sets the value for the given key.
5204 *
5205 * @param value The value to set.
5206 * @param key The key under which to store the value.
5207 **/
5208- (void)setFloat:(float)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005209
Austin Schuh40c16522018-10-28 20:27:54 -07005210/**
5211 * Removes the entry for the given key.
5212 *
5213 * @param aKey Key to be removed from this dictionary.
5214 **/
5215- (void)removeFloatForKey:(NSString *)aKey;
5216
5217/**
5218 * Removes all entries in this dictionary.
5219 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005220- (void)removeAll;
5221
5222@end
5223
5224#pragma mark - String -> Double
5225
Austin Schuh40c16522018-10-28 20:27:54 -07005226/**
5227 * Class used for map fields of <NSString, double>
5228 * values. This performs better than boxing into NSNumbers in NSDictionaries.
5229 *
5230 * @note This class is not meant to be subclassed.
5231 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005232@interface GPBStringDoubleDictionary : NSObject <NSCopying>
5233
Austin Schuh40c16522018-10-28 20:27:54 -07005234/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05005235@property(nonatomic, readonly) NSUInteger count;
5236
Austin Schuh40c16522018-10-28 20:27:54 -07005237/**
5238 * Initializes this dictionary, copying the given values and keys.
5239 *
5240 * @param values The values to be placed in this dictionary.
5241 * @param keys The keys under which to store the values.
5242 * @param count The number of elements to copy into the dictionary.
5243 *
5244 * @return A newly initialized dictionary with a copy of the values and keys.
5245 **/
5246- (instancetype)initWithDoubles:(const double [__nullable])values
5247 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
5248 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005249
Austin Schuh40c16522018-10-28 20:27:54 -07005250/**
5251 * Initializes this dictionary, copying the entries from the given dictionary.
5252 *
5253 * @param dictionary Dictionary containing the entries to add to this dictionary.
5254 *
5255 * @return A newly initialized dictionary with the entries of the given dictionary.
5256 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005257- (instancetype)initWithDictionary:(GPBStringDoubleDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07005258
5259/**
5260 * Initializes this dictionary with the requested capacity.
5261 *
5262 * @param numItems Number of items needed for this dictionary.
5263 *
5264 * @return A newly initialized dictionary with the requested capacity.
5265 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005266- (instancetype)initWithCapacity:(NSUInteger)numItems;
5267
Austin Schuh40c16522018-10-28 20:27:54 -07005268/**
5269 * Gets the value for the given key.
5270 *
5271 * @param value Pointer into which the value will be set, if found.
5272 * @param key Key under which the value is stored, if present.
5273 *
5274 * @return YES if the key was found and the value was copied, NO otherwise.
5275 **/
5276- (BOOL)getDouble:(nullable double *)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005277
Austin Schuh40c16522018-10-28 20:27:54 -07005278/**
5279 * Enumerates the keys and values on this dictionary with the given block.
5280 *
5281 * @param block The block to enumerate with.
5282 * **key**: The key for the current entry.
5283 * **value**: The value for the current entry
5284 * **stop**: A pointer to a boolean that when set stops the enumeration.
5285 **/
5286- (void)enumerateKeysAndDoublesUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05005287 (void (^)(NSString *key, double value, BOOL *stop))block;
5288
Austin Schuh40c16522018-10-28 20:27:54 -07005289/**
5290 * Adds the keys and values from another dictionary.
5291 *
5292 * @param otherDictionary Dictionary containing entries to be added to this
5293 * dictionary.
5294 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005295- (void)addEntriesFromDictionary:(GPBStringDoubleDictionary *)otherDictionary;
5296
Austin Schuh40c16522018-10-28 20:27:54 -07005297/**
5298 * Sets the value for the given key.
5299 *
5300 * @param value The value to set.
5301 * @param key The key under which to store the value.
5302 **/
5303- (void)setDouble:(double)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005304
Austin Schuh40c16522018-10-28 20:27:54 -07005305/**
5306 * Removes the entry for the given key.
5307 *
5308 * @param aKey Key to be removed from this dictionary.
5309 **/
5310- (void)removeDoubleForKey:(NSString *)aKey;
5311
5312/**
5313 * Removes all entries in this dictionary.
5314 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005315- (void)removeAll;
5316
5317@end
5318
5319#pragma mark - String -> Enum
5320
Austin Schuh40c16522018-10-28 20:27:54 -07005321/**
5322 * Class used for map fields of <NSString, int32_t>
5323 * values. This performs better than boxing into NSNumbers in NSDictionaries.
5324 *
5325 * @note This class is not meant to be subclassed.
5326 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005327@interface GPBStringEnumDictionary : NSObject <NSCopying>
5328
Austin Schuh40c16522018-10-28 20:27:54 -07005329/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05005330@property(nonatomic, readonly) NSUInteger count;
Austin Schuh40c16522018-10-28 20:27:54 -07005331/** The validation function to check if the enums are valid. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05005332@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
5333
Austin Schuh40c16522018-10-28 20:27:54 -07005334/**
5335 * Initializes a dictionary with the given validation function.
5336 *
5337 * @param func The enum validation function for the dictionary.
5338 *
5339 * @return A newly initialized dictionary.
5340 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005341- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Austin Schuh40c16522018-10-28 20:27:54 -07005342
5343/**
5344 * Initializes a dictionary with the entries given.
5345 *
5346 * @param func The enum validation function for the dictionary.
5347 * @param values The raw enum values values to be placed in the dictionary.
5348 * @param keys The keys under which to store the values.
5349 * @param count The number of entries to store in the dictionary.
5350 *
5351 * @return A newly initialized dictionary with the keys and values in it.
5352 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005353- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Austin Schuh40c16522018-10-28 20:27:54 -07005354 rawValues:(const int32_t [__nullable])values
5355 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05005356 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07005357
5358/**
5359 * Initializes a dictionary with the entries from the given.
5360 * dictionary.
5361 *
5362 * @param dictionary Dictionary containing the entries to add to the dictionary.
5363 *
5364 * @return A newly initialized dictionary with the entries from the given
5365 * dictionary in it.
5366 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005367- (instancetype)initWithDictionary:(GPBStringEnumDictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07005368
5369/**
5370 * Initializes a dictionary with the given capacity.
5371 *
5372 * @param func The enum validation function for the dictionary.
5373 * @param numItems Capacity needed for the dictionary.
5374 *
5375 * @return A newly initialized dictionary with the given capacity.
5376 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005377- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
5378 capacity:(NSUInteger)numItems;
5379
5380// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
5381// is not a valid enumerator as defined by validationFunc. If the actual value is
5382// desired, use "raw" version of the method.
5383
Austin Schuh40c16522018-10-28 20:27:54 -07005384/**
5385 * Gets the value for the given key.
5386 *
5387 * @param value Pointer into which the value will be set, if found.
5388 * @param key Key under which the value is stored, if present.
5389 *
5390 * @return YES if the key was found and the value was copied, NO otherwise.
5391 **/
5392- (BOOL)getEnum:(nullable int32_t *)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005393
Austin Schuh40c16522018-10-28 20:27:54 -07005394/**
5395 * Enumerates the keys and values on this dictionary with the given block.
5396 *
5397 * @param block The block to enumerate with.
5398 * **key**: The key for the current entry.
5399 * **value**: The value for the current entry
5400 * **stop**: A pointer to a boolean that when set stops the enumeration.
5401 **/
5402- (void)enumerateKeysAndEnumsUsingBlock:
Brian Silverman9c614bc2016-02-15 20:20:02 -05005403 (void (^)(NSString *key, int32_t value, BOOL *stop))block;
5404
Austin Schuh40c16522018-10-28 20:27:54 -07005405/**
5406 * Gets the raw enum value for the given key.
5407 *
5408 * @note This method bypass the validationFunc to enable the access of values that
5409 * were not known at the time the binary was compiled.
5410 *
5411 * @param rawValue Pointer into which the value will be set, if found.
5412 * @param key Key under which the value is stored, if present.
5413 *
5414 * @return YES if the key was found and the value was copied, NO otherwise.
5415 **/
5416- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005417
Austin Schuh40c16522018-10-28 20:27:54 -07005418/**
5419 * Enumerates the keys and values on this dictionary with the given block.
5420 *
5421 * @note This method bypass the validationFunc to enable the access of values that
5422 * were not known at the time the binary was compiled.
5423 *
5424 * @param block The block to enumerate with.
5425 * **key**: The key for the current entry.
5426 * **rawValue**: The value for the current entry
5427 * **stop**: A pointer to a boolean that when set stops the enumeration.
5428 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005429- (void)enumerateKeysAndRawValuesUsingBlock:
5430 (void (^)(NSString *key, int32_t rawValue, BOOL *stop))block;
5431
Austin Schuh40c16522018-10-28 20:27:54 -07005432/**
5433 * Adds the keys and raw enum values from another dictionary.
5434 *
5435 * @note This method bypass the validationFunc to enable the setting of values that
5436 * were not known at the time the binary was compiled.
5437 *
5438 * @param otherDictionary Dictionary containing entries to be added to this
5439 * dictionary.
5440 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005441- (void)addRawEntriesFromDictionary:(GPBStringEnumDictionary *)otherDictionary;
5442
5443// If value is not a valid enumerator as defined by validationFunc, these
5444// methods will assert in debug, and will log in release and assign the value
5445// to the default value. Use the rawValue methods below to assign non enumerator
5446// values.
5447
Austin Schuh40c16522018-10-28 20:27:54 -07005448/**
5449 * Sets the value for the given key.
5450 *
5451 * @param value The value to set.
5452 * @param key The key under which to store the value.
5453 **/
5454- (void)setEnum:(int32_t)value forKey:(NSString *)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005455
Austin Schuh40c16522018-10-28 20:27:54 -07005456/**
5457 * Sets the raw enum value for the given key.
5458 *
5459 * @note This method bypass the validationFunc to enable the setting of values that
5460 * were not known at the time the binary was compiled.
5461 *
5462 * @param rawValue The raw enum value to set.
5463 * @param key The key under which to store the raw enum value.
5464 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005465- (void)setRawValue:(int32_t)rawValue forKey:(NSString *)key;
5466
Austin Schuh40c16522018-10-28 20:27:54 -07005467/**
5468 * Removes the entry for the given key.
5469 *
5470 * @param aKey Key to be removed from this dictionary.
5471 **/
5472- (void)removeEnumForKey:(NSString *)aKey;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005473
Austin Schuh40c16522018-10-28 20:27:54 -07005474/**
5475 * Removes all entries in this dictionary.
5476 **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005477- (void)removeAll;
5478
5479@end
5480
5481//%PDDM-EXPAND-END DECLARE_DICTIONARIES()
5482
5483NS_ASSUME_NONNULL_END
5484
5485//%PDDM-DEFINE DECLARE_DICTIONARIES()
5486//%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt32, uint32_t)
5487//%DICTIONARY_INTERFACES_FOR_POD_KEY(Int32, int32_t)
5488//%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt64, uint64_t)
5489//%DICTIONARY_INTERFACES_FOR_POD_KEY(Int64, int64_t)
5490//%DICTIONARY_INTERFACES_FOR_POD_KEY(Bool, BOOL)
5491//%DICTIONARY_POD_INTERFACES_FOR_KEY(String, NSString, *, OBJECT)
5492//%PDDM-DEFINE DICTIONARY_INTERFACES_FOR_POD_KEY(KEY_NAME, KEY_TYPE)
5493//%DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, , POD)
Austin Schuh40c16522018-10-28 20:27:54 -07005494//%DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, Object, ObjectType)
Brian Silverman9c614bc2016-02-15 20:20:02 -05005495//%PDDM-DEFINE DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, KisP, KHELPER)
5496//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt32, uint32_t)
5497//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int32, int32_t)
5498//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt64, uint64_t)
5499//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int64, int64_t)
5500//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Bool, BOOL)
5501//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Float, float)
5502//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Double, double)
5503//%DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Enum, int32_t)
5504//%PDDM-DEFINE DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE)
Austin Schuh40c16522018-10-28 20:27:54 -07005505//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, POD, VALUE_NAME, value)
Brian Silverman9c614bc2016-02-15 20:20:02 -05005506//%PDDM-DEFINE DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, VALUE_NAME, VALUE_TYPE)
Austin Schuh40c16522018-10-28 20:27:54 -07005507//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, , POD, VALUE_NAME, VALUE_TYPE, OBJECT, Object, object)
5508//%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME)
5509//%/**
5510//% * Gets the value for the given key.
5511//% *
5512//% * @param value Pointer into which the value will be set, if found.
5513//% * @param key Key under which the value is stored, if present.
5514//% *
5515//% * @return YES if the key was found and the value was copied, NO otherwise.
5516//% **/
5517//%- (BOOL)get##VNAME##:(nullable VALUE_TYPE *)value forKey:(KEY_TYPE)key;
5518//%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_TYPE, VNAME)
5519//%/**
5520//% * Fetches the object stored under the given key.
5521//% *
5522//% * @param key Key under which the value is stored, if present.
5523//% *
5524//% * @return The object if found, nil otherwise.
5525//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005526//%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key;
Austin Schuh40c16522018-10-28 20:27:54 -07005527//%PDDM-DEFINE VALUE_FOR_KEY_Enum(KEY_TYPE, VALUE_TYPE, VNAME)
5528//%VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME)
Brian Silverman9c614bc2016-02-15 20:20:02 -05005529//%PDDM-DEFINE ARRAY_ARG_MODIFIERPOD()
5530// Nothing
5531//%PDDM-DEFINE ARRAY_ARG_MODIFIEREnum()
5532// Nothing
5533//%PDDM-DEFINE ARRAY_ARG_MODIFIEROBJECT()
Austin Schuh40c16522018-10-28 20:27:54 -07005534//%__nonnull GPB_UNSAFE_UNRETAINED ##
5535//%PDDM-DEFINE DICTIONARY_CLASS_DECLPOD(KEY_NAME, VALUE_NAME, VALUE_TYPE)
5536//%GPB##KEY_NAME##VALUE_NAME##Dictionary
5537//%PDDM-DEFINE DICTIONARY_CLASS_DECLEnum(KEY_NAME, VALUE_NAME, VALUE_TYPE)
5538//%GPB##KEY_NAME##VALUE_NAME##Dictionary
5539//%PDDM-DEFINE DICTIONARY_CLASS_DECLOBJECT(KEY_NAME, VALUE_NAME, VALUE_TYPE)
5540//%GPB##KEY_NAME##VALUE_NAME##Dictionary<__covariant VALUE_TYPE>
5541//%PDDM-DEFINE DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
Brian Silverman9c614bc2016-02-15 20:20:02 -05005542//%#pragma mark - KEY_NAME -> VALUE_NAME
5543//%
Austin Schuh40c16522018-10-28 20:27:54 -07005544//%/**
5545//% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##>
5546//% * values. This performs better than boxing into NSNumbers in NSDictionaries.
5547//% *
5548//% * @note This class is not meant to be subclassed.
5549//% **/
5550//%@interface DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) : NSObject <NSCopying>
Brian Silverman9c614bc2016-02-15 20:20:02 -05005551//%
Austin Schuh40c16522018-10-28 20:27:54 -07005552//%/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05005553//%@property(nonatomic, readonly) NSUInteger count;
5554//%
Austin Schuh40c16522018-10-28 20:27:54 -07005555//%/**
5556//% * Initializes this dictionary, copying the given values and keys.
5557//% *
5558//% * @param ##VNAME_VAR##s The values to be placed in this dictionary.
5559//% * @param keys ##VNAME_VAR$S## The keys under which to store the values.
5560//% * @param count ##VNAME_VAR$S## The number of elements to copy into the dictionary.
5561//% *
5562//% * @return A newly initialized dictionary with a copy of the values and keys.
5563//% **/
5564//%- (instancetype)initWith##VNAME##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])##VNAME_VAR##s
5565//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05005566//% ##VNAME$S## count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07005567//%
5568//%/**
5569//% * Initializes this dictionary, copying the entries from the given dictionary.
5570//% *
5571//% * @param dictionary Dictionary containing the entries to add to this dictionary.
5572//% *
5573//% * @return A newly initialized dictionary with the entries of the given dictionary.
5574//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005575//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07005576//%
5577//%/**
5578//% * Initializes this dictionary with the requested capacity.
5579//% *
5580//% * @param numItems Number of items needed for this dictionary.
5581//% *
5582//% * @return A newly initialized dictionary with the requested capacity.
5583//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005584//%- (instancetype)initWithCapacity:(NSUInteger)numItems;
5585//%
Austin Schuh40c16522018-10-28 20:27:54 -07005586//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
Brian Silverman9c614bc2016-02-15 20:20:02 -05005587//%
Austin Schuh40c16522018-10-28 20:27:54 -07005588//%/**
5589//% * Adds the keys and values from another dictionary.
5590//% *
5591//% * @param otherDictionary Dictionary containing entries to be added to this
5592//% * dictionary.
5593//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005594//%- (void)addEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary;
5595//%
Austin Schuh40c16522018-10-28 20:27:54 -07005596//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
Brian Silverman9c614bc2016-02-15 20:20:02 -05005597//%
5598//%@end
5599//%
5600
5601//%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE)
5602//%DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, Enum)
5603//%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER)
5604//%#pragma mark - KEY_NAME -> VALUE_NAME
5605//%
Austin Schuh40c16522018-10-28 20:27:54 -07005606//%/**
5607//% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##>
5608//% * values. This performs better than boxing into NSNumbers in NSDictionaries.
5609//% *
5610//% * @note This class is not meant to be subclassed.
5611//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005612//%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject <NSCopying>
5613//%
Austin Schuh40c16522018-10-28 20:27:54 -07005614//%/** Number of entries stored in this dictionary. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05005615//%@property(nonatomic, readonly) NSUInteger count;
Austin Schuh40c16522018-10-28 20:27:54 -07005616//%/** The validation function to check if the enums are valid. */
Brian Silverman9c614bc2016-02-15 20:20:02 -05005617//%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
5618//%
Austin Schuh40c16522018-10-28 20:27:54 -07005619//%/**
5620//% * Initializes a dictionary with the given validation function.
5621//% *
5622//% * @param func The enum validation function for the dictionary.
5623//% *
5624//% * @return A newly initialized dictionary.
5625//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005626//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Austin Schuh40c16522018-10-28 20:27:54 -07005627//%
5628//%/**
5629//% * Initializes a dictionary with the entries given.
5630//% *
5631//% * @param func The enum validation function for the dictionary.
5632//% * @param values The raw enum values values to be placed in the dictionary.
5633//% * @param keys The keys under which to store the values.
5634//% * @param count The number of entries to store in the dictionary.
5635//% *
5636//% * @return A newly initialized dictionary with the keys and values in it.
5637//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005638//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Austin Schuh40c16522018-10-28 20:27:54 -07005639//% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])values
5640//% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
Brian Silverman9c614bc2016-02-15 20:20:02 -05005641//% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Austin Schuh40c16522018-10-28 20:27:54 -07005642//%
5643//%/**
5644//% * Initializes a dictionary with the entries from the given.
5645//% * dictionary.
5646//% *
5647//% * @param dictionary Dictionary containing the entries to add to the dictionary.
5648//% *
5649//% * @return A newly initialized dictionary with the entries from the given
5650//% * dictionary in it.
5651//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005652//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
Austin Schuh40c16522018-10-28 20:27:54 -07005653//%
5654//%/**
5655//% * Initializes a dictionary with the given capacity.
5656//% *
5657//% * @param func The enum validation function for the dictionary.
5658//% * @param numItems Capacity needed for the dictionary.
5659//% *
5660//% * @return A newly initialized dictionary with the given capacity.
5661//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005662//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
5663//% capacity:(NSUInteger)numItems;
5664//%
5665//%// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
5666//%// is not a valid enumerator as defined by validationFunc. If the actual value is
5667//%// desired, use "raw" version of the method.
5668//%
Austin Schuh40c16522018-10-28 20:27:54 -07005669//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value)
Brian Silverman9c614bc2016-02-15 20:20:02 -05005670//%
Austin Schuh40c16522018-10-28 20:27:54 -07005671//%/**
5672//% * Gets the raw enum value for the given key.
5673//% *
5674//% * @note This method bypass the validationFunc to enable the access of values that
5675//% * were not known at the time the binary was compiled.
5676//% *
5677//% * @param rawValue Pointer into which the value will be set, if found.
5678//% * @param key Key under which the value is stored, if present.
5679//% *
5680//% * @return YES if the key was found and the value was copied, NO otherwise.
5681//% **/
5682//%- (BOOL)getRawValue:(nullable VALUE_TYPE *)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005683//%
Austin Schuh40c16522018-10-28 20:27:54 -07005684//%/**
5685//% * Enumerates the keys and values on this dictionary with the given block.
5686//% *
5687//% * @note This method bypass the validationFunc to enable the access of values that
5688//% * were not known at the time the binary was compiled.
5689//% *
5690//% * @param block The block to enumerate with.
5691//% * **key**: The key for the current entry.
5692//% * **rawValue**: The value for the current entry
5693//% * **stop**: A pointer to a boolean that when set stops the enumeration.
5694//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005695//%- (void)enumerateKeysAndRawValuesUsingBlock:
5696//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE rawValue, BOOL *stop))block;
5697//%
Austin Schuh40c16522018-10-28 20:27:54 -07005698//%/**
5699//% * Adds the keys and raw enum values from another dictionary.
5700//% *
5701//% * @note This method bypass the validationFunc to enable the setting of values that
5702//% * were not known at the time the binary was compiled.
5703//% *
5704//% * @param otherDictionary Dictionary containing entries to be added to this
5705//% * dictionary.
5706//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005707//%- (void)addRawEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary;
5708//%
5709//%// If value is not a valid enumerator as defined by validationFunc, these
5710//%// methods will assert in debug, and will log in release and assign the value
5711//%// to the default value. Use the rawValue methods below to assign non enumerator
5712//%// values.
5713//%
Austin Schuh40c16522018-10-28 20:27:54 -07005714//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value)
Brian Silverman9c614bc2016-02-15 20:20:02 -05005715//%
5716//%@end
5717//%
5718
Austin Schuh40c16522018-10-28 20:27:54 -07005719//%PDDM-DEFINE DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
5720//%VALUE_FOR_KEY_##VHELPER(KEY_TYPE##KisP$S##KisP, VALUE_TYPE, VNAME)
Brian Silverman9c614bc2016-02-15 20:20:02 -05005721//%
Austin Schuh40c16522018-10-28 20:27:54 -07005722//%/**
5723//% * Enumerates the keys and values on this dictionary with the given block.
5724//% *
5725//% * @param block The block to enumerate with.
5726//% * **key**: ##VNAME_VAR$S## The key for the current entry.
5727//% * **VNAME_VAR**: The value for the current entry
5728//% * **stop**: ##VNAME_VAR$S## A pointer to a boolean that when set stops the enumeration.
5729//% **/
5730//%- (void)enumerateKeysAnd##VNAME##sUsingBlock:
5731//% (void (^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME_VAR, BOOL *stop))block;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005732
Austin Schuh40c16522018-10-28 20:27:54 -07005733//%PDDM-DEFINE DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
5734//%/**
5735//% * Sets the value for the given key.
5736//% *
5737//% * @param ##VNAME_VAR The value to set.
5738//% * @param key ##VNAME_VAR$S## The key under which to store the value.
5739//% **/
5740//%- (void)set##VNAME##:(VALUE_TYPE)##VNAME_VAR forKey:(KEY_TYPE##KisP$S##KisP)key;
Brian Silverman9c614bc2016-02-15 20:20:02 -05005741//%DICTIONARY_EXTRA_MUTABLE_METHODS_##VHELPER(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
Austin Schuh40c16522018-10-28 20:27:54 -07005742//%/**
5743//% * Removes the entry for the given key.
5744//% *
5745//% * @param aKey Key to be removed from this dictionary.
5746//% **/
5747//%- (void)remove##VNAME##ForKey:(KEY_TYPE##KisP$S##KisP)aKey;
5748//%
5749//%/**
5750//% * Removes all entries in this dictionary.
5751//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005752//%- (void)removeAll;
5753
5754//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_POD(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
5755// Empty
5756//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_OBJECT(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
5757// Empty
5758//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_Enum(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
5759//%
Austin Schuh40c16522018-10-28 20:27:54 -07005760//%/**
5761//% * Sets the raw enum value for the given key.
5762//% *
5763//% * @note This method bypass the validationFunc to enable the setting of values that
5764//% * were not known at the time the binary was compiled.
5765//% *
5766//% * @param rawValue The raw enum value to set.
5767//% * @param key The key under which to store the raw enum value.
5768//% **/
Brian Silverman9c614bc2016-02-15 20:20:02 -05005769//%- (void)setRawValue:(VALUE_TYPE)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key;
5770//%