1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2008 Google Inc. All rights reserved. 3 // 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file or at 6 // https://developers.google.com/open-source/licenses/bsd 7 8 #import <Foundation/Foundation.h> 9 10 #import "GPBRuntimeTypes.h" 11 12 // Note on naming: for the classes holding numeric values, a more natural 13 // naming of the method might be things like "-valueForKey:", 14 // "-setValue:forKey:"; etc. But those selectors are also defined by Key Value 15 // Coding (KVC) as categories on NSObject. So "overloading" the selectors with 16 // other meanings can cause warnings (based on compiler settings), but more 17 // importantly, some of those selector get called as KVC breaks up keypaths. 18 // So if those selectors are used, using KVC will compile cleanly, but could 19 // crash as it invokes those selectors with the wrong types of arguments. 20 21 NS_ASSUME_NONNULL_BEGIN 22 23 // Disable clang-format for the macros. 24 // clang-format off 25 26 //%PDDM-EXPAND DECLARE_DICTIONARIES() 27 // This block of code is generated, do not edit it directly. 28 29 #pragma mark - UInt32 -> UInt32 30 31 /** 32 * Class used for map fields of <uint32_t, uint32_t> 33 * values. This performs better than boxing into NSNumbers in NSDictionaries. 34 * 35 * @note This class is not meant to be subclassed. 36 **/ 37 __attribute__((objc_subclassing_restricted)) 38 @interface GPBUInt32UInt32Dictionary : NSObject <NSCopying> 39 40 /** Number of entries stored in this dictionary. */ 41 @property(nonatomic, readonly) NSUInteger count; 42 43 /** 44 * Initializes this dictionary, copying the given values and keys. 45 * 46 * @param values The values to be placed in this dictionary. 47 * @param keys The keys under which to store the values. 48 * @param count The number of elements to copy into the dictionary. 49 * 50 * @return A newly initialized dictionary with a copy of the values and keys. 51 **/ 52 - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values 53 forKeys:(const uint32_t [__nullable])keys 54 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 55 56 /** 57 * Initializes this dictionary, copying the entries from the given dictionary. 58 * 59 * @param dictionary Dictionary containing the entries to add to this dictionary. 60 * 61 * @return A newly initialized dictionary with the entries of the given dictionary. 62 **/ 63 - (instancetype)initWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary; 64 65 /** 66 * Initializes this dictionary with the requested capacity. 67 * 68 * @param numItems Number of items needed for this dictionary. 69 * 70 * @return A newly initialized dictionary with the requested capacity. 71 **/ 72 - (instancetype)initWithCapacity:(NSUInteger)numItems; 73 74 /** 75 * Gets the value for the given key. 76 * 77 * @param value Pointer into which the value will be set, if found. 78 * @param key Key under which the value is stored, if present. 79 * 80 * @return YES if the key was found and the value was copied, NO otherwise. 81 **/ 82 - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint32_t)key; 83 84 /** 85 * Enumerates the keys and values on this dictionary with the given block. 86 * 87 * @param block The block to enumerate with. 88 * **key**: The key for the current entry. 89 * **value**: The value for the current entry 90 * **stop**: A pointer to a boolean that when set stops the enumeration. 91 **/ 92 - (void)enumerateKeysAndUInt32sUsingBlock: 93 (void (NS_NOESCAPE ^)(uint32_t key, uint32_t value, BOOL *stop))block; 94 95 /** 96 * Adds the keys and values from another dictionary. 97 * 98 * @param otherDictionary Dictionary containing entries to be added to this 99 * dictionary. 100 **/ 101 - (void)addEntriesFromDictionary:(GPBUInt32UInt32Dictionary *)otherDictionary; 102 103 /** 104 * Sets the value for the given key. 105 * 106 * @param value The value to set. 107 * @param key The key under which to store the value. 108 **/ 109 - (void)setUInt32:(uint32_t)value forKey:(uint32_t)key; 110 111 /** 112 * Removes the entry for the given key. 113 * 114 * @param aKey Key to be removed from this dictionary. 115 **/ 116 - (void)removeUInt32ForKey:(uint32_t)aKey; 117 118 /** 119 * Removes all entries in this dictionary. 120 **/ 121 - (void)removeAll; 122 123 @end 124 125 #pragma mark - UInt32 -> Int32 126 127 /** 128 * Class used for map fields of <uint32_t, int32_t> 129 * values. This performs better than boxing into NSNumbers in NSDictionaries. 130 * 131 * @note This class is not meant to be subclassed. 132 **/ 133 __attribute__((objc_subclassing_restricted)) 134 @interface GPBUInt32Int32Dictionary : NSObject <NSCopying> 135 136 /** Number of entries stored in this dictionary. */ 137 @property(nonatomic, readonly) NSUInteger count; 138 139 /** 140 * Initializes this dictionary, copying the given values and keys. 141 * 142 * @param values The values to be placed in this dictionary. 143 * @param keys The keys under which to store the values. 144 * @param count The number of elements to copy into the dictionary. 145 * 146 * @return A newly initialized dictionary with a copy of the values and keys. 147 **/ 148 - (instancetype)initWithInt32s:(const int32_t [__nullable])values 149 forKeys:(const uint32_t [__nullable])keys 150 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 151 152 /** 153 * Initializes this dictionary, copying the entries from the given dictionary. 154 * 155 * @param dictionary Dictionary containing the entries to add to this dictionary. 156 * 157 * @return A newly initialized dictionary with the entries of the given dictionary. 158 **/ 159 - (instancetype)initWithDictionary:(GPBUInt32Int32Dictionary *)dictionary; 160 161 /** 162 * Initializes this dictionary with the requested capacity. 163 * 164 * @param numItems Number of items needed for this dictionary. 165 * 166 * @return A newly initialized dictionary with the requested capacity. 167 **/ 168 - (instancetype)initWithCapacity:(NSUInteger)numItems; 169 170 /** 171 * Gets the value for the given key. 172 * 173 * @param value Pointer into which the value will be set, if found. 174 * @param key Key under which the value is stored, if present. 175 * 176 * @return YES if the key was found and the value was copied, NO otherwise. 177 **/ 178 - (BOOL)getInt32:(nullable int32_t *)value forKey:(uint32_t)key; 179 180 /** 181 * Enumerates the keys and values on this dictionary with the given block. 182 * 183 * @param block The block to enumerate with. 184 * **key**: The key for the current entry. 185 * **value**: The value for the current entry 186 * **stop**: A pointer to a boolean that when set stops the enumeration. 187 **/ 188 - (void)enumerateKeysAndInt32sUsingBlock: 189 (void (NS_NOESCAPE ^)(uint32_t key, int32_t value, BOOL *stop))block; 190 191 /** 192 * Adds the keys and values from another dictionary. 193 * 194 * @param otherDictionary Dictionary containing entries to be added to this 195 * dictionary. 196 **/ 197 - (void)addEntriesFromDictionary:(GPBUInt32Int32Dictionary *)otherDictionary; 198 199 /** 200 * Sets the value for the given key. 201 * 202 * @param value The value to set. 203 * @param key The key under which to store the value. 204 **/ 205 - (void)setInt32:(int32_t)value forKey:(uint32_t)key; 206 207 /** 208 * Removes the entry for the given key. 209 * 210 * @param aKey Key to be removed from this dictionary. 211 **/ 212 - (void)removeInt32ForKey:(uint32_t)aKey; 213 214 /** 215 * Removes all entries in this dictionary. 216 **/ 217 - (void)removeAll; 218 219 @end 220 221 #pragma mark - UInt32 -> UInt64 222 223 /** 224 * Class used for map fields of <uint32_t, uint64_t> 225 * values. This performs better than boxing into NSNumbers in NSDictionaries. 226 * 227 * @note This class is not meant to be subclassed. 228 **/ 229 __attribute__((objc_subclassing_restricted)) 230 @interface GPBUInt32UInt64Dictionary : NSObject <NSCopying> 231 232 /** Number of entries stored in this dictionary. */ 233 @property(nonatomic, readonly) NSUInteger count; 234 235 /** 236 * Initializes this dictionary, copying the given values and keys. 237 * 238 * @param values The values to be placed in this dictionary. 239 * @param keys The keys under which to store the values. 240 * @param count The number of elements to copy into the dictionary. 241 * 242 * @return A newly initialized dictionary with a copy of the values and keys. 243 **/ 244 - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values 245 forKeys:(const uint32_t [__nullable])keys 246 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 247 248 /** 249 * Initializes this dictionary, copying the entries from the given dictionary. 250 * 251 * @param dictionary Dictionary containing the entries to add to this dictionary. 252 * 253 * @return A newly initialized dictionary with the entries of the given dictionary. 254 **/ 255 - (instancetype)initWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary; 256 257 /** 258 * Initializes this dictionary with the requested capacity. 259 * 260 * @param numItems Number of items needed for this dictionary. 261 * 262 * @return A newly initialized dictionary with the requested capacity. 263 **/ 264 - (instancetype)initWithCapacity:(NSUInteger)numItems; 265 266 /** 267 * Gets the value for the given key. 268 * 269 * @param value Pointer into which the value will be set, if found. 270 * @param key Key under which the value is stored, if present. 271 * 272 * @return YES if the key was found and the value was copied, NO otherwise. 273 **/ 274 - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint32_t)key; 275 276 /** 277 * Enumerates the keys and values on this dictionary with the given block. 278 * 279 * @param block The block to enumerate with. 280 * **key**: The key for the current entry. 281 * **value**: The value for the current entry 282 * **stop**: A pointer to a boolean that when set stops the enumeration. 283 **/ 284 - (void)enumerateKeysAndUInt64sUsingBlock: 285 (void (NS_NOESCAPE ^)(uint32_t key, uint64_t value, BOOL *stop))block; 286 287 /** 288 * Adds the keys and values from another dictionary. 289 * 290 * @param otherDictionary Dictionary containing entries to be added to this 291 * dictionary. 292 **/ 293 - (void)addEntriesFromDictionary:(GPBUInt32UInt64Dictionary *)otherDictionary; 294 295 /** 296 * Sets the value for the given key. 297 * 298 * @param value The value to set. 299 * @param key The key under which to store the value. 300 **/ 301 - (void)setUInt64:(uint64_t)value forKey:(uint32_t)key; 302 303 /** 304 * Removes the entry for the given key. 305 * 306 * @param aKey Key to be removed from this dictionary. 307 **/ 308 - (void)removeUInt64ForKey:(uint32_t)aKey; 309 310 /** 311 * Removes all entries in this dictionary. 312 **/ 313 - (void)removeAll; 314 315 @end 316 317 #pragma mark - UInt32 -> Int64 318 319 /** 320 * Class used for map fields of <uint32_t, int64_t> 321 * values. This performs better than boxing into NSNumbers in NSDictionaries. 322 * 323 * @note This class is not meant to be subclassed. 324 **/ 325 __attribute__((objc_subclassing_restricted)) 326 @interface GPBUInt32Int64Dictionary : NSObject <NSCopying> 327 328 /** Number of entries stored in this dictionary. */ 329 @property(nonatomic, readonly) NSUInteger count; 330 331 /** 332 * Initializes this dictionary, copying the given values and keys. 333 * 334 * @param values The values to be placed in this dictionary. 335 * @param keys The keys under which to store the values. 336 * @param count The number of elements to copy into the dictionary. 337 * 338 * @return A newly initialized dictionary with a copy of the values and keys. 339 **/ 340 - (instancetype)initWithInt64s:(const int64_t [__nullable])values 341 forKeys:(const uint32_t [__nullable])keys 342 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 343 344 /** 345 * Initializes this dictionary, copying the entries from the given dictionary. 346 * 347 * @param dictionary Dictionary containing the entries to add to this dictionary. 348 * 349 * @return A newly initialized dictionary with the entries of the given dictionary. 350 **/ 351 - (instancetype)initWithDictionary:(GPBUInt32Int64Dictionary *)dictionary; 352 353 /** 354 * Initializes this dictionary with the requested capacity. 355 * 356 * @param numItems Number of items needed for this dictionary. 357 * 358 * @return A newly initialized dictionary with the requested capacity. 359 **/ 360 - (instancetype)initWithCapacity:(NSUInteger)numItems; 361 362 /** 363 * Gets the value for the given key. 364 * 365 * @param value Pointer into which the value will be set, if found. 366 * @param key Key under which the value is stored, if present. 367 * 368 * @return YES if the key was found and the value was copied, NO otherwise. 369 **/ 370 - (BOOL)getInt64:(nullable int64_t *)value forKey:(uint32_t)key; 371 372 /** 373 * Enumerates the keys and values on this dictionary with the given block. 374 * 375 * @param block The block to enumerate with. 376 * **key**: The key for the current entry. 377 * **value**: The value for the current entry 378 * **stop**: A pointer to a boolean that when set stops the enumeration. 379 **/ 380 - (void)enumerateKeysAndInt64sUsingBlock: 381 (void (NS_NOESCAPE ^)(uint32_t key, int64_t value, BOOL *stop))block; 382 383 /** 384 * Adds the keys and values from another dictionary. 385 * 386 * @param otherDictionary Dictionary containing entries to be added to this 387 * dictionary. 388 **/ 389 - (void)addEntriesFromDictionary:(GPBUInt32Int64Dictionary *)otherDictionary; 390 391 /** 392 * Sets the value for the given key. 393 * 394 * @param value The value to set. 395 * @param key The key under which to store the value. 396 **/ 397 - (void)setInt64:(int64_t)value forKey:(uint32_t)key; 398 399 /** 400 * Removes the entry for the given key. 401 * 402 * @param aKey Key to be removed from this dictionary. 403 **/ 404 - (void)removeInt64ForKey:(uint32_t)aKey; 405 406 /** 407 * Removes all entries in this dictionary. 408 **/ 409 - (void)removeAll; 410 411 @end 412 413 #pragma mark - UInt32 -> Bool 414 415 /** 416 * Class used for map fields of <uint32_t, BOOL> 417 * values. This performs better than boxing into NSNumbers in NSDictionaries. 418 * 419 * @note This class is not meant to be subclassed. 420 **/ 421 __attribute__((objc_subclassing_restricted)) 422 @interface GPBUInt32BoolDictionary : NSObject <NSCopying> 423 424 /** Number of entries stored in this dictionary. */ 425 @property(nonatomic, readonly) NSUInteger count; 426 427 /** 428 * Initializes this dictionary, copying the given values and keys. 429 * 430 * @param values The values to be placed in this dictionary. 431 * @param keys The keys under which to store the values. 432 * @param count The number of elements to copy into the dictionary. 433 * 434 * @return A newly initialized dictionary with a copy of the values and keys. 435 **/ 436 - (instancetype)initWithBools:(const BOOL [__nullable])values 437 forKeys:(const uint32_t [__nullable])keys 438 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 439 440 /** 441 * Initializes this dictionary, copying the entries from the given dictionary. 442 * 443 * @param dictionary Dictionary containing the entries to add to this dictionary. 444 * 445 * @return A newly initialized dictionary with the entries of the given dictionary. 446 **/ 447 - (instancetype)initWithDictionary:(GPBUInt32BoolDictionary *)dictionary; 448 449 /** 450 * Initializes this dictionary with the requested capacity. 451 * 452 * @param numItems Number of items needed for this dictionary. 453 * 454 * @return A newly initialized dictionary with the requested capacity. 455 **/ 456 - (instancetype)initWithCapacity:(NSUInteger)numItems; 457 458 /** 459 * Gets the value for the given key. 460 * 461 * @param value Pointer into which the value will be set, if found. 462 * @param key Key under which the value is stored, if present. 463 * 464 * @return YES if the key was found and the value was copied, NO otherwise. 465 **/ 466 - (BOOL)getBool:(nullable BOOL *)value forKey:(uint32_t)key; 467 468 /** 469 * Enumerates the keys and values on this dictionary with the given block. 470 * 471 * @param block The block to enumerate with. 472 * **key**: The key for the current entry. 473 * **value**: The value for the current entry 474 * **stop**: A pointer to a boolean that when set stops the enumeration. 475 **/ 476 - (void)enumerateKeysAndBoolsUsingBlock: 477 (void (NS_NOESCAPE ^)(uint32_t key, BOOL value, BOOL *stop))block; 478 479 /** 480 * Adds the keys and values from another dictionary. 481 * 482 * @param otherDictionary Dictionary containing entries to be added to this 483 * dictionary. 484 **/ 485 - (void)addEntriesFromDictionary:(GPBUInt32BoolDictionary *)otherDictionary; 486 487 /** 488 * Sets the value for the given key. 489 * 490 * @param value The value to set. 491 * @param key The key under which to store the value. 492 **/ 493 - (void)setBool:(BOOL)value forKey:(uint32_t)key; 494 495 /** 496 * Removes the entry for the given key. 497 * 498 * @param aKey Key to be removed from this dictionary. 499 **/ 500 - (void)removeBoolForKey:(uint32_t)aKey; 501 502 /** 503 * Removes all entries in this dictionary. 504 **/ 505 - (void)removeAll; 506 507 @end 508 509 #pragma mark - UInt32 -> Float 510 511 /** 512 * Class used for map fields of <uint32_t, float> 513 * values. This performs better than boxing into NSNumbers in NSDictionaries. 514 * 515 * @note This class is not meant to be subclassed. 516 **/ 517 __attribute__((objc_subclassing_restricted)) 518 @interface GPBUInt32FloatDictionary : NSObject <NSCopying> 519 520 /** Number of entries stored in this dictionary. */ 521 @property(nonatomic, readonly) NSUInteger count; 522 523 /** 524 * Initializes this dictionary, copying the given values and keys. 525 * 526 * @param values The values to be placed in this dictionary. 527 * @param keys The keys under which to store the values. 528 * @param count The number of elements to copy into the dictionary. 529 * 530 * @return A newly initialized dictionary with a copy of the values and keys. 531 **/ 532 - (instancetype)initWithFloats:(const float [__nullable])values 533 forKeys:(const uint32_t [__nullable])keys 534 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 535 536 /** 537 * Initializes this dictionary, copying the entries from the given dictionary. 538 * 539 * @param dictionary Dictionary containing the entries to add to this dictionary. 540 * 541 * @return A newly initialized dictionary with the entries of the given dictionary. 542 **/ 543 - (instancetype)initWithDictionary:(GPBUInt32FloatDictionary *)dictionary; 544 545 /** 546 * Initializes this dictionary with the requested capacity. 547 * 548 * @param numItems Number of items needed for this dictionary. 549 * 550 * @return A newly initialized dictionary with the requested capacity. 551 **/ 552 - (instancetype)initWithCapacity:(NSUInteger)numItems; 553 554 /** 555 * Gets the value for the given key. 556 * 557 * @param value Pointer into which the value will be set, if found. 558 * @param key Key under which the value is stored, if present. 559 * 560 * @return YES if the key was found and the value was copied, NO otherwise. 561 **/ 562 - (BOOL)getFloat:(nullable float *)value forKey:(uint32_t)key; 563 564 /** 565 * Enumerates the keys and values on this dictionary with the given block. 566 * 567 * @param block The block to enumerate with. 568 * **key**: The key for the current entry. 569 * **value**: The value for the current entry 570 * **stop**: A pointer to a boolean that when set stops the enumeration. 571 **/ 572 - (void)enumerateKeysAndFloatsUsingBlock: 573 (void (NS_NOESCAPE ^)(uint32_t key, float value, BOOL *stop))block; 574 575 /** 576 * Adds the keys and values from another dictionary. 577 * 578 * @param otherDictionary Dictionary containing entries to be added to this 579 * dictionary. 580 **/ 581 - (void)addEntriesFromDictionary:(GPBUInt32FloatDictionary *)otherDictionary; 582 583 /** 584 * Sets the value for the given key. 585 * 586 * @param value The value to set. 587 * @param key The key under which to store the value. 588 **/ 589 - (void)setFloat:(float)value forKey:(uint32_t)key; 590 591 /** 592 * Removes the entry for the given key. 593 * 594 * @param aKey Key to be removed from this dictionary. 595 **/ 596 - (void)removeFloatForKey:(uint32_t)aKey; 597 598 /** 599 * Removes all entries in this dictionary. 600 **/ 601 - (void)removeAll; 602 603 @end 604 605 #pragma mark - UInt32 -> Double 606 607 /** 608 * Class used for map fields of <uint32_t, double> 609 * values. This performs better than boxing into NSNumbers in NSDictionaries. 610 * 611 * @note This class is not meant to be subclassed. 612 **/ 613 __attribute__((objc_subclassing_restricted)) 614 @interface GPBUInt32DoubleDictionary : NSObject <NSCopying> 615 616 /** Number of entries stored in this dictionary. */ 617 @property(nonatomic, readonly) NSUInteger count; 618 619 /** 620 * Initializes this dictionary, copying the given values and keys. 621 * 622 * @param values The values to be placed in this dictionary. 623 * @param keys The keys under which to store the values. 624 * @param count The number of elements to copy into the dictionary. 625 * 626 * @return A newly initialized dictionary with a copy of the values and keys. 627 **/ 628 - (instancetype)initWithDoubles:(const double [__nullable])values 629 forKeys:(const uint32_t [__nullable])keys 630 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 631 632 /** 633 * Initializes this dictionary, copying the entries from the given dictionary. 634 * 635 * @param dictionary Dictionary containing the entries to add to this dictionary. 636 * 637 * @return A newly initialized dictionary with the entries of the given dictionary. 638 **/ 639 - (instancetype)initWithDictionary:(GPBUInt32DoubleDictionary *)dictionary; 640 641 /** 642 * Initializes this dictionary with the requested capacity. 643 * 644 * @param numItems Number of items needed for this dictionary. 645 * 646 * @return A newly initialized dictionary with the requested capacity. 647 **/ 648 - (instancetype)initWithCapacity:(NSUInteger)numItems; 649 650 /** 651 * Gets the value for the given key. 652 * 653 * @param value Pointer into which the value will be set, if found. 654 * @param key Key under which the value is stored, if present. 655 * 656 * @return YES if the key was found and the value was copied, NO otherwise. 657 **/ 658 - (BOOL)getDouble:(nullable double *)value forKey:(uint32_t)key; 659 660 /** 661 * Enumerates the keys and values on this dictionary with the given block. 662 * 663 * @param block The block to enumerate with. 664 * **key**: The key for the current entry. 665 * **value**: The value for the current entry 666 * **stop**: A pointer to a boolean that when set stops the enumeration. 667 **/ 668 - (void)enumerateKeysAndDoublesUsingBlock: 669 (void (NS_NOESCAPE ^)(uint32_t key, double value, BOOL *stop))block; 670 671 /** 672 * Adds the keys and values from another dictionary. 673 * 674 * @param otherDictionary Dictionary containing entries to be added to this 675 * dictionary. 676 **/ 677 - (void)addEntriesFromDictionary:(GPBUInt32DoubleDictionary *)otherDictionary; 678 679 /** 680 * Sets the value for the given key. 681 * 682 * @param value The value to set. 683 * @param key The key under which to store the value. 684 **/ 685 - (void)setDouble:(double)value forKey:(uint32_t)key; 686 687 /** 688 * Removes the entry for the given key. 689 * 690 * @param aKey Key to be removed from this dictionary. 691 **/ 692 - (void)removeDoubleForKey:(uint32_t)aKey; 693 694 /** 695 * Removes all entries in this dictionary. 696 **/ 697 - (void)removeAll; 698 699 @end 700 701 #pragma mark - UInt32 -> Enum 702 703 /** 704 * Class used for map fields of <uint32_t, int32_t> 705 * values. This performs better than boxing into NSNumbers in NSDictionaries. 706 * 707 * @note This class is not meant to be subclassed. 708 **/ 709 __attribute__((objc_subclassing_restricted)) 710 @interface GPBUInt32EnumDictionary : NSObject <NSCopying> 711 712 /** Number of entries stored in this dictionary. */ 713 @property(nonatomic, readonly) NSUInteger count; 714 /** The validation function to check if the enums are valid. */ 715 @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; 716 717 /** 718 * Initializes a dictionary with the given validation function. 719 * 720 * @param func The enum validation function for the dictionary. 721 * 722 * @return A newly initialized dictionary. 723 **/ 724 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; 725 726 /** 727 * Initializes a dictionary with the entries given. 728 * 729 * @param func The enum validation function for the dictionary. 730 * @param values The raw enum values values to be placed in the dictionary. 731 * @param keys The keys under which to store the values. 732 * @param count The number of entries to store in the dictionary. 733 * 734 * @return A newly initialized dictionary with the keys and values in it. 735 **/ 736 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 737 rawValues:(const int32_t [__nullable])values 738 forKeys:(const uint32_t [__nullable])keys 739 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 740 741 /** 742 * Initializes a dictionary with the entries from the given. 743 * dictionary. 744 * 745 * @param dictionary Dictionary containing the entries to add to the dictionary. 746 * 747 * @return A newly initialized dictionary with the entries from the given 748 * dictionary in it. 749 **/ 750 - (instancetype)initWithDictionary:(GPBUInt32EnumDictionary *)dictionary; 751 752 /** 753 * Initializes a dictionary with the given capacity. 754 * 755 * @param func The enum validation function for the dictionary. 756 * @param numItems Capacity needed for the dictionary. 757 * 758 * @return A newly initialized dictionary with the given capacity. 759 **/ 760 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 761 capacity:(NSUInteger)numItems; 762 763 // These will return kGPBUnrecognizedEnumeratorValue if the value for the key 764 // is not a valid enumerator as defined by validationFunc. If the actual value is 765 // desired, use "raw" version of the method. 766 767 /** 768 * Gets the value for the given key. 769 * 770 * @param value Pointer into which the value will be set, if found. 771 * @param key Key under which the value is stored, if present. 772 * 773 * @return YES if the key was found and the value was copied, NO otherwise. 774 **/ 775 - (BOOL)getEnum:(nullable int32_t *)value forKey:(uint32_t)key; 776 777 /** 778 * Enumerates the keys and values on this dictionary with the given block. 779 * 780 * @param block The block to enumerate with. 781 * **key**: The key for the current entry. 782 * **value**: The value for the current entry 783 * **stop**: A pointer to a boolean that when set stops the enumeration. 784 **/ 785 - (void)enumerateKeysAndEnumsUsingBlock: 786 (void (NS_NOESCAPE ^)(uint32_t key, int32_t value, BOOL *stop))block; 787 788 /** 789 * Gets the raw enum value for the given key. 790 * 791 * @note This method bypass the validationFunc to enable the access of values that 792 * were not known at the time the binary was compiled. 793 * 794 * @param rawValue Pointer into which the value will be set, if found. 795 * @param key Key under which the value is stored, if present. 796 * 797 * @return YES if the key was found and the value was copied, NO otherwise. 798 **/ 799 - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint32_t)key; 800 801 /** 802 * Enumerates the keys and values on this dictionary with the given block. 803 * 804 * @note This method bypass the validationFunc to enable the access of values that 805 * were not known at the time the binary was compiled. 806 * 807 * @param block The block to enumerate with. 808 * **key**: The key for the current entry. 809 * **rawValue**: The value for the current entry 810 * **stop**: A pointer to a boolean that when set stops the enumeration. 811 **/ 812 - (void)enumerateKeysAndRawValuesUsingBlock: 813 (void (NS_NOESCAPE ^)(uint32_t key, int32_t rawValue, BOOL *stop))block; 814 815 /** 816 * Adds the keys and raw enum values from another dictionary. 817 * 818 * @note This method bypass the validationFunc to enable the setting of values that 819 * were not known at the time the binary was compiled. 820 * 821 * @param otherDictionary Dictionary containing entries to be added to this 822 * dictionary. 823 **/ 824 - (void)addRawEntriesFromDictionary:(GPBUInt32EnumDictionary *)otherDictionary; 825 826 // If value is not a valid enumerator as defined by validationFunc, these 827 // methods will assert in debug, and will log in release and assign the value 828 // to the default value. Use the rawValue methods below to assign non enumerator 829 // values. 830 831 /** 832 * Sets the value for the given key. 833 * 834 * @param value The value to set. 835 * @param key The key under which to store the value. 836 **/ 837 - (void)setEnum:(int32_t)value forKey:(uint32_t)key; 838 839 /** 840 * Sets the raw enum value for the given key. 841 * 842 * @note This method bypass the validationFunc to enable the setting of values that 843 * were not known at the time the binary was compiled. 844 * 845 * @param rawValue The raw enum value to set. 846 * @param key The key under which to store the raw enum value. 847 **/ 848 - (void)setRawValue:(int32_t)rawValue forKey:(uint32_t)key; 849 850 /** 851 * Removes the entry for the given key. 852 * 853 * @param aKey Key to be removed from this dictionary. 854 **/ 855 - (void)removeEnumForKey:(uint32_t)aKey; 856 857 /** 858 * Removes all entries in this dictionary. 859 **/ 860 - (void)removeAll; 861 862 @end 863 864 #pragma mark - UInt32 -> Object 865 866 /** 867 * Class used for map fields of <uint32_t, ObjectType> 868 * values. This performs better than boxing into NSNumbers in NSDictionaries. 869 * 870 * @note This class is not meant to be subclassed. 871 **/ 872 __attribute__((objc_subclassing_restricted)) 873 @interface GPBUInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying> 874 875 /** Number of entries stored in this dictionary. */ 876 @property(nonatomic, readonly) NSUInteger count; 877 878 /** 879 * Initializes this dictionary, copying the given values and keys. 880 * 881 * @param objects The values to be placed in this dictionary. 882 * @param keys The keys under which to store the values. 883 * @param count The number of elements to copy into the dictionary. 884 * 885 * @return A newly initialized dictionary with a copy of the values and keys. 886 **/ 887 - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects 888 forKeys:(const uint32_t [__nullable])keys 889 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 890 891 /** 892 * Initializes this dictionary, copying the entries from the given dictionary. 893 * 894 * @param dictionary Dictionary containing the entries to add to this dictionary. 895 * 896 * @return A newly initialized dictionary with the entries of the given dictionary. 897 **/ 898 - (instancetype)initWithDictionary:(GPBUInt32ObjectDictionary *)dictionary; 899 900 /** 901 * Initializes this dictionary with the requested capacity. 902 * 903 * @param numItems Number of items needed for this dictionary. 904 * 905 * @return A newly initialized dictionary with the requested capacity. 906 **/ 907 - (instancetype)initWithCapacity:(NSUInteger)numItems; 908 909 /** 910 * Fetches the object stored under the given key. 911 * 912 * @param key Key under which the value is stored, if present. 913 * 914 * @return The object if found, nil otherwise. 915 **/ 916 - (ObjectType)objectForKey:(uint32_t)key; 917 918 /** 919 * Enumerates the keys and values on this dictionary with the given block. 920 * 921 * @param block The block to enumerate with. 922 * **key**: The key for the current entry. 923 * **object**: The value for the current entry 924 * **stop**: A pointer to a boolean that when set stops the enumeration. 925 **/ 926 - (void)enumerateKeysAndObjectsUsingBlock: 927 (void (NS_NOESCAPE ^)(uint32_t key, ObjectType object, BOOL *stop))block; 928 929 /** 930 * Adds the keys and values from another dictionary. 931 * 932 * @param otherDictionary Dictionary containing entries to be added to this 933 * dictionary. 934 **/ 935 - (void)addEntriesFromDictionary:(GPBUInt32ObjectDictionary *)otherDictionary; 936 937 /** 938 * Sets the value for the given key. 939 * 940 * @param object The value to set. 941 * @param key The key under which to store the value. 942 **/ 943 - (void)setObject:(ObjectType)object forKey:(uint32_t)key; 944 945 /** 946 * Removes the entry for the given key. 947 * 948 * @param aKey Key to be removed from this dictionary. 949 **/ 950 - (void)removeObjectForKey:(uint32_t)aKey; 951 952 /** 953 * Removes all entries in this dictionary. 954 **/ 955 - (void)removeAll; 956 957 @end 958 959 #pragma mark - Int32 -> UInt32 960 961 /** 962 * Class used for map fields of <int32_t, uint32_t> 963 * values. This performs better than boxing into NSNumbers in NSDictionaries. 964 * 965 * @note This class is not meant to be subclassed. 966 **/ 967 __attribute__((objc_subclassing_restricted)) 968 @interface GPBInt32UInt32Dictionary : NSObject <NSCopying> 969 970 /** Number of entries stored in this dictionary. */ 971 @property(nonatomic, readonly) NSUInteger count; 972 973 /** 974 * Initializes this dictionary, copying the given values and keys. 975 * 976 * @param values The values to be placed in this dictionary. 977 * @param keys The keys under which to store the values. 978 * @param count The number of elements to copy into the dictionary. 979 * 980 * @return A newly initialized dictionary with a copy of the values and keys. 981 **/ 982 - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values 983 forKeys:(const int32_t [__nullable])keys 984 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 985 986 /** 987 * Initializes this dictionary, copying the entries from the given dictionary. 988 * 989 * @param dictionary Dictionary containing the entries to add to this dictionary. 990 * 991 * @return A newly initialized dictionary with the entries of the given dictionary. 992 **/ 993 - (instancetype)initWithDictionary:(GPBInt32UInt32Dictionary *)dictionary; 994 995 /** 996 * Initializes this dictionary with the requested capacity. 997 * 998 * @param numItems Number of items needed for this dictionary. 999 * 1000 * @return A newly initialized dictionary with the requested capacity. 1001 **/ 1002 - (instancetype)initWithCapacity:(NSUInteger)numItems; 1003 1004 /** 1005 * Gets the value for the given key. 1006 * 1007 * @param value Pointer into which the value will be set, if found. 1008 * @param key Key under which the value is stored, if present. 1009 * 1010 * @return YES if the key was found and the value was copied, NO otherwise. 1011 **/ 1012 - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int32_t)key; 1013 1014 /** 1015 * Enumerates the keys and values on this dictionary with the given block. 1016 * 1017 * @param block The block to enumerate with. 1018 * **key**: The key for the current entry. 1019 * **value**: The value for the current entry 1020 * **stop**: A pointer to a boolean that when set stops the enumeration. 1021 **/ 1022 - (void)enumerateKeysAndUInt32sUsingBlock: 1023 (void (NS_NOESCAPE ^)(int32_t key, uint32_t value, BOOL *stop))block; 1024 1025 /** 1026 * Adds the keys and values from another dictionary. 1027 * 1028 * @param otherDictionary Dictionary containing entries to be added to this 1029 * dictionary. 1030 **/ 1031 - (void)addEntriesFromDictionary:(GPBInt32UInt32Dictionary *)otherDictionary; 1032 1033 /** 1034 * Sets the value for the given key. 1035 * 1036 * @param value The value to set. 1037 * @param key The key under which to store the value. 1038 **/ 1039 - (void)setUInt32:(uint32_t)value forKey:(int32_t)key; 1040 1041 /** 1042 * Removes the entry for the given key. 1043 * 1044 * @param aKey Key to be removed from this dictionary. 1045 **/ 1046 - (void)removeUInt32ForKey:(int32_t)aKey; 1047 1048 /** 1049 * Removes all entries in this dictionary. 1050 **/ 1051 - (void)removeAll; 1052 1053 @end 1054 1055 #pragma mark - Int32 -> Int32 1056 1057 /** 1058 * Class used for map fields of <int32_t, int32_t> 1059 * values. This performs better than boxing into NSNumbers in NSDictionaries. 1060 * 1061 * @note This class is not meant to be subclassed. 1062 **/ 1063 __attribute__((objc_subclassing_restricted)) 1064 @interface GPBInt32Int32Dictionary : NSObject <NSCopying> 1065 1066 /** Number of entries stored in this dictionary. */ 1067 @property(nonatomic, readonly) NSUInteger count; 1068 1069 /** 1070 * Initializes this dictionary, copying the given values and keys. 1071 * 1072 * @param values The values to be placed in this dictionary. 1073 * @param keys The keys under which to store the values. 1074 * @param count The number of elements to copy into the dictionary. 1075 * 1076 * @return A newly initialized dictionary with a copy of the values and keys. 1077 **/ 1078 - (instancetype)initWithInt32s:(const int32_t [__nullable])values 1079 forKeys:(const int32_t [__nullable])keys 1080 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 1081 1082 /** 1083 * Initializes this dictionary, copying the entries from the given dictionary. 1084 * 1085 * @param dictionary Dictionary containing the entries to add to this dictionary. 1086 * 1087 * @return A newly initialized dictionary with the entries of the given dictionary. 1088 **/ 1089 - (instancetype)initWithDictionary:(GPBInt32Int32Dictionary *)dictionary; 1090 1091 /** 1092 * Initializes this dictionary with the requested capacity. 1093 * 1094 * @param numItems Number of items needed for this dictionary. 1095 * 1096 * @return A newly initialized dictionary with the requested capacity. 1097 **/ 1098 - (instancetype)initWithCapacity:(NSUInteger)numItems; 1099 1100 /** 1101 * Gets the value for the given key. 1102 * 1103 * @param value Pointer into which the value will be set, if found. 1104 * @param key Key under which the value is stored, if present. 1105 * 1106 * @return YES if the key was found and the value was copied, NO otherwise. 1107 **/ 1108 - (BOOL)getInt32:(nullable int32_t *)value forKey:(int32_t)key; 1109 1110 /** 1111 * Enumerates the keys and values on this dictionary with the given block. 1112 * 1113 * @param block The block to enumerate with. 1114 * **key**: The key for the current entry. 1115 * **value**: The value for the current entry 1116 * **stop**: A pointer to a boolean that when set stops the enumeration. 1117 **/ 1118 - (void)enumerateKeysAndInt32sUsingBlock: 1119 (void (NS_NOESCAPE ^)(int32_t key, int32_t value, BOOL *stop))block; 1120 1121 /** 1122 * Adds the keys and values from another dictionary. 1123 * 1124 * @param otherDictionary Dictionary containing entries to be added to this 1125 * dictionary. 1126 **/ 1127 - (void)addEntriesFromDictionary:(GPBInt32Int32Dictionary *)otherDictionary; 1128 1129 /** 1130 * Sets the value for the given key. 1131 * 1132 * @param value The value to set. 1133 * @param key The key under which to store the value. 1134 **/ 1135 - (void)setInt32:(int32_t)value forKey:(int32_t)key; 1136 1137 /** 1138 * Removes the entry for the given key. 1139 * 1140 * @param aKey Key to be removed from this dictionary. 1141 **/ 1142 - (void)removeInt32ForKey:(int32_t)aKey; 1143 1144 /** 1145 * Removes all entries in this dictionary. 1146 **/ 1147 - (void)removeAll; 1148 1149 @end 1150 1151 #pragma mark - Int32 -> UInt64 1152 1153 /** 1154 * Class used for map fields of <int32_t, uint64_t> 1155 * values. This performs better than boxing into NSNumbers in NSDictionaries. 1156 * 1157 * @note This class is not meant to be subclassed. 1158 **/ 1159 __attribute__((objc_subclassing_restricted)) 1160 @interface GPBInt32UInt64Dictionary : NSObject <NSCopying> 1161 1162 /** Number of entries stored in this dictionary. */ 1163 @property(nonatomic, readonly) NSUInteger count; 1164 1165 /** 1166 * Initializes this dictionary, copying the given values and keys. 1167 * 1168 * @param values The values to be placed in this dictionary. 1169 * @param keys The keys under which to store the values. 1170 * @param count The number of elements to copy into the dictionary. 1171 * 1172 * @return A newly initialized dictionary with a copy of the values and keys. 1173 **/ 1174 - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values 1175 forKeys:(const int32_t [__nullable])keys 1176 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 1177 1178 /** 1179 * Initializes this dictionary, copying the entries from the given dictionary. 1180 * 1181 * @param dictionary Dictionary containing the entries to add to this dictionary. 1182 * 1183 * @return A newly initialized dictionary with the entries of the given dictionary. 1184 **/ 1185 - (instancetype)initWithDictionary:(GPBInt32UInt64Dictionary *)dictionary; 1186 1187 /** 1188 * Initializes this dictionary with the requested capacity. 1189 * 1190 * @param numItems Number of items needed for this dictionary. 1191 * 1192 * @return A newly initialized dictionary with the requested capacity. 1193 **/ 1194 - (instancetype)initWithCapacity:(NSUInteger)numItems; 1195 1196 /** 1197 * Gets the value for the given key. 1198 * 1199 * @param value Pointer into which the value will be set, if found. 1200 * @param key Key under which the value is stored, if present. 1201 * 1202 * @return YES if the key was found and the value was copied, NO otherwise. 1203 **/ 1204 - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int32_t)key; 1205 1206 /** 1207 * Enumerates the keys and values on this dictionary with the given block. 1208 * 1209 * @param block The block to enumerate with. 1210 * **key**: The key for the current entry. 1211 * **value**: The value for the current entry 1212 * **stop**: A pointer to a boolean that when set stops the enumeration. 1213 **/ 1214 - (void)enumerateKeysAndUInt64sUsingBlock: 1215 (void (NS_NOESCAPE ^)(int32_t key, uint64_t value, BOOL *stop))block; 1216 1217 /** 1218 * Adds the keys and values from another dictionary. 1219 * 1220 * @param otherDictionary Dictionary containing entries to be added to this 1221 * dictionary. 1222 **/ 1223 - (void)addEntriesFromDictionary:(GPBInt32UInt64Dictionary *)otherDictionary; 1224 1225 /** 1226 * Sets the value for the given key. 1227 * 1228 * @param value The value to set. 1229 * @param key The key under which to store the value. 1230 **/ 1231 - (void)setUInt64:(uint64_t)value forKey:(int32_t)key; 1232 1233 /** 1234 * Removes the entry for the given key. 1235 * 1236 * @param aKey Key to be removed from this dictionary. 1237 **/ 1238 - (void)removeUInt64ForKey:(int32_t)aKey; 1239 1240 /** 1241 * Removes all entries in this dictionary. 1242 **/ 1243 - (void)removeAll; 1244 1245 @end 1246 1247 #pragma mark - Int32 -> Int64 1248 1249 /** 1250 * Class used for map fields of <int32_t, int64_t> 1251 * values. This performs better than boxing into NSNumbers in NSDictionaries. 1252 * 1253 * @note This class is not meant to be subclassed. 1254 **/ 1255 __attribute__((objc_subclassing_restricted)) 1256 @interface GPBInt32Int64Dictionary : NSObject <NSCopying> 1257 1258 /** Number of entries stored in this dictionary. */ 1259 @property(nonatomic, readonly) NSUInteger count; 1260 1261 /** 1262 * Initializes this dictionary, copying the given values and keys. 1263 * 1264 * @param values The values to be placed in this dictionary. 1265 * @param keys The keys under which to store the values. 1266 * @param count The number of elements to copy into the dictionary. 1267 * 1268 * @return A newly initialized dictionary with a copy of the values and keys. 1269 **/ 1270 - (instancetype)initWithInt64s:(const int64_t [__nullable])values 1271 forKeys:(const int32_t [__nullable])keys 1272 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 1273 1274 /** 1275 * Initializes this dictionary, copying the entries from the given dictionary. 1276 * 1277 * @param dictionary Dictionary containing the entries to add to this dictionary. 1278 * 1279 * @return A newly initialized dictionary with the entries of the given dictionary. 1280 **/ 1281 - (instancetype)initWithDictionary:(GPBInt32Int64Dictionary *)dictionary; 1282 1283 /** 1284 * Initializes this dictionary with the requested capacity. 1285 * 1286 * @param numItems Number of items needed for this dictionary. 1287 * 1288 * @return A newly initialized dictionary with the requested capacity. 1289 **/ 1290 - (instancetype)initWithCapacity:(NSUInteger)numItems; 1291 1292 /** 1293 * Gets the value for the given key. 1294 * 1295 * @param value Pointer into which the value will be set, if found. 1296 * @param key Key under which the value is stored, if present. 1297 * 1298 * @return YES if the key was found and the value was copied, NO otherwise. 1299 **/ 1300 - (BOOL)getInt64:(nullable int64_t *)value forKey:(int32_t)key; 1301 1302 /** 1303 * Enumerates the keys and values on this dictionary with the given block. 1304 * 1305 * @param block The block to enumerate with. 1306 * **key**: The key for the current entry. 1307 * **value**: The value for the current entry 1308 * **stop**: A pointer to a boolean that when set stops the enumeration. 1309 **/ 1310 - (void)enumerateKeysAndInt64sUsingBlock: 1311 (void (NS_NOESCAPE ^)(int32_t key, int64_t value, BOOL *stop))block; 1312 1313 /** 1314 * Adds the keys and values from another dictionary. 1315 * 1316 * @param otherDictionary Dictionary containing entries to be added to this 1317 * dictionary. 1318 **/ 1319 - (void)addEntriesFromDictionary:(GPBInt32Int64Dictionary *)otherDictionary; 1320 1321 /** 1322 * Sets the value for the given key. 1323 * 1324 * @param value The value to set. 1325 * @param key The key under which to store the value. 1326 **/ 1327 - (void)setInt64:(int64_t)value forKey:(int32_t)key; 1328 1329 /** 1330 * Removes the entry for the given key. 1331 * 1332 * @param aKey Key to be removed from this dictionary. 1333 **/ 1334 - (void)removeInt64ForKey:(int32_t)aKey; 1335 1336 /** 1337 * Removes all entries in this dictionary. 1338 **/ 1339 - (void)removeAll; 1340 1341 @end 1342 1343 #pragma mark - Int32 -> Bool 1344 1345 /** 1346 * Class used for map fields of <int32_t, BOOL> 1347 * values. This performs better than boxing into NSNumbers in NSDictionaries. 1348 * 1349 * @note This class is not meant to be subclassed. 1350 **/ 1351 __attribute__((objc_subclassing_restricted)) 1352 @interface GPBInt32BoolDictionary : NSObject <NSCopying> 1353 1354 /** Number of entries stored in this dictionary. */ 1355 @property(nonatomic, readonly) NSUInteger count; 1356 1357 /** 1358 * Initializes this dictionary, copying the given values and keys. 1359 * 1360 * @param values The values to be placed in this dictionary. 1361 * @param keys The keys under which to store the values. 1362 * @param count The number of elements to copy into the dictionary. 1363 * 1364 * @return A newly initialized dictionary with a copy of the values and keys. 1365 **/ 1366 - (instancetype)initWithBools:(const BOOL [__nullable])values 1367 forKeys:(const int32_t [__nullable])keys 1368 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 1369 1370 /** 1371 * Initializes this dictionary, copying the entries from the given dictionary. 1372 * 1373 * @param dictionary Dictionary containing the entries to add to this dictionary. 1374 * 1375 * @return A newly initialized dictionary with the entries of the given dictionary. 1376 **/ 1377 - (instancetype)initWithDictionary:(GPBInt32BoolDictionary *)dictionary; 1378 1379 /** 1380 * Initializes this dictionary with the requested capacity. 1381 * 1382 * @param numItems Number of items needed for this dictionary. 1383 * 1384 * @return A newly initialized dictionary with the requested capacity. 1385 **/ 1386 - (instancetype)initWithCapacity:(NSUInteger)numItems; 1387 1388 /** 1389 * Gets the value for the given key. 1390 * 1391 * @param value Pointer into which the value will be set, if found. 1392 * @param key Key under which the value is stored, if present. 1393 * 1394 * @return YES if the key was found and the value was copied, NO otherwise. 1395 **/ 1396 - (BOOL)getBool:(nullable BOOL *)value forKey:(int32_t)key; 1397 1398 /** 1399 * Enumerates the keys and values on this dictionary with the given block. 1400 * 1401 * @param block The block to enumerate with. 1402 * **key**: The key for the current entry. 1403 * **value**: The value for the current entry 1404 * **stop**: A pointer to a boolean that when set stops the enumeration. 1405 **/ 1406 - (void)enumerateKeysAndBoolsUsingBlock: 1407 (void (NS_NOESCAPE ^)(int32_t key, BOOL value, BOOL *stop))block; 1408 1409 /** 1410 * Adds the keys and values from another dictionary. 1411 * 1412 * @param otherDictionary Dictionary containing entries to be added to this 1413 * dictionary. 1414 **/ 1415 - (void)addEntriesFromDictionary:(GPBInt32BoolDictionary *)otherDictionary; 1416 1417 /** 1418 * Sets the value for the given key. 1419 * 1420 * @param value The value to set. 1421 * @param key The key under which to store the value. 1422 **/ 1423 - (void)setBool:(BOOL)value forKey:(int32_t)key; 1424 1425 /** 1426 * Removes the entry for the given key. 1427 * 1428 * @param aKey Key to be removed from this dictionary. 1429 **/ 1430 - (void)removeBoolForKey:(int32_t)aKey; 1431 1432 /** 1433 * Removes all entries in this dictionary. 1434 **/ 1435 - (void)removeAll; 1436 1437 @end 1438 1439 #pragma mark - Int32 -> Float 1440 1441 /** 1442 * Class used for map fields of <int32_t, float> 1443 * values. This performs better than boxing into NSNumbers in NSDictionaries. 1444 * 1445 * @note This class is not meant to be subclassed. 1446 **/ 1447 __attribute__((objc_subclassing_restricted)) 1448 @interface GPBInt32FloatDictionary : NSObject <NSCopying> 1449 1450 /** Number of entries stored in this dictionary. */ 1451 @property(nonatomic, readonly) NSUInteger count; 1452 1453 /** 1454 * Initializes this dictionary, copying the given values and keys. 1455 * 1456 * @param values The values to be placed in this dictionary. 1457 * @param keys The keys under which to store the values. 1458 * @param count The number of elements to copy into the dictionary. 1459 * 1460 * @return A newly initialized dictionary with a copy of the values and keys. 1461 **/ 1462 - (instancetype)initWithFloats:(const float [__nullable])values 1463 forKeys:(const int32_t [__nullable])keys 1464 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 1465 1466 /** 1467 * Initializes this dictionary, copying the entries from the given dictionary. 1468 * 1469 * @param dictionary Dictionary containing the entries to add to this dictionary. 1470 * 1471 * @return A newly initialized dictionary with the entries of the given dictionary. 1472 **/ 1473 - (instancetype)initWithDictionary:(GPBInt32FloatDictionary *)dictionary; 1474 1475 /** 1476 * Initializes this dictionary with the requested capacity. 1477 * 1478 * @param numItems Number of items needed for this dictionary. 1479 * 1480 * @return A newly initialized dictionary with the requested capacity. 1481 **/ 1482 - (instancetype)initWithCapacity:(NSUInteger)numItems; 1483 1484 /** 1485 * Gets the value for the given key. 1486 * 1487 * @param value Pointer into which the value will be set, if found. 1488 * @param key Key under which the value is stored, if present. 1489 * 1490 * @return YES if the key was found and the value was copied, NO otherwise. 1491 **/ 1492 - (BOOL)getFloat:(nullable float *)value forKey:(int32_t)key; 1493 1494 /** 1495 * Enumerates the keys and values on this dictionary with the given block. 1496 * 1497 * @param block The block to enumerate with. 1498 * **key**: The key for the current entry. 1499 * **value**: The value for the current entry 1500 * **stop**: A pointer to a boolean that when set stops the enumeration. 1501 **/ 1502 - (void)enumerateKeysAndFloatsUsingBlock: 1503 (void (NS_NOESCAPE ^)(int32_t key, float value, BOOL *stop))block; 1504 1505 /** 1506 * Adds the keys and values from another dictionary. 1507 * 1508 * @param otherDictionary Dictionary containing entries to be added to this 1509 * dictionary. 1510 **/ 1511 - (void)addEntriesFromDictionary:(GPBInt32FloatDictionary *)otherDictionary; 1512 1513 /** 1514 * Sets the value for the given key. 1515 * 1516 * @param value The value to set. 1517 * @param key The key under which to store the value. 1518 **/ 1519 - (void)setFloat:(float)value forKey:(int32_t)key; 1520 1521 /** 1522 * Removes the entry for the given key. 1523 * 1524 * @param aKey Key to be removed from this dictionary. 1525 **/ 1526 - (void)removeFloatForKey:(int32_t)aKey; 1527 1528 /** 1529 * Removes all entries in this dictionary. 1530 **/ 1531 - (void)removeAll; 1532 1533 @end 1534 1535 #pragma mark - Int32 -> Double 1536 1537 /** 1538 * Class used for map fields of <int32_t, double> 1539 * values. This performs better than boxing into NSNumbers in NSDictionaries. 1540 * 1541 * @note This class is not meant to be subclassed. 1542 **/ 1543 __attribute__((objc_subclassing_restricted)) 1544 @interface GPBInt32DoubleDictionary : NSObject <NSCopying> 1545 1546 /** Number of entries stored in this dictionary. */ 1547 @property(nonatomic, readonly) NSUInteger count; 1548 1549 /** 1550 * Initializes this dictionary, copying the given values and keys. 1551 * 1552 * @param values The values to be placed in this dictionary. 1553 * @param keys The keys under which to store the values. 1554 * @param count The number of elements to copy into the dictionary. 1555 * 1556 * @return A newly initialized dictionary with a copy of the values and keys. 1557 **/ 1558 - (instancetype)initWithDoubles:(const double [__nullable])values 1559 forKeys:(const int32_t [__nullable])keys 1560 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 1561 1562 /** 1563 * Initializes this dictionary, copying the entries from the given dictionary. 1564 * 1565 * @param dictionary Dictionary containing the entries to add to this dictionary. 1566 * 1567 * @return A newly initialized dictionary with the entries of the given dictionary. 1568 **/ 1569 - (instancetype)initWithDictionary:(GPBInt32DoubleDictionary *)dictionary; 1570 1571 /** 1572 * Initializes this dictionary with the requested capacity. 1573 * 1574 * @param numItems Number of items needed for this dictionary. 1575 * 1576 * @return A newly initialized dictionary with the requested capacity. 1577 **/ 1578 - (instancetype)initWithCapacity:(NSUInteger)numItems; 1579 1580 /** 1581 * Gets the value for the given key. 1582 * 1583 * @param value Pointer into which the value will be set, if found. 1584 * @param key Key under which the value is stored, if present. 1585 * 1586 * @return YES if the key was found and the value was copied, NO otherwise. 1587 **/ 1588 - (BOOL)getDouble:(nullable double *)value forKey:(int32_t)key; 1589 1590 /** 1591 * Enumerates the keys and values on this dictionary with the given block. 1592 * 1593 * @param block The block to enumerate with. 1594 * **key**: The key for the current entry. 1595 * **value**: The value for the current entry 1596 * **stop**: A pointer to a boolean that when set stops the enumeration. 1597 **/ 1598 - (void)enumerateKeysAndDoublesUsingBlock: 1599 (void (NS_NOESCAPE ^)(int32_t key, double value, BOOL *stop))block; 1600 1601 /** 1602 * Adds the keys and values from another dictionary. 1603 * 1604 * @param otherDictionary Dictionary containing entries to be added to this 1605 * dictionary. 1606 **/ 1607 - (void)addEntriesFromDictionary:(GPBInt32DoubleDictionary *)otherDictionary; 1608 1609 /** 1610 * Sets the value for the given key. 1611 * 1612 * @param value The value to set. 1613 * @param key The key under which to store the value. 1614 **/ 1615 - (void)setDouble:(double)value forKey:(int32_t)key; 1616 1617 /** 1618 * Removes the entry for the given key. 1619 * 1620 * @param aKey Key to be removed from this dictionary. 1621 **/ 1622 - (void)removeDoubleForKey:(int32_t)aKey; 1623 1624 /** 1625 * Removes all entries in this dictionary. 1626 **/ 1627 - (void)removeAll; 1628 1629 @end 1630 1631 #pragma mark - Int32 -> Enum 1632 1633 /** 1634 * Class used for map fields of <int32_t, int32_t> 1635 * values. This performs better than boxing into NSNumbers in NSDictionaries. 1636 * 1637 * @note This class is not meant to be subclassed. 1638 **/ 1639 __attribute__((objc_subclassing_restricted)) 1640 @interface GPBInt32EnumDictionary : NSObject <NSCopying> 1641 1642 /** Number of entries stored in this dictionary. */ 1643 @property(nonatomic, readonly) NSUInteger count; 1644 /** The validation function to check if the enums are valid. */ 1645 @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; 1646 1647 /** 1648 * Initializes a dictionary with the given validation function. 1649 * 1650 * @param func The enum validation function for the dictionary. 1651 * 1652 * @return A newly initialized dictionary. 1653 **/ 1654 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; 1655 1656 /** 1657 * Initializes a dictionary with the entries given. 1658 * 1659 * @param func The enum validation function for the dictionary. 1660 * @param values The raw enum values values to be placed in the dictionary. 1661 * @param keys The keys under which to store the values. 1662 * @param count The number of entries to store in the dictionary. 1663 * 1664 * @return A newly initialized dictionary with the keys and values in it. 1665 **/ 1666 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 1667 rawValues:(const int32_t [__nullable])values 1668 forKeys:(const int32_t [__nullable])keys 1669 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 1670 1671 /** 1672 * Initializes a dictionary with the entries from the given. 1673 * dictionary. 1674 * 1675 * @param dictionary Dictionary containing the entries to add to the dictionary. 1676 * 1677 * @return A newly initialized dictionary with the entries from the given 1678 * dictionary in it. 1679 **/ 1680 - (instancetype)initWithDictionary:(GPBInt32EnumDictionary *)dictionary; 1681 1682 /** 1683 * Initializes a dictionary with the given capacity. 1684 * 1685 * @param func The enum validation function for the dictionary. 1686 * @param numItems Capacity needed for the dictionary. 1687 * 1688 * @return A newly initialized dictionary with the given capacity. 1689 **/ 1690 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 1691 capacity:(NSUInteger)numItems; 1692 1693 // These will return kGPBUnrecognizedEnumeratorValue if the value for the key 1694 // is not a valid enumerator as defined by validationFunc. If the actual value is 1695 // desired, use "raw" version of the method. 1696 1697 /** 1698 * Gets the value for the given key. 1699 * 1700 * @param value Pointer into which the value will be set, if found. 1701 * @param key Key under which the value is stored, if present. 1702 * 1703 * @return YES if the key was found and the value was copied, NO otherwise. 1704 **/ 1705 - (BOOL)getEnum:(nullable int32_t *)value forKey:(int32_t)key; 1706 1707 /** 1708 * Enumerates the keys and values on this dictionary with the given block. 1709 * 1710 * @param block The block to enumerate with. 1711 * **key**: The key for the current entry. 1712 * **value**: The value for the current entry 1713 * **stop**: A pointer to a boolean that when set stops the enumeration. 1714 **/ 1715 - (void)enumerateKeysAndEnumsUsingBlock: 1716 (void (NS_NOESCAPE ^)(int32_t key, int32_t value, BOOL *stop))block; 1717 1718 /** 1719 * Gets the raw enum value for the given key. 1720 * 1721 * @note This method bypass the validationFunc to enable the access of values that 1722 * were not known at the time the binary was compiled. 1723 * 1724 * @param rawValue Pointer into which the value will be set, if found. 1725 * @param key Key under which the value is stored, if present. 1726 * 1727 * @return YES if the key was found and the value was copied, NO otherwise. 1728 **/ 1729 - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int32_t)key; 1730 1731 /** 1732 * Enumerates the keys and values on this dictionary with the given block. 1733 * 1734 * @note This method bypass the validationFunc to enable the access of values that 1735 * were not known at the time the binary was compiled. 1736 * 1737 * @param block The block to enumerate with. 1738 * **key**: The key for the current entry. 1739 * **rawValue**: The value for the current entry 1740 * **stop**: A pointer to a boolean that when set stops the enumeration. 1741 **/ 1742 - (void)enumerateKeysAndRawValuesUsingBlock: 1743 (void (NS_NOESCAPE ^)(int32_t key, int32_t rawValue, BOOL *stop))block; 1744 1745 /** 1746 * Adds the keys and raw enum values from another dictionary. 1747 * 1748 * @note This method bypass the validationFunc to enable the setting of values that 1749 * were not known at the time the binary was compiled. 1750 * 1751 * @param otherDictionary Dictionary containing entries to be added to this 1752 * dictionary. 1753 **/ 1754 - (void)addRawEntriesFromDictionary:(GPBInt32EnumDictionary *)otherDictionary; 1755 1756 // If value is not a valid enumerator as defined by validationFunc, these 1757 // methods will assert in debug, and will log in release and assign the value 1758 // to the default value. Use the rawValue methods below to assign non enumerator 1759 // values. 1760 1761 /** 1762 * Sets the value for the given key. 1763 * 1764 * @param value The value to set. 1765 * @param key The key under which to store the value. 1766 **/ 1767 - (void)setEnum:(int32_t)value forKey:(int32_t)key; 1768 1769 /** 1770 * Sets the raw enum value for the given key. 1771 * 1772 * @note This method bypass the validationFunc to enable the setting of values that 1773 * were not known at the time the binary was compiled. 1774 * 1775 * @param rawValue The raw enum value to set. 1776 * @param key The key under which to store the raw enum value. 1777 **/ 1778 - (void)setRawValue:(int32_t)rawValue forKey:(int32_t)key; 1779 1780 /** 1781 * Removes the entry for the given key. 1782 * 1783 * @param aKey Key to be removed from this dictionary. 1784 **/ 1785 - (void)removeEnumForKey:(int32_t)aKey; 1786 1787 /** 1788 * Removes all entries in this dictionary. 1789 **/ 1790 - (void)removeAll; 1791 1792 @end 1793 1794 #pragma mark - Int32 -> Object 1795 1796 /** 1797 * Class used for map fields of <int32_t, ObjectType> 1798 * values. This performs better than boxing into NSNumbers in NSDictionaries. 1799 * 1800 * @note This class is not meant to be subclassed. 1801 **/ 1802 __attribute__((objc_subclassing_restricted)) 1803 @interface GPBInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying> 1804 1805 /** Number of entries stored in this dictionary. */ 1806 @property(nonatomic, readonly) NSUInteger count; 1807 1808 /** 1809 * Initializes this dictionary, copying the given values and keys. 1810 * 1811 * @param objects The values to be placed in this dictionary. 1812 * @param keys The keys under which to store the values. 1813 * @param count The number of elements to copy into the dictionary. 1814 * 1815 * @return A newly initialized dictionary with a copy of the values and keys. 1816 **/ 1817 - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects 1818 forKeys:(const int32_t [__nullable])keys 1819 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 1820 1821 /** 1822 * Initializes this dictionary, copying the entries from the given dictionary. 1823 * 1824 * @param dictionary Dictionary containing the entries to add to this dictionary. 1825 * 1826 * @return A newly initialized dictionary with the entries of the given dictionary. 1827 **/ 1828 - (instancetype)initWithDictionary:(GPBInt32ObjectDictionary *)dictionary; 1829 1830 /** 1831 * Initializes this dictionary with the requested capacity. 1832 * 1833 * @param numItems Number of items needed for this dictionary. 1834 * 1835 * @return A newly initialized dictionary with the requested capacity. 1836 **/ 1837 - (instancetype)initWithCapacity:(NSUInteger)numItems; 1838 1839 /** 1840 * Fetches the object stored under the given key. 1841 * 1842 * @param key Key under which the value is stored, if present. 1843 * 1844 * @return The object if found, nil otherwise. 1845 **/ 1846 - (ObjectType)objectForKey:(int32_t)key; 1847 1848 /** 1849 * Enumerates the keys and values on this dictionary with the given block. 1850 * 1851 * @param block The block to enumerate with. 1852 * **key**: The key for the current entry. 1853 * **object**: The value for the current entry 1854 * **stop**: A pointer to a boolean that when set stops the enumeration. 1855 **/ 1856 - (void)enumerateKeysAndObjectsUsingBlock: 1857 (void (NS_NOESCAPE ^)(int32_t key, ObjectType object, BOOL *stop))block; 1858 1859 /** 1860 * Adds the keys and values from another dictionary. 1861 * 1862 * @param otherDictionary Dictionary containing entries to be added to this 1863 * dictionary. 1864 **/ 1865 - (void)addEntriesFromDictionary:(GPBInt32ObjectDictionary *)otherDictionary; 1866 1867 /** 1868 * Sets the value for the given key. 1869 * 1870 * @param object The value to set. 1871 * @param key The key under which to store the value. 1872 **/ 1873 - (void)setObject:(ObjectType)object forKey:(int32_t)key; 1874 1875 /** 1876 * Removes the entry for the given key. 1877 * 1878 * @param aKey Key to be removed from this dictionary. 1879 **/ 1880 - (void)removeObjectForKey:(int32_t)aKey; 1881 1882 /** 1883 * Removes all entries in this dictionary. 1884 **/ 1885 - (void)removeAll; 1886 1887 @end 1888 1889 #pragma mark - UInt64 -> UInt32 1890 1891 /** 1892 * Class used for map fields of <uint64_t, uint32_t> 1893 * values. This performs better than boxing into NSNumbers in NSDictionaries. 1894 * 1895 * @note This class is not meant to be subclassed. 1896 **/ 1897 __attribute__((objc_subclassing_restricted)) 1898 @interface GPBUInt64UInt32Dictionary : NSObject <NSCopying> 1899 1900 /** Number of entries stored in this dictionary. */ 1901 @property(nonatomic, readonly) NSUInteger count; 1902 1903 /** 1904 * Initializes this dictionary, copying the given values and keys. 1905 * 1906 * @param values The values to be placed in this dictionary. 1907 * @param keys The keys under which to store the values. 1908 * @param count The number of elements to copy into the dictionary. 1909 * 1910 * @return A newly initialized dictionary with a copy of the values and keys. 1911 **/ 1912 - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values 1913 forKeys:(const uint64_t [__nullable])keys 1914 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 1915 1916 /** 1917 * Initializes this dictionary, copying the entries from the given dictionary. 1918 * 1919 * @param dictionary Dictionary containing the entries to add to this dictionary. 1920 * 1921 * @return A newly initialized dictionary with the entries of the given dictionary. 1922 **/ 1923 - (instancetype)initWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary; 1924 1925 /** 1926 * Initializes this dictionary with the requested capacity. 1927 * 1928 * @param numItems Number of items needed for this dictionary. 1929 * 1930 * @return A newly initialized dictionary with the requested capacity. 1931 **/ 1932 - (instancetype)initWithCapacity:(NSUInteger)numItems; 1933 1934 /** 1935 * Gets the value for the given key. 1936 * 1937 * @param value Pointer into which the value will be set, if found. 1938 * @param key Key under which the value is stored, if present. 1939 * 1940 * @return YES if the key was found and the value was copied, NO otherwise. 1941 **/ 1942 - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint64_t)key; 1943 1944 /** 1945 * Enumerates the keys and values on this dictionary with the given block. 1946 * 1947 * @param block The block to enumerate with. 1948 * **key**: The key for the current entry. 1949 * **value**: The value for the current entry 1950 * **stop**: A pointer to a boolean that when set stops the enumeration. 1951 **/ 1952 - (void)enumerateKeysAndUInt32sUsingBlock: 1953 (void (NS_NOESCAPE ^)(uint64_t key, uint32_t value, BOOL *stop))block; 1954 1955 /** 1956 * Adds the keys and values from another dictionary. 1957 * 1958 * @param otherDictionary Dictionary containing entries to be added to this 1959 * dictionary. 1960 **/ 1961 - (void)addEntriesFromDictionary:(GPBUInt64UInt32Dictionary *)otherDictionary; 1962 1963 /** 1964 * Sets the value for the given key. 1965 * 1966 * @param value The value to set. 1967 * @param key The key under which to store the value. 1968 **/ 1969 - (void)setUInt32:(uint32_t)value forKey:(uint64_t)key; 1970 1971 /** 1972 * Removes the entry for the given key. 1973 * 1974 * @param aKey Key to be removed from this dictionary. 1975 **/ 1976 - (void)removeUInt32ForKey:(uint64_t)aKey; 1977 1978 /** 1979 * Removes all entries in this dictionary. 1980 **/ 1981 - (void)removeAll; 1982 1983 @end 1984 1985 #pragma mark - UInt64 -> Int32 1986 1987 /** 1988 * Class used for map fields of <uint64_t, int32_t> 1989 * values. This performs better than boxing into NSNumbers in NSDictionaries. 1990 * 1991 * @note This class is not meant to be subclassed. 1992 **/ 1993 __attribute__((objc_subclassing_restricted)) 1994 @interface GPBUInt64Int32Dictionary : NSObject <NSCopying> 1995 1996 /** Number of entries stored in this dictionary. */ 1997 @property(nonatomic, readonly) NSUInteger count; 1998 1999 /** 2000 * Initializes this dictionary, copying the given values and keys. 2001 * 2002 * @param values The values to be placed in this dictionary. 2003 * @param keys The keys under which to store the values. 2004 * @param count The number of elements to copy into the dictionary. 2005 * 2006 * @return A newly initialized dictionary with a copy of the values and keys. 2007 **/ 2008 - (instancetype)initWithInt32s:(const int32_t [__nullable])values 2009 forKeys:(const uint64_t [__nullable])keys 2010 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 2011 2012 /** 2013 * Initializes this dictionary, copying the entries from the given dictionary. 2014 * 2015 * @param dictionary Dictionary containing the entries to add to this dictionary. 2016 * 2017 * @return A newly initialized dictionary with the entries of the given dictionary. 2018 **/ 2019 - (instancetype)initWithDictionary:(GPBUInt64Int32Dictionary *)dictionary; 2020 2021 /** 2022 * Initializes this dictionary with the requested capacity. 2023 * 2024 * @param numItems Number of items needed for this dictionary. 2025 * 2026 * @return A newly initialized dictionary with the requested capacity. 2027 **/ 2028 - (instancetype)initWithCapacity:(NSUInteger)numItems; 2029 2030 /** 2031 * Gets the value for the given key. 2032 * 2033 * @param value Pointer into which the value will be set, if found. 2034 * @param key Key under which the value is stored, if present. 2035 * 2036 * @return YES if the key was found and the value was copied, NO otherwise. 2037 **/ 2038 - (BOOL)getInt32:(nullable int32_t *)value forKey:(uint64_t)key; 2039 2040 /** 2041 * Enumerates the keys and values on this dictionary with the given block. 2042 * 2043 * @param block The block to enumerate with. 2044 * **key**: The key for the current entry. 2045 * **value**: The value for the current entry 2046 * **stop**: A pointer to a boolean that when set stops the enumeration. 2047 **/ 2048 - (void)enumerateKeysAndInt32sUsingBlock: 2049 (void (NS_NOESCAPE ^)(uint64_t key, int32_t value, BOOL *stop))block; 2050 2051 /** 2052 * Adds the keys and values from another dictionary. 2053 * 2054 * @param otherDictionary Dictionary containing entries to be added to this 2055 * dictionary. 2056 **/ 2057 - (void)addEntriesFromDictionary:(GPBUInt64Int32Dictionary *)otherDictionary; 2058 2059 /** 2060 * Sets the value for the given key. 2061 * 2062 * @param value The value to set. 2063 * @param key The key under which to store the value. 2064 **/ 2065 - (void)setInt32:(int32_t)value forKey:(uint64_t)key; 2066 2067 /** 2068 * Removes the entry for the given key. 2069 * 2070 * @param aKey Key to be removed from this dictionary. 2071 **/ 2072 - (void)removeInt32ForKey:(uint64_t)aKey; 2073 2074 /** 2075 * Removes all entries in this dictionary. 2076 **/ 2077 - (void)removeAll; 2078 2079 @end 2080 2081 #pragma mark - UInt64 -> UInt64 2082 2083 /** 2084 * Class used for map fields of <uint64_t, uint64_t> 2085 * values. This performs better than boxing into NSNumbers in NSDictionaries. 2086 * 2087 * @note This class is not meant to be subclassed. 2088 **/ 2089 __attribute__((objc_subclassing_restricted)) 2090 @interface GPBUInt64UInt64Dictionary : NSObject <NSCopying> 2091 2092 /** Number of entries stored in this dictionary. */ 2093 @property(nonatomic, readonly) NSUInteger count; 2094 2095 /** 2096 * Initializes this dictionary, copying the given values and keys. 2097 * 2098 * @param values The values to be placed in this dictionary. 2099 * @param keys The keys under which to store the values. 2100 * @param count The number of elements to copy into the dictionary. 2101 * 2102 * @return A newly initialized dictionary with a copy of the values and keys. 2103 **/ 2104 - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values 2105 forKeys:(const uint64_t [__nullable])keys 2106 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 2107 2108 /** 2109 * Initializes this dictionary, copying the entries from the given dictionary. 2110 * 2111 * @param dictionary Dictionary containing the entries to add to this dictionary. 2112 * 2113 * @return A newly initialized dictionary with the entries of the given dictionary. 2114 **/ 2115 - (instancetype)initWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary; 2116 2117 /** 2118 * Initializes this dictionary with the requested capacity. 2119 * 2120 * @param numItems Number of items needed for this dictionary. 2121 * 2122 * @return A newly initialized dictionary with the requested capacity. 2123 **/ 2124 - (instancetype)initWithCapacity:(NSUInteger)numItems; 2125 2126 /** 2127 * Gets the value for the given key. 2128 * 2129 * @param value Pointer into which the value will be set, if found. 2130 * @param key Key under which the value is stored, if present. 2131 * 2132 * @return YES if the key was found and the value was copied, NO otherwise. 2133 **/ 2134 - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint64_t)key; 2135 2136 /** 2137 * Enumerates the keys and values on this dictionary with the given block. 2138 * 2139 * @param block The block to enumerate with. 2140 * **key**: The key for the current entry. 2141 * **value**: The value for the current entry 2142 * **stop**: A pointer to a boolean that when set stops the enumeration. 2143 **/ 2144 - (void)enumerateKeysAndUInt64sUsingBlock: 2145 (void (NS_NOESCAPE ^)(uint64_t key, uint64_t value, BOOL *stop))block; 2146 2147 /** 2148 * Adds the keys and values from another dictionary. 2149 * 2150 * @param otherDictionary Dictionary containing entries to be added to this 2151 * dictionary. 2152 **/ 2153 - (void)addEntriesFromDictionary:(GPBUInt64UInt64Dictionary *)otherDictionary; 2154 2155 /** 2156 * Sets the value for the given key. 2157 * 2158 * @param value The value to set. 2159 * @param key The key under which to store the value. 2160 **/ 2161 - (void)setUInt64:(uint64_t)value forKey:(uint64_t)key; 2162 2163 /** 2164 * Removes the entry for the given key. 2165 * 2166 * @param aKey Key to be removed from this dictionary. 2167 **/ 2168 - (void)removeUInt64ForKey:(uint64_t)aKey; 2169 2170 /** 2171 * Removes all entries in this dictionary. 2172 **/ 2173 - (void)removeAll; 2174 2175 @end 2176 2177 #pragma mark - UInt64 -> Int64 2178 2179 /** 2180 * Class used for map fields of <uint64_t, int64_t> 2181 * values. This performs better than boxing into NSNumbers in NSDictionaries. 2182 * 2183 * @note This class is not meant to be subclassed. 2184 **/ 2185 __attribute__((objc_subclassing_restricted)) 2186 @interface GPBUInt64Int64Dictionary : NSObject <NSCopying> 2187 2188 /** Number of entries stored in this dictionary. */ 2189 @property(nonatomic, readonly) NSUInteger count; 2190 2191 /** 2192 * Initializes this dictionary, copying the given values and keys. 2193 * 2194 * @param values The values to be placed in this dictionary. 2195 * @param keys The keys under which to store the values. 2196 * @param count The number of elements to copy into the dictionary. 2197 * 2198 * @return A newly initialized dictionary with a copy of the values and keys. 2199 **/ 2200 - (instancetype)initWithInt64s:(const int64_t [__nullable])values 2201 forKeys:(const uint64_t [__nullable])keys 2202 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 2203 2204 /** 2205 * Initializes this dictionary, copying the entries from the given dictionary. 2206 * 2207 * @param dictionary Dictionary containing the entries to add to this dictionary. 2208 * 2209 * @return A newly initialized dictionary with the entries of the given dictionary. 2210 **/ 2211 - (instancetype)initWithDictionary:(GPBUInt64Int64Dictionary *)dictionary; 2212 2213 /** 2214 * Initializes this dictionary with the requested capacity. 2215 * 2216 * @param numItems Number of items needed for this dictionary. 2217 * 2218 * @return A newly initialized dictionary with the requested capacity. 2219 **/ 2220 - (instancetype)initWithCapacity:(NSUInteger)numItems; 2221 2222 /** 2223 * Gets the value for the given key. 2224 * 2225 * @param value Pointer into which the value will be set, if found. 2226 * @param key Key under which the value is stored, if present. 2227 * 2228 * @return YES if the key was found and the value was copied, NO otherwise. 2229 **/ 2230 - (BOOL)getInt64:(nullable int64_t *)value forKey:(uint64_t)key; 2231 2232 /** 2233 * Enumerates the keys and values on this dictionary with the given block. 2234 * 2235 * @param block The block to enumerate with. 2236 * **key**: The key for the current entry. 2237 * **value**: The value for the current entry 2238 * **stop**: A pointer to a boolean that when set stops the enumeration. 2239 **/ 2240 - (void)enumerateKeysAndInt64sUsingBlock: 2241 (void (NS_NOESCAPE ^)(uint64_t key, int64_t value, BOOL *stop))block; 2242 2243 /** 2244 * Adds the keys and values from another dictionary. 2245 * 2246 * @param otherDictionary Dictionary containing entries to be added to this 2247 * dictionary. 2248 **/ 2249 - (void)addEntriesFromDictionary:(GPBUInt64Int64Dictionary *)otherDictionary; 2250 2251 /** 2252 * Sets the value for the given key. 2253 * 2254 * @param value The value to set. 2255 * @param key The key under which to store the value. 2256 **/ 2257 - (void)setInt64:(int64_t)value forKey:(uint64_t)key; 2258 2259 /** 2260 * Removes the entry for the given key. 2261 * 2262 * @param aKey Key to be removed from this dictionary. 2263 **/ 2264 - (void)removeInt64ForKey:(uint64_t)aKey; 2265 2266 /** 2267 * Removes all entries in this dictionary. 2268 **/ 2269 - (void)removeAll; 2270 2271 @end 2272 2273 #pragma mark - UInt64 -> Bool 2274 2275 /** 2276 * Class used for map fields of <uint64_t, BOOL> 2277 * values. This performs better than boxing into NSNumbers in NSDictionaries. 2278 * 2279 * @note This class is not meant to be subclassed. 2280 **/ 2281 __attribute__((objc_subclassing_restricted)) 2282 @interface GPBUInt64BoolDictionary : NSObject <NSCopying> 2283 2284 /** Number of entries stored in this dictionary. */ 2285 @property(nonatomic, readonly) NSUInteger count; 2286 2287 /** 2288 * Initializes this dictionary, copying the given values and keys. 2289 * 2290 * @param values The values to be placed in this dictionary. 2291 * @param keys The keys under which to store the values. 2292 * @param count The number of elements to copy into the dictionary. 2293 * 2294 * @return A newly initialized dictionary with a copy of the values and keys. 2295 **/ 2296 - (instancetype)initWithBools:(const BOOL [__nullable])values 2297 forKeys:(const uint64_t [__nullable])keys 2298 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 2299 2300 /** 2301 * Initializes this dictionary, copying the entries from the given dictionary. 2302 * 2303 * @param dictionary Dictionary containing the entries to add to this dictionary. 2304 * 2305 * @return A newly initialized dictionary with the entries of the given dictionary. 2306 **/ 2307 - (instancetype)initWithDictionary:(GPBUInt64BoolDictionary *)dictionary; 2308 2309 /** 2310 * Initializes this dictionary with the requested capacity. 2311 * 2312 * @param numItems Number of items needed for this dictionary. 2313 * 2314 * @return A newly initialized dictionary with the requested capacity. 2315 **/ 2316 - (instancetype)initWithCapacity:(NSUInteger)numItems; 2317 2318 /** 2319 * Gets the value for the given key. 2320 * 2321 * @param value Pointer into which the value will be set, if found. 2322 * @param key Key under which the value is stored, if present. 2323 * 2324 * @return YES if the key was found and the value was copied, NO otherwise. 2325 **/ 2326 - (BOOL)getBool:(nullable BOOL *)value forKey:(uint64_t)key; 2327 2328 /** 2329 * Enumerates the keys and values on this dictionary with the given block. 2330 * 2331 * @param block The block to enumerate with. 2332 * **key**: The key for the current entry. 2333 * **value**: The value for the current entry 2334 * **stop**: A pointer to a boolean that when set stops the enumeration. 2335 **/ 2336 - (void)enumerateKeysAndBoolsUsingBlock: 2337 (void (NS_NOESCAPE ^)(uint64_t key, BOOL value, BOOL *stop))block; 2338 2339 /** 2340 * Adds the keys and values from another dictionary. 2341 * 2342 * @param otherDictionary Dictionary containing entries to be added to this 2343 * dictionary. 2344 **/ 2345 - (void)addEntriesFromDictionary:(GPBUInt64BoolDictionary *)otherDictionary; 2346 2347 /** 2348 * Sets the value for the given key. 2349 * 2350 * @param value The value to set. 2351 * @param key The key under which to store the value. 2352 **/ 2353 - (void)setBool:(BOOL)value forKey:(uint64_t)key; 2354 2355 /** 2356 * Removes the entry for the given key. 2357 * 2358 * @param aKey Key to be removed from this dictionary. 2359 **/ 2360 - (void)removeBoolForKey:(uint64_t)aKey; 2361 2362 /** 2363 * Removes all entries in this dictionary. 2364 **/ 2365 - (void)removeAll; 2366 2367 @end 2368 2369 #pragma mark - UInt64 -> Float 2370 2371 /** 2372 * Class used for map fields of <uint64_t, float> 2373 * values. This performs better than boxing into NSNumbers in NSDictionaries. 2374 * 2375 * @note This class is not meant to be subclassed. 2376 **/ 2377 __attribute__((objc_subclassing_restricted)) 2378 @interface GPBUInt64FloatDictionary : NSObject <NSCopying> 2379 2380 /** Number of entries stored in this dictionary. */ 2381 @property(nonatomic, readonly) NSUInteger count; 2382 2383 /** 2384 * Initializes this dictionary, copying the given values and keys. 2385 * 2386 * @param values The values to be placed in this dictionary. 2387 * @param keys The keys under which to store the values. 2388 * @param count The number of elements to copy into the dictionary. 2389 * 2390 * @return A newly initialized dictionary with a copy of the values and keys. 2391 **/ 2392 - (instancetype)initWithFloats:(const float [__nullable])values 2393 forKeys:(const uint64_t [__nullable])keys 2394 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 2395 2396 /** 2397 * Initializes this dictionary, copying the entries from the given dictionary. 2398 * 2399 * @param dictionary Dictionary containing the entries to add to this dictionary. 2400 * 2401 * @return A newly initialized dictionary with the entries of the given dictionary. 2402 **/ 2403 - (instancetype)initWithDictionary:(GPBUInt64FloatDictionary *)dictionary; 2404 2405 /** 2406 * Initializes this dictionary with the requested capacity. 2407 * 2408 * @param numItems Number of items needed for this dictionary. 2409 * 2410 * @return A newly initialized dictionary with the requested capacity. 2411 **/ 2412 - (instancetype)initWithCapacity:(NSUInteger)numItems; 2413 2414 /** 2415 * Gets the value for the given key. 2416 * 2417 * @param value Pointer into which the value will be set, if found. 2418 * @param key Key under which the value is stored, if present. 2419 * 2420 * @return YES if the key was found and the value was copied, NO otherwise. 2421 **/ 2422 - (BOOL)getFloat:(nullable float *)value forKey:(uint64_t)key; 2423 2424 /** 2425 * Enumerates the keys and values on this dictionary with the given block. 2426 * 2427 * @param block The block to enumerate with. 2428 * **key**: The key for the current entry. 2429 * **value**: The value for the current entry 2430 * **stop**: A pointer to a boolean that when set stops the enumeration. 2431 **/ 2432 - (void)enumerateKeysAndFloatsUsingBlock: 2433 (void (NS_NOESCAPE ^)(uint64_t key, float value, BOOL *stop))block; 2434 2435 /** 2436 * Adds the keys and values from another dictionary. 2437 * 2438 * @param otherDictionary Dictionary containing entries to be added to this 2439 * dictionary. 2440 **/ 2441 - (void)addEntriesFromDictionary:(GPBUInt64FloatDictionary *)otherDictionary; 2442 2443 /** 2444 * Sets the value for the given key. 2445 * 2446 * @param value The value to set. 2447 * @param key The key under which to store the value. 2448 **/ 2449 - (void)setFloat:(float)value forKey:(uint64_t)key; 2450 2451 /** 2452 * Removes the entry for the given key. 2453 * 2454 * @param aKey Key to be removed from this dictionary. 2455 **/ 2456 - (void)removeFloatForKey:(uint64_t)aKey; 2457 2458 /** 2459 * Removes all entries in this dictionary. 2460 **/ 2461 - (void)removeAll; 2462 2463 @end 2464 2465 #pragma mark - UInt64 -> Double 2466 2467 /** 2468 * Class used for map fields of <uint64_t, double> 2469 * values. This performs better than boxing into NSNumbers in NSDictionaries. 2470 * 2471 * @note This class is not meant to be subclassed. 2472 **/ 2473 __attribute__((objc_subclassing_restricted)) 2474 @interface GPBUInt64DoubleDictionary : NSObject <NSCopying> 2475 2476 /** Number of entries stored in this dictionary. */ 2477 @property(nonatomic, readonly) NSUInteger count; 2478 2479 /** 2480 * Initializes this dictionary, copying the given values and keys. 2481 * 2482 * @param values The values to be placed in this dictionary. 2483 * @param keys The keys under which to store the values. 2484 * @param count The number of elements to copy into the dictionary. 2485 * 2486 * @return A newly initialized dictionary with a copy of the values and keys. 2487 **/ 2488 - (instancetype)initWithDoubles:(const double [__nullable])values 2489 forKeys:(const uint64_t [__nullable])keys 2490 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 2491 2492 /** 2493 * Initializes this dictionary, copying the entries from the given dictionary. 2494 * 2495 * @param dictionary Dictionary containing the entries to add to this dictionary. 2496 * 2497 * @return A newly initialized dictionary with the entries of the given dictionary. 2498 **/ 2499 - (instancetype)initWithDictionary:(GPBUInt64DoubleDictionary *)dictionary; 2500 2501 /** 2502 * Initializes this dictionary with the requested capacity. 2503 * 2504 * @param numItems Number of items needed for this dictionary. 2505 * 2506 * @return A newly initialized dictionary with the requested capacity. 2507 **/ 2508 - (instancetype)initWithCapacity:(NSUInteger)numItems; 2509 2510 /** 2511 * Gets the value for the given key. 2512 * 2513 * @param value Pointer into which the value will be set, if found. 2514 * @param key Key under which the value is stored, if present. 2515 * 2516 * @return YES if the key was found and the value was copied, NO otherwise. 2517 **/ 2518 - (BOOL)getDouble:(nullable double *)value forKey:(uint64_t)key; 2519 2520 /** 2521 * Enumerates the keys and values on this dictionary with the given block. 2522 * 2523 * @param block The block to enumerate with. 2524 * **key**: The key for the current entry. 2525 * **value**: The value for the current entry 2526 * **stop**: A pointer to a boolean that when set stops the enumeration. 2527 **/ 2528 - (void)enumerateKeysAndDoublesUsingBlock: 2529 (void (NS_NOESCAPE ^)(uint64_t key, double value, BOOL *stop))block; 2530 2531 /** 2532 * Adds the keys and values from another dictionary. 2533 * 2534 * @param otherDictionary Dictionary containing entries to be added to this 2535 * dictionary. 2536 **/ 2537 - (void)addEntriesFromDictionary:(GPBUInt64DoubleDictionary *)otherDictionary; 2538 2539 /** 2540 * Sets the value for the given key. 2541 * 2542 * @param value The value to set. 2543 * @param key The key under which to store the value. 2544 **/ 2545 - (void)setDouble:(double)value forKey:(uint64_t)key; 2546 2547 /** 2548 * Removes the entry for the given key. 2549 * 2550 * @param aKey Key to be removed from this dictionary. 2551 **/ 2552 - (void)removeDoubleForKey:(uint64_t)aKey; 2553 2554 /** 2555 * Removes all entries in this dictionary. 2556 **/ 2557 - (void)removeAll; 2558 2559 @end 2560 2561 #pragma mark - UInt64 -> Enum 2562 2563 /** 2564 * Class used for map fields of <uint64_t, int32_t> 2565 * values. This performs better than boxing into NSNumbers in NSDictionaries. 2566 * 2567 * @note This class is not meant to be subclassed. 2568 **/ 2569 __attribute__((objc_subclassing_restricted)) 2570 @interface GPBUInt64EnumDictionary : NSObject <NSCopying> 2571 2572 /** Number of entries stored in this dictionary. */ 2573 @property(nonatomic, readonly) NSUInteger count; 2574 /** The validation function to check if the enums are valid. */ 2575 @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; 2576 2577 /** 2578 * Initializes a dictionary with the given validation function. 2579 * 2580 * @param func The enum validation function for the dictionary. 2581 * 2582 * @return A newly initialized dictionary. 2583 **/ 2584 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; 2585 2586 /** 2587 * Initializes a dictionary with the entries given. 2588 * 2589 * @param func The enum validation function for the dictionary. 2590 * @param values The raw enum values values to be placed in the dictionary. 2591 * @param keys The keys under which to store the values. 2592 * @param count The number of entries to store in the dictionary. 2593 * 2594 * @return A newly initialized dictionary with the keys and values in it. 2595 **/ 2596 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 2597 rawValues:(const int32_t [__nullable])values 2598 forKeys:(const uint64_t [__nullable])keys 2599 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 2600 2601 /** 2602 * Initializes a dictionary with the entries from the given. 2603 * dictionary. 2604 * 2605 * @param dictionary Dictionary containing the entries to add to the dictionary. 2606 * 2607 * @return A newly initialized dictionary with the entries from the given 2608 * dictionary in it. 2609 **/ 2610 - (instancetype)initWithDictionary:(GPBUInt64EnumDictionary *)dictionary; 2611 2612 /** 2613 * Initializes a dictionary with the given capacity. 2614 * 2615 * @param func The enum validation function for the dictionary. 2616 * @param numItems Capacity needed for the dictionary. 2617 * 2618 * @return A newly initialized dictionary with the given capacity. 2619 **/ 2620 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 2621 capacity:(NSUInteger)numItems; 2622 2623 // These will return kGPBUnrecognizedEnumeratorValue if the value for the key 2624 // is not a valid enumerator as defined by validationFunc. If the actual value is 2625 // desired, use "raw" version of the method. 2626 2627 /** 2628 * Gets the value for the given key. 2629 * 2630 * @param value Pointer into which the value will be set, if found. 2631 * @param key Key under which the value is stored, if present. 2632 * 2633 * @return YES if the key was found and the value was copied, NO otherwise. 2634 **/ 2635 - (BOOL)getEnum:(nullable int32_t *)value forKey:(uint64_t)key; 2636 2637 /** 2638 * Enumerates the keys and values on this dictionary with the given block. 2639 * 2640 * @param block The block to enumerate with. 2641 * **key**: The key for the current entry. 2642 * **value**: The value for the current entry 2643 * **stop**: A pointer to a boolean that when set stops the enumeration. 2644 **/ 2645 - (void)enumerateKeysAndEnumsUsingBlock: 2646 (void (NS_NOESCAPE ^)(uint64_t key, int32_t value, BOOL *stop))block; 2647 2648 /** 2649 * Gets the raw enum value for the given key. 2650 * 2651 * @note This method bypass the validationFunc to enable the access of values that 2652 * were not known at the time the binary was compiled. 2653 * 2654 * @param rawValue Pointer into which the value will be set, if found. 2655 * @param key Key under which the value is stored, if present. 2656 * 2657 * @return YES if the key was found and the value was copied, NO otherwise. 2658 **/ 2659 - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint64_t)key; 2660 2661 /** 2662 * Enumerates the keys and values on this dictionary with the given block. 2663 * 2664 * @note This method bypass the validationFunc to enable the access of values that 2665 * were not known at the time the binary was compiled. 2666 * 2667 * @param block The block to enumerate with. 2668 * **key**: The key for the current entry. 2669 * **rawValue**: The value for the current entry 2670 * **stop**: A pointer to a boolean that when set stops the enumeration. 2671 **/ 2672 - (void)enumerateKeysAndRawValuesUsingBlock: 2673 (void (NS_NOESCAPE ^)(uint64_t key, int32_t rawValue, BOOL *stop))block; 2674 2675 /** 2676 * Adds the keys and raw enum values from another dictionary. 2677 * 2678 * @note This method bypass the validationFunc to enable the setting of values that 2679 * were not known at the time the binary was compiled. 2680 * 2681 * @param otherDictionary Dictionary containing entries to be added to this 2682 * dictionary. 2683 **/ 2684 - (void)addRawEntriesFromDictionary:(GPBUInt64EnumDictionary *)otherDictionary; 2685 2686 // If value is not a valid enumerator as defined by validationFunc, these 2687 // methods will assert in debug, and will log in release and assign the value 2688 // to the default value. Use the rawValue methods below to assign non enumerator 2689 // values. 2690 2691 /** 2692 * Sets the value for the given key. 2693 * 2694 * @param value The value to set. 2695 * @param key The key under which to store the value. 2696 **/ 2697 - (void)setEnum:(int32_t)value forKey:(uint64_t)key; 2698 2699 /** 2700 * Sets the raw enum value for the given key. 2701 * 2702 * @note This method bypass the validationFunc to enable the setting of values that 2703 * were not known at the time the binary was compiled. 2704 * 2705 * @param rawValue The raw enum value to set. 2706 * @param key The key under which to store the raw enum value. 2707 **/ 2708 - (void)setRawValue:(int32_t)rawValue forKey:(uint64_t)key; 2709 2710 /** 2711 * Removes the entry for the given key. 2712 * 2713 * @param aKey Key to be removed from this dictionary. 2714 **/ 2715 - (void)removeEnumForKey:(uint64_t)aKey; 2716 2717 /** 2718 * Removes all entries in this dictionary. 2719 **/ 2720 - (void)removeAll; 2721 2722 @end 2723 2724 #pragma mark - UInt64 -> Object 2725 2726 /** 2727 * Class used for map fields of <uint64_t, ObjectType> 2728 * values. This performs better than boxing into NSNumbers in NSDictionaries. 2729 * 2730 * @note This class is not meant to be subclassed. 2731 **/ 2732 __attribute__((objc_subclassing_restricted)) 2733 @interface GPBUInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying> 2734 2735 /** Number of entries stored in this dictionary. */ 2736 @property(nonatomic, readonly) NSUInteger count; 2737 2738 /** 2739 * Initializes this dictionary, copying the given values and keys. 2740 * 2741 * @param objects The values to be placed in this dictionary. 2742 * @param keys The keys under which to store the values. 2743 * @param count The number of elements to copy into the dictionary. 2744 * 2745 * @return A newly initialized dictionary with a copy of the values and keys. 2746 **/ 2747 - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects 2748 forKeys:(const uint64_t [__nullable])keys 2749 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 2750 2751 /** 2752 * Initializes this dictionary, copying the entries from the given dictionary. 2753 * 2754 * @param dictionary Dictionary containing the entries to add to this dictionary. 2755 * 2756 * @return A newly initialized dictionary with the entries of the given dictionary. 2757 **/ 2758 - (instancetype)initWithDictionary:(GPBUInt64ObjectDictionary *)dictionary; 2759 2760 /** 2761 * Initializes this dictionary with the requested capacity. 2762 * 2763 * @param numItems Number of items needed for this dictionary. 2764 * 2765 * @return A newly initialized dictionary with the requested capacity. 2766 **/ 2767 - (instancetype)initWithCapacity:(NSUInteger)numItems; 2768 2769 /** 2770 * Fetches the object stored under the given key. 2771 * 2772 * @param key Key under which the value is stored, if present. 2773 * 2774 * @return The object if found, nil otherwise. 2775 **/ 2776 - (ObjectType)objectForKey:(uint64_t)key; 2777 2778 /** 2779 * Enumerates the keys and values on this dictionary with the given block. 2780 * 2781 * @param block The block to enumerate with. 2782 * **key**: The key for the current entry. 2783 * **object**: The value for the current entry 2784 * **stop**: A pointer to a boolean that when set stops the enumeration. 2785 **/ 2786 - (void)enumerateKeysAndObjectsUsingBlock: 2787 (void (NS_NOESCAPE ^)(uint64_t key, ObjectType object, BOOL *stop))block; 2788 2789 /** 2790 * Adds the keys and values from another dictionary. 2791 * 2792 * @param otherDictionary Dictionary containing entries to be added to this 2793 * dictionary. 2794 **/ 2795 - (void)addEntriesFromDictionary:(GPBUInt64ObjectDictionary *)otherDictionary; 2796 2797 /** 2798 * Sets the value for the given key. 2799 * 2800 * @param object The value to set. 2801 * @param key The key under which to store the value. 2802 **/ 2803 - (void)setObject:(ObjectType)object forKey:(uint64_t)key; 2804 2805 /** 2806 * Removes the entry for the given key. 2807 * 2808 * @param aKey Key to be removed from this dictionary. 2809 **/ 2810 - (void)removeObjectForKey:(uint64_t)aKey; 2811 2812 /** 2813 * Removes all entries in this dictionary. 2814 **/ 2815 - (void)removeAll; 2816 2817 @end 2818 2819 #pragma mark - Int64 -> UInt32 2820 2821 /** 2822 * Class used for map fields of <int64_t, uint32_t> 2823 * values. This performs better than boxing into NSNumbers in NSDictionaries. 2824 * 2825 * @note This class is not meant to be subclassed. 2826 **/ 2827 __attribute__((objc_subclassing_restricted)) 2828 @interface GPBInt64UInt32Dictionary : NSObject <NSCopying> 2829 2830 /** Number of entries stored in this dictionary. */ 2831 @property(nonatomic, readonly) NSUInteger count; 2832 2833 /** 2834 * Initializes this dictionary, copying the given values and keys. 2835 * 2836 * @param values The values to be placed in this dictionary. 2837 * @param keys The keys under which to store the values. 2838 * @param count The number of elements to copy into the dictionary. 2839 * 2840 * @return A newly initialized dictionary with a copy of the values and keys. 2841 **/ 2842 - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values 2843 forKeys:(const int64_t [__nullable])keys 2844 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 2845 2846 /** 2847 * Initializes this dictionary, copying the entries from the given dictionary. 2848 * 2849 * @param dictionary Dictionary containing the entries to add to this dictionary. 2850 * 2851 * @return A newly initialized dictionary with the entries of the given dictionary. 2852 **/ 2853 - (instancetype)initWithDictionary:(GPBInt64UInt32Dictionary *)dictionary; 2854 2855 /** 2856 * Initializes this dictionary with the requested capacity. 2857 * 2858 * @param numItems Number of items needed for this dictionary. 2859 * 2860 * @return A newly initialized dictionary with the requested capacity. 2861 **/ 2862 - (instancetype)initWithCapacity:(NSUInteger)numItems; 2863 2864 /** 2865 * Gets the value for the given key. 2866 * 2867 * @param value Pointer into which the value will be set, if found. 2868 * @param key Key under which the value is stored, if present. 2869 * 2870 * @return YES if the key was found and the value was copied, NO otherwise. 2871 **/ 2872 - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int64_t)key; 2873 2874 /** 2875 * Enumerates the keys and values on this dictionary with the given block. 2876 * 2877 * @param block The block to enumerate with. 2878 * **key**: The key for the current entry. 2879 * **value**: The value for the current entry 2880 * **stop**: A pointer to a boolean that when set stops the enumeration. 2881 **/ 2882 - (void)enumerateKeysAndUInt32sUsingBlock: 2883 (void (NS_NOESCAPE ^)(int64_t key, uint32_t value, BOOL *stop))block; 2884 2885 /** 2886 * Adds the keys and values from another dictionary. 2887 * 2888 * @param otherDictionary Dictionary containing entries to be added to this 2889 * dictionary. 2890 **/ 2891 - (void)addEntriesFromDictionary:(GPBInt64UInt32Dictionary *)otherDictionary; 2892 2893 /** 2894 * Sets the value for the given key. 2895 * 2896 * @param value The value to set. 2897 * @param key The key under which to store the value. 2898 **/ 2899 - (void)setUInt32:(uint32_t)value forKey:(int64_t)key; 2900 2901 /** 2902 * Removes the entry for the given key. 2903 * 2904 * @param aKey Key to be removed from this dictionary. 2905 **/ 2906 - (void)removeUInt32ForKey:(int64_t)aKey; 2907 2908 /** 2909 * Removes all entries in this dictionary. 2910 **/ 2911 - (void)removeAll; 2912 2913 @end 2914 2915 #pragma mark - Int64 -> Int32 2916 2917 /** 2918 * Class used for map fields of <int64_t, int32_t> 2919 * values. This performs better than boxing into NSNumbers in NSDictionaries. 2920 * 2921 * @note This class is not meant to be subclassed. 2922 **/ 2923 __attribute__((objc_subclassing_restricted)) 2924 @interface GPBInt64Int32Dictionary : NSObject <NSCopying> 2925 2926 /** Number of entries stored in this dictionary. */ 2927 @property(nonatomic, readonly) NSUInteger count; 2928 2929 /** 2930 * Initializes this dictionary, copying the given values and keys. 2931 * 2932 * @param values The values to be placed in this dictionary. 2933 * @param keys The keys under which to store the values. 2934 * @param count The number of elements to copy into the dictionary. 2935 * 2936 * @return A newly initialized dictionary with a copy of the values and keys. 2937 **/ 2938 - (instancetype)initWithInt32s:(const int32_t [__nullable])values 2939 forKeys:(const int64_t [__nullable])keys 2940 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 2941 2942 /** 2943 * Initializes this dictionary, copying the entries from the given dictionary. 2944 * 2945 * @param dictionary Dictionary containing the entries to add to this dictionary. 2946 * 2947 * @return A newly initialized dictionary with the entries of the given dictionary. 2948 **/ 2949 - (instancetype)initWithDictionary:(GPBInt64Int32Dictionary *)dictionary; 2950 2951 /** 2952 * Initializes this dictionary with the requested capacity. 2953 * 2954 * @param numItems Number of items needed for this dictionary. 2955 * 2956 * @return A newly initialized dictionary with the requested capacity. 2957 **/ 2958 - (instancetype)initWithCapacity:(NSUInteger)numItems; 2959 2960 /** 2961 * Gets the value for the given key. 2962 * 2963 * @param value Pointer into which the value will be set, if found. 2964 * @param key Key under which the value is stored, if present. 2965 * 2966 * @return YES if the key was found and the value was copied, NO otherwise. 2967 **/ 2968 - (BOOL)getInt32:(nullable int32_t *)value forKey:(int64_t)key; 2969 2970 /** 2971 * Enumerates the keys and values on this dictionary with the given block. 2972 * 2973 * @param block The block to enumerate with. 2974 * **key**: The key for the current entry. 2975 * **value**: The value for the current entry 2976 * **stop**: A pointer to a boolean that when set stops the enumeration. 2977 **/ 2978 - (void)enumerateKeysAndInt32sUsingBlock: 2979 (void (NS_NOESCAPE ^)(int64_t key, int32_t value, BOOL *stop))block; 2980 2981 /** 2982 * Adds the keys and values from another dictionary. 2983 * 2984 * @param otherDictionary Dictionary containing entries to be added to this 2985 * dictionary. 2986 **/ 2987 - (void)addEntriesFromDictionary:(GPBInt64Int32Dictionary *)otherDictionary; 2988 2989 /** 2990 * Sets the value for the given key. 2991 * 2992 * @param value The value to set. 2993 * @param key The key under which to store the value. 2994 **/ 2995 - (void)setInt32:(int32_t)value forKey:(int64_t)key; 2996 2997 /** 2998 * Removes the entry for the given key. 2999 * 3000 * @param aKey Key to be removed from this dictionary. 3001 **/ 3002 - (void)removeInt32ForKey:(int64_t)aKey; 3003 3004 /** 3005 * Removes all entries in this dictionary. 3006 **/ 3007 - (void)removeAll; 3008 3009 @end 3010 3011 #pragma mark - Int64 -> UInt64 3012 3013 /** 3014 * Class used for map fields of <int64_t, uint64_t> 3015 * values. This performs better than boxing into NSNumbers in NSDictionaries. 3016 * 3017 * @note This class is not meant to be subclassed. 3018 **/ 3019 __attribute__((objc_subclassing_restricted)) 3020 @interface GPBInt64UInt64Dictionary : NSObject <NSCopying> 3021 3022 /** Number of entries stored in this dictionary. */ 3023 @property(nonatomic, readonly) NSUInteger count; 3024 3025 /** 3026 * Initializes this dictionary, copying the given values and keys. 3027 * 3028 * @param values The values to be placed in this dictionary. 3029 * @param keys The keys under which to store the values. 3030 * @param count The number of elements to copy into the dictionary. 3031 * 3032 * @return A newly initialized dictionary with a copy of the values and keys. 3033 **/ 3034 - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values 3035 forKeys:(const int64_t [__nullable])keys 3036 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 3037 3038 /** 3039 * Initializes this dictionary, copying the entries from the given dictionary. 3040 * 3041 * @param dictionary Dictionary containing the entries to add to this dictionary. 3042 * 3043 * @return A newly initialized dictionary with the entries of the given dictionary. 3044 **/ 3045 - (instancetype)initWithDictionary:(GPBInt64UInt64Dictionary *)dictionary; 3046 3047 /** 3048 * Initializes this dictionary with the requested capacity. 3049 * 3050 * @param numItems Number of items needed for this dictionary. 3051 * 3052 * @return A newly initialized dictionary with the requested capacity. 3053 **/ 3054 - (instancetype)initWithCapacity:(NSUInteger)numItems; 3055 3056 /** 3057 * Gets the value for the given key. 3058 * 3059 * @param value Pointer into which the value will be set, if found. 3060 * @param key Key under which the value is stored, if present. 3061 * 3062 * @return YES if the key was found and the value was copied, NO otherwise. 3063 **/ 3064 - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int64_t)key; 3065 3066 /** 3067 * Enumerates the keys and values on this dictionary with the given block. 3068 * 3069 * @param block The block to enumerate with. 3070 * **key**: The key for the current entry. 3071 * **value**: The value for the current entry 3072 * **stop**: A pointer to a boolean that when set stops the enumeration. 3073 **/ 3074 - (void)enumerateKeysAndUInt64sUsingBlock: 3075 (void (NS_NOESCAPE ^)(int64_t key, uint64_t value, BOOL *stop))block; 3076 3077 /** 3078 * Adds the keys and values from another dictionary. 3079 * 3080 * @param otherDictionary Dictionary containing entries to be added to this 3081 * dictionary. 3082 **/ 3083 - (void)addEntriesFromDictionary:(GPBInt64UInt64Dictionary *)otherDictionary; 3084 3085 /** 3086 * Sets the value for the given key. 3087 * 3088 * @param value The value to set. 3089 * @param key The key under which to store the value. 3090 **/ 3091 - (void)setUInt64:(uint64_t)value forKey:(int64_t)key; 3092 3093 /** 3094 * Removes the entry for the given key. 3095 * 3096 * @param aKey Key to be removed from this dictionary. 3097 **/ 3098 - (void)removeUInt64ForKey:(int64_t)aKey; 3099 3100 /** 3101 * Removes all entries in this dictionary. 3102 **/ 3103 - (void)removeAll; 3104 3105 @end 3106 3107 #pragma mark - Int64 -> Int64 3108 3109 /** 3110 * Class used for map fields of <int64_t, int64_t> 3111 * values. This performs better than boxing into NSNumbers in NSDictionaries. 3112 * 3113 * @note This class is not meant to be subclassed. 3114 **/ 3115 __attribute__((objc_subclassing_restricted)) 3116 @interface GPBInt64Int64Dictionary : NSObject <NSCopying> 3117 3118 /** Number of entries stored in this dictionary. */ 3119 @property(nonatomic, readonly) NSUInteger count; 3120 3121 /** 3122 * Initializes this dictionary, copying the given values and keys. 3123 * 3124 * @param values The values to be placed in this dictionary. 3125 * @param keys The keys under which to store the values. 3126 * @param count The number of elements to copy into the dictionary. 3127 * 3128 * @return A newly initialized dictionary with a copy of the values and keys. 3129 **/ 3130 - (instancetype)initWithInt64s:(const int64_t [__nullable])values 3131 forKeys:(const int64_t [__nullable])keys 3132 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 3133 3134 /** 3135 * Initializes this dictionary, copying the entries from the given dictionary. 3136 * 3137 * @param dictionary Dictionary containing the entries to add to this dictionary. 3138 * 3139 * @return A newly initialized dictionary with the entries of the given dictionary. 3140 **/ 3141 - (instancetype)initWithDictionary:(GPBInt64Int64Dictionary *)dictionary; 3142 3143 /** 3144 * Initializes this dictionary with the requested capacity. 3145 * 3146 * @param numItems Number of items needed for this dictionary. 3147 * 3148 * @return A newly initialized dictionary with the requested capacity. 3149 **/ 3150 - (instancetype)initWithCapacity:(NSUInteger)numItems; 3151 3152 /** 3153 * Gets the value for the given key. 3154 * 3155 * @param value Pointer into which the value will be set, if found. 3156 * @param key Key under which the value is stored, if present. 3157 * 3158 * @return YES if the key was found and the value was copied, NO otherwise. 3159 **/ 3160 - (BOOL)getInt64:(nullable int64_t *)value forKey:(int64_t)key; 3161 3162 /** 3163 * Enumerates the keys and values on this dictionary with the given block. 3164 * 3165 * @param block The block to enumerate with. 3166 * **key**: The key for the current entry. 3167 * **value**: The value for the current entry 3168 * **stop**: A pointer to a boolean that when set stops the enumeration. 3169 **/ 3170 - (void)enumerateKeysAndInt64sUsingBlock: 3171 (void (NS_NOESCAPE ^)(int64_t key, int64_t value, BOOL *stop))block; 3172 3173 /** 3174 * Adds the keys and values from another dictionary. 3175 * 3176 * @param otherDictionary Dictionary containing entries to be added to this 3177 * dictionary. 3178 **/ 3179 - (void)addEntriesFromDictionary:(GPBInt64Int64Dictionary *)otherDictionary; 3180 3181 /** 3182 * Sets the value for the given key. 3183 * 3184 * @param value The value to set. 3185 * @param key The key under which to store the value. 3186 **/ 3187 - (void)setInt64:(int64_t)value forKey:(int64_t)key; 3188 3189 /** 3190 * Removes the entry for the given key. 3191 * 3192 * @param aKey Key to be removed from this dictionary. 3193 **/ 3194 - (void)removeInt64ForKey:(int64_t)aKey; 3195 3196 /** 3197 * Removes all entries in this dictionary. 3198 **/ 3199 - (void)removeAll; 3200 3201 @end 3202 3203 #pragma mark - Int64 -> Bool 3204 3205 /** 3206 * Class used for map fields of <int64_t, BOOL> 3207 * values. This performs better than boxing into NSNumbers in NSDictionaries. 3208 * 3209 * @note This class is not meant to be subclassed. 3210 **/ 3211 __attribute__((objc_subclassing_restricted)) 3212 @interface GPBInt64BoolDictionary : NSObject <NSCopying> 3213 3214 /** Number of entries stored in this dictionary. */ 3215 @property(nonatomic, readonly) NSUInteger count; 3216 3217 /** 3218 * Initializes this dictionary, copying the given values and keys. 3219 * 3220 * @param values The values to be placed in this dictionary. 3221 * @param keys The keys under which to store the values. 3222 * @param count The number of elements to copy into the dictionary. 3223 * 3224 * @return A newly initialized dictionary with a copy of the values and keys. 3225 **/ 3226 - (instancetype)initWithBools:(const BOOL [__nullable])values 3227 forKeys:(const int64_t [__nullable])keys 3228 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 3229 3230 /** 3231 * Initializes this dictionary, copying the entries from the given dictionary. 3232 * 3233 * @param dictionary Dictionary containing the entries to add to this dictionary. 3234 * 3235 * @return A newly initialized dictionary with the entries of the given dictionary. 3236 **/ 3237 - (instancetype)initWithDictionary:(GPBInt64BoolDictionary *)dictionary; 3238 3239 /** 3240 * Initializes this dictionary with the requested capacity. 3241 * 3242 * @param numItems Number of items needed for this dictionary. 3243 * 3244 * @return A newly initialized dictionary with the requested capacity. 3245 **/ 3246 - (instancetype)initWithCapacity:(NSUInteger)numItems; 3247 3248 /** 3249 * Gets the value for the given key. 3250 * 3251 * @param value Pointer into which the value will be set, if found. 3252 * @param key Key under which the value is stored, if present. 3253 * 3254 * @return YES if the key was found and the value was copied, NO otherwise. 3255 **/ 3256 - (BOOL)getBool:(nullable BOOL *)value forKey:(int64_t)key; 3257 3258 /** 3259 * Enumerates the keys and values on this dictionary with the given block. 3260 * 3261 * @param block The block to enumerate with. 3262 * **key**: The key for the current entry. 3263 * **value**: The value for the current entry 3264 * **stop**: A pointer to a boolean that when set stops the enumeration. 3265 **/ 3266 - (void)enumerateKeysAndBoolsUsingBlock: 3267 (void (NS_NOESCAPE ^)(int64_t key, BOOL value, BOOL *stop))block; 3268 3269 /** 3270 * Adds the keys and values from another dictionary. 3271 * 3272 * @param otherDictionary Dictionary containing entries to be added to this 3273 * dictionary. 3274 **/ 3275 - (void)addEntriesFromDictionary:(GPBInt64BoolDictionary *)otherDictionary; 3276 3277 /** 3278 * Sets the value for the given key. 3279 * 3280 * @param value The value to set. 3281 * @param key The key under which to store the value. 3282 **/ 3283 - (void)setBool:(BOOL)value forKey:(int64_t)key; 3284 3285 /** 3286 * Removes the entry for the given key. 3287 * 3288 * @param aKey Key to be removed from this dictionary. 3289 **/ 3290 - (void)removeBoolForKey:(int64_t)aKey; 3291 3292 /** 3293 * Removes all entries in this dictionary. 3294 **/ 3295 - (void)removeAll; 3296 3297 @end 3298 3299 #pragma mark - Int64 -> Float 3300 3301 /** 3302 * Class used for map fields of <int64_t, float> 3303 * values. This performs better than boxing into NSNumbers in NSDictionaries. 3304 * 3305 * @note This class is not meant to be subclassed. 3306 **/ 3307 __attribute__((objc_subclassing_restricted)) 3308 @interface GPBInt64FloatDictionary : NSObject <NSCopying> 3309 3310 /** Number of entries stored in this dictionary. */ 3311 @property(nonatomic, readonly) NSUInteger count; 3312 3313 /** 3314 * Initializes this dictionary, copying the given values and keys. 3315 * 3316 * @param values The values to be placed in this dictionary. 3317 * @param keys The keys under which to store the values. 3318 * @param count The number of elements to copy into the dictionary. 3319 * 3320 * @return A newly initialized dictionary with a copy of the values and keys. 3321 **/ 3322 - (instancetype)initWithFloats:(const float [__nullable])values 3323 forKeys:(const int64_t [__nullable])keys 3324 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 3325 3326 /** 3327 * Initializes this dictionary, copying the entries from the given dictionary. 3328 * 3329 * @param dictionary Dictionary containing the entries to add to this dictionary. 3330 * 3331 * @return A newly initialized dictionary with the entries of the given dictionary. 3332 **/ 3333 - (instancetype)initWithDictionary:(GPBInt64FloatDictionary *)dictionary; 3334 3335 /** 3336 * Initializes this dictionary with the requested capacity. 3337 * 3338 * @param numItems Number of items needed for this dictionary. 3339 * 3340 * @return A newly initialized dictionary with the requested capacity. 3341 **/ 3342 - (instancetype)initWithCapacity:(NSUInteger)numItems; 3343 3344 /** 3345 * Gets the value for the given key. 3346 * 3347 * @param value Pointer into which the value will be set, if found. 3348 * @param key Key under which the value is stored, if present. 3349 * 3350 * @return YES if the key was found and the value was copied, NO otherwise. 3351 **/ 3352 - (BOOL)getFloat:(nullable float *)value forKey:(int64_t)key; 3353 3354 /** 3355 * Enumerates the keys and values on this dictionary with the given block. 3356 * 3357 * @param block The block to enumerate with. 3358 * **key**: The key for the current entry. 3359 * **value**: The value for the current entry 3360 * **stop**: A pointer to a boolean that when set stops the enumeration. 3361 **/ 3362 - (void)enumerateKeysAndFloatsUsingBlock: 3363 (void (NS_NOESCAPE ^)(int64_t key, float value, BOOL *stop))block; 3364 3365 /** 3366 * Adds the keys and values from another dictionary. 3367 * 3368 * @param otherDictionary Dictionary containing entries to be added to this 3369 * dictionary. 3370 **/ 3371 - (void)addEntriesFromDictionary:(GPBInt64FloatDictionary *)otherDictionary; 3372 3373 /** 3374 * Sets the value for the given key. 3375 * 3376 * @param value The value to set. 3377 * @param key The key under which to store the value. 3378 **/ 3379 - (void)setFloat:(float)value forKey:(int64_t)key; 3380 3381 /** 3382 * Removes the entry for the given key. 3383 * 3384 * @param aKey Key to be removed from this dictionary. 3385 **/ 3386 - (void)removeFloatForKey:(int64_t)aKey; 3387 3388 /** 3389 * Removes all entries in this dictionary. 3390 **/ 3391 - (void)removeAll; 3392 3393 @end 3394 3395 #pragma mark - Int64 -> Double 3396 3397 /** 3398 * Class used for map fields of <int64_t, double> 3399 * values. This performs better than boxing into NSNumbers in NSDictionaries. 3400 * 3401 * @note This class is not meant to be subclassed. 3402 **/ 3403 __attribute__((objc_subclassing_restricted)) 3404 @interface GPBInt64DoubleDictionary : NSObject <NSCopying> 3405 3406 /** Number of entries stored in this dictionary. */ 3407 @property(nonatomic, readonly) NSUInteger count; 3408 3409 /** 3410 * Initializes this dictionary, copying the given values and keys. 3411 * 3412 * @param values The values to be placed in this dictionary. 3413 * @param keys The keys under which to store the values. 3414 * @param count The number of elements to copy into the dictionary. 3415 * 3416 * @return A newly initialized dictionary with a copy of the values and keys. 3417 **/ 3418 - (instancetype)initWithDoubles:(const double [__nullable])values 3419 forKeys:(const int64_t [__nullable])keys 3420 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 3421 3422 /** 3423 * Initializes this dictionary, copying the entries from the given dictionary. 3424 * 3425 * @param dictionary Dictionary containing the entries to add to this dictionary. 3426 * 3427 * @return A newly initialized dictionary with the entries of the given dictionary. 3428 **/ 3429 - (instancetype)initWithDictionary:(GPBInt64DoubleDictionary *)dictionary; 3430 3431 /** 3432 * Initializes this dictionary with the requested capacity. 3433 * 3434 * @param numItems Number of items needed for this dictionary. 3435 * 3436 * @return A newly initialized dictionary with the requested capacity. 3437 **/ 3438 - (instancetype)initWithCapacity:(NSUInteger)numItems; 3439 3440 /** 3441 * Gets the value for the given key. 3442 * 3443 * @param value Pointer into which the value will be set, if found. 3444 * @param key Key under which the value is stored, if present. 3445 * 3446 * @return YES if the key was found and the value was copied, NO otherwise. 3447 **/ 3448 - (BOOL)getDouble:(nullable double *)value forKey:(int64_t)key; 3449 3450 /** 3451 * Enumerates the keys and values on this dictionary with the given block. 3452 * 3453 * @param block The block to enumerate with. 3454 * **key**: The key for the current entry. 3455 * **value**: The value for the current entry 3456 * **stop**: A pointer to a boolean that when set stops the enumeration. 3457 **/ 3458 - (void)enumerateKeysAndDoublesUsingBlock: 3459 (void (NS_NOESCAPE ^)(int64_t key, double value, BOOL *stop))block; 3460 3461 /** 3462 * Adds the keys and values from another dictionary. 3463 * 3464 * @param otherDictionary Dictionary containing entries to be added to this 3465 * dictionary. 3466 **/ 3467 - (void)addEntriesFromDictionary:(GPBInt64DoubleDictionary *)otherDictionary; 3468 3469 /** 3470 * Sets the value for the given key. 3471 * 3472 * @param value The value to set. 3473 * @param key The key under which to store the value. 3474 **/ 3475 - (void)setDouble:(double)value forKey:(int64_t)key; 3476 3477 /** 3478 * Removes the entry for the given key. 3479 * 3480 * @param aKey Key to be removed from this dictionary. 3481 **/ 3482 - (void)removeDoubleForKey:(int64_t)aKey; 3483 3484 /** 3485 * Removes all entries in this dictionary. 3486 **/ 3487 - (void)removeAll; 3488 3489 @end 3490 3491 #pragma mark - Int64 -> Enum 3492 3493 /** 3494 * Class used for map fields of <int64_t, int32_t> 3495 * values. This performs better than boxing into NSNumbers in NSDictionaries. 3496 * 3497 * @note This class is not meant to be subclassed. 3498 **/ 3499 __attribute__((objc_subclassing_restricted)) 3500 @interface GPBInt64EnumDictionary : NSObject <NSCopying> 3501 3502 /** Number of entries stored in this dictionary. */ 3503 @property(nonatomic, readonly) NSUInteger count; 3504 /** The validation function to check if the enums are valid. */ 3505 @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; 3506 3507 /** 3508 * Initializes a dictionary with the given validation function. 3509 * 3510 * @param func The enum validation function for the dictionary. 3511 * 3512 * @return A newly initialized dictionary. 3513 **/ 3514 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; 3515 3516 /** 3517 * Initializes a dictionary with the entries given. 3518 * 3519 * @param func The enum validation function for the dictionary. 3520 * @param values The raw enum values values to be placed in the dictionary. 3521 * @param keys The keys under which to store the values. 3522 * @param count The number of entries to store in the dictionary. 3523 * 3524 * @return A newly initialized dictionary with the keys and values in it. 3525 **/ 3526 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 3527 rawValues:(const int32_t [__nullable])values 3528 forKeys:(const int64_t [__nullable])keys 3529 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 3530 3531 /** 3532 * Initializes a dictionary with the entries from the given. 3533 * dictionary. 3534 * 3535 * @param dictionary Dictionary containing the entries to add to the dictionary. 3536 * 3537 * @return A newly initialized dictionary with the entries from the given 3538 * dictionary in it. 3539 **/ 3540 - (instancetype)initWithDictionary:(GPBInt64EnumDictionary *)dictionary; 3541 3542 /** 3543 * Initializes a dictionary with the given capacity. 3544 * 3545 * @param func The enum validation function for the dictionary. 3546 * @param numItems Capacity needed for the dictionary. 3547 * 3548 * @return A newly initialized dictionary with the given capacity. 3549 **/ 3550 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 3551 capacity:(NSUInteger)numItems; 3552 3553 // These will return kGPBUnrecognizedEnumeratorValue if the value for the key 3554 // is not a valid enumerator as defined by validationFunc. If the actual value is 3555 // desired, use "raw" version of the method. 3556 3557 /** 3558 * Gets the value for the given key. 3559 * 3560 * @param value Pointer into which the value will be set, if found. 3561 * @param key Key under which the value is stored, if present. 3562 * 3563 * @return YES if the key was found and the value was copied, NO otherwise. 3564 **/ 3565 - (BOOL)getEnum:(nullable int32_t *)value forKey:(int64_t)key; 3566 3567 /** 3568 * Enumerates the keys and values on this dictionary with the given block. 3569 * 3570 * @param block The block to enumerate with. 3571 * **key**: The key for the current entry. 3572 * **value**: The value for the current entry 3573 * **stop**: A pointer to a boolean that when set stops the enumeration. 3574 **/ 3575 - (void)enumerateKeysAndEnumsUsingBlock: 3576 (void (NS_NOESCAPE ^)(int64_t key, int32_t value, BOOL *stop))block; 3577 3578 /** 3579 * Gets the raw enum value for the given key. 3580 * 3581 * @note This method bypass the validationFunc to enable the access of values that 3582 * were not known at the time the binary was compiled. 3583 * 3584 * @param rawValue Pointer into which the value will be set, if found. 3585 * @param key Key under which the value is stored, if present. 3586 * 3587 * @return YES if the key was found and the value was copied, NO otherwise. 3588 **/ 3589 - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int64_t)key; 3590 3591 /** 3592 * Enumerates the keys and values on this dictionary with the given block. 3593 * 3594 * @note This method bypass the validationFunc to enable the access of values that 3595 * were not known at the time the binary was compiled. 3596 * 3597 * @param block The block to enumerate with. 3598 * **key**: The key for the current entry. 3599 * **rawValue**: The value for the current entry 3600 * **stop**: A pointer to a boolean that when set stops the enumeration. 3601 **/ 3602 - (void)enumerateKeysAndRawValuesUsingBlock: 3603 (void (NS_NOESCAPE ^)(int64_t key, int32_t rawValue, BOOL *stop))block; 3604 3605 /** 3606 * Adds the keys and raw enum values from another dictionary. 3607 * 3608 * @note This method bypass the validationFunc to enable the setting of values that 3609 * were not known at the time the binary was compiled. 3610 * 3611 * @param otherDictionary Dictionary containing entries to be added to this 3612 * dictionary. 3613 **/ 3614 - (void)addRawEntriesFromDictionary:(GPBInt64EnumDictionary *)otherDictionary; 3615 3616 // If value is not a valid enumerator as defined by validationFunc, these 3617 // methods will assert in debug, and will log in release and assign the value 3618 // to the default value. Use the rawValue methods below to assign non enumerator 3619 // values. 3620 3621 /** 3622 * Sets the value for the given key. 3623 * 3624 * @param value The value to set. 3625 * @param key The key under which to store the value. 3626 **/ 3627 - (void)setEnum:(int32_t)value forKey:(int64_t)key; 3628 3629 /** 3630 * Sets the raw enum value for the given key. 3631 * 3632 * @note This method bypass the validationFunc to enable the setting of values that 3633 * were not known at the time the binary was compiled. 3634 * 3635 * @param rawValue The raw enum value to set. 3636 * @param key The key under which to store the raw enum value. 3637 **/ 3638 - (void)setRawValue:(int32_t)rawValue forKey:(int64_t)key; 3639 3640 /** 3641 * Removes the entry for the given key. 3642 * 3643 * @param aKey Key to be removed from this dictionary. 3644 **/ 3645 - (void)removeEnumForKey:(int64_t)aKey; 3646 3647 /** 3648 * Removes all entries in this dictionary. 3649 **/ 3650 - (void)removeAll; 3651 3652 @end 3653 3654 #pragma mark - Int64 -> Object 3655 3656 /** 3657 * Class used for map fields of <int64_t, ObjectType> 3658 * values. This performs better than boxing into NSNumbers in NSDictionaries. 3659 * 3660 * @note This class is not meant to be subclassed. 3661 **/ 3662 __attribute__((objc_subclassing_restricted)) 3663 @interface GPBInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying> 3664 3665 /** Number of entries stored in this dictionary. */ 3666 @property(nonatomic, readonly) NSUInteger count; 3667 3668 /** 3669 * Initializes this dictionary, copying the given values and keys. 3670 * 3671 * @param objects The values to be placed in this dictionary. 3672 * @param keys The keys under which to store the values. 3673 * @param count The number of elements to copy into the dictionary. 3674 * 3675 * @return A newly initialized dictionary with a copy of the values and keys. 3676 **/ 3677 - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects 3678 forKeys:(const int64_t [__nullable])keys 3679 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 3680 3681 /** 3682 * Initializes this dictionary, copying the entries from the given dictionary. 3683 * 3684 * @param dictionary Dictionary containing the entries to add to this dictionary. 3685 * 3686 * @return A newly initialized dictionary with the entries of the given dictionary. 3687 **/ 3688 - (instancetype)initWithDictionary:(GPBInt64ObjectDictionary *)dictionary; 3689 3690 /** 3691 * Initializes this dictionary with the requested capacity. 3692 * 3693 * @param numItems Number of items needed for this dictionary. 3694 * 3695 * @return A newly initialized dictionary with the requested capacity. 3696 **/ 3697 - (instancetype)initWithCapacity:(NSUInteger)numItems; 3698 3699 /** 3700 * Fetches the object stored under the given key. 3701 * 3702 * @param key Key under which the value is stored, if present. 3703 * 3704 * @return The object if found, nil otherwise. 3705 **/ 3706 - (ObjectType)objectForKey:(int64_t)key; 3707 3708 /** 3709 * Enumerates the keys and values on this dictionary with the given block. 3710 * 3711 * @param block The block to enumerate with. 3712 * **key**: The key for the current entry. 3713 * **object**: The value for the current entry 3714 * **stop**: A pointer to a boolean that when set stops the enumeration. 3715 **/ 3716 - (void)enumerateKeysAndObjectsUsingBlock: 3717 (void (NS_NOESCAPE ^)(int64_t key, ObjectType object, BOOL *stop))block; 3718 3719 /** 3720 * Adds the keys and values from another dictionary. 3721 * 3722 * @param otherDictionary Dictionary containing entries to be added to this 3723 * dictionary. 3724 **/ 3725 - (void)addEntriesFromDictionary:(GPBInt64ObjectDictionary *)otherDictionary; 3726 3727 /** 3728 * Sets the value for the given key. 3729 * 3730 * @param object The value to set. 3731 * @param key The key under which to store the value. 3732 **/ 3733 - (void)setObject:(ObjectType)object forKey:(int64_t)key; 3734 3735 /** 3736 * Removes the entry for the given key. 3737 * 3738 * @param aKey Key to be removed from this dictionary. 3739 **/ 3740 - (void)removeObjectForKey:(int64_t)aKey; 3741 3742 /** 3743 * Removes all entries in this dictionary. 3744 **/ 3745 - (void)removeAll; 3746 3747 @end 3748 3749 #pragma mark - Bool -> UInt32 3750 3751 /** 3752 * Class used for map fields of <BOOL, uint32_t> 3753 * values. This performs better than boxing into NSNumbers in NSDictionaries. 3754 * 3755 * @note This class is not meant to be subclassed. 3756 **/ 3757 __attribute__((objc_subclassing_restricted)) 3758 @interface GPBBoolUInt32Dictionary : NSObject <NSCopying> 3759 3760 /** Number of entries stored in this dictionary. */ 3761 @property(nonatomic, readonly) NSUInteger count; 3762 3763 /** 3764 * Initializes this dictionary, copying the given values and keys. 3765 * 3766 * @param values The values to be placed in this dictionary. 3767 * @param keys The keys under which to store the values. 3768 * @param count The number of elements to copy into the dictionary. 3769 * 3770 * @return A newly initialized dictionary with a copy of the values and keys. 3771 **/ 3772 - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values 3773 forKeys:(const BOOL [__nullable])keys 3774 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 3775 3776 /** 3777 * Initializes this dictionary, copying the entries from the given dictionary. 3778 * 3779 * @param dictionary Dictionary containing the entries to add to this dictionary. 3780 * 3781 * @return A newly initialized dictionary with the entries of the given dictionary. 3782 **/ 3783 - (instancetype)initWithDictionary:(GPBBoolUInt32Dictionary *)dictionary; 3784 3785 /** 3786 * Initializes this dictionary with the requested capacity. 3787 * 3788 * @param numItems Number of items needed for this dictionary. 3789 * 3790 * @return A newly initialized dictionary with the requested capacity. 3791 **/ 3792 - (instancetype)initWithCapacity:(NSUInteger)numItems; 3793 3794 /** 3795 * Gets the value for the given key. 3796 * 3797 * @param value Pointer into which the value will be set, if found. 3798 * @param key Key under which the value is stored, if present. 3799 * 3800 * @return YES if the key was found and the value was copied, NO otherwise. 3801 **/ 3802 - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(BOOL)key; 3803 3804 /** 3805 * Enumerates the keys and values on this dictionary with the given block. 3806 * 3807 * @param block The block to enumerate with. 3808 * **key**: The key for the current entry. 3809 * **value**: The value for the current entry 3810 * **stop**: A pointer to a boolean that when set stops the enumeration. 3811 **/ 3812 - (void)enumerateKeysAndUInt32sUsingBlock: 3813 (void (NS_NOESCAPE ^)(BOOL key, uint32_t value, BOOL *stop))block; 3814 3815 /** 3816 * Adds the keys and values from another dictionary. 3817 * 3818 * @param otherDictionary Dictionary containing entries to be added to this 3819 * dictionary. 3820 **/ 3821 - (void)addEntriesFromDictionary:(GPBBoolUInt32Dictionary *)otherDictionary; 3822 3823 /** 3824 * Sets the value for the given key. 3825 * 3826 * @param value The value to set. 3827 * @param key The key under which to store the value. 3828 **/ 3829 - (void)setUInt32:(uint32_t)value forKey:(BOOL)key; 3830 3831 /** 3832 * Removes the entry for the given key. 3833 * 3834 * @param aKey Key to be removed from this dictionary. 3835 **/ 3836 - (void)removeUInt32ForKey:(BOOL)aKey; 3837 3838 /** 3839 * Removes all entries in this dictionary. 3840 **/ 3841 - (void)removeAll; 3842 3843 @end 3844 3845 #pragma mark - Bool -> Int32 3846 3847 /** 3848 * Class used for map fields of <BOOL, int32_t> 3849 * values. This performs better than boxing into NSNumbers in NSDictionaries. 3850 * 3851 * @note This class is not meant to be subclassed. 3852 **/ 3853 __attribute__((objc_subclassing_restricted)) 3854 @interface GPBBoolInt32Dictionary : NSObject <NSCopying> 3855 3856 /** Number of entries stored in this dictionary. */ 3857 @property(nonatomic, readonly) NSUInteger count; 3858 3859 /** 3860 * Initializes this dictionary, copying the given values and keys. 3861 * 3862 * @param values The values to be placed in this dictionary. 3863 * @param keys The keys under which to store the values. 3864 * @param count The number of elements to copy into the dictionary. 3865 * 3866 * @return A newly initialized dictionary with a copy of the values and keys. 3867 **/ 3868 - (instancetype)initWithInt32s:(const int32_t [__nullable])values 3869 forKeys:(const BOOL [__nullable])keys 3870 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 3871 3872 /** 3873 * Initializes this dictionary, copying the entries from the given dictionary. 3874 * 3875 * @param dictionary Dictionary containing the entries to add to this dictionary. 3876 * 3877 * @return A newly initialized dictionary with the entries of the given dictionary. 3878 **/ 3879 - (instancetype)initWithDictionary:(GPBBoolInt32Dictionary *)dictionary; 3880 3881 /** 3882 * Initializes this dictionary with the requested capacity. 3883 * 3884 * @param numItems Number of items needed for this dictionary. 3885 * 3886 * @return A newly initialized dictionary with the requested capacity. 3887 **/ 3888 - (instancetype)initWithCapacity:(NSUInteger)numItems; 3889 3890 /** 3891 * Gets the value for the given key. 3892 * 3893 * @param value Pointer into which the value will be set, if found. 3894 * @param key Key under which the value is stored, if present. 3895 * 3896 * @return YES if the key was found and the value was copied, NO otherwise. 3897 **/ 3898 - (BOOL)getInt32:(nullable int32_t *)value forKey:(BOOL)key; 3899 3900 /** 3901 * Enumerates the keys and values on this dictionary with the given block. 3902 * 3903 * @param block The block to enumerate with. 3904 * **key**: The key for the current entry. 3905 * **value**: The value for the current entry 3906 * **stop**: A pointer to a boolean that when set stops the enumeration. 3907 **/ 3908 - (void)enumerateKeysAndInt32sUsingBlock: 3909 (void (NS_NOESCAPE ^)(BOOL key, int32_t value, BOOL *stop))block; 3910 3911 /** 3912 * Adds the keys and values from another dictionary. 3913 * 3914 * @param otherDictionary Dictionary containing entries to be added to this 3915 * dictionary. 3916 **/ 3917 - (void)addEntriesFromDictionary:(GPBBoolInt32Dictionary *)otherDictionary; 3918 3919 /** 3920 * Sets the value for the given key. 3921 * 3922 * @param value The value to set. 3923 * @param key The key under which to store the value. 3924 **/ 3925 - (void)setInt32:(int32_t)value forKey:(BOOL)key; 3926 3927 /** 3928 * Removes the entry for the given key. 3929 * 3930 * @param aKey Key to be removed from this dictionary. 3931 **/ 3932 - (void)removeInt32ForKey:(BOOL)aKey; 3933 3934 /** 3935 * Removes all entries in this dictionary. 3936 **/ 3937 - (void)removeAll; 3938 3939 @end 3940 3941 #pragma mark - Bool -> UInt64 3942 3943 /** 3944 * Class used for map fields of <BOOL, uint64_t> 3945 * values. This performs better than boxing into NSNumbers in NSDictionaries. 3946 * 3947 * @note This class is not meant to be subclassed. 3948 **/ 3949 __attribute__((objc_subclassing_restricted)) 3950 @interface GPBBoolUInt64Dictionary : NSObject <NSCopying> 3951 3952 /** Number of entries stored in this dictionary. */ 3953 @property(nonatomic, readonly) NSUInteger count; 3954 3955 /** 3956 * Initializes this dictionary, copying the given values and keys. 3957 * 3958 * @param values The values to be placed in this dictionary. 3959 * @param keys The keys under which to store the values. 3960 * @param count The number of elements to copy into the dictionary. 3961 * 3962 * @return A newly initialized dictionary with a copy of the values and keys. 3963 **/ 3964 - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values 3965 forKeys:(const BOOL [__nullable])keys 3966 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 3967 3968 /** 3969 * Initializes this dictionary, copying the entries from the given dictionary. 3970 * 3971 * @param dictionary Dictionary containing the entries to add to this dictionary. 3972 * 3973 * @return A newly initialized dictionary with the entries of the given dictionary. 3974 **/ 3975 - (instancetype)initWithDictionary:(GPBBoolUInt64Dictionary *)dictionary; 3976 3977 /** 3978 * Initializes this dictionary with the requested capacity. 3979 * 3980 * @param numItems Number of items needed for this dictionary. 3981 * 3982 * @return A newly initialized dictionary with the requested capacity. 3983 **/ 3984 - (instancetype)initWithCapacity:(NSUInteger)numItems; 3985 3986 /** 3987 * Gets the value for the given key. 3988 * 3989 * @param value Pointer into which the value will be set, if found. 3990 * @param key Key under which the value is stored, if present. 3991 * 3992 * @return YES if the key was found and the value was copied, NO otherwise. 3993 **/ 3994 - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(BOOL)key; 3995 3996 /** 3997 * Enumerates the keys and values on this dictionary with the given block. 3998 * 3999 * @param block The block to enumerate with. 4000 * **key**: The key for the current entry. 4001 * **value**: The value for the current entry 4002 * **stop**: A pointer to a boolean that when set stops the enumeration. 4003 **/ 4004 - (void)enumerateKeysAndUInt64sUsingBlock: 4005 (void (NS_NOESCAPE ^)(BOOL key, uint64_t value, BOOL *stop))block; 4006 4007 /** 4008 * Adds the keys and values from another dictionary. 4009 * 4010 * @param otherDictionary Dictionary containing entries to be added to this 4011 * dictionary. 4012 **/ 4013 - (void)addEntriesFromDictionary:(GPBBoolUInt64Dictionary *)otherDictionary; 4014 4015 /** 4016 * Sets the value for the given key. 4017 * 4018 * @param value The value to set. 4019 * @param key The key under which to store the value. 4020 **/ 4021 - (void)setUInt64:(uint64_t)value forKey:(BOOL)key; 4022 4023 /** 4024 * Removes the entry for the given key. 4025 * 4026 * @param aKey Key to be removed from this dictionary. 4027 **/ 4028 - (void)removeUInt64ForKey:(BOOL)aKey; 4029 4030 /** 4031 * Removes all entries in this dictionary. 4032 **/ 4033 - (void)removeAll; 4034 4035 @end 4036 4037 #pragma mark - Bool -> Int64 4038 4039 /** 4040 * Class used for map fields of <BOOL, int64_t> 4041 * values. This performs better than boxing into NSNumbers in NSDictionaries. 4042 * 4043 * @note This class is not meant to be subclassed. 4044 **/ 4045 __attribute__((objc_subclassing_restricted)) 4046 @interface GPBBoolInt64Dictionary : NSObject <NSCopying> 4047 4048 /** Number of entries stored in this dictionary. */ 4049 @property(nonatomic, readonly) NSUInteger count; 4050 4051 /** 4052 * Initializes this dictionary, copying the given values and keys. 4053 * 4054 * @param values The values to be placed in this dictionary. 4055 * @param keys The keys under which to store the values. 4056 * @param count The number of elements to copy into the dictionary. 4057 * 4058 * @return A newly initialized dictionary with a copy of the values and keys. 4059 **/ 4060 - (instancetype)initWithInt64s:(const int64_t [__nullable])values 4061 forKeys:(const BOOL [__nullable])keys 4062 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 4063 4064 /** 4065 * Initializes this dictionary, copying the entries from the given dictionary. 4066 * 4067 * @param dictionary Dictionary containing the entries to add to this dictionary. 4068 * 4069 * @return A newly initialized dictionary with the entries of the given dictionary. 4070 **/ 4071 - (instancetype)initWithDictionary:(GPBBoolInt64Dictionary *)dictionary; 4072 4073 /** 4074 * Initializes this dictionary with the requested capacity. 4075 * 4076 * @param numItems Number of items needed for this dictionary. 4077 * 4078 * @return A newly initialized dictionary with the requested capacity. 4079 **/ 4080 - (instancetype)initWithCapacity:(NSUInteger)numItems; 4081 4082 /** 4083 * Gets the value for the given key. 4084 * 4085 * @param value Pointer into which the value will be set, if found. 4086 * @param key Key under which the value is stored, if present. 4087 * 4088 * @return YES if the key was found and the value was copied, NO otherwise. 4089 **/ 4090 - (BOOL)getInt64:(nullable int64_t *)value forKey:(BOOL)key; 4091 4092 /** 4093 * Enumerates the keys and values on this dictionary with the given block. 4094 * 4095 * @param block The block to enumerate with. 4096 * **key**: The key for the current entry. 4097 * **value**: The value for the current entry 4098 * **stop**: A pointer to a boolean that when set stops the enumeration. 4099 **/ 4100 - (void)enumerateKeysAndInt64sUsingBlock: 4101 (void (NS_NOESCAPE ^)(BOOL key, int64_t value, BOOL *stop))block; 4102 4103 /** 4104 * Adds the keys and values from another dictionary. 4105 * 4106 * @param otherDictionary Dictionary containing entries to be added to this 4107 * dictionary. 4108 **/ 4109 - (void)addEntriesFromDictionary:(GPBBoolInt64Dictionary *)otherDictionary; 4110 4111 /** 4112 * Sets the value for the given key. 4113 * 4114 * @param value The value to set. 4115 * @param key The key under which to store the value. 4116 **/ 4117 - (void)setInt64:(int64_t)value forKey:(BOOL)key; 4118 4119 /** 4120 * Removes the entry for the given key. 4121 * 4122 * @param aKey Key to be removed from this dictionary. 4123 **/ 4124 - (void)removeInt64ForKey:(BOOL)aKey; 4125 4126 /** 4127 * Removes all entries in this dictionary. 4128 **/ 4129 - (void)removeAll; 4130 4131 @end 4132 4133 #pragma mark - Bool -> Bool 4134 4135 /** 4136 * Class used for map fields of <BOOL, BOOL> 4137 * values. This performs better than boxing into NSNumbers in NSDictionaries. 4138 * 4139 * @note This class is not meant to be subclassed. 4140 **/ 4141 __attribute__((objc_subclassing_restricted)) 4142 @interface GPBBoolBoolDictionary : NSObject <NSCopying> 4143 4144 /** Number of entries stored in this dictionary. */ 4145 @property(nonatomic, readonly) NSUInteger count; 4146 4147 /** 4148 * Initializes this dictionary, copying the given values and keys. 4149 * 4150 * @param values The values to be placed in this dictionary. 4151 * @param keys The keys under which to store the values. 4152 * @param count The number of elements to copy into the dictionary. 4153 * 4154 * @return A newly initialized dictionary with a copy of the values and keys. 4155 **/ 4156 - (instancetype)initWithBools:(const BOOL [__nullable])values 4157 forKeys:(const BOOL [__nullable])keys 4158 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 4159 4160 /** 4161 * Initializes this dictionary, copying the entries from the given dictionary. 4162 * 4163 * @param dictionary Dictionary containing the entries to add to this dictionary. 4164 * 4165 * @return A newly initialized dictionary with the entries of the given dictionary. 4166 **/ 4167 - (instancetype)initWithDictionary:(GPBBoolBoolDictionary *)dictionary; 4168 4169 /** 4170 * Initializes this dictionary with the requested capacity. 4171 * 4172 * @param numItems Number of items needed for this dictionary. 4173 * 4174 * @return A newly initialized dictionary with the requested capacity. 4175 **/ 4176 - (instancetype)initWithCapacity:(NSUInteger)numItems; 4177 4178 /** 4179 * Gets the value for the given key. 4180 * 4181 * @param value Pointer into which the value will be set, if found. 4182 * @param key Key under which the value is stored, if present. 4183 * 4184 * @return YES if the key was found and the value was copied, NO otherwise. 4185 **/ 4186 - (BOOL)getBool:(nullable BOOL *)value forKey:(BOOL)key; 4187 4188 /** 4189 * Enumerates the keys and values on this dictionary with the given block. 4190 * 4191 * @param block The block to enumerate with. 4192 * **key**: The key for the current entry. 4193 * **value**: The value for the current entry 4194 * **stop**: A pointer to a boolean that when set stops the enumeration. 4195 **/ 4196 - (void)enumerateKeysAndBoolsUsingBlock: 4197 (void (NS_NOESCAPE ^)(BOOL key, BOOL value, BOOL *stop))block; 4198 4199 /** 4200 * Adds the keys and values from another dictionary. 4201 * 4202 * @param otherDictionary Dictionary containing entries to be added to this 4203 * dictionary. 4204 **/ 4205 - (void)addEntriesFromDictionary:(GPBBoolBoolDictionary *)otherDictionary; 4206 4207 /** 4208 * Sets the value for the given key. 4209 * 4210 * @param value The value to set. 4211 * @param key The key under which to store the value. 4212 **/ 4213 - (void)setBool:(BOOL)value forKey:(BOOL)key; 4214 4215 /** 4216 * Removes the entry for the given key. 4217 * 4218 * @param aKey Key to be removed from this dictionary. 4219 **/ 4220 - (void)removeBoolForKey:(BOOL)aKey; 4221 4222 /** 4223 * Removes all entries in this dictionary. 4224 **/ 4225 - (void)removeAll; 4226 4227 @end 4228 4229 #pragma mark - Bool -> Float 4230 4231 /** 4232 * Class used for map fields of <BOOL, float> 4233 * values. This performs better than boxing into NSNumbers in NSDictionaries. 4234 * 4235 * @note This class is not meant to be subclassed. 4236 **/ 4237 __attribute__((objc_subclassing_restricted)) 4238 @interface GPBBoolFloatDictionary : NSObject <NSCopying> 4239 4240 /** Number of entries stored in this dictionary. */ 4241 @property(nonatomic, readonly) NSUInteger count; 4242 4243 /** 4244 * Initializes this dictionary, copying the given values and keys. 4245 * 4246 * @param values The values to be placed in this dictionary. 4247 * @param keys The keys under which to store the values. 4248 * @param count The number of elements to copy into the dictionary. 4249 * 4250 * @return A newly initialized dictionary with a copy of the values and keys. 4251 **/ 4252 - (instancetype)initWithFloats:(const float [__nullable])values 4253 forKeys:(const BOOL [__nullable])keys 4254 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 4255 4256 /** 4257 * Initializes this dictionary, copying the entries from the given dictionary. 4258 * 4259 * @param dictionary Dictionary containing the entries to add to this dictionary. 4260 * 4261 * @return A newly initialized dictionary with the entries of the given dictionary. 4262 **/ 4263 - (instancetype)initWithDictionary:(GPBBoolFloatDictionary *)dictionary; 4264 4265 /** 4266 * Initializes this dictionary with the requested capacity. 4267 * 4268 * @param numItems Number of items needed for this dictionary. 4269 * 4270 * @return A newly initialized dictionary with the requested capacity. 4271 **/ 4272 - (instancetype)initWithCapacity:(NSUInteger)numItems; 4273 4274 /** 4275 * Gets the value for the given key. 4276 * 4277 * @param value Pointer into which the value will be set, if found. 4278 * @param key Key under which the value is stored, if present. 4279 * 4280 * @return YES if the key was found and the value was copied, NO otherwise. 4281 **/ 4282 - (BOOL)getFloat:(nullable float *)value forKey:(BOOL)key; 4283 4284 /** 4285 * Enumerates the keys and values on this dictionary with the given block. 4286 * 4287 * @param block The block to enumerate with. 4288 * **key**: The key for the current entry. 4289 * **value**: The value for the current entry 4290 * **stop**: A pointer to a boolean that when set stops the enumeration. 4291 **/ 4292 - (void)enumerateKeysAndFloatsUsingBlock: 4293 (void (NS_NOESCAPE ^)(BOOL key, float value, BOOL *stop))block; 4294 4295 /** 4296 * Adds the keys and values from another dictionary. 4297 * 4298 * @param otherDictionary Dictionary containing entries to be added to this 4299 * dictionary. 4300 **/ 4301 - (void)addEntriesFromDictionary:(GPBBoolFloatDictionary *)otherDictionary; 4302 4303 /** 4304 * Sets the value for the given key. 4305 * 4306 * @param value The value to set. 4307 * @param key The key under which to store the value. 4308 **/ 4309 - (void)setFloat:(float)value forKey:(BOOL)key; 4310 4311 /** 4312 * Removes the entry for the given key. 4313 * 4314 * @param aKey Key to be removed from this dictionary. 4315 **/ 4316 - (void)removeFloatForKey:(BOOL)aKey; 4317 4318 /** 4319 * Removes all entries in this dictionary. 4320 **/ 4321 - (void)removeAll; 4322 4323 @end 4324 4325 #pragma mark - Bool -> Double 4326 4327 /** 4328 * Class used for map fields of <BOOL, double> 4329 * values. This performs better than boxing into NSNumbers in NSDictionaries. 4330 * 4331 * @note This class is not meant to be subclassed. 4332 **/ 4333 __attribute__((objc_subclassing_restricted)) 4334 @interface GPBBoolDoubleDictionary : NSObject <NSCopying> 4335 4336 /** Number of entries stored in this dictionary. */ 4337 @property(nonatomic, readonly) NSUInteger count; 4338 4339 /** 4340 * Initializes this dictionary, copying the given values and keys. 4341 * 4342 * @param values The values to be placed in this dictionary. 4343 * @param keys The keys under which to store the values. 4344 * @param count The number of elements to copy into the dictionary. 4345 * 4346 * @return A newly initialized dictionary with a copy of the values and keys. 4347 **/ 4348 - (instancetype)initWithDoubles:(const double [__nullable])values 4349 forKeys:(const BOOL [__nullable])keys 4350 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 4351 4352 /** 4353 * Initializes this dictionary, copying the entries from the given dictionary. 4354 * 4355 * @param dictionary Dictionary containing the entries to add to this dictionary. 4356 * 4357 * @return A newly initialized dictionary with the entries of the given dictionary. 4358 **/ 4359 - (instancetype)initWithDictionary:(GPBBoolDoubleDictionary *)dictionary; 4360 4361 /** 4362 * Initializes this dictionary with the requested capacity. 4363 * 4364 * @param numItems Number of items needed for this dictionary. 4365 * 4366 * @return A newly initialized dictionary with the requested capacity. 4367 **/ 4368 - (instancetype)initWithCapacity:(NSUInteger)numItems; 4369 4370 /** 4371 * Gets the value for the given key. 4372 * 4373 * @param value Pointer into which the value will be set, if found. 4374 * @param key Key under which the value is stored, if present. 4375 * 4376 * @return YES if the key was found and the value was copied, NO otherwise. 4377 **/ 4378 - (BOOL)getDouble:(nullable double *)value forKey:(BOOL)key; 4379 4380 /** 4381 * Enumerates the keys and values on this dictionary with the given block. 4382 * 4383 * @param block The block to enumerate with. 4384 * **key**: The key for the current entry. 4385 * **value**: The value for the current entry 4386 * **stop**: A pointer to a boolean that when set stops the enumeration. 4387 **/ 4388 - (void)enumerateKeysAndDoublesUsingBlock: 4389 (void (NS_NOESCAPE ^)(BOOL key, double value, BOOL *stop))block; 4390 4391 /** 4392 * Adds the keys and values from another dictionary. 4393 * 4394 * @param otherDictionary Dictionary containing entries to be added to this 4395 * dictionary. 4396 **/ 4397 - (void)addEntriesFromDictionary:(GPBBoolDoubleDictionary *)otherDictionary; 4398 4399 /** 4400 * Sets the value for the given key. 4401 * 4402 * @param value The value to set. 4403 * @param key The key under which to store the value. 4404 **/ 4405 - (void)setDouble:(double)value forKey:(BOOL)key; 4406 4407 /** 4408 * Removes the entry for the given key. 4409 * 4410 * @param aKey Key to be removed from this dictionary. 4411 **/ 4412 - (void)removeDoubleForKey:(BOOL)aKey; 4413 4414 /** 4415 * Removes all entries in this dictionary. 4416 **/ 4417 - (void)removeAll; 4418 4419 @end 4420 4421 #pragma mark - Bool -> Enum 4422 4423 /** 4424 * Class used for map fields of <BOOL, int32_t> 4425 * values. This performs better than boxing into NSNumbers in NSDictionaries. 4426 * 4427 * @note This class is not meant to be subclassed. 4428 **/ 4429 __attribute__((objc_subclassing_restricted)) 4430 @interface GPBBoolEnumDictionary : NSObject <NSCopying> 4431 4432 /** Number of entries stored in this dictionary. */ 4433 @property(nonatomic, readonly) NSUInteger count; 4434 /** The validation function to check if the enums are valid. */ 4435 @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; 4436 4437 /** 4438 * Initializes a dictionary with the given validation function. 4439 * 4440 * @param func The enum validation function for the dictionary. 4441 * 4442 * @return A newly initialized dictionary. 4443 **/ 4444 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; 4445 4446 /** 4447 * Initializes a dictionary with the entries given. 4448 * 4449 * @param func The enum validation function for the dictionary. 4450 * @param values The raw enum values values to be placed in the dictionary. 4451 * @param keys The keys under which to store the values. 4452 * @param count The number of entries to store in the dictionary. 4453 * 4454 * @return A newly initialized dictionary with the keys and values in it. 4455 **/ 4456 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 4457 rawValues:(const int32_t [__nullable])values 4458 forKeys:(const BOOL [__nullable])keys 4459 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 4460 4461 /** 4462 * Initializes a dictionary with the entries from the given. 4463 * dictionary. 4464 * 4465 * @param dictionary Dictionary containing the entries to add to the dictionary. 4466 * 4467 * @return A newly initialized dictionary with the entries from the given 4468 * dictionary in it. 4469 **/ 4470 - (instancetype)initWithDictionary:(GPBBoolEnumDictionary *)dictionary; 4471 4472 /** 4473 * Initializes a dictionary with the given capacity. 4474 * 4475 * @param func The enum validation function for the dictionary. 4476 * @param numItems Capacity needed for the dictionary. 4477 * 4478 * @return A newly initialized dictionary with the given capacity. 4479 **/ 4480 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 4481 capacity:(NSUInteger)numItems; 4482 4483 // These will return kGPBUnrecognizedEnumeratorValue if the value for the key 4484 // is not a valid enumerator as defined by validationFunc. If the actual value is 4485 // desired, use "raw" version of the method. 4486 4487 /** 4488 * Gets the value for the given key. 4489 * 4490 * @param value Pointer into which the value will be set, if found. 4491 * @param key Key under which the value is stored, if present. 4492 * 4493 * @return YES if the key was found and the value was copied, NO otherwise. 4494 **/ 4495 - (BOOL)getEnum:(nullable int32_t *)value forKey:(BOOL)key; 4496 4497 /** 4498 * Enumerates the keys and values on this dictionary with the given block. 4499 * 4500 * @param block The block to enumerate with. 4501 * **key**: The key for the current entry. 4502 * **value**: The value for the current entry 4503 * **stop**: A pointer to a boolean that when set stops the enumeration. 4504 **/ 4505 - (void)enumerateKeysAndEnumsUsingBlock: 4506 (void (NS_NOESCAPE ^)(BOOL key, int32_t value, BOOL *stop))block; 4507 4508 /** 4509 * Gets the raw enum value for the given key. 4510 * 4511 * @note This method bypass the validationFunc to enable the access of values that 4512 * were not known at the time the binary was compiled. 4513 * 4514 * @param rawValue Pointer into which the value will be set, if found. 4515 * @param key Key under which the value is stored, if present. 4516 * 4517 * @return YES if the key was found and the value was copied, NO otherwise. 4518 **/ 4519 - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(BOOL)key; 4520 4521 /** 4522 * Enumerates the keys and values on this dictionary with the given block. 4523 * 4524 * @note This method bypass the validationFunc to enable the access of values that 4525 * were not known at the time the binary was compiled. 4526 * 4527 * @param block The block to enumerate with. 4528 * **key**: The key for the current entry. 4529 * **rawValue**: The value for the current entry 4530 * **stop**: A pointer to a boolean that when set stops the enumeration. 4531 **/ 4532 - (void)enumerateKeysAndRawValuesUsingBlock: 4533 (void (NS_NOESCAPE ^)(BOOL key, int32_t rawValue, BOOL *stop))block; 4534 4535 /** 4536 * Adds the keys and raw enum values from another dictionary. 4537 * 4538 * @note This method bypass the validationFunc to enable the setting of values that 4539 * were not known at the time the binary was compiled. 4540 * 4541 * @param otherDictionary Dictionary containing entries to be added to this 4542 * dictionary. 4543 **/ 4544 - (void)addRawEntriesFromDictionary:(GPBBoolEnumDictionary *)otherDictionary; 4545 4546 // If value is not a valid enumerator as defined by validationFunc, these 4547 // methods will assert in debug, and will log in release and assign the value 4548 // to the default value. Use the rawValue methods below to assign non enumerator 4549 // values. 4550 4551 /** 4552 * Sets the value for the given key. 4553 * 4554 * @param value The value to set. 4555 * @param key The key under which to store the value. 4556 **/ 4557 - (void)setEnum:(int32_t)value forKey:(BOOL)key; 4558 4559 /** 4560 * Sets the raw enum value for the given key. 4561 * 4562 * @note This method bypass the validationFunc to enable the setting of values that 4563 * were not known at the time the binary was compiled. 4564 * 4565 * @param rawValue The raw enum value to set. 4566 * @param key The key under which to store the raw enum value. 4567 **/ 4568 - (void)setRawValue:(int32_t)rawValue forKey:(BOOL)key; 4569 4570 /** 4571 * Removes the entry for the given key. 4572 * 4573 * @param aKey Key to be removed from this dictionary. 4574 **/ 4575 - (void)removeEnumForKey:(BOOL)aKey; 4576 4577 /** 4578 * Removes all entries in this dictionary. 4579 **/ 4580 - (void)removeAll; 4581 4582 @end 4583 4584 #pragma mark - Bool -> Object 4585 4586 /** 4587 * Class used for map fields of <BOOL, ObjectType> 4588 * values. This performs better than boxing into NSNumbers in NSDictionaries. 4589 * 4590 * @note This class is not meant to be subclassed. 4591 **/ 4592 __attribute__((objc_subclassing_restricted)) 4593 @interface GPBBoolObjectDictionary<__covariant ObjectType> : NSObject <NSCopying> 4594 4595 /** Number of entries stored in this dictionary. */ 4596 @property(nonatomic, readonly) NSUInteger count; 4597 4598 /** 4599 * Initializes this dictionary, copying the given values and keys. 4600 * 4601 * @param objects The values to be placed in this dictionary. 4602 * @param keys The keys under which to store the values. 4603 * @param count The number of elements to copy into the dictionary. 4604 * 4605 * @return A newly initialized dictionary with a copy of the values and keys. 4606 **/ 4607 - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects 4608 forKeys:(const BOOL [__nullable])keys 4609 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 4610 4611 /** 4612 * Initializes this dictionary, copying the entries from the given dictionary. 4613 * 4614 * @param dictionary Dictionary containing the entries to add to this dictionary. 4615 * 4616 * @return A newly initialized dictionary with the entries of the given dictionary. 4617 **/ 4618 - (instancetype)initWithDictionary:(GPBBoolObjectDictionary *)dictionary; 4619 4620 /** 4621 * Initializes this dictionary with the requested capacity. 4622 * 4623 * @param numItems Number of items needed for this dictionary. 4624 * 4625 * @return A newly initialized dictionary with the requested capacity. 4626 **/ 4627 - (instancetype)initWithCapacity:(NSUInteger)numItems; 4628 4629 /** 4630 * Fetches the object stored under the given key. 4631 * 4632 * @param key Key under which the value is stored, if present. 4633 * 4634 * @return The object if found, nil otherwise. 4635 **/ 4636 - (ObjectType)objectForKey:(BOOL)key; 4637 4638 /** 4639 * Enumerates the keys and values on this dictionary with the given block. 4640 * 4641 * @param block The block to enumerate with. 4642 * **key**: The key for the current entry. 4643 * **object**: The value for the current entry 4644 * **stop**: A pointer to a boolean that when set stops the enumeration. 4645 **/ 4646 - (void)enumerateKeysAndObjectsUsingBlock: 4647 (void (NS_NOESCAPE ^)(BOOL key, ObjectType object, BOOL *stop))block; 4648 4649 /** 4650 * Adds the keys and values from another dictionary. 4651 * 4652 * @param otherDictionary Dictionary containing entries to be added to this 4653 * dictionary. 4654 **/ 4655 - (void)addEntriesFromDictionary:(GPBBoolObjectDictionary *)otherDictionary; 4656 4657 /** 4658 * Sets the value for the given key. 4659 * 4660 * @param object The value to set. 4661 * @param key The key under which to store the value. 4662 **/ 4663 - (void)setObject:(ObjectType)object forKey:(BOOL)key; 4664 4665 /** 4666 * Removes the entry for the given key. 4667 * 4668 * @param aKey Key to be removed from this dictionary. 4669 **/ 4670 - (void)removeObjectForKey:(BOOL)aKey; 4671 4672 /** 4673 * Removes all entries in this dictionary. 4674 **/ 4675 - (void)removeAll; 4676 4677 @end 4678 4679 #pragma mark - String -> UInt32 4680 4681 /** 4682 * Class used for map fields of <NSString, uint32_t> 4683 * values. This performs better than boxing into NSNumbers in NSDictionaries. 4684 * 4685 * @note This class is not meant to be subclassed. 4686 **/ 4687 __attribute__((objc_subclassing_restricted)) 4688 @interface GPBStringUInt32Dictionary : NSObject <NSCopying> 4689 4690 /** Number of entries stored in this dictionary. */ 4691 @property(nonatomic, readonly) NSUInteger count; 4692 4693 /** 4694 * Initializes this dictionary, copying the given values and keys. 4695 * 4696 * @param values The values to be placed in this dictionary. 4697 * @param keys The keys under which to store the values. 4698 * @param count The number of elements to copy into the dictionary. 4699 * 4700 * @return A newly initialized dictionary with a copy of the values and keys. 4701 **/ 4702 - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values 4703 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys 4704 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 4705 4706 /** 4707 * Initializes this dictionary, copying the entries from the given dictionary. 4708 * 4709 * @param dictionary Dictionary containing the entries to add to this dictionary. 4710 * 4711 * @return A newly initialized dictionary with the entries of the given dictionary. 4712 **/ 4713 - (instancetype)initWithDictionary:(GPBStringUInt32Dictionary *)dictionary; 4714 4715 /** 4716 * Initializes this dictionary with the requested capacity. 4717 * 4718 * @param numItems Number of items needed for this dictionary. 4719 * 4720 * @return A newly initialized dictionary with the requested capacity. 4721 **/ 4722 - (instancetype)initWithCapacity:(NSUInteger)numItems; 4723 4724 /** 4725 * Gets the value for the given key. 4726 * 4727 * @param value Pointer into which the value will be set, if found. 4728 * @param key Key under which the value is stored, if present. 4729 * 4730 * @return YES if the key was found and the value was copied, NO otherwise. 4731 **/ 4732 - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(NSString *)key; 4733 4734 /** 4735 * Enumerates the keys and values on this dictionary with the given block. 4736 * 4737 * @param block The block to enumerate with. 4738 * **key**: The key for the current entry. 4739 * **value**: The value for the current entry 4740 * **stop**: A pointer to a boolean that when set stops the enumeration. 4741 **/ 4742 - (void)enumerateKeysAndUInt32sUsingBlock: 4743 (void (NS_NOESCAPE ^)(NSString *key, uint32_t value, BOOL *stop))block; 4744 4745 /** 4746 * Adds the keys and values from another dictionary. 4747 * 4748 * @param otherDictionary Dictionary containing entries to be added to this 4749 * dictionary. 4750 **/ 4751 - (void)addEntriesFromDictionary:(GPBStringUInt32Dictionary *)otherDictionary; 4752 4753 /** 4754 * Sets the value for the given key. 4755 * 4756 * @param value The value to set. 4757 * @param key The key under which to store the value. 4758 **/ 4759 - (void)setUInt32:(uint32_t)value forKey:(NSString *)key; 4760 4761 /** 4762 * Removes the entry for the given key. 4763 * 4764 * @param aKey Key to be removed from this dictionary. 4765 **/ 4766 - (void)removeUInt32ForKey:(NSString *)aKey; 4767 4768 /** 4769 * Removes all entries in this dictionary. 4770 **/ 4771 - (void)removeAll; 4772 4773 @end 4774 4775 #pragma mark - String -> Int32 4776 4777 /** 4778 * Class used for map fields of <NSString, int32_t> 4779 * values. This performs better than boxing into NSNumbers in NSDictionaries. 4780 * 4781 * @note This class is not meant to be subclassed. 4782 **/ 4783 __attribute__((objc_subclassing_restricted)) 4784 @interface GPBStringInt32Dictionary : NSObject <NSCopying> 4785 4786 /** Number of entries stored in this dictionary. */ 4787 @property(nonatomic, readonly) NSUInteger count; 4788 4789 /** 4790 * Initializes this dictionary, copying the given values and keys. 4791 * 4792 * @param values The values to be placed in this dictionary. 4793 * @param keys The keys under which to store the values. 4794 * @param count The number of elements to copy into the dictionary. 4795 * 4796 * @return A newly initialized dictionary with a copy of the values and keys. 4797 **/ 4798 - (instancetype)initWithInt32s:(const int32_t [__nullable])values 4799 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys 4800 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 4801 4802 /** 4803 * Initializes this dictionary, copying the entries from the given dictionary. 4804 * 4805 * @param dictionary Dictionary containing the entries to add to this dictionary. 4806 * 4807 * @return A newly initialized dictionary with the entries of the given dictionary. 4808 **/ 4809 - (instancetype)initWithDictionary:(GPBStringInt32Dictionary *)dictionary; 4810 4811 /** 4812 * Initializes this dictionary with the requested capacity. 4813 * 4814 * @param numItems Number of items needed for this dictionary. 4815 * 4816 * @return A newly initialized dictionary with the requested capacity. 4817 **/ 4818 - (instancetype)initWithCapacity:(NSUInteger)numItems; 4819 4820 /** 4821 * Gets the value for the given key. 4822 * 4823 * @param value Pointer into which the value will be set, if found. 4824 * @param key Key under which the value is stored, if present. 4825 * 4826 * @return YES if the key was found and the value was copied, NO otherwise. 4827 **/ 4828 - (BOOL)getInt32:(nullable int32_t *)value forKey:(NSString *)key; 4829 4830 /** 4831 * Enumerates the keys and values on this dictionary with the given block. 4832 * 4833 * @param block The block to enumerate with. 4834 * **key**: The key for the current entry. 4835 * **value**: The value for the current entry 4836 * **stop**: A pointer to a boolean that when set stops the enumeration. 4837 **/ 4838 - (void)enumerateKeysAndInt32sUsingBlock: 4839 (void (NS_NOESCAPE ^)(NSString *key, int32_t value, BOOL *stop))block; 4840 4841 /** 4842 * Adds the keys and values from another dictionary. 4843 * 4844 * @param otherDictionary Dictionary containing entries to be added to this 4845 * dictionary. 4846 **/ 4847 - (void)addEntriesFromDictionary:(GPBStringInt32Dictionary *)otherDictionary; 4848 4849 /** 4850 * Sets the value for the given key. 4851 * 4852 * @param value The value to set. 4853 * @param key The key under which to store the value. 4854 **/ 4855 - (void)setInt32:(int32_t)value forKey:(NSString *)key; 4856 4857 /** 4858 * Removes the entry for the given key. 4859 * 4860 * @param aKey Key to be removed from this dictionary. 4861 **/ 4862 - (void)removeInt32ForKey:(NSString *)aKey; 4863 4864 /** 4865 * Removes all entries in this dictionary. 4866 **/ 4867 - (void)removeAll; 4868 4869 @end 4870 4871 #pragma mark - String -> UInt64 4872 4873 /** 4874 * Class used for map fields of <NSString, uint64_t> 4875 * values. This performs better than boxing into NSNumbers in NSDictionaries. 4876 * 4877 * @note This class is not meant to be subclassed. 4878 **/ 4879 __attribute__((objc_subclassing_restricted)) 4880 @interface GPBStringUInt64Dictionary : NSObject <NSCopying> 4881 4882 /** Number of entries stored in this dictionary. */ 4883 @property(nonatomic, readonly) NSUInteger count; 4884 4885 /** 4886 * Initializes this dictionary, copying the given values and keys. 4887 * 4888 * @param values The values to be placed in this dictionary. 4889 * @param keys The keys under which to store the values. 4890 * @param count The number of elements to copy into the dictionary. 4891 * 4892 * @return A newly initialized dictionary with a copy of the values and keys. 4893 **/ 4894 - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values 4895 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys 4896 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 4897 4898 /** 4899 * Initializes this dictionary, copying the entries from the given dictionary. 4900 * 4901 * @param dictionary Dictionary containing the entries to add to this dictionary. 4902 * 4903 * @return A newly initialized dictionary with the entries of the given dictionary. 4904 **/ 4905 - (instancetype)initWithDictionary:(GPBStringUInt64Dictionary *)dictionary; 4906 4907 /** 4908 * Initializes this dictionary with the requested capacity. 4909 * 4910 * @param numItems Number of items needed for this dictionary. 4911 * 4912 * @return A newly initialized dictionary with the requested capacity. 4913 **/ 4914 - (instancetype)initWithCapacity:(NSUInteger)numItems; 4915 4916 /** 4917 * Gets the value for the given key. 4918 * 4919 * @param value Pointer into which the value will be set, if found. 4920 * @param key Key under which the value is stored, if present. 4921 * 4922 * @return YES if the key was found and the value was copied, NO otherwise. 4923 **/ 4924 - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(NSString *)key; 4925 4926 /** 4927 * Enumerates the keys and values on this dictionary with the given block. 4928 * 4929 * @param block The block to enumerate with. 4930 * **key**: The key for the current entry. 4931 * **value**: The value for the current entry 4932 * **stop**: A pointer to a boolean that when set stops the enumeration. 4933 **/ 4934 - (void)enumerateKeysAndUInt64sUsingBlock: 4935 (void (NS_NOESCAPE ^)(NSString *key, uint64_t value, BOOL *stop))block; 4936 4937 /** 4938 * Adds the keys and values from another dictionary. 4939 * 4940 * @param otherDictionary Dictionary containing entries to be added to this 4941 * dictionary. 4942 **/ 4943 - (void)addEntriesFromDictionary:(GPBStringUInt64Dictionary *)otherDictionary; 4944 4945 /** 4946 * Sets the value for the given key. 4947 * 4948 * @param value The value to set. 4949 * @param key The key under which to store the value. 4950 **/ 4951 - (void)setUInt64:(uint64_t)value forKey:(NSString *)key; 4952 4953 /** 4954 * Removes the entry for the given key. 4955 * 4956 * @param aKey Key to be removed from this dictionary. 4957 **/ 4958 - (void)removeUInt64ForKey:(NSString *)aKey; 4959 4960 /** 4961 * Removes all entries in this dictionary. 4962 **/ 4963 - (void)removeAll; 4964 4965 @end 4966 4967 #pragma mark - String -> Int64 4968 4969 /** 4970 * Class used for map fields of <NSString, int64_t> 4971 * values. This performs better than boxing into NSNumbers in NSDictionaries. 4972 * 4973 * @note This class is not meant to be subclassed. 4974 **/ 4975 __attribute__((objc_subclassing_restricted)) 4976 @interface GPBStringInt64Dictionary : NSObject <NSCopying> 4977 4978 /** Number of entries stored in this dictionary. */ 4979 @property(nonatomic, readonly) NSUInteger count; 4980 4981 /** 4982 * Initializes this dictionary, copying the given values and keys. 4983 * 4984 * @param values The values to be placed in this dictionary. 4985 * @param keys The keys under which to store the values. 4986 * @param count The number of elements to copy into the dictionary. 4987 * 4988 * @return A newly initialized dictionary with a copy of the values and keys. 4989 **/ 4990 - (instancetype)initWithInt64s:(const int64_t [__nullable])values 4991 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys 4992 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 4993 4994 /** 4995 * Initializes this dictionary, copying the entries from the given dictionary. 4996 * 4997 * @param dictionary Dictionary containing the entries to add to this dictionary. 4998 * 4999 * @return A newly initialized dictionary with the entries of the given dictionary. 5000 **/ 5001 - (instancetype)initWithDictionary:(GPBStringInt64Dictionary *)dictionary; 5002 5003 /** 5004 * Initializes this dictionary with the requested capacity. 5005 * 5006 * @param numItems Number of items needed for this dictionary. 5007 * 5008 * @return A newly initialized dictionary with the requested capacity. 5009 **/ 5010 - (instancetype)initWithCapacity:(NSUInteger)numItems; 5011 5012 /** 5013 * Gets the value for the given key. 5014 * 5015 * @param value Pointer into which the value will be set, if found. 5016 * @param key Key under which the value is stored, if present. 5017 * 5018 * @return YES if the key was found and the value was copied, NO otherwise. 5019 **/ 5020 - (BOOL)getInt64:(nullable int64_t *)value forKey:(NSString *)key; 5021 5022 /** 5023 * Enumerates the keys and values on this dictionary with the given block. 5024 * 5025 * @param block The block to enumerate with. 5026 * **key**: The key for the current entry. 5027 * **value**: The value for the current entry 5028 * **stop**: A pointer to a boolean that when set stops the enumeration. 5029 **/ 5030 - (void)enumerateKeysAndInt64sUsingBlock: 5031 (void (NS_NOESCAPE ^)(NSString *key, int64_t value, BOOL *stop))block; 5032 5033 /** 5034 * Adds the keys and values from another dictionary. 5035 * 5036 * @param otherDictionary Dictionary containing entries to be added to this 5037 * dictionary. 5038 **/ 5039 - (void)addEntriesFromDictionary:(GPBStringInt64Dictionary *)otherDictionary; 5040 5041 /** 5042 * Sets the value for the given key. 5043 * 5044 * @param value The value to set. 5045 * @param key The key under which to store the value. 5046 **/ 5047 - (void)setInt64:(int64_t)value forKey:(NSString *)key; 5048 5049 /** 5050 * Removes the entry for the given key. 5051 * 5052 * @param aKey Key to be removed from this dictionary. 5053 **/ 5054 - (void)removeInt64ForKey:(NSString *)aKey; 5055 5056 /** 5057 * Removes all entries in this dictionary. 5058 **/ 5059 - (void)removeAll; 5060 5061 @end 5062 5063 #pragma mark - String -> Bool 5064 5065 /** 5066 * Class used for map fields of <NSString, BOOL> 5067 * values. This performs better than boxing into NSNumbers in NSDictionaries. 5068 * 5069 * @note This class is not meant to be subclassed. 5070 **/ 5071 __attribute__((objc_subclassing_restricted)) 5072 @interface GPBStringBoolDictionary : NSObject <NSCopying> 5073 5074 /** Number of entries stored in this dictionary. */ 5075 @property(nonatomic, readonly) NSUInteger count; 5076 5077 /** 5078 * Initializes this dictionary, copying the given values and keys. 5079 * 5080 * @param values The values to be placed in this dictionary. 5081 * @param keys The keys under which to store the values. 5082 * @param count The number of elements to copy into the dictionary. 5083 * 5084 * @return A newly initialized dictionary with a copy of the values and keys. 5085 **/ 5086 - (instancetype)initWithBools:(const BOOL [__nullable])values 5087 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys 5088 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 5089 5090 /** 5091 * Initializes this dictionary, copying the entries from the given dictionary. 5092 * 5093 * @param dictionary Dictionary containing the entries to add to this dictionary. 5094 * 5095 * @return A newly initialized dictionary with the entries of the given dictionary. 5096 **/ 5097 - (instancetype)initWithDictionary:(GPBStringBoolDictionary *)dictionary; 5098 5099 /** 5100 * Initializes this dictionary with the requested capacity. 5101 * 5102 * @param numItems Number of items needed for this dictionary. 5103 * 5104 * @return A newly initialized dictionary with the requested capacity. 5105 **/ 5106 - (instancetype)initWithCapacity:(NSUInteger)numItems; 5107 5108 /** 5109 * Gets the value for the given key. 5110 * 5111 * @param value Pointer into which the value will be set, if found. 5112 * @param key Key under which the value is stored, if present. 5113 * 5114 * @return YES if the key was found and the value was copied, NO otherwise. 5115 **/ 5116 - (BOOL)getBool:(nullable BOOL *)value forKey:(NSString *)key; 5117 5118 /** 5119 * Enumerates the keys and values on this dictionary with the given block. 5120 * 5121 * @param block The block to enumerate with. 5122 * **key**: The key for the current entry. 5123 * **value**: The value for the current entry 5124 * **stop**: A pointer to a boolean that when set stops the enumeration. 5125 **/ 5126 - (void)enumerateKeysAndBoolsUsingBlock: 5127 (void (NS_NOESCAPE ^)(NSString *key, BOOL value, BOOL *stop))block; 5128 5129 /** 5130 * Adds the keys and values from another dictionary. 5131 * 5132 * @param otherDictionary Dictionary containing entries to be added to this 5133 * dictionary. 5134 **/ 5135 - (void)addEntriesFromDictionary:(GPBStringBoolDictionary *)otherDictionary; 5136 5137 /** 5138 * Sets the value for the given key. 5139 * 5140 * @param value The value to set. 5141 * @param key The key under which to store the value. 5142 **/ 5143 - (void)setBool:(BOOL)value forKey:(NSString *)key; 5144 5145 /** 5146 * Removes the entry for the given key. 5147 * 5148 * @param aKey Key to be removed from this dictionary. 5149 **/ 5150 - (void)removeBoolForKey:(NSString *)aKey; 5151 5152 /** 5153 * Removes all entries in this dictionary. 5154 **/ 5155 - (void)removeAll; 5156 5157 @end 5158 5159 #pragma mark - String -> Float 5160 5161 /** 5162 * Class used for map fields of <NSString, float> 5163 * values. This performs better than boxing into NSNumbers in NSDictionaries. 5164 * 5165 * @note This class is not meant to be subclassed. 5166 **/ 5167 __attribute__((objc_subclassing_restricted)) 5168 @interface GPBStringFloatDictionary : NSObject <NSCopying> 5169 5170 /** Number of entries stored in this dictionary. */ 5171 @property(nonatomic, readonly) NSUInteger count; 5172 5173 /** 5174 * Initializes this dictionary, copying the given values and keys. 5175 * 5176 * @param values The values to be placed in this dictionary. 5177 * @param keys The keys under which to store the values. 5178 * @param count The number of elements to copy into the dictionary. 5179 * 5180 * @return A newly initialized dictionary with a copy of the values and keys. 5181 **/ 5182 - (instancetype)initWithFloats:(const float [__nullable])values 5183 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys 5184 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 5185 5186 /** 5187 * Initializes this dictionary, copying the entries from the given dictionary. 5188 * 5189 * @param dictionary Dictionary containing the entries to add to this dictionary. 5190 * 5191 * @return A newly initialized dictionary with the entries of the given dictionary. 5192 **/ 5193 - (instancetype)initWithDictionary:(GPBStringFloatDictionary *)dictionary; 5194 5195 /** 5196 * Initializes this dictionary with the requested capacity. 5197 * 5198 * @param numItems Number of items needed for this dictionary. 5199 * 5200 * @return A newly initialized dictionary with the requested capacity. 5201 **/ 5202 - (instancetype)initWithCapacity:(NSUInteger)numItems; 5203 5204 /** 5205 * Gets the value for the given key. 5206 * 5207 * @param value Pointer into which the value will be set, if found. 5208 * @param key Key under which the value is stored, if present. 5209 * 5210 * @return YES if the key was found and the value was copied, NO otherwise. 5211 **/ 5212 - (BOOL)getFloat:(nullable float *)value forKey:(NSString *)key; 5213 5214 /** 5215 * Enumerates the keys and values on this dictionary with the given block. 5216 * 5217 * @param block The block to enumerate with. 5218 * **key**: The key for the current entry. 5219 * **value**: The value for the current entry 5220 * **stop**: A pointer to a boolean that when set stops the enumeration. 5221 **/ 5222 - (void)enumerateKeysAndFloatsUsingBlock: 5223 (void (NS_NOESCAPE ^)(NSString *key, float value, BOOL *stop))block; 5224 5225 /** 5226 * Adds the keys and values from another dictionary. 5227 * 5228 * @param otherDictionary Dictionary containing entries to be added to this 5229 * dictionary. 5230 **/ 5231 - (void)addEntriesFromDictionary:(GPBStringFloatDictionary *)otherDictionary; 5232 5233 /** 5234 * Sets the value for the given key. 5235 * 5236 * @param value The value to set. 5237 * @param key The key under which to store the value. 5238 **/ 5239 - (void)setFloat:(float)value forKey:(NSString *)key; 5240 5241 /** 5242 * Removes the entry for the given key. 5243 * 5244 * @param aKey Key to be removed from this dictionary. 5245 **/ 5246 - (void)removeFloatForKey:(NSString *)aKey; 5247 5248 /** 5249 * Removes all entries in this dictionary. 5250 **/ 5251 - (void)removeAll; 5252 5253 @end 5254 5255 #pragma mark - String -> Double 5256 5257 /** 5258 * Class used for map fields of <NSString, double> 5259 * values. This performs better than boxing into NSNumbers in NSDictionaries. 5260 * 5261 * @note This class is not meant to be subclassed. 5262 **/ 5263 __attribute__((objc_subclassing_restricted)) 5264 @interface GPBStringDoubleDictionary : NSObject <NSCopying> 5265 5266 /** Number of entries stored in this dictionary. */ 5267 @property(nonatomic, readonly) NSUInteger count; 5268 5269 /** 5270 * Initializes this dictionary, copying the given values and keys. 5271 * 5272 * @param values The values to be placed in this dictionary. 5273 * @param keys The keys under which to store the values. 5274 * @param count The number of elements to copy into the dictionary. 5275 * 5276 * @return A newly initialized dictionary with a copy of the values and keys. 5277 **/ 5278 - (instancetype)initWithDoubles:(const double [__nullable])values 5279 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys 5280 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 5281 5282 /** 5283 * Initializes this dictionary, copying the entries from the given dictionary. 5284 * 5285 * @param dictionary Dictionary containing the entries to add to this dictionary. 5286 * 5287 * @return A newly initialized dictionary with the entries of the given dictionary. 5288 **/ 5289 - (instancetype)initWithDictionary:(GPBStringDoubleDictionary *)dictionary; 5290 5291 /** 5292 * Initializes this dictionary with the requested capacity. 5293 * 5294 * @param numItems Number of items needed for this dictionary. 5295 * 5296 * @return A newly initialized dictionary with the requested capacity. 5297 **/ 5298 - (instancetype)initWithCapacity:(NSUInteger)numItems; 5299 5300 /** 5301 * Gets the value for the given key. 5302 * 5303 * @param value Pointer into which the value will be set, if found. 5304 * @param key Key under which the value is stored, if present. 5305 * 5306 * @return YES if the key was found and the value was copied, NO otherwise. 5307 **/ 5308 - (BOOL)getDouble:(nullable double *)value forKey:(NSString *)key; 5309 5310 /** 5311 * Enumerates the keys and values on this dictionary with the given block. 5312 * 5313 * @param block The block to enumerate with. 5314 * **key**: The key for the current entry. 5315 * **value**: The value for the current entry 5316 * **stop**: A pointer to a boolean that when set stops the enumeration. 5317 **/ 5318 - (void)enumerateKeysAndDoublesUsingBlock: 5319 (void (NS_NOESCAPE ^)(NSString *key, double value, BOOL *stop))block; 5320 5321 /** 5322 * Adds the keys and values from another dictionary. 5323 * 5324 * @param otherDictionary Dictionary containing entries to be added to this 5325 * dictionary. 5326 **/ 5327 - (void)addEntriesFromDictionary:(GPBStringDoubleDictionary *)otherDictionary; 5328 5329 /** 5330 * Sets the value for the given key. 5331 * 5332 * @param value The value to set. 5333 * @param key The key under which to store the value. 5334 **/ 5335 - (void)setDouble:(double)value forKey:(NSString *)key; 5336 5337 /** 5338 * Removes the entry for the given key. 5339 * 5340 * @param aKey Key to be removed from this dictionary. 5341 **/ 5342 - (void)removeDoubleForKey:(NSString *)aKey; 5343 5344 /** 5345 * Removes all entries in this dictionary. 5346 **/ 5347 - (void)removeAll; 5348 5349 @end 5350 5351 #pragma mark - String -> Enum 5352 5353 /** 5354 * Class used for map fields of <NSString, int32_t> 5355 * values. This performs better than boxing into NSNumbers in NSDictionaries. 5356 * 5357 * @note This class is not meant to be subclassed. 5358 **/ 5359 __attribute__((objc_subclassing_restricted)) 5360 @interface GPBStringEnumDictionary : NSObject <NSCopying> 5361 5362 /** Number of entries stored in this dictionary. */ 5363 @property(nonatomic, readonly) NSUInteger count; 5364 /** The validation function to check if the enums are valid. */ 5365 @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; 5366 5367 /** 5368 * Initializes a dictionary with the given validation function. 5369 * 5370 * @param func The enum validation function for the dictionary. 5371 * 5372 * @return A newly initialized dictionary. 5373 **/ 5374 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; 5375 5376 /** 5377 * Initializes a dictionary with the entries given. 5378 * 5379 * @param func The enum validation function for the dictionary. 5380 * @param values The raw enum values values to be placed in the dictionary. 5381 * @param keys The keys under which to store the values. 5382 * @param count The number of entries to store in the dictionary. 5383 * 5384 * @return A newly initialized dictionary with the keys and values in it. 5385 **/ 5386 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 5387 rawValues:(const int32_t [__nullable])values 5388 forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys 5389 count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 5390 5391 /** 5392 * Initializes a dictionary with the entries from the given. 5393 * dictionary. 5394 * 5395 * @param dictionary Dictionary containing the entries to add to the dictionary. 5396 * 5397 * @return A newly initialized dictionary with the entries from the given 5398 * dictionary in it. 5399 **/ 5400 - (instancetype)initWithDictionary:(GPBStringEnumDictionary *)dictionary; 5401 5402 /** 5403 * Initializes a dictionary with the given capacity. 5404 * 5405 * @param func The enum validation function for the dictionary. 5406 * @param numItems Capacity needed for the dictionary. 5407 * 5408 * @return A newly initialized dictionary with the given capacity. 5409 **/ 5410 - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 5411 capacity:(NSUInteger)numItems; 5412 5413 // These will return kGPBUnrecognizedEnumeratorValue if the value for the key 5414 // is not a valid enumerator as defined by validationFunc. If the actual value is 5415 // desired, use "raw" version of the method. 5416 5417 /** 5418 * Gets the value for the given key. 5419 * 5420 * @param value Pointer into which the value will be set, if found. 5421 * @param key Key under which the value is stored, if present. 5422 * 5423 * @return YES if the key was found and the value was copied, NO otherwise. 5424 **/ 5425 - (BOOL)getEnum:(nullable int32_t *)value forKey:(NSString *)key; 5426 5427 /** 5428 * Enumerates the keys and values on this dictionary with the given block. 5429 * 5430 * @param block The block to enumerate with. 5431 * **key**: The key for the current entry. 5432 * **value**: The value for the current entry 5433 * **stop**: A pointer to a boolean that when set stops the enumeration. 5434 **/ 5435 - (void)enumerateKeysAndEnumsUsingBlock: 5436 (void (NS_NOESCAPE ^)(NSString *key, int32_t value, BOOL *stop))block; 5437 5438 /** 5439 * Gets the raw enum value for the given key. 5440 * 5441 * @note This method bypass the validationFunc to enable the access of values that 5442 * were not known at the time the binary was compiled. 5443 * 5444 * @param rawValue Pointer into which the value will be set, if found. 5445 * @param key Key under which the value is stored, if present. 5446 * 5447 * @return YES if the key was found and the value was copied, NO otherwise. 5448 **/ 5449 - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(NSString *)key; 5450 5451 /** 5452 * Enumerates the keys and values on this dictionary with the given block. 5453 * 5454 * @note This method bypass the validationFunc to enable the access of values that 5455 * were not known at the time the binary was compiled. 5456 * 5457 * @param block The block to enumerate with. 5458 * **key**: The key for the current entry. 5459 * **rawValue**: The value for the current entry 5460 * **stop**: A pointer to a boolean that when set stops the enumeration. 5461 **/ 5462 - (void)enumerateKeysAndRawValuesUsingBlock: 5463 (void (NS_NOESCAPE ^)(NSString *key, int32_t rawValue, BOOL *stop))block; 5464 5465 /** 5466 * Adds the keys and raw enum values from another dictionary. 5467 * 5468 * @note This method bypass the validationFunc to enable the setting of values that 5469 * were not known at the time the binary was compiled. 5470 * 5471 * @param otherDictionary Dictionary containing entries to be added to this 5472 * dictionary. 5473 **/ 5474 - (void)addRawEntriesFromDictionary:(GPBStringEnumDictionary *)otherDictionary; 5475 5476 // If value is not a valid enumerator as defined by validationFunc, these 5477 // methods will assert in debug, and will log in release and assign the value 5478 // to the default value. Use the rawValue methods below to assign non enumerator 5479 // values. 5480 5481 /** 5482 * Sets the value for the given key. 5483 * 5484 * @param value The value to set. 5485 * @param key The key under which to store the value. 5486 **/ 5487 - (void)setEnum:(int32_t)value forKey:(NSString *)key; 5488 5489 /** 5490 * Sets the raw enum value for the given key. 5491 * 5492 * @note This method bypass the validationFunc to enable the setting of values that 5493 * were not known at the time the binary was compiled. 5494 * 5495 * @param rawValue The raw enum value to set. 5496 * @param key The key under which to store the raw enum value. 5497 **/ 5498 - (void)setRawValue:(int32_t)rawValue forKey:(NSString *)key; 5499 5500 /** 5501 * Removes the entry for the given key. 5502 * 5503 * @param aKey Key to be removed from this dictionary. 5504 **/ 5505 - (void)removeEnumForKey:(NSString *)aKey; 5506 5507 /** 5508 * Removes all entries in this dictionary. 5509 **/ 5510 - (void)removeAll; 5511 5512 @end 5513 5514 //%PDDM-EXPAND-END DECLARE_DICTIONARIES() 5515 5516 NS_ASSUME_NONNULL_END 5517 5518 //%PDDM-DEFINE DECLARE_DICTIONARIES() 5519 //%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt32, uint32_t) 5520 //%DICTIONARY_INTERFACES_FOR_POD_KEY(Int32, int32_t) 5521 //%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt64, uint64_t) 5522 //%DICTIONARY_INTERFACES_FOR_POD_KEY(Int64, int64_t) 5523 //%DICTIONARY_INTERFACES_FOR_POD_KEY(Bool, BOOL) 5524 //%DICTIONARY_POD_INTERFACES_FOR_KEY(String, NSString, *, OBJECT) 5525 //%PDDM-DEFINE DICTIONARY_INTERFACES_FOR_POD_KEY(KEY_NAME, KEY_TYPE) 5526 //%DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, , POD) 5527 //%DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, Object, ObjectType) 5528 //%PDDM-DEFINE DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, KisP, KHELPER) 5529 //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt32, uint32_t) 5530 //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int32, int32_t) 5531 //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt64, uint64_t) 5532 //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int64, int64_t) 5533 //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Bool, BOOL) 5534 //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Float, float) 5535 //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Double, double) 5536 //%DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Enum, int32_t) 5537 //%PDDM-DEFINE DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE) 5538 //%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, POD, VALUE_NAME, value) 5539 //%PDDM-DEFINE DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, VALUE_NAME, VALUE_TYPE) 5540 //%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, , POD, VALUE_NAME, VALUE_TYPE, OBJECT, Object, object) 5541 //%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME) 5542 //%/** 5543 //% * Gets the value for the given key. 5544 //% * 5545 //% * @param value Pointer into which the value will be set, if found. 5546 //% * @param key Key under which the value is stored, if present. 5547 //% * 5548 //% * @return YES if the key was found and the value was copied, NO otherwise. 5549 //% **/ 5550 //%- (BOOL)get##VNAME##:(nullable VALUE_TYPE *)value forKey:(KEY_TYPE)key; 5551 //%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_TYPE, VNAME) 5552 //%/** 5553 //% * Fetches the object stored under the given key. 5554 //% * 5555 //% * @param key Key under which the value is stored, if present. 5556 //% * 5557 //% * @return The object if found, nil otherwise. 5558 //% **/ 5559 //%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key; 5560 //%PDDM-DEFINE VALUE_FOR_KEY_Enum(KEY_TYPE, VALUE_TYPE, VNAME) 5561 //%VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME) 5562 //%PDDM-DEFINE ARRAY_ARG_MODIFIERPOD() 5563 // Nothing 5564 //%PDDM-DEFINE ARRAY_ARG_MODIFIEREnum() 5565 // Nothing 5566 //%PDDM-DEFINE ARRAY_ARG_MODIFIEROBJECT() 5567 //%__nonnull GPB_UNSAFE_UNRETAINED ## 5568 //%PDDM-DEFINE DICTIONARY_CLASS_DECLPOD(KEY_NAME, VALUE_NAME, VALUE_TYPE) 5569 //%GPB##KEY_NAME##VALUE_NAME##Dictionary 5570 //%PDDM-DEFINE DICTIONARY_CLASS_DECLEnum(KEY_NAME, VALUE_NAME, VALUE_TYPE) 5571 //%GPB##KEY_NAME##VALUE_NAME##Dictionary 5572 //%PDDM-DEFINE DICTIONARY_CLASS_DECLOBJECT(KEY_NAME, VALUE_NAME, VALUE_TYPE) 5573 //%GPB##KEY_NAME##VALUE_NAME##Dictionary<__covariant VALUE_TYPE> 5574 //%PDDM-DEFINE DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) 5575 //%#pragma mark - KEY_NAME -> VALUE_NAME 5576 //% 5577 //%/** 5578 //% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##> 5579 //% * values. This performs better than boxing into NSNumbers in NSDictionaries. 5580 //% * 5581 //% * @note This class is not meant to be subclassed. 5582 //% **/ 5583 //%__attribute__((objc_subclassing_restricted)) 5584 //%@interface DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) : NSObject <NSCopying> 5585 //% 5586 //%/** Number of entries stored in this dictionary. */ 5587 //%@property(nonatomic, readonly) NSUInteger count; 5588 //% 5589 //%/** 5590 //% * Initializes this dictionary, copying the given values and keys. 5591 //% * 5592 //% * @param ##VNAME_VAR##s The values to be placed in this dictionary. 5593 //% * @param keys ##VNAME_VAR$S## The keys under which to store the values. 5594 //% * @param count ##VNAME_VAR$S## The number of elements to copy into the dictionary. 5595 //% * 5596 //% * @return A newly initialized dictionary with a copy of the values and keys. 5597 //% **/ 5598 //%- (instancetype)initWith##VNAME##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])##VNAME_VAR##s 5599 //% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys 5600 //% ##VNAME$S## count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 5601 //% 5602 //%/** 5603 //% * Initializes this dictionary, copying the entries from the given dictionary. 5604 //% * 5605 //% * @param dictionary Dictionary containing the entries to add to this dictionary. 5606 //% * 5607 //% * @return A newly initialized dictionary with the entries of the given dictionary. 5608 //% **/ 5609 //%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary; 5610 //% 5611 //%/** 5612 //% * Initializes this dictionary with the requested capacity. 5613 //% * 5614 //% * @param numItems Number of items needed for this dictionary. 5615 //% * 5616 //% * @return A newly initialized dictionary with the requested capacity. 5617 //% **/ 5618 //%- (instancetype)initWithCapacity:(NSUInteger)numItems; 5619 //% 5620 //%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) 5621 //% 5622 //%/** 5623 //% * Adds the keys and values from another dictionary. 5624 //% * 5625 //% * @param otherDictionary Dictionary containing entries to be added to this 5626 //% * dictionary. 5627 //% **/ 5628 //%- (void)addEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary; 5629 //% 5630 //%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) 5631 //% 5632 //%@end 5633 //% 5634 5635 //%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE) 5636 //%DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, Enum) 5637 //%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER) 5638 //%#pragma mark - KEY_NAME -> VALUE_NAME 5639 //% 5640 //%/** 5641 //% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##> 5642 //% * values. This performs better than boxing into NSNumbers in NSDictionaries. 5643 //% * 5644 //% * @note This class is not meant to be subclassed. 5645 //% **/ 5646 //%__attribute__((objc_subclassing_restricted)) 5647 //%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject <NSCopying> 5648 //% 5649 //%/** Number of entries stored in this dictionary. */ 5650 //%@property(nonatomic, readonly) NSUInteger count; 5651 //%/** The validation function to check if the enums are valid. */ 5652 //%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; 5653 //% 5654 //%/** 5655 //% * Initializes a dictionary with the given validation function. 5656 //% * 5657 //% * @param func The enum validation function for the dictionary. 5658 //% * 5659 //% * @return A newly initialized dictionary. 5660 //% **/ 5661 //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; 5662 //% 5663 //%/** 5664 //% * Initializes a dictionary with the entries given. 5665 //% * 5666 //% * @param func The enum validation function for the dictionary. 5667 //% * @param values The raw enum values values to be placed in the dictionary. 5668 //% * @param keys The keys under which to store the values. 5669 //% * @param count The number of entries to store in the dictionary. 5670 //% * 5671 //% * @return A newly initialized dictionary with the keys and values in it. 5672 //% **/ 5673 //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 5674 //% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])values 5675 //% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys 5676 //% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; 5677 //% 5678 //%/** 5679 //% * Initializes a dictionary with the entries from the given. 5680 //% * dictionary. 5681 //% * 5682 //% * @param dictionary Dictionary containing the entries to add to the dictionary. 5683 //% * 5684 //% * @return A newly initialized dictionary with the entries from the given 5685 //% * dictionary in it. 5686 //% **/ 5687 //%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary; 5688 //% 5689 //%/** 5690 //% * Initializes a dictionary with the given capacity. 5691 //% * 5692 //% * @param func The enum validation function for the dictionary. 5693 //% * @param numItems Capacity needed for the dictionary. 5694 //% * 5695 //% * @return A newly initialized dictionary with the given capacity. 5696 //% **/ 5697 //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func 5698 //% capacity:(NSUInteger)numItems; 5699 //% 5700 //%// These will return kGPBUnrecognizedEnumeratorValue if the value for the key 5701 //%// is not a valid enumerator as defined by validationFunc. If the actual value is 5702 //%// desired, use "raw" version of the method. 5703 //% 5704 //%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value) 5705 //% 5706 //%/** 5707 //% * Gets the raw enum value for the given key. 5708 //% * 5709 //% * @note This method bypass the validationFunc to enable the access of values that 5710 //% * were not known at the time the binary was compiled. 5711 //% * 5712 //% * @param rawValue Pointer into which the value will be set, if found. 5713 //% * @param key Key under which the value is stored, if present. 5714 //% * 5715 //% * @return YES if the key was found and the value was copied, NO otherwise. 5716 //% **/ 5717 //%- (BOOL)getRawValue:(nullable VALUE_TYPE *)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key; 5718 //% 5719 //%/** 5720 //% * Enumerates the keys and values on this dictionary with the given block. 5721 //% * 5722 //% * @note This method bypass the validationFunc to enable the access of values that 5723 //% * were not known at the time the binary was compiled. 5724 //% * 5725 //% * @param block The block to enumerate with. 5726 //% * **key**: The key for the current entry. 5727 //% * **rawValue**: The value for the current entry 5728 //% * **stop**: A pointer to a boolean that when set stops the enumeration. 5729 //% **/ 5730 //%- (void)enumerateKeysAndRawValuesUsingBlock: 5731 //% (void (NS_NOESCAPE ^)(KEY_TYPE KisP##key, VALUE_TYPE rawValue, BOOL *stop))block; 5732 //% 5733 //%/** 5734 //% * Adds the keys and raw enum values from another dictionary. 5735 //% * 5736 //% * @note This method bypass the validationFunc to enable the setting of values that 5737 //% * were not known at the time the binary was compiled. 5738 //% * 5739 //% * @param otherDictionary Dictionary containing entries to be added to this 5740 //% * dictionary. 5741 //% **/ 5742 //%- (void)addRawEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary; 5743 //% 5744 //%// If value is not a valid enumerator as defined by validationFunc, these 5745 //%// methods will assert in debug, and will log in release and assign the value 5746 //%// to the default value. Use the rawValue methods below to assign non enumerator 5747 //%// values. 5748 //% 5749 //%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value) 5750 //% 5751 //%@end 5752 //% 5753 5754 //%PDDM-DEFINE DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) 5755 //%VALUE_FOR_KEY_##VHELPER(KEY_TYPE##KisP$S##KisP, VALUE_TYPE, VNAME) 5756 //% 5757 //%/** 5758 //% * Enumerates the keys and values on this dictionary with the given block. 5759 //% * 5760 //% * @param block The block to enumerate with. 5761 //% * **key**: ##VNAME_VAR$S## The key for the current entry. 5762 //% * **VNAME_VAR**: The value for the current entry 5763 //% * **stop**: ##VNAME_VAR$S## A pointer to a boolean that when set stops the enumeration. 5764 //% **/ 5765 //%- (void)enumerateKeysAnd##VNAME##sUsingBlock: 5766 //% (void (NS_NOESCAPE ^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME_VAR, BOOL *stop))block; 5767 5768 //%PDDM-DEFINE DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) 5769 //%/** 5770 //% * Sets the value for the given key. 5771 //% * 5772 //% * @param ##VNAME_VAR The value to set. 5773 //% * @param key ##VNAME_VAR$S## The key under which to store the value. 5774 //% **/ 5775 //%- (void)set##VNAME##:(VALUE_TYPE)##VNAME_VAR forKey:(KEY_TYPE##KisP$S##KisP)key; 5776 //%DICTIONARY_EXTRA_MUTABLE_METHODS_##VHELPER(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE) 5777 //%/** 5778 //% * Removes the entry for the given key. 5779 //% * 5780 //% * @param aKey Key to be removed from this dictionary. 5781 //% **/ 5782 //%- (void)remove##VNAME##ForKey:(KEY_TYPE##KisP$S##KisP)aKey; 5783 //% 5784 //%/** 5785 //% * Removes all entries in this dictionary. 5786 //% **/ 5787 //%- (void)removeAll; 5788 5789 //%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_POD(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE) 5790 // Empty 5791 //%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_OBJECT(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE) 5792 // Empty 5793 //%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_Enum(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE) 5794 //% 5795 //%/** 5796 //% * Sets the raw enum value for the given key. 5797 //% * 5798 //% * @note This method bypass the validationFunc to enable the setting of values that 5799 //% * were not known at the time the binary was compiled. 5800 //% * 5801 //% * @param rawValue The raw enum value to set. 5802 //% * @param key The key under which to store the raw enum value. 5803 //% **/ 5804 //%- (void)setRawValue:(VALUE_TYPE)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key; 5805 //% 5806 5807 // clang-format on 5808