GPBDictionary.h 186 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc.  All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#import <Foundation/Foundation.h>

33
#import "GPBRuntimeTypes.h"
34

35 36 37 38 39 40 41 42
// Note on naming: for the classes holding numeric values, a more natural
// naming of the method might be things like "-valueForKey:",
// "-setValue:forKey:"; etc. But those selectors are also defined by Key Value
// Coding (KVC) as categories on NSObject. So "overloading" the selectors with
// other meanings can cause warnings (based on compiler settings), but more
// importantly, some of those selector get called as KVC breaks up keypaths.
// So if those selectors are used, using KVC will compile cleanly, but could
// crash as it invokes those selectors with the wrong types of arguments.
43

44
NS_ASSUME_NONNULL_BEGIN
45

46 47 48 49 50
//%PDDM-EXPAND DECLARE_DICTIONARIES()
// This block of code is generated, do not edit it directly.

#pragma mark - UInt32 -> UInt32

51 52 53 54 55 56
/**
 * Class used for map fields of <uint32_t, uint32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
57 58
@interface GPBUInt32UInt32Dictionary : NSObject <NSCopying>

59
/** Number of entries stored in this dictionary. */
60 61
@property(nonatomic, readonly) NSUInteger count;

62 63 64 65 66 67 68 69 70
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
71 72
- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
                        forKeys:(const uint32_t [__nullable])keys
73
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
74 75 76 77 78 79 80 81

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
82
- (instancetype)initWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary;
83 84 85 86 87 88 89 90

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
91 92
- (instancetype)initWithCapacity:(NSUInteger)numItems;

93 94 95 96 97 98 99 100
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
101
- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint32_t)key;
102

103 104 105 106 107 108 109 110
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
111
- (void)enumerateKeysAndUInt32sUsingBlock:
112 113
    (void (^)(uint32_t key, uint32_t value, BOOL *stop))block;

114 115 116 117 118 119
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
120 121
- (void)addEntriesFromDictionary:(GPBUInt32UInt32Dictionary *)otherDictionary;

122 123 124 125 126 127
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
128
- (void)setUInt32:(uint32_t)value forKey:(uint32_t)key;
129

130 131 132 133 134
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
135
- (void)removeUInt32ForKey:(uint32_t)aKey;
136 137 138 139

/**
 * Removes all entries in this dictionary.
 **/
140 141 142 143 144 145
- (void)removeAll;

@end

#pragma mark - UInt32 -> Int32

146 147 148 149 150 151
/**
 * Class used for map fields of <uint32_t, int32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
152 153
@interface GPBUInt32Int32Dictionary : NSObject <NSCopying>

154
/** Number of entries stored in this dictionary. */
155 156
@property(nonatomic, readonly) NSUInteger count;

157 158 159 160 161 162 163 164 165
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
166 167
- (instancetype)initWithInt32s:(const int32_t [__nullable])values
                       forKeys:(const uint32_t [__nullable])keys
168
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
169 170 171 172 173 174 175 176

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
177
- (instancetype)initWithDictionary:(GPBUInt32Int32Dictionary *)dictionary;
178 179 180 181 182 183 184 185

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
186 187
- (instancetype)initWithCapacity:(NSUInteger)numItems;

188 189 190 191 192 193 194 195
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
196
- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint32_t)key;
197

198 199 200 201 202 203 204 205
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
206
- (void)enumerateKeysAndInt32sUsingBlock:
207 208
    (void (^)(uint32_t key, int32_t value, BOOL *stop))block;

209 210 211 212 213 214
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
215 216
- (void)addEntriesFromDictionary:(GPBUInt32Int32Dictionary *)otherDictionary;

217 218 219 220 221 222
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
223
- (void)setInt32:(int32_t)value forKey:(uint32_t)key;
224

225 226 227 228 229
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
230
- (void)removeInt32ForKey:(uint32_t)aKey;
231 232 233 234

/**
 * Removes all entries in this dictionary.
 **/
235 236 237 238 239 240
- (void)removeAll;

@end

#pragma mark - UInt32 -> UInt64

241 242 243 244 245 246
/**
 * Class used for map fields of <uint32_t, uint64_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
247 248
@interface GPBUInt32UInt64Dictionary : NSObject <NSCopying>

249
/** Number of entries stored in this dictionary. */
250 251
@property(nonatomic, readonly) NSUInteger count;

252 253 254 255 256 257 258 259 260
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
261 262
- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
                        forKeys:(const uint32_t [__nullable])keys
263
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
264 265 266 267 268 269 270 271

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
272
- (instancetype)initWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary;
273 274 275 276 277 278 279 280

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
281 282
- (instancetype)initWithCapacity:(NSUInteger)numItems;

283 284 285 286 287 288 289 290
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
291
- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint32_t)key;
292

293 294 295 296 297 298 299 300
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
301
- (void)enumerateKeysAndUInt64sUsingBlock:
302 303
    (void (^)(uint32_t key, uint64_t value, BOOL *stop))block;

304 305 306 307 308 309
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
310 311
- (void)addEntriesFromDictionary:(GPBUInt32UInt64Dictionary *)otherDictionary;

312 313 314 315 316 317
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
318
- (void)setUInt64:(uint64_t)value forKey:(uint32_t)key;
319

320 321 322 323 324
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
325
- (void)removeUInt64ForKey:(uint32_t)aKey;
326 327 328 329

/**
 * Removes all entries in this dictionary.
 **/
330 331 332 333 334 335
- (void)removeAll;

@end

#pragma mark - UInt32 -> Int64

336 337 338 339 340 341
/**
 * Class used for map fields of <uint32_t, int64_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
342 343
@interface GPBUInt32Int64Dictionary : NSObject <NSCopying>

344
/** Number of entries stored in this dictionary. */
345 346
@property(nonatomic, readonly) NSUInteger count;

347 348 349 350 351 352 353 354 355
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
356 357
- (instancetype)initWithInt64s:(const int64_t [__nullable])values
                       forKeys:(const uint32_t [__nullable])keys
358
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
359 360 361 362 363 364 365 366

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
367
- (instancetype)initWithDictionary:(GPBUInt32Int64Dictionary *)dictionary;
368 369 370 371 372 373 374 375

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
376 377
- (instancetype)initWithCapacity:(NSUInteger)numItems;

378 379 380 381 382 383 384 385
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
386
- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint32_t)key;
387

388 389 390 391 392 393 394 395
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
396
- (void)enumerateKeysAndInt64sUsingBlock:
397 398
    (void (^)(uint32_t key, int64_t value, BOOL *stop))block;

399 400 401 402 403 404
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
405 406
- (void)addEntriesFromDictionary:(GPBUInt32Int64Dictionary *)otherDictionary;

407 408 409 410 411 412
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
413
- (void)setInt64:(int64_t)value forKey:(uint32_t)key;
414

415 416 417 418 419
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
420
- (void)removeInt64ForKey:(uint32_t)aKey;
421 422 423 424

/**
 * Removes all entries in this dictionary.
 **/
425 426 427 428 429 430
- (void)removeAll;

@end

#pragma mark - UInt32 -> Bool

431 432 433 434 435 436
/**
 * Class used for map fields of <uint32_t, BOOL>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
437 438
@interface GPBUInt32BoolDictionary : NSObject <NSCopying>

439
/** Number of entries stored in this dictionary. */
440 441
@property(nonatomic, readonly) NSUInteger count;

442 443 444 445 446 447 448 449 450
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
451 452
- (instancetype)initWithBools:(const BOOL [__nullable])values
                      forKeys:(const uint32_t [__nullable])keys
453
                        count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
454 455 456 457 458 459 460 461

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
462
- (instancetype)initWithDictionary:(GPBUInt32BoolDictionary *)dictionary;
463 464 465 466 467 468 469 470

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
471 472
- (instancetype)initWithCapacity:(NSUInteger)numItems;

473 474 475 476 477 478 479 480
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
481
- (BOOL)getBool:(nullable BOOL *)value forKey:(uint32_t)key;
482

483 484 485 486 487 488 489 490
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
491
- (void)enumerateKeysAndBoolsUsingBlock:
492 493
    (void (^)(uint32_t key, BOOL value, BOOL *stop))block;

494 495 496 497 498 499
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
500 501
- (void)addEntriesFromDictionary:(GPBUInt32BoolDictionary *)otherDictionary;

502 503 504 505 506 507
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
508
- (void)setBool:(BOOL)value forKey:(uint32_t)key;
509

510 511 512 513 514
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
515
- (void)removeBoolForKey:(uint32_t)aKey;
516 517 518 519

/**
 * Removes all entries in this dictionary.
 **/
520 521 522 523 524 525
- (void)removeAll;

@end

#pragma mark - UInt32 -> Float

526 527 528 529 530 531
/**
 * Class used for map fields of <uint32_t, float>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
532 533
@interface GPBUInt32FloatDictionary : NSObject <NSCopying>

534
/** Number of entries stored in this dictionary. */
535 536
@property(nonatomic, readonly) NSUInteger count;

537 538 539 540 541 542 543 544 545
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
546 547
- (instancetype)initWithFloats:(const float [__nullable])values
                       forKeys:(const uint32_t [__nullable])keys
548
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
549 550 551 552 553 554 555 556

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
557
- (instancetype)initWithDictionary:(GPBUInt32FloatDictionary *)dictionary;
558 559 560 561 562 563 564 565

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
566 567
- (instancetype)initWithCapacity:(NSUInteger)numItems;

568 569 570 571 572 573 574 575
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
576
- (BOOL)getFloat:(nullable float *)value forKey:(uint32_t)key;
577

578 579 580 581 582 583 584 585
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
586
- (void)enumerateKeysAndFloatsUsingBlock:
587 588
    (void (^)(uint32_t key, float value, BOOL *stop))block;

589 590 591 592 593 594
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
595 596
- (void)addEntriesFromDictionary:(GPBUInt32FloatDictionary *)otherDictionary;

597 598 599 600 601 602
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
603
- (void)setFloat:(float)value forKey:(uint32_t)key;
604

605 606 607 608 609
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
610
- (void)removeFloatForKey:(uint32_t)aKey;
611 612 613 614

/**
 * Removes all entries in this dictionary.
 **/
615 616 617 618 619 620
- (void)removeAll;

@end

#pragma mark - UInt32 -> Double

621 622 623 624 625 626
/**
 * Class used for map fields of <uint32_t, double>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
627 628
@interface GPBUInt32DoubleDictionary : NSObject <NSCopying>

629
/** Number of entries stored in this dictionary. */
630 631
@property(nonatomic, readonly) NSUInteger count;

632 633 634 635 636 637 638 639 640
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
641 642
- (instancetype)initWithDoubles:(const double [__nullable])values
                        forKeys:(const uint32_t [__nullable])keys
643
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
644 645 646 647 648 649 650 651

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
652
- (instancetype)initWithDictionary:(GPBUInt32DoubleDictionary *)dictionary;
653 654 655 656 657 658 659 660

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
661 662
- (instancetype)initWithCapacity:(NSUInteger)numItems;

663 664 665 666 667 668 669 670
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
671
- (BOOL)getDouble:(nullable double *)value forKey:(uint32_t)key;
672

673 674 675 676 677 678 679 680
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
681
- (void)enumerateKeysAndDoublesUsingBlock:
682 683
    (void (^)(uint32_t key, double value, BOOL *stop))block;

684 685 686 687 688 689
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
690 691
- (void)addEntriesFromDictionary:(GPBUInt32DoubleDictionary *)otherDictionary;

692 693 694 695 696 697
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
698
- (void)setDouble:(double)value forKey:(uint32_t)key;
699

700 701 702 703 704
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
705
- (void)removeDoubleForKey:(uint32_t)aKey;
706 707 708 709

/**
 * Removes all entries in this dictionary.
 **/
710 711 712 713 714 715
- (void)removeAll;

@end

#pragma mark - UInt32 -> Enum

716 717 718 719 720 721
/**
 * Class used for map fields of <uint32_t, int32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
722 723
@interface GPBUInt32EnumDictionary : NSObject <NSCopying>

724
/** Number of entries stored in this dictionary. */
725
@property(nonatomic, readonly) NSUInteger count;
726
/** The validation function to check if the enums are valid. */
727 728
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;

729 730 731 732 733 734 735
/**
 * Initializes a dictionary with the given validation function.
 *
 * @param func The enum validation function for the dictionary.
 *
 * @return A newly initialized dictionary.
 **/
736
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
737 738 739 740 741 742 743 744 745 746 747

/**
 * Initializes a dictionary with the entries given.
 *
 * @param func   The enum validation function for the dictionary.
 * @param values The raw enum values values to be placed in the dictionary.
 * @param keys   The keys under which to store the values.
 * @param count  The number of entries to store in the dictionary.
 *
 * @return A newly initialized dictionary with the keys and values in it.
 **/
748
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
749 750
                                 rawValues:(const int32_t [__nullable])values
                                   forKeys:(const uint32_t [__nullable])keys
751
                                     count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
752 753 754 755 756 757 758 759 760 761

/**
 * Initializes a dictionary with the entries from the given.
 * dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to the dictionary.
 *
 * @return A newly initialized dictionary with the entries from the given
 *         dictionary in it.
 **/
762
- (instancetype)initWithDictionary:(GPBUInt32EnumDictionary *)dictionary;
763 764 765 766 767 768 769 770 771

/**
 * Initializes a dictionary with the given capacity.
 *
 * @param func     The enum validation function for the dictionary.
 * @param numItems Capacity needed for the dictionary.
 *
 * @return A newly initialized dictionary with the given capacity.
 **/
772
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
773 774 775 776 777 778
                                  capacity:(NSUInteger)numItems;

// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
// is not a valid enumerator as defined by validationFunc. If the actual value is
// desired, use "raw" version of the method.

779 780 781 782 783 784 785 786
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
787
- (BOOL)getEnum:(nullable int32_t *)value forKey:(uint32_t)key;
788

789 790 791 792 793 794 795 796
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
797
- (void)enumerateKeysAndEnumsUsingBlock:
798 799
    (void (^)(uint32_t key, int32_t value, BOOL *stop))block;

800 801 802 803 804 805 806 807 808 809 810
/**
 * Gets the raw enum value for the given key.
 *
 * @note This method bypass the validationFunc to enable the access of values that
 *       were not known at the time the binary was compiled.
 *
 * @param rawValue Pointer into which the value will be set, if found.
 * @param key      Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
811
- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint32_t)key;
812

813 814 815 816 817 818 819 820 821 822 823
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @note This method bypass the validationFunc to enable the access of values that
 *       were not known at the time the binary was compiled.
 *
 * @param block The block to enumerate with.
 *   **key**:      The key for the current entry.
 *   **rawValue**: The value for the current entry
 *   **stop**:     A pointer to a boolean that when set stops the enumeration.
 **/
824 825 826
- (void)enumerateKeysAndRawValuesUsingBlock:
    (void (^)(uint32_t key, int32_t rawValue, BOOL *stop))block;

827 828 829 830 831 832 833 834 835
/**
 * Adds the keys and raw enum values from another dictionary.
 *
 * @note This method bypass the validationFunc to enable the setting of values that
 *       were not known at the time the binary was compiled.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
836 837 838 839 840 841 842
- (void)addRawEntriesFromDictionary:(GPBUInt32EnumDictionary *)otherDictionary;

// If value is not a valid enumerator as defined by validationFunc, these
// methods will assert in debug, and will log in release and assign the value
// to the default value. Use the rawValue methods below to assign non enumerator
// values.

843 844 845 846 847 848
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
849
- (void)setEnum:(int32_t)value forKey:(uint32_t)key;
850

851 852 853 854 855 856 857 858 859
/**
 * Sets the raw enum value for the given key.
 *
 * @note This method bypass the validationFunc to enable the setting of values that
 *       were not known at the time the binary was compiled.
 *
 * @param rawValue The raw enum value to set.
 * @param key      The key under which to store the raw enum value.
 **/
860 861
- (void)setRawValue:(int32_t)rawValue forKey:(uint32_t)key;

