Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [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 | |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 33 | #import "GPBRuntimeTypes.h" |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 34 | |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [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. |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 43 | |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 44 | NS_ASSUME_NONNULL_BEGIN |
Thomas Van Lenten | 38b9e74 | 2016-05-27 12:51:18 -0400 | [diff] [blame] | 45 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 46 | //%PDDM-EXPAND DECLARE_DICTIONARIES() |
| 47 | // This block of code is generated, do not edit it directly. |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 48 | // clang-format off |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 49 | |
| 50 | #pragma mark - UInt32 -> UInt32 |
| 51 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 52 | /** |
| 53 | * Class used for map fields of <uint32_t, uint32_t> |
| 54 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 55 | * |
| 56 | * @note This class is not meant to be subclassed. |
| 57 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 58 | @interface GPBUInt32UInt32Dictionary : NSObject <NSCopying> |
| 59 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 60 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 61 | @property(nonatomic, readonly) NSUInteger count; |
| 62 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 63 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 64 | * Initializes this dictionary, copying the given values and keys. |
| 65 | * |
| 66 | * @param values The values to be placed in this dictionary. |
| 67 | * @param keys The keys under which to store the values. |
| 68 | * @param count The number of elements to copy into the dictionary. |
| 69 | * |
| 70 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 71 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 72 | - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values |
| 73 | forKeys:(const uint32_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 74 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 78 | * |
| 79 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 80 | * |
| 81 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 82 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 83 | - (instancetype)initWithDictionary:(GPBUInt32UInt32Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 84 | |
| 85 | /** |
| 86 | * Initializes this dictionary with the requested capacity. |
| 87 | * |
| 88 | * @param numItems Number of items needed for this dictionary. |
| 89 | * |
| 90 | * @return A newly initialized dictionary with the requested capacity. |
| 91 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 92 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 93 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 94 | /** |
| 95 | * Gets the value for the given key. |
| 96 | * |
| 97 | * @param value Pointer into which the value will be set, if found. |
| 98 | * @param key Key under which the value is stored, if present. |
| 99 | * |
| 100 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 101 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 102 | - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 103 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 104 | /** |
| 105 | * Enumerates the keys and values on this dictionary with the given block. |
| 106 | * |
| 107 | * @param block The block to enumerate with. |
| 108 | * **key**: The key for the current entry. |
| 109 | * **value**: The value for the current entry |
| 110 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 111 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 112 | - (void)enumerateKeysAndUInt32sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 113 | (void (NS_NOESCAPE ^)(uint32_t key, uint32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 114 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 115 | /** |
| 116 | * Adds the keys and values from another dictionary. |
| 117 | * |
| 118 | * @param otherDictionary Dictionary containing entries to be added to this |
| 119 | * dictionary. |
| 120 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 121 | - (void)addEntriesFromDictionary:(GPBUInt32UInt32Dictionary *)otherDictionary; |
| 122 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 123 | /** |
| 124 | * Sets the value for the given key. |
| 125 | * |
| 126 | * @param value The value to set. |
| 127 | * @param key The key under which to store the value. |
| 128 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 129 | - (void)setUInt32:(uint32_t)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 130 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 131 | /** |
| 132 | * Removes the entry for the given key. |
| 133 | * |
| 134 | * @param aKey Key to be removed from this dictionary. |
| 135 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 136 | - (void)removeUInt32ForKey:(uint32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 137 | |
| 138 | /** |
| 139 | * Removes all entries in this dictionary. |
| 140 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 141 | - (void)removeAll; |
| 142 | |
| 143 | @end |
| 144 | |
| 145 | #pragma mark - UInt32 -> Int32 |
| 146 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 147 | /** |
| 148 | * Class used for map fields of <uint32_t, int32_t> |
| 149 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 150 | * |
| 151 | * @note This class is not meant to be subclassed. |
| 152 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 153 | @interface GPBUInt32Int32Dictionary : NSObject <NSCopying> |
| 154 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 155 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 156 | @property(nonatomic, readonly) NSUInteger count; |
| 157 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 158 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 159 | * Initializes this dictionary, copying the given values and keys. |
| 160 | * |
| 161 | * @param values The values to be placed in this dictionary. |
| 162 | * @param keys The keys under which to store the values. |
| 163 | * @param count The number of elements to copy into the dictionary. |
| 164 | * |
| 165 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 166 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 167 | - (instancetype)initWithInt32s:(const int32_t [__nullable])values |
| 168 | forKeys:(const uint32_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 169 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 170 | |
| 171 | /** |
| 172 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 173 | * |
| 174 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 175 | * |
| 176 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 177 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 178 | - (instancetype)initWithDictionary:(GPBUInt32Int32Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 179 | |
| 180 | /** |
| 181 | * Initializes this dictionary with the requested capacity. |
| 182 | * |
| 183 | * @param numItems Number of items needed for this dictionary. |
| 184 | * |
| 185 | * @return A newly initialized dictionary with the requested capacity. |
| 186 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 187 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 188 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 189 | /** |
| 190 | * Gets the value for the given key. |
| 191 | * |
| 192 | * @param value Pointer into which the value will be set, if found. |
| 193 | * @param key Key under which the value is stored, if present. |
| 194 | * |
| 195 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 196 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 197 | - (BOOL)getInt32:(nullable int32_t *)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 198 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 199 | /** |
| 200 | * Enumerates the keys and values on this dictionary with the given block. |
| 201 | * |
| 202 | * @param block The block to enumerate with. |
| 203 | * **key**: The key for the current entry. |
| 204 | * **value**: The value for the current entry |
| 205 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 206 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 207 | - (void)enumerateKeysAndInt32sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 208 | (void (NS_NOESCAPE ^)(uint32_t key, int32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 209 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 210 | /** |
| 211 | * Adds the keys and values from another dictionary. |
| 212 | * |
| 213 | * @param otherDictionary Dictionary containing entries to be added to this |
| 214 | * dictionary. |
| 215 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 216 | - (void)addEntriesFromDictionary:(GPBUInt32Int32Dictionary *)otherDictionary; |
| 217 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 218 | /** |
| 219 | * Sets the value for the given key. |
| 220 | * |
| 221 | * @param value The value to set. |
| 222 | * @param key The key under which to store the value. |
| 223 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 224 | - (void)setInt32:(int32_t)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 225 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 226 | /** |
| 227 | * Removes the entry for the given key. |
| 228 | * |
| 229 | * @param aKey Key to be removed from this dictionary. |
| 230 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 231 | - (void)removeInt32ForKey:(uint32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 232 | |
| 233 | /** |
| 234 | * Removes all entries in this dictionary. |
| 235 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 236 | - (void)removeAll; |
| 237 | |
| 238 | @end |
| 239 | |
| 240 | #pragma mark - UInt32 -> UInt64 |
| 241 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 242 | /** |
| 243 | * Class used for map fields of <uint32_t, uint64_t> |
| 244 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 245 | * |
| 246 | * @note This class is not meant to be subclassed. |
| 247 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 248 | @interface GPBUInt32UInt64Dictionary : NSObject <NSCopying> |
| 249 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 250 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 251 | @property(nonatomic, readonly) NSUInteger count; |
| 252 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 253 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 254 | * Initializes this dictionary, copying the given values and keys. |
| 255 | * |
| 256 | * @param values The values to be placed in this dictionary. |
| 257 | * @param keys The keys under which to store the values. |
| 258 | * @param count The number of elements to copy into the dictionary. |
| 259 | * |
| 260 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 261 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 262 | - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values |
| 263 | forKeys:(const uint32_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 264 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 265 | |
| 266 | /** |
| 267 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 268 | * |
| 269 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 270 | * |
| 271 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 272 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 273 | - (instancetype)initWithDictionary:(GPBUInt32UInt64Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 274 | |
| 275 | /** |
| 276 | * Initializes this dictionary with the requested capacity. |
| 277 | * |
| 278 | * @param numItems Number of items needed for this dictionary. |
| 279 | * |
| 280 | * @return A newly initialized dictionary with the requested capacity. |
| 281 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 282 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 283 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 284 | /** |
| 285 | * Gets the value for the given key. |
| 286 | * |
| 287 | * @param value Pointer into which the value will be set, if found. |
| 288 | * @param key Key under which the value is stored, if present. |
| 289 | * |
| 290 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 291 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 292 | - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 293 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 294 | /** |
| 295 | * Enumerates the keys and values on this dictionary with the given block. |
| 296 | * |
| 297 | * @param block The block to enumerate with. |
| 298 | * **key**: The key for the current entry. |
| 299 | * **value**: The value for the current entry |
| 300 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 301 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 302 | - (void)enumerateKeysAndUInt64sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 303 | (void (NS_NOESCAPE ^)(uint32_t key, uint64_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 304 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 305 | /** |
| 306 | * Adds the keys and values from another dictionary. |
| 307 | * |
| 308 | * @param otherDictionary Dictionary containing entries to be added to this |
| 309 | * dictionary. |
| 310 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 311 | - (void)addEntriesFromDictionary:(GPBUInt32UInt64Dictionary *)otherDictionary; |
| 312 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 313 | /** |
| 314 | * Sets the value for the given key. |
| 315 | * |
| 316 | * @param value The value to set. |
| 317 | * @param key The key under which to store the value. |
| 318 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 319 | - (void)setUInt64:(uint64_t)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 320 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 321 | /** |
| 322 | * Removes the entry for the given key. |
| 323 | * |
| 324 | * @param aKey Key to be removed from this dictionary. |
| 325 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 326 | - (void)removeUInt64ForKey:(uint32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 327 | |
| 328 | /** |
| 329 | * Removes all entries in this dictionary. |
| 330 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 331 | - (void)removeAll; |
| 332 | |
| 333 | @end |
| 334 | |
| 335 | #pragma mark - UInt32 -> Int64 |
| 336 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 337 | /** |
| 338 | * Class used for map fields of <uint32_t, int64_t> |
| 339 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 340 | * |
| 341 | * @note This class is not meant to be subclassed. |
| 342 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 343 | @interface GPBUInt32Int64Dictionary : NSObject <NSCopying> |
| 344 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 345 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 346 | @property(nonatomic, readonly) NSUInteger count; |
| 347 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 348 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 349 | * Initializes this dictionary, copying the given values and keys. |
| 350 | * |
| 351 | * @param values The values to be placed in this dictionary. |
| 352 | * @param keys The keys under which to store the values. |
| 353 | * @param count The number of elements to copy into the dictionary. |
| 354 | * |
| 355 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 356 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 357 | - (instancetype)initWithInt64s:(const int64_t [__nullable])values |
| 358 | forKeys:(const uint32_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 359 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 360 | |
| 361 | /** |
| 362 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 363 | * |
| 364 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 365 | * |
| 366 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 367 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 368 | - (instancetype)initWithDictionary:(GPBUInt32Int64Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 369 | |
| 370 | /** |
| 371 | * Initializes this dictionary with the requested capacity. |
| 372 | * |
| 373 | * @param numItems Number of items needed for this dictionary. |
| 374 | * |
| 375 | * @return A newly initialized dictionary with the requested capacity. |
| 376 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 377 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 378 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 379 | /** |
| 380 | * Gets the value for the given key. |
| 381 | * |
| 382 | * @param value Pointer into which the value will be set, if found. |
| 383 | * @param key Key under which the value is stored, if present. |
| 384 | * |
| 385 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 386 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 387 | - (BOOL)getInt64:(nullable int64_t *)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 388 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 389 | /** |
| 390 | * Enumerates the keys and values on this dictionary with the given block. |
| 391 | * |
| 392 | * @param block The block to enumerate with. |
| 393 | * **key**: The key for the current entry. |
| 394 | * **value**: The value for the current entry |
| 395 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 396 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 397 | - (void)enumerateKeysAndInt64sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 398 | (void (NS_NOESCAPE ^)(uint32_t key, int64_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 399 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 400 | /** |
| 401 | * Adds the keys and values from another dictionary. |
| 402 | * |
| 403 | * @param otherDictionary Dictionary containing entries to be added to this |
| 404 | * dictionary. |
| 405 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 406 | - (void)addEntriesFromDictionary:(GPBUInt32Int64Dictionary *)otherDictionary; |
| 407 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 408 | /** |
| 409 | * Sets the value for the given key. |
| 410 | * |
| 411 | * @param value The value to set. |
| 412 | * @param key The key under which to store the value. |
| 413 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 414 | - (void)setInt64:(int64_t)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 415 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 416 | /** |
| 417 | * Removes the entry for the given key. |
| 418 | * |
| 419 | * @param aKey Key to be removed from this dictionary. |
| 420 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 421 | - (void)removeInt64ForKey:(uint32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 422 | |
| 423 | /** |
| 424 | * Removes all entries in this dictionary. |
| 425 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 426 | - (void)removeAll; |
| 427 | |
| 428 | @end |
| 429 | |
| 430 | #pragma mark - UInt32 -> Bool |
| 431 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 432 | /** |
| 433 | * Class used for map fields of <uint32_t, BOOL> |
| 434 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 435 | * |
| 436 | * @note This class is not meant to be subclassed. |
| 437 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 438 | @interface GPBUInt32BoolDictionary : NSObject <NSCopying> |
| 439 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 440 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 441 | @property(nonatomic, readonly) NSUInteger count; |
| 442 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 443 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 444 | * Initializes this dictionary, copying the given values and keys. |
| 445 | * |
| 446 | * @param values The values to be placed in this dictionary. |
| 447 | * @param keys The keys under which to store the values. |
| 448 | * @param count The number of elements to copy into the dictionary. |
| 449 | * |
| 450 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 451 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 452 | - (instancetype)initWithBools:(const BOOL [__nullable])values |
| 453 | forKeys:(const uint32_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 454 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 455 | |
| 456 | /** |
| 457 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 458 | * |
| 459 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 460 | * |
| 461 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 462 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 463 | - (instancetype)initWithDictionary:(GPBUInt32BoolDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 464 | |
| 465 | /** |
| 466 | * Initializes this dictionary with the requested capacity. |
| 467 | * |
| 468 | * @param numItems Number of items needed for this dictionary. |
| 469 | * |
| 470 | * @return A newly initialized dictionary with the requested capacity. |
| 471 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 472 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 473 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 474 | /** |
| 475 | * Gets the value for the given key. |
| 476 | * |
| 477 | * @param value Pointer into which the value will be set, if found. |
| 478 | * @param key Key under which the value is stored, if present. |
| 479 | * |
| 480 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 481 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 482 | - (BOOL)getBool:(nullable BOOL *)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 483 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 484 | /** |
| 485 | * Enumerates the keys and values on this dictionary with the given block. |
| 486 | * |
| 487 | * @param block The block to enumerate with. |
| 488 | * **key**: The key for the current entry. |
| 489 | * **value**: The value for the current entry |
| 490 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 491 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 492 | - (void)enumerateKeysAndBoolsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 493 | (void (NS_NOESCAPE ^)(uint32_t key, BOOL value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 494 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 495 | /** |
| 496 | * Adds the keys and values from another dictionary. |
| 497 | * |
| 498 | * @param otherDictionary Dictionary containing entries to be added to this |
| 499 | * dictionary. |
| 500 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 501 | - (void)addEntriesFromDictionary:(GPBUInt32BoolDictionary *)otherDictionary; |
| 502 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 503 | /** |
| 504 | * Sets the value for the given key. |
| 505 | * |
| 506 | * @param value The value to set. |
| 507 | * @param key The key under which to store the value. |
| 508 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 509 | - (void)setBool:(BOOL)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 510 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 511 | /** |
| 512 | * Removes the entry for the given key. |
| 513 | * |
| 514 | * @param aKey Key to be removed from this dictionary. |
| 515 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 516 | - (void)removeBoolForKey:(uint32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 517 | |
| 518 | /** |
| 519 | * Removes all entries in this dictionary. |
| 520 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 521 | - (void)removeAll; |
| 522 | |
| 523 | @end |
| 524 | |
| 525 | #pragma mark - UInt32 -> Float |
| 526 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 527 | /** |
| 528 | * Class used for map fields of <uint32_t, float> |
| 529 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 530 | * |
| 531 | * @note This class is not meant to be subclassed. |
| 532 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 533 | @interface GPBUInt32FloatDictionary : NSObject <NSCopying> |
| 534 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 535 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 536 | @property(nonatomic, readonly) NSUInteger count; |
| 537 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 538 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 539 | * Initializes this dictionary, copying the given values and keys. |
| 540 | * |
| 541 | * @param values The values to be placed in this dictionary. |
| 542 | * @param keys The keys under which to store the values. |
| 543 | * @param count The number of elements to copy into the dictionary. |
| 544 | * |
| 545 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 546 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 547 | - (instancetype)initWithFloats:(const float [__nullable])values |
| 548 | forKeys:(const uint32_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 549 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 550 | |
| 551 | /** |
| 552 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 553 | * |
| 554 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 555 | * |
| 556 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 557 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 558 | - (instancetype)initWithDictionary:(GPBUInt32FloatDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 559 | |
| 560 | /** |
| 561 | * Initializes this dictionary with the requested capacity. |
| 562 | * |
| 563 | * @param numItems Number of items needed for this dictionary. |
| 564 | * |
| 565 | * @return A newly initialized dictionary with the requested capacity. |
| 566 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 567 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 568 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 569 | /** |
| 570 | * Gets the value for the given key. |
| 571 | * |
| 572 | * @param value Pointer into which the value will be set, if found. |
| 573 | * @param key Key under which the value is stored, if present. |
| 574 | * |
| 575 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 576 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 577 | - (BOOL)getFloat:(nullable float *)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 578 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 579 | /** |
| 580 | * Enumerates the keys and values on this dictionary with the given block. |
| 581 | * |
| 582 | * @param block The block to enumerate with. |
| 583 | * **key**: The key for the current entry. |
| 584 | * **value**: The value for the current entry |
| 585 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 586 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 587 | - (void)enumerateKeysAndFloatsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 588 | (void (NS_NOESCAPE ^)(uint32_t key, float value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 589 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 590 | /** |
| 591 | * Adds the keys and values from another dictionary. |
| 592 | * |
| 593 | * @param otherDictionary Dictionary containing entries to be added to this |
| 594 | * dictionary. |
| 595 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 596 | - (void)addEntriesFromDictionary:(GPBUInt32FloatDictionary *)otherDictionary; |
| 597 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 598 | /** |
| 599 | * Sets the value for the given key. |
| 600 | * |
| 601 | * @param value The value to set. |
| 602 | * @param key The key under which to store the value. |
| 603 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 604 | - (void)setFloat:(float)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 605 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 606 | /** |
| 607 | * Removes the entry for the given key. |
| 608 | * |
| 609 | * @param aKey Key to be removed from this dictionary. |
| 610 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 611 | - (void)removeFloatForKey:(uint32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 612 | |
| 613 | /** |
| 614 | * Removes all entries in this dictionary. |
| 615 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 616 | - (void)removeAll; |
| 617 | |
| 618 | @end |
| 619 | |
| 620 | #pragma mark - UInt32 -> Double |
| 621 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 622 | /** |
| 623 | * Class used for map fields of <uint32_t, double> |
| 624 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 625 | * |
| 626 | * @note This class is not meant to be subclassed. |
| 627 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 628 | @interface GPBUInt32DoubleDictionary : NSObject <NSCopying> |
| 629 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 630 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 631 | @property(nonatomic, readonly) NSUInteger count; |
| 632 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 633 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 634 | * Initializes this dictionary, copying the given values and keys. |
| 635 | * |
| 636 | * @param values The values to be placed in this dictionary. |
| 637 | * @param keys The keys under which to store the values. |
| 638 | * @param count The number of elements to copy into the dictionary. |
| 639 | * |
| 640 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 641 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 642 | - (instancetype)initWithDoubles:(const double [__nullable])values |
| 643 | forKeys:(const uint32_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 644 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 645 | |
| 646 | /** |
| 647 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 648 | * |
| 649 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 650 | * |
| 651 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 652 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 653 | - (instancetype)initWithDictionary:(GPBUInt32DoubleDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 654 | |
| 655 | /** |
| 656 | * Initializes this dictionary with the requested capacity. |
| 657 | * |
| 658 | * @param numItems Number of items needed for this dictionary. |
| 659 | * |
| 660 | * @return A newly initialized dictionary with the requested capacity. |
| 661 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 662 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 663 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 664 | /** |
| 665 | * Gets the value for the given key. |
| 666 | * |
| 667 | * @param value Pointer into which the value will be set, if found. |
| 668 | * @param key Key under which the value is stored, if present. |
| 669 | * |
| 670 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 671 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 672 | - (BOOL)getDouble:(nullable double *)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 673 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 674 | /** |
| 675 | * Enumerates the keys and values on this dictionary with the given block. |
| 676 | * |
| 677 | * @param block The block to enumerate with. |
| 678 | * **key**: The key for the current entry. |
| 679 | * **value**: The value for the current entry |
| 680 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 681 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 682 | - (void)enumerateKeysAndDoublesUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 683 | (void (NS_NOESCAPE ^)(uint32_t key, double value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 684 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 685 | /** |
| 686 | * Adds the keys and values from another dictionary. |
| 687 | * |
| 688 | * @param otherDictionary Dictionary containing entries to be added to this |
| 689 | * dictionary. |
| 690 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 691 | - (void)addEntriesFromDictionary:(GPBUInt32DoubleDictionary *)otherDictionary; |
| 692 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 693 | /** |
| 694 | * Sets the value for the given key. |
| 695 | * |
| 696 | * @param value The value to set. |
| 697 | * @param key The key under which to store the value. |
| 698 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 699 | - (void)setDouble:(double)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 700 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 701 | /** |
| 702 | * Removes the entry for the given key. |
| 703 | * |
| 704 | * @param aKey Key to be removed from this dictionary. |
| 705 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 706 | - (void)removeDoubleForKey:(uint32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 707 | |
| 708 | /** |
| 709 | * Removes all entries in this dictionary. |
| 710 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 711 | - (void)removeAll; |
| 712 | |
| 713 | @end |
| 714 | |
| 715 | #pragma mark - UInt32 -> Enum |
| 716 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 717 | /** |
| 718 | * Class used for map fields of <uint32_t, int32_t> |
| 719 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 720 | * |
| 721 | * @note This class is not meant to be subclassed. |
| 722 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 723 | @interface GPBUInt32EnumDictionary : NSObject <NSCopying> |
| 724 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 725 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 726 | @property(nonatomic, readonly) NSUInteger count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 727 | /** The validation function to check if the enums are valid. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 728 | @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; |
| 729 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 730 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 731 | * Initializes a dictionary with the given validation function. |
| 732 | * |
| 733 | * @param func The enum validation function for the dictionary. |
| 734 | * |
| 735 | * @return A newly initialized dictionary. |
| 736 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 737 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 738 | |
| 739 | /** |
| 740 | * Initializes a dictionary with the entries given. |
| 741 | * |
| 742 | * @param func The enum validation function for the dictionary. |
| 743 | * @param values The raw enum values values to be placed in the dictionary. |
| 744 | * @param keys The keys under which to store the values. |
| 745 | * @param count The number of entries to store in the dictionary. |
| 746 | * |
| 747 | * @return A newly initialized dictionary with the keys and values in it. |
| 748 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 749 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 750 | rawValues:(const int32_t [__nullable])values |
| 751 | forKeys:(const uint32_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 752 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 753 | |
| 754 | /** |
| 755 | * Initializes a dictionary with the entries from the given. |
| 756 | * dictionary. |
| 757 | * |
| 758 | * @param dictionary Dictionary containing the entries to add to the dictionary. |
| 759 | * |
| 760 | * @return A newly initialized dictionary with the entries from the given |
| 761 | * dictionary in it. |
| 762 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 763 | - (instancetype)initWithDictionary:(GPBUInt32EnumDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 764 | |
| 765 | /** |
| 766 | * Initializes a dictionary with the given capacity. |
| 767 | * |
| 768 | * @param func The enum validation function for the dictionary. |
| 769 | * @param numItems Capacity needed for the dictionary. |
| 770 | * |
| 771 | * @return A newly initialized dictionary with the given capacity. |
| 772 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 773 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 774 | capacity:(NSUInteger)numItems; |
| 775 | |
| 776 | // These will return kGPBUnrecognizedEnumeratorValue if the value for the key |
| 777 | // is not a valid enumerator as defined by validationFunc. If the actual value is |
| 778 | // desired, use "raw" version of the method. |
| 779 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 780 | /** |
| 781 | * Gets the value for the given key. |
| 782 | * |
| 783 | * @param value Pointer into which the value will be set, if found. |
| 784 | * @param key Key under which the value is stored, if present. |
| 785 | * |
| 786 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 787 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 788 | - (BOOL)getEnum:(nullable int32_t *)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 789 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 790 | /** |
| 791 | * Enumerates the keys and values on this dictionary with the given block. |
| 792 | * |
| 793 | * @param block The block to enumerate with. |
| 794 | * **key**: The key for the current entry. |
| 795 | * **value**: The value for the current entry |
| 796 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 797 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 798 | - (void)enumerateKeysAndEnumsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 799 | (void (NS_NOESCAPE ^)(uint32_t key, int32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 800 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 801 | /** |
| 802 | * Gets the raw enum value for the given key. |
| 803 | * |
| 804 | * @note This method bypass the validationFunc to enable the access of values that |
| 805 | * were not known at the time the binary was compiled. |
| 806 | * |
| 807 | * @param rawValue Pointer into which the value will be set, if found. |
| 808 | * @param key Key under which the value is stored, if present. |
| 809 | * |
| 810 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 811 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 812 | - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 813 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 814 | /** |
| 815 | * Enumerates the keys and values on this dictionary with the given block. |
| 816 | * |
| 817 | * @note This method bypass the validationFunc to enable the access of values that |
| 818 | * were not known at the time the binary was compiled. |
| 819 | * |
| 820 | * @param block The block to enumerate with. |
| 821 | * **key**: The key for the current entry. |
| 822 | * **rawValue**: The value for the current entry |
| 823 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 824 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 825 | - (void)enumerateKeysAndRawValuesUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 826 | (void (NS_NOESCAPE ^)(uint32_t key, int32_t rawValue, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 827 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 828 | /** |
| 829 | * Adds the keys and raw enum values from another dictionary. |
| 830 | * |
| 831 | * @note This method bypass the validationFunc to enable the setting of values that |
| 832 | * were not known at the time the binary was compiled. |
| 833 | * |
| 834 | * @param otherDictionary Dictionary containing entries to be added to this |
| 835 | * dictionary. |
| 836 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 837 | - (void)addRawEntriesFromDictionary:(GPBUInt32EnumDictionary *)otherDictionary; |
| 838 | |
| 839 | // If value is not a valid enumerator as defined by validationFunc, these |
| 840 | // methods will assert in debug, and will log in release and assign the value |
| 841 | // to the default value. Use the rawValue methods below to assign non enumerator |
| 842 | // values. |
| 843 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 844 | /** |
| 845 | * Sets the value for the given key. |
| 846 | * |
| 847 | * @param value The value to set. |
| 848 | * @param key The key under which to store the value. |
| 849 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 850 | - (void)setEnum:(int32_t)value forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 851 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 852 | /** |
| 853 | * Sets the raw enum value for the given key. |
| 854 | * |
| 855 | * @note This method bypass the validationFunc to enable the setting of values that |
| 856 | * were not known at the time the binary was compiled. |
| 857 | * |
| 858 | * @param rawValue The raw enum value to set. |
| 859 | * @param key The key under which to store the raw enum value. |
| 860 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 861 | - (void)setRawValue:(int32_t)rawValue forKey:(uint32_t)key; |
| 862 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 863 | /** |
| 864 | * Removes the entry for the given key. |
| 865 | * |
| 866 | * @param aKey Key to be removed from this dictionary. |
| 867 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 868 | - (void)removeEnumForKey:(uint32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 869 | |
| 870 | /** |
| 871 | * Removes all entries in this dictionary. |
| 872 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 873 | - (void)removeAll; |
| 874 | |
| 875 | @end |
| 876 | |
| 877 | #pragma mark - UInt32 -> Object |
| 878 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 879 | /** |
| 880 | * Class used for map fields of <uint32_t, ObjectType> |
| 881 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 882 | * |
| 883 | * @note This class is not meant to be subclassed. |
| 884 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 885 | @interface GPBUInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying> |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 886 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 887 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 888 | @property(nonatomic, readonly) NSUInteger count; |
| 889 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 890 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 891 | * Initializes this dictionary, copying the given values and keys. |
| 892 | * |
| 893 | * @param objects The values to be placed in this dictionary. |
| 894 | * @param keys The keys under which to store the values. |
| 895 | * @param count The number of elements to copy into the dictionary. |
| 896 | * |
| 897 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 898 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 899 | - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects |
| 900 | forKeys:(const uint32_t [__nullable])keys |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 901 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 902 | |
| 903 | /** |
| 904 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 905 | * |
| 906 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 907 | * |
| 908 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 909 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 910 | - (instancetype)initWithDictionary:(GPBUInt32ObjectDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 911 | |
| 912 | /** |
| 913 | * Initializes this dictionary with the requested capacity. |
| 914 | * |
| 915 | * @param numItems Number of items needed for this dictionary. |
| 916 | * |
| 917 | * @return A newly initialized dictionary with the requested capacity. |
| 918 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 919 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 920 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 921 | /** |
| 922 | * Fetches the object stored under the given key. |
| 923 | * |
| 924 | * @param key Key under which the value is stored, if present. |
| 925 | * |
| 926 | * @return The object if found, nil otherwise. |
| 927 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 928 | - (ObjectType)objectForKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 929 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 930 | /** |
| 931 | * Enumerates the keys and values on this dictionary with the given block. |
| 932 | * |
| 933 | * @param block The block to enumerate with. |
| 934 | * **key**: The key for the current entry. |
| 935 | * **object**: The value for the current entry |
| 936 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 937 | **/ |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 938 | - (void)enumerateKeysAndObjectsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 939 | (void (NS_NOESCAPE ^)(uint32_t key, ObjectType object, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 940 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 941 | /** |
| 942 | * Adds the keys and values from another dictionary. |
| 943 | * |
| 944 | * @param otherDictionary Dictionary containing entries to be added to this |
| 945 | * dictionary. |
| 946 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 947 | - (void)addEntriesFromDictionary:(GPBUInt32ObjectDictionary *)otherDictionary; |
| 948 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 949 | /** |
| 950 | * Sets the value for the given key. |
| 951 | * |
| 952 | * @param object The value to set. |
| 953 | * @param key The key under which to store the value. |
| 954 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 955 | - (void)setObject:(ObjectType)object forKey:(uint32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 956 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 957 | /** |
| 958 | * Removes the entry for the given key. |
| 959 | * |
| 960 | * @param aKey Key to be removed from this dictionary. |
| 961 | **/ |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 962 | - (void)removeObjectForKey:(uint32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 963 | |
| 964 | /** |
| 965 | * Removes all entries in this dictionary. |
| 966 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 967 | - (void)removeAll; |
| 968 | |
| 969 | @end |
| 970 | |
| 971 | #pragma mark - Int32 -> UInt32 |
| 972 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 973 | /** |
| 974 | * Class used for map fields of <int32_t, uint32_t> |
| 975 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 976 | * |
| 977 | * @note This class is not meant to be subclassed. |
| 978 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 979 | @interface GPBInt32UInt32Dictionary : NSObject <NSCopying> |
| 980 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 981 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 982 | @property(nonatomic, readonly) NSUInteger count; |
| 983 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 984 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 985 | * Initializes this dictionary, copying the given values and keys. |
| 986 | * |
| 987 | * @param values The values to be placed in this dictionary. |
| 988 | * @param keys The keys under which to store the values. |
| 989 | * @param count The number of elements to copy into the dictionary. |
| 990 | * |
| 991 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 992 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 993 | - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values |
| 994 | forKeys:(const int32_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 995 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 996 | |
| 997 | /** |
| 998 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 999 | * |
| 1000 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 1001 | * |
| 1002 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 1003 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1004 | - (instancetype)initWithDictionary:(GPBInt32UInt32Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1005 | |
| 1006 | /** |
| 1007 | * Initializes this dictionary with the requested capacity. |
| 1008 | * |
| 1009 | * @param numItems Number of items needed for this dictionary. |
| 1010 | * |
| 1011 | * @return A newly initialized dictionary with the requested capacity. |
| 1012 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1013 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 1014 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1015 | /** |
| 1016 | * Gets the value for the given key. |
| 1017 | * |
| 1018 | * @param value Pointer into which the value will be set, if found. |
| 1019 | * @param key Key under which the value is stored, if present. |
| 1020 | * |
| 1021 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 1022 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1023 | - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1024 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1025 | /** |
| 1026 | * Enumerates the keys and values on this dictionary with the given block. |
| 1027 | * |
| 1028 | * @param block The block to enumerate with. |
| 1029 | * **key**: The key for the current entry. |
| 1030 | * **value**: The value for the current entry |
| 1031 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1032 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1033 | - (void)enumerateKeysAndUInt32sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 1034 | (void (NS_NOESCAPE ^)(int32_t key, uint32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1035 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1036 | /** |
| 1037 | * Adds the keys and values from another dictionary. |
| 1038 | * |
| 1039 | * @param otherDictionary Dictionary containing entries to be added to this |
| 1040 | * dictionary. |
| 1041 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1042 | - (void)addEntriesFromDictionary:(GPBInt32UInt32Dictionary *)otherDictionary; |
| 1043 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1044 | /** |
| 1045 | * Sets the value for the given key. |
| 1046 | * |
| 1047 | * @param value The value to set. |
| 1048 | * @param key The key under which to store the value. |
| 1049 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1050 | - (void)setUInt32:(uint32_t)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1051 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1052 | /** |
| 1053 | * Removes the entry for the given key. |
| 1054 | * |
| 1055 | * @param aKey Key to be removed from this dictionary. |
| 1056 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1057 | - (void)removeUInt32ForKey:(int32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1058 | |
| 1059 | /** |
| 1060 | * Removes all entries in this dictionary. |
| 1061 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1062 | - (void)removeAll; |
| 1063 | |
| 1064 | @end |
| 1065 | |
| 1066 | #pragma mark - Int32 -> Int32 |
| 1067 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1068 | /** |
| 1069 | * Class used for map fields of <int32_t, int32_t> |
| 1070 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 1071 | * |
| 1072 | * @note This class is not meant to be subclassed. |
| 1073 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1074 | @interface GPBInt32Int32Dictionary : NSObject <NSCopying> |
| 1075 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1076 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1077 | @property(nonatomic, readonly) NSUInteger count; |
| 1078 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1079 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1080 | * Initializes this dictionary, copying the given values and keys. |
| 1081 | * |
| 1082 | * @param values The values to be placed in this dictionary. |
| 1083 | * @param keys The keys under which to store the values. |
| 1084 | * @param count The number of elements to copy into the dictionary. |
| 1085 | * |
| 1086 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 1087 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1088 | - (instancetype)initWithInt32s:(const int32_t [__nullable])values |
| 1089 | forKeys:(const int32_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1090 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1091 | |
| 1092 | /** |
| 1093 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 1094 | * |
| 1095 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 1096 | * |
| 1097 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 1098 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1099 | - (instancetype)initWithDictionary:(GPBInt32Int32Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1100 | |
| 1101 | /** |
| 1102 | * Initializes this dictionary with the requested capacity. |
| 1103 | * |
| 1104 | * @param numItems Number of items needed for this dictionary. |
| 1105 | * |
| 1106 | * @return A newly initialized dictionary with the requested capacity. |
| 1107 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1108 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 1109 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1110 | /** |
| 1111 | * Gets the value for the given key. |
| 1112 | * |
| 1113 | * @param value Pointer into which the value will be set, if found. |
| 1114 | * @param key Key under which the value is stored, if present. |
| 1115 | * |
| 1116 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 1117 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1118 | - (BOOL)getInt32:(nullable int32_t *)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1119 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1120 | /** |
| 1121 | * Enumerates the keys and values on this dictionary with the given block. |
| 1122 | * |
| 1123 | * @param block The block to enumerate with. |
| 1124 | * **key**: The key for the current entry. |
| 1125 | * **value**: The value for the current entry |
| 1126 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1127 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1128 | - (void)enumerateKeysAndInt32sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 1129 | (void (NS_NOESCAPE ^)(int32_t key, int32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1130 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1131 | /** |
| 1132 | * Adds the keys and values from another dictionary. |
| 1133 | * |
| 1134 | * @param otherDictionary Dictionary containing entries to be added to this |
| 1135 | * dictionary. |
| 1136 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1137 | - (void)addEntriesFromDictionary:(GPBInt32Int32Dictionary *)otherDictionary; |
| 1138 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1139 | /** |
| 1140 | * Sets the value for the given key. |
| 1141 | * |
| 1142 | * @param value The value to set. |
| 1143 | * @param key The key under which to store the value. |
| 1144 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1145 | - (void)setInt32:(int32_t)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1146 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1147 | /** |
| 1148 | * Removes the entry for the given key. |
| 1149 | * |
| 1150 | * @param aKey Key to be removed from this dictionary. |
| 1151 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1152 | - (void)removeInt32ForKey:(int32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1153 | |
| 1154 | /** |
| 1155 | * Removes all entries in this dictionary. |
| 1156 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1157 | - (void)removeAll; |
| 1158 | |
| 1159 | @end |
| 1160 | |
| 1161 | #pragma mark - Int32 -> UInt64 |
| 1162 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1163 | /** |
| 1164 | * Class used for map fields of <int32_t, uint64_t> |
| 1165 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 1166 | * |
| 1167 | * @note This class is not meant to be subclassed. |
| 1168 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1169 | @interface GPBInt32UInt64Dictionary : NSObject <NSCopying> |
| 1170 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1171 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1172 | @property(nonatomic, readonly) NSUInteger count; |
| 1173 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1174 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1175 | * Initializes this dictionary, copying the given values and keys. |
| 1176 | * |
| 1177 | * @param values The values to be placed in this dictionary. |
| 1178 | * @param keys The keys under which to store the values. |
| 1179 | * @param count The number of elements to copy into the dictionary. |
| 1180 | * |
| 1181 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 1182 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1183 | - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values |
| 1184 | forKeys:(const int32_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1185 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1186 | |
| 1187 | /** |
| 1188 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 1189 | * |
| 1190 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 1191 | * |
| 1192 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 1193 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1194 | - (instancetype)initWithDictionary:(GPBInt32UInt64Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1195 | |
| 1196 | /** |
| 1197 | * Initializes this dictionary with the requested capacity. |
| 1198 | * |
| 1199 | * @param numItems Number of items needed for this dictionary. |
| 1200 | * |
| 1201 | * @return A newly initialized dictionary with the requested capacity. |
| 1202 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1203 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 1204 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1205 | /** |
| 1206 | * Gets the value for the given key. |
| 1207 | * |
| 1208 | * @param value Pointer into which the value will be set, if found. |
| 1209 | * @param key Key under which the value is stored, if present. |
| 1210 | * |
| 1211 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 1212 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1213 | - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1214 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1215 | /** |
| 1216 | * Enumerates the keys and values on this dictionary with the given block. |
| 1217 | * |
| 1218 | * @param block The block to enumerate with. |
| 1219 | * **key**: The key for the current entry. |
| 1220 | * **value**: The value for the current entry |
| 1221 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1222 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1223 | - (void)enumerateKeysAndUInt64sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 1224 | (void (NS_NOESCAPE ^)(int32_t key, uint64_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1225 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1226 | /** |
| 1227 | * Adds the keys and values from another dictionary. |
| 1228 | * |
| 1229 | * @param otherDictionary Dictionary containing entries to be added to this |
| 1230 | * dictionary. |
| 1231 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1232 | - (void)addEntriesFromDictionary:(GPBInt32UInt64Dictionary *)otherDictionary; |
| 1233 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1234 | /** |
| 1235 | * Sets the value for the given key. |
| 1236 | * |
| 1237 | * @param value The value to set. |
| 1238 | * @param key The key under which to store the value. |
| 1239 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1240 | - (void)setUInt64:(uint64_t)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1241 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1242 | /** |
| 1243 | * Removes the entry for the given key. |
| 1244 | * |
| 1245 | * @param aKey Key to be removed from this dictionary. |
| 1246 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1247 | - (void)removeUInt64ForKey:(int32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1248 | |
| 1249 | /** |
| 1250 | * Removes all entries in this dictionary. |
| 1251 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1252 | - (void)removeAll; |
| 1253 | |
| 1254 | @end |
| 1255 | |
| 1256 | #pragma mark - Int32 -> Int64 |
| 1257 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1258 | /** |
| 1259 | * Class used for map fields of <int32_t, int64_t> |
| 1260 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 1261 | * |
| 1262 | * @note This class is not meant to be subclassed. |
| 1263 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1264 | @interface GPBInt32Int64Dictionary : NSObject <NSCopying> |
| 1265 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1266 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1267 | @property(nonatomic, readonly) NSUInteger count; |
| 1268 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1269 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1270 | * Initializes this dictionary, copying the given values and keys. |
| 1271 | * |
| 1272 | * @param values The values to be placed in this dictionary. |
| 1273 | * @param keys The keys under which to store the values. |
| 1274 | * @param count The number of elements to copy into the dictionary. |
| 1275 | * |
| 1276 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 1277 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1278 | - (instancetype)initWithInt64s:(const int64_t [__nullable])values |
| 1279 | forKeys:(const int32_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1280 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1281 | |
| 1282 | /** |
| 1283 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 1284 | * |
| 1285 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 1286 | * |
| 1287 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 1288 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1289 | - (instancetype)initWithDictionary:(GPBInt32Int64Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1290 | |
| 1291 | /** |
| 1292 | * Initializes this dictionary with the requested capacity. |
| 1293 | * |
| 1294 | * @param numItems Number of items needed for this dictionary. |
| 1295 | * |
| 1296 | * @return A newly initialized dictionary with the requested capacity. |
| 1297 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1298 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 1299 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1300 | /** |
| 1301 | * Gets the value for the given key. |
| 1302 | * |
| 1303 | * @param value Pointer into which the value will be set, if found. |
| 1304 | * @param key Key under which the value is stored, if present. |
| 1305 | * |
| 1306 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 1307 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1308 | - (BOOL)getInt64:(nullable int64_t *)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1309 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1310 | /** |
| 1311 | * Enumerates the keys and values on this dictionary with the given block. |
| 1312 | * |
| 1313 | * @param block The block to enumerate with. |
| 1314 | * **key**: The key for the current entry. |
| 1315 | * **value**: The value for the current entry |
| 1316 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1317 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1318 | - (void)enumerateKeysAndInt64sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 1319 | (void (NS_NOESCAPE ^)(int32_t key, int64_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1320 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1321 | /** |
| 1322 | * Adds the keys and values from another dictionary. |
| 1323 | * |
| 1324 | * @param otherDictionary Dictionary containing entries to be added to this |
| 1325 | * dictionary. |
| 1326 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1327 | - (void)addEntriesFromDictionary:(GPBInt32Int64Dictionary *)otherDictionary; |
| 1328 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1329 | /** |
| 1330 | * Sets the value for the given key. |
| 1331 | * |
| 1332 | * @param value The value to set. |
| 1333 | * @param key The key under which to store the value. |
| 1334 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1335 | - (void)setInt64:(int64_t)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1336 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1337 | /** |
| 1338 | * Removes the entry for the given key. |
| 1339 | * |
| 1340 | * @param aKey Key to be removed from this dictionary. |
| 1341 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1342 | - (void)removeInt64ForKey:(int32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1343 | |
| 1344 | /** |
| 1345 | * Removes all entries in this dictionary. |
| 1346 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1347 | - (void)removeAll; |
| 1348 | |
| 1349 | @end |
| 1350 | |
| 1351 | #pragma mark - Int32 -> Bool |
| 1352 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1353 | /** |
| 1354 | * Class used for map fields of <int32_t, BOOL> |
| 1355 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 1356 | * |
| 1357 | * @note This class is not meant to be subclassed. |
| 1358 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1359 | @interface GPBInt32BoolDictionary : NSObject <NSCopying> |
| 1360 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1361 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1362 | @property(nonatomic, readonly) NSUInteger count; |
| 1363 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1364 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1365 | * Initializes this dictionary, copying the given values and keys. |
| 1366 | * |
| 1367 | * @param values The values to be placed in this dictionary. |
| 1368 | * @param keys The keys under which to store the values. |
| 1369 | * @param count The number of elements to copy into the dictionary. |
| 1370 | * |
| 1371 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 1372 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1373 | - (instancetype)initWithBools:(const BOOL [__nullable])values |
| 1374 | forKeys:(const int32_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1375 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1376 | |
| 1377 | /** |
| 1378 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 1379 | * |
| 1380 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 1381 | * |
| 1382 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 1383 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1384 | - (instancetype)initWithDictionary:(GPBInt32BoolDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1385 | |
| 1386 | /** |
| 1387 | * Initializes this dictionary with the requested capacity. |
| 1388 | * |
| 1389 | * @param numItems Number of items needed for this dictionary. |
| 1390 | * |
| 1391 | * @return A newly initialized dictionary with the requested capacity. |
| 1392 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1393 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 1394 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1395 | /** |
| 1396 | * Gets the value for the given key. |
| 1397 | * |
| 1398 | * @param value Pointer into which the value will be set, if found. |
| 1399 | * @param key Key under which the value is stored, if present. |
| 1400 | * |
| 1401 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 1402 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1403 | - (BOOL)getBool:(nullable BOOL *)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1404 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1405 | /** |
| 1406 | * Enumerates the keys and values on this dictionary with the given block. |
| 1407 | * |
| 1408 | * @param block The block to enumerate with. |
| 1409 | * **key**: The key for the current entry. |
| 1410 | * **value**: The value for the current entry |
| 1411 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1412 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1413 | - (void)enumerateKeysAndBoolsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 1414 | (void (NS_NOESCAPE ^)(int32_t key, BOOL value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1415 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1416 | /** |
| 1417 | * Adds the keys and values from another dictionary. |
| 1418 | * |
| 1419 | * @param otherDictionary Dictionary containing entries to be added to this |
| 1420 | * dictionary. |
| 1421 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1422 | - (void)addEntriesFromDictionary:(GPBInt32BoolDictionary *)otherDictionary; |
| 1423 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1424 | /** |
| 1425 | * Sets the value for the given key. |
| 1426 | * |
| 1427 | * @param value The value to set. |
| 1428 | * @param key The key under which to store the value. |
| 1429 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1430 | - (void)setBool:(BOOL)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1431 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1432 | /** |
| 1433 | * Removes the entry for the given key. |
| 1434 | * |
| 1435 | * @param aKey Key to be removed from this dictionary. |
| 1436 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1437 | - (void)removeBoolForKey:(int32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1438 | |
| 1439 | /** |
| 1440 | * Removes all entries in this dictionary. |
| 1441 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1442 | - (void)removeAll; |
| 1443 | |
| 1444 | @end |
| 1445 | |
| 1446 | #pragma mark - Int32 -> Float |
| 1447 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1448 | /** |
| 1449 | * Class used for map fields of <int32_t, float> |
| 1450 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 1451 | * |
| 1452 | * @note This class is not meant to be subclassed. |
| 1453 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1454 | @interface GPBInt32FloatDictionary : NSObject <NSCopying> |
| 1455 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1456 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1457 | @property(nonatomic, readonly) NSUInteger count; |
| 1458 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1459 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1460 | * Initializes this dictionary, copying the given values and keys. |
| 1461 | * |
| 1462 | * @param values The values to be placed in this dictionary. |
| 1463 | * @param keys The keys under which to store the values. |
| 1464 | * @param count The number of elements to copy into the dictionary. |
| 1465 | * |
| 1466 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 1467 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1468 | - (instancetype)initWithFloats:(const float [__nullable])values |
| 1469 | forKeys:(const int32_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1470 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1471 | |
| 1472 | /** |
| 1473 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 1474 | * |
| 1475 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 1476 | * |
| 1477 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 1478 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1479 | - (instancetype)initWithDictionary:(GPBInt32FloatDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1480 | |
| 1481 | /** |
| 1482 | * Initializes this dictionary with the requested capacity. |
| 1483 | * |
| 1484 | * @param numItems Number of items needed for this dictionary. |
| 1485 | * |
| 1486 | * @return A newly initialized dictionary with the requested capacity. |
| 1487 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1488 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 1489 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1490 | /** |
| 1491 | * Gets the value for the given key. |
| 1492 | * |
| 1493 | * @param value Pointer into which the value will be set, if found. |
| 1494 | * @param key Key under which the value is stored, if present. |
| 1495 | * |
| 1496 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 1497 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1498 | - (BOOL)getFloat:(nullable float *)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1499 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1500 | /** |
| 1501 | * Enumerates the keys and values on this dictionary with the given block. |
| 1502 | * |
| 1503 | * @param block The block to enumerate with. |
| 1504 | * **key**: The key for the current entry. |
| 1505 | * **value**: The value for the current entry |
| 1506 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1507 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1508 | - (void)enumerateKeysAndFloatsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 1509 | (void (NS_NOESCAPE ^)(int32_t key, float value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1510 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1511 | /** |
| 1512 | * Adds the keys and values from another dictionary. |
| 1513 | * |
| 1514 | * @param otherDictionary Dictionary containing entries to be added to this |
| 1515 | * dictionary. |
| 1516 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1517 | - (void)addEntriesFromDictionary:(GPBInt32FloatDictionary *)otherDictionary; |
| 1518 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1519 | /** |
| 1520 | * Sets the value for the given key. |
| 1521 | * |
| 1522 | * @param value The value to set. |
| 1523 | * @param key The key under which to store the value. |
| 1524 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1525 | - (void)setFloat:(float)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1526 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1527 | /** |
| 1528 | * Removes the entry for the given key. |
| 1529 | * |
| 1530 | * @param aKey Key to be removed from this dictionary. |
| 1531 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1532 | - (void)removeFloatForKey:(int32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1533 | |
| 1534 | /** |
| 1535 | * Removes all entries in this dictionary. |
| 1536 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1537 | - (void)removeAll; |
| 1538 | |
| 1539 | @end |
| 1540 | |
| 1541 | #pragma mark - Int32 -> Double |
| 1542 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1543 | /** |
| 1544 | * Class used for map fields of <int32_t, double> |
| 1545 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 1546 | * |
| 1547 | * @note This class is not meant to be subclassed. |
| 1548 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1549 | @interface GPBInt32DoubleDictionary : NSObject <NSCopying> |
| 1550 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1551 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1552 | @property(nonatomic, readonly) NSUInteger count; |
| 1553 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1554 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1555 | * Initializes this dictionary, copying the given values and keys. |
| 1556 | * |
| 1557 | * @param values The values to be placed in this dictionary. |
| 1558 | * @param keys The keys under which to store the values. |
| 1559 | * @param count The number of elements to copy into the dictionary. |
| 1560 | * |
| 1561 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 1562 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1563 | - (instancetype)initWithDoubles:(const double [__nullable])values |
| 1564 | forKeys:(const int32_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1565 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1566 | |
| 1567 | /** |
| 1568 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 1569 | * |
| 1570 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 1571 | * |
| 1572 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 1573 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1574 | - (instancetype)initWithDictionary:(GPBInt32DoubleDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1575 | |
| 1576 | /** |
| 1577 | * Initializes this dictionary with the requested capacity. |
| 1578 | * |
| 1579 | * @param numItems Number of items needed for this dictionary. |
| 1580 | * |
| 1581 | * @return A newly initialized dictionary with the requested capacity. |
| 1582 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1583 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 1584 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1585 | /** |
| 1586 | * Gets the value for the given key. |
| 1587 | * |
| 1588 | * @param value Pointer into which the value will be set, if found. |
| 1589 | * @param key Key under which the value is stored, if present. |
| 1590 | * |
| 1591 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 1592 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1593 | - (BOOL)getDouble:(nullable double *)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1594 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1595 | /** |
| 1596 | * Enumerates the keys and values on this dictionary with the given block. |
| 1597 | * |
| 1598 | * @param block The block to enumerate with. |
| 1599 | * **key**: The key for the current entry. |
| 1600 | * **value**: The value for the current entry |
| 1601 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1602 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1603 | - (void)enumerateKeysAndDoublesUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 1604 | (void (NS_NOESCAPE ^)(int32_t key, double value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1605 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1606 | /** |
| 1607 | * Adds the keys and values from another dictionary. |
| 1608 | * |
| 1609 | * @param otherDictionary Dictionary containing entries to be added to this |
| 1610 | * dictionary. |
| 1611 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1612 | - (void)addEntriesFromDictionary:(GPBInt32DoubleDictionary *)otherDictionary; |
| 1613 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1614 | /** |
| 1615 | * Sets the value for the given key. |
| 1616 | * |
| 1617 | * @param value The value to set. |
| 1618 | * @param key The key under which to store the value. |
| 1619 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1620 | - (void)setDouble:(double)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1621 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1622 | /** |
| 1623 | * Removes the entry for the given key. |
| 1624 | * |
| 1625 | * @param aKey Key to be removed from this dictionary. |
| 1626 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1627 | - (void)removeDoubleForKey:(int32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1628 | |
| 1629 | /** |
| 1630 | * Removes all entries in this dictionary. |
| 1631 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1632 | - (void)removeAll; |
| 1633 | |
| 1634 | @end |
| 1635 | |
| 1636 | #pragma mark - Int32 -> Enum |
| 1637 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1638 | /** |
| 1639 | * Class used for map fields of <int32_t, int32_t> |
| 1640 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 1641 | * |
| 1642 | * @note This class is not meant to be subclassed. |
| 1643 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1644 | @interface GPBInt32EnumDictionary : NSObject <NSCopying> |
| 1645 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1646 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1647 | @property(nonatomic, readonly) NSUInteger count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1648 | /** The validation function to check if the enums are valid. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1649 | @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; |
| 1650 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1651 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1652 | * Initializes a dictionary with the given validation function. |
| 1653 | * |
| 1654 | * @param func The enum validation function for the dictionary. |
| 1655 | * |
| 1656 | * @return A newly initialized dictionary. |
| 1657 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1658 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1659 | |
| 1660 | /** |
| 1661 | * Initializes a dictionary with the entries given. |
| 1662 | * |
| 1663 | * @param func The enum validation function for the dictionary. |
| 1664 | * @param values The raw enum values values to be placed in the dictionary. |
| 1665 | * @param keys The keys under which to store the values. |
| 1666 | * @param count The number of entries to store in the dictionary. |
| 1667 | * |
| 1668 | * @return A newly initialized dictionary with the keys and values in it. |
| 1669 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1670 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1671 | rawValues:(const int32_t [__nullable])values |
| 1672 | forKeys:(const int32_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1673 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1674 | |
| 1675 | /** |
| 1676 | * Initializes a dictionary with the entries from the given. |
| 1677 | * dictionary. |
| 1678 | * |
| 1679 | * @param dictionary Dictionary containing the entries to add to the dictionary. |
| 1680 | * |
| 1681 | * @return A newly initialized dictionary with the entries from the given |
| 1682 | * dictionary in it. |
| 1683 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1684 | - (instancetype)initWithDictionary:(GPBInt32EnumDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1685 | |
| 1686 | /** |
| 1687 | * Initializes a dictionary with the given capacity. |
| 1688 | * |
| 1689 | * @param func The enum validation function for the dictionary. |
| 1690 | * @param numItems Capacity needed for the dictionary. |
| 1691 | * |
| 1692 | * @return A newly initialized dictionary with the given capacity. |
| 1693 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1694 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1695 | capacity:(NSUInteger)numItems; |
| 1696 | |
| 1697 | // These will return kGPBUnrecognizedEnumeratorValue if the value for the key |
| 1698 | // is not a valid enumerator as defined by validationFunc. If the actual value is |
| 1699 | // desired, use "raw" version of the method. |
| 1700 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1701 | /** |
| 1702 | * Gets the value for the given key. |
| 1703 | * |
| 1704 | * @param value Pointer into which the value will be set, if found. |
| 1705 | * @param key Key under which the value is stored, if present. |
| 1706 | * |
| 1707 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 1708 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1709 | - (BOOL)getEnum:(nullable int32_t *)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1710 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1711 | /** |
| 1712 | * Enumerates the keys and values on this dictionary with the given block. |
| 1713 | * |
| 1714 | * @param block The block to enumerate with. |
| 1715 | * **key**: The key for the current entry. |
| 1716 | * **value**: The value for the current entry |
| 1717 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1718 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1719 | - (void)enumerateKeysAndEnumsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 1720 | (void (NS_NOESCAPE ^)(int32_t key, int32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1721 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1722 | /** |
| 1723 | * Gets the raw enum value for the given key. |
| 1724 | * |
| 1725 | * @note This method bypass the validationFunc to enable the access of values that |
| 1726 | * were not known at the time the binary was compiled. |
| 1727 | * |
| 1728 | * @param rawValue Pointer into which the value will be set, if found. |
| 1729 | * @param key Key under which the value is stored, if present. |
| 1730 | * |
| 1731 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 1732 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1733 | - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1734 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1735 | /** |
| 1736 | * Enumerates the keys and values on this dictionary with the given block. |
| 1737 | * |
| 1738 | * @note This method bypass the validationFunc to enable the access of values that |
| 1739 | * were not known at the time the binary was compiled. |
| 1740 | * |
| 1741 | * @param block The block to enumerate with. |
| 1742 | * **key**: The key for the current entry. |
| 1743 | * **rawValue**: The value for the current entry |
| 1744 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1745 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1746 | - (void)enumerateKeysAndRawValuesUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 1747 | (void (NS_NOESCAPE ^)(int32_t key, int32_t rawValue, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1748 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1749 | /** |
| 1750 | * Adds the keys and raw enum values from another dictionary. |
| 1751 | * |
| 1752 | * @note This method bypass the validationFunc to enable the setting of values that |
| 1753 | * were not known at the time the binary was compiled. |
| 1754 | * |
| 1755 | * @param otherDictionary Dictionary containing entries to be added to this |
| 1756 | * dictionary. |
| 1757 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1758 | - (void)addRawEntriesFromDictionary:(GPBInt32EnumDictionary *)otherDictionary; |
| 1759 | |
| 1760 | // If value is not a valid enumerator as defined by validationFunc, these |
| 1761 | // methods will assert in debug, and will log in release and assign the value |
| 1762 | // to the default value. Use the rawValue methods below to assign non enumerator |
| 1763 | // values. |
| 1764 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1765 | /** |
| 1766 | * Sets the value for the given key. |
| 1767 | * |
| 1768 | * @param value The value to set. |
| 1769 | * @param key The key under which to store the value. |
| 1770 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1771 | - (void)setEnum:(int32_t)value forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1772 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1773 | /** |
| 1774 | * Sets the raw enum value for the given key. |
| 1775 | * |
| 1776 | * @note This method bypass the validationFunc to enable the setting of values that |
| 1777 | * were not known at the time the binary was compiled. |
| 1778 | * |
| 1779 | * @param rawValue The raw enum value to set. |
| 1780 | * @param key The key under which to store the raw enum value. |
| 1781 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1782 | - (void)setRawValue:(int32_t)rawValue forKey:(int32_t)key; |
| 1783 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1784 | /** |
| 1785 | * Removes the entry for the given key. |
| 1786 | * |
| 1787 | * @param aKey Key to be removed from this dictionary. |
| 1788 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1789 | - (void)removeEnumForKey:(int32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1790 | |
| 1791 | /** |
| 1792 | * Removes all entries in this dictionary. |
| 1793 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1794 | - (void)removeAll; |
| 1795 | |
| 1796 | @end |
| 1797 | |
| 1798 | #pragma mark - Int32 -> Object |
| 1799 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1800 | /** |
| 1801 | * Class used for map fields of <int32_t, ObjectType> |
| 1802 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 1803 | * |
| 1804 | * @note This class is not meant to be subclassed. |
| 1805 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 1806 | @interface GPBInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying> |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1807 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1808 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1809 | @property(nonatomic, readonly) NSUInteger count; |
| 1810 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1811 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1812 | * Initializes this dictionary, copying the given values and keys. |
| 1813 | * |
| 1814 | * @param objects The values to be placed in this dictionary. |
| 1815 | * @param keys The keys under which to store the values. |
| 1816 | * @param count The number of elements to copy into the dictionary. |
| 1817 | * |
| 1818 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 1819 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1820 | - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects |
| 1821 | forKeys:(const int32_t [__nullable])keys |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 1822 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1823 | |
| 1824 | /** |
| 1825 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 1826 | * |
| 1827 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 1828 | * |
| 1829 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 1830 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1831 | - (instancetype)initWithDictionary:(GPBInt32ObjectDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1832 | |
| 1833 | /** |
| 1834 | * Initializes this dictionary with the requested capacity. |
| 1835 | * |
| 1836 | * @param numItems Number of items needed for this dictionary. |
| 1837 | * |
| 1838 | * @return A newly initialized dictionary with the requested capacity. |
| 1839 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1840 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 1841 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1842 | /** |
| 1843 | * Fetches the object stored under the given key. |
| 1844 | * |
| 1845 | * @param key Key under which the value is stored, if present. |
| 1846 | * |
| 1847 | * @return The object if found, nil otherwise. |
| 1848 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 1849 | - (ObjectType)objectForKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1850 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1851 | /** |
| 1852 | * Enumerates the keys and values on this dictionary with the given block. |
| 1853 | * |
| 1854 | * @param block The block to enumerate with. |
| 1855 | * **key**: The key for the current entry. |
| 1856 | * **object**: The value for the current entry |
| 1857 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1858 | **/ |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 1859 | - (void)enumerateKeysAndObjectsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 1860 | (void (NS_NOESCAPE ^)(int32_t key, ObjectType object, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1861 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1862 | /** |
| 1863 | * Adds the keys and values from another dictionary. |
| 1864 | * |
| 1865 | * @param otherDictionary Dictionary containing entries to be added to this |
| 1866 | * dictionary. |
| 1867 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1868 | - (void)addEntriesFromDictionary:(GPBInt32ObjectDictionary *)otherDictionary; |
| 1869 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1870 | /** |
| 1871 | * Sets the value for the given key. |
| 1872 | * |
| 1873 | * @param object The value to set. |
| 1874 | * @param key The key under which to store the value. |
| 1875 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 1876 | - (void)setObject:(ObjectType)object forKey:(int32_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1877 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1878 | /** |
| 1879 | * Removes the entry for the given key. |
| 1880 | * |
| 1881 | * @param aKey Key to be removed from this dictionary. |
| 1882 | **/ |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 1883 | - (void)removeObjectForKey:(int32_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1884 | |
| 1885 | /** |
| 1886 | * Removes all entries in this dictionary. |
| 1887 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1888 | - (void)removeAll; |
| 1889 | |
| 1890 | @end |
| 1891 | |
| 1892 | #pragma mark - UInt64 -> UInt32 |
| 1893 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1894 | /** |
| 1895 | * Class used for map fields of <uint64_t, uint32_t> |
| 1896 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 1897 | * |
| 1898 | * @note This class is not meant to be subclassed. |
| 1899 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1900 | @interface GPBUInt64UInt32Dictionary : NSObject <NSCopying> |
| 1901 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1902 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1903 | @property(nonatomic, readonly) NSUInteger count; |
| 1904 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1905 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1906 | * Initializes this dictionary, copying the given values and keys. |
| 1907 | * |
| 1908 | * @param values The values to be placed in this dictionary. |
| 1909 | * @param keys The keys under which to store the values. |
| 1910 | * @param count The number of elements to copy into the dictionary. |
| 1911 | * |
| 1912 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 1913 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1914 | - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values |
| 1915 | forKeys:(const uint64_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1916 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1917 | |
| 1918 | /** |
| 1919 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 1920 | * |
| 1921 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 1922 | * |
| 1923 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 1924 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1925 | - (instancetype)initWithDictionary:(GPBUInt64UInt32Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1926 | |
| 1927 | /** |
| 1928 | * Initializes this dictionary with the requested capacity. |
| 1929 | * |
| 1930 | * @param numItems Number of items needed for this dictionary. |
| 1931 | * |
| 1932 | * @return A newly initialized dictionary with the requested capacity. |
| 1933 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1934 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 1935 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1936 | /** |
| 1937 | * Gets the value for the given key. |
| 1938 | * |
| 1939 | * @param value Pointer into which the value will be set, if found. |
| 1940 | * @param key Key under which the value is stored, if present. |
| 1941 | * |
| 1942 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 1943 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1944 | - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1945 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1946 | /** |
| 1947 | * Enumerates the keys and values on this dictionary with the given block. |
| 1948 | * |
| 1949 | * @param block The block to enumerate with. |
| 1950 | * **key**: The key for the current entry. |
| 1951 | * **value**: The value for the current entry |
| 1952 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1953 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1954 | - (void)enumerateKeysAndUInt32sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 1955 | (void (NS_NOESCAPE ^)(uint64_t key, uint32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1956 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1957 | /** |
| 1958 | * Adds the keys and values from another dictionary. |
| 1959 | * |
| 1960 | * @param otherDictionary Dictionary containing entries to be added to this |
| 1961 | * dictionary. |
| 1962 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1963 | - (void)addEntriesFromDictionary:(GPBUInt64UInt32Dictionary *)otherDictionary; |
| 1964 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1965 | /** |
| 1966 | * Sets the value for the given key. |
| 1967 | * |
| 1968 | * @param value The value to set. |
| 1969 | * @param key The key under which to store the value. |
| 1970 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1971 | - (void)setUInt32:(uint32_t)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1972 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1973 | /** |
| 1974 | * Removes the entry for the given key. |
| 1975 | * |
| 1976 | * @param aKey Key to be removed from this dictionary. |
| 1977 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 1978 | - (void)removeUInt32ForKey:(uint64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1979 | |
| 1980 | /** |
| 1981 | * Removes all entries in this dictionary. |
| 1982 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1983 | - (void)removeAll; |
| 1984 | |
| 1985 | @end |
| 1986 | |
| 1987 | #pragma mark - UInt64 -> Int32 |
| 1988 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1989 | /** |
| 1990 | * Class used for map fields of <uint64_t, int32_t> |
| 1991 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 1992 | * |
| 1993 | * @note This class is not meant to be subclassed. |
| 1994 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1995 | @interface GPBUInt64Int32Dictionary : NSObject <NSCopying> |
| 1996 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1997 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1998 | @property(nonatomic, readonly) NSUInteger count; |
| 1999 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2000 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2001 | * Initializes this dictionary, copying the given values and keys. |
| 2002 | * |
| 2003 | * @param values The values to be placed in this dictionary. |
| 2004 | * @param keys The keys under which to store the values. |
| 2005 | * @param count The number of elements to copy into the dictionary. |
| 2006 | * |
| 2007 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 2008 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 2009 | - (instancetype)initWithInt32s:(const int32_t [__nullable])values |
| 2010 | forKeys:(const uint64_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2011 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2012 | |
| 2013 | /** |
| 2014 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 2015 | * |
| 2016 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 2017 | * |
| 2018 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 2019 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2020 | - (instancetype)initWithDictionary:(GPBUInt64Int32Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2021 | |
| 2022 | /** |
| 2023 | * Initializes this dictionary with the requested capacity. |
| 2024 | * |
| 2025 | * @param numItems Number of items needed for this dictionary. |
| 2026 | * |
| 2027 | * @return A newly initialized dictionary with the requested capacity. |
| 2028 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2029 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 2030 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2031 | /** |
| 2032 | * Gets the value for the given key. |
| 2033 | * |
| 2034 | * @param value Pointer into which the value will be set, if found. |
| 2035 | * @param key Key under which the value is stored, if present. |
| 2036 | * |
| 2037 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 2038 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2039 | - (BOOL)getInt32:(nullable int32_t *)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2040 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2041 | /** |
| 2042 | * Enumerates the keys and values on this dictionary with the given block. |
| 2043 | * |
| 2044 | * @param block The block to enumerate with. |
| 2045 | * **key**: The key for the current entry. |
| 2046 | * **value**: The value for the current entry |
| 2047 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 2048 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2049 | - (void)enumerateKeysAndInt32sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 2050 | (void (NS_NOESCAPE ^)(uint64_t key, int32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2051 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2052 | /** |
| 2053 | * Adds the keys and values from another dictionary. |
| 2054 | * |
| 2055 | * @param otherDictionary Dictionary containing entries to be added to this |
| 2056 | * dictionary. |
| 2057 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2058 | - (void)addEntriesFromDictionary:(GPBUInt64Int32Dictionary *)otherDictionary; |
| 2059 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2060 | /** |
| 2061 | * Sets the value for the given key. |
| 2062 | * |
| 2063 | * @param value The value to set. |
| 2064 | * @param key The key under which to store the value. |
| 2065 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2066 | - (void)setInt32:(int32_t)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2067 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2068 | /** |
| 2069 | * Removes the entry for the given key. |
| 2070 | * |
| 2071 | * @param aKey Key to be removed from this dictionary. |
| 2072 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2073 | - (void)removeInt32ForKey:(uint64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2074 | |
| 2075 | /** |
| 2076 | * Removes all entries in this dictionary. |
| 2077 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2078 | - (void)removeAll; |
| 2079 | |
| 2080 | @end |
| 2081 | |
| 2082 | #pragma mark - UInt64 -> UInt64 |
| 2083 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2084 | /** |
| 2085 | * Class used for map fields of <uint64_t, uint64_t> |
| 2086 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 2087 | * |
| 2088 | * @note This class is not meant to be subclassed. |
| 2089 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2090 | @interface GPBUInt64UInt64Dictionary : NSObject <NSCopying> |
| 2091 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2092 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2093 | @property(nonatomic, readonly) NSUInteger count; |
| 2094 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2095 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2096 | * Initializes this dictionary, copying the given values and keys. |
| 2097 | * |
| 2098 | * @param values The values to be placed in this dictionary. |
| 2099 | * @param keys The keys under which to store the values. |
| 2100 | * @param count The number of elements to copy into the dictionary. |
| 2101 | * |
| 2102 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 2103 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 2104 | - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values |
| 2105 | forKeys:(const uint64_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2106 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2107 | |
| 2108 | /** |
| 2109 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 2110 | * |
| 2111 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 2112 | * |
| 2113 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 2114 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2115 | - (instancetype)initWithDictionary:(GPBUInt64UInt64Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2116 | |
| 2117 | /** |
| 2118 | * Initializes this dictionary with the requested capacity. |
| 2119 | * |
| 2120 | * @param numItems Number of items needed for this dictionary. |
| 2121 | * |
| 2122 | * @return A newly initialized dictionary with the requested capacity. |
| 2123 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2124 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 2125 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2126 | /** |
| 2127 | * Gets the value for the given key. |
| 2128 | * |
| 2129 | * @param value Pointer into which the value will be set, if found. |
| 2130 | * @param key Key under which the value is stored, if present. |
| 2131 | * |
| 2132 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 2133 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2134 | - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2135 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2136 | /** |
| 2137 | * Enumerates the keys and values on this dictionary with the given block. |
| 2138 | * |
| 2139 | * @param block The block to enumerate with. |
| 2140 | * **key**: The key for the current entry. |
| 2141 | * **value**: The value for the current entry |
| 2142 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 2143 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2144 | - (void)enumerateKeysAndUInt64sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 2145 | (void (NS_NOESCAPE ^)(uint64_t key, uint64_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2146 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2147 | /** |
| 2148 | * Adds the keys and values from another dictionary. |
| 2149 | * |
| 2150 | * @param otherDictionary Dictionary containing entries to be added to this |
| 2151 | * dictionary. |
| 2152 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2153 | - (void)addEntriesFromDictionary:(GPBUInt64UInt64Dictionary *)otherDictionary; |
| 2154 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2155 | /** |
| 2156 | * Sets the value for the given key. |
| 2157 | * |
| 2158 | * @param value The value to set. |
| 2159 | * @param key The key under which to store the value. |
| 2160 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2161 | - (void)setUInt64:(uint64_t)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2162 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2163 | /** |
| 2164 | * Removes the entry for the given key. |
| 2165 | * |
| 2166 | * @param aKey Key to be removed from this dictionary. |
| 2167 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2168 | - (void)removeUInt64ForKey:(uint64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2169 | |
| 2170 | /** |
| 2171 | * Removes all entries in this dictionary. |
| 2172 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2173 | - (void)removeAll; |
| 2174 | |
| 2175 | @end |
| 2176 | |
| 2177 | #pragma mark - UInt64 -> Int64 |
| 2178 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2179 | /** |
| 2180 | * Class used for map fields of <uint64_t, int64_t> |
| 2181 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 2182 | * |
| 2183 | * @note This class is not meant to be subclassed. |
| 2184 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2185 | @interface GPBUInt64Int64Dictionary : NSObject <NSCopying> |
| 2186 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2187 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2188 | @property(nonatomic, readonly) NSUInteger count; |
| 2189 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2190 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2191 | * Initializes this dictionary, copying the given values and keys. |
| 2192 | * |
| 2193 | * @param values The values to be placed in this dictionary. |
| 2194 | * @param keys The keys under which to store the values. |
| 2195 | * @param count The number of elements to copy into the dictionary. |
| 2196 | * |
| 2197 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 2198 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 2199 | - (instancetype)initWithInt64s:(const int64_t [__nullable])values |
| 2200 | forKeys:(const uint64_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2201 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2202 | |
| 2203 | /** |
| 2204 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 2205 | * |
| 2206 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 2207 | * |
| 2208 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 2209 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2210 | - (instancetype)initWithDictionary:(GPBUInt64Int64Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2211 | |
| 2212 | /** |
| 2213 | * Initializes this dictionary with the requested capacity. |
| 2214 | * |
| 2215 | * @param numItems Number of items needed for this dictionary. |
| 2216 | * |
| 2217 | * @return A newly initialized dictionary with the requested capacity. |
| 2218 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2219 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 2220 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2221 | /** |
| 2222 | * Gets the value for the given key. |
| 2223 | * |
| 2224 | * @param value Pointer into which the value will be set, if found. |
| 2225 | * @param key Key under which the value is stored, if present. |
| 2226 | * |
| 2227 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 2228 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2229 | - (BOOL)getInt64:(nullable int64_t *)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2230 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2231 | /** |
| 2232 | * Enumerates the keys and values on this dictionary with the given block. |
| 2233 | * |
| 2234 | * @param block The block to enumerate with. |
| 2235 | * **key**: The key for the current entry. |
| 2236 | * **value**: The value for the current entry |
| 2237 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 2238 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2239 | - (void)enumerateKeysAndInt64sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 2240 | (void (NS_NOESCAPE ^)(uint64_t key, int64_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2241 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2242 | /** |
| 2243 | * Adds the keys and values from another dictionary. |
| 2244 | * |
| 2245 | * @param otherDictionary Dictionary containing entries to be added to this |
| 2246 | * dictionary. |
| 2247 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2248 | - (void)addEntriesFromDictionary:(GPBUInt64Int64Dictionary *)otherDictionary; |
| 2249 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2250 | /** |
| 2251 | * Sets the value for the given key. |
| 2252 | * |
| 2253 | * @param value The value to set. |
| 2254 | * @param key The key under which to store the value. |
| 2255 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2256 | - (void)setInt64:(int64_t)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2257 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2258 | /** |
| 2259 | * Removes the entry for the given key. |
| 2260 | * |
| 2261 | * @param aKey Key to be removed from this dictionary. |
| 2262 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2263 | - (void)removeInt64ForKey:(uint64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2264 | |
| 2265 | /** |
| 2266 | * Removes all entries in this dictionary. |
| 2267 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2268 | - (void)removeAll; |
| 2269 | |
| 2270 | @end |
| 2271 | |
| 2272 | #pragma mark - UInt64 -> Bool |
| 2273 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2274 | /** |
| 2275 | * Class used for map fields of <uint64_t, BOOL> |
| 2276 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 2277 | * |
| 2278 | * @note This class is not meant to be subclassed. |
| 2279 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2280 | @interface GPBUInt64BoolDictionary : NSObject <NSCopying> |
| 2281 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2282 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2283 | @property(nonatomic, readonly) NSUInteger count; |
| 2284 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2285 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2286 | * Initializes this dictionary, copying the given values and keys. |
| 2287 | * |
| 2288 | * @param values The values to be placed in this dictionary. |
| 2289 | * @param keys The keys under which to store the values. |
| 2290 | * @param count The number of elements to copy into the dictionary. |
| 2291 | * |
| 2292 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 2293 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 2294 | - (instancetype)initWithBools:(const BOOL [__nullable])values |
| 2295 | forKeys:(const uint64_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2296 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2297 | |
| 2298 | /** |
| 2299 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 2300 | * |
| 2301 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 2302 | * |
| 2303 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 2304 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2305 | - (instancetype)initWithDictionary:(GPBUInt64BoolDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2306 | |
| 2307 | /** |
| 2308 | * Initializes this dictionary with the requested capacity. |
| 2309 | * |
| 2310 | * @param numItems Number of items needed for this dictionary. |
| 2311 | * |
| 2312 | * @return A newly initialized dictionary with the requested capacity. |
| 2313 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2314 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 2315 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2316 | /** |
| 2317 | * Gets the value for the given key. |
| 2318 | * |
| 2319 | * @param value Pointer into which the value will be set, if found. |
| 2320 | * @param key Key under which the value is stored, if present. |
| 2321 | * |
| 2322 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 2323 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2324 | - (BOOL)getBool:(nullable BOOL *)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2325 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2326 | /** |
| 2327 | * Enumerates the keys and values on this dictionary with the given block. |
| 2328 | * |
| 2329 | * @param block The block to enumerate with. |
| 2330 | * **key**: The key for the current entry. |
| 2331 | * **value**: The value for the current entry |
| 2332 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 2333 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2334 | - (void)enumerateKeysAndBoolsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 2335 | (void (NS_NOESCAPE ^)(uint64_t key, BOOL value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2336 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2337 | /** |
| 2338 | * Adds the keys and values from another dictionary. |
| 2339 | * |
| 2340 | * @param otherDictionary Dictionary containing entries to be added to this |
| 2341 | * dictionary. |
| 2342 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2343 | - (void)addEntriesFromDictionary:(GPBUInt64BoolDictionary *)otherDictionary; |
| 2344 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2345 | /** |
| 2346 | * Sets the value for the given key. |
| 2347 | * |
| 2348 | * @param value The value to set. |
| 2349 | * @param key The key under which to store the value. |
| 2350 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2351 | - (void)setBool:(BOOL)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2352 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2353 | /** |
| 2354 | * Removes the entry for the given key. |
| 2355 | * |
| 2356 | * @param aKey Key to be removed from this dictionary. |
| 2357 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2358 | - (void)removeBoolForKey:(uint64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2359 | |
| 2360 | /** |
| 2361 | * Removes all entries in this dictionary. |
| 2362 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2363 | - (void)removeAll; |
| 2364 | |
| 2365 | @end |
| 2366 | |
| 2367 | #pragma mark - UInt64 -> Float |
| 2368 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2369 | /** |
| 2370 | * Class used for map fields of <uint64_t, float> |
| 2371 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 2372 | * |
| 2373 | * @note This class is not meant to be subclassed. |
| 2374 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2375 | @interface GPBUInt64FloatDictionary : NSObject <NSCopying> |
| 2376 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2377 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2378 | @property(nonatomic, readonly) NSUInteger count; |
| 2379 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2380 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2381 | * Initializes this dictionary, copying the given values and keys. |
| 2382 | * |
| 2383 | * @param values The values to be placed in this dictionary. |
| 2384 | * @param keys The keys under which to store the values. |
| 2385 | * @param count The number of elements to copy into the dictionary. |
| 2386 | * |
| 2387 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 2388 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 2389 | - (instancetype)initWithFloats:(const float [__nullable])values |
| 2390 | forKeys:(const uint64_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2391 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2392 | |
| 2393 | /** |
| 2394 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 2395 | * |
| 2396 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 2397 | * |
| 2398 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 2399 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2400 | - (instancetype)initWithDictionary:(GPBUInt64FloatDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2401 | |
| 2402 | /** |
| 2403 | * Initializes this dictionary with the requested capacity. |
| 2404 | * |
| 2405 | * @param numItems Number of items needed for this dictionary. |
| 2406 | * |
| 2407 | * @return A newly initialized dictionary with the requested capacity. |
| 2408 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2409 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 2410 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2411 | /** |
| 2412 | * Gets the value for the given key. |
| 2413 | * |
| 2414 | * @param value Pointer into which the value will be set, if found. |
| 2415 | * @param key Key under which the value is stored, if present. |
| 2416 | * |
| 2417 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 2418 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2419 | - (BOOL)getFloat:(nullable float *)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2420 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2421 | /** |
| 2422 | * Enumerates the keys and values on this dictionary with the given block. |
| 2423 | * |
| 2424 | * @param block The block to enumerate with. |
| 2425 | * **key**: The key for the current entry. |
| 2426 | * **value**: The value for the current entry |
| 2427 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 2428 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2429 | - (void)enumerateKeysAndFloatsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 2430 | (void (NS_NOESCAPE ^)(uint64_t key, float value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2431 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2432 | /** |
| 2433 | * Adds the keys and values from another dictionary. |
| 2434 | * |
| 2435 | * @param otherDictionary Dictionary containing entries to be added to this |
| 2436 | * dictionary. |
| 2437 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2438 | - (void)addEntriesFromDictionary:(GPBUInt64FloatDictionary *)otherDictionary; |
| 2439 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2440 | /** |
| 2441 | * Sets the value for the given key. |
| 2442 | * |
| 2443 | * @param value The value to set. |
| 2444 | * @param key The key under which to store the value. |
| 2445 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2446 | - (void)setFloat:(float)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2447 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2448 | /** |
| 2449 | * Removes the entry for the given key. |
| 2450 | * |
| 2451 | * @param aKey Key to be removed from this dictionary. |
| 2452 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2453 | - (void)removeFloatForKey:(uint64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2454 | |
| 2455 | /** |
| 2456 | * Removes all entries in this dictionary. |
| 2457 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2458 | - (void)removeAll; |
| 2459 | |
| 2460 | @end |
| 2461 | |
| 2462 | #pragma mark - UInt64 -> Double |
| 2463 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2464 | /** |
| 2465 | * Class used for map fields of <uint64_t, double> |
| 2466 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 2467 | * |
| 2468 | * @note This class is not meant to be subclassed. |
| 2469 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2470 | @interface GPBUInt64DoubleDictionary : NSObject <NSCopying> |
| 2471 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2472 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2473 | @property(nonatomic, readonly) NSUInteger count; |
| 2474 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2475 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2476 | * Initializes this dictionary, copying the given values and keys. |
| 2477 | * |
| 2478 | * @param values The values to be placed in this dictionary. |
| 2479 | * @param keys The keys under which to store the values. |
| 2480 | * @param count The number of elements to copy into the dictionary. |
| 2481 | * |
| 2482 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 2483 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 2484 | - (instancetype)initWithDoubles:(const double [__nullable])values |
| 2485 | forKeys:(const uint64_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2486 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2487 | |
| 2488 | /** |
| 2489 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 2490 | * |
| 2491 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 2492 | * |
| 2493 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 2494 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2495 | - (instancetype)initWithDictionary:(GPBUInt64DoubleDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2496 | |
| 2497 | /** |
| 2498 | * Initializes this dictionary with the requested capacity. |
| 2499 | * |
| 2500 | * @param numItems Number of items needed for this dictionary. |
| 2501 | * |
| 2502 | * @return A newly initialized dictionary with the requested capacity. |
| 2503 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2504 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 2505 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2506 | /** |
| 2507 | * Gets the value for the given key. |
| 2508 | * |
| 2509 | * @param value Pointer into which the value will be set, if found. |
| 2510 | * @param key Key under which the value is stored, if present. |
| 2511 | * |
| 2512 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 2513 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2514 | - (BOOL)getDouble:(nullable double *)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2515 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2516 | /** |
| 2517 | * Enumerates the keys and values on this dictionary with the given block. |
| 2518 | * |
| 2519 | * @param block The block to enumerate with. |
| 2520 | * **key**: The key for the current entry. |
| 2521 | * **value**: The value for the current entry |
| 2522 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 2523 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2524 | - (void)enumerateKeysAndDoublesUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 2525 | (void (NS_NOESCAPE ^)(uint64_t key, double value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2526 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2527 | /** |
| 2528 | * Adds the keys and values from another dictionary. |
| 2529 | * |
| 2530 | * @param otherDictionary Dictionary containing entries to be added to this |
| 2531 | * dictionary. |
| 2532 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2533 | - (void)addEntriesFromDictionary:(GPBUInt64DoubleDictionary *)otherDictionary; |
| 2534 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2535 | /** |
| 2536 | * Sets the value for the given key. |
| 2537 | * |
| 2538 | * @param value The value to set. |
| 2539 | * @param key The key under which to store the value. |
| 2540 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2541 | - (void)setDouble:(double)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2542 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2543 | /** |
| 2544 | * Removes the entry for the given key. |
| 2545 | * |
| 2546 | * @param aKey Key to be removed from this dictionary. |
| 2547 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2548 | - (void)removeDoubleForKey:(uint64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2549 | |
| 2550 | /** |
| 2551 | * Removes all entries in this dictionary. |
| 2552 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2553 | - (void)removeAll; |
| 2554 | |
| 2555 | @end |
| 2556 | |
| 2557 | #pragma mark - UInt64 -> Enum |
| 2558 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2559 | /** |
| 2560 | * Class used for map fields of <uint64_t, int32_t> |
| 2561 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 2562 | * |
| 2563 | * @note This class is not meant to be subclassed. |
| 2564 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2565 | @interface GPBUInt64EnumDictionary : NSObject <NSCopying> |
| 2566 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2567 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2568 | @property(nonatomic, readonly) NSUInteger count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2569 | /** The validation function to check if the enums are valid. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2570 | @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; |
| 2571 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2572 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2573 | * Initializes a dictionary with the given validation function. |
| 2574 | * |
| 2575 | * @param func The enum validation function for the dictionary. |
| 2576 | * |
| 2577 | * @return A newly initialized dictionary. |
| 2578 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 2579 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2580 | |
| 2581 | /** |
| 2582 | * Initializes a dictionary with the entries given. |
| 2583 | * |
| 2584 | * @param func The enum validation function for the dictionary. |
| 2585 | * @param values The raw enum values values to be placed in the dictionary. |
| 2586 | * @param keys The keys under which to store the values. |
| 2587 | * @param count The number of entries to store in the dictionary. |
| 2588 | * |
| 2589 | * @return A newly initialized dictionary with the keys and values in it. |
| 2590 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 2591 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 2592 | rawValues:(const int32_t [__nullable])values |
| 2593 | forKeys:(const uint64_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2594 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2595 | |
| 2596 | /** |
| 2597 | * Initializes a dictionary with the entries from the given. |
| 2598 | * dictionary. |
| 2599 | * |
| 2600 | * @param dictionary Dictionary containing the entries to add to the dictionary. |
| 2601 | * |
| 2602 | * @return A newly initialized dictionary with the entries from the given |
| 2603 | * dictionary in it. |
| 2604 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2605 | - (instancetype)initWithDictionary:(GPBUInt64EnumDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2606 | |
| 2607 | /** |
| 2608 | * Initializes a dictionary with the given capacity. |
| 2609 | * |
| 2610 | * @param func The enum validation function for the dictionary. |
| 2611 | * @param numItems Capacity needed for the dictionary. |
| 2612 | * |
| 2613 | * @return A newly initialized dictionary with the given capacity. |
| 2614 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 2615 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2616 | capacity:(NSUInteger)numItems; |
| 2617 | |
| 2618 | // These will return kGPBUnrecognizedEnumeratorValue if the value for the key |
| 2619 | // is not a valid enumerator as defined by validationFunc. If the actual value is |
| 2620 | // desired, use "raw" version of the method. |
| 2621 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2622 | /** |
| 2623 | * Gets the value for the given key. |
| 2624 | * |
| 2625 | * @param value Pointer into which the value will be set, if found. |
| 2626 | * @param key Key under which the value is stored, if present. |
| 2627 | * |
| 2628 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 2629 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2630 | - (BOOL)getEnum:(nullable int32_t *)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2631 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2632 | /** |
| 2633 | * Enumerates the keys and values on this dictionary with the given block. |
| 2634 | * |
| 2635 | * @param block The block to enumerate with. |
| 2636 | * **key**: The key for the current entry. |
| 2637 | * **value**: The value for the current entry |
| 2638 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 2639 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2640 | - (void)enumerateKeysAndEnumsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 2641 | (void (NS_NOESCAPE ^)(uint64_t key, int32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2642 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2643 | /** |
| 2644 | * Gets the raw enum value for the given key. |
| 2645 | * |
| 2646 | * @note This method bypass the validationFunc to enable the access of values that |
| 2647 | * were not known at the time the binary was compiled. |
| 2648 | * |
| 2649 | * @param rawValue Pointer into which the value will be set, if found. |
| 2650 | * @param key Key under which the value is stored, if present. |
| 2651 | * |
| 2652 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 2653 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2654 | - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2655 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2656 | /** |
| 2657 | * Enumerates the keys and values on this dictionary with the given block. |
| 2658 | * |
| 2659 | * @note This method bypass the validationFunc to enable the access of values that |
| 2660 | * were not known at the time the binary was compiled. |
| 2661 | * |
| 2662 | * @param block The block to enumerate with. |
| 2663 | * **key**: The key for the current entry. |
| 2664 | * **rawValue**: The value for the current entry |
| 2665 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 2666 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2667 | - (void)enumerateKeysAndRawValuesUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 2668 | (void (NS_NOESCAPE ^)(uint64_t key, int32_t rawValue, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2669 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2670 | /** |
| 2671 | * Adds the keys and raw enum values from another dictionary. |
| 2672 | * |
| 2673 | * @note This method bypass the validationFunc to enable the setting of values that |
| 2674 | * were not known at the time the binary was compiled. |
| 2675 | * |
| 2676 | * @param otherDictionary Dictionary containing entries to be added to this |
| 2677 | * dictionary. |
| 2678 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2679 | - (void)addRawEntriesFromDictionary:(GPBUInt64EnumDictionary *)otherDictionary; |
| 2680 | |
| 2681 | // If value is not a valid enumerator as defined by validationFunc, these |
| 2682 | // methods will assert in debug, and will log in release and assign the value |
| 2683 | // to the default value. Use the rawValue methods below to assign non enumerator |
| 2684 | // values. |
| 2685 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2686 | /** |
| 2687 | * Sets the value for the given key. |
| 2688 | * |
| 2689 | * @param value The value to set. |
| 2690 | * @param key The key under which to store the value. |
| 2691 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2692 | - (void)setEnum:(int32_t)value forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2693 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2694 | /** |
| 2695 | * Sets the raw enum value for the given key. |
| 2696 | * |
| 2697 | * @note This method bypass the validationFunc to enable the setting of values that |
| 2698 | * were not known at the time the binary was compiled. |
| 2699 | * |
| 2700 | * @param rawValue The raw enum value to set. |
| 2701 | * @param key The key under which to store the raw enum value. |
| 2702 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2703 | - (void)setRawValue:(int32_t)rawValue forKey:(uint64_t)key; |
| 2704 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2705 | /** |
| 2706 | * Removes the entry for the given key. |
| 2707 | * |
| 2708 | * @param aKey Key to be removed from this dictionary. |
| 2709 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2710 | - (void)removeEnumForKey:(uint64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2711 | |
| 2712 | /** |
| 2713 | * Removes all entries in this dictionary. |
| 2714 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2715 | - (void)removeAll; |
| 2716 | |
| 2717 | @end |
| 2718 | |
| 2719 | #pragma mark - UInt64 -> Object |
| 2720 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2721 | /** |
| 2722 | * Class used for map fields of <uint64_t, ObjectType> |
| 2723 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 2724 | * |
| 2725 | * @note This class is not meant to be subclassed. |
| 2726 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 2727 | @interface GPBUInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying> |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2728 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2729 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2730 | @property(nonatomic, readonly) NSUInteger count; |
| 2731 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2732 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2733 | * Initializes this dictionary, copying the given values and keys. |
| 2734 | * |
| 2735 | * @param objects The values to be placed in this dictionary. |
| 2736 | * @param keys The keys under which to store the values. |
| 2737 | * @param count The number of elements to copy into the dictionary. |
| 2738 | * |
| 2739 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 2740 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 2741 | - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects |
| 2742 | forKeys:(const uint64_t [__nullable])keys |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 2743 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2744 | |
| 2745 | /** |
| 2746 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 2747 | * |
| 2748 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 2749 | * |
| 2750 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 2751 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2752 | - (instancetype)initWithDictionary:(GPBUInt64ObjectDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2753 | |
| 2754 | /** |
| 2755 | * Initializes this dictionary with the requested capacity. |
| 2756 | * |
| 2757 | * @param numItems Number of items needed for this dictionary. |
| 2758 | * |
| 2759 | * @return A newly initialized dictionary with the requested capacity. |
| 2760 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2761 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 2762 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2763 | /** |
| 2764 | * Fetches the object stored under the given key. |
| 2765 | * |
| 2766 | * @param key Key under which the value is stored, if present. |
| 2767 | * |
| 2768 | * @return The object if found, nil otherwise. |
| 2769 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 2770 | - (ObjectType)objectForKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2771 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2772 | /** |
| 2773 | * Enumerates the keys and values on this dictionary with the given block. |
| 2774 | * |
| 2775 | * @param block The block to enumerate with. |
| 2776 | * **key**: The key for the current entry. |
| 2777 | * **object**: The value for the current entry |
| 2778 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 2779 | **/ |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 2780 | - (void)enumerateKeysAndObjectsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 2781 | (void (NS_NOESCAPE ^)(uint64_t key, ObjectType object, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2782 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2783 | /** |
| 2784 | * Adds the keys and values from another dictionary. |
| 2785 | * |
| 2786 | * @param otherDictionary Dictionary containing entries to be added to this |
| 2787 | * dictionary. |
| 2788 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2789 | - (void)addEntriesFromDictionary:(GPBUInt64ObjectDictionary *)otherDictionary; |
| 2790 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2791 | /** |
| 2792 | * Sets the value for the given key. |
| 2793 | * |
| 2794 | * @param object The value to set. |
| 2795 | * @param key The key under which to store the value. |
| 2796 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 2797 | - (void)setObject:(ObjectType)object forKey:(uint64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2798 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2799 | /** |
| 2800 | * Removes the entry for the given key. |
| 2801 | * |
| 2802 | * @param aKey Key to be removed from this dictionary. |
| 2803 | **/ |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 2804 | - (void)removeObjectForKey:(uint64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2805 | |
| 2806 | /** |
| 2807 | * Removes all entries in this dictionary. |
| 2808 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2809 | - (void)removeAll; |
| 2810 | |
| 2811 | @end |
| 2812 | |
| 2813 | #pragma mark - Int64 -> UInt32 |
| 2814 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2815 | /** |
| 2816 | * Class used for map fields of <int64_t, uint32_t> |
| 2817 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 2818 | * |
| 2819 | * @note This class is not meant to be subclassed. |
| 2820 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2821 | @interface GPBInt64UInt32Dictionary : NSObject <NSCopying> |
| 2822 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2823 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2824 | @property(nonatomic, readonly) NSUInteger count; |
| 2825 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2826 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2827 | * Initializes this dictionary, copying the given values and keys. |
| 2828 | * |
| 2829 | * @param values The values to be placed in this dictionary. |
| 2830 | * @param keys The keys under which to store the values. |
| 2831 | * @param count The number of elements to copy into the dictionary. |
| 2832 | * |
| 2833 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 2834 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 2835 | - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values |
| 2836 | forKeys:(const int64_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2837 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2838 | |
| 2839 | /** |
| 2840 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 2841 | * |
| 2842 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 2843 | * |
| 2844 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 2845 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2846 | - (instancetype)initWithDictionary:(GPBInt64UInt32Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2847 | |
| 2848 | /** |
| 2849 | * Initializes this dictionary with the requested capacity. |
| 2850 | * |
| 2851 | * @param numItems Number of items needed for this dictionary. |
| 2852 | * |
| 2853 | * @return A newly initialized dictionary with the requested capacity. |
| 2854 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2855 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 2856 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2857 | /** |
| 2858 | * Gets the value for the given key. |
| 2859 | * |
| 2860 | * @param value Pointer into which the value will be set, if found. |
| 2861 | * @param key Key under which the value is stored, if present. |
| 2862 | * |
| 2863 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 2864 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2865 | - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2866 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2867 | /** |
| 2868 | * Enumerates the keys and values on this dictionary with the given block. |
| 2869 | * |
| 2870 | * @param block The block to enumerate with. |
| 2871 | * **key**: The key for the current entry. |
| 2872 | * **value**: The value for the current entry |
| 2873 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 2874 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2875 | - (void)enumerateKeysAndUInt32sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 2876 | (void (NS_NOESCAPE ^)(int64_t key, uint32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2877 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2878 | /** |
| 2879 | * Adds the keys and values from another dictionary. |
| 2880 | * |
| 2881 | * @param otherDictionary Dictionary containing entries to be added to this |
| 2882 | * dictionary. |
| 2883 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2884 | - (void)addEntriesFromDictionary:(GPBInt64UInt32Dictionary *)otherDictionary; |
| 2885 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2886 | /** |
| 2887 | * Sets the value for the given key. |
| 2888 | * |
| 2889 | * @param value The value to set. |
| 2890 | * @param key The key under which to store the value. |
| 2891 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2892 | - (void)setUInt32:(uint32_t)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2893 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2894 | /** |
| 2895 | * Removes the entry for the given key. |
| 2896 | * |
| 2897 | * @param aKey Key to be removed from this dictionary. |
| 2898 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2899 | - (void)removeUInt32ForKey:(int64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2900 | |
| 2901 | /** |
| 2902 | * Removes all entries in this dictionary. |
| 2903 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2904 | - (void)removeAll; |
| 2905 | |
| 2906 | @end |
| 2907 | |
| 2908 | #pragma mark - Int64 -> Int32 |
| 2909 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2910 | /** |
| 2911 | * Class used for map fields of <int64_t, int32_t> |
| 2912 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 2913 | * |
| 2914 | * @note This class is not meant to be subclassed. |
| 2915 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2916 | @interface GPBInt64Int32Dictionary : NSObject <NSCopying> |
| 2917 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2918 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2919 | @property(nonatomic, readonly) NSUInteger count; |
| 2920 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2921 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2922 | * Initializes this dictionary, copying the given values and keys. |
| 2923 | * |
| 2924 | * @param values The values to be placed in this dictionary. |
| 2925 | * @param keys The keys under which to store the values. |
| 2926 | * @param count The number of elements to copy into the dictionary. |
| 2927 | * |
| 2928 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 2929 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 2930 | - (instancetype)initWithInt32s:(const int32_t [__nullable])values |
| 2931 | forKeys:(const int64_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2932 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2933 | |
| 2934 | /** |
| 2935 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 2936 | * |
| 2937 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 2938 | * |
| 2939 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 2940 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2941 | - (instancetype)initWithDictionary:(GPBInt64Int32Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2942 | |
| 2943 | /** |
| 2944 | * Initializes this dictionary with the requested capacity. |
| 2945 | * |
| 2946 | * @param numItems Number of items needed for this dictionary. |
| 2947 | * |
| 2948 | * @return A newly initialized dictionary with the requested capacity. |
| 2949 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2950 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 2951 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2952 | /** |
| 2953 | * Gets the value for the given key. |
| 2954 | * |
| 2955 | * @param value Pointer into which the value will be set, if found. |
| 2956 | * @param key Key under which the value is stored, if present. |
| 2957 | * |
| 2958 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 2959 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2960 | - (BOOL)getInt32:(nullable int32_t *)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2961 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2962 | /** |
| 2963 | * Enumerates the keys and values on this dictionary with the given block. |
| 2964 | * |
| 2965 | * @param block The block to enumerate with. |
| 2966 | * **key**: The key for the current entry. |
| 2967 | * **value**: The value for the current entry |
| 2968 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 2969 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2970 | - (void)enumerateKeysAndInt32sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 2971 | (void (NS_NOESCAPE ^)(int64_t key, int32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2972 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2973 | /** |
| 2974 | * Adds the keys and values from another dictionary. |
| 2975 | * |
| 2976 | * @param otherDictionary Dictionary containing entries to be added to this |
| 2977 | * dictionary. |
| 2978 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2979 | - (void)addEntriesFromDictionary:(GPBInt64Int32Dictionary *)otherDictionary; |
| 2980 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2981 | /** |
| 2982 | * Sets the value for the given key. |
| 2983 | * |
| 2984 | * @param value The value to set. |
| 2985 | * @param key The key under which to store the value. |
| 2986 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2987 | - (void)setInt32:(int32_t)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2988 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2989 | /** |
| 2990 | * Removes the entry for the given key. |
| 2991 | * |
| 2992 | * @param aKey Key to be removed from this dictionary. |
| 2993 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 2994 | - (void)removeInt32ForKey:(int64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 2995 | |
| 2996 | /** |
| 2997 | * Removes all entries in this dictionary. |
| 2998 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 2999 | - (void)removeAll; |
| 3000 | |
| 3001 | @end |
| 3002 | |
| 3003 | #pragma mark - Int64 -> UInt64 |
| 3004 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3005 | /** |
| 3006 | * Class used for map fields of <int64_t, uint64_t> |
| 3007 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 3008 | * |
| 3009 | * @note This class is not meant to be subclassed. |
| 3010 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3011 | @interface GPBInt64UInt64Dictionary : NSObject <NSCopying> |
| 3012 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3013 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3014 | @property(nonatomic, readonly) NSUInteger count; |
| 3015 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3016 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3017 | * Initializes this dictionary, copying the given values and keys. |
| 3018 | * |
| 3019 | * @param values The values to be placed in this dictionary. |
| 3020 | * @param keys The keys under which to store the values. |
| 3021 | * @param count The number of elements to copy into the dictionary. |
| 3022 | * |
| 3023 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 3024 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 3025 | - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values |
| 3026 | forKeys:(const int64_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3027 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3028 | |
| 3029 | /** |
| 3030 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 3031 | * |
| 3032 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 3033 | * |
| 3034 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 3035 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3036 | - (instancetype)initWithDictionary:(GPBInt64UInt64Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3037 | |
| 3038 | /** |
| 3039 | * Initializes this dictionary with the requested capacity. |
| 3040 | * |
| 3041 | * @param numItems Number of items needed for this dictionary. |
| 3042 | * |
| 3043 | * @return A newly initialized dictionary with the requested capacity. |
| 3044 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3045 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 3046 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3047 | /** |
| 3048 | * Gets the value for the given key. |
| 3049 | * |
| 3050 | * @param value Pointer into which the value will be set, if found. |
| 3051 | * @param key Key under which the value is stored, if present. |
| 3052 | * |
| 3053 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 3054 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3055 | - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3056 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3057 | /** |
| 3058 | * Enumerates the keys and values on this dictionary with the given block. |
| 3059 | * |
| 3060 | * @param block The block to enumerate with. |
| 3061 | * **key**: The key for the current entry. |
| 3062 | * **value**: The value for the current entry |
| 3063 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 3064 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3065 | - (void)enumerateKeysAndUInt64sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 3066 | (void (NS_NOESCAPE ^)(int64_t key, uint64_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3067 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3068 | /** |
| 3069 | * Adds the keys and values from another dictionary. |
| 3070 | * |
| 3071 | * @param otherDictionary Dictionary containing entries to be added to this |
| 3072 | * dictionary. |
| 3073 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3074 | - (void)addEntriesFromDictionary:(GPBInt64UInt64Dictionary *)otherDictionary; |
| 3075 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3076 | /** |
| 3077 | * Sets the value for the given key. |
| 3078 | * |
| 3079 | * @param value The value to set. |
| 3080 | * @param key The key under which to store the value. |
| 3081 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3082 | - (void)setUInt64:(uint64_t)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3083 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3084 | /** |
| 3085 | * Removes the entry for the given key. |
| 3086 | * |
| 3087 | * @param aKey Key to be removed from this dictionary. |
| 3088 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3089 | - (void)removeUInt64ForKey:(int64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3090 | |
| 3091 | /** |
| 3092 | * Removes all entries in this dictionary. |
| 3093 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3094 | - (void)removeAll; |
| 3095 | |
| 3096 | @end |
| 3097 | |
| 3098 | #pragma mark - Int64 -> Int64 |
| 3099 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3100 | /** |
| 3101 | * Class used for map fields of <int64_t, int64_t> |
| 3102 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 3103 | * |
| 3104 | * @note This class is not meant to be subclassed. |
| 3105 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3106 | @interface GPBInt64Int64Dictionary : NSObject <NSCopying> |
| 3107 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3108 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3109 | @property(nonatomic, readonly) NSUInteger count; |
| 3110 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3111 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3112 | * Initializes this dictionary, copying the given values and keys. |
| 3113 | * |
| 3114 | * @param values The values to be placed in this dictionary. |
| 3115 | * @param keys The keys under which to store the values. |
| 3116 | * @param count The number of elements to copy into the dictionary. |
| 3117 | * |
| 3118 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 3119 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 3120 | - (instancetype)initWithInt64s:(const int64_t [__nullable])values |
| 3121 | forKeys:(const int64_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3122 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3123 | |
| 3124 | /** |
| 3125 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 3126 | * |
| 3127 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 3128 | * |
| 3129 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 3130 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3131 | - (instancetype)initWithDictionary:(GPBInt64Int64Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3132 | |
| 3133 | /** |
| 3134 | * Initializes this dictionary with the requested capacity. |
| 3135 | * |
| 3136 | * @param numItems Number of items needed for this dictionary. |
| 3137 | * |
| 3138 | * @return A newly initialized dictionary with the requested capacity. |
| 3139 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3140 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 3141 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3142 | /** |
| 3143 | * Gets the value for the given key. |
| 3144 | * |
| 3145 | * @param value Pointer into which the value will be set, if found. |
| 3146 | * @param key Key under which the value is stored, if present. |
| 3147 | * |
| 3148 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 3149 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3150 | - (BOOL)getInt64:(nullable int64_t *)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3151 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3152 | /** |
| 3153 | * Enumerates the keys and values on this dictionary with the given block. |
| 3154 | * |
| 3155 | * @param block The block to enumerate with. |
| 3156 | * **key**: The key for the current entry. |
| 3157 | * **value**: The value for the current entry |
| 3158 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 3159 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3160 | - (void)enumerateKeysAndInt64sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 3161 | (void (NS_NOESCAPE ^)(int64_t key, int64_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3162 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3163 | /** |
| 3164 | * Adds the keys and values from another dictionary. |
| 3165 | * |
| 3166 | * @param otherDictionary Dictionary containing entries to be added to this |
| 3167 | * dictionary. |
| 3168 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3169 | - (void)addEntriesFromDictionary:(GPBInt64Int64Dictionary *)otherDictionary; |
| 3170 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3171 | /** |
| 3172 | * Sets the value for the given key. |
| 3173 | * |
| 3174 | * @param value The value to set. |
| 3175 | * @param key The key under which to store the value. |
| 3176 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3177 | - (void)setInt64:(int64_t)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3178 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3179 | /** |
| 3180 | * Removes the entry for the given key. |
| 3181 | * |
| 3182 | * @param aKey Key to be removed from this dictionary. |
| 3183 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3184 | - (void)removeInt64ForKey:(int64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3185 | |
| 3186 | /** |
| 3187 | * Removes all entries in this dictionary. |
| 3188 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3189 | - (void)removeAll; |
| 3190 | |
| 3191 | @end |
| 3192 | |
| 3193 | #pragma mark - Int64 -> Bool |
| 3194 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3195 | /** |
| 3196 | * Class used for map fields of <int64_t, BOOL> |
| 3197 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 3198 | * |
| 3199 | * @note This class is not meant to be subclassed. |
| 3200 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3201 | @interface GPBInt64BoolDictionary : NSObject <NSCopying> |
| 3202 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3203 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3204 | @property(nonatomic, readonly) NSUInteger count; |
| 3205 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3206 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3207 | * Initializes this dictionary, copying the given values and keys. |
| 3208 | * |
| 3209 | * @param values The values to be placed in this dictionary. |
| 3210 | * @param keys The keys under which to store the values. |
| 3211 | * @param count The number of elements to copy into the dictionary. |
| 3212 | * |
| 3213 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 3214 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 3215 | - (instancetype)initWithBools:(const BOOL [__nullable])values |
| 3216 | forKeys:(const int64_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3217 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3218 | |
| 3219 | /** |
| 3220 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 3221 | * |
| 3222 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 3223 | * |
| 3224 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 3225 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3226 | - (instancetype)initWithDictionary:(GPBInt64BoolDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3227 | |
| 3228 | /** |
| 3229 | * Initializes this dictionary with the requested capacity. |
| 3230 | * |
| 3231 | * @param numItems Number of items needed for this dictionary. |
| 3232 | * |
| 3233 | * @return A newly initialized dictionary with the requested capacity. |
| 3234 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3235 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 3236 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3237 | /** |
| 3238 | * Gets the value for the given key. |
| 3239 | * |
| 3240 | * @param value Pointer into which the value will be set, if found. |
| 3241 | * @param key Key under which the value is stored, if present. |
| 3242 | * |
| 3243 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 3244 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3245 | - (BOOL)getBool:(nullable BOOL *)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3246 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3247 | /** |
| 3248 | * Enumerates the keys and values on this dictionary with the given block. |
| 3249 | * |
| 3250 | * @param block The block to enumerate with. |
| 3251 | * **key**: The key for the current entry. |
| 3252 | * **value**: The value for the current entry |
| 3253 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 3254 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3255 | - (void)enumerateKeysAndBoolsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 3256 | (void (NS_NOESCAPE ^)(int64_t key, BOOL value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3257 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3258 | /** |
| 3259 | * Adds the keys and values from another dictionary. |
| 3260 | * |
| 3261 | * @param otherDictionary Dictionary containing entries to be added to this |
| 3262 | * dictionary. |
| 3263 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3264 | - (void)addEntriesFromDictionary:(GPBInt64BoolDictionary *)otherDictionary; |
| 3265 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3266 | /** |
| 3267 | * Sets the value for the given key. |
| 3268 | * |
| 3269 | * @param value The value to set. |
| 3270 | * @param key The key under which to store the value. |
| 3271 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3272 | - (void)setBool:(BOOL)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3273 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3274 | /** |
| 3275 | * Removes the entry for the given key. |
| 3276 | * |
| 3277 | * @param aKey Key to be removed from this dictionary. |
| 3278 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3279 | - (void)removeBoolForKey:(int64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3280 | |
| 3281 | /** |
| 3282 | * Removes all entries in this dictionary. |
| 3283 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3284 | - (void)removeAll; |
| 3285 | |
| 3286 | @end |
| 3287 | |
| 3288 | #pragma mark - Int64 -> Float |
| 3289 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3290 | /** |
| 3291 | * Class used for map fields of <int64_t, float> |
| 3292 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 3293 | * |
| 3294 | * @note This class is not meant to be subclassed. |
| 3295 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3296 | @interface GPBInt64FloatDictionary : NSObject <NSCopying> |
| 3297 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3298 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3299 | @property(nonatomic, readonly) NSUInteger count; |
| 3300 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3301 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3302 | * Initializes this dictionary, copying the given values and keys. |
| 3303 | * |
| 3304 | * @param values The values to be placed in this dictionary. |
| 3305 | * @param keys The keys under which to store the values. |
| 3306 | * @param count The number of elements to copy into the dictionary. |
| 3307 | * |
| 3308 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 3309 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 3310 | - (instancetype)initWithFloats:(const float [__nullable])values |
| 3311 | forKeys:(const int64_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3312 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3313 | |
| 3314 | /** |
| 3315 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 3316 | * |
| 3317 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 3318 | * |
| 3319 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 3320 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3321 | - (instancetype)initWithDictionary:(GPBInt64FloatDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3322 | |
| 3323 | /** |
| 3324 | * Initializes this dictionary with the requested capacity. |
| 3325 | * |
| 3326 | * @param numItems Number of items needed for this dictionary. |
| 3327 | * |
| 3328 | * @return A newly initialized dictionary with the requested capacity. |
| 3329 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3330 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 3331 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3332 | /** |
| 3333 | * Gets the value for the given key. |
| 3334 | * |
| 3335 | * @param value Pointer into which the value will be set, if found. |
| 3336 | * @param key Key under which the value is stored, if present. |
| 3337 | * |
| 3338 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 3339 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3340 | - (BOOL)getFloat:(nullable float *)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3341 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3342 | /** |
| 3343 | * Enumerates the keys and values on this dictionary with the given block. |
| 3344 | * |
| 3345 | * @param block The block to enumerate with. |
| 3346 | * **key**: The key for the current entry. |
| 3347 | * **value**: The value for the current entry |
| 3348 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 3349 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3350 | - (void)enumerateKeysAndFloatsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 3351 | (void (NS_NOESCAPE ^)(int64_t key, float value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3352 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3353 | /** |
| 3354 | * Adds the keys and values from another dictionary. |
| 3355 | * |
| 3356 | * @param otherDictionary Dictionary containing entries to be added to this |
| 3357 | * dictionary. |
| 3358 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3359 | - (void)addEntriesFromDictionary:(GPBInt64FloatDictionary *)otherDictionary; |
| 3360 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3361 | /** |
| 3362 | * Sets the value for the given key. |
| 3363 | * |
| 3364 | * @param value The value to set. |
| 3365 | * @param key The key under which to store the value. |
| 3366 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3367 | - (void)setFloat:(float)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3368 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3369 | /** |
| 3370 | * Removes the entry for the given key. |
| 3371 | * |
| 3372 | * @param aKey Key to be removed from this dictionary. |
| 3373 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3374 | - (void)removeFloatForKey:(int64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3375 | |
| 3376 | /** |
| 3377 | * Removes all entries in this dictionary. |
| 3378 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3379 | - (void)removeAll; |
| 3380 | |
| 3381 | @end |
| 3382 | |
| 3383 | #pragma mark - Int64 -> Double |
| 3384 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3385 | /** |
| 3386 | * Class used for map fields of <int64_t, double> |
| 3387 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 3388 | * |
| 3389 | * @note This class is not meant to be subclassed. |
| 3390 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3391 | @interface GPBInt64DoubleDictionary : NSObject <NSCopying> |
| 3392 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3393 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3394 | @property(nonatomic, readonly) NSUInteger count; |
| 3395 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3396 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3397 | * Initializes this dictionary, copying the given values and keys. |
| 3398 | * |
| 3399 | * @param values The values to be placed in this dictionary. |
| 3400 | * @param keys The keys under which to store the values. |
| 3401 | * @param count The number of elements to copy into the dictionary. |
| 3402 | * |
| 3403 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 3404 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 3405 | - (instancetype)initWithDoubles:(const double [__nullable])values |
| 3406 | forKeys:(const int64_t [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3407 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3408 | |
| 3409 | /** |
| 3410 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 3411 | * |
| 3412 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 3413 | * |
| 3414 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 3415 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3416 | - (instancetype)initWithDictionary:(GPBInt64DoubleDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3417 | |
| 3418 | /** |
| 3419 | * Initializes this dictionary with the requested capacity. |
| 3420 | * |
| 3421 | * @param numItems Number of items needed for this dictionary. |
| 3422 | * |
| 3423 | * @return A newly initialized dictionary with the requested capacity. |
| 3424 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3425 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 3426 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3427 | /** |
| 3428 | * Gets the value for the given key. |
| 3429 | * |
| 3430 | * @param value Pointer into which the value will be set, if found. |
| 3431 | * @param key Key under which the value is stored, if present. |
| 3432 | * |
| 3433 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 3434 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3435 | - (BOOL)getDouble:(nullable double *)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3436 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3437 | /** |
| 3438 | * Enumerates the keys and values on this dictionary with the given block. |
| 3439 | * |
| 3440 | * @param block The block to enumerate with. |
| 3441 | * **key**: The key for the current entry. |
| 3442 | * **value**: The value for the current entry |
| 3443 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 3444 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3445 | - (void)enumerateKeysAndDoublesUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 3446 | (void (NS_NOESCAPE ^)(int64_t key, double value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3447 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3448 | /** |
| 3449 | * Adds the keys and values from another dictionary. |
| 3450 | * |
| 3451 | * @param otherDictionary Dictionary containing entries to be added to this |
| 3452 | * dictionary. |
| 3453 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3454 | - (void)addEntriesFromDictionary:(GPBInt64DoubleDictionary *)otherDictionary; |
| 3455 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3456 | /** |
| 3457 | * Sets the value for the given key. |
| 3458 | * |
| 3459 | * @param value The value to set. |
| 3460 | * @param key The key under which to store the value. |
| 3461 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3462 | - (void)setDouble:(double)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3463 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3464 | /** |
| 3465 | * Removes the entry for the given key. |
| 3466 | * |
| 3467 | * @param aKey Key to be removed from this dictionary. |
| 3468 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3469 | - (void)removeDoubleForKey:(int64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3470 | |
| 3471 | /** |
| 3472 | * Removes all entries in this dictionary. |
| 3473 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3474 | - (void)removeAll; |
| 3475 | |
| 3476 | @end |
| 3477 | |
| 3478 | #pragma mark - Int64 -> Enum |
| 3479 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3480 | /** |
| 3481 | * Class used for map fields of <int64_t, int32_t> |
| 3482 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 3483 | * |
| 3484 | * @note This class is not meant to be subclassed. |
| 3485 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3486 | @interface GPBInt64EnumDictionary : NSObject <NSCopying> |
| 3487 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3488 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3489 | @property(nonatomic, readonly) NSUInteger count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3490 | /** The validation function to check if the enums are valid. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3491 | @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; |
| 3492 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3493 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3494 | * Initializes a dictionary with the given validation function. |
| 3495 | * |
| 3496 | * @param func The enum validation function for the dictionary. |
| 3497 | * |
| 3498 | * @return A newly initialized dictionary. |
| 3499 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 3500 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3501 | |
| 3502 | /** |
| 3503 | * Initializes a dictionary with the entries given. |
| 3504 | * |
| 3505 | * @param func The enum validation function for the dictionary. |
| 3506 | * @param values The raw enum values values to be placed in the dictionary. |
| 3507 | * @param keys The keys under which to store the values. |
| 3508 | * @param count The number of entries to store in the dictionary. |
| 3509 | * |
| 3510 | * @return A newly initialized dictionary with the keys and values in it. |
| 3511 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 3512 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 3513 | rawValues:(const int32_t [__nullable])values |
| 3514 | forKeys:(const int64_t [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3515 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3516 | |
| 3517 | /** |
| 3518 | * Initializes a dictionary with the entries from the given. |
| 3519 | * dictionary. |
| 3520 | * |
| 3521 | * @param dictionary Dictionary containing the entries to add to the dictionary. |
| 3522 | * |
| 3523 | * @return A newly initialized dictionary with the entries from the given |
| 3524 | * dictionary in it. |
| 3525 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3526 | - (instancetype)initWithDictionary:(GPBInt64EnumDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3527 | |
| 3528 | /** |
| 3529 | * Initializes a dictionary with the given capacity. |
| 3530 | * |
| 3531 | * @param func The enum validation function for the dictionary. |
| 3532 | * @param numItems Capacity needed for the dictionary. |
| 3533 | * |
| 3534 | * @return A newly initialized dictionary with the given capacity. |
| 3535 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 3536 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3537 | capacity:(NSUInteger)numItems; |
| 3538 | |
| 3539 | // These will return kGPBUnrecognizedEnumeratorValue if the value for the key |
| 3540 | // is not a valid enumerator as defined by validationFunc. If the actual value is |
| 3541 | // desired, use "raw" version of the method. |
| 3542 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3543 | /** |
| 3544 | * Gets the value for the given key. |
| 3545 | * |
| 3546 | * @param value Pointer into which the value will be set, if found. |
| 3547 | * @param key Key under which the value is stored, if present. |
| 3548 | * |
| 3549 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 3550 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3551 | - (BOOL)getEnum:(nullable int32_t *)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3552 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3553 | /** |
| 3554 | * Enumerates the keys and values on this dictionary with the given block. |
| 3555 | * |
| 3556 | * @param block The block to enumerate with. |
| 3557 | * **key**: The key for the current entry. |
| 3558 | * **value**: The value for the current entry |
| 3559 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 3560 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3561 | - (void)enumerateKeysAndEnumsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 3562 | (void (NS_NOESCAPE ^)(int64_t key, int32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3563 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3564 | /** |
| 3565 | * Gets the raw enum value for the given key. |
| 3566 | * |
| 3567 | * @note This method bypass the validationFunc to enable the access of values that |
| 3568 | * were not known at the time the binary was compiled. |
| 3569 | * |
| 3570 | * @param rawValue Pointer into which the value will be set, if found. |
| 3571 | * @param key Key under which the value is stored, if present. |
| 3572 | * |
| 3573 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 3574 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3575 | - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3576 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3577 | /** |
| 3578 | * Enumerates the keys and values on this dictionary with the given block. |
| 3579 | * |
| 3580 | * @note This method bypass the validationFunc to enable the access of values that |
| 3581 | * were not known at the time the binary was compiled. |
| 3582 | * |
| 3583 | * @param block The block to enumerate with. |
| 3584 | * **key**: The key for the current entry. |
| 3585 | * **rawValue**: The value for the current entry |
| 3586 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 3587 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3588 | - (void)enumerateKeysAndRawValuesUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 3589 | (void (NS_NOESCAPE ^)(int64_t key, int32_t rawValue, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3590 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3591 | /** |
| 3592 | * Adds the keys and raw enum values from another dictionary. |
| 3593 | * |
| 3594 | * @note This method bypass the validationFunc to enable the setting of values that |
| 3595 | * were not known at the time the binary was compiled. |
| 3596 | * |
| 3597 | * @param otherDictionary Dictionary containing entries to be added to this |
| 3598 | * dictionary. |
| 3599 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3600 | - (void)addRawEntriesFromDictionary:(GPBInt64EnumDictionary *)otherDictionary; |
| 3601 | |
| 3602 | // If value is not a valid enumerator as defined by validationFunc, these |
| 3603 | // methods will assert in debug, and will log in release and assign the value |
| 3604 | // to the default value. Use the rawValue methods below to assign non enumerator |
| 3605 | // values. |
| 3606 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3607 | /** |
| 3608 | * Sets the value for the given key. |
| 3609 | * |
| 3610 | * @param value The value to set. |
| 3611 | * @param key The key under which to store the value. |
| 3612 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3613 | - (void)setEnum:(int32_t)value forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3614 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3615 | /** |
| 3616 | * Sets the raw enum value for the given key. |
| 3617 | * |
| 3618 | * @note This method bypass the validationFunc to enable the setting of values that |
| 3619 | * were not known at the time the binary was compiled. |
| 3620 | * |
| 3621 | * @param rawValue The raw enum value to set. |
| 3622 | * @param key The key under which to store the raw enum value. |
| 3623 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3624 | - (void)setRawValue:(int32_t)rawValue forKey:(int64_t)key; |
| 3625 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3626 | /** |
| 3627 | * Removes the entry for the given key. |
| 3628 | * |
| 3629 | * @param aKey Key to be removed from this dictionary. |
| 3630 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3631 | - (void)removeEnumForKey:(int64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3632 | |
| 3633 | /** |
| 3634 | * Removes all entries in this dictionary. |
| 3635 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3636 | - (void)removeAll; |
| 3637 | |
| 3638 | @end |
| 3639 | |
| 3640 | #pragma mark - Int64 -> Object |
| 3641 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3642 | /** |
| 3643 | * Class used for map fields of <int64_t, ObjectType> |
| 3644 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 3645 | * |
| 3646 | * @note This class is not meant to be subclassed. |
| 3647 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 3648 | @interface GPBInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying> |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3649 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3650 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3651 | @property(nonatomic, readonly) NSUInteger count; |
| 3652 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3653 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3654 | * Initializes this dictionary, copying the given values and keys. |
| 3655 | * |
| 3656 | * @param objects The values to be placed in this dictionary. |
| 3657 | * @param keys The keys under which to store the values. |
| 3658 | * @param count The number of elements to copy into the dictionary. |
| 3659 | * |
| 3660 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 3661 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 3662 | - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects |
| 3663 | forKeys:(const int64_t [__nullable])keys |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 3664 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3665 | |
| 3666 | /** |
| 3667 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 3668 | * |
| 3669 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 3670 | * |
| 3671 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 3672 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3673 | - (instancetype)initWithDictionary:(GPBInt64ObjectDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3674 | |
| 3675 | /** |
| 3676 | * Initializes this dictionary with the requested capacity. |
| 3677 | * |
| 3678 | * @param numItems Number of items needed for this dictionary. |
| 3679 | * |
| 3680 | * @return A newly initialized dictionary with the requested capacity. |
| 3681 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3682 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 3683 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3684 | /** |
| 3685 | * Fetches the object stored under the given key. |
| 3686 | * |
| 3687 | * @param key Key under which the value is stored, if present. |
| 3688 | * |
| 3689 | * @return The object if found, nil otherwise. |
| 3690 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 3691 | - (ObjectType)objectForKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3692 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3693 | /** |
| 3694 | * Enumerates the keys and values on this dictionary with the given block. |
| 3695 | * |
| 3696 | * @param block The block to enumerate with. |
| 3697 | * **key**: The key for the current entry. |
| 3698 | * **object**: The value for the current entry |
| 3699 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 3700 | **/ |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 3701 | - (void)enumerateKeysAndObjectsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 3702 | (void (NS_NOESCAPE ^)(int64_t key, ObjectType object, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3703 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3704 | /** |
| 3705 | * Adds the keys and values from another dictionary. |
| 3706 | * |
| 3707 | * @param otherDictionary Dictionary containing entries to be added to this |
| 3708 | * dictionary. |
| 3709 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3710 | - (void)addEntriesFromDictionary:(GPBInt64ObjectDictionary *)otherDictionary; |
| 3711 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3712 | /** |
| 3713 | * Sets the value for the given key. |
| 3714 | * |
| 3715 | * @param object The value to set. |
| 3716 | * @param key The key under which to store the value. |
| 3717 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 3718 | - (void)setObject:(ObjectType)object forKey:(int64_t)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3719 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3720 | /** |
| 3721 | * Removes the entry for the given key. |
| 3722 | * |
| 3723 | * @param aKey Key to be removed from this dictionary. |
| 3724 | **/ |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 3725 | - (void)removeObjectForKey:(int64_t)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3726 | |
| 3727 | /** |
| 3728 | * Removes all entries in this dictionary. |
| 3729 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3730 | - (void)removeAll; |
| 3731 | |
| 3732 | @end |
| 3733 | |
| 3734 | #pragma mark - Bool -> UInt32 |
| 3735 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3736 | /** |
| 3737 | * Class used for map fields of <BOOL, uint32_t> |
| 3738 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 3739 | * |
| 3740 | * @note This class is not meant to be subclassed. |
| 3741 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3742 | @interface GPBBoolUInt32Dictionary : NSObject <NSCopying> |
| 3743 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3744 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3745 | @property(nonatomic, readonly) NSUInteger count; |
| 3746 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3747 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3748 | * Initializes this dictionary, copying the given values and keys. |
| 3749 | * |
| 3750 | * @param values The values to be placed in this dictionary. |
| 3751 | * @param keys The keys under which to store the values. |
| 3752 | * @param count The number of elements to copy into the dictionary. |
| 3753 | * |
| 3754 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 3755 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 3756 | - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values |
| 3757 | forKeys:(const BOOL [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3758 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3759 | |
| 3760 | /** |
| 3761 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 3762 | * |
| 3763 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 3764 | * |
| 3765 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 3766 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3767 | - (instancetype)initWithDictionary:(GPBBoolUInt32Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3768 | |
| 3769 | /** |
| 3770 | * Initializes this dictionary with the requested capacity. |
| 3771 | * |
| 3772 | * @param numItems Number of items needed for this dictionary. |
| 3773 | * |
| 3774 | * @return A newly initialized dictionary with the requested capacity. |
| 3775 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3776 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 3777 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3778 | /** |
| 3779 | * Gets the value for the given key. |
| 3780 | * |
| 3781 | * @param value Pointer into which the value will be set, if found. |
| 3782 | * @param key Key under which the value is stored, if present. |
| 3783 | * |
| 3784 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 3785 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3786 | - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3787 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3788 | /** |
| 3789 | * Enumerates the keys and values on this dictionary with the given block. |
| 3790 | * |
| 3791 | * @param block The block to enumerate with. |
| 3792 | * **key**: The key for the current entry. |
| 3793 | * **value**: The value for the current entry |
| 3794 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 3795 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3796 | - (void)enumerateKeysAndUInt32sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 3797 | (void (NS_NOESCAPE ^)(BOOL key, uint32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3798 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3799 | /** |
| 3800 | * Adds the keys and values from another dictionary. |
| 3801 | * |
| 3802 | * @param otherDictionary Dictionary containing entries to be added to this |
| 3803 | * dictionary. |
| 3804 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3805 | - (void)addEntriesFromDictionary:(GPBBoolUInt32Dictionary *)otherDictionary; |
| 3806 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3807 | /** |
| 3808 | * Sets the value for the given key. |
| 3809 | * |
| 3810 | * @param value The value to set. |
| 3811 | * @param key The key under which to store the value. |
| 3812 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3813 | - (void)setUInt32:(uint32_t)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3814 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3815 | /** |
| 3816 | * Removes the entry for the given key. |
| 3817 | * |
| 3818 | * @param aKey Key to be removed from this dictionary. |
| 3819 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3820 | - (void)removeUInt32ForKey:(BOOL)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3821 | |
| 3822 | /** |
| 3823 | * Removes all entries in this dictionary. |
| 3824 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3825 | - (void)removeAll; |
| 3826 | |
| 3827 | @end |
| 3828 | |
| 3829 | #pragma mark - Bool -> Int32 |
| 3830 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3831 | /** |
| 3832 | * Class used for map fields of <BOOL, int32_t> |
| 3833 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 3834 | * |
| 3835 | * @note This class is not meant to be subclassed. |
| 3836 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3837 | @interface GPBBoolInt32Dictionary : NSObject <NSCopying> |
| 3838 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3839 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3840 | @property(nonatomic, readonly) NSUInteger count; |
| 3841 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3842 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3843 | * Initializes this dictionary, copying the given values and keys. |
| 3844 | * |
| 3845 | * @param values The values to be placed in this dictionary. |
| 3846 | * @param keys The keys under which to store the values. |
| 3847 | * @param count The number of elements to copy into the dictionary. |
| 3848 | * |
| 3849 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 3850 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 3851 | - (instancetype)initWithInt32s:(const int32_t [__nullable])values |
| 3852 | forKeys:(const BOOL [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3853 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3854 | |
| 3855 | /** |
| 3856 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 3857 | * |
| 3858 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 3859 | * |
| 3860 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 3861 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3862 | - (instancetype)initWithDictionary:(GPBBoolInt32Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3863 | |
| 3864 | /** |
| 3865 | * Initializes this dictionary with the requested capacity. |
| 3866 | * |
| 3867 | * @param numItems Number of items needed for this dictionary. |
| 3868 | * |
| 3869 | * @return A newly initialized dictionary with the requested capacity. |
| 3870 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3871 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 3872 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3873 | /** |
| 3874 | * Gets the value for the given key. |
| 3875 | * |
| 3876 | * @param value Pointer into which the value will be set, if found. |
| 3877 | * @param key Key under which the value is stored, if present. |
| 3878 | * |
| 3879 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 3880 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3881 | - (BOOL)getInt32:(nullable int32_t *)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3882 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3883 | /** |
| 3884 | * Enumerates the keys and values on this dictionary with the given block. |
| 3885 | * |
| 3886 | * @param block The block to enumerate with. |
| 3887 | * **key**: The key for the current entry. |
| 3888 | * **value**: The value for the current entry |
| 3889 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 3890 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3891 | - (void)enumerateKeysAndInt32sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 3892 | (void (NS_NOESCAPE ^)(BOOL key, int32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3893 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3894 | /** |
| 3895 | * Adds the keys and values from another dictionary. |
| 3896 | * |
| 3897 | * @param otherDictionary Dictionary containing entries to be added to this |
| 3898 | * dictionary. |
| 3899 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3900 | - (void)addEntriesFromDictionary:(GPBBoolInt32Dictionary *)otherDictionary; |
| 3901 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3902 | /** |
| 3903 | * Sets the value for the given key. |
| 3904 | * |
| 3905 | * @param value The value to set. |
| 3906 | * @param key The key under which to store the value. |
| 3907 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3908 | - (void)setInt32:(int32_t)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3909 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3910 | /** |
| 3911 | * Removes the entry for the given key. |
| 3912 | * |
| 3913 | * @param aKey Key to be removed from this dictionary. |
| 3914 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3915 | - (void)removeInt32ForKey:(BOOL)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3916 | |
| 3917 | /** |
| 3918 | * Removes all entries in this dictionary. |
| 3919 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3920 | - (void)removeAll; |
| 3921 | |
| 3922 | @end |
| 3923 | |
| 3924 | #pragma mark - Bool -> UInt64 |
| 3925 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3926 | /** |
| 3927 | * Class used for map fields of <BOOL, uint64_t> |
| 3928 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 3929 | * |
| 3930 | * @note This class is not meant to be subclassed. |
| 3931 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3932 | @interface GPBBoolUInt64Dictionary : NSObject <NSCopying> |
| 3933 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3934 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3935 | @property(nonatomic, readonly) NSUInteger count; |
| 3936 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3937 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3938 | * Initializes this dictionary, copying the given values and keys. |
| 3939 | * |
| 3940 | * @param values The values to be placed in this dictionary. |
| 3941 | * @param keys The keys under which to store the values. |
| 3942 | * @param count The number of elements to copy into the dictionary. |
| 3943 | * |
| 3944 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 3945 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 3946 | - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values |
| 3947 | forKeys:(const BOOL [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3948 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3949 | |
| 3950 | /** |
| 3951 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 3952 | * |
| 3953 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 3954 | * |
| 3955 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 3956 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3957 | - (instancetype)initWithDictionary:(GPBBoolUInt64Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3958 | |
| 3959 | /** |
| 3960 | * Initializes this dictionary with the requested capacity. |
| 3961 | * |
| 3962 | * @param numItems Number of items needed for this dictionary. |
| 3963 | * |
| 3964 | * @return A newly initialized dictionary with the requested capacity. |
| 3965 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3966 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 3967 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3968 | /** |
| 3969 | * Gets the value for the given key. |
| 3970 | * |
| 3971 | * @param value Pointer into which the value will be set, if found. |
| 3972 | * @param key Key under which the value is stored, if present. |
| 3973 | * |
| 3974 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 3975 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3976 | - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3977 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3978 | /** |
| 3979 | * Enumerates the keys and values on this dictionary with the given block. |
| 3980 | * |
| 3981 | * @param block The block to enumerate with. |
| 3982 | * **key**: The key for the current entry. |
| 3983 | * **value**: The value for the current entry |
| 3984 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 3985 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 3986 | - (void)enumerateKeysAndUInt64sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 3987 | (void (NS_NOESCAPE ^)(BOOL key, uint64_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3988 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3989 | /** |
| 3990 | * Adds the keys and values from another dictionary. |
| 3991 | * |
| 3992 | * @param otherDictionary Dictionary containing entries to be added to this |
| 3993 | * dictionary. |
| 3994 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 3995 | - (void)addEntriesFromDictionary:(GPBBoolUInt64Dictionary *)otherDictionary; |
| 3996 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 3997 | /** |
| 3998 | * Sets the value for the given key. |
| 3999 | * |
| 4000 | * @param value The value to set. |
| 4001 | * @param key The key under which to store the value. |
| 4002 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4003 | - (void)setUInt64:(uint64_t)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4004 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4005 | /** |
| 4006 | * Removes the entry for the given key. |
| 4007 | * |
| 4008 | * @param aKey Key to be removed from this dictionary. |
| 4009 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4010 | - (void)removeUInt64ForKey:(BOOL)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4011 | |
| 4012 | /** |
| 4013 | * Removes all entries in this dictionary. |
| 4014 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4015 | - (void)removeAll; |
| 4016 | |
| 4017 | @end |
| 4018 | |
| 4019 | #pragma mark - Bool -> Int64 |
| 4020 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4021 | /** |
| 4022 | * Class used for map fields of <BOOL, int64_t> |
| 4023 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 4024 | * |
| 4025 | * @note This class is not meant to be subclassed. |
| 4026 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4027 | @interface GPBBoolInt64Dictionary : NSObject <NSCopying> |
| 4028 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4029 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4030 | @property(nonatomic, readonly) NSUInteger count; |
| 4031 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4032 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4033 | * Initializes this dictionary, copying the given values and keys. |
| 4034 | * |
| 4035 | * @param values The values to be placed in this dictionary. |
| 4036 | * @param keys The keys under which to store the values. |
| 4037 | * @param count The number of elements to copy into the dictionary. |
| 4038 | * |
| 4039 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 4040 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 4041 | - (instancetype)initWithInt64s:(const int64_t [__nullable])values |
| 4042 | forKeys:(const BOOL [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4043 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4044 | |
| 4045 | /** |
| 4046 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 4047 | * |
| 4048 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 4049 | * |
| 4050 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 4051 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4052 | - (instancetype)initWithDictionary:(GPBBoolInt64Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4053 | |
| 4054 | /** |
| 4055 | * Initializes this dictionary with the requested capacity. |
| 4056 | * |
| 4057 | * @param numItems Number of items needed for this dictionary. |
| 4058 | * |
| 4059 | * @return A newly initialized dictionary with the requested capacity. |
| 4060 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4061 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 4062 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4063 | /** |
| 4064 | * Gets the value for the given key. |
| 4065 | * |
| 4066 | * @param value Pointer into which the value will be set, if found. |
| 4067 | * @param key Key under which the value is stored, if present. |
| 4068 | * |
| 4069 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 4070 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4071 | - (BOOL)getInt64:(nullable int64_t *)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4072 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4073 | /** |
| 4074 | * Enumerates the keys and values on this dictionary with the given block. |
| 4075 | * |
| 4076 | * @param block The block to enumerate with. |
| 4077 | * **key**: The key for the current entry. |
| 4078 | * **value**: The value for the current entry |
| 4079 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 4080 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4081 | - (void)enumerateKeysAndInt64sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 4082 | (void (NS_NOESCAPE ^)(BOOL key, int64_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4083 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4084 | /** |
| 4085 | * Adds the keys and values from another dictionary. |
| 4086 | * |
| 4087 | * @param otherDictionary Dictionary containing entries to be added to this |
| 4088 | * dictionary. |
| 4089 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4090 | - (void)addEntriesFromDictionary:(GPBBoolInt64Dictionary *)otherDictionary; |
| 4091 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4092 | /** |
| 4093 | * Sets the value for the given key. |
| 4094 | * |
| 4095 | * @param value The value to set. |
| 4096 | * @param key The key under which to store the value. |
| 4097 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4098 | - (void)setInt64:(int64_t)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4099 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4100 | /** |
| 4101 | * Removes the entry for the given key. |
| 4102 | * |
| 4103 | * @param aKey Key to be removed from this dictionary. |
| 4104 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4105 | - (void)removeInt64ForKey:(BOOL)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4106 | |
| 4107 | /** |
| 4108 | * Removes all entries in this dictionary. |
| 4109 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4110 | - (void)removeAll; |
| 4111 | |
| 4112 | @end |
| 4113 | |
| 4114 | #pragma mark - Bool -> Bool |
| 4115 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4116 | /** |
| 4117 | * Class used for map fields of <BOOL, BOOL> |
| 4118 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 4119 | * |
| 4120 | * @note This class is not meant to be subclassed. |
| 4121 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4122 | @interface GPBBoolBoolDictionary : NSObject <NSCopying> |
| 4123 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4124 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4125 | @property(nonatomic, readonly) NSUInteger count; |
| 4126 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4127 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4128 | * Initializes this dictionary, copying the given values and keys. |
| 4129 | * |
| 4130 | * @param values The values to be placed in this dictionary. |
| 4131 | * @param keys The keys under which to store the values. |
| 4132 | * @param count The number of elements to copy into the dictionary. |
| 4133 | * |
| 4134 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 4135 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 4136 | - (instancetype)initWithBools:(const BOOL [__nullable])values |
| 4137 | forKeys:(const BOOL [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4138 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4139 | |
| 4140 | /** |
| 4141 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 4142 | * |
| 4143 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 4144 | * |
| 4145 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 4146 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4147 | - (instancetype)initWithDictionary:(GPBBoolBoolDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4148 | |
| 4149 | /** |
| 4150 | * Initializes this dictionary with the requested capacity. |
| 4151 | * |
| 4152 | * @param numItems Number of items needed for this dictionary. |
| 4153 | * |
| 4154 | * @return A newly initialized dictionary with the requested capacity. |
| 4155 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4156 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 4157 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4158 | /** |
| 4159 | * Gets the value for the given key. |
| 4160 | * |
| 4161 | * @param value Pointer into which the value will be set, if found. |
| 4162 | * @param key Key under which the value is stored, if present. |
| 4163 | * |
| 4164 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 4165 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4166 | - (BOOL)getBool:(nullable BOOL *)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4167 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4168 | /** |
| 4169 | * Enumerates the keys and values on this dictionary with the given block. |
| 4170 | * |
| 4171 | * @param block The block to enumerate with. |
| 4172 | * **key**: The key for the current entry. |
| 4173 | * **value**: The value for the current entry |
| 4174 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 4175 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4176 | - (void)enumerateKeysAndBoolsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 4177 | (void (NS_NOESCAPE ^)(BOOL key, BOOL value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4178 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4179 | /** |
| 4180 | * Adds the keys and values from another dictionary. |
| 4181 | * |
| 4182 | * @param otherDictionary Dictionary containing entries to be added to this |
| 4183 | * dictionary. |
| 4184 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4185 | - (void)addEntriesFromDictionary:(GPBBoolBoolDictionary *)otherDictionary; |
| 4186 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4187 | /** |
| 4188 | * Sets the value for the given key. |
| 4189 | * |
| 4190 | * @param value The value to set. |
| 4191 | * @param key The key under which to store the value. |
| 4192 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4193 | - (void)setBool:(BOOL)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4194 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4195 | /** |
| 4196 | * Removes the entry for the given key. |
| 4197 | * |
| 4198 | * @param aKey Key to be removed from this dictionary. |
| 4199 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4200 | - (void)removeBoolForKey:(BOOL)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4201 | |
| 4202 | /** |
| 4203 | * Removes all entries in this dictionary. |
| 4204 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4205 | - (void)removeAll; |
| 4206 | |
| 4207 | @end |
| 4208 | |
| 4209 | #pragma mark - Bool -> Float |
| 4210 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4211 | /** |
| 4212 | * Class used for map fields of <BOOL, float> |
| 4213 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 4214 | * |
| 4215 | * @note This class is not meant to be subclassed. |
| 4216 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4217 | @interface GPBBoolFloatDictionary : NSObject <NSCopying> |
| 4218 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4219 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4220 | @property(nonatomic, readonly) NSUInteger count; |
| 4221 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4222 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4223 | * Initializes this dictionary, copying the given values and keys. |
| 4224 | * |
| 4225 | * @param values The values to be placed in this dictionary. |
| 4226 | * @param keys The keys under which to store the values. |
| 4227 | * @param count The number of elements to copy into the dictionary. |
| 4228 | * |
| 4229 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 4230 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 4231 | - (instancetype)initWithFloats:(const float [__nullable])values |
| 4232 | forKeys:(const BOOL [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4233 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4234 | |
| 4235 | /** |
| 4236 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 4237 | * |
| 4238 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 4239 | * |
| 4240 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 4241 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4242 | - (instancetype)initWithDictionary:(GPBBoolFloatDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4243 | |
| 4244 | /** |
| 4245 | * Initializes this dictionary with the requested capacity. |
| 4246 | * |
| 4247 | * @param numItems Number of items needed for this dictionary. |
| 4248 | * |
| 4249 | * @return A newly initialized dictionary with the requested capacity. |
| 4250 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4251 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 4252 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4253 | /** |
| 4254 | * Gets the value for the given key. |
| 4255 | * |
| 4256 | * @param value Pointer into which the value will be set, if found. |
| 4257 | * @param key Key under which the value is stored, if present. |
| 4258 | * |
| 4259 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 4260 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4261 | - (BOOL)getFloat:(nullable float *)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4262 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4263 | /** |
| 4264 | * Enumerates the keys and values on this dictionary with the given block. |
| 4265 | * |
| 4266 | * @param block The block to enumerate with. |
| 4267 | * **key**: The key for the current entry. |
| 4268 | * **value**: The value for the current entry |
| 4269 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 4270 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4271 | - (void)enumerateKeysAndFloatsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 4272 | (void (NS_NOESCAPE ^)(BOOL key, float value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4273 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4274 | /** |
| 4275 | * Adds the keys and values from another dictionary. |
| 4276 | * |
| 4277 | * @param otherDictionary Dictionary containing entries to be added to this |
| 4278 | * dictionary. |
| 4279 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4280 | - (void)addEntriesFromDictionary:(GPBBoolFloatDictionary *)otherDictionary; |
| 4281 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4282 | /** |
| 4283 | * Sets the value for the given key. |
| 4284 | * |
| 4285 | * @param value The value to set. |
| 4286 | * @param key The key under which to store the value. |
| 4287 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4288 | - (void)setFloat:(float)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4289 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4290 | /** |
| 4291 | * Removes the entry for the given key. |
| 4292 | * |
| 4293 | * @param aKey Key to be removed from this dictionary. |
| 4294 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4295 | - (void)removeFloatForKey:(BOOL)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4296 | |
| 4297 | /** |
| 4298 | * Removes all entries in this dictionary. |
| 4299 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4300 | - (void)removeAll; |
| 4301 | |
| 4302 | @end |
| 4303 | |
| 4304 | #pragma mark - Bool -> Double |
| 4305 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4306 | /** |
| 4307 | * Class used for map fields of <BOOL, double> |
| 4308 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 4309 | * |
| 4310 | * @note This class is not meant to be subclassed. |
| 4311 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4312 | @interface GPBBoolDoubleDictionary : NSObject <NSCopying> |
| 4313 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4314 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4315 | @property(nonatomic, readonly) NSUInteger count; |
| 4316 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4317 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4318 | * Initializes this dictionary, copying the given values and keys. |
| 4319 | * |
| 4320 | * @param values The values to be placed in this dictionary. |
| 4321 | * @param keys The keys under which to store the values. |
| 4322 | * @param count The number of elements to copy into the dictionary. |
| 4323 | * |
| 4324 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 4325 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 4326 | - (instancetype)initWithDoubles:(const double [__nullable])values |
| 4327 | forKeys:(const BOOL [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4328 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4329 | |
| 4330 | /** |
| 4331 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 4332 | * |
| 4333 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 4334 | * |
| 4335 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 4336 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4337 | - (instancetype)initWithDictionary:(GPBBoolDoubleDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4338 | |
| 4339 | /** |
| 4340 | * Initializes this dictionary with the requested capacity. |
| 4341 | * |
| 4342 | * @param numItems Number of items needed for this dictionary. |
| 4343 | * |
| 4344 | * @return A newly initialized dictionary with the requested capacity. |
| 4345 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4346 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 4347 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4348 | /** |
| 4349 | * Gets the value for the given key. |
| 4350 | * |
| 4351 | * @param value Pointer into which the value will be set, if found. |
| 4352 | * @param key Key under which the value is stored, if present. |
| 4353 | * |
| 4354 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 4355 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4356 | - (BOOL)getDouble:(nullable double *)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4357 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4358 | /** |
| 4359 | * Enumerates the keys and values on this dictionary with the given block. |
| 4360 | * |
| 4361 | * @param block The block to enumerate with. |
| 4362 | * **key**: The key for the current entry. |
| 4363 | * **value**: The value for the current entry |
| 4364 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 4365 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4366 | - (void)enumerateKeysAndDoublesUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 4367 | (void (NS_NOESCAPE ^)(BOOL key, double value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4368 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4369 | /** |
| 4370 | * Adds the keys and values from another dictionary. |
| 4371 | * |
| 4372 | * @param otherDictionary Dictionary containing entries to be added to this |
| 4373 | * dictionary. |
| 4374 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4375 | - (void)addEntriesFromDictionary:(GPBBoolDoubleDictionary *)otherDictionary; |
| 4376 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4377 | /** |
| 4378 | * Sets the value for the given key. |
| 4379 | * |
| 4380 | * @param value The value to set. |
| 4381 | * @param key The key under which to store the value. |
| 4382 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4383 | - (void)setDouble:(double)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4384 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4385 | /** |
| 4386 | * Removes the entry for the given key. |
| 4387 | * |
| 4388 | * @param aKey Key to be removed from this dictionary. |
| 4389 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4390 | - (void)removeDoubleForKey:(BOOL)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4391 | |
| 4392 | /** |
| 4393 | * Removes all entries in this dictionary. |
| 4394 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4395 | - (void)removeAll; |
| 4396 | |
| 4397 | @end |
| 4398 | |
| 4399 | #pragma mark - Bool -> Enum |
| 4400 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4401 | /** |
| 4402 | * Class used for map fields of <BOOL, int32_t> |
| 4403 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 4404 | * |
| 4405 | * @note This class is not meant to be subclassed. |
| 4406 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4407 | @interface GPBBoolEnumDictionary : NSObject <NSCopying> |
| 4408 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4409 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4410 | @property(nonatomic, readonly) NSUInteger count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4411 | /** The validation function to check if the enums are valid. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4412 | @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; |
| 4413 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4414 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4415 | * Initializes a dictionary with the given validation function. |
| 4416 | * |
| 4417 | * @param func The enum validation function for the dictionary. |
| 4418 | * |
| 4419 | * @return A newly initialized dictionary. |
| 4420 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 4421 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4422 | |
| 4423 | /** |
| 4424 | * Initializes a dictionary with the entries given. |
| 4425 | * |
| 4426 | * @param func The enum validation function for the dictionary. |
| 4427 | * @param values The raw enum values values to be placed in the dictionary. |
| 4428 | * @param keys The keys under which to store the values. |
| 4429 | * @param count The number of entries to store in the dictionary. |
| 4430 | * |
| 4431 | * @return A newly initialized dictionary with the keys and values in it. |
| 4432 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 4433 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 4434 | rawValues:(const int32_t [__nullable])values |
| 4435 | forKeys:(const BOOL [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4436 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4437 | |
| 4438 | /** |
| 4439 | * Initializes a dictionary with the entries from the given. |
| 4440 | * dictionary. |
| 4441 | * |
| 4442 | * @param dictionary Dictionary containing the entries to add to the dictionary. |
| 4443 | * |
| 4444 | * @return A newly initialized dictionary with the entries from the given |
| 4445 | * dictionary in it. |
| 4446 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4447 | - (instancetype)initWithDictionary:(GPBBoolEnumDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4448 | |
| 4449 | /** |
| 4450 | * Initializes a dictionary with the given capacity. |
| 4451 | * |
| 4452 | * @param func The enum validation function for the dictionary. |
| 4453 | * @param numItems Capacity needed for the dictionary. |
| 4454 | * |
| 4455 | * @return A newly initialized dictionary with the given capacity. |
| 4456 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 4457 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4458 | capacity:(NSUInteger)numItems; |
| 4459 | |
| 4460 | // These will return kGPBUnrecognizedEnumeratorValue if the value for the key |
| 4461 | // is not a valid enumerator as defined by validationFunc. If the actual value is |
| 4462 | // desired, use "raw" version of the method. |
| 4463 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4464 | /** |
| 4465 | * Gets the value for the given key. |
| 4466 | * |
| 4467 | * @param value Pointer into which the value will be set, if found. |
| 4468 | * @param key Key under which the value is stored, if present. |
| 4469 | * |
| 4470 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 4471 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4472 | - (BOOL)getEnum:(nullable int32_t *)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4473 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4474 | /** |
| 4475 | * Enumerates the keys and values on this dictionary with the given block. |
| 4476 | * |
| 4477 | * @param block The block to enumerate with. |
| 4478 | * **key**: The key for the current entry. |
| 4479 | * **value**: The value for the current entry |
| 4480 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 4481 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4482 | - (void)enumerateKeysAndEnumsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 4483 | (void (NS_NOESCAPE ^)(BOOL key, int32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4484 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4485 | /** |
| 4486 | * Gets the raw enum value for the given key. |
| 4487 | * |
| 4488 | * @note This method bypass the validationFunc to enable the access of values that |
| 4489 | * were not known at the time the binary was compiled. |
| 4490 | * |
| 4491 | * @param rawValue Pointer into which the value will be set, if found. |
| 4492 | * @param key Key under which the value is stored, if present. |
| 4493 | * |
| 4494 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 4495 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4496 | - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4497 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4498 | /** |
| 4499 | * Enumerates the keys and values on this dictionary with the given block. |
| 4500 | * |
| 4501 | * @note This method bypass the validationFunc to enable the access of values that |
| 4502 | * were not known at the time the binary was compiled. |
| 4503 | * |
| 4504 | * @param block The block to enumerate with. |
| 4505 | * **key**: The key for the current entry. |
| 4506 | * **rawValue**: The value for the current entry |
| 4507 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 4508 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4509 | - (void)enumerateKeysAndRawValuesUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 4510 | (void (NS_NOESCAPE ^)(BOOL key, int32_t rawValue, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4511 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4512 | /** |
| 4513 | * Adds the keys and raw enum values from another dictionary. |
| 4514 | * |
| 4515 | * @note This method bypass the validationFunc to enable the setting of values that |
| 4516 | * were not known at the time the binary was compiled. |
| 4517 | * |
| 4518 | * @param otherDictionary Dictionary containing entries to be added to this |
| 4519 | * dictionary. |
| 4520 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4521 | - (void)addRawEntriesFromDictionary:(GPBBoolEnumDictionary *)otherDictionary; |
| 4522 | |
| 4523 | // If value is not a valid enumerator as defined by validationFunc, these |
| 4524 | // methods will assert in debug, and will log in release and assign the value |
| 4525 | // to the default value. Use the rawValue methods below to assign non enumerator |
| 4526 | // values. |
| 4527 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4528 | /** |
| 4529 | * Sets the value for the given key. |
| 4530 | * |
| 4531 | * @param value The value to set. |
| 4532 | * @param key The key under which to store the value. |
| 4533 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4534 | - (void)setEnum:(int32_t)value forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4535 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4536 | /** |
| 4537 | * Sets the raw enum value for the given key. |
| 4538 | * |
| 4539 | * @note This method bypass the validationFunc to enable the setting of values that |
| 4540 | * were not known at the time the binary was compiled. |
| 4541 | * |
| 4542 | * @param rawValue The raw enum value to set. |
| 4543 | * @param key The key under which to store the raw enum value. |
| 4544 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4545 | - (void)setRawValue:(int32_t)rawValue forKey:(BOOL)key; |
| 4546 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4547 | /** |
| 4548 | * Removes the entry for the given key. |
| 4549 | * |
| 4550 | * @param aKey Key to be removed from this dictionary. |
| 4551 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4552 | - (void)removeEnumForKey:(BOOL)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4553 | |
| 4554 | /** |
| 4555 | * Removes all entries in this dictionary. |
| 4556 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4557 | - (void)removeAll; |
| 4558 | |
| 4559 | @end |
| 4560 | |
| 4561 | #pragma mark - Bool -> Object |
| 4562 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4563 | /** |
| 4564 | * Class used for map fields of <BOOL, ObjectType> |
| 4565 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 4566 | * |
| 4567 | * @note This class is not meant to be subclassed. |
| 4568 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 4569 | @interface GPBBoolObjectDictionary<__covariant ObjectType> : NSObject <NSCopying> |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4570 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4571 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4572 | @property(nonatomic, readonly) NSUInteger count; |
| 4573 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4574 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4575 | * Initializes this dictionary, copying the given values and keys. |
| 4576 | * |
| 4577 | * @param objects The values to be placed in this dictionary. |
| 4578 | * @param keys The keys under which to store the values. |
| 4579 | * @param count The number of elements to copy into the dictionary. |
| 4580 | * |
| 4581 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 4582 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 4583 | - (instancetype)initWithObjects:(const ObjectType __nonnull GPB_UNSAFE_UNRETAINED [__nullable])objects |
| 4584 | forKeys:(const BOOL [__nullable])keys |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 4585 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4586 | |
| 4587 | /** |
| 4588 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 4589 | * |
| 4590 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 4591 | * |
| 4592 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 4593 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4594 | - (instancetype)initWithDictionary:(GPBBoolObjectDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4595 | |
| 4596 | /** |
| 4597 | * Initializes this dictionary with the requested capacity. |
| 4598 | * |
| 4599 | * @param numItems Number of items needed for this dictionary. |
| 4600 | * |
| 4601 | * @return A newly initialized dictionary with the requested capacity. |
| 4602 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4603 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 4604 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4605 | /** |
| 4606 | * Fetches the object stored under the given key. |
| 4607 | * |
| 4608 | * @param key Key under which the value is stored, if present. |
| 4609 | * |
| 4610 | * @return The object if found, nil otherwise. |
| 4611 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 4612 | - (ObjectType)objectForKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4613 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4614 | /** |
| 4615 | * Enumerates the keys and values on this dictionary with the given block. |
| 4616 | * |
| 4617 | * @param block The block to enumerate with. |
| 4618 | * **key**: The key for the current entry. |
| 4619 | * **object**: The value for the current entry |
| 4620 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 4621 | **/ |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 4622 | - (void)enumerateKeysAndObjectsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 4623 | (void (NS_NOESCAPE ^)(BOOL key, ObjectType object, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4624 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4625 | /** |
| 4626 | * Adds the keys and values from another dictionary. |
| 4627 | * |
| 4628 | * @param otherDictionary Dictionary containing entries to be added to this |
| 4629 | * dictionary. |
| 4630 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4631 | - (void)addEntriesFromDictionary:(GPBBoolObjectDictionary *)otherDictionary; |
| 4632 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4633 | /** |
| 4634 | * Sets the value for the given key. |
| 4635 | * |
| 4636 | * @param object The value to set. |
| 4637 | * @param key The key under which to store the value. |
| 4638 | **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 4639 | - (void)setObject:(ObjectType)object forKey:(BOOL)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4640 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4641 | /** |
| 4642 | * Removes the entry for the given key. |
| 4643 | * |
| 4644 | * @param aKey Key to be removed from this dictionary. |
| 4645 | **/ |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 4646 | - (void)removeObjectForKey:(BOOL)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4647 | |
| 4648 | /** |
| 4649 | * Removes all entries in this dictionary. |
| 4650 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4651 | - (void)removeAll; |
| 4652 | |
| 4653 | @end |
| 4654 | |
| 4655 | #pragma mark - String -> UInt32 |
| 4656 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4657 | /** |
| 4658 | * Class used for map fields of <NSString, uint32_t> |
| 4659 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 4660 | * |
| 4661 | * @note This class is not meant to be subclassed. |
| 4662 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4663 | @interface GPBStringUInt32Dictionary : NSObject <NSCopying> |
| 4664 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4665 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4666 | @property(nonatomic, readonly) NSUInteger count; |
| 4667 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4668 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4669 | * Initializes this dictionary, copying the given values and keys. |
| 4670 | * |
| 4671 | * @param values The values to be placed in this dictionary. |
| 4672 | * @param keys The keys under which to store the values. |
| 4673 | * @param count The number of elements to copy into the dictionary. |
| 4674 | * |
| 4675 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 4676 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 4677 | - (instancetype)initWithUInt32s:(const uint32_t [__nullable])values |
| 4678 | forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4679 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4680 | |
| 4681 | /** |
| 4682 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 4683 | * |
| 4684 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 4685 | * |
| 4686 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 4687 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4688 | - (instancetype)initWithDictionary:(GPBStringUInt32Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4689 | |
| 4690 | /** |
| 4691 | * Initializes this dictionary with the requested capacity. |
| 4692 | * |
| 4693 | * @param numItems Number of items needed for this dictionary. |
| 4694 | * |
| 4695 | * @return A newly initialized dictionary with the requested capacity. |
| 4696 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4697 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 4698 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4699 | /** |
| 4700 | * Gets the value for the given key. |
| 4701 | * |
| 4702 | * @param value Pointer into which the value will be set, if found. |
| 4703 | * @param key Key under which the value is stored, if present. |
| 4704 | * |
| 4705 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 4706 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4707 | - (BOOL)getUInt32:(nullable uint32_t *)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4708 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4709 | /** |
| 4710 | * Enumerates the keys and values on this dictionary with the given block. |
| 4711 | * |
| 4712 | * @param block The block to enumerate with. |
| 4713 | * **key**: The key for the current entry. |
| 4714 | * **value**: The value for the current entry |
| 4715 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 4716 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4717 | - (void)enumerateKeysAndUInt32sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 4718 | (void (NS_NOESCAPE ^)(NSString *key, uint32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4719 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4720 | /** |
| 4721 | * Adds the keys and values from another dictionary. |
| 4722 | * |
| 4723 | * @param otherDictionary Dictionary containing entries to be added to this |
| 4724 | * dictionary. |
| 4725 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4726 | - (void)addEntriesFromDictionary:(GPBStringUInt32Dictionary *)otherDictionary; |
| 4727 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4728 | /** |
| 4729 | * Sets the value for the given key. |
| 4730 | * |
| 4731 | * @param value The value to set. |
| 4732 | * @param key The key under which to store the value. |
| 4733 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4734 | - (void)setUInt32:(uint32_t)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4735 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4736 | /** |
| 4737 | * Removes the entry for the given key. |
| 4738 | * |
| 4739 | * @param aKey Key to be removed from this dictionary. |
| 4740 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4741 | - (void)removeUInt32ForKey:(NSString *)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4742 | |
| 4743 | /** |
| 4744 | * Removes all entries in this dictionary. |
| 4745 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4746 | - (void)removeAll; |
| 4747 | |
| 4748 | @end |
| 4749 | |
| 4750 | #pragma mark - String -> Int32 |
| 4751 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4752 | /** |
| 4753 | * Class used for map fields of <NSString, int32_t> |
| 4754 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 4755 | * |
| 4756 | * @note This class is not meant to be subclassed. |
| 4757 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4758 | @interface GPBStringInt32Dictionary : NSObject <NSCopying> |
| 4759 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4760 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4761 | @property(nonatomic, readonly) NSUInteger count; |
| 4762 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4763 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4764 | * Initializes this dictionary, copying the given values and keys. |
| 4765 | * |
| 4766 | * @param values The values to be placed in this dictionary. |
| 4767 | * @param keys The keys under which to store the values. |
| 4768 | * @param count The number of elements to copy into the dictionary. |
| 4769 | * |
| 4770 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 4771 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 4772 | - (instancetype)initWithInt32s:(const int32_t [__nullable])values |
| 4773 | forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4774 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4775 | |
| 4776 | /** |
| 4777 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 4778 | * |
| 4779 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 4780 | * |
| 4781 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 4782 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4783 | - (instancetype)initWithDictionary:(GPBStringInt32Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4784 | |
| 4785 | /** |
| 4786 | * Initializes this dictionary with the requested capacity. |
| 4787 | * |
| 4788 | * @param numItems Number of items needed for this dictionary. |
| 4789 | * |
| 4790 | * @return A newly initialized dictionary with the requested capacity. |
| 4791 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4792 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 4793 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4794 | /** |
| 4795 | * Gets the value for the given key. |
| 4796 | * |
| 4797 | * @param value Pointer into which the value will be set, if found. |
| 4798 | * @param key Key under which the value is stored, if present. |
| 4799 | * |
| 4800 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 4801 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4802 | - (BOOL)getInt32:(nullable int32_t *)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4803 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4804 | /** |
| 4805 | * Enumerates the keys and values on this dictionary with the given block. |
| 4806 | * |
| 4807 | * @param block The block to enumerate with. |
| 4808 | * **key**: The key for the current entry. |
| 4809 | * **value**: The value for the current entry |
| 4810 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 4811 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4812 | - (void)enumerateKeysAndInt32sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 4813 | (void (NS_NOESCAPE ^)(NSString *key, int32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4814 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4815 | /** |
| 4816 | * Adds the keys and values from another dictionary. |
| 4817 | * |
| 4818 | * @param otherDictionary Dictionary containing entries to be added to this |
| 4819 | * dictionary. |
| 4820 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4821 | - (void)addEntriesFromDictionary:(GPBStringInt32Dictionary *)otherDictionary; |
| 4822 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4823 | /** |
| 4824 | * Sets the value for the given key. |
| 4825 | * |
| 4826 | * @param value The value to set. |
| 4827 | * @param key The key under which to store the value. |
| 4828 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4829 | - (void)setInt32:(int32_t)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4830 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4831 | /** |
| 4832 | * Removes the entry for the given key. |
| 4833 | * |
| 4834 | * @param aKey Key to be removed from this dictionary. |
| 4835 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4836 | - (void)removeInt32ForKey:(NSString *)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4837 | |
| 4838 | /** |
| 4839 | * Removes all entries in this dictionary. |
| 4840 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4841 | - (void)removeAll; |
| 4842 | |
| 4843 | @end |
| 4844 | |
| 4845 | #pragma mark - String -> UInt64 |
| 4846 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4847 | /** |
| 4848 | * Class used for map fields of <NSString, uint64_t> |
| 4849 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 4850 | * |
| 4851 | * @note This class is not meant to be subclassed. |
| 4852 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4853 | @interface GPBStringUInt64Dictionary : NSObject <NSCopying> |
| 4854 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4855 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4856 | @property(nonatomic, readonly) NSUInteger count; |
| 4857 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4858 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4859 | * Initializes this dictionary, copying the given values and keys. |
| 4860 | * |
| 4861 | * @param values The values to be placed in this dictionary. |
| 4862 | * @param keys The keys under which to store the values. |
| 4863 | * @param count The number of elements to copy into the dictionary. |
| 4864 | * |
| 4865 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 4866 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 4867 | - (instancetype)initWithUInt64s:(const uint64_t [__nullable])values |
| 4868 | forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4869 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4870 | |
| 4871 | /** |
| 4872 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 4873 | * |
| 4874 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 4875 | * |
| 4876 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 4877 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4878 | - (instancetype)initWithDictionary:(GPBStringUInt64Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4879 | |
| 4880 | /** |
| 4881 | * Initializes this dictionary with the requested capacity. |
| 4882 | * |
| 4883 | * @param numItems Number of items needed for this dictionary. |
| 4884 | * |
| 4885 | * @return A newly initialized dictionary with the requested capacity. |
| 4886 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4887 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 4888 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4889 | /** |
| 4890 | * Gets the value for the given key. |
| 4891 | * |
| 4892 | * @param value Pointer into which the value will be set, if found. |
| 4893 | * @param key Key under which the value is stored, if present. |
| 4894 | * |
| 4895 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 4896 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4897 | - (BOOL)getUInt64:(nullable uint64_t *)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4898 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4899 | /** |
| 4900 | * Enumerates the keys and values on this dictionary with the given block. |
| 4901 | * |
| 4902 | * @param block The block to enumerate with. |
| 4903 | * **key**: The key for the current entry. |
| 4904 | * **value**: The value for the current entry |
| 4905 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 4906 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4907 | - (void)enumerateKeysAndUInt64sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 4908 | (void (NS_NOESCAPE ^)(NSString *key, uint64_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4909 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4910 | /** |
| 4911 | * Adds the keys and values from another dictionary. |
| 4912 | * |
| 4913 | * @param otherDictionary Dictionary containing entries to be added to this |
| 4914 | * dictionary. |
| 4915 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4916 | - (void)addEntriesFromDictionary:(GPBStringUInt64Dictionary *)otherDictionary; |
| 4917 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4918 | /** |
| 4919 | * Sets the value for the given key. |
| 4920 | * |
| 4921 | * @param value The value to set. |
| 4922 | * @param key The key under which to store the value. |
| 4923 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4924 | - (void)setUInt64:(uint64_t)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4925 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4926 | /** |
| 4927 | * Removes the entry for the given key. |
| 4928 | * |
| 4929 | * @param aKey Key to be removed from this dictionary. |
| 4930 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4931 | - (void)removeUInt64ForKey:(NSString *)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4932 | |
| 4933 | /** |
| 4934 | * Removes all entries in this dictionary. |
| 4935 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4936 | - (void)removeAll; |
| 4937 | |
| 4938 | @end |
| 4939 | |
| 4940 | #pragma mark - String -> Int64 |
| 4941 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4942 | /** |
| 4943 | * Class used for map fields of <NSString, int64_t> |
| 4944 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 4945 | * |
| 4946 | * @note This class is not meant to be subclassed. |
| 4947 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4948 | @interface GPBStringInt64Dictionary : NSObject <NSCopying> |
| 4949 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4950 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4951 | @property(nonatomic, readonly) NSUInteger count; |
| 4952 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4953 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4954 | * Initializes this dictionary, copying the given values and keys. |
| 4955 | * |
| 4956 | * @param values The values to be placed in this dictionary. |
| 4957 | * @param keys The keys under which to store the values. |
| 4958 | * @param count The number of elements to copy into the dictionary. |
| 4959 | * |
| 4960 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 4961 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 4962 | - (instancetype)initWithInt64s:(const int64_t [__nullable])values |
| 4963 | forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4964 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4965 | |
| 4966 | /** |
| 4967 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 4968 | * |
| 4969 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 4970 | * |
| 4971 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 4972 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4973 | - (instancetype)initWithDictionary:(GPBStringInt64Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4974 | |
| 4975 | /** |
| 4976 | * Initializes this dictionary with the requested capacity. |
| 4977 | * |
| 4978 | * @param numItems Number of items needed for this dictionary. |
| 4979 | * |
| 4980 | * @return A newly initialized dictionary with the requested capacity. |
| 4981 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4982 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 4983 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4984 | /** |
| 4985 | * Gets the value for the given key. |
| 4986 | * |
| 4987 | * @param value Pointer into which the value will be set, if found. |
| 4988 | * @param key Key under which the value is stored, if present. |
| 4989 | * |
| 4990 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 4991 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 4992 | - (BOOL)getInt64:(nullable int64_t *)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 4993 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 4994 | /** |
| 4995 | * Enumerates the keys and values on this dictionary with the given block. |
| 4996 | * |
| 4997 | * @param block The block to enumerate with. |
| 4998 | * **key**: The key for the current entry. |
| 4999 | * **value**: The value for the current entry |
| 5000 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 5001 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5002 | - (void)enumerateKeysAndInt64sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 5003 | (void (NS_NOESCAPE ^)(NSString *key, int64_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5004 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5005 | /** |
| 5006 | * Adds the keys and values from another dictionary. |
| 5007 | * |
| 5008 | * @param otherDictionary Dictionary containing entries to be added to this |
| 5009 | * dictionary. |
| 5010 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5011 | - (void)addEntriesFromDictionary:(GPBStringInt64Dictionary *)otherDictionary; |
| 5012 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5013 | /** |
| 5014 | * Sets the value for the given key. |
| 5015 | * |
| 5016 | * @param value The value to set. |
| 5017 | * @param key The key under which to store the value. |
| 5018 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5019 | - (void)setInt64:(int64_t)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5020 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5021 | /** |
| 5022 | * Removes the entry for the given key. |
| 5023 | * |
| 5024 | * @param aKey Key to be removed from this dictionary. |
| 5025 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5026 | - (void)removeInt64ForKey:(NSString *)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5027 | |
| 5028 | /** |
| 5029 | * Removes all entries in this dictionary. |
| 5030 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5031 | - (void)removeAll; |
| 5032 | |
| 5033 | @end |
| 5034 | |
| 5035 | #pragma mark - String -> Bool |
| 5036 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5037 | /** |
| 5038 | * Class used for map fields of <NSString, BOOL> |
| 5039 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 5040 | * |
| 5041 | * @note This class is not meant to be subclassed. |
| 5042 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5043 | @interface GPBStringBoolDictionary : NSObject <NSCopying> |
| 5044 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5045 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5046 | @property(nonatomic, readonly) NSUInteger count; |
| 5047 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5048 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5049 | * Initializes this dictionary, copying the given values and keys. |
| 5050 | * |
| 5051 | * @param values The values to be placed in this dictionary. |
| 5052 | * @param keys The keys under which to store the values. |
| 5053 | * @param count The number of elements to copy into the dictionary. |
| 5054 | * |
| 5055 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 5056 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 5057 | - (instancetype)initWithBools:(const BOOL [__nullable])values |
| 5058 | forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5059 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5060 | |
| 5061 | /** |
| 5062 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 5063 | * |
| 5064 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 5065 | * |
| 5066 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 5067 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5068 | - (instancetype)initWithDictionary:(GPBStringBoolDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5069 | |
| 5070 | /** |
| 5071 | * Initializes this dictionary with the requested capacity. |
| 5072 | * |
| 5073 | * @param numItems Number of items needed for this dictionary. |
| 5074 | * |
| 5075 | * @return A newly initialized dictionary with the requested capacity. |
| 5076 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5077 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 5078 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5079 | /** |
| 5080 | * Gets the value for the given key. |
| 5081 | * |
| 5082 | * @param value Pointer into which the value will be set, if found. |
| 5083 | * @param key Key under which the value is stored, if present. |
| 5084 | * |
| 5085 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 5086 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5087 | - (BOOL)getBool:(nullable BOOL *)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5088 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5089 | /** |
| 5090 | * Enumerates the keys and values on this dictionary with the given block. |
| 5091 | * |
| 5092 | * @param block The block to enumerate with. |
| 5093 | * **key**: The key for the current entry. |
| 5094 | * **value**: The value for the current entry |
| 5095 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 5096 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5097 | - (void)enumerateKeysAndBoolsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 5098 | (void (NS_NOESCAPE ^)(NSString *key, BOOL value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5099 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5100 | /** |
| 5101 | * Adds the keys and values from another dictionary. |
| 5102 | * |
| 5103 | * @param otherDictionary Dictionary containing entries to be added to this |
| 5104 | * dictionary. |
| 5105 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5106 | - (void)addEntriesFromDictionary:(GPBStringBoolDictionary *)otherDictionary; |
| 5107 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5108 | /** |
| 5109 | * Sets the value for the given key. |
| 5110 | * |
| 5111 | * @param value The value to set. |
| 5112 | * @param key The key under which to store the value. |
| 5113 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5114 | - (void)setBool:(BOOL)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5115 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5116 | /** |
| 5117 | * Removes the entry for the given key. |
| 5118 | * |
| 5119 | * @param aKey Key to be removed from this dictionary. |
| 5120 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5121 | - (void)removeBoolForKey:(NSString *)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5122 | |
| 5123 | /** |
| 5124 | * Removes all entries in this dictionary. |
| 5125 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5126 | - (void)removeAll; |
| 5127 | |
| 5128 | @end |
| 5129 | |
| 5130 | #pragma mark - String -> Float |
| 5131 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5132 | /** |
| 5133 | * Class used for map fields of <NSString, float> |
| 5134 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 5135 | * |
| 5136 | * @note This class is not meant to be subclassed. |
| 5137 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5138 | @interface GPBStringFloatDictionary : NSObject <NSCopying> |
| 5139 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5140 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5141 | @property(nonatomic, readonly) NSUInteger count; |
| 5142 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5143 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5144 | * Initializes this dictionary, copying the given values and keys. |
| 5145 | * |
| 5146 | * @param values The values to be placed in this dictionary. |
| 5147 | * @param keys The keys under which to store the values. |
| 5148 | * @param count The number of elements to copy into the dictionary. |
| 5149 | * |
| 5150 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 5151 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 5152 | - (instancetype)initWithFloats:(const float [__nullable])values |
| 5153 | forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5154 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5155 | |
| 5156 | /** |
| 5157 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 5158 | * |
| 5159 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 5160 | * |
| 5161 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 5162 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5163 | - (instancetype)initWithDictionary:(GPBStringFloatDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5164 | |
| 5165 | /** |
| 5166 | * Initializes this dictionary with the requested capacity. |
| 5167 | * |
| 5168 | * @param numItems Number of items needed for this dictionary. |
| 5169 | * |
| 5170 | * @return A newly initialized dictionary with the requested capacity. |
| 5171 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5172 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 5173 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5174 | /** |
| 5175 | * Gets the value for the given key. |
| 5176 | * |
| 5177 | * @param value Pointer into which the value will be set, if found. |
| 5178 | * @param key Key under which the value is stored, if present. |
| 5179 | * |
| 5180 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 5181 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5182 | - (BOOL)getFloat:(nullable float *)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5183 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5184 | /** |
| 5185 | * Enumerates the keys and values on this dictionary with the given block. |
| 5186 | * |
| 5187 | * @param block The block to enumerate with. |
| 5188 | * **key**: The key for the current entry. |
| 5189 | * **value**: The value for the current entry |
| 5190 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 5191 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5192 | - (void)enumerateKeysAndFloatsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 5193 | (void (NS_NOESCAPE ^)(NSString *key, float value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5194 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5195 | /** |
| 5196 | * Adds the keys and values from another dictionary. |
| 5197 | * |
| 5198 | * @param otherDictionary Dictionary containing entries to be added to this |
| 5199 | * dictionary. |
| 5200 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5201 | - (void)addEntriesFromDictionary:(GPBStringFloatDictionary *)otherDictionary; |
| 5202 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5203 | /** |
| 5204 | * Sets the value for the given key. |
| 5205 | * |
| 5206 | * @param value The value to set. |
| 5207 | * @param key The key under which to store the value. |
| 5208 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5209 | - (void)setFloat:(float)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5210 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5211 | /** |
| 5212 | * Removes the entry for the given key. |
| 5213 | * |
| 5214 | * @param aKey Key to be removed from this dictionary. |
| 5215 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5216 | - (void)removeFloatForKey:(NSString *)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5217 | |
| 5218 | /** |
| 5219 | * Removes all entries in this dictionary. |
| 5220 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5221 | - (void)removeAll; |
| 5222 | |
| 5223 | @end |
| 5224 | |
| 5225 | #pragma mark - String -> Double |
| 5226 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5227 | /** |
| 5228 | * Class used for map fields of <NSString, double> |
| 5229 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 5230 | * |
| 5231 | * @note This class is not meant to be subclassed. |
| 5232 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5233 | @interface GPBStringDoubleDictionary : NSObject <NSCopying> |
| 5234 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5235 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5236 | @property(nonatomic, readonly) NSUInteger count; |
| 5237 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5238 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5239 | * Initializes this dictionary, copying the given values and keys. |
| 5240 | * |
| 5241 | * @param values The values to be placed in this dictionary. |
| 5242 | * @param keys The keys under which to store the values. |
| 5243 | * @param count The number of elements to copy into the dictionary. |
| 5244 | * |
| 5245 | * @return A newly initialized dictionary with a copy of the values and keys. |
| 5246 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 5247 | - (instancetype)initWithDoubles:(const double [__nullable])values |
| 5248 | forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5249 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5250 | |
| 5251 | /** |
| 5252 | * Initializes this dictionary, copying the entries from the given dictionary. |
| 5253 | * |
| 5254 | * @param dictionary Dictionary containing the entries to add to this dictionary. |
| 5255 | * |
| 5256 | * @return A newly initialized dictionary with the entries of the given dictionary. |
| 5257 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5258 | - (instancetype)initWithDictionary:(GPBStringDoubleDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5259 | |
| 5260 | /** |
| 5261 | * Initializes this dictionary with the requested capacity. |
| 5262 | * |
| 5263 | * @param numItems Number of items needed for this dictionary. |
| 5264 | * |
| 5265 | * @return A newly initialized dictionary with the requested capacity. |
| 5266 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5267 | - (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 5268 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5269 | /** |
| 5270 | * Gets the value for the given key. |
| 5271 | * |
| 5272 | * @param value Pointer into which the value will be set, if found. |
| 5273 | * @param key Key under which the value is stored, if present. |
| 5274 | * |
| 5275 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 5276 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5277 | - (BOOL)getDouble:(nullable double *)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5278 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5279 | /** |
| 5280 | * Enumerates the keys and values on this dictionary with the given block. |
| 5281 | * |
| 5282 | * @param block The block to enumerate with. |
| 5283 | * **key**: The key for the current entry. |
| 5284 | * **value**: The value for the current entry |
| 5285 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 5286 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5287 | - (void)enumerateKeysAndDoublesUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 5288 | (void (NS_NOESCAPE ^)(NSString *key, double value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5289 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5290 | /** |
| 5291 | * Adds the keys and values from another dictionary. |
| 5292 | * |
| 5293 | * @param otherDictionary Dictionary containing entries to be added to this |
| 5294 | * dictionary. |
| 5295 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5296 | - (void)addEntriesFromDictionary:(GPBStringDoubleDictionary *)otherDictionary; |
| 5297 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5298 | /** |
| 5299 | * Sets the value for the given key. |
| 5300 | * |
| 5301 | * @param value The value to set. |
| 5302 | * @param key The key under which to store the value. |
| 5303 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5304 | - (void)setDouble:(double)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5305 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5306 | /** |
| 5307 | * Removes the entry for the given key. |
| 5308 | * |
| 5309 | * @param aKey Key to be removed from this dictionary. |
| 5310 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5311 | - (void)removeDoubleForKey:(NSString *)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5312 | |
| 5313 | /** |
| 5314 | * Removes all entries in this dictionary. |
| 5315 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5316 | - (void)removeAll; |
| 5317 | |
| 5318 | @end |
| 5319 | |
| 5320 | #pragma mark - String -> Enum |
| 5321 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5322 | /** |
| 5323 | * Class used for map fields of <NSString, int32_t> |
| 5324 | * values. This performs better than boxing into NSNumbers in NSDictionaries. |
| 5325 | * |
| 5326 | * @note This class is not meant to be subclassed. |
| 5327 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5328 | @interface GPBStringEnumDictionary : NSObject <NSCopying> |
| 5329 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5330 | /** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5331 | @property(nonatomic, readonly) NSUInteger count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5332 | /** The validation function to check if the enums are valid. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5333 | @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; |
| 5334 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5335 | /** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5336 | * Initializes a dictionary with the given validation function. |
| 5337 | * |
| 5338 | * @param func The enum validation function for the dictionary. |
| 5339 | * |
| 5340 | * @return A newly initialized dictionary. |
| 5341 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 5342 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5343 | |
| 5344 | /** |
| 5345 | * Initializes a dictionary with the entries given. |
| 5346 | * |
| 5347 | * @param func The enum validation function for the dictionary. |
| 5348 | * @param values The raw enum values values to be placed in the dictionary. |
| 5349 | * @param keys The keys under which to store the values. |
| 5350 | * @param count The number of entries to store in the dictionary. |
| 5351 | * |
| 5352 | * @return A newly initialized dictionary with the keys and values in it. |
| 5353 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 5354 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 5355 | rawValues:(const int32_t [__nullable])values |
| 5356 | forKeys:(const NSString * __nonnull GPB_UNSAFE_UNRETAINED [__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5357 | count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5358 | |
| 5359 | /** |
| 5360 | * Initializes a dictionary with the entries from the given. |
| 5361 | * dictionary. |
| 5362 | * |
| 5363 | * @param dictionary Dictionary containing the entries to add to the dictionary. |
| 5364 | * |
| 5365 | * @return A newly initialized dictionary with the entries from the given |
| 5366 | * dictionary in it. |
| 5367 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5368 | - (instancetype)initWithDictionary:(GPBStringEnumDictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5369 | |
| 5370 | /** |
| 5371 | * Initializes a dictionary with the given capacity. |
| 5372 | * |
| 5373 | * @param func The enum validation function for the dictionary. |
| 5374 | * @param numItems Capacity needed for the dictionary. |
| 5375 | * |
| 5376 | * @return A newly initialized dictionary with the given capacity. |
| 5377 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 5378 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5379 | capacity:(NSUInteger)numItems; |
| 5380 | |
| 5381 | // These will return kGPBUnrecognizedEnumeratorValue if the value for the key |
| 5382 | // is not a valid enumerator as defined by validationFunc. If the actual value is |
| 5383 | // desired, use "raw" version of the method. |
| 5384 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5385 | /** |
| 5386 | * Gets the value for the given key. |
| 5387 | * |
| 5388 | * @param value Pointer into which the value will be set, if found. |
| 5389 | * @param key Key under which the value is stored, if present. |
| 5390 | * |
| 5391 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 5392 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5393 | - (BOOL)getEnum:(nullable int32_t *)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5394 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5395 | /** |
| 5396 | * Enumerates the keys and values on this dictionary with the given block. |
| 5397 | * |
| 5398 | * @param block The block to enumerate with. |
| 5399 | * **key**: The key for the current entry. |
| 5400 | * **value**: The value for the current entry |
| 5401 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 5402 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5403 | - (void)enumerateKeysAndEnumsUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 5404 | (void (NS_NOESCAPE ^)(NSString *key, int32_t value, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5405 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5406 | /** |
| 5407 | * Gets the raw enum value for the given key. |
| 5408 | * |
| 5409 | * @note This method bypass the validationFunc to enable the access of values that |
| 5410 | * were not known at the time the binary was compiled. |
| 5411 | * |
| 5412 | * @param rawValue Pointer into which the value will be set, if found. |
| 5413 | * @param key Key under which the value is stored, if present. |
| 5414 | * |
| 5415 | * @return YES if the key was found and the value was copied, NO otherwise. |
| 5416 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5417 | - (BOOL)getRawValue:(nullable int32_t *)rawValue forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5418 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5419 | /** |
| 5420 | * Enumerates the keys and values on this dictionary with the given block. |
| 5421 | * |
| 5422 | * @note This method bypass the validationFunc to enable the access of values that |
| 5423 | * were not known at the time the binary was compiled. |
| 5424 | * |
| 5425 | * @param block The block to enumerate with. |
| 5426 | * **key**: The key for the current entry. |
| 5427 | * **rawValue**: The value for the current entry |
| 5428 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 5429 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5430 | - (void)enumerateKeysAndRawValuesUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 5431 | (void (NS_NOESCAPE ^)(NSString *key, int32_t rawValue, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5432 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5433 | /** |
| 5434 | * Adds the keys and raw enum values from another dictionary. |
| 5435 | * |
| 5436 | * @note This method bypass the validationFunc to enable the setting of values that |
| 5437 | * were not known at the time the binary was compiled. |
| 5438 | * |
| 5439 | * @param otherDictionary Dictionary containing entries to be added to this |
| 5440 | * dictionary. |
| 5441 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5442 | - (void)addRawEntriesFromDictionary:(GPBStringEnumDictionary *)otherDictionary; |
| 5443 | |
| 5444 | // If value is not a valid enumerator as defined by validationFunc, these |
| 5445 | // methods will assert in debug, and will log in release and assign the value |
| 5446 | // to the default value. Use the rawValue methods below to assign non enumerator |
| 5447 | // values. |
| 5448 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5449 | /** |
| 5450 | * Sets the value for the given key. |
| 5451 | * |
| 5452 | * @param value The value to set. |
| 5453 | * @param key The key under which to store the value. |
| 5454 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5455 | - (void)setEnum:(int32_t)value forKey:(NSString *)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5456 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5457 | /** |
| 5458 | * Sets the raw enum value for the given key. |
| 5459 | * |
| 5460 | * @note This method bypass the validationFunc to enable the setting of values that |
| 5461 | * were not known at the time the binary was compiled. |
| 5462 | * |
| 5463 | * @param rawValue The raw enum value to set. |
| 5464 | * @param key The key under which to store the raw enum value. |
| 5465 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5466 | - (void)setRawValue:(int32_t)rawValue forKey:(NSString *)key; |
| 5467 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5468 | /** |
| 5469 | * Removes the entry for the given key. |
| 5470 | * |
| 5471 | * @param aKey Key to be removed from this dictionary. |
| 5472 | **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5473 | - (void)removeEnumForKey:(NSString *)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5474 | |
| 5475 | /** |
| 5476 | * Removes all entries in this dictionary. |
| 5477 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5478 | - (void)removeAll; |
| 5479 | |
| 5480 | @end |
| 5481 | |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 5482 | // clang-format on |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5483 | //%PDDM-EXPAND-END DECLARE_DICTIONARIES() |
| 5484 | |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 5485 | NS_ASSUME_NONNULL_END |
| 5486 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5487 | //%PDDM-DEFINE DECLARE_DICTIONARIES() |
| 5488 | //%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt32, uint32_t) |
| 5489 | //%DICTIONARY_INTERFACES_FOR_POD_KEY(Int32, int32_t) |
| 5490 | //%DICTIONARY_INTERFACES_FOR_POD_KEY(UInt64, uint64_t) |
| 5491 | //%DICTIONARY_INTERFACES_FOR_POD_KEY(Int64, int64_t) |
| 5492 | //%DICTIONARY_INTERFACES_FOR_POD_KEY(Bool, BOOL) |
| 5493 | //%DICTIONARY_POD_INTERFACES_FOR_KEY(String, NSString, *, OBJECT) |
| 5494 | //%PDDM-DEFINE DICTIONARY_INTERFACES_FOR_POD_KEY(KEY_NAME, KEY_TYPE) |
| 5495 | //%DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, , POD) |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 5496 | //%DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, Object, ObjectType) |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5497 | //%PDDM-DEFINE DICTIONARY_POD_INTERFACES_FOR_KEY(KEY_NAME, KEY_TYPE, KisP, KHELPER) |
| 5498 | //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt32, uint32_t) |
| 5499 | //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int32, int32_t) |
| 5500 | //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, UInt64, uint64_t) |
| 5501 | //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Int64, int64_t) |
| 5502 | //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Bool, BOOL) |
| 5503 | //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Float, float) |
| 5504 | //%DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Double, double) |
| 5505 | //%DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, Enum, int32_t) |
| 5506 | //%PDDM-DEFINE DICTIONARY_KEY_TO_POD_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE) |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5507 | //%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, POD, VALUE_NAME, value) |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5508 | //%PDDM-DEFINE DICTIONARY_POD_KEY_TO_OBJECT_INTERFACE(KEY_NAME, KEY_TYPE, VALUE_NAME, VALUE_TYPE) |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5509 | //%DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, , POD, VALUE_NAME, VALUE_TYPE, OBJECT, Object, object) |
| 5510 | //%PDDM-DEFINE VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME) |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5511 | //%/** |
| 5512 | //% * Gets the value for the given key. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5513 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5514 | //% * @param value Pointer into which the value will be set, if found. |
| 5515 | //% * @param key Key under which the value is stored, if present. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5516 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5517 | //% * @return YES if the key was found and the value was copied, NO otherwise. |
| 5518 | //% **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5519 | //%- (BOOL)get##VNAME##:(nullable VALUE_TYPE *)value forKey:(KEY_TYPE)key; |
| 5520 | //%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_TYPE, VNAME) |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5521 | //%/** |
| 5522 | //% * Fetches the object stored under the given key. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5523 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5524 | //% * @param key Key under which the value is stored, if present. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5525 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5526 | //% * @return The object if found, nil otherwise. |
| 5527 | //% **/ |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 5528 | //%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key; |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5529 | //%PDDM-DEFINE VALUE_FOR_KEY_Enum(KEY_TYPE, VALUE_TYPE, VNAME) |
| 5530 | //%VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME) |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5531 | //%PDDM-DEFINE ARRAY_ARG_MODIFIERPOD() |
| 5532 | // Nothing |
| 5533 | //%PDDM-DEFINE ARRAY_ARG_MODIFIEREnum() |
| 5534 | // Nothing |
| 5535 | //%PDDM-DEFINE ARRAY_ARG_MODIFIEROBJECT() |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 5536 | //%__nonnull GPB_UNSAFE_UNRETAINED ## |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 5537 | //%PDDM-DEFINE DICTIONARY_CLASS_DECLPOD(KEY_NAME, VALUE_NAME, VALUE_TYPE) |
| 5538 | //%GPB##KEY_NAME##VALUE_NAME##Dictionary |
| 5539 | //%PDDM-DEFINE DICTIONARY_CLASS_DECLEnum(KEY_NAME, VALUE_NAME, VALUE_TYPE) |
| 5540 | //%GPB##KEY_NAME##VALUE_NAME##Dictionary |
| 5541 | //%PDDM-DEFINE DICTIONARY_CLASS_DECLOBJECT(KEY_NAME, VALUE_NAME, VALUE_TYPE) |
| 5542 | //%GPB##KEY_NAME##VALUE_NAME##Dictionary<__covariant VALUE_TYPE> |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5543 | //%PDDM-DEFINE DICTIONARY_COMMON_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5544 | //%#pragma mark - KEY_NAME -> VALUE_NAME |
| 5545 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5546 | //%/** |
| 5547 | //% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##> |
| 5548 | //% * values. This performs better than boxing into NSNumbers in NSDictionaries. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5549 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5550 | //% * @note This class is not meant to be subclassed. |
| 5551 | //% **/ |
Thomas Van Lenten | 2480acb | 2015-11-30 14:38:04 -0500 | [diff] [blame] | 5552 | //%@interface DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) : NSObject <NSCopying> |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5553 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5554 | //%/** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5555 | //%@property(nonatomic, readonly) NSUInteger count; |
| 5556 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5557 | //%/** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5558 | //% * Initializes this dictionary, copying the given values and keys. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5559 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5560 | //% * @param ##VNAME_VAR##s The values to be placed in this dictionary. |
| 5561 | //% * @param keys ##VNAME_VAR$S## The keys under which to store the values. |
| 5562 | //% * @param count ##VNAME_VAR$S## The number of elements to copy into the dictionary. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5563 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5564 | //% * @return A newly initialized dictionary with a copy of the values and keys. |
| 5565 | //% **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 5566 | //%- (instancetype)initWith##VNAME##s:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])##VNAME_VAR##s |
| 5567 | //% ##VNAME$S## forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys |
Thomas Van Lenten | 1383d53 | 2015-09-29 11:41:53 -0400 | [diff] [blame] | 5568 | //% ##VNAME$S## count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5569 | //% |
| 5570 | //%/** |
| 5571 | //% * Initializes this dictionary, copying the entries from the given dictionary. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5572 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5573 | //% * @param dictionary Dictionary containing the entries to add to this dictionary. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5574 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5575 | //% * @return A newly initialized dictionary with the entries of the given dictionary. |
| 5576 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5577 | //%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5578 | //% |
| 5579 | //%/** |
| 5580 | //% * Initializes this dictionary with the requested capacity. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5581 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5582 | //% * @param numItems Number of items needed for this dictionary. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5583 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5584 | //% * @return A newly initialized dictionary with the requested capacity. |
| 5585 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5586 | //%- (instancetype)initWithCapacity:(NSUInteger)numItems; |
| 5587 | //% |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5588 | //%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5589 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5590 | //%/** |
| 5591 | //% * Adds the keys and values from another dictionary. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5592 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5593 | //% * @param otherDictionary Dictionary containing entries to be added to this |
| 5594 | //% * dictionary. |
| 5595 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5596 | //%- (void)addEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary; |
| 5597 | //% |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5598 | //%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5599 | //% |
| 5600 | //%@end |
| 5601 | //% |
| 5602 | |
| 5603 | //%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE) |
| 5604 | //%DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, Enum) |
| 5605 | //%PDDM-DEFINE DICTIONARY_KEY_TO_ENUM_INTERFACE2(KEY_NAME, KEY_TYPE, KisP, KHELPER, VALUE_NAME, VALUE_TYPE, VHELPER) |
| 5606 | //%#pragma mark - KEY_NAME -> VALUE_NAME |
| 5607 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5608 | //%/** |
| 5609 | //% * Class used for map fields of <##KEY_TYPE##, ##VALUE_TYPE##> |
| 5610 | //% * values. This performs better than boxing into NSNumbers in NSDictionaries. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5611 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5612 | //% * @note This class is not meant to be subclassed. |
| 5613 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5614 | //%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject <NSCopying> |
| 5615 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5616 | //%/** Number of entries stored in this dictionary. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5617 | //%@property(nonatomic, readonly) NSUInteger count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5618 | //%/** The validation function to check if the enums are valid. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5619 | //%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; |
| 5620 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5621 | //%/** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5622 | //% * Initializes a dictionary with the given validation function. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5623 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5624 | //% * @param func The enum validation function for the dictionary. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5625 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5626 | //% * @return A newly initialized dictionary. |
| 5627 | //% **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 5628 | //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5629 | //% |
| 5630 | //%/** |
| 5631 | //% * Initializes a dictionary with the entries given. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5632 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5633 | //% * @param func The enum validation function for the dictionary. |
| 5634 | //% * @param values The raw enum values values to be placed in the dictionary. |
| 5635 | //% * @param keys The keys under which to store the values. |
| 5636 | //% * @param count The number of entries to store in the dictionary. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5637 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5638 | //% * @return A newly initialized dictionary with the keys and values in it. |
| 5639 | //% **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 5640 | //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 5641 | //% rawValues:(const VALUE_TYPE ARRAY_ARG_MODIFIER##VHELPER()[__nullable])values |
| 5642 | //% forKeys:(const KEY_TYPE##KisP$S##KisP ARRAY_ARG_MODIFIER##KHELPER()[__nullable])keys |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5643 | //% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5644 | //% |
| 5645 | //%/** |
| 5646 | //% * Initializes a dictionary with the entries from the given. |
| 5647 | //% * dictionary. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5648 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5649 | //% * @param dictionary Dictionary containing the entries to add to the dictionary. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5650 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5651 | //% * @return A newly initialized dictionary with the entries from the given |
| 5652 | //% * dictionary in it. |
| 5653 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5654 | //%- (instancetype)initWithDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)dictionary; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5655 | //% |
| 5656 | //%/** |
| 5657 | //% * Initializes a dictionary with the given capacity. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5658 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5659 | //% * @param func The enum validation function for the dictionary. |
| 5660 | //% * @param numItems Capacity needed for the dictionary. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5661 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5662 | //% * @return A newly initialized dictionary with the given capacity. |
| 5663 | //% **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 5664 | //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5665 | //% capacity:(NSUInteger)numItems; |
| 5666 | //% |
| 5667 | //%// These will return kGPBUnrecognizedEnumeratorValue if the value for the key |
| 5668 | //%// is not a valid enumerator as defined by validationFunc. If the actual value is |
| 5669 | //%// desired, use "raw" version of the method. |
| 5670 | //% |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5671 | //%DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value) |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5672 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5673 | //%/** |
| 5674 | //% * Gets the raw enum value for the given key. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5675 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5676 | //% * @note This method bypass the validationFunc to enable the access of values that |
| 5677 | //% * were not known at the time the binary was compiled. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5678 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5679 | //% * @param rawValue Pointer into which the value will be set, if found. |
| 5680 | //% * @param key Key under which the value is stored, if present. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5681 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5682 | //% * @return YES if the key was found and the value was copied, NO otherwise. |
| 5683 | //% **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5684 | //%- (BOOL)getRawValue:(nullable VALUE_TYPE *)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5685 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5686 | //%/** |
| 5687 | //% * Enumerates the keys and values on this dictionary with the given block. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5688 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5689 | //% * @note This method bypass the validationFunc to enable the access of values that |
| 5690 | //% * were not known at the time the binary was compiled. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5691 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5692 | //% * @param block The block to enumerate with. |
| 5693 | //% * **key**: The key for the current entry. |
| 5694 | //% * **rawValue**: The value for the current entry |
| 5695 | //% * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 5696 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5697 | //%- (void)enumerateKeysAndRawValuesUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 5698 | //% (void (NS_NOESCAPE ^)(KEY_TYPE KisP##key, VALUE_TYPE rawValue, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5699 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5700 | //%/** |
| 5701 | //% * Adds the keys and raw enum values from another dictionary. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5702 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5703 | //% * @note This method bypass the validationFunc to enable the setting of values that |
| 5704 | //% * were not known at the time the binary was compiled. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5705 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5706 | //% * @param otherDictionary Dictionary containing entries to be added to this |
| 5707 | //% * dictionary. |
| 5708 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5709 | //%- (void)addRawEntriesFromDictionary:(GPB##KEY_NAME##VALUE_NAME##Dictionary *)otherDictionary; |
| 5710 | //% |
| 5711 | //%// If value is not a valid enumerator as defined by validationFunc, these |
| 5712 | //%// methods will assert in debug, and will log in release and assign the value |
| 5713 | //%// to the default value. Use the rawValue methods below to assign non enumerator |
| 5714 | //%// values. |
| 5715 | //% |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5716 | //%DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, Enum, value) |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5717 | //% |
| 5718 | //%@end |
| 5719 | //% |
| 5720 | |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5721 | //%PDDM-DEFINE DICTIONARY_IMMUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) |
| 5722 | //%VALUE_FOR_KEY_##VHELPER(KEY_TYPE##KisP$S##KisP, VALUE_TYPE, VNAME) |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5723 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5724 | //%/** |
| 5725 | //% * Enumerates the keys and values on this dictionary with the given block. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5726 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5727 | //% * @param block The block to enumerate with. |
| 5728 | //% * **key**: ##VNAME_VAR$S## The key for the current entry. |
| 5729 | //% * **VNAME_VAR**: The value for the current entry |
| 5730 | //% * **stop**: ##VNAME_VAR$S## A pointer to a boolean that when set stops the enumeration. |
| 5731 | //% **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5732 | //%- (void)enumerateKeysAnd##VNAME##sUsingBlock: |
Thomas Van Lenten | c486130 | 2018-12-04 10:52:20 -0500 | [diff] [blame] | 5733 | //% (void (NS_NOESCAPE ^)(KEY_TYPE KisP##key, VALUE_TYPE VNAME_VAR, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5734 | |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5735 | //%PDDM-DEFINE DICTIONARY_MUTABLE_INTERFACE(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE, VHELPER, VNAME, VNAME_VAR) |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5736 | //%/** |
| 5737 | //% * Sets the value for the given key. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5738 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5739 | //% * @param ##VNAME_VAR The value to set. |
| 5740 | //% * @param key ##VNAME_VAR$S## The key under which to store the value. |
| 5741 | //% **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5742 | //%- (void)set##VNAME##:(VALUE_TYPE)##VNAME_VAR forKey:(KEY_TYPE##KisP$S##KisP)key; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5743 | //%DICTIONARY_EXTRA_MUTABLE_METHODS_##VHELPER(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE) |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5744 | //%/** |
| 5745 | //% * Removes the entry for the given key. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5746 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5747 | //% * @param aKey Key to be removed from this dictionary. |
| 5748 | //% **/ |
Thomas Van Lenten | a230b5d | 2016-06-21 08:25:28 -0400 | [diff] [blame] | 5749 | //%- (void)remove##VNAME##ForKey:(KEY_TYPE##KisP$S##KisP)aKey; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5750 | //% |
| 5751 | //%/** |
| 5752 | //% * Removes all entries in this dictionary. |
| 5753 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5754 | //%- (void)removeAll; |
| 5755 | |
| 5756 | //%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_POD(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE) |
| 5757 | // Empty |
| 5758 | //%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_OBJECT(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE) |
| 5759 | // Empty |
| 5760 | //%PDDM-DEFINE DICTIONARY_EXTRA_MUTABLE_METHODS_Enum(KEY_NAME, KEY_TYPE, KisP, VALUE_NAME, VALUE_TYPE) |
| 5761 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5762 | //%/** |
| 5763 | //% * Sets the raw enum value for the given key. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5764 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5765 | //% * @note This method bypass the validationFunc to enable the setting of values that |
| 5766 | //% * were not known at the time the binary was compiled. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 5767 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 5768 | //% * @param rawValue The raw enum value to set. |
| 5769 | //% * @param key The key under which to store the raw enum value. |
| 5770 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 5771 | //%- (void)setRawValue:(VALUE_TYPE)rawValue forKey:(KEY_TYPE##KisP$S##KisP)key; |
| 5772 | //% |