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