862 863 864 865 866
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
867
- (void)removeEnumForKey:(uint32_t)aKey;
868 869 870 871

/**
 * Removes all entries in this dictionary.
 **/
872 873 874 875 876 877
- (void)removeAll;

@end

#pragma mark - UInt32 -> Object

878 879 880 881 882 883
/**
 * Class used for map fields of <uint32_t, ObjectType>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
884
@interface GPBUInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
885

886
/** Number of entries stored in this dictionary. */
887 888
@property(nonatomic, readonly) NSUInteger count;

889
/**
890
 * Initializes this dictionary, copying the given values and keys.
891
 *
892 893 894
 * @param objects      The values to be placed in this dictionary.
 * @param keys         The keys under which to store the values.
 * @param count        The number of elements to copy into the dictionary.
895
 *
896
 * @return A newly initialized dictionary with a copy of the values and keys.
897
 **/
898 899 900
- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
                        forKeys:(const uint32_t [__nullable])keys
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
901 902

/**
903
 * Initializes this dictionary, copying the entries from the given dictionary.
904 905 906 907 908
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
909
- (instancetype)initWithDictionary:(GPBUInt32ObjectDictionary *)dictionary;
910 911 912 913 914 915 916 917

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
918 919
- (instancetype)initWithCapacity:(NSUInteger)numItems;

920 921 922 923 924 925 926
/**
 * Fetches the object stored under the given key.
 *
 * @param key Key under which the value is stored, if present.
 *
 * @return The object if found, nil otherwise.
 **/
927
- (ObjectType)objectForKey:(uint32_t)key;
928

929 930 931 932 933 934 935 936
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:         The key for the current entry.
 *   **object**:      The value for the current entry
 *   **stop**:        A pointer to a boolean that when set stops the enumeration.
 **/
937
- (void)enumerateKeysAndObjectsUsingBlock:
938
    (void (^)(uint32_t key, ObjectType object, BOOL *stop))block;
939

940 941 942 943 944 945
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
946 947
- (void)addEntriesFromDictionary:(GPBUInt32ObjectDictionary *)otherDictionary;

948 949 950 951 952 953
/**
 * Sets the value for the given key.
 *
 * @param object     The value to set.
 * @param key        The key under which to store the value.
 **/
954
- (void)setObject:(ObjectType)object forKey:(uint32_t)key;
955

956 957 958 959 960
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
961
- (void)removeObjectForKey:(uint32_t)aKey;
962 963 964 965

/**
 * Removes all entries in this dictionary.
 **/
966 967 968 969 970 971
- (void)removeAll;

@end

#pragma mark - Int32 -> UInt32

972 973 974 975 976 977
/**
 * Class used for map fields of <int32_t, uint32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
978 979
@interface GPBInt32UInt32Dictionary : NSObject <NSCopying>

980
/** Number of entries stored in this dictionary. */
981 982
@property(nonatomic, readonly) NSUInteger count;

983 984 985 986 987 988 989 990 991
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
992 993
- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
                        forKeys:(const int32_t [__nullable])keys
994
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
995 996 997 998 999 1000 1001 1002

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
1003
- (instancetype)initWithDictionary:(GPBInt32UInt32Dictionary *)dictionary;
1004 1005 1006 1007 1008 1009 1010 1011

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
1012 1013
- (instancetype)initWithCapacity:(NSUInteger)numItems;

1014 1015 1016 1017 1018 1019 1020 1021
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
1022
- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int32_t)key;
1023

1024 1025 1026 1027 1028 1029 1030 1031
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
1032
- (void)enumerateKeysAndUInt32sUsingBlock:
1033 1034
    (void (^)(int32_t key, uint32_t value, BOOL *stop))block;

1035 1036 1037 1038 1039 1040
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
1041 1042
- (void)addEntriesFromDictionary:(GPBInt32UInt32Dictionary *)otherDictionary;

1043 1044 1045 1046 1047 1048
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
1049
- (void)setUInt32:(uint32_t)value forKey:(int32_t)key;
1050

1051 1052 1053 1054 1055
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
1056
- (void)removeUInt32ForKey:(int32_t)aKey;
1057 1058 1059 1060

/**
 * Removes all entries in this dictionary.
 **/
1061 1062 1063 1064 1065 1066
- (void)removeAll;

@end

#pragma mark - Int32 -> Int32

1067 1068 1069 1070 1071 1072
/**
 * Class used for map fields of <int32_t, int32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
1073 1074
@interface GPBInt32Int32Dictionary : NSObject <NSCopying>

1075
/** Number of entries stored in this dictionary. */
1076 1077
@property(nonatomic, readonly) NSUInteger count;

1078 1079 1080 1081 1082 1083 1084 1085 1086
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
1087 1088
- (instancetype)initWithInt32s:(const int32_t [__nullable])values
                       forKeys:(const int32_t [__nullable])keys
1089
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
1090 1091 1092 1093 1094 1095 1096 1097

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
1098
- (instancetype)initWithDictionary:(GPBInt32Int32Dictionary *)dictionary;
1099 1100 1101 1102 1103 1104 1105 1106

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
1107 1108
- (instancetype)initWithCapacity:(NSUInteger)numItems;

1109 1110 1111 1112 1113 1114 1115 1116
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
1117
- (BOOL)getInt32:(nullable int32_t *)value forKey:(int32_t)key;
1118

1119 1120 1121 1122 1123 1124 1125 1126
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
1127
- (void)enumerateKeysAndInt32sUsingBlock:
1128 1129
    (void (^)(int32_t key, int32_t value, BOOL *stop))block;

1130 1131 1132 1133 1134 1135
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
1136 1137
- (void)addEntriesFromDictionary:(GPBInt32Int32Dictionary *)otherDictionary;

1138 1139 1140 1141 1142 1143
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
1144
- (void)setInt32:(int32_t)value forKey:(int32_t)key;
1145

1146 1147 1148 1149 1150
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
1151
- (void)removeInt32ForKey:(int32_t)aKey;
1152 1153 1154 1155

/**
 * Removes all entries in this dictionary.
 **/
1156 1157 1158 1159 1160 1161
- (void)removeAll;

@end

#pragma mark - Int32 -> UInt64

1162 1163 1164 1165 1166 1167
/**
 * Class used for map fields of <int32_t, uint64_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
1168 1169
@interface GPBInt32UInt64Dictionary : NSObject <NSCopying>

1170
/** Number of entries stored in this dictionary. */
1171 1172
@property(nonatomic, readonly) NSUInteger count;

1173 1174 1175 1176 1177 1178 1179 1180 1181
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
1182 1183
- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
                        forKeys:(const int32_t [__nullable])keys
1184
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
1185 1186 1187 1188 1189 1190 1191 1192

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
1193
- (instancetype)initWithDictionary:(GPBInt32UInt64Dictionary *)dictionary;
1194 1195 1196 1197 1198 1199 1200 1201

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
1202 1203
- (instancetype)initWithCapacity:(NSUInteger)numItems;

1204 1205 1206 1207 1208 1209 1210 1211
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
1212
- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int32_t)key;
1213

1214 1215 1216 1217 1218 1219 1220 1221
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
1222
- (void)enumerateKeysAndUInt64sUsingBlock:
1223 1224
    (void (^)(int32_t key, uint64_t value, BOOL *stop))block;

1225 1226 1227 1228 1229 1230
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
1231 1232
- (void)addEntriesFromDictionary:(GPBInt32UInt64Dictionary *)otherDictionary;

1233 1234 1235 1236 1237 1238
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
1239
- (void)setUInt64:(uint64_t)value forKey:(int32_t)key;
1240

1241 1242 1243 1244 1245
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
1246
- (void)removeUInt64ForKey:(int32_t)aKey;
1247 1248 1249 1250

/**
 * Removes all entries in this dictionary.
 **/
1251 1252 1253 1254 1255 1256
- (void)removeAll;

@end

#pragma mark - Int32 -> Int64

1257 1258 1259 1260 1261 1262
/**
 * Class used for map fields of <int32_t, int64_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
1263 1264
@interface GPBInt32Int64Dictionary : NSObject <NSCopying>

1265
/** Number of entries stored in this dictionary. */
1266 1267
@property(nonatomic, readonly) NSUInteger count;

1268 1269 1270 1271 1272 1273 1274 1275 1276
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
1277 1278
- (instancetype)initWithInt64s:(const int64_t [__nullable])values
                       forKeys:(const int32_t [__nullable])keys
1279
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
1280 1281 1282 1283 1284 1285 1286 1287

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
1288
- (instancetype)initWithDictionary:(GPBInt32Int64Dictionary *)dictionary;
1289 1290 1291 1292 1293 1294 1295 1296

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
1297 1298
- (instancetype)initWithCapacity:(NSUInteger)numItems;

1299 1300 1301 1302 1303 1304 1305 1306
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
1307
- (BOOL)getInt64:(nullable int64_t *)value forKey:(int32_t)key;
1308

1309 1310 1311 1312 1313 1314 1315 1316
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
1317
- (void)enumerateKeysAndInt64sUsingBlock:
1318 1319
    (void (^)(int32_t key, int64_t value, BOOL *stop))block;

1320 1321 1322 1323 1324 1325
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
1326 1327
- (void)addEntriesFromDictionary:(GPBInt32Int64Dictionary *)otherDictionary;

1328 1329 1330 1331 1332 1333
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
1334
- (void)setInt64:(int64_t)value forKey:(int32_t)key;
1335

1336 1337 1338 1339 1340
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
1341
- (void)removeInt64ForKey:(int32_t)aKey;
1342 1343 1344 1345

/**
 * Removes all entries in this dictionary.
 **/
1346 1347 1348 1349 1350 1351
- (void)removeAll;

@end

#pragma mark - Int32 -> Bool

1352 1353 1354 1355 1356 1357
/**
 * Class used for map fields of <int32_t, BOOL>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
1358 1359
@interface GPBInt32BoolDictionary : NSObject <NSCopying>

1360
/** Number of entries stored in this dictionary. */
1361 1362
@property(nonatomic, readonly) NSUInteger count;

1363 1364 1365 1366 1367 1368 1369 1370 1371
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
1372 1373
- (instancetype)initWithBools:(const BOOL [__nullable])values
                      forKeys:(const int32_t [__nullable])keys
1374
                        count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
1375 1376 1377 1378 1379 1380 1381 1382

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
1383
- (instancetype)initWithDictionary:(GPBInt32BoolDictionary *)dictionary;
1384 1385 1386 1387 1388 1389 1390 1391

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
1392 1393
- (instancetype)initWithCapacity:(NSUInteger)numItems;

1394 1395 1396 1397 1398 1399 1400 1401
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
1402
- (BOOL)getBool:(nullable BOOL *)value forKey:(int32_t)key;
1403

1404 1405 1406 1407 1408 1409 1410 1411
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
1412
- (void)enumerateKeysAndBoolsUsingBlock:
1413 1414
    (void (^)(int32_t key, BOOL value, BOOL *stop))block;

1415 1416 1417 1418 1419 1420
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
1421 1422
- (void)addEntriesFromDictionary:(GPBInt32BoolDictionary *)otherDictionary;

1423 1424 1425 1426 1427 1428
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
1429
- (void)setBool:(BOOL)value forKey:(int32_t)key;
1430

1431 1432 1433 1434 1435
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
1436
- (void)removeBoolForKey:(int32_t)aKey;
1437 1438 1439 1440

/**
 * Removes all entries in this dictionary.
 **/
1441 1442 1443 1444 1445 1446
- (void)removeAll;

@end

#pragma mark - Int32 -> Float

1447 1448 1449 1450 1451 1452
/**
 * Class used for map fields of <int32_t, float>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
1453 1454
@interface GPBInt32FloatDictionary : NSObject <NSCopying>

1455
/** Number of entries stored in this dictionary. */
1456 1457
@property(nonatomic, readonly) NSUInteger count;

1458 1459 1460 1461 1462 1463 1464 1465 1466
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
1467 1468
- (instancetype)initWithFloats:(const float [__nullable])values
                       forKeys:(const int32_t [__nullable])keys
1469
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
1470 1471 1472 1473 1474 1475 1476 1477

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
1478
- (instancetype)initWithDictionary:(GPBInt32FloatDictionary *)dictionary;
1479 1480 1481 1482 1483 1484 1485 1486

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
1487 1488
- (instancetype)initWithCapacity:(NSUInteger)numItems;

1489 1490 1491 1492 1493 1494 1495 1496
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
1497
- (BOOL)getFloat:(nullable float *)value forKey:(int32_t)key;
1498

1499 1500 1501 1502 1503 1504 1505 1506
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
1507
- (void)enumerateKeysAndFloatsUsingBlock:
1508 1509
    (void (^)(int32_t key, float value, BOOL *stop))block;

1510 1511 1512 1513 1514 1515
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
1516 1517
- (void)addEntriesFromDictionary:(GPBInt32FloatDictionary *)otherDictionary;

1518 1519 1520 1521 1522 1523
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
1524
- (void)setFloat:(float)value forKey:(int32_t)key;
1525

1526 1527 1528 1529 1530
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
1531
- (void)removeFloatForKey:(int32_t)aKey;
1532 1533 1534 1535

/**
 * Removes all entries in this dictionary.
 **/
1536 1537 1538 1539 1540 1541
- (void)removeAll;

@end

#pragma mark - Int32 -> Double

1542 1543 1544 1545 1546 1547
/**
 * Class used for map fields of <int32_t, double>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
1548 1549
@interface GPBInt32DoubleDictionary : NSObject <NSCopying>

1550
/** Number of entries stored in this dictionary. */
1551 1552
@property(nonatomic, readonly) NSUInteger count;

1553 1554 1555 1556 1557 1558 1559 1560 1561
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
1562 1563
- (instancetype)initWithDoubles:(const double [__nullable])values
                        forKeys:(const int32_t [__nullable])keys
1564
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
1565 1566 1567 1568 1569 1570 1571 1572

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
1573
- (instancetype)initWithDictionary:(GPBInt32DoubleDictionary *)dictionary;
1574 1575 1576 1577 1578 1579 1580 1581

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
1582 1583
- (instancetype)initWithCapacity:(NSUInteger)numItems;

1584 1585 1586 1587 1588 1589 1590 1591
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
1592
- (BOOL)getDouble:(nullable double *)value forKey:(int32_t)key;
1593

1594 1595 1596 1597 1598 1599 1600 1601
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
1602
- (void)enumerateKeysAndDoublesUsingBlock:
1603 1604
    (void (^)(int32_t key, double value, BOOL *stop))block;

1605 1606 1607 1608 1609 1610
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
1611 1612
- (void)addEntriesFromDictionary:(GPBInt32DoubleDictionary *)otherDictionary;

1613 1614 1615 1616 1617 1618
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
1619
- (void)setDouble:(double)value forKey:(int32_t)key;
1620

1621 1622 1623 1624 1625
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
1626
- (void)removeDoubleForKey:(int32_t)aKey;
1627 1628 1629 1630

/**
 * Removes all entries in this dictionary.
 **/
1631 1632 1633 1634 1635 1636
- (void)removeAll;

@end

#pragma mark - Int32 -> Enum

1637 1638 1639 1640 1641 1642
/**
 * Class used for map fields of <int32_t, int32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
1643 1644
@interface GPBInt32EnumDictionary : NSObject <NSCopying>

1645
/** Number of entries stored in this dictionary. */
1646
@property(nonatomic, readonly) NSUInteger count;
1647
/** The validation function to check if the enums are valid. */
1648 1649
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;

1650 1651 1652 1653 1654 1655 1656
/**
 * Initializes a dictionary with the given validation function.
 *
 * @param func The enum validation function for the dictionary.
 *
 * @return A newly initialized dictionary.
 **/
1657
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668

/**
 * Initializes a dictionary with the entries given.
 *
 * @param func   The enum validation function for the dictionary.
 * @param values The raw enum values values to be placed in the dictionary.
 * @param keys   The keys under which to store the values.
 * @param count  The number of entries to store in the dictionary.
 *
 * @return A newly initialized dictionary with the keys and values in it.
 **/
