blob: 28d880d6f717a0a27b6da0d2d03a967d2da230fe [file] [log] [blame]
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001// 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
Thomas Van Lentend846b0b2015-06-08 16:24:57 -040033#import "GPBRuntimeTypes.h"
Thomas Van Lenten30650d82015-05-01 08:57:16 -040034
Thomas Van Lentena230b5d2016-06-21 08:25:28 -040035// 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.
Thomas Van Lenten8c889572015-06-16 16:45:14 -040043
Thomas Van Lentena230b5d2016-06-21 08:25:28 -040044NS_ASSUME_NONNULL_BEGIN
Thomas Van Lenten38b9e742016-05-27 12:51:18 -040045
Thomas Van Lenten30650d82015-05-01 08:57:16 -040046//%PDDM-EXPAND DECLARE_DICTIONARIES()
47// This block of code is generated, do not edit it directly.
Dave MacLachlanab48ecf2020-01-20 13:47:20 -080048// clang-format off
Thomas Van Lenten30650d82015-05-01 08:57:16 -040049
50#pragma mark - UInt32 -> UInt32
51
Sergio Campamá32fadc02016-08-08 07:15:02 -070052/**
53 * Class used for map fields of <uint32_t, uint32_t>
54 * values. This performs better than boxing into NSNumbers in NSDictionaries.
55 *
56 * @note This class is not meant to be subclassed.
57 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -040058@interface GPBUInt32UInt32Dictionary : NSObject <NSCopying>
59
Sergio Campamá32fadc02016-08-08 07:15:02 -070060/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -040061@property(nonatomic, readonly) NSUInteger count;
62
Sergio Campamá32fadc02016-08-08 07:15:02 -070063/**
Sergio Campamá32fadc02016-08-08 07:15:02 -070064 * Initializes this dictionary, copying the given values and keys.
65 *
66 * @param values The values to be placed in this dictionary.
67 * @param keys The keys under which to store the values.
68 * @param count The number of elements to copy into the dictionary.
69 *
70 * @return A newly initialized dictionary with a copy of the values and keys.
71 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -050072- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
73 forKeys:(const uint32_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -040074 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -070075
76/**
77 * Initializes this dictionary, copying the entries from the given dictionary.
78 *
79 * @param dictionary Dictionary containing the entries to add to this dictionary.
80 *
81 * @return A newly initialized dictionary with the entries of the given dictionary.
82 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -040083- (instancetype)initWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -070084
85/**
86 * Initializes this dictionary with the requested capacity.
87 *
88 * @param numItems Number of items needed for this dictionary.
89 *
90 * @return A newly initialized dictionary with the requested capacity.
91 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -040092- (instancetype)initWithCapacity:(NSUInteger)numItems;
93
Sergio Campamá32fadc02016-08-08 07:15:02 -070094/**
95 * Gets the value for the given key.
96 *
97 * @param value Pointer into which the value will be set, if found.
98 * @param key Key under which the value is stored, if present.
99 *
100 * @return YES if the key was found and the value was copied, NO otherwise.
101 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400102- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400103
Sergio Campamá32fadc02016-08-08 07:15:02 -0700104/**
105 * Enumerates the keys and values on this dictionary with the given block.
106 *
107 * @param block The block to enumerate with.
108 * **key**: The key for the current entry.
109 * **value**: The value for the current entry
110 * **stop**: A pointer to a boolean that when set stops the enumeration.
111 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400112- (void)enumerateKeysAndUInt32sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -0500113 (void (NS_NOESCAPE ^)(uint32_t key, uint32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400114
Sergio Campamá32fadc02016-08-08 07:15:02 -0700115/**
116 * Adds the keys and values from another dictionary.
117 *
118 * @param otherDictionary Dictionary containing entries to be added to this
119 * dictionary.
120 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400121- (void)addEntriesFromDictionary:(GPBUInt32UInt32Dictionary *)otherDictionary;
122
Sergio Campamá32fadc02016-08-08 07:15:02 -0700123/**
124 * Sets the value for the given key.
125 *
126 * @param value The value to set.
127 * @param key The key under which to store the value.
128 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400129- (void)setUInt32:(uint32_t)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400130
Sergio Campamá32fadc02016-08-08 07:15:02 -0700131/**
132 * Removes the entry for the given key.
133 *
134 * @param aKey Key to be removed from this dictionary.
135 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400136- (void)removeUInt32ForKey:(uint32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700137
138/**
139 * Removes all entries in this dictionary.
140 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400141- (void)removeAll;
142
143@end
144
145#pragma mark - UInt32 -> Int32
146
Sergio Campamá32fadc02016-08-08 07:15:02 -0700147/**
148 * Class used for map fields of <uint32_t, int32_t>
149 * values. This performs better than boxing into NSNumbers in NSDictionaries.
150 *
151 * @note This class is not meant to be subclassed.
152 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400153@interface GPBUInt32Int32Dictionary : NSObject <NSCopying>
154
Sergio Campamá32fadc02016-08-08 07:15:02 -0700155/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400156@property(nonatomic, readonly) NSUInteger count;
157
Sergio Campamá32fadc02016-08-08 07:15:02 -0700158/**
Sergio Campamá32fadc02016-08-08 07:15:02 -0700159 * Initializes this dictionary, copying the given values and keys.
160 *
161 * @param values The values to be placed in this dictionary.
162 * @param keys The keys under which to store the values.
163 * @param count The number of elements to copy into the dictionary.
164 *
165 * @return A newly initialized dictionary with a copy of the values and keys.
166 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -0500167- (instancetype)initWithInt32s:(const int32_t [__nullable])values
168 forKeys:(const uint32_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400169 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700170
171/**
172 * Initializes this dictionary, copying the entries from the given dictionary.
173 *
174 * @param dictionary Dictionary containing the entries to add to this dictionary.
175 *
176 * @return A newly initialized dictionary with the entries of the given dictionary.
177 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400178- (instancetype)initWithDictionary:(GPBUInt32Int32Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700179
180/**
181 * Initializes this dictionary with the requested capacity.
182 *
183 * @param numItems Number of items needed for this dictionary.
184 *
185 * @return A newly initialized dictionary with the requested capacity.
186 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400187- (instancetype)initWithCapacity:(NSUInteger)numItems;
188
Sergio Campamá32fadc02016-08-08 07:15:02 -0700189/**
190 * Gets the value for the given key.
191 *
192 * @param value Pointer into which the value will be set, if found.
193 * @param key Key under which the value is stored, if present.
194 *
195 * @return YES if the key was found and the value was copied, NO otherwise.
196 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400197- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400198
Sergio Campamá32fadc02016-08-08 07:15:02 -0700199/**
200 * Enumerates the keys and values on this dictionary with the given block.
201 *
202 * @param block The block to enumerate with.
203 * **key**: The key for the current entry.
204 * **value**: The value for the current entry
205 * **stop**: A pointer to a boolean that when set stops the enumeration.
206 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400207- (void)enumerateKeysAndInt32sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -0500208 (void (NS_NOESCAPE ^)(uint32_t key, int32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400209
Sergio Campamá32fadc02016-08-08 07:15:02 -0700210/**
211 * Adds the keys and values from another dictionary.
212 *
213 * @param otherDictionary Dictionary containing entries to be added to this
214 * dictionary.
215 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400216- (void)addEntriesFromDictionary:(GPBUInt32Int32Dictionary *)otherDictionary;
217
Sergio Campamá32fadc02016-08-08 07:15:02 -0700218/**
219 * Sets the value for the given key.
220 *
221 * @param value The value to set.
222 * @param key The key under which to store the value.
223 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400224- (void)setInt32:(int32_t)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400225
Sergio Campamá32fadc02016-08-08 07:15:02 -0700226/**
227 * Removes the entry for the given key.
228 *
229 * @param aKey Key to be removed from this dictionary.
230 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400231- (void)removeInt32ForKey:(uint32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700232
233/**
234 * Removes all entries in this dictionary.
235 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400236- (void)removeAll;
237
238@end
239
240#pragma mark - UInt32 -> UInt64
241
Sergio Campamá32fadc02016-08-08 07:15:02 -0700242/**
243 * Class used for map fields of <uint32_t, uint64_t>
244 * values. This performs better than boxing into NSNumbers in NSDictionaries.
245 *
246 * @note This class is not meant to be subclassed.
247 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400248@interface GPBUInt32UInt64Dictionary : NSObject <NSCopying>
249
Sergio Campamá32fadc02016-08-08 07:15:02 -0700250/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400251@property(nonatomic, readonly) NSUInteger count;
252
Sergio Campamá32fadc02016-08-08 07:15:02 -0700253/**
Sergio Campamá32fadc02016-08-08 07:15:02 -0700254 * Initializes this dictionary, copying the given values and keys.
255 *
256 * @param values The values to be placed in this dictionary.
257 * @param keys The keys under which to store the values.
258 * @param count The number of elements to copy into the dictionary.
259 *
260 * @return A newly initialized dictionary with a copy of the values and keys.
261 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -0500262- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
263 forKeys:(const uint32_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400264 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700265
266/**
267 * Initializes this dictionary, copying the entries from the given dictionary.
268 *
269 * @param dictionary Dictionary containing the entries to add to this dictionary.
270 *
271 * @return A newly initialized dictionary with the entries of the given dictionary.
272 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400273- (instancetype)initWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700274
275/**
276 * Initializes this dictionary with the requested capacity.
277 *
278 * @param numItems Number of items needed for this dictionary.
279 *
280 * @return A newly initialized dictionary with the requested capacity.
281 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400282- (instancetype)initWithCapacity:(NSUInteger)numItems;
283
Sergio Campamá32fadc02016-08-08 07:15:02 -0700284/**
285 * Gets the value for the given key.
286 *
287 * @param value Pointer into which the value will be set, if found.
288 * @param key Key under which the value is stored, if present.
289 *
290 * @return YES if the key was found and the value was copied, NO otherwise.
291 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400292- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400293
Sergio Campamá32fadc02016-08-08 07:15:02 -0700294/**
295 * Enumerates the keys and values on this dictionary with the given block.
296 *
297 * @param block The block to enumerate with.
298 * **key**: The key for the current entry.
299 * **value**: The value for the current entry
300 * **stop**: A pointer to a boolean that when set stops the enumeration.
301 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400302- (void)enumerateKeysAndUInt64sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -0500303 (void (NS_NOESCAPE ^)(uint32_t key, uint64_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400304
Sergio Campamá32fadc02016-08-08 07:15:02 -0700305/**
306 * Adds the keys and values from another dictionary.
307 *
308 * @param otherDictionary Dictionary containing entries to be added to this
309 * dictionary.
310 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400311- (void)addEntriesFromDictionary:(GPBUInt32UInt64Dictionary *)otherDictionary;
312
Sergio Campamá32fadc02016-08-08 07:15:02 -0700313/**
314 * Sets the value for the given key.
315 *
316 * @param value The value to set.
317 * @param key The key under which to store the value.
318 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400319- (void)setUInt64:(uint64_t)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400320
Sergio Campamá32fadc02016-08-08 07:15:02 -0700321/**
322 * Removes the entry for the given key.
323 *
324 * @param aKey Key to be removed from this dictionary.
325 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400326- (void)removeUInt64ForKey:(uint32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700327
328/**
329 * Removes all entries in this dictionary.
330 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400331- (void)removeAll;
332
333@end
334
335#pragma mark - UInt32 -> Int64
336
Sergio Campamá32fadc02016-08-08 07:15:02 -0700337/**
338 * Class used for map fields of <uint32_t, int64_t>
339 * values. This performs better than boxing into NSNumbers in NSDictionaries.
340 *
341 * @note This class is not meant to be subclassed.
342 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400343@interface GPBUInt32Int64Dictionary : NSObject <NSCopying>
344
Sergio Campamá32fadc02016-08-08 07:15:02 -0700345/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400346@property(nonatomic, readonly) NSUInteger count;
347
Sergio Campamá32fadc02016-08-08 07:15:02 -0700348/**
Sergio Campamá32fadc02016-08-08 07:15:02 -0700349 * Initializes this dictionary, copying the given values and keys.
350 *
351 * @param values The values to be placed in this dictionary.
352 * @param keys The keys under which to store the values.
353 * @param count The number of elements to copy into the dictionary.
354 *
355 * @return A newly initialized dictionary with a copy of the values and keys.
356 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -0500357- (instancetype)initWithInt64s:(const int64_t [__nullable])values
358 forKeys:(const uint32_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400359 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700360
361/**
362 * Initializes this dictionary, copying the entries from the given dictionary.
363 *
364 * @param dictionary Dictionary containing the entries to add to this dictionary.
365 *
366 * @return A newly initialized dictionary with the entries of the given dictionary.
367 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400368- (instancetype)initWithDictionary:(GPBUInt32Int64Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700369
370/**
371 * Initializes this dictionary with the requested capacity.
372 *
373 * @param numItems Number of items needed for this dictionary.
374 *
375 * @return A newly initialized dictionary with the requested capacity.
376 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400377- (instancetype)initWithCapacity:(NSUInteger)numItems;
378
Sergio Campamá32fadc02016-08-08 07:15:02 -0700379/**
380 * Gets the value for the given key.
381 *
382 * @param value Pointer into which the value will be set, if found.
383 * @param key Key under which the value is stored, if present.
384 *
385 * @return YES if the key was found and the value was copied, NO otherwise.
386 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400387- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400388
Sergio Campamá32fadc02016-08-08 07:15:02 -0700389/**
390 * Enumerates the keys and values on this dictionary with the given block.
391 *
392 * @param block The block to enumerate with.
393 * **key**: The key for the current entry.
394 * **value**: The value for the current entry
395 * **stop**: A pointer to a boolean that when set stops the enumeration.
396 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400397- (void)enumerateKeysAndInt64sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -0500398 (void (NS_NOESCAPE ^)(uint32_t key, int64_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400399
Sergio Campamá32fadc02016-08-08 07:15:02 -0700400/**
401 * Adds the keys and values from another dictionary.
402 *
403 * @param otherDictionary Dictionary containing entries to be added to this
404 * dictionary.
405 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400406- (void)addEntriesFromDictionary:(GPBUInt32Int64Dictionary *)otherDictionary;
407
Sergio Campamá32fadc02016-08-08 07:15:02 -0700408/**
409 * Sets the value for the given key.
410 *
411 * @param value The value to set.
412 * @param key The key under which to store the value.
413 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400414- (void)setInt64:(int64_t)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400415
Sergio Campamá32fadc02016-08-08 07:15:02 -0700416/**
417 * Removes the entry for the given key.
418 *
419 * @param aKey Key to be removed from this dictionary.
420 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400421- (void)removeInt64ForKey:(uint32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700422
423/**
424 * Removes all entries in this dictionary.
425 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400426- (void)removeAll;
427
428@end
429
430#pragma mark - UInt32 -> Bool
431
Sergio Campamá32fadc02016-08-08 07:15:02 -0700432/**
433 * Class used for map fields of <uint32_t, BOOL>
434 * values. This performs better than boxing into NSNumbers in NSDictionaries.
435 *
436 * @note This class is not meant to be subclassed.
437 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400438@interface GPBUInt32BoolDictionary : NSObject <NSCopying>
439
Sergio Campamá32fadc02016-08-08 07:15:02 -0700440/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400441@property(nonatomic, readonly) NSUInteger count;
442
Sergio Campamá32fadc02016-08-08 07:15:02 -0700443/**
Sergio Campamá32fadc02016-08-08 07:15:02 -0700444 * Initializes this dictionary, copying the given values and keys.
445 *
446 * @param values The values to be placed in this dictionary.
447 * @param keys The keys under which to store the values.
448 * @param count The number of elements to copy into the dictionary.
449 *
450 * @return A newly initialized dictionary with a copy of the values and keys.
451 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -0500452- (instancetype)initWithBools:(const BOOL [__nullable])values
453 forKeys:(const uint32_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400454 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700455
456/**
457 * Initializes this dictionary, copying the entries from the given dictionary.
458 *
459 * @param dictionary Dictionary containing the entries to add to this dictionary.
460 *
461 * @return A newly initialized dictionary with the entries of the given dictionary.
462 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400463- (instancetype)initWithDictionary:(GPBUInt32BoolDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700464
465/**
466 * Initializes this dictionary with the requested capacity.
467 *
468 * @param numItems Number of items needed for this dictionary.
469 *
470 * @return A newly initialized dictionary with the requested capacity.
471 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400472- (instancetype)initWithCapacity:(NSUInteger)numItems;
473
Sergio Campamá32fadc02016-08-08 07:15:02 -0700474/**
475 * Gets the value for the given key.
476 *
477 * @param value Pointer into which the value will be set, if found.
478 * @param key Key under which the value is stored, if present.
479 *
480 * @return YES if the key was found and the value was copied, NO otherwise.
481 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400482- (BOOL)getBool:(nullable BOOL *)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400483
Sergio Campamá32fadc02016-08-08 07:15:02 -0700484/**
485 * Enumerates the keys and values on this dictionary with the given block.
486 *
487 * @param block The block to enumerate with.
488 * **key**: The key for the current entry.
489 * **value**: The value for the current entry
490 * **stop**: A pointer to a boolean that when set stops the enumeration.
491 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400492- (void)enumerateKeysAndBoolsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -0500493 (void (NS_NOESCAPE ^)(uint32_t key, BOOL value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400494
Sergio Campamá32fadc02016-08-08 07:15:02 -0700495/**
496 * Adds the keys and values from another dictionary.
497 *
498 * @param otherDictionary Dictionary containing entries to be added to this
499 * dictionary.
500 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400501- (void)addEntriesFromDictionary:(GPBUInt32BoolDictionary *)otherDictionary;
502
Sergio Campamá32fadc02016-08-08 07:15:02 -0700503/**
504 * Sets the value for the given key.
505 *
506 * @param value The value to set.
507 * @param key The key under which to store the value.
508 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400509- (void)setBool:(BOOL)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400510
Sergio Campamá32fadc02016-08-08 07:15:02 -0700511/**
512 * Removes the entry for the given key.
513 *
514 * @param aKey Key to be removed from this dictionary.
515 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400516- (void)removeBoolForKey:(uint32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700517
518/**
519 * Removes all entries in this dictionary.
520 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400521- (void)removeAll;
522
523@end
524
525#pragma mark - UInt32 -> Float
526
Sergio Campamá32fadc02016-08-08 07:15:02 -0700527/**
528 * Class used for map fields of <uint32_t, float>
529 * values. This performs better than boxing into NSNumbers in NSDictionaries.
530 *
531 * @note This class is not meant to be subclassed.
532 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400533@interface GPBUInt32FloatDictionary : NSObject <NSCopying>
534
Sergio Campamá32fadc02016-08-08 07:15:02 -0700535/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400536@property(nonatomic, readonly) NSUInteger count;
537
Sergio Campamá32fadc02016-08-08 07:15:02 -0700538/**
Sergio Campamá32fadc02016-08-08 07:15:02 -0700539 * Initializes this dictionary, copying the given values and keys.
540 *
541 * @param values The values to be placed in this dictionary.
542 * @param keys The keys under which to store the values.
543 * @param count The number of elements to copy into the dictionary.
544 *
545 * @return A newly initialized dictionary with a copy of the values and keys.
546 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -0500547- (instancetype)initWithFloats:(const float [__nullable])values
548 forKeys:(const uint32_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400549 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700550
551/**
552 * Initializes this dictionary, copying the entries from the given dictionary.
553 *
554 * @param dictionary Dictionary containing the entries to add to this dictionary.
555 *
556 * @return A newly initialized dictionary with the entries of the given dictionary.
557 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400558- (instancetype)initWithDictionary:(GPBUInt32FloatDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700559
560/**
561 * Initializes this dictionary with the requested capacity.
562 *
563 * @param numItems Number of items needed for this dictionary.
564 *
565 * @return A newly initialized dictionary with the requested capacity.
566 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400567- (instancetype)initWithCapacity:(NSUInteger)numItems;
568
Sergio Campamá32fadc02016-08-08 07:15:02 -0700569/**
570 * Gets the value for the given key.
571 *
572 * @param value Pointer into which the value will be set, if found.
573 * @param key Key under which the value is stored, if present.
574 *
575 * @return YES if the key was found and the value was copied, NO otherwise.
576 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400577- (BOOL)getFloat:(nullable float *)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400578
Sergio Campamá32fadc02016-08-08 07:15:02 -0700579/**
580 * Enumerates the keys and values on this dictionary with the given block.
581 *
582 * @param block The block to enumerate with.
583 * **key**: The key for the current entry.
584 * **value**: The value for the current entry
585 * **stop**: A pointer to a boolean that when set stops the enumeration.
586 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400587- (void)enumerateKeysAndFloatsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -0500588 (void (NS_NOESCAPE ^)(uint32_t key, float value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400589
Sergio Campamá32fadc02016-08-08 07:15:02 -0700590/**
591 * Adds the keys and values from another dictionary.
592 *
593 * @param otherDictionary Dictionary containing entries to be added to this
594 * dictionary.
595 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400596- (void)addEntriesFromDictionary:(GPBUInt32FloatDictionary *)otherDictionary;
597
Sergio Campamá32fadc02016-08-08 07:15:02 -0700598/**
599 * Sets the value for the given key.
600 *
601 * @param value The value to set.
602 * @param key The key under which to store the value.
603 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400604- (void)setFloat:(float)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400605
Sergio Campamá32fadc02016-08-08 07:15:02 -0700606/**
607 * Removes the entry for the given key.
608 *
609 * @param aKey Key to be removed from this dictionary.
610 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400611- (void)removeFloatForKey:(uint32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700612
613/**
614 * Removes all entries in this dictionary.
615 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400616- (void)removeAll;
617
618@end
619
620#pragma mark - UInt32 -> Double
621
Sergio Campamá32fadc02016-08-08 07:15:02 -0700622/**
623 * Class used for map fields of <uint32_t, double>
624 * values. This performs better than boxing into NSNumbers in NSDictionaries.
625 *
626 * @note This class is not meant to be subclassed.
627 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400628@interface GPBUInt32DoubleDictionary : NSObject <NSCopying>
629
Sergio Campamá32fadc02016-08-08 07:15:02 -0700630/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400631@property(nonatomic, readonly) NSUInteger count;
632
Sergio Campamá32fadc02016-08-08 07:15:02 -0700633/**
Sergio Campamá32fadc02016-08-08 07:15:02 -0700634 * Initializes this dictionary, copying the given values and keys.
635 *
636 * @param values The values to be placed in this dictionary.
637 * @param keys The keys under which to store the values.
638 * @param count The number of elements to copy into the dictionary.
639 *
640 * @return A newly initialized dictionary with a copy of the values and keys.
641 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -0500642- (instancetype)initWithDoubles:(const double [__nullable])values
643 forKeys:(const uint32_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400644 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700645
646/**
647 * Initializes this dictionary, copying the entries from the given dictionary.
648 *
649 * @param dictionary Dictionary containing the entries to add to this dictionary.
650 *
651 * @return A newly initialized dictionary with the entries of the given dictionary.
652 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400653- (instancetype)initWithDictionary:(GPBUInt32DoubleDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700654
655/**
656 * Initializes this dictionary with the requested capacity.
657 *
658 * @param numItems Number of items needed for this dictionary.
659 *
660 * @return A newly initialized dictionary with the requested capacity.
661 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400662- (instancetype)initWithCapacity:(NSUInteger)numItems;
663
Sergio Campamá32fadc02016-08-08 07:15:02 -0700664/**
665 * Gets the value for the given key.
666 *
667 * @param value Pointer into which the value will be set, if found.
668 * @param key Key under which the value is stored, if present.
669 *
670 * @return YES if the key was found and the value was copied, NO otherwise.
671 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400672- (BOOL)getDouble:(nullable double *)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400673
Sergio Campamá32fadc02016-08-08 07:15:02 -0700674/**
675 * Enumerates the keys and values on this dictionary with the given block.
676 *
677 * @param block The block to enumerate with.
678 * **key**: The key for the current entry.
679 * **value**: The value for the current entry
680 * **stop**: A pointer to a boolean that when set stops the enumeration.
681 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400682- (void)enumerateKeysAndDoublesUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -0500683 (void (NS_NOESCAPE ^)(uint32_t key, double value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400684
Sergio Campamá32fadc02016-08-08 07:15:02 -0700685/**
686 * Adds the keys and values from another dictionary.
687 *
688 * @param otherDictionary Dictionary containing entries to be added to this
689 * dictionary.
690 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400691- (void)addEntriesFromDictionary:(GPBUInt32DoubleDictionary *)otherDictionary;
692
Sergio Campamá32fadc02016-08-08 07:15:02 -0700693/**
694 * Sets the value for the given key.
695 *
696 * @param value The value to set.
697 * @param key The key under which to store the value.
698 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400699- (void)setDouble:(double)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400700
Sergio Campamá32fadc02016-08-08 07:15:02 -0700701/**
702 * Removes the entry for the given key.
703 *
704 * @param aKey Key to be removed from this dictionary.
705 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400706- (void)removeDoubleForKey:(uint32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700707
708/**
709 * Removes all entries in this dictionary.
710 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400711- (void)removeAll;
712
713@end
714
715#pragma mark - UInt32 -> Enum
716
Sergio Campamá32fadc02016-08-08 07:15:02 -0700717/**
718 * Class used for map fields of <uint32_t, int32_t>
719 * values. This performs better than boxing into NSNumbers in NSDictionaries.
720 *
721 * @note This class is not meant to be subclassed.
722 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400723@interface GPBUInt32EnumDictionary : NSObject <NSCopying>
724
Sergio Campamá32fadc02016-08-08 07:15:02 -0700725/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400726@property(nonatomic, readonly) NSUInteger count;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700727/** The validation function to check if the enums are valid. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400728@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
729
Sergio Campamá32fadc02016-08-08 07:15:02 -0700730/**
Sergio Campamá32fadc02016-08-08 07:15:02 -0700731 * Initializes a dictionary with the given validation function.
732 *
733 * @param func The enum validation function for the dictionary.
734 *
735 * @return A newly initialized dictionary.
736 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -0400737- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700738
739/**
740 * Initializes a dictionary with the entries given.
741 *
742 * @param func The enum validation function for the dictionary.
743 * @param values The raw enum values values to be placed in the dictionary.
744 * @param keys The keys under which to store the values.
745 * @param count The number of entries to store in the dictionary.
746 *
747 * @return A newly initialized dictionary with the keys and values in it.
748 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -0400749- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Sergio Campama3d7b42d2017-01-25 11:51:54 -0500750 rawValues:(const int32_t [__nullable])values
751 forKeys:(const uint32_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400752 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700753
754/**
755 * Initializes a dictionary with the entries from the given.
756 * dictionary.
757 *
758 * @param dictionary Dictionary containing the entries to add to the dictionary.
759 *
760 * @return A newly initialized dictionary with the entries from the given
761 * dictionary in it.
762 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400763- (instancetype)initWithDictionary:(GPBUInt32EnumDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700764
765/**
766 * Initializes a dictionary with the given capacity.
767 *
768 * @param func The enum validation function for the dictionary.
769 * @param numItems Capacity needed for the dictionary.
770 *
771 * @return A newly initialized dictionary with the given capacity.
772 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -0400773- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400774 capacity:(NSUInteger)numItems;
775
776// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
777// is not a valid enumerator as defined by validationFunc. If the actual value is
778// desired, use "raw" version of the method.
779
Sergio Campamá32fadc02016-08-08 07:15:02 -0700780/**
781 * Gets the value for the given key.
782 *
783 * @param value Pointer into which the value will be set, if found.
784 * @param key Key under which the value is stored, if present.
785 *
786 * @return YES if the key was found and the value was copied, NO otherwise.
787 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400788- (BOOL)getEnum:(nullable int32_t *)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400789
Sergio Campamá32fadc02016-08-08 07:15:02 -0700790/**
791 * Enumerates the keys and values on this dictionary with the given block.
792 *
793 * @param block The block to enumerate with.
794 * **key**: The key for the current entry.
795 * **value**: The value for the current entry
796 * **stop**: A pointer to a boolean that when set stops the enumeration.
797 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400798- (void)enumerateKeysAndEnumsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -0500799 (void (NS_NOESCAPE ^)(uint32_t key, int32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400800
Sergio Campamá32fadc02016-08-08 07:15:02 -0700801/**
802 * Gets the raw enum value for the given key.
803 *
804 * @note This method bypass the validationFunc to enable the access of values that
805 * were not known at the time the binary was compiled.
806 *
807 * @param rawValue Pointer into which the value will be set, if found.
808 * @param key Key under which the value is stored, if present.
809 *
810 * @return YES if the key was found and the value was copied, NO otherwise.
811 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400812- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400813
Sergio Campamá32fadc02016-08-08 07:15:02 -0700814/**
815 * Enumerates the keys and values on this dictionary with the given block.
816 *
817 * @note This method bypass the validationFunc to enable the access of values that
818 * were not known at the time the binary was compiled.
819 *
820 * @param block The block to enumerate with.
821 * **key**: The key for the current entry.
822 * **rawValue**: The value for the current entry
823 * **stop**: A pointer to a boolean that when set stops the enumeration.
824 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400825- (void)enumerateKeysAndRawValuesUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -0500826 (void (NS_NOESCAPE ^)(uint32_t key, int32_t rawValue, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400827
Sergio Campamá32fadc02016-08-08 07:15:02 -0700828/**
829 * Adds the keys and raw enum values from another dictionary.
830 *
831 * @note This method bypass the validationFunc to enable the setting of values that
832 * were not known at the time the binary was compiled.
833 *
834 * @param otherDictionary Dictionary containing entries to be added to this
835 * dictionary.
836 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400837- (void)addRawEntriesFromDictionary:(GPBUInt32EnumDictionary *)otherDictionary;
838
839// If value is not a valid enumerator as defined by validationFunc, these
840// methods will assert in debug, and will log in release and assign the value
841// to the default value. Use the rawValue methods below to assign non enumerator
842// values.
843
Sergio Campamá32fadc02016-08-08 07:15:02 -0700844/**
845 * Sets the value for the given key.
846 *
847 * @param value The value to set.
848 * @param key The key under which to store the value.
849 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400850- (void)setEnum:(int32_t)value forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400851
Sergio Campamá32fadc02016-08-08 07:15:02 -0700852/**
853 * Sets the raw enum value for the given key.
854 *
855 * @note This method bypass the validationFunc to enable the setting of values that
856 * were not known at the time the binary was compiled.
857 *
858 * @param rawValue The raw enum value to set.
859 * @param key The key under which to store the raw enum value.
860 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400861- (void)setRawValue:(int32_t)rawValue forKey:(uint32_t)key;
862
Sergio Campamá32fadc02016-08-08 07:15:02 -0700863/**
864 * Removes the entry for the given key.
865 *
866 * @param aKey Key to be removed from this dictionary.
867 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400868- (void)removeEnumForKey:(uint32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700869
870/**
871 * Removes all entries in this dictionary.
872 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400873- (void)removeAll;
874
875@end
876
877#pragma mark - UInt32 -> Object
878
Sergio Campamá32fadc02016-08-08 07:15:02 -0700879/**
880 * Class used for map fields of <uint32_t, ObjectType>
881 * values. This performs better than boxing into NSNumbers in NSDictionaries.
882 *
883 * @note This class is not meant to be subclassed.
884 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500885@interface GPBUInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400886
Sergio Campamá32fadc02016-08-08 07:15:02 -0700887/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400888@property(nonatomic, readonly) NSUInteger count;
889
Sergio Campamá32fadc02016-08-08 07:15:02 -0700890/**
Sergio Campamá32fadc02016-08-08 07:15:02 -0700891 * Initializes this dictionary, copying the given values and keys.
892 *
893 * @param objects The values to be placed in this dictionary.
894 * @param keys The keys under which to store the values.
895 * @param count The number of elements to copy into the dictionary.
896 *
897 * @return A newly initialized dictionary with a copy of the values and keys.
898 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -0500899- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
900 forKeys:(const uint32_t [__nullable])keys
Thomas Van Lenten1383d532015-09-29 11:41:53 -0400901 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700902
903/**
904 * Initializes this dictionary, copying the entries from the given dictionary.
905 *
906 * @param dictionary Dictionary containing the entries to add to this dictionary.
907 *
908 * @return A newly initialized dictionary with the entries of the given dictionary.
909 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400910- (instancetype)initWithDictionary:(GPBUInt32ObjectDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700911
912/**
913 * Initializes this dictionary with the requested capacity.
914 *
915 * @param numItems Number of items needed for this dictionary.
916 *
917 * @return A newly initialized dictionary with the requested capacity.
918 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400919- (instancetype)initWithCapacity:(NSUInteger)numItems;
920
Sergio Campamá32fadc02016-08-08 07:15:02 -0700921/**
922 * Fetches the object stored under the given key.
923 *
924 * @param key Key under which the value is stored, if present.
925 *
926 * @return The object if found, nil otherwise.
927 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500928- (ObjectType)objectForKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400929
Sergio Campamá32fadc02016-08-08 07:15:02 -0700930/**
931 * Enumerates the keys and values on this dictionary with the given block.
932 *
933 * @param block The block to enumerate with.
934 * **key**: The key for the current entry.
935 * **object**: The value for the current entry
936 * **stop**: A pointer to a boolean that when set stops the enumeration.
937 **/
Thomas Van Lenten1383d532015-09-29 11:41:53 -0400938- (void)enumerateKeysAndObjectsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -0500939 (void (NS_NOESCAPE ^)(uint32_t key, ObjectType object, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400940
Sergio Campamá32fadc02016-08-08 07:15:02 -0700941/**
942 * Adds the keys and values from another dictionary.
943 *
944 * @param otherDictionary Dictionary containing entries to be added to this
945 * dictionary.
946 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400947- (void)addEntriesFromDictionary:(GPBUInt32ObjectDictionary *)otherDictionary;
948
Sergio Campamá32fadc02016-08-08 07:15:02 -0700949/**
950 * Sets the value for the given key.
951 *
952 * @param object The value to set.
953 * @param key The key under which to store the value.
954 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -0500955- (void)setObject:(ObjectType)object forKey:(uint32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400956
Sergio Campamá32fadc02016-08-08 07:15:02 -0700957/**
958 * Removes the entry for the given key.
959 *
960 * @param aKey Key to be removed from this dictionary.
961 **/
Thomas Van Lenten1383d532015-09-29 11:41:53 -0400962- (void)removeObjectForKey:(uint32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700963
964/**
965 * Removes all entries in this dictionary.
966 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400967- (void)removeAll;
968
969@end
970
971#pragma mark - Int32 -> UInt32
972
Sergio Campamá32fadc02016-08-08 07:15:02 -0700973/**
974 * Class used for map fields of <int32_t, uint32_t>
975 * values. This performs better than boxing into NSNumbers in NSDictionaries.
976 *
977 * @note This class is not meant to be subclassed.
978 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400979@interface GPBInt32UInt32Dictionary : NSObject <NSCopying>
980
Sergio Campamá32fadc02016-08-08 07:15:02 -0700981/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400982@property(nonatomic, readonly) NSUInteger count;
983
Sergio Campamá32fadc02016-08-08 07:15:02 -0700984/**
Sergio Campamá32fadc02016-08-08 07:15:02 -0700985 * Initializes this dictionary, copying the given values and keys.
986 *
987 * @param values The values to be placed in this dictionary.
988 * @param keys The keys under which to store the values.
989 * @param count The number of elements to copy into the dictionary.
990 *
991 * @return A newly initialized dictionary with a copy of the values and keys.
992 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -0500993- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
994 forKeys:(const int32_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -0400995 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700996
997/**
998 * Initializes this dictionary, copying the entries from the given dictionary.
999 *
1000 * @param dictionary Dictionary containing the entries to add to this dictionary.
1001 *
1002 * @return A newly initialized dictionary with the entries of the given dictionary.
1003 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001004- (instancetype)initWithDictionary:(GPBInt32UInt32Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001005
1006/**
1007 * Initializes this dictionary with the requested capacity.
1008 *
1009 * @param numItems Number of items needed for this dictionary.
1010 *
1011 * @return A newly initialized dictionary with the requested capacity.
1012 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001013- (instancetype)initWithCapacity:(NSUInteger)numItems;
1014
Sergio Campamá32fadc02016-08-08 07:15:02 -07001015/**
1016 * Gets the value for the given key.
1017 *
1018 * @param value Pointer into which the value will be set, if found.
1019 * @param key Key under which the value is stored, if present.
1020 *
1021 * @return YES if the key was found and the value was copied, NO otherwise.
1022 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001023- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001024
Sergio Campamá32fadc02016-08-08 07:15:02 -07001025/**
1026 * Enumerates the keys and values on this dictionary with the given block.
1027 *
1028 * @param block The block to enumerate with.
1029 * **key**: The key for the current entry.
1030 * **value**: The value for the current entry
1031 * **stop**: A pointer to a boolean that when set stops the enumeration.
1032 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001033- (void)enumerateKeysAndUInt32sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05001034 (void (NS_NOESCAPE ^)(int32_t key, uint32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001035
Sergio Campamá32fadc02016-08-08 07:15:02 -07001036/**
1037 * Adds the keys and values from another dictionary.
1038 *
1039 * @param otherDictionary Dictionary containing entries to be added to this
1040 * dictionary.
1041 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001042- (void)addEntriesFromDictionary:(GPBInt32UInt32Dictionary *)otherDictionary;
1043
Sergio Campamá32fadc02016-08-08 07:15:02 -07001044/**
1045 * Sets the value for the given key.
1046 *
1047 * @param value The value to set.
1048 * @param key The key under which to store the value.
1049 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001050- (void)setUInt32:(uint32_t)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001051
Sergio Campamá32fadc02016-08-08 07:15:02 -07001052/**
1053 * Removes the entry for the given key.
1054 *
1055 * @param aKey Key to be removed from this dictionary.
1056 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001057- (void)removeUInt32ForKey:(int32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001058
1059/**
1060 * Removes all entries in this dictionary.
1061 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001062- (void)removeAll;
1063
1064@end
1065
1066#pragma mark - Int32 -> Int32
1067
Sergio Campamá32fadc02016-08-08 07:15:02 -07001068/**
1069 * Class used for map fields of <int32_t, int32_t>
1070 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1071 *
1072 * @note This class is not meant to be subclassed.
1073 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001074@interface GPBInt32Int32Dictionary : NSObject <NSCopying>
1075
Sergio Campamá32fadc02016-08-08 07:15:02 -07001076/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001077@property(nonatomic, readonly) NSUInteger count;
1078
Sergio Campamá32fadc02016-08-08 07:15:02 -07001079/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07001080 * Initializes this dictionary, copying the given values and keys.
1081 *
1082 * @param values The values to be placed in this dictionary.
1083 * @param keys The keys under which to store the values.
1084 * @param count The number of elements to copy into the dictionary.
1085 *
1086 * @return A newly initialized dictionary with a copy of the values and keys.
1087 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05001088- (instancetype)initWithInt32s:(const int32_t [__nullable])values
1089 forKeys:(const int32_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001090 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001091
1092/**
1093 * Initializes this dictionary, copying the entries from the given dictionary.
1094 *
1095 * @param dictionary Dictionary containing the entries to add to this dictionary.
1096 *
1097 * @return A newly initialized dictionary with the entries of the given dictionary.
1098 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001099- (instancetype)initWithDictionary:(GPBInt32Int32Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001100
1101/**
1102 * Initializes this dictionary with the requested capacity.
1103 *
1104 * @param numItems Number of items needed for this dictionary.
1105 *
1106 * @return A newly initialized dictionary with the requested capacity.
1107 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001108- (instancetype)initWithCapacity:(NSUInteger)numItems;
1109
Sergio Campamá32fadc02016-08-08 07:15:02 -07001110/**
1111 * Gets the value for the given key.
1112 *
1113 * @param value Pointer into which the value will be set, if found.
1114 * @param key Key under which the value is stored, if present.
1115 *
1116 * @return YES if the key was found and the value was copied, NO otherwise.
1117 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001118- (BOOL)getInt32:(nullable int32_t *)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001119
Sergio Campamá32fadc02016-08-08 07:15:02 -07001120/**
1121 * Enumerates the keys and values on this dictionary with the given block.
1122 *
1123 * @param block The block to enumerate with.
1124 * **key**: The key for the current entry.
1125 * **value**: The value for the current entry
1126 * **stop**: A pointer to a boolean that when set stops the enumeration.
1127 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001128- (void)enumerateKeysAndInt32sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05001129 (void (NS_NOESCAPE ^)(int32_t key, int32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001130
Sergio Campamá32fadc02016-08-08 07:15:02 -07001131/**
1132 * Adds the keys and values from another dictionary.
1133 *
1134 * @param otherDictionary Dictionary containing entries to be added to this
1135 * dictionary.
1136 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001137- (void)addEntriesFromDictionary:(GPBInt32Int32Dictionary *)otherDictionary;
1138
Sergio Campamá32fadc02016-08-08 07:15:02 -07001139/**
1140 * Sets the value for the given key.
1141 *
1142 * @param value The value to set.
1143 * @param key The key under which to store the value.
1144 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001145- (void)setInt32:(int32_t)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001146
Sergio Campamá32fadc02016-08-08 07:15:02 -07001147/**
1148 * Removes the entry for the given key.
1149 *
1150 * @param aKey Key to be removed from this dictionary.
1151 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001152- (void)removeInt32ForKey:(int32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001153
1154/**
1155 * Removes all entries in this dictionary.
1156 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001157- (void)removeAll;
1158
1159@end
1160
1161#pragma mark - Int32 -> UInt64
1162
Sergio Campamá32fadc02016-08-08 07:15:02 -07001163/**
1164 * Class used for map fields of <int32_t, uint64_t>
1165 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1166 *
1167 * @note This class is not meant to be subclassed.
1168 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001169@interface GPBInt32UInt64Dictionary : NSObject <NSCopying>
1170
Sergio Campamá32fadc02016-08-08 07:15:02 -07001171/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001172@property(nonatomic, readonly) NSUInteger count;
1173
Sergio Campamá32fadc02016-08-08 07:15:02 -07001174/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07001175 * Initializes this dictionary, copying the given values and keys.
1176 *
1177 * @param values The values to be placed in this dictionary.
1178 * @param keys The keys under which to store the values.
1179 * @param count The number of elements to copy into the dictionary.
1180 *
1181 * @return A newly initialized dictionary with a copy of the values and keys.
1182 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05001183- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
1184 forKeys:(const int32_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001185 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001186
1187/**
1188 * Initializes this dictionary, copying the entries from the given dictionary.
1189 *
1190 * @param dictionary Dictionary containing the entries to add to this dictionary.
1191 *
1192 * @return A newly initialized dictionary with the entries of the given dictionary.
1193 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001194- (instancetype)initWithDictionary:(GPBInt32UInt64Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001195
1196/**
1197 * Initializes this dictionary with the requested capacity.
1198 *
1199 * @param numItems Number of items needed for this dictionary.
1200 *
1201 * @return A newly initialized dictionary with the requested capacity.
1202 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001203- (instancetype)initWithCapacity:(NSUInteger)numItems;
1204
Sergio Campamá32fadc02016-08-08 07:15:02 -07001205/**
1206 * Gets the value for the given key.
1207 *
1208 * @param value Pointer into which the value will be set, if found.
1209 * @param key Key under which the value is stored, if present.
1210 *
1211 * @return YES if the key was found and the value was copied, NO otherwise.
1212 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001213- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001214
Sergio Campamá32fadc02016-08-08 07:15:02 -07001215/**
1216 * Enumerates the keys and values on this dictionary with the given block.
1217 *
1218 * @param block The block to enumerate with.
1219 * **key**: The key for the current entry.
1220 * **value**: The value for the current entry
1221 * **stop**: A pointer to a boolean that when set stops the enumeration.
1222 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001223- (void)enumerateKeysAndUInt64sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05001224 (void (NS_NOESCAPE ^)(int32_t key, uint64_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001225
Sergio Campamá32fadc02016-08-08 07:15:02 -07001226/**
1227 * Adds the keys and values from another dictionary.
1228 *
1229 * @param otherDictionary Dictionary containing entries to be added to this
1230 * dictionary.
1231 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001232- (void)addEntriesFromDictionary:(GPBInt32UInt64Dictionary *)otherDictionary;
1233
Sergio Campamá32fadc02016-08-08 07:15:02 -07001234/**
1235 * Sets the value for the given key.
1236 *
1237 * @param value The value to set.
1238 * @param key The key under which to store the value.
1239 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001240- (void)setUInt64:(uint64_t)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001241
Sergio Campamá32fadc02016-08-08 07:15:02 -07001242/**
1243 * Removes the entry for the given key.
1244 *
1245 * @param aKey Key to be removed from this dictionary.
1246 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001247- (void)removeUInt64ForKey:(int32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001248
1249/**
1250 * Removes all entries in this dictionary.
1251 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001252- (void)removeAll;
1253
1254@end
1255
1256#pragma mark - Int32 -> Int64
1257
Sergio Campamá32fadc02016-08-08 07:15:02 -07001258/**
1259 * Class used for map fields of <int32_t, int64_t>
1260 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1261 *
1262 * @note This class is not meant to be subclassed.
1263 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001264@interface GPBInt32Int64Dictionary : NSObject <NSCopying>
1265
Sergio Campamá32fadc02016-08-08 07:15:02 -07001266/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001267@property(nonatomic, readonly) NSUInteger count;
1268
Sergio Campamá32fadc02016-08-08 07:15:02 -07001269/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07001270 * Initializes this dictionary, copying the given values and keys.
1271 *
1272 * @param values The values to be placed in this dictionary.
1273 * @param keys The keys under which to store the values.
1274 * @param count The number of elements to copy into the dictionary.
1275 *
1276 * @return A newly initialized dictionary with a copy of the values and keys.
1277 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05001278- (instancetype)initWithInt64s:(const int64_t [__nullable])values
1279 forKeys:(const int32_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001280 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001281
1282/**
1283 * Initializes this dictionary, copying the entries from the given dictionary.
1284 *
1285 * @param dictionary Dictionary containing the entries to add to this dictionary.
1286 *
1287 * @return A newly initialized dictionary with the entries of the given dictionary.
1288 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001289- (instancetype)initWithDictionary:(GPBInt32Int64Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001290
1291/**
1292 * Initializes this dictionary with the requested capacity.
1293 *
1294 * @param numItems Number of items needed for this dictionary.
1295 *
1296 * @return A newly initialized dictionary with the requested capacity.
1297 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001298- (instancetype)initWithCapacity:(NSUInteger)numItems;
1299
Sergio Campamá32fadc02016-08-08 07:15:02 -07001300/**
1301 * Gets the value for the given key.
1302 *
1303 * @param value Pointer into which the value will be set, if found.
1304 * @param key Key under which the value is stored, if present.
1305 *
1306 * @return YES if the key was found and the value was copied, NO otherwise.
1307 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001308- (BOOL)getInt64:(nullable int64_t *)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001309
Sergio Campamá32fadc02016-08-08 07:15:02 -07001310/**
1311 * Enumerates the keys and values on this dictionary with the given block.
1312 *
1313 * @param block The block to enumerate with.
1314 * **key**: The key for the current entry.
1315 * **value**: The value for the current entry
1316 * **stop**: A pointer to a boolean that when set stops the enumeration.
1317 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001318- (void)enumerateKeysAndInt64sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05001319 (void (NS_NOESCAPE ^)(int32_t key, int64_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001320
Sergio Campamá32fadc02016-08-08 07:15:02 -07001321/**
1322 * Adds the keys and values from another dictionary.
1323 *
1324 * @param otherDictionary Dictionary containing entries to be added to this
1325 * dictionary.
1326 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001327- (void)addEntriesFromDictionary:(GPBInt32Int64Dictionary *)otherDictionary;
1328
Sergio Campamá32fadc02016-08-08 07:15:02 -07001329/**
1330 * Sets the value for the given key.
1331 *
1332 * @param value The value to set.
1333 * @param key The key under which to store the value.
1334 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001335- (void)setInt64:(int64_t)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001336
Sergio Campamá32fadc02016-08-08 07:15:02 -07001337/**
1338 * Removes the entry for the given key.
1339 *
1340 * @param aKey Key to be removed from this dictionary.
1341 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001342- (void)removeInt64ForKey:(int32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001343
1344/**
1345 * Removes all entries in this dictionary.
1346 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001347- (void)removeAll;
1348
1349@end
1350
1351#pragma mark - Int32 -> Bool
1352
Sergio Campamá32fadc02016-08-08 07:15:02 -07001353/**
1354 * Class used for map fields of <int32_t, BOOL>
1355 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1356 *
1357 * @note This class is not meant to be subclassed.
1358 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001359@interface GPBInt32BoolDictionary : NSObject <NSCopying>
1360
Sergio Campamá32fadc02016-08-08 07:15:02 -07001361/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001362@property(nonatomic, readonly) NSUInteger count;
1363
Sergio Campamá32fadc02016-08-08 07:15:02 -07001364/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07001365 * Initializes this dictionary, copying the given values and keys.
1366 *
1367 * @param values The values to be placed in this dictionary.
1368 * @param keys The keys under which to store the values.
1369 * @param count The number of elements to copy into the dictionary.
1370 *
1371 * @return A newly initialized dictionary with a copy of the values and keys.
1372 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05001373- (instancetype)initWithBools:(const BOOL [__nullable])values
1374 forKeys:(const int32_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001375 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001376
1377/**
1378 * Initializes this dictionary, copying the entries from the given dictionary.
1379 *
1380 * @param dictionary Dictionary containing the entries to add to this dictionary.
1381 *
1382 * @return A newly initialized dictionary with the entries of the given dictionary.
1383 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001384- (instancetype)initWithDictionary:(GPBInt32BoolDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001385
1386/**
1387 * Initializes this dictionary with the requested capacity.
1388 *
1389 * @param numItems Number of items needed for this dictionary.
1390 *
1391 * @return A newly initialized dictionary with the requested capacity.
1392 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001393- (instancetype)initWithCapacity:(NSUInteger)numItems;
1394
Sergio Campamá32fadc02016-08-08 07:15:02 -07001395/**
1396 * Gets the value for the given key.
1397 *
1398 * @param value Pointer into which the value will be set, if found.
1399 * @param key Key under which the value is stored, if present.
1400 *
1401 * @return YES if the key was found and the value was copied, NO otherwise.
1402 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001403- (BOOL)getBool:(nullable BOOL *)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001404
Sergio Campamá32fadc02016-08-08 07:15:02 -07001405/**
1406 * Enumerates the keys and values on this dictionary with the given block.
1407 *
1408 * @param block The block to enumerate with.
1409 * **key**: The key for the current entry.
1410 * **value**: The value for the current entry
1411 * **stop**: A pointer to a boolean that when set stops the enumeration.
1412 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001413- (void)enumerateKeysAndBoolsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05001414 (void (NS_NOESCAPE ^)(int32_t key, BOOL value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001415
Sergio Campamá32fadc02016-08-08 07:15:02 -07001416/**
1417 * Adds the keys and values from another dictionary.
1418 *
1419 * @param otherDictionary Dictionary containing entries to be added to this
1420 * dictionary.
1421 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001422- (void)addEntriesFromDictionary:(GPBInt32BoolDictionary *)otherDictionary;
1423
Sergio Campamá32fadc02016-08-08 07:15:02 -07001424/**
1425 * Sets the value for the given key.
1426 *
1427 * @param value The value to set.
1428 * @param key The key under which to store the value.
1429 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001430- (void)setBool:(BOOL)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001431
Sergio Campamá32fadc02016-08-08 07:15:02 -07001432/**
1433 * Removes the entry for the given key.
1434 *
1435 * @param aKey Key to be removed from this dictionary.
1436 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001437- (void)removeBoolForKey:(int32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001438
1439/**
1440 * Removes all entries in this dictionary.
1441 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001442- (void)removeAll;
1443
1444@end
1445
1446#pragma mark - Int32 -> Float
1447
Sergio Campamá32fadc02016-08-08 07:15:02 -07001448/**
1449 * Class used for map fields of <int32_t, float>
1450 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1451 *
1452 * @note This class is not meant to be subclassed.
1453 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001454@interface GPBInt32FloatDictionary : NSObject <NSCopying>
1455
Sergio Campamá32fadc02016-08-08 07:15:02 -07001456/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001457@property(nonatomic, readonly) NSUInteger count;
1458
Sergio Campamá32fadc02016-08-08 07:15:02 -07001459/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07001460 * Initializes this dictionary, copying the given values and keys.
1461 *
1462 * @param values The values to be placed in this dictionary.
1463 * @param keys The keys under which to store the values.
1464 * @param count The number of elements to copy into the dictionary.
1465 *
1466 * @return A newly initialized dictionary with a copy of the values and keys.
1467 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05001468- (instancetype)initWithFloats:(const float [__nullable])values
1469 forKeys:(const int32_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001470 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001471
1472/**
1473 * Initializes this dictionary, copying the entries from the given dictionary.
1474 *
1475 * @param dictionary Dictionary containing the entries to add to this dictionary.
1476 *
1477 * @return A newly initialized dictionary with the entries of the given dictionary.
1478 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001479- (instancetype)initWithDictionary:(GPBInt32FloatDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001480
1481/**
1482 * Initializes this dictionary with the requested capacity.
1483 *
1484 * @param numItems Number of items needed for this dictionary.
1485 *
1486 * @return A newly initialized dictionary with the requested capacity.
1487 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001488- (instancetype)initWithCapacity:(NSUInteger)numItems;
1489
Sergio Campamá32fadc02016-08-08 07:15:02 -07001490/**
1491 * Gets the value for the given key.
1492 *
1493 * @param value Pointer into which the value will be set, if found.
1494 * @param key Key under which the value is stored, if present.
1495 *
1496 * @return YES if the key was found and the value was copied, NO otherwise.
1497 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001498- (BOOL)getFloat:(nullable float *)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001499
Sergio Campamá32fadc02016-08-08 07:15:02 -07001500/**
1501 * Enumerates the keys and values on this dictionary with the given block.
1502 *
1503 * @param block The block to enumerate with.
1504 * **key**: The key for the current entry.
1505 * **value**: The value for the current entry
1506 * **stop**: A pointer to a boolean that when set stops the enumeration.
1507 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001508- (void)enumerateKeysAndFloatsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05001509 (void (NS_NOESCAPE ^)(int32_t key, float value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001510
Sergio Campamá32fadc02016-08-08 07:15:02 -07001511/**
1512 * Adds the keys and values from another dictionary.
1513 *
1514 * @param otherDictionary Dictionary containing entries to be added to this
1515 * dictionary.
1516 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001517- (void)addEntriesFromDictionary:(GPBInt32FloatDictionary *)otherDictionary;
1518
Sergio Campamá32fadc02016-08-08 07:15:02 -07001519/**
1520 * Sets the value for the given key.
1521 *
1522 * @param value The value to set.
1523 * @param key The key under which to store the value.
1524 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001525- (void)setFloat:(float)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001526
Sergio Campamá32fadc02016-08-08 07:15:02 -07001527/**
1528 * Removes the entry for the given key.
1529 *
1530 * @param aKey Key to be removed from this dictionary.
1531 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001532- (void)removeFloatForKey:(int32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001533
1534/**
1535 * Removes all entries in this dictionary.
1536 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001537- (void)removeAll;
1538
1539@end
1540
1541#pragma mark - Int32 -> Double
1542
Sergio Campamá32fadc02016-08-08 07:15:02 -07001543/**
1544 * Class used for map fields of <int32_t, double>
1545 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1546 *
1547 * @note This class is not meant to be subclassed.
1548 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001549@interface GPBInt32DoubleDictionary : NSObject <NSCopying>
1550
Sergio Campamá32fadc02016-08-08 07:15:02 -07001551/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001552@property(nonatomic, readonly) NSUInteger count;
1553
Sergio Campamá32fadc02016-08-08 07:15:02 -07001554/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07001555 * Initializes this dictionary, copying the given values and keys.
1556 *
1557 * @param values The values to be placed in this dictionary.
1558 * @param keys The keys under which to store the values.
1559 * @param count The number of elements to copy into the dictionary.
1560 *
1561 * @return A newly initialized dictionary with a copy of the values and keys.
1562 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05001563- (instancetype)initWithDoubles:(const double [__nullable])values
1564 forKeys:(const int32_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001565 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001566
1567/**
1568 * Initializes this dictionary, copying the entries from the given dictionary.
1569 *
1570 * @param dictionary Dictionary containing the entries to add to this dictionary.
1571 *
1572 * @return A newly initialized dictionary with the entries of the given dictionary.
1573 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001574- (instancetype)initWithDictionary:(GPBInt32DoubleDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001575
1576/**
1577 * Initializes this dictionary with the requested capacity.
1578 *
1579 * @param numItems Number of items needed for this dictionary.
1580 *
1581 * @return A newly initialized dictionary with the requested capacity.
1582 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001583- (instancetype)initWithCapacity:(NSUInteger)numItems;
1584
Sergio Campamá32fadc02016-08-08 07:15:02 -07001585/**
1586 * Gets the value for the given key.
1587 *
1588 * @param value Pointer into which the value will be set, if found.
1589 * @param key Key under which the value is stored, if present.
1590 *
1591 * @return YES if the key was found and the value was copied, NO otherwise.
1592 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001593- (BOOL)getDouble:(nullable double *)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001594
Sergio Campamá32fadc02016-08-08 07:15:02 -07001595/**
1596 * Enumerates the keys and values on this dictionary with the given block.
1597 *
1598 * @param block The block to enumerate with.
1599 * **key**: The key for the current entry.
1600 * **value**: The value for the current entry
1601 * **stop**: A pointer to a boolean that when set stops the enumeration.
1602 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001603- (void)enumerateKeysAndDoublesUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05001604 (void (NS_NOESCAPE ^)(int32_t key, double value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001605
Sergio Campamá32fadc02016-08-08 07:15:02 -07001606/**
1607 * Adds the keys and values from another dictionary.
1608 *
1609 * @param otherDictionary Dictionary containing entries to be added to this
1610 * dictionary.
1611 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001612- (void)addEntriesFromDictionary:(GPBInt32DoubleDictionary *)otherDictionary;
1613
Sergio Campamá32fadc02016-08-08 07:15:02 -07001614/**
1615 * Sets the value for the given key.
1616 *
1617 * @param value The value to set.
1618 * @param key The key under which to store the value.
1619 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001620- (void)setDouble:(double)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001621
Sergio Campamá32fadc02016-08-08 07:15:02 -07001622/**
1623 * Removes the entry for the given key.
1624 *
1625 * @param aKey Key to be removed from this dictionary.
1626 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001627- (void)removeDoubleForKey:(int32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001628
1629/**
1630 * Removes all entries in this dictionary.
1631 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001632- (void)removeAll;
1633
1634@end
1635
1636#pragma mark - Int32 -> Enum
1637
Sergio Campamá32fadc02016-08-08 07:15:02 -07001638/**
1639 * Class used for map fields of <int32_t, int32_t>
1640 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1641 *
1642 * @note This class is not meant to be subclassed.
1643 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001644@interface GPBInt32EnumDictionary : NSObject <NSCopying>
1645
Sergio Campamá32fadc02016-08-08 07:15:02 -07001646/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001647@property(nonatomic, readonly) NSUInteger count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001648/** The validation function to check if the enums are valid. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001649@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
1650
Sergio Campamá32fadc02016-08-08 07:15:02 -07001651/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07001652 * Initializes a dictionary with the given validation function.
1653 *
1654 * @param func The enum validation function for the dictionary.
1655 *
1656 * @return A newly initialized dictionary.
1657 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04001658- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001659
1660/**
1661 * Initializes a dictionary with the entries given.
1662 *
1663 * @param func The enum validation function for the dictionary.
1664 * @param values The raw enum values values to be placed in the dictionary.
1665 * @param keys The keys under which to store the values.
1666 * @param count The number of entries to store in the dictionary.
1667 *
1668 * @return A newly initialized dictionary with the keys and values in it.
1669 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04001670- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Sergio Campama3d7b42d2017-01-25 11:51:54 -05001671 rawValues:(const int32_t [__nullable])values
1672 forKeys:(const int32_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001673 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001674
1675/**
1676 * Initializes a dictionary with the entries from the given.
1677 * dictionary.
1678 *
1679 * @param dictionary Dictionary containing the entries to add to the dictionary.
1680 *
1681 * @return A newly initialized dictionary with the entries from the given
1682 * dictionary in it.
1683 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001684- (instancetype)initWithDictionary:(GPBInt32EnumDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001685
1686/**
1687 * Initializes a dictionary with the given capacity.
1688 *
1689 * @param func The enum validation function for the dictionary.
1690 * @param numItems Capacity needed for the dictionary.
1691 *
1692 * @return A newly initialized dictionary with the given capacity.
1693 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04001694- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001695 capacity:(NSUInteger)numItems;
1696
1697// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
1698// is not a valid enumerator as defined by validationFunc. If the actual value is
1699// desired, use "raw" version of the method.
1700
Sergio Campamá32fadc02016-08-08 07:15:02 -07001701/**
1702 * Gets the value for the given key.
1703 *
1704 * @param value Pointer into which the value will be set, if found.
1705 * @param key Key under which the value is stored, if present.
1706 *
1707 * @return YES if the key was found and the value was copied, NO otherwise.
1708 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001709- (BOOL)getEnum:(nullable int32_t *)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001710
Sergio Campamá32fadc02016-08-08 07:15:02 -07001711/**
1712 * Enumerates the keys and values on this dictionary with the given block.
1713 *
1714 * @param block The block to enumerate with.
1715 * **key**: The key for the current entry.
1716 * **value**: The value for the current entry
1717 * **stop**: A pointer to a boolean that when set stops the enumeration.
1718 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001719- (void)enumerateKeysAndEnumsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05001720 (void (NS_NOESCAPE ^)(int32_t key, int32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001721
Sergio Campamá32fadc02016-08-08 07:15:02 -07001722/**
1723 * Gets the raw enum value for the given key.
1724 *
1725 * @note This method bypass the validationFunc to enable the access of values that
1726 * were not known at the time the binary was compiled.
1727 *
1728 * @param rawValue Pointer into which the value will be set, if found.
1729 * @param key Key under which the value is stored, if present.
1730 *
1731 * @return YES if the key was found and the value was copied, NO otherwise.
1732 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001733- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001734
Sergio Campamá32fadc02016-08-08 07:15:02 -07001735/**
1736 * Enumerates the keys and values on this dictionary with the given block.
1737 *
1738 * @note This method bypass the validationFunc to enable the access of values that
1739 * were not known at the time the binary was compiled.
1740 *
1741 * @param block The block to enumerate with.
1742 * **key**: The key for the current entry.
1743 * **rawValue**: The value for the current entry
1744 * **stop**: A pointer to a boolean that when set stops the enumeration.
1745 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001746- (void)enumerateKeysAndRawValuesUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05001747 (void (NS_NOESCAPE ^)(int32_t key, int32_t rawValue, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001748
Sergio Campamá32fadc02016-08-08 07:15:02 -07001749/**
1750 * Adds the keys and raw enum values from another dictionary.
1751 *
1752 * @note This method bypass the validationFunc to enable the setting of values that
1753 * were not known at the time the binary was compiled.
1754 *
1755 * @param otherDictionary Dictionary containing entries to be added to this
1756 * dictionary.
1757 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001758- (void)addRawEntriesFromDictionary:(GPBInt32EnumDictionary *)otherDictionary;
1759
1760// If value is not a valid enumerator as defined by validationFunc, these
1761// methods will assert in debug, and will log in release and assign the value
1762// to the default value. Use the rawValue methods below to assign non enumerator
1763// values.
1764
Sergio Campamá32fadc02016-08-08 07:15:02 -07001765/**
1766 * Sets the value for the given key.
1767 *
1768 * @param value The value to set.
1769 * @param key The key under which to store the value.
1770 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001771- (void)setEnum:(int32_t)value forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001772
Sergio Campamá32fadc02016-08-08 07:15:02 -07001773/**
1774 * Sets the raw enum value for the given key.
1775 *
1776 * @note This method bypass the validationFunc to enable the setting of values that
1777 * were not known at the time the binary was compiled.
1778 *
1779 * @param rawValue The raw enum value to set.
1780 * @param key The key under which to store the raw enum value.
1781 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001782- (void)setRawValue:(int32_t)rawValue forKey:(int32_t)key;
1783
Sergio Campamá32fadc02016-08-08 07:15:02 -07001784/**
1785 * Removes the entry for the given key.
1786 *
1787 * @param aKey Key to be removed from this dictionary.
1788 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001789- (void)removeEnumForKey:(int32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001790
1791/**
1792 * Removes all entries in this dictionary.
1793 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001794- (void)removeAll;
1795
1796@end
1797
1798#pragma mark - Int32 -> Object
1799
Sergio Campamá32fadc02016-08-08 07:15:02 -07001800/**
1801 * Class used for map fields of <int32_t, ObjectType>
1802 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1803 *
1804 * @note This class is not meant to be subclassed.
1805 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05001806@interface GPBInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001807
Sergio Campamá32fadc02016-08-08 07:15:02 -07001808/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001809@property(nonatomic, readonly) NSUInteger count;
1810
Sergio Campamá32fadc02016-08-08 07:15:02 -07001811/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07001812 * Initializes this dictionary, copying the given values and keys.
1813 *
1814 * @param objects The values to be placed in this dictionary.
1815 * @param keys The keys under which to store the values.
1816 * @param count The number of elements to copy into the dictionary.
1817 *
1818 * @return A newly initialized dictionary with a copy of the values and keys.
1819 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05001820- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
1821 forKeys:(const int32_t [__nullable])keys
Thomas Van Lenten1383d532015-09-29 11:41:53 -04001822 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001823
1824/**
1825 * Initializes this dictionary, copying the entries from the given dictionary.
1826 *
1827 * @param dictionary Dictionary containing the entries to add to this dictionary.
1828 *
1829 * @return A newly initialized dictionary with the entries of the given dictionary.
1830 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001831- (instancetype)initWithDictionary:(GPBInt32ObjectDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001832
1833/**
1834 * Initializes this dictionary with the requested capacity.
1835 *
1836 * @param numItems Number of items needed for this dictionary.
1837 *
1838 * @return A newly initialized dictionary with the requested capacity.
1839 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001840- (instancetype)initWithCapacity:(NSUInteger)numItems;
1841
Sergio Campamá32fadc02016-08-08 07:15:02 -07001842/**
1843 * Fetches the object stored under the given key.
1844 *
1845 * @param key Key under which the value is stored, if present.
1846 *
1847 * @return The object if found, nil otherwise.
1848 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05001849- (ObjectType)objectForKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001850
Sergio Campamá32fadc02016-08-08 07:15:02 -07001851/**
1852 * Enumerates the keys and values on this dictionary with the given block.
1853 *
1854 * @param block The block to enumerate with.
1855 * **key**: The key for the current entry.
1856 * **object**: The value for the current entry
1857 * **stop**: A pointer to a boolean that when set stops the enumeration.
1858 **/
Thomas Van Lenten1383d532015-09-29 11:41:53 -04001859- (void)enumerateKeysAndObjectsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05001860 (void (NS_NOESCAPE ^)(int32_t key, ObjectType object, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001861
Sergio Campamá32fadc02016-08-08 07:15:02 -07001862/**
1863 * Adds the keys and values from another dictionary.
1864 *
1865 * @param otherDictionary Dictionary containing entries to be added to this
1866 * dictionary.
1867 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001868- (void)addEntriesFromDictionary:(GPBInt32ObjectDictionary *)otherDictionary;
1869
Sergio Campamá32fadc02016-08-08 07:15:02 -07001870/**
1871 * Sets the value for the given key.
1872 *
1873 * @param object The value to set.
1874 * @param key The key under which to store the value.
1875 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05001876- (void)setObject:(ObjectType)object forKey:(int32_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001877
Sergio Campamá32fadc02016-08-08 07:15:02 -07001878/**
1879 * Removes the entry for the given key.
1880 *
1881 * @param aKey Key to be removed from this dictionary.
1882 **/
Thomas Van Lenten1383d532015-09-29 11:41:53 -04001883- (void)removeObjectForKey:(int32_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001884
1885/**
1886 * Removes all entries in this dictionary.
1887 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001888- (void)removeAll;
1889
1890@end
1891
1892#pragma mark - UInt64 -> UInt32
1893
Sergio Campamá32fadc02016-08-08 07:15:02 -07001894/**
1895 * Class used for map fields of <uint64_t, uint32_t>
1896 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1897 *
1898 * @note This class is not meant to be subclassed.
1899 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001900@interface GPBUInt64UInt32Dictionary : NSObject <NSCopying>
1901
Sergio Campamá32fadc02016-08-08 07:15:02 -07001902/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001903@property(nonatomic, readonly) NSUInteger count;
1904
Sergio Campamá32fadc02016-08-08 07:15:02 -07001905/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07001906 * Initializes this dictionary, copying the given values and keys.
1907 *
1908 * @param values The values to be placed in this dictionary.
1909 * @param keys The keys under which to store the values.
1910 * @param count The number of elements to copy into the dictionary.
1911 *
1912 * @return A newly initialized dictionary with a copy of the values and keys.
1913 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05001914- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
1915 forKeys:(const uint64_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001916 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001917
1918/**
1919 * Initializes this dictionary, copying the entries from the given dictionary.
1920 *
1921 * @param dictionary Dictionary containing the entries to add to this dictionary.
1922 *
1923 * @return A newly initialized dictionary with the entries of the given dictionary.
1924 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001925- (instancetype)initWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001926
1927/**
1928 * Initializes this dictionary with the requested capacity.
1929 *
1930 * @param numItems Number of items needed for this dictionary.
1931 *
1932 * @return A newly initialized dictionary with the requested capacity.
1933 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001934- (instancetype)initWithCapacity:(NSUInteger)numItems;
1935
Sergio Campamá32fadc02016-08-08 07:15:02 -07001936/**
1937 * Gets the value for the given key.
1938 *
1939 * @param value Pointer into which the value will be set, if found.
1940 * @param key Key under which the value is stored, if present.
1941 *
1942 * @return YES if the key was found and the value was copied, NO otherwise.
1943 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001944- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001945
Sergio Campamá32fadc02016-08-08 07:15:02 -07001946/**
1947 * Enumerates the keys and values on this dictionary with the given block.
1948 *
1949 * @param block The block to enumerate with.
1950 * **key**: The key for the current entry.
1951 * **value**: The value for the current entry
1952 * **stop**: A pointer to a boolean that when set stops the enumeration.
1953 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001954- (void)enumerateKeysAndUInt32sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05001955 (void (NS_NOESCAPE ^)(uint64_t key, uint32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001956
Sergio Campamá32fadc02016-08-08 07:15:02 -07001957/**
1958 * Adds the keys and values from another dictionary.
1959 *
1960 * @param otherDictionary Dictionary containing entries to be added to this
1961 * dictionary.
1962 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001963- (void)addEntriesFromDictionary:(GPBUInt64UInt32Dictionary *)otherDictionary;
1964
Sergio Campamá32fadc02016-08-08 07:15:02 -07001965/**
1966 * Sets the value for the given key.
1967 *
1968 * @param value The value to set.
1969 * @param key The key under which to store the value.
1970 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001971- (void)setUInt32:(uint32_t)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001972
Sergio Campamá32fadc02016-08-08 07:15:02 -07001973/**
1974 * Removes the entry for the given key.
1975 *
1976 * @param aKey Key to be removed from this dictionary.
1977 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04001978- (void)removeUInt32ForKey:(uint64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001979
1980/**
1981 * Removes all entries in this dictionary.
1982 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001983- (void)removeAll;
1984
1985@end
1986
1987#pragma mark - UInt64 -> Int32
1988
Sergio Campamá32fadc02016-08-08 07:15:02 -07001989/**
1990 * Class used for map fields of <uint64_t, int32_t>
1991 * values. This performs better than boxing into NSNumbers in NSDictionaries.
1992 *
1993 * @note This class is not meant to be subclassed.
1994 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001995@interface GPBUInt64Int32Dictionary : NSObject <NSCopying>
1996
Sergio Campamá32fadc02016-08-08 07:15:02 -07001997/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001998@property(nonatomic, readonly) NSUInteger count;
1999
Sergio Campamá32fadc02016-08-08 07:15:02 -07002000/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07002001 * Initializes this dictionary, copying the given values and keys.
2002 *
2003 * @param values The values to be placed in this dictionary.
2004 * @param keys The keys under which to store the values.
2005 * @param count The number of elements to copy into the dictionary.
2006 *
2007 * @return A newly initialized dictionary with a copy of the values and keys.
2008 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05002009- (instancetype)initWithInt32s:(const int32_t [__nullable])values
2010 forKeys:(const uint64_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002011 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002012
2013/**
2014 * Initializes this dictionary, copying the entries from the given dictionary.
2015 *
2016 * @param dictionary Dictionary containing the entries to add to this dictionary.
2017 *
2018 * @return A newly initialized dictionary with the entries of the given dictionary.
2019 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002020- (instancetype)initWithDictionary:(GPBUInt64Int32Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002021
2022/**
2023 * Initializes this dictionary with the requested capacity.
2024 *
2025 * @param numItems Number of items needed for this dictionary.
2026 *
2027 * @return A newly initialized dictionary with the requested capacity.
2028 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002029- (instancetype)initWithCapacity:(NSUInteger)numItems;
2030
Sergio Campamá32fadc02016-08-08 07:15:02 -07002031/**
2032 * Gets the value for the given key.
2033 *
2034 * @param value Pointer into which the value will be set, if found.
2035 * @param key Key under which the value is stored, if present.
2036 *
2037 * @return YES if the key was found and the value was copied, NO otherwise.
2038 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002039- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002040
Sergio Campamá32fadc02016-08-08 07:15:02 -07002041/**
2042 * Enumerates the keys and values on this dictionary with the given block.
2043 *
2044 * @param block The block to enumerate with.
2045 * **key**: The key for the current entry.
2046 * **value**: The value for the current entry
2047 * **stop**: A pointer to a boolean that when set stops the enumeration.
2048 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002049- (void)enumerateKeysAndInt32sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05002050 (void (NS_NOESCAPE ^)(uint64_t key, int32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002051
Sergio Campamá32fadc02016-08-08 07:15:02 -07002052/**
2053 * Adds the keys and values from another dictionary.
2054 *
2055 * @param otherDictionary Dictionary containing entries to be added to this
2056 * dictionary.
2057 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002058- (void)addEntriesFromDictionary:(GPBUInt64Int32Dictionary *)otherDictionary;
2059
Sergio Campamá32fadc02016-08-08 07:15:02 -07002060/**
2061 * Sets the value for the given key.
2062 *
2063 * @param value The value to set.
2064 * @param key The key under which to store the value.
2065 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002066- (void)setInt32:(int32_t)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002067
Sergio Campamá32fadc02016-08-08 07:15:02 -07002068/**
2069 * Removes the entry for the given key.
2070 *
2071 * @param aKey Key to be removed from this dictionary.
2072 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002073- (void)removeInt32ForKey:(uint64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002074
2075/**
2076 * Removes all entries in this dictionary.
2077 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002078- (void)removeAll;
2079
2080@end
2081
2082#pragma mark - UInt64 -> UInt64
2083
Sergio Campamá32fadc02016-08-08 07:15:02 -07002084/**
2085 * Class used for map fields of <uint64_t, uint64_t>
2086 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2087 *
2088 * @note This class is not meant to be subclassed.
2089 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002090@interface GPBUInt64UInt64Dictionary : NSObject <NSCopying>
2091
Sergio Campamá32fadc02016-08-08 07:15:02 -07002092/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002093@property(nonatomic, readonly) NSUInteger count;
2094
Sergio Campamá32fadc02016-08-08 07:15:02 -07002095/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07002096 * Initializes this dictionary, copying the given values and keys.
2097 *
2098 * @param values The values to be placed in this dictionary.
2099 * @param keys The keys under which to store the values.
2100 * @param count The number of elements to copy into the dictionary.
2101 *
2102 * @return A newly initialized dictionary with a copy of the values and keys.
2103 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05002104- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
2105 forKeys:(const uint64_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002106 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002107
2108/**
2109 * Initializes this dictionary, copying the entries from the given dictionary.
2110 *
2111 * @param dictionary Dictionary containing the entries to add to this dictionary.
2112 *
2113 * @return A newly initialized dictionary with the entries of the given dictionary.
2114 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002115- (instancetype)initWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002116
2117/**
2118 * Initializes this dictionary with the requested capacity.
2119 *
2120 * @param numItems Number of items needed for this dictionary.
2121 *
2122 * @return A newly initialized dictionary with the requested capacity.
2123 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002124- (instancetype)initWithCapacity:(NSUInteger)numItems;
2125
Sergio Campamá32fadc02016-08-08 07:15:02 -07002126/**
2127 * Gets the value for the given key.
2128 *
2129 * @param value Pointer into which the value will be set, if found.
2130 * @param key Key under which the value is stored, if present.
2131 *
2132 * @return YES if the key was found and the value was copied, NO otherwise.
2133 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002134- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002135
Sergio Campamá32fadc02016-08-08 07:15:02 -07002136/**
2137 * Enumerates the keys and values on this dictionary with the given block.
2138 *
2139 * @param block The block to enumerate with.
2140 * **key**: The key for the current entry.
2141 * **value**: The value for the current entry
2142 * **stop**: A pointer to a boolean that when set stops the enumeration.
2143 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002144- (void)enumerateKeysAndUInt64sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05002145 (void (NS_NOESCAPE ^)(uint64_t key, uint64_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002146
Sergio Campamá32fadc02016-08-08 07:15:02 -07002147/**
2148 * Adds the keys and values from another dictionary.
2149 *
2150 * @param otherDictionary Dictionary containing entries to be added to this
2151 * dictionary.
2152 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002153- (void)addEntriesFromDictionary:(GPBUInt64UInt64Dictionary *)otherDictionary;
2154
Sergio Campamá32fadc02016-08-08 07:15:02 -07002155/**
2156 * Sets the value for the given key.
2157 *
2158 * @param value The value to set.
2159 * @param key The key under which to store the value.
2160 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002161- (void)setUInt64:(uint64_t)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002162
Sergio Campamá32fadc02016-08-08 07:15:02 -07002163/**
2164 * Removes the entry for the given key.
2165 *
2166 * @param aKey Key to be removed from this dictionary.
2167 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002168- (void)removeUInt64ForKey:(uint64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002169
2170/**
2171 * Removes all entries in this dictionary.
2172 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002173- (void)removeAll;
2174
2175@end
2176
2177#pragma mark - UInt64 -> Int64
2178
Sergio Campamá32fadc02016-08-08 07:15:02 -07002179/**
2180 * Class used for map fields of <uint64_t, int64_t>
2181 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2182 *
2183 * @note This class is not meant to be subclassed.
2184 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002185@interface GPBUInt64Int64Dictionary : NSObject <NSCopying>
2186
Sergio Campamá32fadc02016-08-08 07:15:02 -07002187/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002188@property(nonatomic, readonly) NSUInteger count;
2189
Sergio Campamá32fadc02016-08-08 07:15:02 -07002190/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07002191 * Initializes this dictionary, copying the given values and keys.
2192 *
2193 * @param values The values to be placed in this dictionary.
2194 * @param keys The keys under which to store the values.
2195 * @param count The number of elements to copy into the dictionary.
2196 *
2197 * @return A newly initialized dictionary with a copy of the values and keys.
2198 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05002199- (instancetype)initWithInt64s:(const int64_t [__nullable])values
2200 forKeys:(const uint64_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002201 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002202
2203/**
2204 * Initializes this dictionary, copying the entries from the given dictionary.
2205 *
2206 * @param dictionary Dictionary containing the entries to add to this dictionary.
2207 *
2208 * @return A newly initialized dictionary with the entries of the given dictionary.
2209 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002210- (instancetype)initWithDictionary:(GPBUInt64Int64Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002211
2212/**
2213 * Initializes this dictionary with the requested capacity.
2214 *
2215 * @param numItems Number of items needed for this dictionary.
2216 *
2217 * @return A newly initialized dictionary with the requested capacity.
2218 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002219- (instancetype)initWithCapacity:(NSUInteger)numItems;
2220
Sergio Campamá32fadc02016-08-08 07:15:02 -07002221/**
2222 * Gets the value for the given key.
2223 *
2224 * @param value Pointer into which the value will be set, if found.
2225 * @param key Key under which the value is stored, if present.
2226 *
2227 * @return YES if the key was found and the value was copied, NO otherwise.
2228 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002229- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002230
Sergio Campamá32fadc02016-08-08 07:15:02 -07002231/**
2232 * Enumerates the keys and values on this dictionary with the given block.
2233 *
2234 * @param block The block to enumerate with.
2235 * **key**: The key for the current entry.
2236 * **value**: The value for the current entry
2237 * **stop**: A pointer to a boolean that when set stops the enumeration.
2238 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002239- (void)enumerateKeysAndInt64sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05002240 (void (NS_NOESCAPE ^)(uint64_t key, int64_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002241
Sergio Campamá32fadc02016-08-08 07:15:02 -07002242/**
2243 * Adds the keys and values from another dictionary.
2244 *
2245 * @param otherDictionary Dictionary containing entries to be added to this
2246 * dictionary.
2247 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002248- (void)addEntriesFromDictionary:(GPBUInt64Int64Dictionary *)otherDictionary;
2249
Sergio Campamá32fadc02016-08-08 07:15:02 -07002250/**
2251 * Sets the value for the given key.
2252 *
2253 * @param value The value to set.
2254 * @param key The key under which to store the value.
2255 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002256- (void)setInt64:(int64_t)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002257
Sergio Campamá32fadc02016-08-08 07:15:02 -07002258/**
2259 * Removes the entry for the given key.
2260 *
2261 * @param aKey Key to be removed from this dictionary.
2262 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002263- (void)removeInt64ForKey:(uint64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002264
2265/**
2266 * Removes all entries in this dictionary.
2267 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002268- (void)removeAll;
2269
2270@end
2271
2272#pragma mark - UInt64 -> Bool
2273
Sergio Campamá32fadc02016-08-08 07:15:02 -07002274/**
2275 * Class used for map fields of <uint64_t, BOOL>
2276 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2277 *
2278 * @note This class is not meant to be subclassed.
2279 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002280@interface GPBUInt64BoolDictionary : NSObject <NSCopying>
2281
Sergio Campamá32fadc02016-08-08 07:15:02 -07002282/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002283@property(nonatomic, readonly) NSUInteger count;
2284
Sergio Campamá32fadc02016-08-08 07:15:02 -07002285/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07002286 * Initializes this dictionary, copying the given values and keys.
2287 *
2288 * @param values The values to be placed in this dictionary.
2289 * @param keys The keys under which to store the values.
2290 * @param count The number of elements to copy into the dictionary.
2291 *
2292 * @return A newly initialized dictionary with a copy of the values and keys.
2293 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05002294- (instancetype)initWithBools:(const BOOL [__nullable])values
2295 forKeys:(const uint64_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002296 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002297
2298/**
2299 * Initializes this dictionary, copying the entries from the given dictionary.
2300 *
2301 * @param dictionary Dictionary containing the entries to add to this dictionary.
2302 *
2303 * @return A newly initialized dictionary with the entries of the given dictionary.
2304 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002305- (instancetype)initWithDictionary:(GPBUInt64BoolDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002306
2307/**
2308 * Initializes this dictionary with the requested capacity.
2309 *
2310 * @param numItems Number of items needed for this dictionary.
2311 *
2312 * @return A newly initialized dictionary with the requested capacity.
2313 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002314- (instancetype)initWithCapacity:(NSUInteger)numItems;
2315
Sergio Campamá32fadc02016-08-08 07:15:02 -07002316/**
2317 * Gets the value for the given key.
2318 *
2319 * @param value Pointer into which the value will be set, if found.
2320 * @param key Key under which the value is stored, if present.
2321 *
2322 * @return YES if the key was found and the value was copied, NO otherwise.
2323 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002324- (BOOL)getBool:(nullable BOOL *)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002325
Sergio Campamá32fadc02016-08-08 07:15:02 -07002326/**
2327 * Enumerates the keys and values on this dictionary with the given block.
2328 *
2329 * @param block The block to enumerate with.
2330 * **key**: The key for the current entry.
2331 * **value**: The value for the current entry
2332 * **stop**: A pointer to a boolean that when set stops the enumeration.
2333 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002334- (void)enumerateKeysAndBoolsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05002335 (void (NS_NOESCAPE ^)(uint64_t key, BOOL value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002336
Sergio Campamá32fadc02016-08-08 07:15:02 -07002337/**
2338 * Adds the keys and values from another dictionary.
2339 *
2340 * @param otherDictionary Dictionary containing entries to be added to this
2341 * dictionary.
2342 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002343- (void)addEntriesFromDictionary:(GPBUInt64BoolDictionary *)otherDictionary;
2344
Sergio Campamá32fadc02016-08-08 07:15:02 -07002345/**
2346 * Sets the value for the given key.
2347 *
2348 * @param value The value to set.
2349 * @param key The key under which to store the value.
2350 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002351- (void)setBool:(BOOL)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002352
Sergio Campamá32fadc02016-08-08 07:15:02 -07002353/**
2354 * Removes the entry for the given key.
2355 *
2356 * @param aKey Key to be removed from this dictionary.
2357 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002358- (void)removeBoolForKey:(uint64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002359
2360/**
2361 * Removes all entries in this dictionary.
2362 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002363- (void)removeAll;
2364
2365@end
2366
2367#pragma mark - UInt64 -> Float
2368
Sergio Campamá32fadc02016-08-08 07:15:02 -07002369/**
2370 * Class used for map fields of <uint64_t, float>
2371 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2372 *
2373 * @note This class is not meant to be subclassed.
2374 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002375@interface GPBUInt64FloatDictionary : NSObject <NSCopying>
2376
Sergio Campamá32fadc02016-08-08 07:15:02 -07002377/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002378@property(nonatomic, readonly) NSUInteger count;
2379
Sergio Campamá32fadc02016-08-08 07:15:02 -07002380/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07002381 * Initializes this dictionary, copying the given values and keys.
2382 *
2383 * @param values The values to be placed in this dictionary.
2384 * @param keys The keys under which to store the values.
2385 * @param count The number of elements to copy into the dictionary.
2386 *
2387 * @return A newly initialized dictionary with a copy of the values and keys.
2388 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05002389- (instancetype)initWithFloats:(const float [__nullable])values
2390 forKeys:(const uint64_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002391 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002392
2393/**
2394 * Initializes this dictionary, copying the entries from the given dictionary.
2395 *
2396 * @param dictionary Dictionary containing the entries to add to this dictionary.
2397 *
2398 * @return A newly initialized dictionary with the entries of the given dictionary.
2399 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002400- (instancetype)initWithDictionary:(GPBUInt64FloatDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002401
2402/**
2403 * Initializes this dictionary with the requested capacity.
2404 *
2405 * @param numItems Number of items needed for this dictionary.
2406 *
2407 * @return A newly initialized dictionary with the requested capacity.
2408 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002409- (instancetype)initWithCapacity:(NSUInteger)numItems;
2410
Sergio Campamá32fadc02016-08-08 07:15:02 -07002411/**
2412 * Gets the value for the given key.
2413 *
2414 * @param value Pointer into which the value will be set, if found.
2415 * @param key Key under which the value is stored, if present.
2416 *
2417 * @return YES if the key was found and the value was copied, NO otherwise.
2418 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002419- (BOOL)getFloat:(nullable float *)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002420
Sergio Campamá32fadc02016-08-08 07:15:02 -07002421/**
2422 * Enumerates the keys and values on this dictionary with the given block.
2423 *
2424 * @param block The block to enumerate with.
2425 * **key**: The key for the current entry.
2426 * **value**: The value for the current entry
2427 * **stop**: A pointer to a boolean that when set stops the enumeration.
2428 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002429- (void)enumerateKeysAndFloatsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05002430 (void (NS_NOESCAPE ^)(uint64_t key, float value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002431
Sergio Campamá32fadc02016-08-08 07:15:02 -07002432/**
2433 * Adds the keys and values from another dictionary.
2434 *
2435 * @param otherDictionary Dictionary containing entries to be added to this
2436 * dictionary.
2437 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002438- (void)addEntriesFromDictionary:(GPBUInt64FloatDictionary *)otherDictionary;
2439
Sergio Campamá32fadc02016-08-08 07:15:02 -07002440/**
2441 * Sets the value for the given key.
2442 *
2443 * @param value The value to set.
2444 * @param key The key under which to store the value.
2445 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002446- (void)setFloat:(float)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002447
Sergio Campamá32fadc02016-08-08 07:15:02 -07002448/**
2449 * Removes the entry for the given key.
2450 *
2451 * @param aKey Key to be removed from this dictionary.
2452 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002453- (void)removeFloatForKey:(uint64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002454
2455/**
2456 * Removes all entries in this dictionary.
2457 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002458- (void)removeAll;
2459
2460@end
2461
2462#pragma mark - UInt64 -> Double
2463
Sergio Campamá32fadc02016-08-08 07:15:02 -07002464/**
2465 * Class used for map fields of <uint64_t, double>
2466 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2467 *
2468 * @note This class is not meant to be subclassed.
2469 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002470@interface GPBUInt64DoubleDictionary : NSObject <NSCopying>
2471
Sergio Campamá32fadc02016-08-08 07:15:02 -07002472/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002473@property(nonatomic, readonly) NSUInteger count;
2474
Sergio Campamá32fadc02016-08-08 07:15:02 -07002475/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07002476 * Initializes this dictionary, copying the given values and keys.
2477 *
2478 * @param values The values to be placed in this dictionary.
2479 * @param keys The keys under which to store the values.
2480 * @param count The number of elements to copy into the dictionary.
2481 *
2482 * @return A newly initialized dictionary with a copy of the values and keys.
2483 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05002484- (instancetype)initWithDoubles:(const double [__nullable])values
2485 forKeys:(const uint64_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002486 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002487
2488/**
2489 * Initializes this dictionary, copying the entries from the given dictionary.
2490 *
2491 * @param dictionary Dictionary containing the entries to add to this dictionary.
2492 *
2493 * @return A newly initialized dictionary with the entries of the given dictionary.
2494 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002495- (instancetype)initWithDictionary:(GPBUInt64DoubleDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002496
2497/**
2498 * Initializes this dictionary with the requested capacity.
2499 *
2500 * @param numItems Number of items needed for this dictionary.
2501 *
2502 * @return A newly initialized dictionary with the requested capacity.
2503 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002504- (instancetype)initWithCapacity:(NSUInteger)numItems;
2505
Sergio Campamá32fadc02016-08-08 07:15:02 -07002506/**
2507 * Gets the value for the given key.
2508 *
2509 * @param value Pointer into which the value will be set, if found.
2510 * @param key Key under which the value is stored, if present.
2511 *
2512 * @return YES if the key was found and the value was copied, NO otherwise.
2513 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002514- (BOOL)getDouble:(nullable double *)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002515
Sergio Campamá32fadc02016-08-08 07:15:02 -07002516/**
2517 * Enumerates the keys and values on this dictionary with the given block.
2518 *
2519 * @param block The block to enumerate with.
2520 * **key**: The key for the current entry.
2521 * **value**: The value for the current entry
2522 * **stop**: A pointer to a boolean that when set stops the enumeration.
2523 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002524- (void)enumerateKeysAndDoublesUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05002525 (void (NS_NOESCAPE ^)(uint64_t key, double value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002526
Sergio Campamá32fadc02016-08-08 07:15:02 -07002527/**
2528 * Adds the keys and values from another dictionary.
2529 *
2530 * @param otherDictionary Dictionary containing entries to be added to this
2531 * dictionary.
2532 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002533- (void)addEntriesFromDictionary:(GPBUInt64DoubleDictionary *)otherDictionary;
2534
Sergio Campamá32fadc02016-08-08 07:15:02 -07002535/**
2536 * Sets the value for the given key.
2537 *
2538 * @param value The value to set.
2539 * @param key The key under which to store the value.
2540 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002541- (void)setDouble:(double)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002542
Sergio Campamá32fadc02016-08-08 07:15:02 -07002543/**
2544 * Removes the entry for the given key.
2545 *
2546 * @param aKey Key to be removed from this dictionary.
2547 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002548- (void)removeDoubleForKey:(uint64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002549
2550/**
2551 * Removes all entries in this dictionary.
2552 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002553- (void)removeAll;
2554
2555@end
2556
2557#pragma mark - UInt64 -> Enum
2558
Sergio Campamá32fadc02016-08-08 07:15:02 -07002559/**
2560 * Class used for map fields of <uint64_t, int32_t>
2561 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2562 *
2563 * @note This class is not meant to be subclassed.
2564 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002565@interface GPBUInt64EnumDictionary : NSObject <NSCopying>
2566
Sergio Campamá32fadc02016-08-08 07:15:02 -07002567/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002568@property(nonatomic, readonly) NSUInteger count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002569/** The validation function to check if the enums are valid. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002570@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
2571
Sergio Campamá32fadc02016-08-08 07:15:02 -07002572/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07002573 * Initializes a dictionary with the given validation function.
2574 *
2575 * @param func The enum validation function for the dictionary.
2576 *
2577 * @return A newly initialized dictionary.
2578 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04002579- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002580
2581/**
2582 * Initializes a dictionary with the entries given.
2583 *
2584 * @param func The enum validation function for the dictionary.
2585 * @param values The raw enum values values to be placed in the dictionary.
2586 * @param keys The keys under which to store the values.
2587 * @param count The number of entries to store in the dictionary.
2588 *
2589 * @return A newly initialized dictionary with the keys and values in it.
2590 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04002591- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Sergio Campama3d7b42d2017-01-25 11:51:54 -05002592 rawValues:(const int32_t [__nullable])values
2593 forKeys:(const uint64_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002594 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002595
2596/**
2597 * Initializes a dictionary with the entries from the given.
2598 * dictionary.
2599 *
2600 * @param dictionary Dictionary containing the entries to add to the dictionary.
2601 *
2602 * @return A newly initialized dictionary with the entries from the given
2603 * dictionary in it.
2604 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002605- (instancetype)initWithDictionary:(GPBUInt64EnumDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002606
2607/**
2608 * Initializes a dictionary with the given capacity.
2609 *
2610 * @param func The enum validation function for the dictionary.
2611 * @param numItems Capacity needed for the dictionary.
2612 *
2613 * @return A newly initialized dictionary with the given capacity.
2614 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04002615- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002616 capacity:(NSUInteger)numItems;
2617
2618// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
2619// is not a valid enumerator as defined by validationFunc. If the actual value is
2620// desired, use "raw" version of the method.
2621
Sergio Campamá32fadc02016-08-08 07:15:02 -07002622/**
2623 * Gets the value for the given key.
2624 *
2625 * @param value Pointer into which the value will be set, if found.
2626 * @param key Key under which the value is stored, if present.
2627 *
2628 * @return YES if the key was found and the value was copied, NO otherwise.
2629 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002630- (BOOL)getEnum:(nullable int32_t *)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002631
Sergio Campamá32fadc02016-08-08 07:15:02 -07002632/**
2633 * Enumerates the keys and values on this dictionary with the given block.
2634 *
2635 * @param block The block to enumerate with.
2636 * **key**: The key for the current entry.
2637 * **value**: The value for the current entry
2638 * **stop**: A pointer to a boolean that when set stops the enumeration.
2639 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002640- (void)enumerateKeysAndEnumsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05002641 (void (NS_NOESCAPE ^)(uint64_t key, int32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002642
Sergio Campamá32fadc02016-08-08 07:15:02 -07002643/**
2644 * Gets the raw enum value for the given key.
2645 *
2646 * @note This method bypass the validationFunc to enable the access of values that
2647 * were not known at the time the binary was compiled.
2648 *
2649 * @param rawValue Pointer into which the value will be set, if found.
2650 * @param key Key under which the value is stored, if present.
2651 *
2652 * @return YES if the key was found and the value was copied, NO otherwise.
2653 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002654- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002655
Sergio Campamá32fadc02016-08-08 07:15:02 -07002656/**
2657 * Enumerates the keys and values on this dictionary with the given block.
2658 *
2659 * @note This method bypass the validationFunc to enable the access of values that
2660 * were not known at the time the binary was compiled.
2661 *
2662 * @param block The block to enumerate with.
2663 * **key**: The key for the current entry.
2664 * **rawValue**: The value for the current entry
2665 * **stop**: A pointer to a boolean that when set stops the enumeration.
2666 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002667- (void)enumerateKeysAndRawValuesUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05002668 (void (NS_NOESCAPE ^)(uint64_t key, int32_t rawValue, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002669
Sergio Campamá32fadc02016-08-08 07:15:02 -07002670/**
2671 * Adds the keys and raw enum values from another dictionary.
2672 *
2673 * @note This method bypass the validationFunc to enable the setting of values that
2674 * were not known at the time the binary was compiled.
2675 *
2676 * @param otherDictionary Dictionary containing entries to be added to this
2677 * dictionary.
2678 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002679- (void)addRawEntriesFromDictionary:(GPBUInt64EnumDictionary *)otherDictionary;
2680
2681// If value is not a valid enumerator as defined by validationFunc, these
2682// methods will assert in debug, and will log in release and assign the value
2683// to the default value. Use the rawValue methods below to assign non enumerator
2684// values.
2685
Sergio Campamá32fadc02016-08-08 07:15:02 -07002686/**
2687 * Sets the value for the given key.
2688 *
2689 * @param value The value to set.
2690 * @param key The key under which to store the value.
2691 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002692- (void)setEnum:(int32_t)value forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002693
Sergio Campamá32fadc02016-08-08 07:15:02 -07002694/**
2695 * Sets the raw enum value for the given key.
2696 *
2697 * @note This method bypass the validationFunc to enable the setting of values that
2698 * were not known at the time the binary was compiled.
2699 *
2700 * @param rawValue The raw enum value to set.
2701 * @param key The key under which to store the raw enum value.
2702 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002703- (void)setRawValue:(int32_t)rawValue forKey:(uint64_t)key;
2704
Sergio Campamá32fadc02016-08-08 07:15:02 -07002705/**
2706 * Removes the entry for the given key.
2707 *
2708 * @param aKey Key to be removed from this dictionary.
2709 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002710- (void)removeEnumForKey:(uint64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002711
2712/**
2713 * Removes all entries in this dictionary.
2714 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002715- (void)removeAll;
2716
2717@end
2718
2719#pragma mark - UInt64 -> Object
2720
Sergio Campamá32fadc02016-08-08 07:15:02 -07002721/**
2722 * Class used for map fields of <uint64_t, ObjectType>
2723 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2724 *
2725 * @note This class is not meant to be subclassed.
2726 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05002727@interface GPBUInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002728
Sergio Campamá32fadc02016-08-08 07:15:02 -07002729/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002730@property(nonatomic, readonly) NSUInteger count;
2731
Sergio Campamá32fadc02016-08-08 07:15:02 -07002732/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07002733 * Initializes this dictionary, copying the given values and keys.
2734 *
2735 * @param objects The values to be placed in this dictionary.
2736 * @param keys The keys under which to store the values.
2737 * @param count The number of elements to copy into the dictionary.
2738 *
2739 * @return A newly initialized dictionary with a copy of the values and keys.
2740 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05002741- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
2742 forKeys:(const uint64_t [__nullable])keys
Thomas Van Lenten1383d532015-09-29 11:41:53 -04002743 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002744
2745/**
2746 * Initializes this dictionary, copying the entries from the given dictionary.
2747 *
2748 * @param dictionary Dictionary containing the entries to add to this dictionary.
2749 *
2750 * @return A newly initialized dictionary with the entries of the given dictionary.
2751 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002752- (instancetype)initWithDictionary:(GPBUInt64ObjectDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002753
2754/**
2755 * Initializes this dictionary with the requested capacity.
2756 *
2757 * @param numItems Number of items needed for this dictionary.
2758 *
2759 * @return A newly initialized dictionary with the requested capacity.
2760 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002761- (instancetype)initWithCapacity:(NSUInteger)numItems;
2762
Sergio Campamá32fadc02016-08-08 07:15:02 -07002763/**
2764 * Fetches the object stored under the given key.
2765 *
2766 * @param key Key under which the value is stored, if present.
2767 *
2768 * @return The object if found, nil otherwise.
2769 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05002770- (ObjectType)objectForKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002771
Sergio Campamá32fadc02016-08-08 07:15:02 -07002772/**
2773 * Enumerates the keys and values on this dictionary with the given block.
2774 *
2775 * @param block The block to enumerate with.
2776 * **key**: The key for the current entry.
2777 * **object**: The value for the current entry
2778 * **stop**: A pointer to a boolean that when set stops the enumeration.
2779 **/
Thomas Van Lenten1383d532015-09-29 11:41:53 -04002780- (void)enumerateKeysAndObjectsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05002781 (void (NS_NOESCAPE ^)(uint64_t key, ObjectType object, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002782
Sergio Campamá32fadc02016-08-08 07:15:02 -07002783/**
2784 * Adds the keys and values from another dictionary.
2785 *
2786 * @param otherDictionary Dictionary containing entries to be added to this
2787 * dictionary.
2788 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002789- (void)addEntriesFromDictionary:(GPBUInt64ObjectDictionary *)otherDictionary;
2790
Sergio Campamá32fadc02016-08-08 07:15:02 -07002791/**
2792 * Sets the value for the given key.
2793 *
2794 * @param object The value to set.
2795 * @param key The key under which to store the value.
2796 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05002797- (void)setObject:(ObjectType)object forKey:(uint64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002798
Sergio Campamá32fadc02016-08-08 07:15:02 -07002799/**
2800 * Removes the entry for the given key.
2801 *
2802 * @param aKey Key to be removed from this dictionary.
2803 **/
Thomas Van Lenten1383d532015-09-29 11:41:53 -04002804- (void)removeObjectForKey:(uint64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002805
2806/**
2807 * Removes all entries in this dictionary.
2808 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002809- (void)removeAll;
2810
2811@end
2812
2813#pragma mark - Int64 -> UInt32
2814
Sergio Campamá32fadc02016-08-08 07:15:02 -07002815/**
2816 * Class used for map fields of <int64_t, uint32_t>
2817 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2818 *
2819 * @note This class is not meant to be subclassed.
2820 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002821@interface GPBInt64UInt32Dictionary : NSObject <NSCopying>
2822
Sergio Campamá32fadc02016-08-08 07:15:02 -07002823/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002824@property(nonatomic, readonly) NSUInteger count;
2825
Sergio Campamá32fadc02016-08-08 07:15:02 -07002826/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07002827 * Initializes this dictionary, copying the given values and keys.
2828 *
2829 * @param values The values to be placed in this dictionary.
2830 * @param keys The keys under which to store the values.
2831 * @param count The number of elements to copy into the dictionary.
2832 *
2833 * @return A newly initialized dictionary with a copy of the values and keys.
2834 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05002835- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
2836 forKeys:(const int64_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002837 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002838
2839/**
2840 * Initializes this dictionary, copying the entries from the given dictionary.
2841 *
2842 * @param dictionary Dictionary containing the entries to add to this dictionary.
2843 *
2844 * @return A newly initialized dictionary with the entries of the given dictionary.
2845 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002846- (instancetype)initWithDictionary:(GPBInt64UInt32Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002847
2848/**
2849 * Initializes this dictionary with the requested capacity.
2850 *
2851 * @param numItems Number of items needed for this dictionary.
2852 *
2853 * @return A newly initialized dictionary with the requested capacity.
2854 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002855- (instancetype)initWithCapacity:(NSUInteger)numItems;
2856
Sergio Campamá32fadc02016-08-08 07:15:02 -07002857/**
2858 * Gets the value for the given key.
2859 *
2860 * @param value Pointer into which the value will be set, if found.
2861 * @param key Key under which the value is stored, if present.
2862 *
2863 * @return YES if the key was found and the value was copied, NO otherwise.
2864 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002865- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002866
Sergio Campamá32fadc02016-08-08 07:15:02 -07002867/**
2868 * Enumerates the keys and values on this dictionary with the given block.
2869 *
2870 * @param block The block to enumerate with.
2871 * **key**: The key for the current entry.
2872 * **value**: The value for the current entry
2873 * **stop**: A pointer to a boolean that when set stops the enumeration.
2874 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002875- (void)enumerateKeysAndUInt32sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05002876 (void (NS_NOESCAPE ^)(int64_t key, uint32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002877
Sergio Campamá32fadc02016-08-08 07:15:02 -07002878/**
2879 * Adds the keys and values from another dictionary.
2880 *
2881 * @param otherDictionary Dictionary containing entries to be added to this
2882 * dictionary.
2883 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002884- (void)addEntriesFromDictionary:(GPBInt64UInt32Dictionary *)otherDictionary;
2885
Sergio Campamá32fadc02016-08-08 07:15:02 -07002886/**
2887 * Sets the value for the given key.
2888 *
2889 * @param value The value to set.
2890 * @param key The key under which to store the value.
2891 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002892- (void)setUInt32:(uint32_t)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002893
Sergio Campamá32fadc02016-08-08 07:15:02 -07002894/**
2895 * Removes the entry for the given key.
2896 *
2897 * @param aKey Key to be removed from this dictionary.
2898 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002899- (void)removeUInt32ForKey:(int64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002900
2901/**
2902 * Removes all entries in this dictionary.
2903 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002904- (void)removeAll;
2905
2906@end
2907
2908#pragma mark - Int64 -> Int32
2909
Sergio Campamá32fadc02016-08-08 07:15:02 -07002910/**
2911 * Class used for map fields of <int64_t, int32_t>
2912 * values. This performs better than boxing into NSNumbers in NSDictionaries.
2913 *
2914 * @note This class is not meant to be subclassed.
2915 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002916@interface GPBInt64Int32Dictionary : NSObject <NSCopying>
2917
Sergio Campamá32fadc02016-08-08 07:15:02 -07002918/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002919@property(nonatomic, readonly) NSUInteger count;
2920
Sergio Campamá32fadc02016-08-08 07:15:02 -07002921/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07002922 * Initializes this dictionary, copying the given values and keys.
2923 *
2924 * @param values The values to be placed in this dictionary.
2925 * @param keys The keys under which to store the values.
2926 * @param count The number of elements to copy into the dictionary.
2927 *
2928 * @return A newly initialized dictionary with a copy of the values and keys.
2929 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05002930- (instancetype)initWithInt32s:(const int32_t [__nullable])values
2931 forKeys:(const int64_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002932 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002933
2934/**
2935 * Initializes this dictionary, copying the entries from the given dictionary.
2936 *
2937 * @param dictionary Dictionary containing the entries to add to this dictionary.
2938 *
2939 * @return A newly initialized dictionary with the entries of the given dictionary.
2940 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002941- (instancetype)initWithDictionary:(GPBInt64Int32Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002942
2943/**
2944 * Initializes this dictionary with the requested capacity.
2945 *
2946 * @param numItems Number of items needed for this dictionary.
2947 *
2948 * @return A newly initialized dictionary with the requested capacity.
2949 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002950- (instancetype)initWithCapacity:(NSUInteger)numItems;
2951
Sergio Campamá32fadc02016-08-08 07:15:02 -07002952/**
2953 * Gets the value for the given key.
2954 *
2955 * @param value Pointer into which the value will be set, if found.
2956 * @param key Key under which the value is stored, if present.
2957 *
2958 * @return YES if the key was found and the value was copied, NO otherwise.
2959 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002960- (BOOL)getInt32:(nullable int32_t *)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002961
Sergio Campamá32fadc02016-08-08 07:15:02 -07002962/**
2963 * Enumerates the keys and values on this dictionary with the given block.
2964 *
2965 * @param block The block to enumerate with.
2966 * **key**: The key for the current entry.
2967 * **value**: The value for the current entry
2968 * **stop**: A pointer to a boolean that when set stops the enumeration.
2969 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002970- (void)enumerateKeysAndInt32sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05002971 (void (NS_NOESCAPE ^)(int64_t key, int32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002972
Sergio Campamá32fadc02016-08-08 07:15:02 -07002973/**
2974 * Adds the keys and values from another dictionary.
2975 *
2976 * @param otherDictionary Dictionary containing entries to be added to this
2977 * dictionary.
2978 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002979- (void)addEntriesFromDictionary:(GPBInt64Int32Dictionary *)otherDictionary;
2980
Sergio Campamá32fadc02016-08-08 07:15:02 -07002981/**
2982 * Sets the value for the given key.
2983 *
2984 * @param value The value to set.
2985 * @param key The key under which to store the value.
2986 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002987- (void)setInt32:(int32_t)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002988
Sergio Campamá32fadc02016-08-08 07:15:02 -07002989/**
2990 * Removes the entry for the given key.
2991 *
2992 * @param aKey Key to be removed from this dictionary.
2993 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04002994- (void)removeInt32ForKey:(int64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07002995
2996/**
2997 * Removes all entries in this dictionary.
2998 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04002999- (void)removeAll;
3000
3001@end
3002
3003#pragma mark - Int64 -> UInt64
3004
Sergio Campamá32fadc02016-08-08 07:15:02 -07003005/**
3006 * Class used for map fields of <int64_t, uint64_t>
3007 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3008 *
3009 * @note This class is not meant to be subclassed.
3010 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003011@interface GPBInt64UInt64Dictionary : NSObject <NSCopying>
3012
Sergio Campamá32fadc02016-08-08 07:15:02 -07003013/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003014@property(nonatomic, readonly) NSUInteger count;
3015
Sergio Campamá32fadc02016-08-08 07:15:02 -07003016/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07003017 * Initializes this dictionary, copying the given values and keys.
3018 *
3019 * @param values The values to be placed in this dictionary.
3020 * @param keys The keys under which to store the values.
3021 * @param count The number of elements to copy into the dictionary.
3022 *
3023 * @return A newly initialized dictionary with a copy of the values and keys.
3024 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05003025- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
3026 forKeys:(const int64_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003027 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003028
3029/**
3030 * Initializes this dictionary, copying the entries from the given dictionary.
3031 *
3032 * @param dictionary Dictionary containing the entries to add to this dictionary.
3033 *
3034 * @return A newly initialized dictionary with the entries of the given dictionary.
3035 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003036- (instancetype)initWithDictionary:(GPBInt64UInt64Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003037
3038/**
3039 * Initializes this dictionary with the requested capacity.
3040 *
3041 * @param numItems Number of items needed for this dictionary.
3042 *
3043 * @return A newly initialized dictionary with the requested capacity.
3044 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003045- (instancetype)initWithCapacity:(NSUInteger)numItems;
3046
Sergio Campamá32fadc02016-08-08 07:15:02 -07003047/**
3048 * Gets the value for the given key.
3049 *
3050 * @param value Pointer into which the value will be set, if found.
3051 * @param key Key under which the value is stored, if present.
3052 *
3053 * @return YES if the key was found and the value was copied, NO otherwise.
3054 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003055- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003056
Sergio Campamá32fadc02016-08-08 07:15:02 -07003057/**
3058 * Enumerates the keys and values on this dictionary with the given block.
3059 *
3060 * @param block The block to enumerate with.
3061 * **key**: The key for the current entry.
3062 * **value**: The value for the current entry
3063 * **stop**: A pointer to a boolean that when set stops the enumeration.
3064 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003065- (void)enumerateKeysAndUInt64sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05003066 (void (NS_NOESCAPE ^)(int64_t key, uint64_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003067
Sergio Campamá32fadc02016-08-08 07:15:02 -07003068/**
3069 * Adds the keys and values from another dictionary.
3070 *
3071 * @param otherDictionary Dictionary containing entries to be added to this
3072 * dictionary.
3073 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003074- (void)addEntriesFromDictionary:(GPBInt64UInt64Dictionary *)otherDictionary;
3075
Sergio Campamá32fadc02016-08-08 07:15:02 -07003076/**
3077 * Sets the value for the given key.
3078 *
3079 * @param value The value to set.
3080 * @param key The key under which to store the value.
3081 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003082- (void)setUInt64:(uint64_t)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003083
Sergio Campamá32fadc02016-08-08 07:15:02 -07003084/**
3085 * Removes the entry for the given key.
3086 *
3087 * @param aKey Key to be removed from this dictionary.
3088 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003089- (void)removeUInt64ForKey:(int64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003090
3091/**
3092 * Removes all entries in this dictionary.
3093 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003094- (void)removeAll;
3095
3096@end
3097
3098#pragma mark - Int64 -> Int64
3099
Sergio Campamá32fadc02016-08-08 07:15:02 -07003100/**
3101 * Class used for map fields of <int64_t, int64_t>
3102 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3103 *
3104 * @note This class is not meant to be subclassed.
3105 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003106@interface GPBInt64Int64Dictionary : NSObject <NSCopying>
3107
Sergio Campamá32fadc02016-08-08 07:15:02 -07003108/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003109@property(nonatomic, readonly) NSUInteger count;
3110
Sergio Campamá32fadc02016-08-08 07:15:02 -07003111/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07003112 * Initializes this dictionary, copying the given values and keys.
3113 *
3114 * @param values The values to be placed in this dictionary.
3115 * @param keys The keys under which to store the values.
3116 * @param count The number of elements to copy into the dictionary.
3117 *
3118 * @return A newly initialized dictionary with a copy of the values and keys.
3119 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05003120- (instancetype)initWithInt64s:(const int64_t [__nullable])values
3121 forKeys:(const int64_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003122 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003123
3124/**
3125 * Initializes this dictionary, copying the entries from the given dictionary.
3126 *
3127 * @param dictionary Dictionary containing the entries to add to this dictionary.
3128 *
3129 * @return A newly initialized dictionary with the entries of the given dictionary.
3130 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003131- (instancetype)initWithDictionary:(GPBInt64Int64Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003132
3133/**
3134 * Initializes this dictionary with the requested capacity.
3135 *
3136 * @param numItems Number of items needed for this dictionary.
3137 *
3138 * @return A newly initialized dictionary with the requested capacity.
3139 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003140- (instancetype)initWithCapacity:(NSUInteger)numItems;
3141
Sergio Campamá32fadc02016-08-08 07:15:02 -07003142/**
3143 * Gets the value for the given key.
3144 *
3145 * @param value Pointer into which the value will be set, if found.
3146 * @param key Key under which the value is stored, if present.
3147 *
3148 * @return YES if the key was found and the value was copied, NO otherwise.
3149 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003150- (BOOL)getInt64:(nullable int64_t *)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003151
Sergio Campamá32fadc02016-08-08 07:15:02 -07003152/**
3153 * Enumerates the keys and values on this dictionary with the given block.
3154 *
3155 * @param block The block to enumerate with.
3156 * **key**: The key for the current entry.
3157 * **value**: The value for the current entry
3158 * **stop**: A pointer to a boolean that when set stops the enumeration.
3159 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003160- (void)enumerateKeysAndInt64sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05003161 (void (NS_NOESCAPE ^)(int64_t key, int64_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003162
Sergio Campamá32fadc02016-08-08 07:15:02 -07003163/**
3164 * Adds the keys and values from another dictionary.
3165 *
3166 * @param otherDictionary Dictionary containing entries to be added to this
3167 * dictionary.
3168 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003169- (void)addEntriesFromDictionary:(GPBInt64Int64Dictionary *)otherDictionary;
3170
Sergio Campamá32fadc02016-08-08 07:15:02 -07003171/**
3172 * Sets the value for the given key.
3173 *
3174 * @param value The value to set.
3175 * @param key The key under which to store the value.
3176 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003177- (void)setInt64:(int64_t)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003178
Sergio Campamá32fadc02016-08-08 07:15:02 -07003179/**
3180 * Removes the entry for the given key.
3181 *
3182 * @param aKey Key to be removed from this dictionary.
3183 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003184- (void)removeInt64ForKey:(int64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003185
3186/**
3187 * Removes all entries in this dictionary.
3188 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003189- (void)removeAll;
3190
3191@end
3192
3193#pragma mark - Int64 -> Bool
3194
Sergio Campamá32fadc02016-08-08 07:15:02 -07003195/**
3196 * Class used for map fields of <int64_t, BOOL>
3197 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3198 *
3199 * @note This class is not meant to be subclassed.
3200 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003201@interface GPBInt64BoolDictionary : NSObject <NSCopying>
3202
Sergio Campamá32fadc02016-08-08 07:15:02 -07003203/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003204@property(nonatomic, readonly) NSUInteger count;
3205
Sergio Campamá32fadc02016-08-08 07:15:02 -07003206/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07003207 * Initializes this dictionary, copying the given values and keys.
3208 *
3209 * @param values The values to be placed in this dictionary.
3210 * @param keys The keys under which to store the values.
3211 * @param count The number of elements to copy into the dictionary.
3212 *
3213 * @return A newly initialized dictionary with a copy of the values and keys.
3214 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05003215- (instancetype)initWithBools:(const BOOL [__nullable])values
3216 forKeys:(const int64_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003217 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003218
3219/**
3220 * Initializes this dictionary, copying the entries from the given dictionary.
3221 *
3222 * @param dictionary Dictionary containing the entries to add to this dictionary.
3223 *
3224 * @return A newly initialized dictionary with the entries of the given dictionary.
3225 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003226- (instancetype)initWithDictionary:(GPBInt64BoolDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003227
3228/**
3229 * Initializes this dictionary with the requested capacity.
3230 *
3231 * @param numItems Number of items needed for this dictionary.
3232 *
3233 * @return A newly initialized dictionary with the requested capacity.
3234 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003235- (instancetype)initWithCapacity:(NSUInteger)numItems;
3236
Sergio Campamá32fadc02016-08-08 07:15:02 -07003237/**
3238 * Gets the value for the given key.
3239 *
3240 * @param value Pointer into which the value will be set, if found.
3241 * @param key Key under which the value is stored, if present.
3242 *
3243 * @return YES if the key was found and the value was copied, NO otherwise.
3244 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003245- (BOOL)getBool:(nullable BOOL *)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003246
Sergio Campamá32fadc02016-08-08 07:15:02 -07003247/**
3248 * Enumerates the keys and values on this dictionary with the given block.
3249 *
3250 * @param block The block to enumerate with.
3251 * **key**: The key for the current entry.
3252 * **value**: The value for the current entry
3253 * **stop**: A pointer to a boolean that when set stops the enumeration.
3254 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003255- (void)enumerateKeysAndBoolsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05003256 (void (NS_NOESCAPE ^)(int64_t key, BOOL value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003257
Sergio Campamá32fadc02016-08-08 07:15:02 -07003258/**
3259 * Adds the keys and values from another dictionary.
3260 *
3261 * @param otherDictionary Dictionary containing entries to be added to this
3262 * dictionary.
3263 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003264- (void)addEntriesFromDictionary:(GPBInt64BoolDictionary *)otherDictionary;
3265
Sergio Campamá32fadc02016-08-08 07:15:02 -07003266/**
3267 * Sets the value for the given key.
3268 *
3269 * @param value The value to set.
3270 * @param key The key under which to store the value.
3271 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003272- (void)setBool:(BOOL)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003273
Sergio Campamá32fadc02016-08-08 07:15:02 -07003274/**
3275 * Removes the entry for the given key.
3276 *
3277 * @param aKey Key to be removed from this dictionary.
3278 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003279- (void)removeBoolForKey:(int64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003280
3281/**
3282 * Removes all entries in this dictionary.
3283 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003284- (void)removeAll;
3285
3286@end
3287
3288#pragma mark - Int64 -> Float
3289
Sergio Campamá32fadc02016-08-08 07:15:02 -07003290/**
3291 * Class used for map fields of <int64_t, float>
3292 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3293 *
3294 * @note This class is not meant to be subclassed.
3295 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003296@interface GPBInt64FloatDictionary : NSObject <NSCopying>
3297
Sergio Campamá32fadc02016-08-08 07:15:02 -07003298/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003299@property(nonatomic, readonly) NSUInteger count;
3300
Sergio Campamá32fadc02016-08-08 07:15:02 -07003301/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07003302 * Initializes this dictionary, copying the given values and keys.
3303 *
3304 * @param values The values to be placed in this dictionary.
3305 * @param keys The keys under which to store the values.
3306 * @param count The number of elements to copy into the dictionary.
3307 *
3308 * @return A newly initialized dictionary with a copy of the values and keys.
3309 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05003310- (instancetype)initWithFloats:(const float [__nullable])values
3311 forKeys:(const int64_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003312 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003313
3314/**
3315 * Initializes this dictionary, copying the entries from the given dictionary.
3316 *
3317 * @param dictionary Dictionary containing the entries to add to this dictionary.
3318 *
3319 * @return A newly initialized dictionary with the entries of the given dictionary.
3320 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003321- (instancetype)initWithDictionary:(GPBInt64FloatDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003322
3323/**
3324 * Initializes this dictionary with the requested capacity.
3325 *
3326 * @param numItems Number of items needed for this dictionary.
3327 *
3328 * @return A newly initialized dictionary with the requested capacity.
3329 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003330- (instancetype)initWithCapacity:(NSUInteger)numItems;
3331
Sergio Campamá32fadc02016-08-08 07:15:02 -07003332/**
3333 * Gets the value for the given key.
3334 *
3335 * @param value Pointer into which the value will be set, if found.
3336 * @param key Key under which the value is stored, if present.
3337 *
3338 * @return YES if the key was found and the value was copied, NO otherwise.
3339 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003340- (BOOL)getFloat:(nullable float *)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003341
Sergio Campamá32fadc02016-08-08 07:15:02 -07003342/**
3343 * Enumerates the keys and values on this dictionary with the given block.
3344 *
3345 * @param block The block to enumerate with.
3346 * **key**: The key for the current entry.
3347 * **value**: The value for the current entry
3348 * **stop**: A pointer to a boolean that when set stops the enumeration.
3349 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003350- (void)enumerateKeysAndFloatsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05003351 (void (NS_NOESCAPE ^)(int64_t key, float value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003352
Sergio Campamá32fadc02016-08-08 07:15:02 -07003353/**
3354 * Adds the keys and values from another dictionary.
3355 *
3356 * @param otherDictionary Dictionary containing entries to be added to this
3357 * dictionary.
3358 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003359- (void)addEntriesFromDictionary:(GPBInt64FloatDictionary *)otherDictionary;
3360
Sergio Campamá32fadc02016-08-08 07:15:02 -07003361/**
3362 * Sets the value for the given key.
3363 *
3364 * @param value The value to set.
3365 * @param key The key under which to store the value.
3366 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003367- (void)setFloat:(float)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003368
Sergio Campamá32fadc02016-08-08 07:15:02 -07003369/**
3370 * Removes the entry for the given key.
3371 *
3372 * @param aKey Key to be removed from this dictionary.
3373 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003374- (void)removeFloatForKey:(int64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003375
3376/**
3377 * Removes all entries in this dictionary.
3378 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003379- (void)removeAll;
3380
3381@end
3382
3383#pragma mark - Int64 -> Double
3384
Sergio Campamá32fadc02016-08-08 07:15:02 -07003385/**
3386 * Class used for map fields of <int64_t, double>
3387 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3388 *
3389 * @note This class is not meant to be subclassed.
3390 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003391@interface GPBInt64DoubleDictionary : NSObject <NSCopying>
3392
Sergio Campamá32fadc02016-08-08 07:15:02 -07003393/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003394@property(nonatomic, readonly) NSUInteger count;
3395
Sergio Campamá32fadc02016-08-08 07:15:02 -07003396/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07003397 * Initializes this dictionary, copying the given values and keys.
3398 *
3399 * @param values The values to be placed in this dictionary.
3400 * @param keys The keys under which to store the values.
3401 * @param count The number of elements to copy into the dictionary.
3402 *
3403 * @return A newly initialized dictionary with a copy of the values and keys.
3404 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05003405- (instancetype)initWithDoubles:(const double [__nullable])values
3406 forKeys:(const int64_t [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003407 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003408
3409/**
3410 * Initializes this dictionary, copying the entries from the given dictionary.
3411 *
3412 * @param dictionary Dictionary containing the entries to add to this dictionary.
3413 *
3414 * @return A newly initialized dictionary with the entries of the given dictionary.
3415 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003416- (instancetype)initWithDictionary:(GPBInt64DoubleDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003417
3418/**
3419 * Initializes this dictionary with the requested capacity.
3420 *
3421 * @param numItems Number of items needed for this dictionary.
3422 *
3423 * @return A newly initialized dictionary with the requested capacity.
3424 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003425- (instancetype)initWithCapacity:(NSUInteger)numItems;
3426
Sergio Campamá32fadc02016-08-08 07:15:02 -07003427/**
3428 * Gets the value for the given key.
3429 *
3430 * @param value Pointer into which the value will be set, if found.
3431 * @param key Key under which the value is stored, if present.
3432 *
3433 * @return YES if the key was found and the value was copied, NO otherwise.
3434 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003435- (BOOL)getDouble:(nullable double *)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003436
Sergio Campamá32fadc02016-08-08 07:15:02 -07003437/**
3438 * Enumerates the keys and values on this dictionary with the given block.
3439 *
3440 * @param block The block to enumerate with.
3441 * **key**: The key for the current entry.
3442 * **value**: The value for the current entry
3443 * **stop**: A pointer to a boolean that when set stops the enumeration.
3444 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003445- (void)enumerateKeysAndDoublesUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05003446 (void (NS_NOESCAPE ^)(int64_t key, double value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003447
Sergio Campamá32fadc02016-08-08 07:15:02 -07003448/**
3449 * Adds the keys and values from another dictionary.
3450 *
3451 * @param otherDictionary Dictionary containing entries to be added to this
3452 * dictionary.
3453 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003454- (void)addEntriesFromDictionary:(GPBInt64DoubleDictionary *)otherDictionary;
3455
Sergio Campamá32fadc02016-08-08 07:15:02 -07003456/**
3457 * Sets the value for the given key.
3458 *
3459 * @param value The value to set.
3460 * @param key The key under which to store the value.
3461 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003462- (void)setDouble:(double)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003463
Sergio Campamá32fadc02016-08-08 07:15:02 -07003464/**
3465 * Removes the entry for the given key.
3466 *
3467 * @param aKey Key to be removed from this dictionary.
3468 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003469- (void)removeDoubleForKey:(int64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003470
3471/**
3472 * Removes all entries in this dictionary.
3473 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003474- (void)removeAll;
3475
3476@end
3477
3478#pragma mark - Int64 -> Enum
3479
Sergio Campamá32fadc02016-08-08 07:15:02 -07003480/**
3481 * Class used for map fields of <int64_t, int32_t>
3482 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3483 *
3484 * @note This class is not meant to be subclassed.
3485 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003486@interface GPBInt64EnumDictionary : NSObject <NSCopying>
3487
Sergio Campamá32fadc02016-08-08 07:15:02 -07003488/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003489@property(nonatomic, readonly) NSUInteger count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003490/** The validation function to check if the enums are valid. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003491@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
3492
Sergio Campamá32fadc02016-08-08 07:15:02 -07003493/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07003494 * Initializes a dictionary with the given validation function.
3495 *
3496 * @param func The enum validation function for the dictionary.
3497 *
3498 * @return A newly initialized dictionary.
3499 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04003500- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003501
3502/**
3503 * Initializes a dictionary with the entries given.
3504 *
3505 * @param func The enum validation function for the dictionary.
3506 * @param values The raw enum values values to be placed in the dictionary.
3507 * @param keys The keys under which to store the values.
3508 * @param count The number of entries to store in the dictionary.
3509 *
3510 * @return A newly initialized dictionary with the keys and values in it.
3511 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04003512- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Sergio Campama3d7b42d2017-01-25 11:51:54 -05003513 rawValues:(const int32_t [__nullable])values
3514 forKeys:(const int64_t [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003515 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003516
3517/**
3518 * Initializes a dictionary with the entries from the given.
3519 * dictionary.
3520 *
3521 * @param dictionary Dictionary containing the entries to add to the dictionary.
3522 *
3523 * @return A newly initialized dictionary with the entries from the given
3524 * dictionary in it.
3525 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003526- (instancetype)initWithDictionary:(GPBInt64EnumDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003527
3528/**
3529 * Initializes a dictionary with the given capacity.
3530 *
3531 * @param func The enum validation function for the dictionary.
3532 * @param numItems Capacity needed for the dictionary.
3533 *
3534 * @return A newly initialized dictionary with the given capacity.
3535 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04003536- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003537 capacity:(NSUInteger)numItems;
3538
3539// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
3540// is not a valid enumerator as defined by validationFunc. If the actual value is
3541// desired, use "raw" version of the method.
3542
Sergio Campamá32fadc02016-08-08 07:15:02 -07003543/**
3544 * Gets the value for the given key.
3545 *
3546 * @param value Pointer into which the value will be set, if found.
3547 * @param key Key under which the value is stored, if present.
3548 *
3549 * @return YES if the key was found and the value was copied, NO otherwise.
3550 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003551- (BOOL)getEnum:(nullable int32_t *)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003552
Sergio Campamá32fadc02016-08-08 07:15:02 -07003553/**
3554 * Enumerates the keys and values on this dictionary with the given block.
3555 *
3556 * @param block The block to enumerate with.
3557 * **key**: The key for the current entry.
3558 * **value**: The value for the current entry
3559 * **stop**: A pointer to a boolean that when set stops the enumeration.
3560 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003561- (void)enumerateKeysAndEnumsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05003562 (void (NS_NOESCAPE ^)(int64_t key, int32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003563
Sergio Campamá32fadc02016-08-08 07:15:02 -07003564/**
3565 * Gets the raw enum value for the given key.
3566 *
3567 * @note This method bypass the validationFunc to enable the access of values that
3568 * were not known at the time the binary was compiled.
3569 *
3570 * @param rawValue Pointer into which the value will be set, if found.
3571 * @param key Key under which the value is stored, if present.
3572 *
3573 * @return YES if the key was found and the value was copied, NO otherwise.
3574 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003575- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003576
Sergio Campamá32fadc02016-08-08 07:15:02 -07003577/**
3578 * Enumerates the keys and values on this dictionary with the given block.
3579 *
3580 * @note This method bypass the validationFunc to enable the access of values that
3581 * were not known at the time the binary was compiled.
3582 *
3583 * @param block The block to enumerate with.
3584 * **key**: The key for the current entry.
3585 * **rawValue**: The value for the current entry
3586 * **stop**: A pointer to a boolean that when set stops the enumeration.
3587 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003588- (void)enumerateKeysAndRawValuesUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05003589 (void (NS_NOESCAPE ^)(int64_t key, int32_t rawValue, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003590
Sergio Campamá32fadc02016-08-08 07:15:02 -07003591/**
3592 * Adds the keys and raw enum values from another dictionary.
3593 *
3594 * @note This method bypass the validationFunc to enable the setting of values that
3595 * were not known at the time the binary was compiled.
3596 *
3597 * @param otherDictionary Dictionary containing entries to be added to this
3598 * dictionary.
3599 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003600- (void)addRawEntriesFromDictionary:(GPBInt64EnumDictionary *)otherDictionary;
3601
3602// If value is not a valid enumerator as defined by validationFunc, these
3603// methods will assert in debug, and will log in release and assign the value
3604// to the default value. Use the rawValue methods below to assign non enumerator
3605// values.
3606
Sergio Campamá32fadc02016-08-08 07:15:02 -07003607/**
3608 * Sets the value for the given key.
3609 *
3610 * @param value The value to set.
3611 * @param key The key under which to store the value.
3612 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003613- (void)setEnum:(int32_t)value forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003614
Sergio Campamá32fadc02016-08-08 07:15:02 -07003615/**
3616 * Sets the raw enum value for the given key.
3617 *
3618 * @note This method bypass the validationFunc to enable the setting of values that
3619 * were not known at the time the binary was compiled.
3620 *
3621 * @param rawValue The raw enum value to set.
3622 * @param key The key under which to store the raw enum value.
3623 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003624- (void)setRawValue:(int32_t)rawValue forKey:(int64_t)key;
3625
Sergio Campamá32fadc02016-08-08 07:15:02 -07003626/**
3627 * Removes the entry for the given key.
3628 *
3629 * @param aKey Key to be removed from this dictionary.
3630 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003631- (void)removeEnumForKey:(int64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003632
3633/**
3634 * Removes all entries in this dictionary.
3635 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003636- (void)removeAll;
3637
3638@end
3639
3640#pragma mark - Int64 -> Object
3641
Sergio Campamá32fadc02016-08-08 07:15:02 -07003642/**
3643 * Class used for map fields of <int64_t, ObjectType>
3644 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3645 *
3646 * @note This class is not meant to be subclassed.
3647 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05003648@interface GPBInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003649
Sergio Campamá32fadc02016-08-08 07:15:02 -07003650/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003651@property(nonatomic, readonly) NSUInteger count;
3652
Sergio Campamá32fadc02016-08-08 07:15:02 -07003653/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07003654 * Initializes this dictionary, copying the given values and keys.
3655 *
3656 * @param objects The values to be placed in this dictionary.
3657 * @param keys The keys under which to store the values.
3658 * @param count The number of elements to copy into the dictionary.
3659 *
3660 * @return A newly initialized dictionary with a copy of the values and keys.
3661 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05003662- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
3663 forKeys:(const int64_t [__nullable])keys
Thomas Van Lenten1383d532015-09-29 11:41:53 -04003664 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003665
3666/**
3667 * Initializes this dictionary, copying the entries from the given dictionary.
3668 *
3669 * @param dictionary Dictionary containing the entries to add to this dictionary.
3670 *
3671 * @return A newly initialized dictionary with the entries of the given dictionary.
3672 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003673- (instancetype)initWithDictionary:(GPBInt64ObjectDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003674
3675/**
3676 * Initializes this dictionary with the requested capacity.
3677 *
3678 * @param numItems Number of items needed for this dictionary.
3679 *
3680 * @return A newly initialized dictionary with the requested capacity.
3681 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003682- (instancetype)initWithCapacity:(NSUInteger)numItems;
3683
Sergio Campamá32fadc02016-08-08 07:15:02 -07003684/**
3685 * Fetches the object stored under the given key.
3686 *
3687 * @param key Key under which the value is stored, if present.
3688 *
3689 * @return The object if found, nil otherwise.
3690 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05003691- (ObjectType)objectForKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003692
Sergio Campamá32fadc02016-08-08 07:15:02 -07003693/**
3694 * Enumerates the keys and values on this dictionary with the given block.
3695 *
3696 * @param block The block to enumerate with.
3697 * **key**: The key for the current entry.
3698 * **object**: The value for the current entry
3699 * **stop**: A pointer to a boolean that when set stops the enumeration.
3700 **/
Thomas Van Lenten1383d532015-09-29 11:41:53 -04003701- (void)enumerateKeysAndObjectsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05003702 (void (NS_NOESCAPE ^)(int64_t key, ObjectType object, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003703
Sergio Campamá32fadc02016-08-08 07:15:02 -07003704/**
3705 * Adds the keys and values from another dictionary.
3706 *
3707 * @param otherDictionary Dictionary containing entries to be added to this
3708 * dictionary.
3709 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003710- (void)addEntriesFromDictionary:(GPBInt64ObjectDictionary *)otherDictionary;
3711
Sergio Campamá32fadc02016-08-08 07:15:02 -07003712/**
3713 * Sets the value for the given key.
3714 *
3715 * @param object The value to set.
3716 * @param key The key under which to store the value.
3717 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05003718- (void)setObject:(ObjectType)object forKey:(int64_t)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003719
Sergio Campamá32fadc02016-08-08 07:15:02 -07003720/**
3721 * Removes the entry for the given key.
3722 *
3723 * @param aKey Key to be removed from this dictionary.
3724 **/
Thomas Van Lenten1383d532015-09-29 11:41:53 -04003725- (void)removeObjectForKey:(int64_t)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003726
3727/**
3728 * Removes all entries in this dictionary.
3729 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003730- (void)removeAll;
3731
3732@end
3733
3734#pragma mark - Bool -> UInt32
3735
Sergio Campamá32fadc02016-08-08 07:15:02 -07003736/**
3737 * Class used for map fields of <BOOL, uint32_t>
3738 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3739 *
3740 * @note This class is not meant to be subclassed.
3741 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003742@interface GPBBoolUInt32Dictionary : NSObject <NSCopying>
3743
Sergio Campamá32fadc02016-08-08 07:15:02 -07003744/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003745@property(nonatomic, readonly) NSUInteger count;
3746
Sergio Campamá32fadc02016-08-08 07:15:02 -07003747/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07003748 * Initializes this dictionary, copying the given values and keys.
3749 *
3750 * @param values The values to be placed in this dictionary.
3751 * @param keys The keys under which to store the values.
3752 * @param count The number of elements to copy into the dictionary.
3753 *
3754 * @return A newly initialized dictionary with a copy of the values and keys.
3755 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05003756- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
3757 forKeys:(const BOOL [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003758 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003759
3760/**
3761 * Initializes this dictionary, copying the entries from the given dictionary.
3762 *
3763 * @param dictionary Dictionary containing the entries to add to this dictionary.
3764 *
3765 * @return A newly initialized dictionary with the entries of the given dictionary.
3766 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003767- (instancetype)initWithDictionary:(GPBBoolUInt32Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003768
3769/**
3770 * Initializes this dictionary with the requested capacity.
3771 *
3772 * @param numItems Number of items needed for this dictionary.
3773 *
3774 * @return A newly initialized dictionary with the requested capacity.
3775 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003776- (instancetype)initWithCapacity:(NSUInteger)numItems;
3777
Sergio Campamá32fadc02016-08-08 07:15:02 -07003778/**
3779 * Gets the value for the given key.
3780 *
3781 * @param value Pointer into which the value will be set, if found.
3782 * @param key Key under which the value is stored, if present.
3783 *
3784 * @return YES if the key was found and the value was copied, NO otherwise.
3785 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003786- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003787
Sergio Campamá32fadc02016-08-08 07:15:02 -07003788/**
3789 * Enumerates the keys and values on this dictionary with the given block.
3790 *
3791 * @param block The block to enumerate with.
3792 * **key**: The key for the current entry.
3793 * **value**: The value for the current entry
3794 * **stop**: A pointer to a boolean that when set stops the enumeration.
3795 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003796- (void)enumerateKeysAndUInt32sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05003797 (void (NS_NOESCAPE ^)(BOOL key, uint32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003798
Sergio Campamá32fadc02016-08-08 07:15:02 -07003799/**
3800 * Adds the keys and values from another dictionary.
3801 *
3802 * @param otherDictionary Dictionary containing entries to be added to this
3803 * dictionary.
3804 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003805- (void)addEntriesFromDictionary:(GPBBoolUInt32Dictionary *)otherDictionary;
3806
Sergio Campamá32fadc02016-08-08 07:15:02 -07003807/**
3808 * Sets the value for the given key.
3809 *
3810 * @param value The value to set.
3811 * @param key The key under which to store the value.
3812 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003813- (void)setUInt32:(uint32_t)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003814
Sergio Campamá32fadc02016-08-08 07:15:02 -07003815/**
3816 * Removes the entry for the given key.
3817 *
3818 * @param aKey Key to be removed from this dictionary.
3819 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003820- (void)removeUInt32ForKey:(BOOL)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003821
3822/**
3823 * Removes all entries in this dictionary.
3824 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003825- (void)removeAll;
3826
3827@end
3828
3829#pragma mark - Bool -> Int32
3830
Sergio Campamá32fadc02016-08-08 07:15:02 -07003831/**
3832 * Class used for map fields of <BOOL, int32_t>
3833 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3834 *
3835 * @note This class is not meant to be subclassed.
3836 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003837@interface GPBBoolInt32Dictionary : NSObject <NSCopying>
3838
Sergio Campamá32fadc02016-08-08 07:15:02 -07003839/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003840@property(nonatomic, readonly) NSUInteger count;
3841
Sergio Campamá32fadc02016-08-08 07:15:02 -07003842/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07003843 * Initializes this dictionary, copying the given values and keys.
3844 *
3845 * @param values The values to be placed in this dictionary.
3846 * @param keys The keys under which to store the values.
3847 * @param count The number of elements to copy into the dictionary.
3848 *
3849 * @return A newly initialized dictionary with a copy of the values and keys.
3850 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05003851- (instancetype)initWithInt32s:(const int32_t [__nullable])values
3852 forKeys:(const BOOL [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003853 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003854
3855/**
3856 * Initializes this dictionary, copying the entries from the given dictionary.
3857 *
3858 * @param dictionary Dictionary containing the entries to add to this dictionary.
3859 *
3860 * @return A newly initialized dictionary with the entries of the given dictionary.
3861 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003862- (instancetype)initWithDictionary:(GPBBoolInt32Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003863
3864/**
3865 * Initializes this dictionary with the requested capacity.
3866 *
3867 * @param numItems Number of items needed for this dictionary.
3868 *
3869 * @return A newly initialized dictionary with the requested capacity.
3870 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003871- (instancetype)initWithCapacity:(NSUInteger)numItems;
3872
Sergio Campamá32fadc02016-08-08 07:15:02 -07003873/**
3874 * Gets the value for the given key.
3875 *
3876 * @param value Pointer into which the value will be set, if found.
3877 * @param key Key under which the value is stored, if present.
3878 *
3879 * @return YES if the key was found and the value was copied, NO otherwise.
3880 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003881- (BOOL)getInt32:(nullable int32_t *)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003882
Sergio Campamá32fadc02016-08-08 07:15:02 -07003883/**
3884 * Enumerates the keys and values on this dictionary with the given block.
3885 *
3886 * @param block The block to enumerate with.
3887 * **key**: The key for the current entry.
3888 * **value**: The value for the current entry
3889 * **stop**: A pointer to a boolean that when set stops the enumeration.
3890 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003891- (void)enumerateKeysAndInt32sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05003892 (void (NS_NOESCAPE ^)(BOOL key, int32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003893
Sergio Campamá32fadc02016-08-08 07:15:02 -07003894/**
3895 * Adds the keys and values from another dictionary.
3896 *
3897 * @param otherDictionary Dictionary containing entries to be added to this
3898 * dictionary.
3899 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003900- (void)addEntriesFromDictionary:(GPBBoolInt32Dictionary *)otherDictionary;
3901
Sergio Campamá32fadc02016-08-08 07:15:02 -07003902/**
3903 * Sets the value for the given key.
3904 *
3905 * @param value The value to set.
3906 * @param key The key under which to store the value.
3907 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003908- (void)setInt32:(int32_t)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003909
Sergio Campamá32fadc02016-08-08 07:15:02 -07003910/**
3911 * Removes the entry for the given key.
3912 *
3913 * @param aKey Key to be removed from this dictionary.
3914 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003915- (void)removeInt32ForKey:(BOOL)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003916
3917/**
3918 * Removes all entries in this dictionary.
3919 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003920- (void)removeAll;
3921
3922@end
3923
3924#pragma mark - Bool -> UInt64
3925
Sergio Campamá32fadc02016-08-08 07:15:02 -07003926/**
3927 * Class used for map fields of <BOOL, uint64_t>
3928 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3929 *
3930 * @note This class is not meant to be subclassed.
3931 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003932@interface GPBBoolUInt64Dictionary : NSObject <NSCopying>
3933
Sergio Campamá32fadc02016-08-08 07:15:02 -07003934/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003935@property(nonatomic, readonly) NSUInteger count;
3936
Sergio Campamá32fadc02016-08-08 07:15:02 -07003937/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07003938 * Initializes this dictionary, copying the given values and keys.
3939 *
3940 * @param values The values to be placed in this dictionary.
3941 * @param keys The keys under which to store the values.
3942 * @param count The number of elements to copy into the dictionary.
3943 *
3944 * @return A newly initialized dictionary with a copy of the values and keys.
3945 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05003946- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
3947 forKeys:(const BOOL [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003948 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003949
3950/**
3951 * Initializes this dictionary, copying the entries from the given dictionary.
3952 *
3953 * @param dictionary Dictionary containing the entries to add to this dictionary.
3954 *
3955 * @return A newly initialized dictionary with the entries of the given dictionary.
3956 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003957- (instancetype)initWithDictionary:(GPBBoolUInt64Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07003958
3959/**
3960 * Initializes this dictionary with the requested capacity.
3961 *
3962 * @param numItems Number of items needed for this dictionary.
3963 *
3964 * @return A newly initialized dictionary with the requested capacity.
3965 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003966- (instancetype)initWithCapacity:(NSUInteger)numItems;
3967
Sergio Campamá32fadc02016-08-08 07:15:02 -07003968/**
3969 * Gets the value for the given key.
3970 *
3971 * @param value Pointer into which the value will be set, if found.
3972 * @param key Key under which the value is stored, if present.
3973 *
3974 * @return YES if the key was found and the value was copied, NO otherwise.
3975 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003976- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003977
Sergio Campamá32fadc02016-08-08 07:15:02 -07003978/**
3979 * Enumerates the keys and values on this dictionary with the given block.
3980 *
3981 * @param block The block to enumerate with.
3982 * **key**: The key for the current entry.
3983 * **value**: The value for the current entry
3984 * **stop**: A pointer to a boolean that when set stops the enumeration.
3985 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04003986- (void)enumerateKeysAndUInt64sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05003987 (void (NS_NOESCAPE ^)(BOOL key, uint64_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003988
Sergio Campamá32fadc02016-08-08 07:15:02 -07003989/**
3990 * Adds the keys and values from another dictionary.
3991 *
3992 * @param otherDictionary Dictionary containing entries to be added to this
3993 * dictionary.
3994 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04003995- (void)addEntriesFromDictionary:(GPBBoolUInt64Dictionary *)otherDictionary;
3996
Sergio Campamá32fadc02016-08-08 07:15:02 -07003997/**
3998 * Sets the value for the given key.
3999 *
4000 * @param value The value to set.
4001 * @param key The key under which to store the value.
4002 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004003- (void)setUInt64:(uint64_t)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004004
Sergio Campamá32fadc02016-08-08 07:15:02 -07004005/**
4006 * Removes the entry for the given key.
4007 *
4008 * @param aKey Key to be removed from this dictionary.
4009 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004010- (void)removeUInt64ForKey:(BOOL)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004011
4012/**
4013 * Removes all entries in this dictionary.
4014 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004015- (void)removeAll;
4016
4017@end
4018
4019#pragma mark - Bool -> Int64
4020
Sergio Campamá32fadc02016-08-08 07:15:02 -07004021/**
4022 * Class used for map fields of <BOOL, int64_t>
4023 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4024 *
4025 * @note This class is not meant to be subclassed.
4026 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004027@interface GPBBoolInt64Dictionary : NSObject <NSCopying>
4028
Sergio Campamá32fadc02016-08-08 07:15:02 -07004029/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004030@property(nonatomic, readonly) NSUInteger count;
4031
Sergio Campamá32fadc02016-08-08 07:15:02 -07004032/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07004033 * Initializes this dictionary, copying the given values and keys.
4034 *
4035 * @param values The values to be placed in this dictionary.
4036 * @param keys The keys under which to store the values.
4037 * @param count The number of elements to copy into the dictionary.
4038 *
4039 * @return A newly initialized dictionary with a copy of the values and keys.
4040 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05004041- (instancetype)initWithInt64s:(const int64_t [__nullable])values
4042 forKeys:(const BOOL [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004043 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004044
4045/**
4046 * Initializes this dictionary, copying the entries from the given dictionary.
4047 *
4048 * @param dictionary Dictionary containing the entries to add to this dictionary.
4049 *
4050 * @return A newly initialized dictionary with the entries of the given dictionary.
4051 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004052- (instancetype)initWithDictionary:(GPBBoolInt64Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004053
4054/**
4055 * Initializes this dictionary with the requested capacity.
4056 *
4057 * @param numItems Number of items needed for this dictionary.
4058 *
4059 * @return A newly initialized dictionary with the requested capacity.
4060 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004061- (instancetype)initWithCapacity:(NSUInteger)numItems;
4062
Sergio Campamá32fadc02016-08-08 07:15:02 -07004063/**
4064 * Gets the value for the given key.
4065 *
4066 * @param value Pointer into which the value will be set, if found.
4067 * @param key Key under which the value is stored, if present.
4068 *
4069 * @return YES if the key was found and the value was copied, NO otherwise.
4070 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004071- (BOOL)getInt64:(nullable int64_t *)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004072
Sergio Campamá32fadc02016-08-08 07:15:02 -07004073/**
4074 * Enumerates the keys and values on this dictionary with the given block.
4075 *
4076 * @param block The block to enumerate with.
4077 * **key**: The key for the current entry.
4078 * **value**: The value for the current entry
4079 * **stop**: A pointer to a boolean that when set stops the enumeration.
4080 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004081- (void)enumerateKeysAndInt64sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05004082 (void (NS_NOESCAPE ^)(BOOL key, int64_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004083
Sergio Campamá32fadc02016-08-08 07:15:02 -07004084/**
4085 * Adds the keys and values from another dictionary.
4086 *
4087 * @param otherDictionary Dictionary containing entries to be added to this
4088 * dictionary.
4089 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004090- (void)addEntriesFromDictionary:(GPBBoolInt64Dictionary *)otherDictionary;
4091
Sergio Campamá32fadc02016-08-08 07:15:02 -07004092/**
4093 * Sets the value for the given key.
4094 *
4095 * @param value The value to set.
4096 * @param key The key under which to store the value.
4097 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004098- (void)setInt64:(int64_t)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004099
Sergio Campamá32fadc02016-08-08 07:15:02 -07004100/**
4101 * Removes the entry for the given key.
4102 *
4103 * @param aKey Key to be removed from this dictionary.
4104 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004105- (void)removeInt64ForKey:(BOOL)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004106
4107/**
4108 * Removes all entries in this dictionary.
4109 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004110- (void)removeAll;
4111
4112@end
4113
4114#pragma mark - Bool -> Bool
4115
Sergio Campamá32fadc02016-08-08 07:15:02 -07004116/**
4117 * Class used for map fields of <BOOL, BOOL>
4118 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4119 *
4120 * @note This class is not meant to be subclassed.
4121 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004122@interface GPBBoolBoolDictionary : NSObject <NSCopying>
4123
Sergio Campamá32fadc02016-08-08 07:15:02 -07004124/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004125@property(nonatomic, readonly) NSUInteger count;
4126
Sergio Campamá32fadc02016-08-08 07:15:02 -07004127/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07004128 * Initializes this dictionary, copying the given values and keys.
4129 *
4130 * @param values The values to be placed in this dictionary.
4131 * @param keys The keys under which to store the values.
4132 * @param count The number of elements to copy into the dictionary.
4133 *
4134 * @return A newly initialized dictionary with a copy of the values and keys.
4135 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05004136- (instancetype)initWithBools:(const BOOL [__nullable])values
4137 forKeys:(const BOOL [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004138 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004139
4140/**
4141 * Initializes this dictionary, copying the entries from the given dictionary.
4142 *
4143 * @param dictionary Dictionary containing the entries to add to this dictionary.
4144 *
4145 * @return A newly initialized dictionary with the entries of the given dictionary.
4146 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004147- (instancetype)initWithDictionary:(GPBBoolBoolDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004148
4149/**
4150 * Initializes this dictionary with the requested capacity.
4151 *
4152 * @param numItems Number of items needed for this dictionary.
4153 *
4154 * @return A newly initialized dictionary with the requested capacity.
4155 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004156- (instancetype)initWithCapacity:(NSUInteger)numItems;
4157
Sergio Campamá32fadc02016-08-08 07:15:02 -07004158/**
4159 * Gets the value for the given key.
4160 *
4161 * @param value Pointer into which the value will be set, if found.
4162 * @param key Key under which the value is stored, if present.
4163 *
4164 * @return YES if the key was found and the value was copied, NO otherwise.
4165 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004166- (BOOL)getBool:(nullable BOOL *)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004167
Sergio Campamá32fadc02016-08-08 07:15:02 -07004168/**
4169 * Enumerates the keys and values on this dictionary with the given block.
4170 *
4171 * @param block The block to enumerate with.
4172 * **key**: The key for the current entry.
4173 * **value**: The value for the current entry
4174 * **stop**: A pointer to a boolean that when set stops the enumeration.
4175 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004176- (void)enumerateKeysAndBoolsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05004177 (void (NS_NOESCAPE ^)(BOOL key, BOOL value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004178
Sergio Campamá32fadc02016-08-08 07:15:02 -07004179/**
4180 * Adds the keys and values from another dictionary.
4181 *
4182 * @param otherDictionary Dictionary containing entries to be added to this
4183 * dictionary.
4184 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004185- (void)addEntriesFromDictionary:(GPBBoolBoolDictionary *)otherDictionary;
4186
Sergio Campamá32fadc02016-08-08 07:15:02 -07004187/**
4188 * Sets the value for the given key.
4189 *
4190 * @param value The value to set.
4191 * @param key The key under which to store the value.
4192 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004193- (void)setBool:(BOOL)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004194
Sergio Campamá32fadc02016-08-08 07:15:02 -07004195/**
4196 * Removes the entry for the given key.
4197 *
4198 * @param aKey Key to be removed from this dictionary.
4199 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004200- (void)removeBoolForKey:(BOOL)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004201
4202/**
4203 * Removes all entries in this dictionary.
4204 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004205- (void)removeAll;
4206
4207@end
4208
4209#pragma mark - Bool -> Float
4210
Sergio Campamá32fadc02016-08-08 07:15:02 -07004211/**
4212 * Class used for map fields of <BOOL, float>
4213 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4214 *
4215 * @note This class is not meant to be subclassed.
4216 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004217@interface GPBBoolFloatDictionary : NSObject <NSCopying>
4218
Sergio Campamá32fadc02016-08-08 07:15:02 -07004219/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004220@property(nonatomic, readonly) NSUInteger count;
4221
Sergio Campamá32fadc02016-08-08 07:15:02 -07004222/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07004223 * Initializes this dictionary, copying the given values and keys.
4224 *
4225 * @param values The values to be placed in this dictionary.
4226 * @param keys The keys under which to store the values.
4227 * @param count The number of elements to copy into the dictionary.
4228 *
4229 * @return A newly initialized dictionary with a copy of the values and keys.
4230 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05004231- (instancetype)initWithFloats:(const float [__nullable])values
4232 forKeys:(const BOOL [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004233 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004234
4235/**
4236 * Initializes this dictionary, copying the entries from the given dictionary.
4237 *
4238 * @param dictionary Dictionary containing the entries to add to this dictionary.
4239 *
4240 * @return A newly initialized dictionary with the entries of the given dictionary.
4241 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004242- (instancetype)initWithDictionary:(GPBBoolFloatDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004243
4244/**
4245 * Initializes this dictionary with the requested capacity.
4246 *
4247 * @param numItems Number of items needed for this dictionary.
4248 *
4249 * @return A newly initialized dictionary with the requested capacity.
4250 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004251- (instancetype)initWithCapacity:(NSUInteger)numItems;
4252
Sergio Campamá32fadc02016-08-08 07:15:02 -07004253/**
4254 * Gets the value for the given key.
4255 *
4256 * @param value Pointer into which the value will be set, if found.
4257 * @param key Key under which the value is stored, if present.
4258 *
4259 * @return YES if the key was found and the value was copied, NO otherwise.
4260 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004261- (BOOL)getFloat:(nullable float *)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004262
Sergio Campamá32fadc02016-08-08 07:15:02 -07004263/**
4264 * Enumerates the keys and values on this dictionary with the given block.
4265 *
4266 * @param block The block to enumerate with.
4267 * **key**: The key for the current entry.
4268 * **value**: The value for the current entry
4269 * **stop**: A pointer to a boolean that when set stops the enumeration.
4270 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004271- (void)enumerateKeysAndFloatsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05004272 (void (NS_NOESCAPE ^)(BOOL key, float value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004273
Sergio Campamá32fadc02016-08-08 07:15:02 -07004274/**
4275 * Adds the keys and values from another dictionary.
4276 *
4277 * @param otherDictionary Dictionary containing entries to be added to this
4278 * dictionary.
4279 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004280- (void)addEntriesFromDictionary:(GPBBoolFloatDictionary *)otherDictionary;
4281
Sergio Campamá32fadc02016-08-08 07:15:02 -07004282/**
4283 * Sets the value for the given key.
4284 *
4285 * @param value The value to set.
4286 * @param key The key under which to store the value.
4287 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004288- (void)setFloat:(float)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004289
Sergio Campamá32fadc02016-08-08 07:15:02 -07004290/**
4291 * Removes the entry for the given key.
4292 *
4293 * @param aKey Key to be removed from this dictionary.
4294 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004295- (void)removeFloatForKey:(BOOL)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004296
4297/**
4298 * Removes all entries in this dictionary.
4299 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004300- (void)removeAll;
4301
4302@end
4303
4304#pragma mark - Bool -> Double
4305
Sergio Campamá32fadc02016-08-08 07:15:02 -07004306/**
4307 * Class used for map fields of <BOOL, double>
4308 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4309 *
4310 * @note This class is not meant to be subclassed.
4311 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004312@interface GPBBoolDoubleDictionary : NSObject <NSCopying>
4313
Sergio Campamá32fadc02016-08-08 07:15:02 -07004314/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004315@property(nonatomic, readonly) NSUInteger count;
4316
Sergio Campamá32fadc02016-08-08 07:15:02 -07004317/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07004318 * Initializes this dictionary, copying the given values and keys.
4319 *
4320 * @param values The values to be placed in this dictionary.
4321 * @param keys The keys under which to store the values.
4322 * @param count The number of elements to copy into the dictionary.
4323 *
4324 * @return A newly initialized dictionary with a copy of the values and keys.
4325 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05004326- (instancetype)initWithDoubles:(const double [__nullable])values
4327 forKeys:(const BOOL [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004328 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004329
4330/**
4331 * Initializes this dictionary, copying the entries from the given dictionary.
4332 *
4333 * @param dictionary Dictionary containing the entries to add to this dictionary.
4334 *
4335 * @return A newly initialized dictionary with the entries of the given dictionary.
4336 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004337- (instancetype)initWithDictionary:(GPBBoolDoubleDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004338
4339/**
4340 * Initializes this dictionary with the requested capacity.
4341 *
4342 * @param numItems Number of items needed for this dictionary.
4343 *
4344 * @return A newly initialized dictionary with the requested capacity.
4345 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004346- (instancetype)initWithCapacity:(NSUInteger)numItems;
4347
Sergio Campamá32fadc02016-08-08 07:15:02 -07004348/**
4349 * Gets the value for the given key.
4350 *
4351 * @param value Pointer into which the value will be set, if found.
4352 * @param key Key under which the value is stored, if present.
4353 *
4354 * @return YES if the key was found and the value was copied, NO otherwise.
4355 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004356- (BOOL)getDouble:(nullable double *)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004357
Sergio Campamá32fadc02016-08-08 07:15:02 -07004358/**
4359 * Enumerates the keys and values on this dictionary with the given block.
4360 *
4361 * @param block The block to enumerate with.
4362 * **key**: The key for the current entry.
4363 * **value**: The value for the current entry
4364 * **stop**: A pointer to a boolean that when set stops the enumeration.
4365 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004366- (void)enumerateKeysAndDoublesUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05004367 (void (NS_NOESCAPE ^)(BOOL key, double value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004368
Sergio Campamá32fadc02016-08-08 07:15:02 -07004369/**
4370 * Adds the keys and values from another dictionary.
4371 *
4372 * @param otherDictionary Dictionary containing entries to be added to this
4373 * dictionary.
4374 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004375- (void)addEntriesFromDictionary:(GPBBoolDoubleDictionary *)otherDictionary;
4376
Sergio Campamá32fadc02016-08-08 07:15:02 -07004377/**
4378 * Sets the value for the given key.
4379 *
4380 * @param value The value to set.
4381 * @param key The key under which to store the value.
4382 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004383- (void)setDouble:(double)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004384
Sergio Campamá32fadc02016-08-08 07:15:02 -07004385/**
4386 * Removes the entry for the given key.
4387 *
4388 * @param aKey Key to be removed from this dictionary.
4389 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004390- (void)removeDoubleForKey:(BOOL)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004391
4392/**
4393 * Removes all entries in this dictionary.
4394 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004395- (void)removeAll;
4396
4397@end
4398
4399#pragma mark - Bool -> Enum
4400
Sergio Campamá32fadc02016-08-08 07:15:02 -07004401/**
4402 * Class used for map fields of <BOOL, int32_t>
4403 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4404 *
4405 * @note This class is not meant to be subclassed.
4406 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004407@interface GPBBoolEnumDictionary : NSObject <NSCopying>
4408
Sergio Campamá32fadc02016-08-08 07:15:02 -07004409/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004410@property(nonatomic, readonly) NSUInteger count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004411/** The validation function to check if the enums are valid. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004412@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
4413
Sergio Campamá32fadc02016-08-08 07:15:02 -07004414/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07004415 * Initializes a dictionary with the given validation function.
4416 *
4417 * @param func The enum validation function for the dictionary.
4418 *
4419 * @return A newly initialized dictionary.
4420 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04004421- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004422
4423/**
4424 * Initializes a dictionary with the entries given.
4425 *
4426 * @param func The enum validation function for the dictionary.
4427 * @param values The raw enum values values to be placed in the dictionary.
4428 * @param keys The keys under which to store the values.
4429 * @param count The number of entries to store in the dictionary.
4430 *
4431 * @return A newly initialized dictionary with the keys and values in it.
4432 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04004433- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Sergio Campama3d7b42d2017-01-25 11:51:54 -05004434 rawValues:(const int32_t [__nullable])values
4435 forKeys:(const BOOL [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004436 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004437
4438/**
4439 * Initializes a dictionary with the entries from the given.
4440 * dictionary.
4441 *
4442 * @param dictionary Dictionary containing the entries to add to the dictionary.
4443 *
4444 * @return A newly initialized dictionary with the entries from the given
4445 * dictionary in it.
4446 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004447- (instancetype)initWithDictionary:(GPBBoolEnumDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004448
4449/**
4450 * Initializes a dictionary with the given capacity.
4451 *
4452 * @param func The enum validation function for the dictionary.
4453 * @param numItems Capacity needed for the dictionary.
4454 *
4455 * @return A newly initialized dictionary with the given capacity.
4456 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04004457- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004458 capacity:(NSUInteger)numItems;
4459
4460// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
4461// is not a valid enumerator as defined by validationFunc. If the actual value is
4462// desired, use "raw" version of the method.
4463
Sergio Campamá32fadc02016-08-08 07:15:02 -07004464/**
4465 * Gets the value for the given key.
4466 *
4467 * @param value Pointer into which the value will be set, if found.
4468 * @param key Key under which the value is stored, if present.
4469 *
4470 * @return YES if the key was found and the value was copied, NO otherwise.
4471 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004472- (BOOL)getEnum:(nullable int32_t *)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004473
Sergio Campamá32fadc02016-08-08 07:15:02 -07004474/**
4475 * Enumerates the keys and values on this dictionary with the given block.
4476 *
4477 * @param block The block to enumerate with.
4478 * **key**: The key for the current entry.
4479 * **value**: The value for the current entry
4480 * **stop**: A pointer to a boolean that when set stops the enumeration.
4481 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004482- (void)enumerateKeysAndEnumsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05004483 (void (NS_NOESCAPE ^)(BOOL key, int32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004484
Sergio Campamá32fadc02016-08-08 07:15:02 -07004485/**
4486 * Gets the raw enum value for the given key.
4487 *
4488 * @note This method bypass the validationFunc to enable the access of values that
4489 * were not known at the time the binary was compiled.
4490 *
4491 * @param rawValue Pointer into which the value will be set, if found.
4492 * @param key Key under which the value is stored, if present.
4493 *
4494 * @return YES if the key was found and the value was copied, NO otherwise.
4495 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004496- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004497
Sergio Campamá32fadc02016-08-08 07:15:02 -07004498/**
4499 * Enumerates the keys and values on this dictionary with the given block.
4500 *
4501 * @note This method bypass the validationFunc to enable the access of values that
4502 * were not known at the time the binary was compiled.
4503 *
4504 * @param block The block to enumerate with.
4505 * **key**: The key for the current entry.
4506 * **rawValue**: The value for the current entry
4507 * **stop**: A pointer to a boolean that when set stops the enumeration.
4508 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004509- (void)enumerateKeysAndRawValuesUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05004510 (void (NS_NOESCAPE ^)(BOOL key, int32_t rawValue, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004511
Sergio Campamá32fadc02016-08-08 07:15:02 -07004512/**
4513 * Adds the keys and raw enum values from another dictionary.
4514 *
4515 * @note This method bypass the validationFunc to enable the setting of values that
4516 * were not known at the time the binary was compiled.
4517 *
4518 * @param otherDictionary Dictionary containing entries to be added to this
4519 * dictionary.
4520 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004521- (void)addRawEntriesFromDictionary:(GPBBoolEnumDictionary *)otherDictionary;
4522
4523// If value is not a valid enumerator as defined by validationFunc, these
4524// methods will assert in debug, and will log in release and assign the value
4525// to the default value. Use the rawValue methods below to assign non enumerator
4526// values.
4527
Sergio Campamá32fadc02016-08-08 07:15:02 -07004528/**
4529 * Sets the value for the given key.
4530 *
4531 * @param value The value to set.
4532 * @param key The key under which to store the value.
4533 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004534- (void)setEnum:(int32_t)value forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004535
Sergio Campamá32fadc02016-08-08 07:15:02 -07004536/**
4537 * Sets the raw enum value for the given key.
4538 *
4539 * @note This method bypass the validationFunc to enable the setting of values that
4540 * were not known at the time the binary was compiled.
4541 *
4542 * @param rawValue The raw enum value to set.
4543 * @param key The key under which to store the raw enum value.
4544 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004545- (void)setRawValue:(int32_t)rawValue forKey:(BOOL)key;
4546
Sergio Campamá32fadc02016-08-08 07:15:02 -07004547/**
4548 * Removes the entry for the given key.
4549 *
4550 * @param aKey Key to be removed from this dictionary.
4551 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004552- (void)removeEnumForKey:(BOOL)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004553
4554/**
4555 * Removes all entries in this dictionary.
4556 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004557- (void)removeAll;
4558
4559@end
4560
4561#pragma mark - Bool -> Object
4562
Sergio Campamá32fadc02016-08-08 07:15:02 -07004563/**
4564 * Class used for map fields of <BOOL, ObjectType>
4565 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4566 *
4567 * @note This class is not meant to be subclassed.
4568 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05004569@interface GPBBoolObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004570
Sergio Campamá32fadc02016-08-08 07:15:02 -07004571/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004572@property(nonatomic, readonly) NSUInteger count;
4573
Sergio Campamá32fadc02016-08-08 07:15:02 -07004574/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07004575 * Initializes this dictionary, copying the given values and keys.
4576 *
4577 * @param objects The values to be placed in this dictionary.
4578 * @param keys The keys under which to store the values.
4579 * @param count The number of elements to copy into the dictionary.
4580 *
4581 * @return A newly initialized dictionary with a copy of the values and keys.
4582 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05004583- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
4584 forKeys:(const BOOL [__nullable])keys
Thomas Van Lenten1383d532015-09-29 11:41:53 -04004585 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004586
4587/**
4588 * Initializes this dictionary, copying the entries from the given dictionary.
4589 *
4590 * @param dictionary Dictionary containing the entries to add to this dictionary.
4591 *
4592 * @return A newly initialized dictionary with the entries of the given dictionary.
4593 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004594- (instancetype)initWithDictionary:(GPBBoolObjectDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004595
4596/**
4597 * Initializes this dictionary with the requested capacity.
4598 *
4599 * @param numItems Number of items needed for this dictionary.
4600 *
4601 * @return A newly initialized dictionary with the requested capacity.
4602 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004603- (instancetype)initWithCapacity:(NSUInteger)numItems;
4604
Sergio Campamá32fadc02016-08-08 07:15:02 -07004605/**
4606 * Fetches the object stored under the given key.
4607 *
4608 * @param key Key under which the value is stored, if present.
4609 *
4610 * @return The object if found, nil otherwise.
4611 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05004612- (ObjectType)objectForKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004613
Sergio Campamá32fadc02016-08-08 07:15:02 -07004614/**
4615 * Enumerates the keys and values on this dictionary with the given block.
4616 *
4617 * @param block The block to enumerate with.
4618 * **key**: The key for the current entry.
4619 * **object**: The value for the current entry
4620 * **stop**: A pointer to a boolean that when set stops the enumeration.
4621 **/
Thomas Van Lenten1383d532015-09-29 11:41:53 -04004622- (void)enumerateKeysAndObjectsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05004623 (void (NS_NOESCAPE ^)(BOOL key, ObjectType object, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004624
Sergio Campamá32fadc02016-08-08 07:15:02 -07004625/**
4626 * Adds the keys and values from another dictionary.
4627 *
4628 * @param otherDictionary Dictionary containing entries to be added to this
4629 * dictionary.
4630 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004631- (void)addEntriesFromDictionary:(GPBBoolObjectDictionary *)otherDictionary;
4632
Sergio Campamá32fadc02016-08-08 07:15:02 -07004633/**
4634 * Sets the value for the given key.
4635 *
4636 * @param object The value to set.
4637 * @param key The key under which to store the value.
4638 **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05004639- (void)setObject:(ObjectType)object forKey:(BOOL)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004640
Sergio Campamá32fadc02016-08-08 07:15:02 -07004641/**
4642 * Removes the entry for the given key.
4643 *
4644 * @param aKey Key to be removed from this dictionary.
4645 **/
Thomas Van Lenten1383d532015-09-29 11:41:53 -04004646- (void)removeObjectForKey:(BOOL)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004647
4648/**
4649 * Removes all entries in this dictionary.
4650 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004651- (void)removeAll;
4652
4653@end
4654
4655#pragma mark - String -> UInt32
4656
Sergio Campamá32fadc02016-08-08 07:15:02 -07004657/**
4658 * Class used for map fields of <NSString, uint32_t>
4659 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4660 *
4661 * @note This class is not meant to be subclassed.
4662 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004663@interface GPBStringUInt32Dictionary : NSObject <NSCopying>
4664
Sergio Campamá32fadc02016-08-08 07:15:02 -07004665/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004666@property(nonatomic, readonly) NSUInteger count;
4667
Sergio Campamá32fadc02016-08-08 07:15:02 -07004668/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07004669 * Initializes this dictionary, copying the given values and keys.
4670 *
4671 * @param values The values to be placed in this dictionary.
4672 * @param keys The keys under which to store the values.
4673 * @param count The number of elements to copy into the dictionary.
4674 *
4675 * @return A newly initialized dictionary with a copy of the values and keys.
4676 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05004677- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
4678 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004679 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004680
4681/**
4682 * Initializes this dictionary, copying the entries from the given dictionary.
4683 *
4684 * @param dictionary Dictionary containing the entries to add to this dictionary.
4685 *
4686 * @return A newly initialized dictionary with the entries of the given dictionary.
4687 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004688- (instancetype)initWithDictionary:(GPBStringUInt32Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004689
4690/**
4691 * Initializes this dictionary with the requested capacity.
4692 *
4693 * @param numItems Number of items needed for this dictionary.
4694 *
4695 * @return A newly initialized dictionary with the requested capacity.
4696 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004697- (instancetype)initWithCapacity:(NSUInteger)numItems;
4698
Sergio Campamá32fadc02016-08-08 07:15:02 -07004699/**
4700 * Gets the value for the given key.
4701 *
4702 * @param value Pointer into which the value will be set, if found.
4703 * @param key Key under which the value is stored, if present.
4704 *
4705 * @return YES if the key was found and the value was copied, NO otherwise.
4706 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004707- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004708
Sergio Campamá32fadc02016-08-08 07:15:02 -07004709/**
4710 * Enumerates the keys and values on this dictionary with the given block.
4711 *
4712 * @param block The block to enumerate with.
4713 * **key**: The key for the current entry.
4714 * **value**: The value for the current entry
4715 * **stop**: A pointer to a boolean that when set stops the enumeration.
4716 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004717- (void)enumerateKeysAndUInt32sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05004718 (void (NS_NOESCAPE ^)(NSString *key, uint32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004719
Sergio Campamá32fadc02016-08-08 07:15:02 -07004720/**
4721 * Adds the keys and values from another dictionary.
4722 *
4723 * @param otherDictionary Dictionary containing entries to be added to this
4724 * dictionary.
4725 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004726- (void)addEntriesFromDictionary:(GPBStringUInt32Dictionary *)otherDictionary;
4727
Sergio Campamá32fadc02016-08-08 07:15:02 -07004728/**
4729 * Sets the value for the given key.
4730 *
4731 * @param value The value to set.
4732 * @param key The key under which to store the value.
4733 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004734- (void)setUInt32:(uint32_t)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004735
Sergio Campamá32fadc02016-08-08 07:15:02 -07004736/**
4737 * Removes the entry for the given key.
4738 *
4739 * @param aKey Key to be removed from this dictionary.
4740 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004741- (void)removeUInt32ForKey:(NSString *)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004742
4743/**
4744 * Removes all entries in this dictionary.
4745 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004746- (void)removeAll;
4747
4748@end
4749
4750#pragma mark - String -> Int32
4751
Sergio Campamá32fadc02016-08-08 07:15:02 -07004752/**
4753 * Class used for map fields of <NSString, int32_t>
4754 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4755 *
4756 * @note This class is not meant to be subclassed.
4757 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004758@interface GPBStringInt32Dictionary : NSObject <NSCopying>
4759
Sergio Campamá32fadc02016-08-08 07:15:02 -07004760/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004761@property(nonatomic, readonly) NSUInteger count;
4762
Sergio Campamá32fadc02016-08-08 07:15:02 -07004763/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07004764 * Initializes this dictionary, copying the given values and keys.
4765 *
4766 * @param values The values to be placed in this dictionary.
4767 * @param keys The keys under which to store the values.
4768 * @param count The number of elements to copy into the dictionary.
4769 *
4770 * @return A newly initialized dictionary with a copy of the values and keys.
4771 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05004772- (instancetype)initWithInt32s:(const int32_t [__nullable])values
4773 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004774 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004775
4776/**
4777 * Initializes this dictionary, copying the entries from the given dictionary.
4778 *
4779 * @param dictionary Dictionary containing the entries to add to this dictionary.
4780 *
4781 * @return A newly initialized dictionary with the entries of the given dictionary.
4782 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004783- (instancetype)initWithDictionary:(GPBStringInt32Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004784
4785/**
4786 * Initializes this dictionary with the requested capacity.
4787 *
4788 * @param numItems Number of items needed for this dictionary.
4789 *
4790 * @return A newly initialized dictionary with the requested capacity.
4791 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004792- (instancetype)initWithCapacity:(NSUInteger)numItems;
4793
Sergio Campamá32fadc02016-08-08 07:15:02 -07004794/**
4795 * Gets the value for the given key.
4796 *
4797 * @param value Pointer into which the value will be set, if found.
4798 * @param key Key under which the value is stored, if present.
4799 *
4800 * @return YES if the key was found and the value was copied, NO otherwise.
4801 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004802- (BOOL)getInt32:(nullable int32_t *)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004803
Sergio Campamá32fadc02016-08-08 07:15:02 -07004804/**
4805 * Enumerates the keys and values on this dictionary with the given block.
4806 *
4807 * @param block The block to enumerate with.
4808 * **key**: The key for the current entry.
4809 * **value**: The value for the current entry
4810 * **stop**: A pointer to a boolean that when set stops the enumeration.
4811 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004812- (void)enumerateKeysAndInt32sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05004813 (void (NS_NOESCAPE ^)(NSString *key, int32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004814
Sergio Campamá32fadc02016-08-08 07:15:02 -07004815/**
4816 * Adds the keys and values from another dictionary.
4817 *
4818 * @param otherDictionary Dictionary containing entries to be added to this
4819 * dictionary.
4820 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004821- (void)addEntriesFromDictionary:(GPBStringInt32Dictionary *)otherDictionary;
4822
Sergio Campamá32fadc02016-08-08 07:15:02 -07004823/**
4824 * Sets the value for the given key.
4825 *
4826 * @param value The value to set.
4827 * @param key The key under which to store the value.
4828 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004829- (void)setInt32:(int32_t)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004830
Sergio Campamá32fadc02016-08-08 07:15:02 -07004831/**
4832 * Removes the entry for the given key.
4833 *
4834 * @param aKey Key to be removed from this dictionary.
4835 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004836- (void)removeInt32ForKey:(NSString *)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004837
4838/**
4839 * Removes all entries in this dictionary.
4840 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004841- (void)removeAll;
4842
4843@end
4844
4845#pragma mark - String -> UInt64
4846
Sergio Campamá32fadc02016-08-08 07:15:02 -07004847/**
4848 * Class used for map fields of <NSString, uint64_t>
4849 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4850 *
4851 * @note This class is not meant to be subclassed.
4852 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004853@interface GPBStringUInt64Dictionary : NSObject <NSCopying>
4854
Sergio Campamá32fadc02016-08-08 07:15:02 -07004855/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004856@property(nonatomic, readonly) NSUInteger count;
4857
Sergio Campamá32fadc02016-08-08 07:15:02 -07004858/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07004859 * Initializes this dictionary, copying the given values and keys.
4860 *
4861 * @param values The values to be placed in this dictionary.
4862 * @param keys The keys under which to store the values.
4863 * @param count The number of elements to copy into the dictionary.
4864 *
4865 * @return A newly initialized dictionary with a copy of the values and keys.
4866 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05004867- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
4868 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004869 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004870
4871/**
4872 * Initializes this dictionary, copying the entries from the given dictionary.
4873 *
4874 * @param dictionary Dictionary containing the entries to add to this dictionary.
4875 *
4876 * @return A newly initialized dictionary with the entries of the given dictionary.
4877 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004878- (instancetype)initWithDictionary:(GPBStringUInt64Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004879
4880/**
4881 * Initializes this dictionary with the requested capacity.
4882 *
4883 * @param numItems Number of items needed for this dictionary.
4884 *
4885 * @return A newly initialized dictionary with the requested capacity.
4886 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004887- (instancetype)initWithCapacity:(NSUInteger)numItems;
4888
Sergio Campamá32fadc02016-08-08 07:15:02 -07004889/**
4890 * Gets the value for the given key.
4891 *
4892 * @param value Pointer into which the value will be set, if found.
4893 * @param key Key under which the value is stored, if present.
4894 *
4895 * @return YES if the key was found and the value was copied, NO otherwise.
4896 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004897- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004898
Sergio Campamá32fadc02016-08-08 07:15:02 -07004899/**
4900 * Enumerates the keys and values on this dictionary with the given block.
4901 *
4902 * @param block The block to enumerate with.
4903 * **key**: The key for the current entry.
4904 * **value**: The value for the current entry
4905 * **stop**: A pointer to a boolean that when set stops the enumeration.
4906 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004907- (void)enumerateKeysAndUInt64sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05004908 (void (NS_NOESCAPE ^)(NSString *key, uint64_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004909
Sergio Campamá32fadc02016-08-08 07:15:02 -07004910/**
4911 * Adds the keys and values from another dictionary.
4912 *
4913 * @param otherDictionary Dictionary containing entries to be added to this
4914 * dictionary.
4915 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004916- (void)addEntriesFromDictionary:(GPBStringUInt64Dictionary *)otherDictionary;
4917
Sergio Campamá32fadc02016-08-08 07:15:02 -07004918/**
4919 * Sets the value for the given key.
4920 *
4921 * @param value The value to set.
4922 * @param key The key under which to store the value.
4923 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004924- (void)setUInt64:(uint64_t)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004925
Sergio Campamá32fadc02016-08-08 07:15:02 -07004926/**
4927 * Removes the entry for the given key.
4928 *
4929 * @param aKey Key to be removed from this dictionary.
4930 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004931- (void)removeUInt64ForKey:(NSString *)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004932
4933/**
4934 * Removes all entries in this dictionary.
4935 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004936- (void)removeAll;
4937
4938@end
4939
4940#pragma mark - String -> Int64
4941
Sergio Campamá32fadc02016-08-08 07:15:02 -07004942/**
4943 * Class used for map fields of <NSString, int64_t>
4944 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4945 *
4946 * @note This class is not meant to be subclassed.
4947 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004948@interface GPBStringInt64Dictionary : NSObject <NSCopying>
4949
Sergio Campamá32fadc02016-08-08 07:15:02 -07004950/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004951@property(nonatomic, readonly) NSUInteger count;
4952
Sergio Campamá32fadc02016-08-08 07:15:02 -07004953/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07004954 * Initializes this dictionary, copying the given values and keys.
4955 *
4956 * @param values The values to be placed in this dictionary.
4957 * @param keys The keys under which to store the values.
4958 * @param count The number of elements to copy into the dictionary.
4959 *
4960 * @return A newly initialized dictionary with a copy of the values and keys.
4961 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05004962- (instancetype)initWithInt64s:(const int64_t [__nullable])values
4963 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004964 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004965
4966/**
4967 * Initializes this dictionary, copying the entries from the given dictionary.
4968 *
4969 * @param dictionary Dictionary containing the entries to add to this dictionary.
4970 *
4971 * @return A newly initialized dictionary with the entries of the given dictionary.
4972 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004973- (instancetype)initWithDictionary:(GPBStringInt64Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07004974
4975/**
4976 * Initializes this dictionary with the requested capacity.
4977 *
4978 * @param numItems Number of items needed for this dictionary.
4979 *
4980 * @return A newly initialized dictionary with the requested capacity.
4981 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004982- (instancetype)initWithCapacity:(NSUInteger)numItems;
4983
Sergio Campamá32fadc02016-08-08 07:15:02 -07004984/**
4985 * Gets the value for the given key.
4986 *
4987 * @param value Pointer into which the value will be set, if found.
4988 * @param key Key under which the value is stored, if present.
4989 *
4990 * @return YES if the key was found and the value was copied, NO otherwise.
4991 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04004992- (BOOL)getInt64:(nullable int64_t *)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04004993
Sergio Campamá32fadc02016-08-08 07:15:02 -07004994/**
4995 * Enumerates the keys and values on this dictionary with the given block.
4996 *
4997 * @param block The block to enumerate with.
4998 * **key**: The key for the current entry.
4999 * **value**: The value for the current entry
5000 * **stop**: A pointer to a boolean that when set stops the enumeration.
5001 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005002- (void)enumerateKeysAndInt64sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05005003 (void (NS_NOESCAPE ^)(NSString *key, int64_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005004
Sergio Campamá32fadc02016-08-08 07:15:02 -07005005/**
5006 * Adds the keys and values from another dictionary.
5007 *
5008 * @param otherDictionary Dictionary containing entries to be added to this
5009 * dictionary.
5010 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005011- (void)addEntriesFromDictionary:(GPBStringInt64Dictionary *)otherDictionary;
5012
Sergio Campamá32fadc02016-08-08 07:15:02 -07005013/**
5014 * Sets the value for the given key.
5015 *
5016 * @param value The value to set.
5017 * @param key The key under which to store the value.
5018 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005019- (void)setInt64:(int64_t)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005020
Sergio Campamá32fadc02016-08-08 07:15:02 -07005021/**
5022 * Removes the entry for the given key.
5023 *
5024 * @param aKey Key to be removed from this dictionary.
5025 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005026- (void)removeInt64ForKey:(NSString *)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005027
5028/**
5029 * Removes all entries in this dictionary.
5030 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005031- (void)removeAll;
5032
5033@end
5034
5035#pragma mark - String -> Bool
5036
Sergio Campamá32fadc02016-08-08 07:15:02 -07005037/**
5038 * Class used for map fields of <NSString, BOOL>
5039 * values. This performs better than boxing into NSNumbers in NSDictionaries.
5040 *
5041 * @note This class is not meant to be subclassed.
5042 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005043@interface GPBStringBoolDictionary : NSObject <NSCopying>
5044
Sergio Campamá32fadc02016-08-08 07:15:02 -07005045/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005046@property(nonatomic, readonly) NSUInteger count;
5047
Sergio Campamá32fadc02016-08-08 07:15:02 -07005048/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07005049 * Initializes this dictionary, copying the given values and keys.
5050 *
5051 * @param values The values to be placed in this dictionary.
5052 * @param keys The keys under which to store the values.
5053 * @param count The number of elements to copy into the dictionary.
5054 *
5055 * @return A newly initialized dictionary with a copy of the values and keys.
5056 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05005057- (instancetype)initWithBools:(const BOOL [__nullable])values
5058 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005059 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005060
5061/**
5062 * Initializes this dictionary, copying the entries from the given dictionary.
5063 *
5064 * @param dictionary Dictionary containing the entries to add to this dictionary.
5065 *
5066 * @return A newly initialized dictionary with the entries of the given dictionary.
5067 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005068- (instancetype)initWithDictionary:(GPBStringBoolDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005069
5070/**
5071 * Initializes this dictionary with the requested capacity.
5072 *
5073 * @param numItems Number of items needed for this dictionary.
5074 *
5075 * @return A newly initialized dictionary with the requested capacity.
5076 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005077- (instancetype)initWithCapacity:(NSUInteger)numItems;
5078
Sergio Campamá32fadc02016-08-08 07:15:02 -07005079/**
5080 * Gets the value for the given key.
5081 *
5082 * @param value Pointer into which the value will be set, if found.
5083 * @param key Key under which the value is stored, if present.
5084 *
5085 * @return YES if the key was found and the value was copied, NO otherwise.
5086 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005087- (BOOL)getBool:(nullable BOOL *)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005088
Sergio Campamá32fadc02016-08-08 07:15:02 -07005089/**
5090 * Enumerates the keys and values on this dictionary with the given block.
5091 *
5092 * @param block The block to enumerate with.
5093 * **key**: The key for the current entry.
5094 * **value**: The value for the current entry
5095 * **stop**: A pointer to a boolean that when set stops the enumeration.
5096 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005097- (void)enumerateKeysAndBoolsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05005098 (void (NS_NOESCAPE ^)(NSString *key, BOOL value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005099
Sergio Campamá32fadc02016-08-08 07:15:02 -07005100/**
5101 * Adds the keys and values from another dictionary.
5102 *
5103 * @param otherDictionary Dictionary containing entries to be added to this
5104 * dictionary.
5105 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005106- (void)addEntriesFromDictionary:(GPBStringBoolDictionary *)otherDictionary;
5107
Sergio Campamá32fadc02016-08-08 07:15:02 -07005108/**
5109 * Sets the value for the given key.
5110 *
5111 * @param value The value to set.
5112 * @param key The key under which to store the value.
5113 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005114- (void)setBool:(BOOL)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005115
Sergio Campamá32fadc02016-08-08 07:15:02 -07005116/**
5117 * Removes the entry for the given key.
5118 *
5119 * @param aKey Key to be removed from this dictionary.
5120 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005121- (void)removeBoolForKey:(NSString *)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005122
5123/**
5124 * Removes all entries in this dictionary.
5125 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005126- (void)removeAll;
5127
5128@end
5129
5130#pragma mark - String -> Float
5131
Sergio Campamá32fadc02016-08-08 07:15:02 -07005132/**
5133 * Class used for map fields of <NSString, float>
5134 * values. This performs better than boxing into NSNumbers in NSDictionaries.
5135 *
5136 * @note This class is not meant to be subclassed.
5137 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005138@interface GPBStringFloatDictionary : NSObject <NSCopying>
5139
Sergio Campamá32fadc02016-08-08 07:15:02 -07005140/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005141@property(nonatomic, readonly) NSUInteger count;
5142
Sergio Campamá32fadc02016-08-08 07:15:02 -07005143/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07005144 * Initializes this dictionary, copying the given values and keys.
5145 *
5146 * @param values The values to be placed in this dictionary.
5147 * @param keys The keys under which to store the values.
5148 * @param count The number of elements to copy into the dictionary.
5149 *
5150 * @return A newly initialized dictionary with a copy of the values and keys.
5151 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05005152- (instancetype)initWithFloats:(const float [__nullable])values
5153 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005154 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005155
5156/**
5157 * Initializes this dictionary, copying the entries from the given dictionary.
5158 *
5159 * @param dictionary Dictionary containing the entries to add to this dictionary.
5160 *
5161 * @return A newly initialized dictionary with the entries of the given dictionary.
5162 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005163- (instancetype)initWithDictionary:(GPBStringFloatDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005164
5165/**
5166 * Initializes this dictionary with the requested capacity.
5167 *
5168 * @param numItems Number of items needed for this dictionary.
5169 *
5170 * @return A newly initialized dictionary with the requested capacity.
5171 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005172- (instancetype)initWithCapacity:(NSUInteger)numItems;
5173
Sergio Campamá32fadc02016-08-08 07:15:02 -07005174/**
5175 * Gets the value for the given key.
5176 *
5177 * @param value Pointer into which the value will be set, if found.
5178 * @param key Key under which the value is stored, if present.
5179 *
5180 * @return YES if the key was found and the value was copied, NO otherwise.
5181 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005182- (BOOL)getFloat:(nullable float *)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005183
Sergio Campamá32fadc02016-08-08 07:15:02 -07005184/**
5185 * Enumerates the keys and values on this dictionary with the given block.
5186 *
5187 * @param block The block to enumerate with.
5188 * **key**: The key for the current entry.
5189 * **value**: The value for the current entry
5190 * **stop**: A pointer to a boolean that when set stops the enumeration.
5191 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005192- (void)enumerateKeysAndFloatsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05005193 (void (NS_NOESCAPE ^)(NSString *key, float value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005194
Sergio Campamá32fadc02016-08-08 07:15:02 -07005195/**
5196 * Adds the keys and values from another dictionary.
5197 *
5198 * @param otherDictionary Dictionary containing entries to be added to this
5199 * dictionary.
5200 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005201- (void)addEntriesFromDictionary:(GPBStringFloatDictionary *)otherDictionary;
5202
Sergio Campamá32fadc02016-08-08 07:15:02 -07005203/**
5204 * Sets the value for the given key.
5205 *
5206 * @param value The value to set.
5207 * @param key The key under which to store the value.
5208 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005209- (void)setFloat:(float)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005210
Sergio Campamá32fadc02016-08-08 07:15:02 -07005211/**
5212 * Removes the entry for the given key.
5213 *
5214 * @param aKey Key to be removed from this dictionary.
5215 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005216- (void)removeFloatForKey:(NSString *)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005217
5218/**
5219 * Removes all entries in this dictionary.
5220 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005221- (void)removeAll;
5222
5223@end
5224
5225#pragma mark - String -> Double
5226
Sergio Campamá32fadc02016-08-08 07:15:02 -07005227/**
5228 * Class used for map fields of <NSString, double>
5229 * values. This performs better than boxing into NSNumbers in NSDictionaries.
5230 *
5231 * @note This class is not meant to be subclassed.
5232 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005233@interface GPBStringDoubleDictionary : NSObject <NSCopying>
5234
Sergio Campamá32fadc02016-08-08 07:15:02 -07005235/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005236@property(nonatomic, readonly) NSUInteger count;
5237
Sergio Campamá32fadc02016-08-08 07:15:02 -07005238/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07005239 * Initializes this dictionary, copying the given values and keys.
5240 *
5241 * @param values The values to be placed in this dictionary.
5242 * @param keys The keys under which to store the values.
5243 * @param count The number of elements to copy into the dictionary.
5244 *
5245 * @return A newly initialized dictionary with a copy of the values and keys.
5246 **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05005247- (instancetype)initWithDoubles:(const double [__nullable])values
5248 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005249 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005250
5251/**
5252 * Initializes this dictionary, copying the entries from the given dictionary.
5253 *
5254 * @param dictionary Dictionary containing the entries to add to this dictionary.
5255 *
5256 * @return A newly initialized dictionary with the entries of the given dictionary.
5257 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005258- (instancetype)initWithDictionary:(GPBStringDoubleDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005259
5260/**
5261 * Initializes this dictionary with the requested capacity.
5262 *
5263 * @param numItems Number of items needed for this dictionary.
5264 *
5265 * @return A newly initialized dictionary with the requested capacity.
5266 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005267- (instancetype)initWithCapacity:(NSUInteger)numItems;
5268
Sergio Campamá32fadc02016-08-08 07:15:02 -07005269/**
5270 * Gets the value for the given key.
5271 *
5272 * @param value Pointer into which the value will be set, if found.
5273 * @param key Key under which the value is stored, if present.
5274 *
5275 * @return YES if the key was found and the value was copied, NO otherwise.
5276 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005277- (BOOL)getDouble:(nullable double *)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005278
Sergio Campamá32fadc02016-08-08 07:15:02 -07005279/**
5280 * Enumerates the keys and values on this dictionary with the given block.
5281 *
5282 * @param block The block to enumerate with.
5283 * **key**: The key for the current entry.
5284 * **value**: The value for the current entry
5285 * **stop**: A pointer to a boolean that when set stops the enumeration.
5286 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005287- (void)enumerateKeysAndDoublesUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05005288 (void (NS_NOESCAPE ^)(NSString *key, double value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005289
Sergio Campamá32fadc02016-08-08 07:15:02 -07005290/**
5291 * Adds the keys and values from another dictionary.
5292 *
5293 * @param otherDictionary Dictionary containing entries to be added to this
5294 * dictionary.
5295 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005296- (void)addEntriesFromDictionary:(GPBStringDoubleDictionary *)otherDictionary;
5297
Sergio Campamá32fadc02016-08-08 07:15:02 -07005298/**
5299 * Sets the value for the given key.
5300 *
5301 * @param value The value to set.
5302 * @param key The key under which to store the value.
5303 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005304- (void)setDouble:(double)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005305
Sergio Campamá32fadc02016-08-08 07:15:02 -07005306/**
5307 * Removes the entry for the given key.
5308 *
5309 * @param aKey Key to be removed from this dictionary.
5310 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005311- (void)removeDoubleForKey:(NSString *)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005312
5313/**
5314 * Removes all entries in this dictionary.
5315 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005316- (void)removeAll;
5317
5318@end
5319
5320#pragma mark - String -> Enum
5321
Sergio Campamá32fadc02016-08-08 07:15:02 -07005322/**
5323 * Class used for map fields of <NSString, int32_t>
5324 * values. This performs better than boxing into NSNumbers in NSDictionaries.
5325 *
5326 * @note This class is not meant to be subclassed.
5327 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005328@interface GPBStringEnumDictionary : NSObject <NSCopying>
5329
Sergio Campamá32fadc02016-08-08 07:15:02 -07005330/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005331@property(nonatomic, readonly) NSUInteger count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005332/** The validation function to check if the enums are valid. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005333@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
5334
Sergio Campamá32fadc02016-08-08 07:15:02 -07005335/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07005336 * Initializes a dictionary with the given validation function.
5337 *
5338 * @param func The enum validation function for the dictionary.
5339 *
5340 * @return A newly initialized dictionary.
5341 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04005342- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005343
5344/**
5345 * Initializes a dictionary with the entries given.
5346 *
5347 * @param func The enum validation function for the dictionary.
5348 * @param values The raw enum values values to be placed in the dictionary.
5349 * @param keys The keys under which to store the values.
5350 * @param count The number of entries to store in the dictionary.
5351 *
5352 * @return A newly initialized dictionary with the keys and values in it.
5353 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04005354- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Sergio Campama3d7b42d2017-01-25 11:51:54 -05005355 rawValues:(const int32_t [__nullable])values
5356 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005357 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005358
5359/**
5360 * Initializes a dictionary with the entries from the given.
5361 * dictionary.
5362 *
5363 * @param dictionary Dictionary containing the entries to add to the dictionary.
5364 *
5365 * @return A newly initialized dictionary with the entries from the given
5366 * dictionary in it.
5367 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005368- (instancetype)initWithDictionary:(GPBStringEnumDictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005369
5370/**
5371 * Initializes a dictionary with the given capacity.
5372 *
5373 * @param func The enum validation function for the dictionary.
5374 * @param numItems Capacity needed for the dictionary.
5375 *
5376 * @return A newly initialized dictionary with the given capacity.
5377 **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04005378- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005379 capacity:(NSUInteger)numItems;
5380
5381// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
5382// is not a valid enumerator as defined by validationFunc. If the actual value is
5383// desired, use "raw" version of the method.
5384
Sergio Campamá32fadc02016-08-08 07:15:02 -07005385/**
5386 * Gets the value for the given key.
5387 *
5388 * @param value Pointer into which the value will be set, if found.
5389 * @param key Key under which the value is stored, if present.
5390 *
5391 * @return YES if the key was found and the value was copied, NO otherwise.
5392 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005393- (BOOL)getEnum:(nullable int32_t *)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005394
Sergio Campamá32fadc02016-08-08 07:15:02 -07005395/**
5396 * Enumerates the keys and values on this dictionary with the given block.
5397 *
5398 * @param block The block to enumerate with.
5399 * **key**: The key for the current entry.
5400 * **value**: The value for the current entry
5401 * **stop**: A pointer to a boolean that when set stops the enumeration.
5402 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005403- (void)enumerateKeysAndEnumsUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05005404 (void (NS_NOESCAPE ^)(NSString *key, int32_t value, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005405
Sergio Campamá32fadc02016-08-08 07:15:02 -07005406/**
5407 * Gets the raw enum value for the given key.
5408 *
5409 * @note This method bypass the validationFunc to enable the access of values that
5410 * were not known at the time the binary was compiled.
5411 *
5412 * @param rawValue Pointer into which the value will be set, if found.
5413 * @param key Key under which the value is stored, if present.
5414 *
5415 * @return YES if the key was found and the value was copied, NO otherwise.
5416 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005417- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005418
Sergio Campamá32fadc02016-08-08 07:15:02 -07005419/**
5420 * Enumerates the keys and values on this dictionary with the given block.
5421 *
5422 * @note This method bypass the validationFunc to enable the access of values that
5423 * were not known at the time the binary was compiled.
5424 *
5425 * @param block The block to enumerate with.
5426 * **key**: The key for the current entry.
5427 * **rawValue**: The value for the current entry
5428 * **stop**: A pointer to a boolean that when set stops the enumeration.
5429 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005430- (void)enumerateKeysAndRawValuesUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05005431 (void (NS_NOESCAPE ^)(NSString *key, int32_t rawValue, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005432
Sergio Campamá32fadc02016-08-08 07:15:02 -07005433/**
5434 * Adds the keys and raw enum values from another dictionary.
5435 *
5436 * @note This method bypass the validationFunc to enable the setting of values that
5437 * were not known at the time the binary was compiled.
5438 *
5439 * @param otherDictionary Dictionary containing entries to be added to this
5440 * dictionary.
5441 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005442- (void)addRawEntriesFromDictionary:(GPBStringEnumDictionary *)otherDictionary;
5443
5444// If value is not a valid enumerator as defined by validationFunc, these
5445// methods will assert in debug, and will log in release and assign the value
5446// to the default value. Use the rawValue methods below to assign non enumerator
5447// values.
5448
Sergio Campamá32fadc02016-08-08 07:15:02 -07005449/**
5450 * Sets the value for the given key.
5451 *
5452 * @param value The value to set.
5453 * @param key The key under which to store the value.
5454 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005455- (void)setEnum:(int32_t)value forKey:(NSString *)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005456
Sergio Campamá32fadc02016-08-08 07:15:02 -07005457/**
5458 * Sets the raw enum value for the given key.
5459 *
5460 * @note This method bypass the validationFunc to enable the setting of values that
5461 * were not known at the time the binary was compiled.
5462 *
5463 * @param rawValue The raw enum value to set.
5464 * @param key The key under which to store the raw enum value.
5465 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005466- (void)setRawValue:(int32_t)rawValue forKey:(NSString *)key;
5467
Sergio Campamá32fadc02016-08-08 07:15:02 -07005468/**
5469 * Removes the entry for the given key.
5470 *
5471 * @param aKey Key to be removed from this dictionary.
5472 **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005473- (void)removeEnumForKey:(NSString *)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005474
5475/**
5476 * Removes all entries in this dictionary.
5477 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005478- (void)removeAll;
5479
5480@end
5481
Dave MacLachlanab48ecf2020-01-20 13:47:20 -08005482// clang-format on
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005483//%PDDM-EXPAND-END DECLARE_DICTIONARIES()
5484
Thomas Van Lenten8c889572015-06-16 16:45:14 -04005485NS_ASSUME_NONNULL_END
5486
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005487//%PDDM-DEFINE DECLARE_DICTIONARIES()
5488//%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt32, uint32_t)
5489//%DICTIONARY_INTERFACES_FOR_POD_KEY(Int32, int32_t)
5490//%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt64, uint64_t)
5491//%DICTIONARY_INTERFACES_FOR_POD_KEY(Int64, int64_t)
5492//%DICTIONARY_INTERFACES_FOR_POD_KEY(Bool, BOOL)
5493//%DICTIONARY_POD_INTERFACES_FOR_KEY(String, NSString, *, OBJECT)
5494//%PDDM-DEFINE DICTIONARY_INTERFACES_FOR_POD_KEY(KEY_NAME, KEY_TYPE)
5495//%DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, , POD)
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05005496//%DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, Object, ObjectType)
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005497//%PDDM-DEFINE DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, KisP, KHELPER)
5498//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt32, uint32_t)
5499//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int32, int32_t)
5500//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt64, uint64_t)
5501//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int64, int64_t)
5502//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Bool, BOOL)
5503//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Float, float)
5504//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Double, double)
5505//%DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Enum, int32_t)
5506//%PDDM-DEFINE DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE)
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005507//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, POD, VALUE_NAME, value)
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005508//%PDDM-DEFINE DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, VALUE_NAME, VALUE_TYPE)
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005509//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, , POD, VALUE_NAME, VALUE_TYPE, OBJECT, Object, object)
5510//%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME)
Sergio Campamá32fadc02016-08-08 07:15:02 -07005511//%/**
5512//% * Gets the value for the given key.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005513//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005514//% * @param value Pointer into which the value will be set, if found.
5515//% * @param key Key under which the value is stored, if present.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005516//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005517//% * @return YES if the key was found and the value was copied, NO otherwise.
5518//% **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005519//%- (BOOL)get##VNAME##:(nullable VALUE_TYPE *)value forKey:(KEY_TYPE)key;
5520//%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_TYPE, VNAME)
Sergio Campamá32fadc02016-08-08 07:15:02 -07005521//%/**
5522//% * Fetches the object stored under the given key.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005523//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005524//% * @param key Key under which the value is stored, if present.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005525//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005526//% * @return The object if found, nil otherwise.
5527//% **/
Thomas Van Lenten1383d532015-09-29 11:41:53 -04005528//%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key;
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005529//%PDDM-DEFINE VALUE_FOR_KEY_Enum(KEY_TYPE, VALUE_TYPE, VNAME)
5530//%VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME)
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005531//%PDDM-DEFINE ARRAY_ARG_MODIFIERPOD()
5532// Nothing
5533//%PDDM-DEFINE ARRAY_ARG_MODIFIEREnum()
5534// Nothing
5535//%PDDM-DEFINE ARRAY_ARG_MODIFIEROBJECT()
Sergio Campama3d7b42d2017-01-25 11:51:54 -05005536//%__nonnull GPB_UNSAFE_UNRETAINED ##
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05005537//%PDDM-DEFINE DICTIONARY_CLASS_DECLPOD(KEY_NAME, VALUE_NAME, VALUE_TYPE)
5538//%GPB##KEY_NAME##VALUE_NAME##Dictionary
5539//%PDDM-DEFINE DICTIONARY_CLASS_DECLEnum(KEY_NAME, VALUE_NAME, VALUE_TYPE)
5540//%GPB##KEY_NAME##VALUE_NAME##Dictionary
5541//%PDDM-DEFINE DICTIONARY_CLASS_DECLOBJECT(KEY_NAME, VALUE_NAME, VALUE_TYPE)
5542//%GPB##KEY_NAME##VALUE_NAME##Dictionary<__covariant VALUE_TYPE>
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005543//%PDDM-DEFINE DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005544//%#pragma mark - KEY_NAME -> VALUE_NAME
5545//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07005546//%/**
5547//% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##>
5548//% * values. This performs better than boxing into NSNumbers in NSDictionaries.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005549//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005550//% * @note This class is not meant to be subclassed.
5551//% **/
Thomas Van Lenten2480acb2015-11-30 14:38:04 -05005552//%@interface DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) : NSObject <NSCopying>
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005553//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07005554//%/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005555//%@property(nonatomic, readonly) NSUInteger count;
5556//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07005557//%/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07005558//% * Initializes this dictionary, copying the given values and keys.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005559//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005560//% * @param ##VNAME_VAR##s The values to be placed in this dictionary.
5561//% * @param keys ##VNAME_VAR$S## The keys under which to store the values.
5562//% * @param count ##VNAME_VAR$S## The number of elements to copy into the dictionary.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005563//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005564//% * @return A newly initialized dictionary with a copy of the values and keys.
5565//% **/
Sergio Campama3d7b42d2017-01-25 11:51:54 -05005566//%- (instancetype)initWith##VNAME##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])##VNAME_VAR##s
5567//% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
Thomas Van Lenten1383d532015-09-29 11:41:53 -04005568//% ##VNAME$S## count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005569//%
5570//%/**
5571//% * Initializes this dictionary, copying the entries from the given dictionary.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005572//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005573//% * @param dictionary Dictionary containing the entries to add to this dictionary.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005574//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005575//% * @return A newly initialized dictionary with the entries of the given dictionary.
5576//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005577//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005578//%
5579//%/**
5580//% * Initializes this dictionary with the requested capacity.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005581//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005582//% * @param numItems Number of items needed for this dictionary.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005583//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005584//% * @return A newly initialized dictionary with the requested capacity.
5585//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005586//%- (instancetype)initWithCapacity:(NSUInteger)numItems;
5587//%
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005588//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005589//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07005590//%/**
5591//% * Adds the keys and values from another dictionary.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005592//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005593//% * @param otherDictionary Dictionary containing entries to be added to this
5594//% * dictionary.
5595//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005596//%- (void)addEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary;
5597//%
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005598//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005599//%
5600//%@end
5601//%
5602
5603//%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE)
5604//%DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, Enum)
5605//%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER)
5606//%#pragma mark - KEY_NAME -> VALUE_NAME
5607//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07005608//%/**
5609//% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##>
5610//% * values. This performs better than boxing into NSNumbers in NSDictionaries.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005611//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005612//% * @note This class is not meant to be subclassed.
5613//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005614//%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject <NSCopying>
5615//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07005616//%/** Number of entries stored in this dictionary. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005617//%@property(nonatomic, readonly) NSUInteger count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005618//%/** The validation function to check if the enums are valid. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005619//%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
5620//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07005621//%/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07005622//% * Initializes a dictionary with the given validation function.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005623//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005624//% * @param func The enum validation function for the dictionary.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005625//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005626//% * @return A newly initialized dictionary.
5627//% **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04005628//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005629//%
5630//%/**
5631//% * Initializes a dictionary with the entries given.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005632//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005633//% * @param func The enum validation function for the dictionary.
5634//% * @param values The raw enum values values to be placed in the dictionary.
5635//% * @param keys The keys under which to store the values.
5636//% * @param count The number of entries to store in the dictionary.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005637//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005638//% * @return A newly initialized dictionary with the keys and values in it.
5639//% **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04005640//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Sergio Campama3d7b42d2017-01-25 11:51:54 -05005641//% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])values
5642//% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005643//% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005644//%
5645//%/**
5646//% * Initializes a dictionary with the entries from the given.
5647//% * dictionary.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005648//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005649//% * @param dictionary Dictionary containing the entries to add to the dictionary.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005650//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005651//% * @return A newly initialized dictionary with the entries from the given
5652//% * dictionary in it.
5653//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005654//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005655//%
5656//%/**
5657//% * Initializes a dictionary with the given capacity.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005658//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005659//% * @param func The enum validation function for the dictionary.
5660//% * @param numItems Capacity needed for the dictionary.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005661//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005662//% * @return A newly initialized dictionary with the given capacity.
5663//% **/
Thomas Van Lenten8c889572015-06-16 16:45:14 -04005664//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005665//% capacity:(NSUInteger)numItems;
5666//%
5667//%// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
5668//%// is not a valid enumerator as defined by validationFunc. If the actual value is
5669//%// desired, use "raw" version of the method.
5670//%
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005671//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value)
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005672//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07005673//%/**
5674//% * Gets the raw enum value for the given key.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005675//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005676//% * @note This method bypass the validationFunc to enable the access of values that
5677//% * were not known at the time the binary was compiled.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005678//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005679//% * @param rawValue Pointer into which the value will be set, if found.
5680//% * @param key Key under which the value is stored, if present.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005681//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005682//% * @return YES if the key was found and the value was copied, NO otherwise.
5683//% **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005684//%- (BOOL)getRawValue:(nullable VALUE_TYPE *)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005685//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07005686//%/**
5687//% * Enumerates the keys and values on this dictionary with the given block.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005688//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005689//% * @note This method bypass the validationFunc to enable the access of values that
5690//% * were not known at the time the binary was compiled.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005691//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005692//% * @param block The block to enumerate with.
5693//% * **key**: The key for the current entry.
5694//% * **rawValue**: The value for the current entry
5695//% * **stop**: A pointer to a boolean that when set stops the enumeration.
5696//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005697//%- (void)enumerateKeysAndRawValuesUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05005698//% (void (NS_NOESCAPE ^)(KEY_TYPE KisP##key, VALUE_TYPE rawValue, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005699//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07005700//%/**
5701//% * Adds the keys and raw enum values from another dictionary.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005702//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005703//% * @note This method bypass the validationFunc to enable the setting of values that
5704//% * were not known at the time the binary was compiled.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005705//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005706//% * @param otherDictionary Dictionary containing entries to be added to this
5707//% * dictionary.
5708//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005709//%- (void)addRawEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary;
5710//%
5711//%// If value is not a valid enumerator as defined by validationFunc, these
5712//%// methods will assert in debug, and will log in release and assign the value
5713//%// to the default value. Use the rawValue methods below to assign non enumerator
5714//%// values.
5715//%
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005716//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value)
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005717//%
5718//%@end
5719//%
5720
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005721//%PDDM-DEFINE DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
5722//%VALUE_FOR_KEY_##VHELPER(KEY_TYPE##KisP$S##KisP, VALUE_TYPE, VNAME)
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005723//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07005724//%/**
5725//% * Enumerates the keys and values on this dictionary with the given block.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005726//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005727//% * @param block The block to enumerate with.
5728//% * **key**: ##VNAME_VAR$S## The key for the current entry.
5729//% * **VNAME_VAR**: The value for the current entry
5730//% * **stop**: ##VNAME_VAR$S## A pointer to a boolean that when set stops the enumeration.
5731//% **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005732//%- (void)enumerateKeysAnd##VNAME##sUsingBlock:
Thomas Van Lentenc4861302018-12-04 10:52:20 -05005733//% (void (NS_NOESCAPE ^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME_VAR, BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005734
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005735//%PDDM-DEFINE DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
Sergio Campamá32fadc02016-08-08 07:15:02 -07005736//%/**
5737//% * Sets the value for the given key.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005738//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005739//% * @param ##VNAME_VAR The value to set.
5740//% * @param key ##VNAME_VAR$S## The key under which to store the value.
5741//% **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005742//%- (void)set##VNAME##:(VALUE_TYPE)##VNAME_VAR forKey:(KEY_TYPE##KisP$S##KisP)key;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005743//%DICTIONARY_EXTRA_MUTABLE_METHODS_##VHELPER(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
Sergio Campamá32fadc02016-08-08 07:15:02 -07005744//%/**
5745//% * Removes the entry for the given key.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005746//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005747//% * @param aKey Key to be removed from this dictionary.
5748//% **/
Thomas Van Lentena230b5d2016-06-21 08:25:28 -04005749//%- (void)remove##VNAME##ForKey:(KEY_TYPE##KisP$S##KisP)aKey;
Sergio Campamá32fadc02016-08-08 07:15:02 -07005750//%
5751//%/**
5752//% * Removes all entries in this dictionary.
5753//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005754//%- (void)removeAll;
5755
5756//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_POD(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
5757// Empty
5758//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_OBJECT(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
5759// Empty
5760//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_Enum(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
5761//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07005762//%/**
5763//% * Sets the raw enum value for the given key.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005764//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005765//% * @note This method bypass the validationFunc to enable the setting of values that
5766//% * were not known at the time the binary was compiled.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05005767//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07005768//% * @param rawValue The raw enum value to set.
5769//% * @param key The key under which to store the raw enum value.
5770//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04005771//%- (void)setRawValue:(VALUE_TYPE)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key;
5772//%