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