1669
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
1670 1671
                                 rawValues:(const int32_t [__nullable])values
                                   forKeys:(const int32_t [__nullable])keys
1672
                                     count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
1673 1674 1675 1676 1677 1678 1679 1680 1681 1682

/**
 * Initializes a dictionary with the entries from the given.
 * dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to the dictionary.
 *
 * @return A newly initialized dictionary with the entries from the given
 *         dictionary in it.
 **/
1683
- (instancetype)initWithDictionary:(GPBInt32EnumDictionary *)dictionary;
1684 1685 1686 1687 1688 1689 1690 1691 1692

/**
 * Initializes a dictionary with the given capacity.
 *
 * @param func     The enum validation function for the dictionary.
 * @param numItems Capacity needed for the dictionary.
 *
 * @return A newly initialized dictionary with the given capacity.
 **/
1693
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
1694 1695 1696 1697 1698 1699
                                  capacity:(NSUInteger)numItems;

// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
// is not a valid enumerator as defined by validationFunc. If the actual value is
// desired, use "raw" version of the method.

1700 1701 1702 1703 1704 1705 1706 1707
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
1708
- (BOOL)getEnum:(nullable int32_t *)value forKey:(int32_t)key;
1709

1710 1711 1712 1713 1714 1715 1716 1717
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
1718
- (void)enumerateKeysAndEnumsUsingBlock:
1719 1720
    (void (^)(int32_t key, int32_t value, BOOL *stop))block;

1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731
/**
 * Gets the raw enum value for the given key.
 *
 * @note This method bypass the validationFunc to enable the access of values that
 *       were not known at the time the binary was compiled.
 *
 * @param rawValue Pointer into which the value will be set, if found.
 * @param key      Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
1732
- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int32_t)key;
1733

1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @note This method bypass the validationFunc to enable the access of values that
 *       were not known at the time the binary was compiled.
 *
 * @param block The block to enumerate with.
 *   **key**:      The key for the current entry.
 *   **rawValue**: The value for the current entry
 *   **stop**:     A pointer to a boolean that when set stops the enumeration.
 **/
1745 1746 1747
- (void)enumerateKeysAndRawValuesUsingBlock:
    (void (^)(int32_t key, int32_t rawValue, BOOL *stop))block;

1748 1749 1750 1751 1752 1753 1754 1755 1756
/**
 * Adds the keys and raw enum values from another dictionary.
 *
 * @note This method bypass the validationFunc to enable the setting of values that
 *       were not known at the time the binary was compiled.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
1757 1758 1759 1760 1761 1762 1763
- (void)addRawEntriesFromDictionary:(GPBInt32EnumDictionary *)otherDictionary;

// If value is not a valid enumerator as defined by validationFunc, these
// methods will assert in debug, and will log in release and assign the value
// to the default value. Use the rawValue methods below to assign non enumerator
// values.

1764 1765 1766 1767 1768 1769
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
1770
- (void)setEnum:(int32_t)value forKey:(int32_t)key;
1771

1772 1773 1774 1775 1776 1777 1778 1779 1780
/**
 * Sets the raw enum value for the given key.
 *
 * @note This method bypass the validationFunc to enable the setting of values that
 *       were not known at the time the binary was compiled.
 *
 * @param rawValue The raw enum value to set.
 * @param key      The key under which to store the raw enum value.
 **/
1781 1782
- (void)setRawValue:(int32_t)rawValue forKey:(int32_t)key;

1783 1784 1785 1786 1787
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
1788
- (void)removeEnumForKey:(int32_t)aKey;
1789 1790 1791 1792

/**
 * Removes all entries in this dictionary.
 **/
1793 1794 1795 1796 1797 1798
- (void)removeAll;

@end

#pragma mark - Int32 -> Object

1799 1800 1801 1802 1803 1804
/**
 * Class used for map fields of <int32_t, ObjectType>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
1805
@interface GPBInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
1806

1807
/** Number of entries stored in this dictionary. */
1808 1809
@property(nonatomic, readonly) NSUInteger count;

1810 1811 1812 1813 1814 1815 1816 1817 1818
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param objects      The values to be placed in this dictionary.
 * @param keys         The keys under which to store the values.
 * @param count        The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
1819 1820
- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
                        forKeys:(const int32_t [__nullable])keys
1821
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
1822 1823 1824 1825 1826 1827 1828 1829

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
1830
- (instancetype)initWithDictionary:(GPBInt32ObjectDictionary *)dictionary;
1831 1832 1833 1834 1835 1836 1837 1838

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
1839 1840
- (instancetype)initWithCapacity:(NSUInteger)numItems;

1841 1842 1843 1844 1845 1846 1847
/**
 * Fetches the object stored under the given key.
 *
 * @param key Key under which the value is stored, if present.
 *
 * @return The object if found, nil otherwise.
 **/
1848
- (ObjectType)objectForKey:(int32_t)key;
1849

1850 1851 1852 1853 1854 1855 1856 1857
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:         The key for the current entry.
 *   **object**:      The value for the current entry
 *   **stop**:        A pointer to a boolean that when set stops the enumeration.
 **/
1858
- (void)enumerateKeysAndObjectsUsingBlock:
1859
    (void (^)(int32_t key, ObjectType object, BOOL *stop))block;
1860

1861 1862 1863 1864 1865 1866
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
1867 1868
- (void)addEntriesFromDictionary:(GPBInt32ObjectDictionary *)otherDictionary;

1869 1870 1871 1872 1873 1874
/**
 * Sets the value for the given key.
 *
 * @param object     The value to set.
 * @param key        The key under which to store the value.
 **/
1875
- (void)setObject:(ObjectType)object forKey:(int32_t)key;
1876

1877 1878 1879 1880 1881
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
1882
- (void)removeObjectForKey:(int32_t)aKey;
1883 1884 1885 1886

/**
 * Removes all entries in this dictionary.
 **/
1887 1888 1889 1890 1891 1892
- (void)removeAll;

@end

#pragma mark - UInt64 -> UInt32

1893 1894 1895 1896 1897 1898
/**
 * Class used for map fields of <uint64_t, uint32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
1899 1900
@interface GPBUInt64UInt32Dictionary : NSObject <NSCopying>

1901
/** Number of entries stored in this dictionary. */
1902 1903
@property(nonatomic, readonly) NSUInteger count;

1904 1905 1906 1907 1908 1909 1910 1911 1912
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
1913 1914
- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
                        forKeys:(const uint64_t [__nullable])keys
1915
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
1916 1917 1918 1919 1920 1921 1922 1923

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
1924
- (instancetype)initWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary;
1925 1926 1927 1928 1929 1930 1931 1932

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
1933 1934
- (instancetype)initWithCapacity:(NSUInteger)numItems;

1935 1936 1937 1938 1939 1940 1941 1942
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
1943
- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint64_t)key;
1944

1945 1946 1947 1948 1949 1950 1951 1952
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
1953
- (void)enumerateKeysAndUInt32sUsingBlock:
1954 1955
    (void (^)(uint64_t key, uint32_t value, BOOL *stop))block;

1956 1957 1958 1959 1960 1961
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
1962 1963
- (void)addEntriesFromDictionary:(GPBUInt64UInt32Dictionary *)otherDictionary;

1964 1965 1966 1967 1968 1969
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
1970
- (void)setUInt32:(uint32_t)value forKey:(uint64_t)key;
1971

1972 1973 1974 1975 1976
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
1977
- (void)removeUInt32ForKey:(uint64_t)aKey;
1978 1979 1980 1981

/**
 * Removes all entries in this dictionary.
 **/
1982 1983 1984 1985 1986 1987
- (void)removeAll;

@end

#pragma mark - UInt64 -> Int32

1988 1989 1990 1991 1992 1993
/**
 * Class used for map fields of <uint64_t, int32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
1994 1995
@interface GPBUInt64Int32Dictionary : NSObject <NSCopying>

1996
/** Number of entries stored in this dictionary. */
1997 1998
@property(nonatomic, readonly) NSUInteger count;

1999 2000 2001 2002 2003 2004 2005 2006 2007
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
2008 2009
- (instancetype)initWithInt32s:(const int32_t [__nullable])values
                       forKeys:(const uint64_t [__nullable])keys
2010
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
2011 2012 2013 2014 2015 2016 2017 2018

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
2019
- (instancetype)initWithDictionary:(GPBUInt64Int32Dictionary *)dictionary;
2020 2021 2022 2023 2024 2025 2026 2027

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
2028 2029
- (instancetype)initWithCapacity:(NSUInteger)numItems;

2030 2031 2032 2033 2034 2035 2036 2037
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
2038
- (BOOL)getInt32:(nullable int32_t *)value forKey:(uint64_t)key;
2039

2040 2041 2042 2043 2044 2045 2046 2047
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
2048
- (void)enumerateKeysAndInt32sUsingBlock:
2049 2050
    (void (^)(uint64_t key, int32_t value, BOOL *stop))block;

2051 2052 2053 2054 2055 2056
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
2057 2058
- (void)addEntriesFromDictionary:(GPBUInt64Int32Dictionary *)otherDictionary;

2059 2060 2061 2062 2063 2064
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
2065
- (void)setInt32:(int32_t)value forKey:(uint64_t)key;
2066

2067 2068 2069 2070 2071
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
2072
- (void)removeInt32ForKey:(uint64_t)aKey;
2073 2074 2075 2076

/**
 * Removes all entries in this dictionary.
 **/
2077 2078 2079 2080 2081 2082
- (void)removeAll;

@end

#pragma mark - UInt64 -> UInt64

2083 2084 2085 2086 2087 2088
/**
 * Class used for map fields of <uint64_t, uint64_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
2089 2090
@interface GPBUInt64UInt64Dictionary : NSObject <NSCopying>

2091
/** Number of entries stored in this dictionary. */
2092 2093
@property(nonatomic, readonly) NSUInteger count;

2094 2095 2096 2097 2098 2099 2100 2101 2102
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
2103 2104
- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
                        forKeys:(const uint64_t [__nullable])keys
2105
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
2106 2107 2108 2109 2110 2111 2112 2113

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
2114
- (instancetype)initWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary;
2115 2116 2117 2118 2119 2120 2121 2122

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
2123 2124
- (instancetype)initWithCapacity:(NSUInteger)numItems;

2125 2126 2127 2128 2129 2130 2131 2132
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
2133
- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint64_t)key;
2134

2135 2136 2137 2138 2139 2140 2141 2142
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
2143
- (void)enumerateKeysAndUInt64sUsingBlock:
2144 2145
    (void (^)(uint64_t key, uint64_t value, BOOL *stop))block;

2146 2147 2148 2149 2150 2151
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
2152 2153
- (void)addEntriesFromDictionary:(GPBUInt64UInt64Dictionary *)otherDictionary;

2154 2155 2156 2157 2158 2159
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
2160
- (void)setUInt64:(uint64_t)value forKey:(uint64_t)key;
2161

2162 2163 2164 2165 2166
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
2167
- (void)removeUInt64ForKey:(uint64_t)aKey;
2168 2169 2170 2171

/**
 * Removes all entries in this dictionary.
 **/
2172 2173 2174 2175 2176 2177
- (void)removeAll;

@end

#pragma mark - UInt64 -> Int64

2178 2179 2180 2181 2182 2183
/**
 * Class used for map fields of <uint64_t, int64_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
2184 2185
@interface GPBUInt64Int64Dictionary : NSObject <NSCopying>

2186
/** Number of entries stored in this dictionary. */
2187 2188
@property(nonatomic, readonly) NSUInteger count;

2189 2190 2191 2192 2193 2194 2195 2196 2197
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
2198 2199
- (instancetype)initWithInt64s:(const int64_t [__nullable])values
                       forKeys:(const uint64_t [__nullable])keys
2200
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
2201 2202 2203 2204 2205 2206 2207 2208

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
2209
- (instancetype)initWithDictionary:(GPBUInt64Int64Dictionary *)dictionary;
2210 2211 2212 2213 2214 2215 2216 2217

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
2218 2219
- (instancetype)initWithCapacity:(NSUInteger)numItems;

2220 2221 2222 2223 2224 2225 2226 2227
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
2228
- (BOOL)getInt64:(nullable int64_t *)value forKey:(uint64_t)key;
2229

2230 2231 2232 2233 2234 2235 2236 2237
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
2238
- (void)enumerateKeysAndInt64sUsingBlock:
2239 2240
    (void (^)(uint64_t key, int64_t value, BOOL *stop))block;

2241 2242 2243 2244 2245 2246
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
2247 2248
- (void)addEntriesFromDictionary:(GPBUInt64Int64Dictionary *)otherDictionary;

2249 2250 2251 2252 2253 2254
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
2255
- (void)setInt64:(int64_t)value forKey:(uint64_t)key;
2256

2257 2258 2259 2260 2261
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
2262
- (void)removeInt64ForKey:(uint64_t)aKey;
2263 2264 2265 2266

/**
 * Removes all entries in this dictionary.
 **/
2267 2268 2269 2270 2271 2272
- (void)removeAll;

@end

#pragma mark - UInt64 -> Bool

2273 2274 2275 2276 2277 2278
/**
 * Class used for map fields of <uint64_t, BOOL>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
2279 2280 2281 2282
@interface GPBUInt64BoolDictionary : NSObject <NSCopying>

/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
2283

2284 2285 2286 2287 2288 2289 2290 2291 2292
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
2293 2294
- (instancetype)initWithBools:(const BOOL [__nullable])values
                      forKeys:(const uint64_t [__nullable])keys
2295
                        count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
2296 2297 2298 2299 2300 2301 2302 2303

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
2304
- (instancetype)initWithDictionary:(GPBUInt64BoolDictionary *)dictionary;
2305 2306 2307 2308 2309 2310 2311 2312

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
2313 2314
- (instancetype)initWithCapacity:(NSUInteger)numItems;

2315 2316 2317 2318 2319 2320 2321 2322
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
2323
- (BOOL)getBool:(nullable BOOL *)value forKey:(uint64_t)key;
2324

2325 2326 2327 2328 2329 2330 2331 2332
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
2333
- (void)enumerateKeysAndBoolsUsingBlock:
2334 2335
    (void (^)(uint64_t key, BOOL value, BOOL *stop))block;

2336 2337 2338 2339 2340 2341
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
2342 2343
- (void)addEntriesFromDictionary:(GPBUInt64BoolDictionary *)otherDictionary;

2344 2345 2346 2347 2348 2349
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
2350
- (void)setBool:(BOOL)value forKey:(uint64_t)key;
2351

2352 2353 2354 2355 2356
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
2357
- (void)removeBoolForKey:(uint64_t)aKey;
2358 2359 2360 2361

/**
 * Removes all entries in this dictionary.
 **/
2362 2363 2364 2365 2366 2367
- (void)removeAll;

@end

#pragma mark - UInt64 -> Float

2368 2369 2370 2371 2372 2373
/**
 * Class used for map fields of <uint64_t, float>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
2374 2375
@interface GPBUInt64FloatDictionary : NSObject <NSCopying>

2376
/** Number of entries stored in this dictionary. */
2377 2378
@property(nonatomic, readonly) NSUInteger count;

2379 2380 2381 2382 2383 2384 2385 2386 2387
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
2388 2389
- (instancetype)initWithFloats:(const float [__nullable])values
                       forKeys:(const uint64_t [__nullable])keys
2390
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
2391 2392 2393 2394 2395 2396 2397 2398

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
2399
- (instancetype)initWithDictionary:(GPBUInt64FloatDictionary *)dictionary;
2400 2401 2402 2403 2404 2405 2406 2407

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
2408 2409
- (instancetype)initWithCapacity:(NSUInteger)numItems;

2410 2411 2412 2413 2414 2415 2416 2417
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
2418
- (BOOL)getFloat:(nullable float *)value forKey:(uint64_t)key;
2419

