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