2420 2421 2422 2423 2424 2425 2426 2427
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
2428
- (void)enumerateKeysAndFloatsUsingBlock:
2429 2430
    (void (^)(uint64_t key, float value, BOOL *stop))block;

2431 2432 2433 2434 2435 2436
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
2437 2438
- (void)addEntriesFromDictionary:(GPBUInt64FloatDictionary *)otherDictionary;

2439 2440 2441 2442 2443 2444
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
2445
- (void)setFloat:(float)value forKey:(uint64_t)key;
2446

2447 2448 2449 2450 2451
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
2452
- (void)removeFloatForKey:(uint64_t)aKey;
2453 2454 2455 2456

/**
 * Removes all entries in this dictionary.
 **/
2457 2458 2459 2460 2461 2462
- (void)removeAll;

@end

#pragma mark - UInt64 -> Double

2463 2464 2465 2466 2467 2468
/**
 * Class used for map fields of <uint64_t, double>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
2469 2470
@interface GPBUInt64DoubleDictionary : NSObject <NSCopying>

2471
/** Number of entries stored in this dictionary. */
2472 2473
@property(nonatomic, readonly) NSUInteger count;

2474 2475 2476 2477 2478 2479 2480 2481 2482
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
2483 2484
- (instancetype)initWithDoubles:(const double [__nullable])values
                        forKeys:(const uint64_t [__nullable])keys
2485
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
2486 2487 2488 2489 2490 2491 2492 2493

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
2494
- (instancetype)initWithDictionary:(GPBUInt64DoubleDictionary *)dictionary;
2495 2496 2497 2498 2499 2500 2501 2502

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
2503 2504
- (instancetype)initWithCapacity:(NSUInteger)numItems;

2505 2506 2507 2508 2509 2510 2511 2512
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
2513
- (BOOL)getDouble:(nullable double *)value forKey:(uint64_t)key;
2514

2515 2516 2517 2518 2519 2520 2521 2522
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
2523
- (void)enumerateKeysAndDoublesUsingBlock:
2524 2525
    (void (^)(uint64_t key, double value, BOOL *stop))block;

2526 2527 2528 2529 2530 2531
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
2532 2533
- (void)addEntriesFromDictionary:(GPBUInt64DoubleDictionary *)otherDictionary;

2534 2535 2536 2537 2538 2539
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
2540
- (void)setDouble:(double)value forKey:(uint64_t)key;
2541

2542 2543 2544 2545 2546
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
2547
- (void)removeDoubleForKey:(uint64_t)aKey;
2548 2549 2550 2551

/**
 * Removes all entries in this dictionary.
 **/
2552 2553 2554 2555 2556 2557
- (void)removeAll;

@end

#pragma mark - UInt64 -> Enum

2558 2559 2560 2561 2562 2563
/**
 * Class used for map fields of <uint64_t, int32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
2564 2565
@interface GPBUInt64EnumDictionary : NSObject <NSCopying>

2566
/** Number of entries stored in this dictionary. */
2567
@property(nonatomic, readonly) NSUInteger count;
2568
/** The validation function to check if the enums are valid. */
2569 2570
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;

2571 2572 2573 2574 2575 2576 2577
/**
 * Initializes a dictionary with the given validation function.
 *
 * @param func The enum validation function for the dictionary.
 *
 * @return A newly initialized dictionary.
 **/
2578
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589

/**
 * Initializes a dictionary with the entries given.
 *
 * @param func   The enum validation function for the dictionary.
 * @param values The raw enum values values to be placed in the dictionary.
 * @param keys   The keys under which to store the values.
 * @param count  The number of entries to store in the dictionary.
 *
 * @return A newly initialized dictionary with the keys and values in it.
 **/
2590
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
2591 2592
                                 rawValues:(const int32_t [__nullable])values
                                   forKeys:(const uint64_t [__nullable])keys
2593
                                     count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
2594 2595 2596 2597 2598 2599 2600 2601 2602 2603

/**
 * Initializes a dictionary with the entries from the given.
 * dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to the dictionary.
 *
 * @return A newly initialized dictionary with the entries from the given
 *         dictionary in it.
 **/
2604
- (instancetype)initWithDictionary:(GPBUInt64EnumDictionary *)dictionary;
2605 2606 2607 2608 2609 2610 2611 2612 2613

/**
 * Initializes a dictionary with the given capacity.
 *
 * @param func     The enum validation function for the dictionary.
 * @param numItems Capacity needed for the dictionary.
 *
 * @return A newly initialized dictionary with the given capacity.
 **/
2614
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
2615 2616 2617 2618 2619 2620
                                  capacity:(NSUInteger)numItems;

// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
// is not a valid enumerator as defined by validationFunc. If the actual value is
// desired, use "raw" version of the method.

2621 2622 2623 2624 2625 2626 2627 2628
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
2629
- (BOOL)getEnum:(nullable int32_t *)value forKey:(uint64_t)key;
2630

2631 2632 2633 2634 2635 2636 2637 2638
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
2639
- (void)enumerateKeysAndEnumsUsingBlock:
2640 2641
    (void (^)(uint64_t key, int32_t value, BOOL *stop))block;

2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652
/**
 * Gets the raw enum value for the given key.
 *
 * @note This method bypass the validationFunc to enable the access of values that
 *       were not known at the time the binary was compiled.
 *
 * @param rawValue Pointer into which the value will be set, if found.
 * @param key      Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
2653
- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint64_t)key;
2654

2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @note This method bypass the validationFunc to enable the access of values that
 *       were not known at the time the binary was compiled.
 *
 * @param block The block to enumerate with.
 *   **key**:      The key for the current entry.
 *   **rawValue**: The value for the current entry
 *   **stop**:     A pointer to a boolean that when set stops the enumeration.
 **/
2666 2667 2668
- (void)enumerateKeysAndRawValuesUsingBlock:
    (void (^)(uint64_t key, int32_t rawValue, BOOL *stop))block;

2669 2670 2671 2672 2673 2674 2675 2676 2677
/**
 * Adds the keys and raw enum values from another dictionary.
 *
 * @note This method bypass the validationFunc to enable the setting of values that
 *       were not known at the time the binary was compiled.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
2678 2679 2680 2681 2682 2683 2684
- (void)addRawEntriesFromDictionary:(GPBUInt64EnumDictionary *)otherDictionary;

// If value is not a valid enumerator as defined by validationFunc, these
// methods will assert in debug, and will log in release and assign the value
// to the default value. Use the rawValue methods below to assign non enumerator
// values.

2685 2686 2687 2688 2689 2690
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
2691
- (void)setEnum:(int32_t)value forKey:(uint64_t)key;
2692

2693 2694 2695 2696 2697 2698 2699 2700 2701
/**
 * Sets the raw enum value for the given key.
 *
 * @note This method bypass the validationFunc to enable the setting of values that
 *       were not known at the time the binary was compiled.
 *
 * @param rawValue The raw enum value to set.
 * @param key      The key under which to store the raw enum value.
 **/
2702 2703
- (void)setRawValue:(int32_t)rawValue forKey:(uint64_t)key;

2704 2705 2706 2707 2708
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
2709
- (void)removeEnumForKey:(uint64_t)aKey;
2710 2711 2712 2713

/**
 * Removes all entries in this dictionary.
 **/
2714 2715 2716 2717 2718 2719
- (void)removeAll;

@end

#pragma mark - UInt64 -> Object

2720 2721 2722 2723 2724 2725
/**
 * Class used for map fields of <uint64_t, ObjectType>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
2726
@interface GPBUInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
2727

2728
/** Number of entries stored in this dictionary. */
2729 2730
@property(nonatomic, readonly) NSUInteger count;

2731 2732 2733 2734 2735 2736 2737 2738 2739
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param objects      The values to be placed in this dictionary.
 * @param keys         The keys under which to store the values.
 * @param count        The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
2740 2741
- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
                        forKeys:(const uint64_t [__nullable])keys
2742
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
2743 2744 2745 2746 2747 2748 2749 2750

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
2751
- (instancetype)initWithDictionary:(GPBUInt64ObjectDictionary *)dictionary;
2752 2753 2754 2755 2756 2757 2758 2759

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
2760 2761
- (instancetype)initWithCapacity:(NSUInteger)numItems;

2762 2763 2764 2765 2766 2767 2768
/**
 * Fetches the object stored under the given key.
 *
 * @param key Key under which the value is stored, if present.
 *
 * @return The object if found, nil otherwise.
 **/
2769
- (ObjectType)objectForKey:(uint64_t)key;
2770

2771 2772 2773 2774 2775 2776 2777 2778
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:         The key for the current entry.
 *   **object**:      The value for the current entry
 *   **stop**:        A pointer to a boolean that when set stops the enumeration.
 **/
2779
- (void)enumerateKeysAndObjectsUsingBlock:
2780
    (void (^)(uint64_t key, ObjectType object, BOOL *stop))block;
2781

2782 2783 2784 2785 2786 2787
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
2788 2789
- (void)addEntriesFromDictionary:(GPBUInt64ObjectDictionary *)otherDictionary;

2790 2791 2792 2793 2794 2795
/**
 * Sets the value for the given key.
 *
 * @param object     The value to set.
 * @param key        The key under which to store the value.
 **/
2796
- (void)setObject:(ObjectType)object forKey:(uint64_t)key;
2797

2798 2799 2800 2801 2802
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
2803
- (void)removeObjectForKey:(uint64_t)aKey;
2804 2805 2806 2807

/**
 * Removes all entries in this dictionary.
 **/
2808 2809 2810 2811 2812 2813
- (void)removeAll;

@end

#pragma mark - Int64 -> UInt32

2814 2815 2816 2817 2818 2819
/**
 * Class used for map fields of <int64_t, uint32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
2820 2821
@interface GPBInt64UInt32Dictionary : NSObject <NSCopying>

2822
/** Number of entries stored in this dictionary. */
2823 2824
@property(nonatomic, readonly) NSUInteger count;

2825 2826 2827 2828 2829 2830 2831 2832 2833
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
2834 2835
- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
                        forKeys:(const int64_t [__nullable])keys
2836
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
2837 2838 2839 2840 2841 2842 2843 2844

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
2845
- (instancetype)initWithDictionary:(GPBInt64UInt32Dictionary *)dictionary;
2846 2847 2848 2849 2850 2851 2852 2853

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
2854 2855
- (instancetype)initWithCapacity:(NSUInteger)numItems;

2856 2857 2858 2859 2860 2861 2862 2863
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
2864
- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int64_t)key;
2865

2866 2867 2868 2869 2870 2871 2872 2873
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
2874
- (void)enumerateKeysAndUInt32sUsingBlock:
2875 2876
    (void (^)(int64_t key, uint32_t value, BOOL *stop))block;

2877 2878 2879 2880 2881 2882
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
2883 2884
- (void)addEntriesFromDictionary:(GPBInt64UInt32Dictionary *)otherDictionary;

2885 2886 2887 2888 2889 2890
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
2891
- (void)setUInt32:(uint32_t)value forKey:(int64_t)key;
2892

2893 2894 2895 2896 2897
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
2898
- (void)removeUInt32ForKey:(int64_t)aKey;
2899 2900 2901 2902

/**
 * Removes all entries in this dictionary.
 **/
2903 2904 2905 2906 2907 2908
- (void)removeAll;

@end

#pragma mark - Int64 -> Int32

2909 2910 2911 2912 2913 2914
/**
 * Class used for map fields of <int64_t, int32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
2915 2916
@interface GPBInt64Int32Dictionary : NSObject <NSCopying>

2917
/** Number of entries stored in this dictionary. */
2918 2919
@property(nonatomic, readonly) NSUInteger count;

2920 2921 2922 2923 2924 2925 2926 2927 2928
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
2929 2930
- (instancetype)initWithInt32s:(const int32_t [__nullable])values
                       forKeys:(const int64_t [__nullable])keys
2931
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
2932 2933 2934 2935 2936 2937 2938 2939

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
2940
- (instancetype)initWithDictionary:(GPBInt64Int32Dictionary *)dictionary;
2941 2942 2943 2944 2945 2946 2947 2948

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
2949 2950
- (instancetype)initWithCapacity:(NSUInteger)numItems;

2951 2952 2953 2954 2955 2956 2957 2958
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
2959
- (BOOL)getInt32:(nullable int32_t *)value forKey:(int64_t)key;
2960

2961 2962 2963 2964 2965 2966 2967 2968
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
2969
- (void)enumerateKeysAndInt32sUsingBlock:
2970 2971
    (void (^)(int64_t key, int32_t value, BOOL *stop))block;

2972 2973 2974 2975 2976 2977
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
2978 2979
- (void)addEntriesFromDictionary:(GPBInt64Int32Dictionary *)otherDictionary;

2980 2981 2982 2983 2984 2985
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
2986
- (void)setInt32:(int32_t)value forKey:(int64_t)key;
2987

2988 2989 2990 2991 2992
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
2993
- (void)removeInt32ForKey:(int64_t)aKey;
2994 2995 2996 2997

/**
 * Removes all entries in this dictionary.
 **/
2998 2999 3000 3001 3002 3003
- (void)removeAll;

@end

#pragma mark - Int64 -> UInt64

3004 3005 3006 3007 3008 3009
/**
 * Class used for map fields of <int64_t, uint64_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
3010 3011
@interface GPBInt64UInt64Dictionary : NSObject <NSCopying>

3012
/** Number of entries stored in this dictionary. */
3013 3014
@property(nonatomic, readonly) NSUInteger count;

3015 3016 3017 3018 3019 3020 3021 3022 3023
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
3024 3025
- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
                        forKeys:(const int64_t [__nullable])keys
3026
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
3027 3028 3029 3030 3031 3032 3033 3034

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
3035
- (instancetype)initWithDictionary:(GPBInt64UInt64Dictionary *)dictionary;
3036 3037 3038 3039 3040 3041 3042 3043

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
3044 3045
- (instancetype)initWithCapacity:(NSUInteger)numItems;

3046 3047 3048 3049 3050 3051 3052 3053
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
3054
- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int64_t)key;
3055

3056 3057 3058 3059 3060 3061 3062 3063
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
3064
- (void)enumerateKeysAndUInt64sUsingBlock:
3065 3066
    (void (^)(int64_t key, uint64_t value, BOOL *stop))block;

3067 3068 3069 3070 3071 3072
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
3073 3074
- (void)addEntriesFromDictionary:(GPBInt64UInt64Dictionary *)otherDictionary;

3075 3076 3077 3078 3079 3080
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
3081
- (void)setUInt64:(uint64_t)value forKey:(int64_t)key;
3082

3083 3084 3085 3086 3087
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
3088
- (void)removeUInt64ForKey:(int64_t)aKey;
3089 3090 3091 3092

/**
 * Removes all entries in this dictionary.
 **/
3093 3094 3095 3096 3097
- (void)removeAll;

@end

#pragma mark - Int64 -> Int64
3098 3099

/**
3100 3101
 * Class used for map fields of <int64_t, int64_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
3102
 *
3103
 * @note This class is not meant to be subclassed.
3104
 **/
3105 3106 3107 3108
@interface GPBInt64Int64Dictionary : NSObject <NSCopying>

/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
3109

3110 3111 3112 3113 3114 3115 3116 3117 3118
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
3119 3120
- (instancetype)initWithInt64s:(const int64_t [__nullable])values
                       forKeys:(const int64_t [__nullable])keys
3121
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
3122 3123 3124 3125 3126 3127 3128 3129

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
3130
- (instancetype)initWithDictionary:(GPBInt64Int64Dictionary *)dictionary;
3131 3132 3133 3134 3135 3136 3137 3138

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
3139 3140
- (instancetype)initWithCapacity:(NSUInteger)numItems;

3141 3142 3143 3144 3145 3146 3147 3148
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
3149
- (BOOL)getInt64:(nullable int64_t *)value forKey:(int64_t)key;
3150

3151 3152 3153 3154 3155 3156 3157 3158
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
3159
- (void)enumerateKeysAndInt64sUsingBlock:
3160 3161
    (void (^)(int64_t key, int64_t value, BOOL *stop))block;

3162 3163 3164 3165 3166 3167
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
3168 3169
- (void)addEntriesFromDictionary:(GPBInt64Int64Dictionary *)otherDictionary;

3170 3171 3172 3173 3174 3175
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
3176
- (void)setInt64:(int64_t)value forKey:(int64_t)key;
3177

3178 3179 3180 3181 3182
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
3183
- (void)removeInt64ForKey:(int64_t)aKey;
3184 3185 3186 3187

/**
 * Removes all entries in this dictionary.
 **/
3188 3189 3190 3191 3192 3193
- (void)removeAll;

@end

#pragma mark - Int64 -> Bool

3194 3195 3196 3197 3198 3199
/**
 * Class used for map fields of <int64_t, BOOL>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
3200 3201
@interface GPBInt64BoolDictionary : NSObject <NSCopying>

3202
/** Number of entries stored in this dictionary. */
3203 3204
@property(nonatomic, readonly) NSUInteger count;

3205 3206 3207 3208 3209 3210 3211 3212 3213
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
3214 3215
- (instancetype)initWithBools:(const BOOL [__nullable])values
                      forKeys:(const int64_t [__nullable])keys
3216
                        count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
3217 3218 3219 3220 3221 3222 3223 3224

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
3225
- (instancetype)initWithDictionary:(GPBInt64BoolDictionary *)dictionary;
3226 3227 3228 3229 3230 3231 3232 3233

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
3234 3235
- (instancetype)initWithCapacity:(NSUInteger)numItems;

3236 3237 3238 3239 3240 3241 3242 3243
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
3244
- (BOOL)getBool:(nullable BOOL *)value forKey:(int64_t)key;
3245

3246 3247 3248 3249 3250 3251 3252 3253
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
3254
- (void)enumerateKeysAndBoolsUsingBlock:
3255 3256
    (void (^)(int64_t key, BOOL value, BOOL *stop))block;

3257 3258 3259 3260 3261 3262
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
3263 3264
- (void)addEntriesFromDictionary:(GPBInt64BoolDictionary *)otherDictionary;

3265 3266 3267 3268 3269 3270
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
3271
- (void)setBool:(BOOL)value forKey:(int64_t)key;
3272

3273 3274 3275 3276 3277
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
3278
- (void)removeBoolForKey:(int64_t)aKey;
3279 3280 3281 3282

/**
 * Removes all entries in this dictionary.
 **/
3283 3284 3285 3286 3287 3288
- (void)removeAll;

@end

#pragma mark - Int64 -> Float

3289 3290 3291 3292 3293 3294
/**
 * Class used for map fields of <int64_t, float>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
3295 3296
@interface GPBInt64FloatDictionary : NSObject <NSCopying>

3297
/** Number of entries stored in this dictionary. */
3298 3299
@property(nonatomic, readonly) NSUInteger count;

3300 3301 3302 3303 3304 3305 3306 3307 3308
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
3309 3310
- (instancetype)initWithFloats:(const float [__nullable])values
                       forKeys:(const int64_t [__nullable])keys
3311
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
3312 3313 3314 3315 3316 3317 3318 3319

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
3320
- (instancetype)initWithDictionary:(GPBInt64FloatDictionary *)dictionary;
3321 3322 3323 3324 3325 3326 3327 3328

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
3329 3330
- (instancetype)initWithCapacity:(NSUInteger)numItems;

3331 3332 3333 3334 3335 3336 3337 3338
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
3339
- (BOOL)getFloat:(nullable float *)value forKey:(int64_t)key;
3340

3341 3342 3343 3344 3345 3346 3347 3348
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
3349
- (void)enumerateKeysAndFloatsUsingBlock:
3350 3351
    (void (^)(int64_t key, float value, BOOL *stop))block;

3352 3353 3354 3355 3356 3357
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
3358 3359
- (void)addEntriesFromDictionary:(GPBInt64FloatDictionary *)otherDictionary;

3360 3361 3362 3363 3364 3365
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
3366
- (void)setFloat:(float)value forKey:(int64_t)key;
3367

3368 3369 3370 3371 3372
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
3373
- (void)removeFloatForKey:(int64_t)aKey;
3374 3375 3376 3377

/**
 * Removes all entries in this dictionary.
 **/
3378 3379 3380 3381 3382 3383
- (void)removeAll;

@end

#pragma mark - Int64 -> Double

3384 3385 3386 3387 3388 3389
/**
 * Class used for map fields of <int64_t, double>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
3390 3391
@interface GPBInt64DoubleDictionary : NSObject <NSCopying>

3392
/** Number of entries stored in this dictionary. */
3393 3394
@property(nonatomic, readonly) NSUInteger count;

3395 3396 3397 3398 3399 3400 3401 3402 3403
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
3404 3405
- (instancetype)initWithDoubles:(const double [__nullable])values
                        forKeys:(const int64_t [__nullable])keys
3406
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
3407 3408 3409 3410 3411 3412 3413 3414

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
3415
- (instancetype)initWithDictionary:(GPBInt64DoubleDictionary *)dictionary;
3416 3417 3418 3419 3420 3421 3422 3423

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
3424 3425
- (instancetype)initWithCapacity:(NSUInteger)numItems;

3426 3427 3428 3429 3430 3431 3432 3433
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
3434
- (BOOL)getDouble:(nullable double *)value forKey:(int64_t)key;
3435

3436 3437 3438 3439 3440 3441 3442 3443
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
3444
- (void)enumerateKeysAndDoublesUsingBlock:
3445 3446
    (void (^)(int64_t key, double value, BOOL *stop))block;

3447 3448 3449 3450 3451 3452
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
3453 3454
- (void)addEntriesFromDictionary:(GPBInt64DoubleDictionary *)otherDictionary;

3455 3456 3457 3458 3459 3460
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
3461
- (void)setDouble:(double)value forKey:(int64_t)key;
3462

3463 3464 3465 3466 3467
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
3468
- (void)removeDoubleForKey:(int64_t)aKey;
3469 3470 3471 3472

/**
 * Removes all entries in this dictionary.
 **/
3473 3474 3475 3476 3477 3478
- (void)removeAll;

@end

#pragma mark - Int64 -> Enum

3479 3480 3481 3482 3483 3484
/**
 * Class used for map fields of <int64_t, int32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
3485 3486
@interface GPBInt64EnumDictionary : NSObject <NSCopying>

3487
/** Number of entries stored in this dictionary. */
3488
@property(nonatomic, readonly) NSUInteger count;
3489
/** The validation function to check if the enums are valid. */
3490 3491
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;

3492 3493 3494 3495 3496 3497 3498
/**
 * Initializes a dictionary with the given validation function.
 *
 * @param func The enum validation function for the dictionary.
 *
 * @return A newly initialized dictionary.
 **/
3499
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510

/**
 * Initializes a dictionary with the entries given.
 *
 * @param func   The enum validation function for the dictionary.
 * @param values The raw enum values values to be placed in the dictionary.
 * @param keys   The keys under which to store the values.
 * @param count  The number of entries to store in the dictionary.
 *
 * @return A newly initialized dictionary with the keys and values in it.
 **/
3511
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
3512 3513
                                 rawValues:(const int32_t [__nullable])values
                                   forKeys:(const int64_t [__nullable])keys
3514
                                     count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
3515 3516 3517 3518 3519 3520 3521 3522 3523 3524

/**
 * Initializes a dictionary with the entries from the given.
 * dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to the dictionary.
 *
 * @return A newly initialized dictionary with the entries from the given
 *         dictionary in it.
 **/
3525
- (instancetype)initWithDictionary:(GPBInt64EnumDictionary *)dictionary;
3526 3527 3528 3529 3530 3531 3532 3533 3534

/**
 * Initializes a dictionary with the given capacity.
 *
 * @param func     The enum validation function for the dictionary.
 * @param numItems Capacity needed for the dictionary.
 *
 * @return A newly initialized dictionary with the given capacity.
 **/
3535
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
3536 3537 3538 3539 3540 3541
                                  capacity:(NSUInteger)numItems;

// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
// is not a valid enumerator as defined by validationFunc. If the actual value is
// desired, use "raw" version of the method.

3542 3543 3544 3545 3546 3547 3548 3549
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
3550
- (BOOL)getEnum:(nullable int32_t *)value forKey:(int64_t)key;
3551

3552 3553 3554 3555 3556 3557 3558 3559
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
3560
- (void)enumerateKeysAndEnumsUsingBlock:
3561 3562
    (void (^)(int64_t key, int32_t value, BOOL *stop))block;

3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573
/**
 * Gets the raw enum value for the given key.
 *
 * @note This method bypass the validationFunc to enable the access of values that
 *       were not known at the time the binary was compiled.
 *
 * @param rawValue Pointer into which the value will be set, if found.
 * @param key      Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
3574
- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int64_t)key;
3575

3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @note This method bypass the validationFunc to enable the access of values that
 *       were not known at the time the binary was compiled.
 *
 * @param block The block to enumerate with.
 *   **key**:      The key for the current entry.
 *   **rawValue**: The value for the current entry
 *   **stop**:     A pointer to a boolean that when set stops the enumeration.
 **/
3587 3588 3589
- (void)enumerateKeysAndRawValuesUsingBlock:
    (void (^)(int64_t key, int32_t rawValue, BOOL *stop))block;

3590 3591 3592 3593 3594 3595 3596 3597 3598
/**
 * Adds the keys and raw enum values from another dictionary.
 *
 * @note This method bypass the validationFunc to enable the setting of values that
 *       were not known at the time the binary was compiled.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
3599 3600 3601 3602 3603 3604 3605
- (void)addRawEntriesFromDictionary:(GPBInt64EnumDictionary *)otherDictionary;

// If value is not a valid enumerator as defined by validationFunc, these
// methods will assert in debug, and will log in release and assign the value
// to the default value. Use the rawValue methods below to assign non enumerator
// values.

3606 3607 3608 3609 3610 3611
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
3612
- (void)setEnum:(int32_t)value forKey:(int64_t)key;
3613

3614 3615 3616 3617 3618 3619 3620 3621 3622
/**
 * Sets the raw enum value for the given key.
 *
 * @note This method bypass the validationFunc to enable the setting of values that
 *       were not known at the time the binary was compiled.
 *
 * @param rawValue The raw enum value to set.
 * @param key      The key under which to store the raw enum value.
 **/
3623 3624
- (void)setRawValue:(int32_t)rawValue forKey:(int64_t)key;

3625 3626 3627 3628 3629
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
3630
- (void)removeEnumForKey:(int64_t)aKey;
3631 3632 3633 3634

/**
 * Removes all entries in this dictionary.
 **/
3635 3636 3637 3638 3639 3640
- (void)removeAll;

@end

#pragma mark - Int64 -> Object

3641 3642 3643 3644 3645 3646
/**
 * Class used for map fields of <int64_t, ObjectType>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
3647
@interface GPBInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
3648

3649
/** Number of entries stored in this dictionary. */
3650 3651
@property(nonatomic, readonly) NSUInteger count;

3652 3653 3654 3655 3656 3657 3658 3659 3660
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param objects      The values to be placed in this dictionary.
 * @param keys         The keys under which to store the values.
 * @param count        The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
3661 3662
- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
                        forKeys:(const int64_t [__nullable])keys
3663
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
3664 3665 3666 3667 3668 3669 3670 3671

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
3672
- (instancetype)initWithDictionary:(GPBInt64ObjectDictionary *)dictionary;
3673 3674 3675 3676 3677 3678 3679 3680

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
3681 3682
- (instancetype)initWithCapacity:(NSUInteger)numItems;

3683 3684 3685 3686 3687 3688 3689
/**
 * Fetches the object stored under the given key.
 *
 * @param key Key under which the value is stored, if present.
 *
 * @return The object if found, nil otherwise.
 **/
3690
- (ObjectType)objectForKey:(int64_t)key;
3691

3692 3693 3694 3695 3696 3697 3698 3699
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:         The key for the current entry.
 *   **object**:      The value for the current entry
 *   **stop**:        A pointer to a boolean that when set stops the enumeration.
 **/
3700
- (void)enumerateKeysAndObjectsUsingBlock:
3701
    (void (^)(int64_t key, ObjectType object, BOOL *stop))block;
3702

3703 3704 3705 3706 3707 3708
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
3709 3710
- (void)addEntriesFromDictionary:(GPBInt64ObjectDictionary *)otherDictionary;

3711 3712 3713 3714 3715 3716
/**
 * Sets the value for the given key.
 *
 * @param object     The value to set.
 * @param key        The key under which to store the value.
 **/
3717
- (void)setObject:(ObjectType)object forKey:(int64_t)key;
3718

3719 3720 3721 3722 3723
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
3724
- (void)removeObjectForKey:(int64_t)aKey;
3725 3726 3727 3728

/**
 * Removes all entries in this dictionary.
 **/
3729 3730 3731 3732 3733 3734
- (void)removeAll;

@end

#pragma mark - Bool -> UInt32

3735 3736 3737 3738 3739 3740
/**
 * Class used for map fields of <BOOL, uint32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
3741 3742
@interface GPBBoolUInt32Dictionary : NSObject <NSCopying>

3743
/** Number of entries stored in this dictionary. */
3744 3745
@property(nonatomic, readonly) NSUInteger count;

3746 3747 3748 3749 3750 3751 3752 3753 3754
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
3755 3756
- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
                        forKeys:(const BOOL [__nullable])keys
3757
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
3758 3759 3760 3761 3762 3763 3764 3765

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
3766
- (instancetype)initWithDictionary:(GPBBoolUInt32Dictionary *)dictionary;
3767 3768 3769 3770 3771 3772 3773 3774

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
3775 3776
- (instancetype)initWithCapacity:(NSUInteger)numItems;

3777 3778 3779 3780 3781 3782 3783 3784
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
3785
- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(BOOL)key;
3786

3787 3788 3789 3790 3791 3792 3793 3794
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
3795
- (void)enumerateKeysAndUInt32sUsingBlock:
3796 3797
    (void (^)(BOOL key, uint32_t value, BOOL *stop))block;

3798 3799 3800 3801 3802 3803
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
3804 3805
- (void)addEntriesFromDictionary:(GPBBoolUInt32Dictionary *)otherDictionary;

3806 3807 3808 3809 3810 3811
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
3812
- (void)setUInt32:(uint32_t)value forKey:(BOOL)key;
3813

3814 3815 3816 3817 3818
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
3819
- (void)removeUInt32ForKey:(BOOL)aKey;
3820 3821 3822 3823

/**
 * Removes all entries in this dictionary.
 **/
3824 3825 3826 3827 3828 3829
- (void)removeAll;

@end

#pragma mark - Bool -> Int32

3830 3831 3832 3833 3834 3835
/**
 * Class used for map fields of <BOOL, int32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
3836 3837
@interface GPBBoolInt32Dictionary : NSObject <NSCopying>

3838
/** Number of entries stored in this dictionary. */
3839 3840
@property(nonatomic, readonly) NSUInteger count;

3841 3842 3843 3844 3845 3846 3847 3848 3849
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
3850 3851
- (instancetype)initWithInt32s:(const int32_t [__nullable])values
                       forKeys:(const BOOL [__nullable])keys
3852
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
3853 3854 3855 3856 3857 3858 3859 3860

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
3861
- (instancetype)initWithDictionary:(GPBBoolInt32Dictionary *)dictionary;
3862 3863 3864 3865 3866 3867 3868 3869

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
3870 3871
- (instancetype)initWithCapacity:(NSUInteger)numItems;

3872 3873 3874 3875 3876 3877 3878 3879
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
3880
- (BOOL)getInt32:(nullable int32_t *)value forKey:(BOOL)key;
3881

3882 3883 3884 3885 3886 3887 3888 3889
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
3890
- (void)enumerateKeysAndInt32sUsingBlock:
3891 3892
    (void (^)(BOOL key, int32_t value, BOOL *stop))block;

3893 3894 3895 3896 3897 3898
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
3899 3900
- (void)addEntriesFromDictionary:(GPBBoolInt32Dictionary *)otherDictionary;

3901 3902 3903 3904 3905 3906
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
3907
- (void)setInt32:(int32_t)value forKey:(BOOL)key;
3908

3909 3910 3911 3912 3913
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
3914
- (void)removeInt32ForKey:(BOOL)aKey;
3915 3916 3917 3918

/**
 * Removes all entries in this dictionary.
 **/
3919 3920 3921 3922 3923 3924
- (void)removeAll;

@end

#pragma mark - Bool -> UInt64

3925 3926 3927 3928 3929 3930
/**
 * Class used for map fields of <BOOL, uint64_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
3931 3932
@interface GPBBoolUInt64Dictionary : NSObject <NSCopying>

3933
/** Number of entries stored in this dictionary. */
3934 3935
@property(nonatomic, readonly) NSUInteger count;

3936 3937 3938 3939 3940 3941 3942 3943 3944
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
3945 3946
- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
                        forKeys:(const BOOL [__nullable])keys
3947
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
3948 3949 3950 3951 3952 3953 3954 3955

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
3956
- (instancetype)initWithDictionary:(GPBBoolUInt64Dictionary *)dictionary;
3957 3958 3959 3960 3961 3962 3963 3964

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
3965 3966
- (instancetype)initWithCapacity:(NSUInteger)numItems;

3967 3968 3969 3970 3971 3972 3973 3974
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
3975
- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(BOOL)key;
3976

3977 3978 3979 3980 3981 3982 3983 3984
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
3985
- (void)enumerateKeysAndUInt64sUsingBlock:
3986 3987
    (void (^)(BOOL key, uint64_t value, BOOL *stop))block;

3988 3989 3990 3991 3992 3993
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
3994 3995
- (void)addEntriesFromDictionary:(GPBBoolUInt64Dictionary *)otherDictionary;

3996 3997 3998 3999 4000 4001
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
4002
- (void)setUInt64:(uint64_t)value forKey:(BOOL)key;
4003

4004 4005 4006 4007 4008
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
4009
- (void)removeUInt64ForKey:(BOOL)aKey;
4010 4011 4012 4013

/**
 * Removes all entries in this dictionary.
 **/
4014 4015 4016 4017 4018 4019
- (void)removeAll;

@end

#pragma mark - Bool -> Int64

4020 4021 4022 4023 4024 4025
/**
 * Class used for map fields of <BOOL, int64_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
4026 4027
@interface GPBBoolInt64Dictionary : NSObject <NSCopying>

4028
/** Number of entries stored in this dictionary. */
4029 4030
@property(nonatomic, readonly) NSUInteger count;

4031 4032 4033 4034 4035 4036 4037 4038 4039
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
4040 4041
- (instancetype)initWithInt64s:(const int64_t [__nullable])values
                       forKeys:(const BOOL [__nullable])keys
4042
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
4043 4044 4045 4046 4047 4048 4049 4050

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
4051
- (instancetype)initWithDictionary:(GPBBoolInt64Dictionary *)dictionary;
4052 4053 4054 4055 4056 4057 4058 4059

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
4060 4061
- (instancetype)initWithCapacity:(NSUInteger)numItems;

4062 4063 4064 4065 4066 4067 4068 4069
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
4070
- (BOOL)getInt64:(nullable int64_t *)value forKey:(BOOL)key;
4071

4072 4073 4074 4075 4076 4077 4078 4079
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
4080
- (void)enumerateKeysAndInt64sUsingBlock:
4081 4082
    (void (^)(BOOL key, int64_t value, BOOL *stop))block;

4083 4084 4085 4086 4087 4088
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
4089 4090
- (void)addEntriesFromDictionary:(GPBBoolInt64Dictionary *)otherDictionary;

4091 4092 4093 4094 4095 4096
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
4097
- (void)setInt64:(int64_t)value forKey:(BOOL)key;
4098

4099 4100 4101 4102 4103
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
4104
- (void)removeInt64ForKey:(BOOL)aKey;
4105 4106 4107 4108

/**
 * Removes all entries in this dictionary.
 **/
4109 4110 4111 4112 4113 4114
- (void)removeAll;

@end

#pragma mark - Bool -> Bool

4115 4116 4117 4118 4119 4120
/**
 * Class used for map fields of <BOOL, BOOL>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
4121 4122
@interface GPBBoolBoolDictionary : NSObject <NSCopying>

4123
/** Number of entries stored in this dictionary. */
4124 4125
@property(nonatomic, readonly) NSUInteger count;

4126 4127 4128 4129 4130 4131 4132 4133 4134
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
4135 4136
- (instancetype)initWithBools:(const BOOL [__nullable])values
                      forKeys:(const BOOL [__nullable])keys
4137
                        count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
4138 4139 4140 4141 4142 4143 4144 4145

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
4146
- (instancetype)initWithDictionary:(GPBBoolBoolDictionary *)dictionary;
4147 4148 4149 4150 4151 4152 4153 4154

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
4155 4156
- (instancetype)initWithCapacity:(NSUInteger)numItems;

4157 4158 4159 4160 4161 4162 4163 4164
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
4165
- (BOOL)getBool:(nullable BOOL *)value forKey:(BOOL)key;
4166

4167 4168 4169 4170 4171 4172 4173 4174
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
4175
- (void)enumerateKeysAndBoolsUsingBlock:
4176 4177
    (void (^)(BOOL key, BOOL value, BOOL *stop))block;

4178 4179 4180 4181 4182 4183
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
4184 4185
- (void)addEntriesFromDictionary:(GPBBoolBoolDictionary *)otherDictionary;

4186 4187 4188 4189 4190 4191
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
4192
- (void)setBool:(BOOL)value forKey:(BOOL)key;
4193

4194 4195 4196 4197 4198
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
4199
- (void)removeBoolForKey:(BOOL)aKey;
4200 4201 4202 4203

/**
 * Removes all entries in this dictionary.
 **/
4204 4205 4206 4207 4208 4209
- (void)removeAll;

@end

#pragma mark - Bool -> Float

4210 4211 4212 4213 4214 4215
/**
 * Class used for map fields of <BOOL, float>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
4216 4217
@interface GPBBoolFloatDictionary : NSObject <NSCopying>

4218
/** Number of entries stored in this dictionary. */
4219 4220
@property(nonatomic, readonly) NSUInteger count;

4221 4222 4223 4224 4225 4226 4227 4228 4229
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
4230 4231
- (instancetype)initWithFloats:(const float [__nullable])values
                       forKeys:(const BOOL [__nullable])keys
4232
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
4233 4234 4235 4236 4237 4238 4239 4240

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
4241
- (instancetype)initWithDictionary:(GPBBoolFloatDictionary *)dictionary;
4242 4243 4244 4245 4246 4247 4248 4249

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
4250 4251
- (instancetype)initWithCapacity:(NSUInteger)numItems;

4252 4253 4254 4255 4256 4257 4258 4259
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
4260
- (BOOL)getFloat:(nullable float *)value forKey:(BOOL)key;
4261

4262 4263 4264 4265 4266 4267 4268 4269
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
4270
- (void)enumerateKeysAndFloatsUsingBlock:
4271 4272
    (void (^)(BOOL key, float value, BOOL *stop))block;

4273 4274 4275 4276 4277 4278
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
4279 4280
- (void)addEntriesFromDictionary:(GPBBoolFloatDictionary *)otherDictionary;

4281 4282 4283 4284 4285 4286
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
4287
- (void)setFloat:(float)value forKey:(BOOL)key;
4288

4289 4290 4291 4292 4293
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
4294
- (void)removeFloatForKey:(BOOL)aKey;
4295 4296 4297 4298

/**
 * Removes all entries in this dictionary.
 **/
4299 4300 4301 4302 4303 4304
- (void)removeAll;

@end

#pragma mark - Bool -> Double

4305 4306 4307 4308 4309 4310
/**
 * Class used for map fields of <BOOL, double>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
4311 4312
@interface GPBBoolDoubleDictionary : NSObject <NSCopying>

4313
/** Number of entries stored in this dictionary. */
4314 4315
@property(nonatomic, readonly) NSUInteger count;

4316 4317 4318 4319 4320 4321 4322 4323 4324
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
4325 4326
- (instancetype)initWithDoubles:(const double [__nullable])values
                        forKeys:(const BOOL [__nullable])keys
4327
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
4328 4329 4330 4331 4332 4333 4334 4335

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
4336
- (instancetype)initWithDictionary:(GPBBoolDoubleDictionary *)dictionary;
4337 4338 4339 4340 4341 4342 4343 4344

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
4345 4346
- (instancetype)initWithCapacity:(NSUInteger)numItems;

4347 4348 4349 4350 4351 4352 4353 4354
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
4355
- (BOOL)getDouble:(nullable double *)value forKey:(BOOL)key;
4356

4357 4358 4359 4360 4361 4362 4363 4364
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
4365
- (void)enumerateKeysAndDoublesUsingBlock:
4366 4367
    (void (^)(BOOL key, double value, BOOL *stop))block;

4368 4369 4370 4371 4372 4373
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
4374 4375
- (void)addEntriesFromDictionary:(GPBBoolDoubleDictionary *)otherDictionary;

4376 4377 4378 4379 4380 4381
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
4382
- (void)setDouble:(double)value forKey:(BOOL)key;
4383

4384 4385 4386 4387 4388
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
4389
- (void)removeDoubleForKey:(BOOL)aKey;
4390 4391 4392 4393

/**
 * Removes all entries in this dictionary.
 **/
4394 4395 4396 4397 4398 4399
- (void)removeAll;

@end

#pragma mark - Bool -> Enum

4400 4401 4402 4403 4404 4405
/**
 * Class used for map fields of <BOOL, int32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
4406 4407
@interface GPBBoolEnumDictionary : NSObject <NSCopying>

4408
/** Number of entries stored in this dictionary. */
4409
@property(nonatomic, readonly) NSUInteger count;
4410
/** The validation function to check if the enums are valid. */
4411 4412
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;

4413 4414 4415 4416 4417 4418 4419
/**
 * Initializes a dictionary with the given validation function.
 *
 * @param func The enum validation function for the dictionary.
 *
 * @return A newly initialized dictionary.
 **/
4420
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431

/**
 * Initializes a dictionary with the entries given.
 *
 * @param func   The enum validation function for the dictionary.
 * @param values The raw enum values values to be placed in the dictionary.
 * @param keys   The keys under which to store the values.
 * @param count  The number of entries to store in the dictionary.
 *
 * @return A newly initialized dictionary with the keys and values in it.
 **/
4432
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
4433 4434
                                 rawValues:(const int32_t [__nullable])values
                                   forKeys:(const BOOL [__nullable])keys
4435
                                     count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
4436 4437 4438 4439 4440 4441 4442 4443 4444 4445

/**
 * Initializes a dictionary with the entries from the given.
 * dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to the dictionary.
 *
 * @return A newly initialized dictionary with the entries from the given
 *         dictionary in it.
 **/
4446
- (instancetype)initWithDictionary:(GPBBoolEnumDictionary *)dictionary;
4447 4448 4449 4450 4451 4452 4453 4454 4455

/**
 * Initializes a dictionary with the given capacity.
 *
 * @param func     The enum validation function for the dictionary.
 * @param numItems Capacity needed for the dictionary.
 *
 * @return A newly initialized dictionary with the given capacity.
 **/
4456
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
4457 4458 4459 4460 4461 4462
                                  capacity:(NSUInteger)numItems;

// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
// is not a valid enumerator as defined by validationFunc. If the actual value is
// desired, use "raw" version of the method.

4463 4464 4465 4466 4467 4468 4469 4470
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
4471
- (BOOL)getEnum:(nullable int32_t *)value forKey:(BOOL)key;
4472

4473 4474 4475 4476 4477 4478 4479 4480
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
4481
- (void)enumerateKeysAndEnumsUsingBlock:
4482 4483
    (void (^)(BOOL key, int32_t value, BOOL *stop))block;

4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494
/**
 * Gets the raw enum value for the given key.
 *
 * @note This method bypass the validationFunc to enable the access of values that
 *       were not known at the time the binary was compiled.
 *
 * @param rawValue Pointer into which the value will be set, if found.
 * @param key      Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
4495
- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(BOOL)key;
4496

4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @note This method bypass the validationFunc to enable the access of values that
 *       were not known at the time the binary was compiled.
 *
 * @param block The block to enumerate with.
 *   **key**:      The key for the current entry.
 *   **rawValue**: The value for the current entry
 *   **stop**:     A pointer to a boolean that when set stops the enumeration.
 **/
4508 4509 4510
- (void)enumerateKeysAndRawValuesUsingBlock:
    (void (^)(BOOL key, int32_t rawValue, BOOL *stop))block;

4511 4512 4513 4514 4515 4516 4517 4518 4519
/**
 * Adds the keys and raw enum values from another dictionary.
 *
 * @note This method bypass the validationFunc to enable the setting of values that
 *       were not known at the time the binary was compiled.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
4520 4521 4522 4523 4524 4525 4526
- (void)addRawEntriesFromDictionary:(GPBBoolEnumDictionary *)otherDictionary;

// If value is not a valid enumerator as defined by validationFunc, these
// methods will assert in debug, and will log in release and assign the value
// to the default value. Use the rawValue methods below to assign non enumerator
// values.

4527 4528 4529 4530 4531 4532
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
4533
- (void)setEnum:(int32_t)value forKey:(BOOL)key;
4534

4535 4536 4537 4538 4539 4540 4541 4542 4543
/**
 * Sets the raw enum value for the given key.
 *
 * @note This method bypass the validationFunc to enable the setting of values that
 *       were not known at the time the binary was compiled.
 *
 * @param rawValue The raw enum value to set.
 * @param key      The key under which to store the raw enum value.
 **/
4544 4545
- (void)setRawValue:(int32_t)rawValue forKey:(BOOL)key;

4546 4547 4548 4549 4550
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
4551
- (void)removeEnumForKey:(BOOL)aKey;
4552 4553 4554 4555

/**
 * Removes all entries in this dictionary.
 **/
4556 4557 4558 4559 4560 4561
- (void)removeAll;

@end

#pragma mark - Bool -> Object

4562 4563 4564 4565 4566 4567
/**
 * Class used for map fields of <BOOL, ObjectType>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
4568
@interface GPBBoolObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
4569

4570
/** Number of entries stored in this dictionary. */
4571 4572
@property(nonatomic, readonly) NSUInteger count;

4573 4574 4575 4576 4577 4578 4579 4580 4581
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param objects      The values to be placed in this dictionary.
 * @param keys         The keys under which to store the values.
 * @param count        The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
4582 4583
- (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects
                        forKeys:(const BOOL [__nullable])keys
4584
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
4585 4586 4587 4588 4589 4590 4591 4592

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
4593
- (instancetype)initWithDictionary:(GPBBoolObjectDictionary *)dictionary;
4594 4595 4596 4597 4598 4599 4600 4601

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
4602 4603
- (instancetype)initWithCapacity:(NSUInteger)numItems;

4604 4605 4606 4607 4608 4609 4610
/**
 * Fetches the object stored under the given key.
 *
 * @param key Key under which the value is stored, if present.
 *
 * @return The object if found, nil otherwise.
 **/
4611
- (ObjectType)objectForKey:(BOOL)key;
4612

4613 4614 4615 4616 4617 4618 4619 4620
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:         The key for the current entry.
 *   **object**:      The value for the current entry
 *   **stop**:        A pointer to a boolean that when set stops the enumeration.
 **/
4621
- (void)enumerateKeysAndObjectsUsingBlock:
4622
    (void (^)(BOOL key, ObjectType object, BOOL *stop))block;
4623

4624 4625 4626 4627 4628 4629
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
4630 4631
- (void)addEntriesFromDictionary:(GPBBoolObjectDictionary *)otherDictionary;

4632 4633 4634 4635 4636 4637
/**
 * Sets the value for the given key.
 *
 * @param object     The value to set.
 * @param key        The key under which to store the value.
 **/
4638
- (void)setObject:(ObjectType)object forKey:(BOOL)key;
4639

4640 4641 4642 4643 4644
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
4645
- (void)removeObjectForKey:(BOOL)aKey;
4646 4647 4648 4649

/**
 * Removes all entries in this dictionary.
 **/
4650 4651 4652 4653 4654 4655
- (void)removeAll;

@end

#pragma mark - String -> UInt32

4656 4657 4658 4659 4660 4661
/**
 * Class used for map fields of <NSString, uint32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
4662 4663
@interface GPBStringUInt32Dictionary : NSObject <NSCopying>

4664
/** Number of entries stored in this dictionary. */
4665 4666
@property(nonatomic, readonly) NSUInteger count;

4667 4668 4669 4670 4671 4672 4673 4674 4675
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
4676 4677
- (instancetype)initWithUInt32s:(const uint32_t [__nullable])values
                        forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
4678
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
4679 4680 4681 4682 4683 4684 4685 4686

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
4687
- (instancetype)initWithDictionary:(GPBStringUInt32Dictionary *)dictionary;
4688 4689 4690 4691 4692 4693 4694 4695

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
4696 4697
- (instancetype)initWithCapacity:(NSUInteger)numItems;

4698 4699 4700 4701 4702 4703 4704 4705
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
4706
- (BOOL)getUInt32:(nullable uint32_t *)value forKey:(NSString *)key;
4707

4708 4709 4710 4711 4712 4713 4714 4715
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
4716
- (void)enumerateKeysAndUInt32sUsingBlock:
4717 4718
    (void (^)(NSString *key, uint32_t value, BOOL *stop))block;

4719 4720 4721 4722 4723 4724
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
4725 4726
- (void)addEntriesFromDictionary:(GPBStringUInt32Dictionary *)otherDictionary;

4727 4728 4729 4730 4731 4732
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
4733
- (void)setUInt32:(uint32_t)value forKey:(NSString *)key;
4734

4735 4736 4737 4738 4739
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
4740 4741 4742 4743
- (void)removeUInt32ForKey:(NSString *)aKey;

/**
 * Removes all entries in this dictionary.
4744
 **/
4745 4746 4747 4748 4749
- (void)removeAll;

@end

#pragma mark - String -> Int32
4750 4751

/**
4752 4753
 * Class used for map fields of <NSString, int32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
4754
 *
4755
 * @note This class is not meant to be subclassed.
4756
 **/
4757 4758 4759 4760
@interface GPBStringInt32Dictionary : NSObject <NSCopying>

/** Number of entries stored in this dictionary. */
@property(nonatomic, readonly) NSUInteger count;
4761

4762 4763 4764 4765 4766 4767 4768 4769 4770
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
4771 4772
- (instancetype)initWithInt32s:(const int32_t [__nullable])values
                       forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
4773
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
4774 4775 4776 4777 4778 4779 4780 4781

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
4782
- (instancetype)initWithDictionary:(GPBStringInt32Dictionary *)dictionary;
4783 4784 4785 4786 4787 4788 4789 4790

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
4791 4792
- (instancetype)initWithCapacity:(NSUInteger)numItems;

4793 4794 4795 4796 4797 4798 4799 4800
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
4801
- (BOOL)getInt32:(nullable int32_t *)value forKey:(NSString *)key;
4802

4803 4804 4805 4806 4807 4808 4809 4810
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
4811
- (void)enumerateKeysAndInt32sUsingBlock:
4812 4813
    (void (^)(NSString *key, int32_t value, BOOL *stop))block;

4814 4815 4816 4817 4818 4819
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
4820 4821
- (void)addEntriesFromDictionary:(GPBStringInt32Dictionary *)otherDictionary;

4822 4823 4824 4825 4826 4827
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
4828
- (void)setInt32:(int32_t)value forKey:(NSString *)key;
4829

4830 4831 4832 4833 4834
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
4835
- (void)removeInt32ForKey:(NSString *)aKey;
4836 4837 4838 4839

/**
 * Removes all entries in this dictionary.
 **/
4840 4841 4842 4843 4844 4845
- (void)removeAll;

@end

#pragma mark - String -> UInt64

4846 4847 4848 4849 4850 4851
/**
 * Class used for map fields of <NSString, uint64_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
4852 4853
@interface GPBStringUInt64Dictionary : NSObject <NSCopying>

4854
/** Number of entries stored in this dictionary. */
4855 4856
@property(nonatomic, readonly) NSUInteger count;

4857 4858 4859 4860 4861 4862 4863 4864 4865
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
4866 4867
- (instancetype)initWithUInt64s:(const uint64_t [__nullable])values
                        forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
4868
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
4869 4870 4871 4872 4873 4874 4875 4876

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
4877
- (instancetype)initWithDictionary:(GPBStringUInt64Dictionary *)dictionary;
4878 4879 4880 4881 4882 4883 4884 4885

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
4886 4887
- (instancetype)initWithCapacity:(NSUInteger)numItems;

4888 4889 4890 4891 4892 4893 4894 4895
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
4896
- (BOOL)getUInt64:(nullable uint64_t *)value forKey:(NSString *)key;
4897

4898 4899 4900 4901 4902 4903 4904 4905
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
4906
- (void)enumerateKeysAndUInt64sUsingBlock:
4907 4908
    (void (^)(NSString *key, uint64_t value, BOOL *stop))block;

4909 4910 4911 4912 4913 4914
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
4915 4916
- (void)addEntriesFromDictionary:(GPBStringUInt64Dictionary *)otherDictionary;

4917 4918 4919 4920 4921 4922
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
4923
- (void)setUInt64:(uint64_t)value forKey:(NSString *)key;
4924

4925 4926 4927 4928 4929
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
4930
- (void)removeUInt64ForKey:(NSString *)aKey;
4931 4932 4933 4934

/**
 * Removes all entries in this dictionary.
 **/
4935 4936 4937 4938 4939 4940
- (void)removeAll;

@end

#pragma mark - String -> Int64

4941 4942 4943 4944 4945 4946
/**
 * Class used for map fields of <NSString, int64_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
4947 4948
@interface GPBStringInt64Dictionary : NSObject <NSCopying>

4949
/** Number of entries stored in this dictionary. */
4950 4951
@property(nonatomic, readonly) NSUInteger count;

4952 4953 4954 4955 4956 4957 4958 4959 4960
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
4961 4962
- (instancetype)initWithInt64s:(const int64_t [__nullable])values
                       forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
4963
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
4964 4965 4966 4967 4968 4969 4970 4971

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
4972
- (instancetype)initWithDictionary:(GPBStringInt64Dictionary *)dictionary;
4973 4974 4975 4976 4977 4978 4979 4980

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
4981 4982
- (instancetype)initWithCapacity:(NSUInteger)numItems;

4983 4984 4985 4986 4987 4988 4989 4990
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
4991
- (BOOL)getInt64:(nullable int64_t *)value forKey:(NSString *)key;
4992

4993 4994 4995 4996 4997 4998 4999 5000
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
5001
- (void)enumerateKeysAndInt64sUsingBlock:
5002 5003
    (void (^)(NSString *key, int64_t value, BOOL *stop))block;

5004 5005 5006 5007 5008 5009
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
5010 5011
- (void)addEntriesFromDictionary:(GPBStringInt64Dictionary *)otherDictionary;

5012 5013 5014 5015 5016 5017
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
5018
- (void)setInt64:(int64_t)value forKey:(NSString *)key;
5019

5020 5021 5022 5023 5024
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
5025
- (void)removeInt64ForKey:(NSString *)aKey;
5026 5027 5028 5029

/**
 * Removes all entries in this dictionary.
 **/
5030 5031 5032 5033 5034 5035
- (void)removeAll;

@end

#pragma mark - String -> Bool

5036 5037 5038 5039 5040 5041
/**
 * Class used for map fields of <NSString, BOOL>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
5042 5043
@interface GPBStringBoolDictionary : NSObject <NSCopying>

5044
/** Number of entries stored in this dictionary. */
5045 5046
@property(nonatomic, readonly) NSUInteger count;

5047 5048 5049 5050 5051 5052 5053 5054 5055
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
5056 5057
- (instancetype)initWithBools:(const BOOL [__nullable])values
                      forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
5058
                        count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
5059 5060 5061 5062 5063 5064 5065 5066

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
5067
- (instancetype)initWithDictionary:(GPBStringBoolDictionary *)dictionary;
5068 5069 5070 5071 5072 5073 5074 5075

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
5076 5077
- (instancetype)initWithCapacity:(NSUInteger)numItems;

5078 5079 5080 5081 5082 5083 5084 5085
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
5086
- (BOOL)getBool:(nullable BOOL *)value forKey:(NSString *)key;
5087

5088 5089 5090 5091 5092 5093 5094 5095
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
5096
- (void)enumerateKeysAndBoolsUsingBlock:
5097 5098
    (void (^)(NSString *key, BOOL value, BOOL *stop))block;

5099 5100 5101 5102 5103 5104
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
5105 5106
- (void)addEntriesFromDictionary:(GPBStringBoolDictionary *)otherDictionary;

5107 5108 5109 5110 5111 5112
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
5113
- (void)setBool:(BOOL)value forKey:(NSString *)key;
5114

5115 5116 5117 5118 5119
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
5120
- (void)removeBoolForKey:(NSString *)aKey;
5121 5122 5123 5124

/**
 * Removes all entries in this dictionary.
 **/
5125 5126 5127 5128 5129 5130
- (void)removeAll;

@end

#pragma mark - String -> Float

5131 5132 5133 5134 5135 5136
/**
 * Class used for map fields of <NSString, float>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
5137 5138
@interface GPBStringFloatDictionary : NSObject <NSCopying>

5139
/** Number of entries stored in this dictionary. */
5140 5141
@property(nonatomic, readonly) NSUInteger count;

5142 5143 5144 5145 5146 5147 5148 5149 5150
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
5151 5152
- (instancetype)initWithFloats:(const float [__nullable])values
                       forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
5153
                         count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
5154 5155 5156 5157 5158 5159 5160 5161

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
5162
- (instancetype)initWithDictionary:(GPBStringFloatDictionary *)dictionary;
5163 5164 5165 5166 5167 5168 5169 5170

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
5171 5172
- (instancetype)initWithCapacity:(NSUInteger)numItems;

5173 5174 5175 5176 5177 5178 5179 5180
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
5181
- (BOOL)getFloat:(nullable float *)value forKey:(NSString *)key;
5182

5183 5184 5185 5186 5187 5188 5189 5190
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
5191
- (void)enumerateKeysAndFloatsUsingBlock:
5192 5193
    (void (^)(NSString *key, float value, BOOL *stop))block;

5194 5195 5196 5197 5198 5199
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
5200 5201
- (void)addEntriesFromDictionary:(GPBStringFloatDictionary *)otherDictionary;

5202 5203 5204 5205 5206 5207
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
5208
- (void)setFloat:(float)value forKey:(NSString *)key;
5209

5210 5211 5212 5213 5214
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
5215
- (void)removeFloatForKey:(NSString *)aKey;
5216 5217 5218 5219

/**
 * Removes all entries in this dictionary.
 **/
5220 5221 5222 5223 5224 5225
- (void)removeAll;

@end

#pragma mark - String -> Double

5226 5227 5228 5229 5230 5231
/**
 * Class used for map fields of <NSString, double>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
5232 5233
@interface GPBStringDoubleDictionary : NSObject <NSCopying>

5234
/** Number of entries stored in this dictionary. */
5235 5236
@property(nonatomic, readonly) NSUInteger count;

5237 5238 5239 5240 5241 5242 5243 5244 5245
/**
 * Initializes this dictionary, copying the given values and keys.
 *
 * @param values      The values to be placed in this dictionary.
 * @param keys        The keys under which to store the values.
 * @param count       The number of elements to copy into the dictionary.
 *
 * @return A newly initialized dictionary with a copy of the values and keys.
 **/
5246 5247
- (instancetype)initWithDoubles:(const double [__nullable])values
                        forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
5248
                          count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
5249 5250 5251 5252 5253 5254 5255 5256

/**
 * Initializes this dictionary, copying the entries from the given dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to this dictionary.
 *
 * @return A newly initialized dictionary with the entries of the given dictionary.
 **/
5257
- (instancetype)initWithDictionary:(GPBStringDoubleDictionary *)dictionary;
5258 5259 5260 5261 5262 5263 5264 5265

/**
 * Initializes this dictionary with the requested capacity.
 *
 * @param numItems Number of items needed for this dictionary.
 *
 * @return A newly initialized dictionary with the requested capacity.
 **/
5266 5267
- (instancetype)initWithCapacity:(NSUInteger)numItems;

5268 5269 5270 5271 5272 5273 5274 5275
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
5276
- (BOOL)getDouble:(nullable double *)value forKey:(NSString *)key;
5277

5278 5279 5280 5281 5282 5283 5284 5285
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
5286
- (void)enumerateKeysAndDoublesUsingBlock:
5287 5288
    (void (^)(NSString *key, double value, BOOL *stop))block;

5289 5290 5291 5292 5293 5294
/**
 * Adds the keys and values from another dictionary.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
5295 5296
- (void)addEntriesFromDictionary:(GPBStringDoubleDictionary *)otherDictionary;

5297 5298 5299 5300 5301 5302
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
5303
- (void)setDouble:(double)value forKey:(NSString *)key;
5304

5305 5306 5307 5308 5309
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
5310
- (void)removeDoubleForKey:(NSString *)aKey;
5311 5312 5313 5314

/**
 * Removes all entries in this dictionary.
 **/
5315 5316 5317 5318 5319 5320
- (void)removeAll;

@end

#pragma mark - String -> Enum

5321 5322 5323 5324 5325 5326
/**
 * Class used for map fields of <NSString, int32_t>
 * values. This performs better than boxing into NSNumbers in NSDictionaries.
 *
 * @note This class is not meant to be subclassed.
 **/
5327 5328
@interface GPBStringEnumDictionary : NSObject <NSCopying>

5329
/** Number of entries stored in this dictionary. */
5330
@property(nonatomic, readonly) NSUInteger count;
5331
/** The validation function to check if the enums are valid. */
5332 5333
@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;

5334 5335 5336 5337 5338 5339 5340
/**
 * Initializes a dictionary with the given validation function.
 *
 * @param func The enum validation function for the dictionary.
 *
 * @return A newly initialized dictionary.
 **/
5341
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352

/**
 * Initializes a dictionary with the entries given.
 *
 * @param func   The enum validation function for the dictionary.
 * @param values The raw enum values values to be placed in the dictionary.
 * @param keys   The keys under which to store the values.
 * @param count  The number of entries to store in the dictionary.
 *
 * @return A newly initialized dictionary with the keys and values in it.
 **/
5353
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
5354 5355
                                 rawValues:(const int32_t [__nullable])values
                                   forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys
5356
                                     count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
5357 5358 5359 5360 5361 5362 5363 5364 5365 5366

/**
 * Initializes a dictionary with the entries from the given.
 * dictionary.
 *
 * @param dictionary Dictionary containing the entries to add to the dictionary.
 *
 * @return A newly initialized dictionary with the entries from the given
 *         dictionary in it.
 **/
5367
- (instancetype)initWithDictionary:(GPBStringEnumDictionary *)dictionary;
5368 5369 5370 5371 5372 5373 5374 5375 5376

/**
 * Initializes a dictionary with the given capacity.
 *
 * @param func     The enum validation function for the dictionary.
 * @param numItems Capacity needed for the dictionary.
 *
 * @return A newly initialized dictionary with the given capacity.
 **/
5377
- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
5378 5379 5380 5381 5382 5383
                                  capacity:(NSUInteger)numItems;

// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
// is not a valid enumerator as defined by validationFunc. If the actual value is
// desired, use "raw" version of the method.

5384 5385 5386 5387 5388 5389 5390 5391
/**
 * Gets the value for the given key.
 *
 * @param value Pointer into which the value will be set, if found.
 * @param key   Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
5392
- (BOOL)getEnum:(nullable int32_t *)value forKey:(NSString *)key;
5393

5394 5395 5396 5397 5398 5399 5400 5401
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @param block The block to enumerate with.
 *   **key**:        The key for the current entry.
 *   **value**:      The value for the current entry
 *   **stop**:       A pointer to a boolean that when set stops the enumeration.
 **/
5402
- (void)enumerateKeysAndEnumsUsingBlock:
5403 5404
    (void (^)(NSString *key, int32_t value, BOOL *stop))block;

5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415
/**
 * Gets the raw enum value for the given key.
 *
 * @note This method bypass the validationFunc to enable the access of values that
 *       were not known at the time the binary was compiled.
 *
 * @param rawValue Pointer into which the value will be set, if found.
 * @param key      Key under which the value is stored, if present.
 *
 * @return YES if the key was found and the value was copied, NO otherwise.
 **/
5416
- (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(NSString *)key;
5417

5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428
/**
 * Enumerates the keys and values on this dictionary with the given block.
 *
 * @note This method bypass the validationFunc to enable the access of values that
 *       were not known at the time the binary was compiled.
 *
 * @param block The block to enumerate with.
 *   **key**:      The key for the current entry.
 *   **rawValue**: The value for the current entry
 *   **stop**:     A pointer to a boolean that when set stops the enumeration.
 **/
5429 5430 5431
- (void)enumerateKeysAndRawValuesUsingBlock:
    (void (^)(NSString *key, int32_t rawValue, BOOL *stop))block;

5432 5433 5434 5435 5436 5437 5438 5439 5440
/**
 * Adds the keys and raw enum values from another dictionary.
 *
 * @note This method bypass the validationFunc to enable the setting of values that
 *       were not known at the time the binary was compiled.
 *
 * @param otherDictionary Dictionary containing entries to be added to this
 *                        dictionary.
 **/
5441 5442 5443 5444 5445 5446 5447
- (void)addRawEntriesFromDictionary:(GPBStringEnumDictionary *)otherDictionary;

// If value is not a valid enumerator as defined by validationFunc, these
// methods will assert in debug, and will log in release and assign the value
// to the default value. Use the rawValue methods below to assign non enumerator
// values.

5448 5449 5450 5451 5452 5453
/**
 * Sets the value for the given key.
 *
 * @param value     The value to set.
 * @param key       The key under which to store the value.
 **/
5454
- (void)setEnum:(int32_t)value forKey:(NSString *)key;
5455

5456 5457 5458 5459 5460 5461 5462 5463 5464
/**
 * Sets the raw enum value for the given key.
 *
 * @note This method bypass the validationFunc to enable the setting of values that
 *       were not known at the time the binary was compiled.
 *
 * @param rawValue The raw enum value to set.
 * @param key      The key under which to store the raw enum value.
 **/
5465 5466
- (void)setRawValue:(int32_t)rawValue forKey:(NSString *)key;

5467 5468 5469 5470 5471
/**
 * Removes the entry for the given key.
 *
 * @param aKey Key to be removed from this dictionary.
 **/
5472
- (void)removeEnumForKey:(NSString *)aKey;
5473 5474 5475 5476

/**
 * Removes all entries in this dictionary.
 **/
5477 5478 5479 5480 5481 5482
- (void)removeAll;

@end

//%PDDM-EXPAND-END DECLARE_DICTIONARIES()

5483 5484
NS_ASSUME_NONNULL_END

5485 5486 5487 5488 5489 5490 5491 5492 5493
//%PDDM-DEFINE DECLARE_DICTIONARIES()
//%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt32, uint32_t)
//%DICTIONARY_INTERFACES_FOR_POD_KEY(Int32, int32_t)
//%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt64, uint64_t)
//%DICTIONARY_INTERFACES_FOR_POD_KEY(Int64, int64_t)
//%DICTIONARY_INTERFACES_FOR_POD_KEY(Bool, BOOL)
//%DICTIONARY_POD_INTERFACES_FOR_KEY(String, NSString, *, OBJECT)
//%PDDM-DEFINE DICTIONARY_INTERFACES_FOR_POD_KEY(KEY_NAME, KEY_TYPE)
//%DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, , POD)
5494
//%DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, Object, ObjectType)
5495 5496 5497 5498 5499 5500 5501 5502 5503 5504
//%PDDM-DEFINE DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, KisP, KHELPER)
//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt32, uint32_t)
//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int32, int32_t)
//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt64, uint64_t)
//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int64, int64_t)
//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Bool, BOOL)
//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Float, float)
//%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Double, double)
//%DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Enum, int32_t)
//%PDDM-DEFINE DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE)
5505
//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, POD, VALUE_NAME, value)
5506
//%PDDM-DEFINE DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, VALUE_NAME, VALUE_TYPE)
5507 5508
//%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, , POD, VALUE_NAME, VALUE_TYPE, OBJECT, Object, object)
//%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME)
5509 5510
//%/**
//% * Gets the value for the given key.
5511
//% *
5512 5513
//% * @param value Pointer into which the value will be set, if found.
//% * @param key   Key under which the value is stored, if present.
5514
//% *
5515 5516
//% * @return YES if the key was found and the value was copied, NO otherwise.
//% **/
5517 5518
//%- (BOOL)get##VNAME##:(nullable VALUE_TYPE *)value forKey:(KEY_TYPE)key;
//%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_TYPE, VNAME)
5519 5520
//%/**
//% * Fetches the object stored under the given key.
5521
//% *
5522
//% * @param key Key under which the value is stored, if present.
5523
//% *
5524 5525
//% * @return The object if found, nil otherwise.
//% **/
5526
//%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key;
5527 5528
//%PDDM-DEFINE VALUE_FOR_KEY_Enum(KEY_TYPE, VALUE_TYPE, VNAME)
//%VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME)
5529 5530 5531 5532 5533
//%PDDM-DEFINE ARRAY_ARG_MODIFIERPOD()
// Nothing
//%PDDM-DEFINE ARRAY_ARG_MODIFIEREnum()
// Nothing
//%PDDM-DEFINE ARRAY_ARG_MODIFIEROBJECT()
5534
//%__nonnull GPB_UNSAFE_UNRETAINED ##
5535 5536 5537 5538 5539 5540
//%PDDM-DEFINE DICTIONARY_CLASS_DECLPOD(KEY_NAME, VALUE_NAME, VALUE_TYPE)
//%GPB##KEY_NAME##VALUE_NAME##Dictionary
//%PDDM-DEFINE DICTIONARY_CLASS_DECLEnum(KEY_NAME, VALUE_NAME, VALUE_TYPE)
//%GPB##KEY_NAME##VALUE_NAME##Dictionary
//%PDDM-DEFINE DICTIONARY_CLASS_DECLOBJECT(KEY_NAME, VALUE_NAME, VALUE_TYPE)
//%GPB##KEY_NAME##VALUE_NAME##Dictionary<__covariant VALUE_TYPE>
5541
//%PDDM-DEFINE DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
5542 5543
//%#pragma mark - KEY_NAME -> VALUE_NAME
//%
5544 5545 5546
//%/**
//% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##>
//% * values. This performs better than boxing into NSNumbers in NSDictionaries.
5547
//% *
5548 5549
//% * @note This class is not meant to be subclassed.
//% **/
5550
//%@interface DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) : NSObject <NSCopying>
5551
//%
5552
//%/** Number of entries stored in this dictionary. */
5553 5554
//%@property(nonatomic, readonly) NSUInteger count;
//%
5555 5556
//%/**
//% * Initializes this dictionary, copying the given values and keys.
5557
//% *
5558 5559 5560
//% * @param ##VNAME_VAR##s      The values to be placed in this dictionary.
//% * @param keys ##VNAME_VAR$S##  The keys under which to store the values.
//% * @param count ##VNAME_VAR$S## The number of elements to copy into the dictionary.
5561
//% *
5562 5563
//% * @return A newly initialized dictionary with a copy of the values and keys.
//% **/
5564 5565
//%- (instancetype)initWith##VNAME##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])##VNAME_VAR##s
//%                ##VNAME$S##  forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
5566
//%                ##VNAME$S##    count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
5567 5568 5569
//%
//%/**
//% * Initializes this dictionary, copying the entries from the given dictionary.
5570
//% *
5571
//% * @param dictionary Dictionary containing the entries to add to this dictionary.
5572
//% *
5573 5574
//% * @return A newly initialized dictionary with the entries of the given dictionary.
//% **/
5575
//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
5576 5577 5578
//%
//%/**
//% * Initializes this dictionary with the requested capacity.
5579
//% *
5580
//% * @param numItems Number of items needed for this dictionary.
5581
//% *
5582 5583
//% * @return A newly initialized dictionary with the requested capacity.
//% **/
5584 5585
//%- (instancetype)initWithCapacity:(NSUInteger)numItems;
//%
5586
//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
5587
//%
5588 5589
//%/**
//% * Adds the keys and values from another dictionary.
5590
//% *
5591 5592 5593
//% * @param otherDictionary Dictionary containing entries to be added to this
//% *                        dictionary.
//% **/
5594 5595
//%- (void)addEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary;
//%
5596
//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
5597 5598 5599 5600 5601 5602 5603 5604 5605
//%
//%@end
//%

//%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE)
//%DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, Enum)
//%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER)
//%#pragma mark - KEY_NAME -> VALUE_NAME
//%
5606 5607 5608
//%/**
//% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##>
//% * values. This performs better than boxing into NSNumbers in NSDictionaries.
5609
//% *
5610 5611
//% * @note This class is not meant to be subclassed.
//% **/
5612 5613
//%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject <NSCopying>
//%
5614
//%/** Number of entries stored in this dictionary. */
5615
//%@property(nonatomic, readonly) NSUInteger count;
5616
//%/** The validation function to check if the enums are valid. */
5617 5618
//%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
//%
5619 5620
//%/**
//% * Initializes a dictionary with the given validation function.
5621
//% *
5622
//% * @param func The enum validation function for the dictionary.
5623
//% *
5624 5625
//% * @return A newly initialized dictionary.
//% **/
5626
//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
5627 5628 5629
//%
//%/**
//% * Initializes a dictionary with the entries given.
5630
//% *
5631 5632 5633 5634
//% * @param func   The enum validation function for the dictionary.
//% * @param values The raw enum values values to be placed in the dictionary.
//% * @param keys   The keys under which to store the values.
//% * @param count  The number of entries to store in the dictionary.
5635
//% *
5636 5637
//% * @return A newly initialized dictionary with the keys and values in it.
//% **/
5638
//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
5639 5640
//%                                 rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])values
//%                                   forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys
5641
//%                                     count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
5642 5643 5644 5645
//%
//%/**
//% * Initializes a dictionary with the entries from the given.
//% * dictionary.
5646
//% *
5647
//% * @param dictionary Dictionary containing the entries to add to the dictionary.
5648
//% *
5649 5650 5651
//% * @return A newly initialized dictionary with the entries from the given
//% *         dictionary in it.
//% **/
5652
//%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary;
5653 5654 5655
//%
//%/**
//% * Initializes a dictionary with the given capacity.
5656
//% *
5657 5658
//% * @param func     The enum validation function for the dictionary.
//% * @param numItems Capacity needed for the dictionary.
5659
//% *
5660 5661
//% * @return A newly initialized dictionary with the given capacity.
//% **/
5662
//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
5663 5664 5665 5666 5667 5668
//%                                  capacity:(NSUInteger)numItems;
//%
//%// These will return kGPBUnrecognizedEnumeratorValue if the value for the key
//%// is not a valid enumerator as defined by validationFunc. If the actual value is
//%// desired, use "raw" version of the method.
//%
5669
//%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value)
5670
//%
5671 5672
//%/**
//% * Gets the raw enum value for the given key.
5673
//% *
5674 5675
//% * @note This method bypass the validationFunc to enable the access of values that
//% *       were not known at the time the binary was compiled.
5676
//% *
5677 5678
//% * @param rawValue Pointer into which the value will be set, if found.
//% * @param key      Key under which the value is stored, if present.
5679
//% *
5680 5681
//% * @return YES if the key was found and the value was copied, NO otherwise.
//% **/
5682
//%- (BOOL)getRawValue:(nullable VALUE_TYPE *)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key;
5683
//%
5684 5685
//%/**
//% * Enumerates the keys and values on this dictionary with the given block.
5686
//% *
5687 5688
//% * @note This method bypass the validationFunc to enable the access of values that
//% *       were not known at the time the binary was compiled.
5689
//% *
5690 5691 5692 5693 5694
//% * @param block The block to enumerate with.
//% *   **key**:      The key for the current entry.
//% *   **rawValue**: The value for the current entry
//% *   **stop**:     A pointer to a boolean that when set stops the enumeration.
//% **/
5695 5696 5697
//%- (void)enumerateKeysAndRawValuesUsingBlock:
//%    (void (^)(KEY_TYPE KisP##key, VALUE_TYPE rawValue, BOOL *stop))block;
//%
5698 5699
//%/**
//% * Adds the keys and raw enum values from another dictionary.
5700
//% *
5701 5702
//% * @note This method bypass the validationFunc to enable the setting of values that
//% *       were not known at the time the binary was compiled.
5703
//% *
5704 5705 5706
//% * @param otherDictionary Dictionary containing entries to be added to this
//% *                        dictionary.
//% **/
5707 5708 5709 5710 5711 5712 5713
//%- (void)addRawEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary;
//%
//%// If value is not a valid enumerator as defined by validationFunc, these
//%// methods will assert in debug, and will log in release and assign the value
//%// to the default value. Use the rawValue methods below to assign non enumerator
//%// values.
//%
5714
//%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value)
5715 5716 5717 5718
//%
//%@end
//%

5719 5720
//%PDDM-DEFINE DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
//%VALUE_FOR_KEY_##VHELPER(KEY_TYPE##KisP$S##KisP, VALUE_TYPE, VNAME)
5721
//%
5722 5723
//%/**
//% * Enumerates the keys and values on this dictionary with the given block.
5724
//% *
5725 5726 5727 5728 5729
//% * @param block The block to enumerate with.
//% *   **key**: ##VNAME_VAR$S##  The key for the current entry.
//% *   **VNAME_VAR**:      The value for the current entry
//% *   **stop**: ##VNAME_VAR$S## A pointer to a boolean that when set stops the enumeration.
//% **/
5730 5731
//%- (void)enumerateKeysAnd##VNAME##sUsingBlock:
//%    (void (^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME_VAR, BOOL *stop))block;
5732

5733
//%PDDM-DEFINE DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR)
5734 5735
//%/**
//% * Sets the value for the given key.
5736
//% *
5737 5738 5739
//% * @param ##VNAME_VAR     The value to set.
//% * @param key ##VNAME_VAR$S## The key under which to store the value.
//% **/
5740
//%- (void)set##VNAME##:(VALUE_TYPE)##VNAME_VAR forKey:(KEY_TYPE##KisP$S##KisP)key;
5741
//%DICTIONARY_EXTRA_MUTABLE_METHODS_##VHELPER(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
5742 5743
//%/**
//% * Removes the entry for the given key.
5744
//% *
5745 5746
//% * @param aKey Key to be removed from this dictionary.
//% **/
5747
//%- (void)remove##VNAME##ForKey:(KEY_TYPE##KisP$S##KisP)aKey;
5748 5749 5750 5751
//%
//%/**
//% * Removes all entries in this dictionary.
//% **/
5752 5753 5754 5755 5756 5757 5758 5759
//%- (void)removeAll;

//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_POD(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
// Empty
//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_OBJECT(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
// Empty
//%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_Enum(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE)
//%
5760 5761
//%/**
//% * Sets the raw enum value for the given key.
5762
//% *
5763 5764
//% * @note This method bypass the validationFunc to enable the setting of values that
//% *       were not known at the time the binary was compiled.
5765
//% *
5766 5767 5768
//% * @param rawValue The raw enum value to set.
//% * @param key      The key under which to store the raw enum value.
//% **/
5769 5770
//%- (void)setRawValue:(VALUE_TYPE)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key;
//%