Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1 | // Protocol Buffers - Google's data interchange format |
| 2 | // Copyright 2015 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 | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 35 | NS_ASSUME_NONNULL_BEGIN |
| 36 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 37 | //%PDDM-EXPAND DECLARE_ARRAYS() |
| 38 | // This block of code is generated, do not edit it directly. |
| 39 | |
| 40 | #pragma mark - Int32 |
| 41 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 42 | /** |
| 43 | * Class used for repeated fields of int32_t values. This performs better than |
| 44 | * boxing into NSNumbers in NSArrays. |
| 45 | * |
| 46 | * @note This class is not meant to be subclassed. |
| 47 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 48 | @interface GPBInt32Array : NSObject <NSCopying> |
| 49 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 50 | /** The number of elements contained in the array. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 51 | @property(nonatomic, readonly) NSUInteger count; |
| 52 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 53 | /** |
| 54 | * @return A newly instanced and empty GPBInt32Array. |
| 55 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 56 | + (instancetype)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | * Creates and initializes a GPBInt32Array with the single element given. |
| 60 | * |
| 61 | * @param value The value to be placed in the array. |
| 62 | * |
| 63 | * @return A newly instanced GPBInt32Array with value in it. |
| 64 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 65 | + (instancetype)arrayWithValue:(int32_t)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * Creates and initializes a GPBInt32Array with the contents of the given |
| 69 | * array. |
| 70 | * |
| 71 | * @param array Array with the contents to be put into the new array. |
| 72 | * |
| 73 | * @return A newly instanced GPBInt32Array with the contents of array. |
| 74 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 75 | + (instancetype)arrayWithValueArray:(GPBInt32Array *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 76 | |
| 77 | /** |
| 78 | * Creates and initializes a GPBInt32Array with the given capacity. |
| 79 | * |
| 80 | * @param count The capacity needed for the array. |
| 81 | * |
| 82 | * @return A newly instanced GPBInt32Array with a capacity of count. |
| 83 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 84 | + (instancetype)arrayWithCapacity:(NSUInteger)count; |
| 85 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 86 | /** |
| 87 | * @return A newly initialized and empty GPBInt32Array. |
| 88 | **/ |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 89 | - (instancetype)init NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * Initializes the array, copying the given values. |
| 93 | * |
| 94 | * @param values An array with the values to put inside this array. |
| 95 | * @param count The number of elements to copy into the array. |
| 96 | * |
| 97 | * @return A newly initialized GPBInt32Array with a copy of the values. |
| 98 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 99 | - (instancetype)initWithValues:(const int32_t [__nullable])values |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 100 | count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 101 | |
| 102 | /** |
| 103 | * Initializes the array, copying the given values. |
| 104 | * |
| 105 | * @param array An array with the values to put inside this array. |
| 106 | * |
| 107 | * @return A newly initialized GPBInt32Array with a copy of the values. |
| 108 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 109 | - (instancetype)initWithValueArray:(GPBInt32Array *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 110 | |
| 111 | /** |
| 112 | * Initializes the array with the given capacity. |
| 113 | * |
| 114 | * @param count The capacity needed for the array. |
| 115 | * |
| 116 | * @return A newly initialized GPBInt32Array with a capacity of count. |
| 117 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 118 | - (instancetype)initWithCapacity:(NSUInteger)count; |
| 119 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 120 | /** |
| 121 | * Gets the value at the given index. |
| 122 | * |
| 123 | * @param index The index of the value to get. |
| 124 | * |
| 125 | * @return The value at the given index. |
| 126 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 127 | - (int32_t)valueAtIndex:(NSUInteger)index; |
| 128 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 129 | /** |
| 130 | * Enumerates the values on this array with the given block. |
| 131 | * |
| 132 | * @param block The block to enumerate with. |
| 133 | * **value**: The current value being enumerated. |
| 134 | * **idx**: The index of the current value. |
| 135 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 136 | **/ |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 137 | - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 138 | |
| 139 | /** |
| 140 | * Enumerates the values on this array with the given block. |
| 141 | * |
| 142 | * @param opts Options to control the enumeration. |
| 143 | * @param block The block to enumerate with. |
| 144 | * **value**: The current value being enumerated. |
| 145 | * **idx**: The index of the current value. |
| 146 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 147 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 148 | - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 149 | usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 150 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 151 | /** |
| 152 | * Adds a value to this array. |
| 153 | * |
| 154 | * @param value The value to add to this array. |
| 155 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 156 | - (void)addValue:(int32_t)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 157 | |
| 158 | /** |
| 159 | * Adds values to this array. |
| 160 | * |
| 161 | * @param values The values to add to this array. |
| 162 | * @param count The number of elements to add. |
| 163 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 164 | - (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 165 | |
| 166 | /** |
| 167 | * Adds the values from the given array to this array. |
| 168 | * |
| 169 | * @param array The array containing the elements to add to this array. |
| 170 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 171 | - (void)addValuesFromArray:(GPBInt32Array *)array; |
| 172 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 173 | /** |
| 174 | * Inserts a value into the given position. |
| 175 | * |
| 176 | * @param value The value to add to this array. |
| 177 | * @param index The index into which to insert the value. |
| 178 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 179 | - (void)insertValue:(int32_t)value atIndex:(NSUInteger)index; |
| 180 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 181 | /** |
| 182 | * Replaces the value at the given index with the given value. |
| 183 | * |
| 184 | * @param index The index for which to replace the value. |
| 185 | * @param value The value to replace with. |
| 186 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 187 | - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value; |
| 188 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 189 | /** |
| 190 | * Removes the value at the given index. |
| 191 | * |
| 192 | * @param index The index of the value to remove. |
| 193 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 194 | - (void)removeValueAtIndex:(NSUInteger)index; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 195 | |
| 196 | /** |
| 197 | * Removes all the values from this array. |
| 198 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 199 | - (void)removeAll; |
| 200 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 201 | /** |
| 202 | * Exchanges the values between the given indexes. |
| 203 | * |
| 204 | * @param idx1 The index of the first element to exchange. |
| 205 | * @param idx2 The index of the second element to exchange. |
| 206 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 207 | - (void)exchangeValueAtIndex:(NSUInteger)idx1 |
| 208 | withValueAtIndex:(NSUInteger)idx2; |
| 209 | |
| 210 | @end |
| 211 | |
| 212 | #pragma mark - UInt32 |
| 213 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 214 | /** |
| 215 | * Class used for repeated fields of uint32_t values. This performs better than |
| 216 | * boxing into NSNumbers in NSArrays. |
| 217 | * |
| 218 | * @note This class is not meant to be subclassed. |
| 219 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 220 | @interface GPBUInt32Array : NSObject <NSCopying> |
| 221 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 222 | /** The number of elements contained in the array. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 223 | @property(nonatomic, readonly) NSUInteger count; |
| 224 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 225 | /** |
| 226 | * @return A newly instanced and empty GPBUInt32Array. |
| 227 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 228 | + (instancetype)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 229 | |
| 230 | /** |
| 231 | * Creates and initializes a GPBUInt32Array with the single element given. |
| 232 | * |
| 233 | * @param value The value to be placed in the array. |
| 234 | * |
| 235 | * @return A newly instanced GPBUInt32Array with value in it. |
| 236 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 237 | + (instancetype)arrayWithValue:(uint32_t)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 238 | |
| 239 | /** |
| 240 | * Creates and initializes a GPBUInt32Array with the contents of the given |
| 241 | * array. |
| 242 | * |
| 243 | * @param array Array with the contents to be put into the new array. |
| 244 | * |
| 245 | * @return A newly instanced GPBUInt32Array with the contents of array. |
| 246 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 247 | + (instancetype)arrayWithValueArray:(GPBUInt32Array *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 248 | |
| 249 | /** |
| 250 | * Creates and initializes a GPBUInt32Array with the given capacity. |
| 251 | * |
| 252 | * @param count The capacity needed for the array. |
| 253 | * |
| 254 | * @return A newly instanced GPBUInt32Array with a capacity of count. |
| 255 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 256 | + (instancetype)arrayWithCapacity:(NSUInteger)count; |
| 257 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 258 | /** |
| 259 | * @return A newly initialized and empty GPBUInt32Array. |
| 260 | **/ |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 261 | - (instancetype)init NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 262 | |
| 263 | /** |
| 264 | * Initializes the array, copying the given values. |
| 265 | * |
| 266 | * @param values An array with the values to put inside this array. |
| 267 | * @param count The number of elements to copy into the array. |
| 268 | * |
| 269 | * @return A newly initialized GPBUInt32Array with a copy of the values. |
| 270 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 271 | - (instancetype)initWithValues:(const uint32_t [__nullable])values |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 272 | count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 273 | |
| 274 | /** |
| 275 | * Initializes the array, copying the given values. |
| 276 | * |
| 277 | * @param array An array with the values to put inside this array. |
| 278 | * |
| 279 | * @return A newly initialized GPBUInt32Array with a copy of the values. |
| 280 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 281 | - (instancetype)initWithValueArray:(GPBUInt32Array *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 282 | |
| 283 | /** |
| 284 | * Initializes the array with the given capacity. |
| 285 | * |
| 286 | * @param count The capacity needed for the array. |
| 287 | * |
| 288 | * @return A newly initialized GPBUInt32Array with a capacity of count. |
| 289 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 290 | - (instancetype)initWithCapacity:(NSUInteger)count; |
| 291 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 292 | /** |
| 293 | * Gets the value at the given index. |
| 294 | * |
| 295 | * @param index The index of the value to get. |
| 296 | * |
| 297 | * @return The value at the given index. |
| 298 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 299 | - (uint32_t)valueAtIndex:(NSUInteger)index; |
| 300 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 301 | /** |
| 302 | * Enumerates the values on this array with the given block. |
| 303 | * |
| 304 | * @param block The block to enumerate with. |
| 305 | * **value**: The current value being enumerated. |
| 306 | * **idx**: The index of the current value. |
| 307 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 308 | **/ |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 309 | - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 310 | |
| 311 | /** |
| 312 | * Enumerates the values on this array with the given block. |
| 313 | * |
| 314 | * @param opts Options to control the enumeration. |
| 315 | * @param block The block to enumerate with. |
| 316 | * **value**: The current value being enumerated. |
| 317 | * **idx**: The index of the current value. |
| 318 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 319 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 320 | - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 321 | usingBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 322 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 323 | /** |
| 324 | * Adds a value to this array. |
| 325 | * |
| 326 | * @param value The value to add to this array. |
| 327 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 328 | - (void)addValue:(uint32_t)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 329 | |
| 330 | /** |
| 331 | * Adds values to this array. |
| 332 | * |
| 333 | * @param values The values to add to this array. |
| 334 | * @param count The number of elements to add. |
| 335 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 336 | - (void)addValues:(const uint32_t [__nullable])values count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 337 | |
| 338 | /** |
| 339 | * Adds the values from the given array to this array. |
| 340 | * |
| 341 | * @param array The array containing the elements to add to this array. |
| 342 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 343 | - (void)addValuesFromArray:(GPBUInt32Array *)array; |
| 344 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 345 | /** |
| 346 | * Inserts a value into the given position. |
| 347 | * |
| 348 | * @param value The value to add to this array. |
| 349 | * @param index The index into which to insert the value. |
| 350 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 351 | - (void)insertValue:(uint32_t)value atIndex:(NSUInteger)index; |
| 352 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 353 | /** |
| 354 | * Replaces the value at the given index with the given value. |
| 355 | * |
| 356 | * @param index The index for which to replace the value. |
| 357 | * @param value The value to replace with. |
| 358 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 359 | - (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint32_t)value; |
| 360 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 361 | /** |
| 362 | * Removes the value at the given index. |
| 363 | * |
| 364 | * @param index The index of the value to remove. |
| 365 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 366 | - (void)removeValueAtIndex:(NSUInteger)index; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 367 | |
| 368 | /** |
| 369 | * Removes all the values from this array. |
| 370 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 371 | - (void)removeAll; |
| 372 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 373 | /** |
| 374 | * Exchanges the values between the given indexes. |
| 375 | * |
| 376 | * @param idx1 The index of the first element to exchange. |
| 377 | * @param idx2 The index of the second element to exchange. |
| 378 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 379 | - (void)exchangeValueAtIndex:(NSUInteger)idx1 |
| 380 | withValueAtIndex:(NSUInteger)idx2; |
| 381 | |
| 382 | @end |
| 383 | |
| 384 | #pragma mark - Int64 |
| 385 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 386 | /** |
| 387 | * Class used for repeated fields of int64_t values. This performs better than |
| 388 | * boxing into NSNumbers in NSArrays. |
| 389 | * |
| 390 | * @note This class is not meant to be subclassed. |
| 391 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 392 | @interface GPBInt64Array : NSObject <NSCopying> |
| 393 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 394 | /** The number of elements contained in the array. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 395 | @property(nonatomic, readonly) NSUInteger count; |
| 396 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 397 | /** |
| 398 | * @return A newly instanced and empty GPBInt64Array. |
| 399 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 400 | + (instancetype)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 401 | |
| 402 | /** |
| 403 | * Creates and initializes a GPBInt64Array with the single element given. |
| 404 | * |
| 405 | * @param value The value to be placed in the array. |
| 406 | * |
| 407 | * @return A newly instanced GPBInt64Array with value in it. |
| 408 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 409 | + (instancetype)arrayWithValue:(int64_t)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 410 | |
| 411 | /** |
| 412 | * Creates and initializes a GPBInt64Array with the contents of the given |
| 413 | * array. |
| 414 | * |
| 415 | * @param array Array with the contents to be put into the new array. |
| 416 | * |
| 417 | * @return A newly instanced GPBInt64Array with the contents of array. |
| 418 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 419 | + (instancetype)arrayWithValueArray:(GPBInt64Array *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 420 | |
| 421 | /** |
| 422 | * Creates and initializes a GPBInt64Array with the given capacity. |
| 423 | * |
| 424 | * @param count The capacity needed for the array. |
| 425 | * |
| 426 | * @return A newly instanced GPBInt64Array with a capacity of count. |
| 427 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 428 | + (instancetype)arrayWithCapacity:(NSUInteger)count; |
| 429 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 430 | /** |
| 431 | * @return A newly initialized and empty GPBInt64Array. |
| 432 | **/ |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 433 | - (instancetype)init NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 434 | |
| 435 | /** |
| 436 | * Initializes the array, copying the given values. |
| 437 | * |
| 438 | * @param values An array with the values to put inside this array. |
| 439 | * @param count The number of elements to copy into the array. |
| 440 | * |
| 441 | * @return A newly initialized GPBInt64Array with a copy of the values. |
| 442 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 443 | - (instancetype)initWithValues:(const int64_t [__nullable])values |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 444 | count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 445 | |
| 446 | /** |
| 447 | * Initializes the array, copying the given values. |
| 448 | * |
| 449 | * @param array An array with the values to put inside this array. |
| 450 | * |
| 451 | * @return A newly initialized GPBInt64Array with a copy of the values. |
| 452 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 453 | - (instancetype)initWithValueArray:(GPBInt64Array *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 454 | |
| 455 | /** |
| 456 | * Initializes the array with the given capacity. |
| 457 | * |
| 458 | * @param count The capacity needed for the array. |
| 459 | * |
| 460 | * @return A newly initialized GPBInt64Array with a capacity of count. |
| 461 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 462 | - (instancetype)initWithCapacity:(NSUInteger)count; |
| 463 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 464 | /** |
| 465 | * Gets the value at the given index. |
| 466 | * |
| 467 | * @param index The index of the value to get. |
| 468 | * |
| 469 | * @return The value at the given index. |
| 470 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 471 | - (int64_t)valueAtIndex:(NSUInteger)index; |
| 472 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 473 | /** |
| 474 | * Enumerates the values on this array with the given block. |
| 475 | * |
| 476 | * @param block The block to enumerate with. |
| 477 | * **value**: The current value being enumerated. |
| 478 | * **idx**: The index of the current value. |
| 479 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 480 | **/ |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 481 | - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))block; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 482 | |
| 483 | /** |
| 484 | * Enumerates the values on this array with the given block. |
| 485 | * |
| 486 | * @param opts Options to control the enumeration. |
| 487 | * @param block The block to enumerate with. |
| 488 | * **value**: The current value being enumerated. |
| 489 | * **idx**: The index of the current value. |
| 490 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 491 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 492 | - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 493 | usingBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx, 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 a value to this array. |
| 497 | * |
| 498 | * @param value The value to add to this array. |
| 499 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 500 | - (void)addValue:(int64_t)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 501 | |
| 502 | /** |
| 503 | * Adds values to this array. |
| 504 | * |
| 505 | * @param values The values to add to this array. |
| 506 | * @param count The number of elements to add. |
| 507 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 508 | - (void)addValues:(const int64_t [__nullable])values count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 509 | |
| 510 | /** |
| 511 | * Adds the values from the given array to this array. |
| 512 | * |
| 513 | * @param array The array containing the elements to add to this array. |
| 514 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 515 | - (void)addValuesFromArray:(GPBInt64Array *)array; |
| 516 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 517 | /** |
| 518 | * Inserts a value into the given position. |
| 519 | * |
| 520 | * @param value The value to add to this array. |
| 521 | * @param index The index into which to insert the value. |
| 522 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 523 | - (void)insertValue:(int64_t)value atIndex:(NSUInteger)index; |
| 524 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 525 | /** |
| 526 | * Replaces the value at the given index with the given value. |
| 527 | * |
| 528 | * @param index The index for which to replace the value. |
| 529 | * @param value The value to replace with. |
| 530 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 531 | - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int64_t)value; |
| 532 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 533 | /** |
| 534 | * Removes the value at the given index. |
| 535 | * |
| 536 | * @param index The index of the value to remove. |
| 537 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 538 | - (void)removeValueAtIndex:(NSUInteger)index; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 539 | |
| 540 | /** |
| 541 | * Removes all the values from this array. |
| 542 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 543 | - (void)removeAll; |
| 544 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 545 | /** |
| 546 | * Exchanges the values between the given indexes. |
| 547 | * |
| 548 | * @param idx1 The index of the first element to exchange. |
| 549 | * @param idx2 The index of the second element to exchange. |
| 550 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 551 | - (void)exchangeValueAtIndex:(NSUInteger)idx1 |
| 552 | withValueAtIndex:(NSUInteger)idx2; |
| 553 | |
| 554 | @end |
| 555 | |
| 556 | #pragma mark - UInt64 |
| 557 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 558 | /** |
| 559 | * Class used for repeated fields of uint64_t values. This performs better than |
| 560 | * boxing into NSNumbers in NSArrays. |
| 561 | * |
| 562 | * @note This class is not meant to be subclassed. |
| 563 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 564 | @interface GPBUInt64Array : NSObject <NSCopying> |
| 565 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 566 | /** The number of elements contained in the array. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 567 | @property(nonatomic, readonly) NSUInteger count; |
| 568 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 569 | /** |
| 570 | * @return A newly instanced and empty GPBUInt64Array. |
| 571 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 572 | + (instancetype)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 573 | |
| 574 | /** |
| 575 | * Creates and initializes a GPBUInt64Array with the single element given. |
| 576 | * |
| 577 | * @param value The value to be placed in the array. |
| 578 | * |
| 579 | * @return A newly instanced GPBUInt64Array with value in it. |
| 580 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 581 | + (instancetype)arrayWithValue:(uint64_t)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 582 | |
| 583 | /** |
| 584 | * Creates and initializes a GPBUInt64Array with the contents of the given |
| 585 | * array. |
| 586 | * |
| 587 | * @param array Array with the contents to be put into the new array. |
| 588 | * |
| 589 | * @return A newly instanced GPBUInt64Array with the contents of array. |
| 590 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 591 | + (instancetype)arrayWithValueArray:(GPBUInt64Array *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 592 | |
| 593 | /** |
| 594 | * Creates and initializes a GPBUInt64Array with the given capacity. |
| 595 | * |
| 596 | * @param count The capacity needed for the array. |
| 597 | * |
| 598 | * @return A newly instanced GPBUInt64Array with a capacity of count. |
| 599 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 600 | + (instancetype)arrayWithCapacity:(NSUInteger)count; |
| 601 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 602 | /** |
| 603 | * @return A newly initialized and empty GPBUInt64Array. |
| 604 | **/ |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 605 | - (instancetype)init NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 606 | |
| 607 | /** |
| 608 | * Initializes the array, copying the given values. |
| 609 | * |
| 610 | * @param values An array with the values to put inside this array. |
| 611 | * @param count The number of elements to copy into the array. |
| 612 | * |
| 613 | * @return A newly initialized GPBUInt64Array with a copy of the values. |
| 614 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 615 | - (instancetype)initWithValues:(const uint64_t [__nullable])values |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 616 | count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 617 | |
| 618 | /** |
| 619 | * Initializes the array, copying the given values. |
| 620 | * |
| 621 | * @param array An array with the values to put inside this array. |
| 622 | * |
| 623 | * @return A newly initialized GPBUInt64Array with a copy of the values. |
| 624 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 625 | - (instancetype)initWithValueArray:(GPBUInt64Array *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 626 | |
| 627 | /** |
| 628 | * Initializes the array with the given capacity. |
| 629 | * |
| 630 | * @param count The capacity needed for the array. |
| 631 | * |
| 632 | * @return A newly initialized GPBUInt64Array with a capacity of count. |
| 633 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 634 | - (instancetype)initWithCapacity:(NSUInteger)count; |
| 635 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 636 | /** |
| 637 | * Gets the value at the given index. |
| 638 | * |
| 639 | * @param index The index of the value to get. |
| 640 | * |
| 641 | * @return The value at the given index. |
| 642 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 643 | - (uint64_t)valueAtIndex:(NSUInteger)index; |
| 644 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 645 | /** |
| 646 | * Enumerates the values on this array with the given block. |
| 647 | * |
| 648 | * @param block The block to enumerate with. |
| 649 | * **value**: The current value being enumerated. |
| 650 | * **idx**: The index of the current value. |
| 651 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 652 | **/ |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 653 | - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 654 | |
| 655 | /** |
| 656 | * Enumerates the values on this array with the given block. |
| 657 | * |
| 658 | * @param opts Options to control the enumeration. |
| 659 | * @param block The block to enumerate with. |
| 660 | * **value**: The current value being enumerated. |
| 661 | * **idx**: The index of the current value. |
| 662 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 663 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 664 | - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 665 | usingBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 666 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 667 | /** |
| 668 | * Adds a value to this array. |
| 669 | * |
| 670 | * @param value The value to add to this array. |
| 671 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 672 | - (void)addValue:(uint64_t)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 673 | |
| 674 | /** |
| 675 | * Adds values to this array. |
| 676 | * |
| 677 | * @param values The values to add to this array. |
| 678 | * @param count The number of elements to add. |
| 679 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 680 | - (void)addValues:(const uint64_t [__nullable])values count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 681 | |
| 682 | /** |
| 683 | * Adds the values from the given array to this array. |
| 684 | * |
| 685 | * @param array The array containing the elements to add to this array. |
| 686 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 687 | - (void)addValuesFromArray:(GPBUInt64Array *)array; |
| 688 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 689 | /** |
| 690 | * Inserts a value into the given position. |
| 691 | * |
| 692 | * @param value The value to add to this array. |
| 693 | * @param index The index into which to insert the value. |
| 694 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 695 | - (void)insertValue:(uint64_t)value atIndex:(NSUInteger)index; |
| 696 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 697 | /** |
| 698 | * Replaces the value at the given index with the given value. |
| 699 | * |
| 700 | * @param index The index for which to replace the value. |
| 701 | * @param value The value to replace with. |
| 702 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 703 | - (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint64_t)value; |
| 704 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 705 | /** |
| 706 | * Removes the value at the given index. |
| 707 | * |
| 708 | * @param index The index of the value to remove. |
| 709 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 710 | - (void)removeValueAtIndex:(NSUInteger)index; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 711 | |
| 712 | /** |
| 713 | * Removes all the values from this array. |
| 714 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 715 | - (void)removeAll; |
| 716 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 717 | /** |
| 718 | * Exchanges the values between the given indexes. |
| 719 | * |
| 720 | * @param idx1 The index of the first element to exchange. |
| 721 | * @param idx2 The index of the second element to exchange. |
| 722 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 723 | - (void)exchangeValueAtIndex:(NSUInteger)idx1 |
| 724 | withValueAtIndex:(NSUInteger)idx2; |
| 725 | |
| 726 | @end |
| 727 | |
| 728 | #pragma mark - Float |
| 729 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 730 | /** |
| 731 | * Class used for repeated fields of float values. This performs better than |
| 732 | * boxing into NSNumbers in NSArrays. |
| 733 | * |
| 734 | * @note This class is not meant to be subclassed. |
| 735 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 736 | @interface GPBFloatArray : NSObject <NSCopying> |
| 737 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 738 | /** The number of elements contained in the array. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 739 | @property(nonatomic, readonly) NSUInteger count; |
| 740 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 741 | /** |
| 742 | * @return A newly instanced and empty GPBFloatArray. |
| 743 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 744 | + (instancetype)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 745 | |
| 746 | /** |
| 747 | * Creates and initializes a GPBFloatArray with the single element given. |
| 748 | * |
| 749 | * @param value The value to be placed in the array. |
| 750 | * |
| 751 | * @return A newly instanced GPBFloatArray with value in it. |
| 752 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 753 | + (instancetype)arrayWithValue:(float)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 754 | |
| 755 | /** |
| 756 | * Creates and initializes a GPBFloatArray with the contents of the given |
| 757 | * array. |
| 758 | * |
| 759 | * @param array Array with the contents to be put into the new array. |
| 760 | * |
| 761 | * @return A newly instanced GPBFloatArray with the contents of array. |
| 762 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 763 | + (instancetype)arrayWithValueArray:(GPBFloatArray *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 764 | |
| 765 | /** |
| 766 | * Creates and initializes a GPBFloatArray with the given capacity. |
| 767 | * |
| 768 | * @param count The capacity needed for the array. |
| 769 | * |
| 770 | * @return A newly instanced GPBFloatArray with a capacity of count. |
| 771 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 772 | + (instancetype)arrayWithCapacity:(NSUInteger)count; |
| 773 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 774 | /** |
| 775 | * @return A newly initialized and empty GPBFloatArray. |
| 776 | **/ |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 777 | - (instancetype)init NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 778 | |
| 779 | /** |
| 780 | * Initializes the array, copying the given values. |
| 781 | * |
| 782 | * @param values An array with the values to put inside this array. |
| 783 | * @param count The number of elements to copy into the array. |
| 784 | * |
| 785 | * @return A newly initialized GPBFloatArray with a copy of the values. |
| 786 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 787 | - (instancetype)initWithValues:(const float [__nullable])values |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 788 | count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 789 | |
| 790 | /** |
| 791 | * Initializes the array, copying the given values. |
| 792 | * |
| 793 | * @param array An array with the values to put inside this array. |
| 794 | * |
| 795 | * @return A newly initialized GPBFloatArray with a copy of the values. |
| 796 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 797 | - (instancetype)initWithValueArray:(GPBFloatArray *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 798 | |
| 799 | /** |
| 800 | * Initializes the array with the given capacity. |
| 801 | * |
| 802 | * @param count The capacity needed for the array. |
| 803 | * |
| 804 | * @return A newly initialized GPBFloatArray with a capacity of count. |
| 805 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 806 | - (instancetype)initWithCapacity:(NSUInteger)count; |
| 807 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 808 | /** |
| 809 | * Gets the value at the given index. |
| 810 | * |
| 811 | * @param index The index of the value to get. |
| 812 | * |
| 813 | * @return The value at the given index. |
| 814 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 815 | - (float)valueAtIndex:(NSUInteger)index; |
| 816 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 817 | /** |
| 818 | * Enumerates the values on this array with the given block. |
| 819 | * |
| 820 | * @param block The block to enumerate with. |
| 821 | * **value**: The current value being enumerated. |
| 822 | * **idx**: The index of the current value. |
| 823 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 824 | **/ |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 825 | - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 826 | |
| 827 | /** |
| 828 | * Enumerates the values on this array with the given block. |
| 829 | * |
| 830 | * @param opts Options to control the enumeration. |
| 831 | * @param block The block to enumerate with. |
| 832 | * **value**: The current value being enumerated. |
| 833 | * **idx**: The index of the current value. |
| 834 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 835 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 836 | - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 837 | usingBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 838 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 839 | /** |
| 840 | * Adds a value to this array. |
| 841 | * |
| 842 | * @param value The value to add to this array. |
| 843 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 844 | - (void)addValue:(float)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 845 | |
| 846 | /** |
| 847 | * Adds values to this array. |
| 848 | * |
| 849 | * @param values The values to add to this array. |
| 850 | * @param count The number of elements to add. |
| 851 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 852 | - (void)addValues:(const float [__nullable])values count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 853 | |
| 854 | /** |
| 855 | * Adds the values from the given array to this array. |
| 856 | * |
| 857 | * @param array The array containing the elements to add to this array. |
| 858 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 859 | - (void)addValuesFromArray:(GPBFloatArray *)array; |
| 860 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 861 | /** |
| 862 | * Inserts a value into the given position. |
| 863 | * |
| 864 | * @param value The value to add to this array. |
| 865 | * @param index The index into which to insert the value. |
| 866 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 867 | - (void)insertValue:(float)value atIndex:(NSUInteger)index; |
| 868 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 869 | /** |
| 870 | * Replaces the value at the given index with the given value. |
| 871 | * |
| 872 | * @param index The index for which to replace the value. |
| 873 | * @param value The value to replace with. |
| 874 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 875 | - (void)replaceValueAtIndex:(NSUInteger)index withValue:(float)value; |
| 876 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 877 | /** |
| 878 | * Removes the value at the given index. |
| 879 | * |
| 880 | * @param index The index of the value to remove. |
| 881 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 882 | - (void)removeValueAtIndex:(NSUInteger)index; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 883 | |
| 884 | /** |
| 885 | * Removes all the values from this array. |
| 886 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 887 | - (void)removeAll; |
| 888 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 889 | /** |
| 890 | * Exchanges the values between the given indexes. |
| 891 | * |
| 892 | * @param idx1 The index of the first element to exchange. |
| 893 | * @param idx2 The index of the second element to exchange. |
| 894 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 895 | - (void)exchangeValueAtIndex:(NSUInteger)idx1 |
| 896 | withValueAtIndex:(NSUInteger)idx2; |
| 897 | |
| 898 | @end |
| 899 | |
| 900 | #pragma mark - Double |
| 901 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 902 | /** |
| 903 | * Class used for repeated fields of double values. This performs better than |
| 904 | * boxing into NSNumbers in NSArrays. |
| 905 | * |
| 906 | * @note This class is not meant to be subclassed. |
| 907 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 908 | @interface GPBDoubleArray : NSObject <NSCopying> |
| 909 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 910 | /** The number of elements contained in the array. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 911 | @property(nonatomic, readonly) NSUInteger count; |
| 912 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 913 | /** |
| 914 | * @return A newly instanced and empty GPBDoubleArray. |
| 915 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 916 | + (instancetype)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 917 | |
| 918 | /** |
| 919 | * Creates and initializes a GPBDoubleArray with the single element given. |
| 920 | * |
| 921 | * @param value The value to be placed in the array. |
| 922 | * |
| 923 | * @return A newly instanced GPBDoubleArray with value in it. |
| 924 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 925 | + (instancetype)arrayWithValue:(double)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 926 | |
| 927 | /** |
| 928 | * Creates and initializes a GPBDoubleArray with the contents of the given |
| 929 | * array. |
| 930 | * |
| 931 | * @param array Array with the contents to be put into the new array. |
| 932 | * |
| 933 | * @return A newly instanced GPBDoubleArray with the contents of array. |
| 934 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 935 | + (instancetype)arrayWithValueArray:(GPBDoubleArray *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 936 | |
| 937 | /** |
| 938 | * Creates and initializes a GPBDoubleArray with the given capacity. |
| 939 | * |
| 940 | * @param count The capacity needed for the array. |
| 941 | * |
| 942 | * @return A newly instanced GPBDoubleArray with a capacity of count. |
| 943 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 944 | + (instancetype)arrayWithCapacity:(NSUInteger)count; |
| 945 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 946 | /** |
| 947 | * @return A newly initialized and empty GPBDoubleArray. |
| 948 | **/ |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 949 | - (instancetype)init NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 950 | |
| 951 | /** |
| 952 | * Initializes the array, copying the given values. |
| 953 | * |
| 954 | * @param values An array with the values to put inside this array. |
| 955 | * @param count The number of elements to copy into the array. |
| 956 | * |
| 957 | * @return A newly initialized GPBDoubleArray with a copy of the values. |
| 958 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 959 | - (instancetype)initWithValues:(const double [__nullable])values |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 960 | count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 961 | |
| 962 | /** |
| 963 | * Initializes the array, copying the given values. |
| 964 | * |
| 965 | * @param array An array with the values to put inside this array. |
| 966 | * |
| 967 | * @return A newly initialized GPBDoubleArray with a copy of the values. |
| 968 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 969 | - (instancetype)initWithValueArray:(GPBDoubleArray *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 970 | |
| 971 | /** |
| 972 | * Initializes the array with the given capacity. |
| 973 | * |
| 974 | * @param count The capacity needed for the array. |
| 975 | * |
| 976 | * @return A newly initialized GPBDoubleArray with a capacity of count. |
| 977 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 978 | - (instancetype)initWithCapacity:(NSUInteger)count; |
| 979 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 980 | /** |
| 981 | * Gets the value at the given index. |
| 982 | * |
| 983 | * @param index The index of the value to get. |
| 984 | * |
| 985 | * @return The value at the given index. |
| 986 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 987 | - (double)valueAtIndex:(NSUInteger)index; |
| 988 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 989 | /** |
| 990 | * Enumerates the values on this array with the given block. |
| 991 | * |
| 992 | * @param block The block to enumerate with. |
| 993 | * **value**: The current value being enumerated. |
| 994 | * **idx**: The index of the current value. |
| 995 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 996 | **/ |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 997 | - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 998 | |
| 999 | /** |
| 1000 | * Enumerates the values on this array with the given block. |
| 1001 | * |
| 1002 | * @param opts Options to control the enumeration. |
| 1003 | * @param block The block to enumerate with. |
| 1004 | * **value**: The current value being enumerated. |
| 1005 | * **idx**: The index of the current value. |
| 1006 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1007 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1008 | - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 1009 | usingBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1010 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1011 | /** |
| 1012 | * Adds a value to this array. |
| 1013 | * |
| 1014 | * @param value The value to add to this array. |
| 1015 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1016 | - (void)addValue:(double)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1017 | |
| 1018 | /** |
| 1019 | * Adds values to this array. |
| 1020 | * |
| 1021 | * @param values The values to add to this array. |
| 1022 | * @param count The number of elements to add. |
| 1023 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1024 | - (void)addValues:(const double [__nullable])values count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1025 | |
| 1026 | /** |
| 1027 | * Adds the values from the given array to this array. |
| 1028 | * |
| 1029 | * @param array The array containing the elements to add to this array. |
| 1030 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1031 | - (void)addValuesFromArray:(GPBDoubleArray *)array; |
| 1032 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1033 | /** |
| 1034 | * Inserts a value into the given position. |
| 1035 | * |
| 1036 | * @param value The value to add to this array. |
| 1037 | * @param index The index into which to insert the value. |
| 1038 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1039 | - (void)insertValue:(double)value atIndex:(NSUInteger)index; |
| 1040 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1041 | /** |
| 1042 | * Replaces the value at the given index with the given value. |
| 1043 | * |
| 1044 | * @param index The index for which to replace the value. |
| 1045 | * @param value The value to replace with. |
| 1046 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1047 | - (void)replaceValueAtIndex:(NSUInteger)index withValue:(double)value; |
| 1048 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1049 | /** |
| 1050 | * Removes the value at the given index. |
| 1051 | * |
| 1052 | * @param index The index of the value to remove. |
| 1053 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1054 | - (void)removeValueAtIndex:(NSUInteger)index; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1055 | |
| 1056 | /** |
| 1057 | * Removes all the values from this array. |
| 1058 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1059 | - (void)removeAll; |
| 1060 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1061 | /** |
| 1062 | * Exchanges the values between the given indexes. |
| 1063 | * |
| 1064 | * @param idx1 The index of the first element to exchange. |
| 1065 | * @param idx2 The index of the second element to exchange. |
| 1066 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1067 | - (void)exchangeValueAtIndex:(NSUInteger)idx1 |
| 1068 | withValueAtIndex:(NSUInteger)idx2; |
| 1069 | |
| 1070 | @end |
| 1071 | |
| 1072 | #pragma mark - Bool |
| 1073 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1074 | /** |
| 1075 | * Class used for repeated fields of BOOL values. This performs better than |
| 1076 | * boxing into NSNumbers in NSArrays. |
| 1077 | * |
| 1078 | * @note This class is not meant to be subclassed. |
| 1079 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1080 | @interface GPBBoolArray : NSObject <NSCopying> |
| 1081 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1082 | /** The number of elements contained in the array. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1083 | @property(nonatomic, readonly) NSUInteger count; |
| 1084 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1085 | /** |
| 1086 | * @return A newly instanced and empty GPBBoolArray. |
| 1087 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1088 | + (instancetype)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1089 | |
| 1090 | /** |
| 1091 | * Creates and initializes a GPBBoolArray with the single element given. |
| 1092 | * |
| 1093 | * @param value The value to be placed in the array. |
| 1094 | * |
| 1095 | * @return A newly instanced GPBBoolArray with value in it. |
| 1096 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1097 | + (instancetype)arrayWithValue:(BOOL)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1098 | |
| 1099 | /** |
| 1100 | * Creates and initializes a GPBBoolArray with the contents of the given |
| 1101 | * array. |
| 1102 | * |
| 1103 | * @param array Array with the contents to be put into the new array. |
| 1104 | * |
| 1105 | * @return A newly instanced GPBBoolArray with the contents of array. |
| 1106 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1107 | + (instancetype)arrayWithValueArray:(GPBBoolArray *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1108 | |
| 1109 | /** |
| 1110 | * Creates and initializes a GPBBoolArray with the given capacity. |
| 1111 | * |
| 1112 | * @param count The capacity needed for the array. |
| 1113 | * |
| 1114 | * @return A newly instanced GPBBoolArray with a capacity of count. |
| 1115 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1116 | + (instancetype)arrayWithCapacity:(NSUInteger)count; |
| 1117 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1118 | /** |
| 1119 | * @return A newly initialized and empty GPBBoolArray. |
| 1120 | **/ |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 1121 | - (instancetype)init NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1122 | |
| 1123 | /** |
| 1124 | * Initializes the array, copying the given values. |
| 1125 | * |
| 1126 | * @param values An array with the values to put inside this array. |
| 1127 | * @param count The number of elements to copy into the array. |
| 1128 | * |
| 1129 | * @return A newly initialized GPBBoolArray with a copy of the values. |
| 1130 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1131 | - (instancetype)initWithValues:(const BOOL [__nullable])values |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 1132 | count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1133 | |
| 1134 | /** |
| 1135 | * Initializes the array, copying the given values. |
| 1136 | * |
| 1137 | * @param array An array with the values to put inside this array. |
| 1138 | * |
| 1139 | * @return A newly initialized GPBBoolArray with a copy of the values. |
| 1140 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1141 | - (instancetype)initWithValueArray:(GPBBoolArray *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1142 | |
| 1143 | /** |
| 1144 | * Initializes the array with the given capacity. |
| 1145 | * |
| 1146 | * @param count The capacity needed for the array. |
| 1147 | * |
| 1148 | * @return A newly initialized GPBBoolArray with a capacity of count. |
| 1149 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1150 | - (instancetype)initWithCapacity:(NSUInteger)count; |
| 1151 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1152 | /** |
| 1153 | * Gets the value at the given index. |
| 1154 | * |
| 1155 | * @param index The index of the value to get. |
| 1156 | * |
| 1157 | * @return The value at the given index. |
| 1158 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1159 | - (BOOL)valueAtIndex:(NSUInteger)index; |
| 1160 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1161 | /** |
| 1162 | * Enumerates the values on this array with the given block. |
| 1163 | * |
| 1164 | * @param block The block to enumerate with. |
| 1165 | * **value**: The current value being enumerated. |
| 1166 | * **idx**: The index of the current value. |
| 1167 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1168 | **/ |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 1169 | - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1170 | |
| 1171 | /** |
| 1172 | * Enumerates the values on this array with the given block. |
| 1173 | * |
| 1174 | * @param opts Options to control the enumeration. |
| 1175 | * @param block The block to enumerate with. |
| 1176 | * **value**: The current value being enumerated. |
| 1177 | * **idx**: The index of the current value. |
| 1178 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1179 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1180 | - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 1181 | usingBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1182 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1183 | /** |
| 1184 | * Adds a value to this array. |
| 1185 | * |
| 1186 | * @param value The value to add to this array. |
| 1187 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1188 | - (void)addValue:(BOOL)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1189 | |
| 1190 | /** |
| 1191 | * Adds values to this array. |
| 1192 | * |
| 1193 | * @param values The values to add to this array. |
| 1194 | * @param count The number of elements to add. |
| 1195 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1196 | - (void)addValues:(const BOOL [__nullable])values count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1197 | |
| 1198 | /** |
| 1199 | * Adds the values from the given array to this array. |
| 1200 | * |
| 1201 | * @param array The array containing the elements to add to this array. |
| 1202 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1203 | - (void)addValuesFromArray:(GPBBoolArray *)array; |
| 1204 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1205 | /** |
| 1206 | * Inserts a value into the given position. |
| 1207 | * |
| 1208 | * @param value The value to add to this array. |
| 1209 | * @param index The index into which to insert the value. |
| 1210 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1211 | - (void)insertValue:(BOOL)value atIndex:(NSUInteger)index; |
| 1212 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1213 | /** |
| 1214 | * Replaces the value at the given index with the given value. |
| 1215 | * |
| 1216 | * @param index The index for which to replace the value. |
| 1217 | * @param value The value to replace with. |
| 1218 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1219 | - (void)replaceValueAtIndex:(NSUInteger)index withValue:(BOOL)value; |
| 1220 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1221 | /** |
| 1222 | * Removes the value at the given index. |
| 1223 | * |
| 1224 | * @param index The index of the value to remove. |
| 1225 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1226 | - (void)removeValueAtIndex:(NSUInteger)index; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1227 | |
| 1228 | /** |
| 1229 | * Removes all the values from this array. |
| 1230 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1231 | - (void)removeAll; |
| 1232 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1233 | /** |
| 1234 | * Exchanges the values between the given indexes. |
| 1235 | * |
| 1236 | * @param idx1 The index of the first element to exchange. |
| 1237 | * @param idx2 The index of the second element to exchange. |
| 1238 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1239 | - (void)exchangeValueAtIndex:(NSUInteger)idx1 |
| 1240 | withValueAtIndex:(NSUInteger)idx2; |
| 1241 | |
| 1242 | @end |
| 1243 | |
| 1244 | #pragma mark - Enum |
| 1245 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1246 | /** |
| 1247 | * This class is used for repeated fields of int32_t values. This performs |
| 1248 | * better than boxing into NSNumbers in NSArrays. |
| 1249 | * |
| 1250 | * @note This class is not meant to be subclassed. |
| 1251 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1252 | @interface GPBEnumArray : NSObject <NSCopying> |
| 1253 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1254 | /** The number of elements contained in the array. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1255 | @property(nonatomic, readonly) NSUInteger count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1256 | /** The validation function to check if the enums are valid. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1257 | @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; |
| 1258 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1259 | /** |
| 1260 | * @return A newly instanced and empty GPBEnumArray. |
| 1261 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1262 | + (instancetype)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1263 | |
| 1264 | /** |
| 1265 | * Creates and initializes a GPBEnumArray with the enum validation function |
| 1266 | * given. |
| 1267 | * |
| 1268 | * @param func The enum validation function for the array. |
| 1269 | * |
| 1270 | * @return A newly instanced GPBEnumArray. |
| 1271 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1272 | + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1273 | |
| 1274 | /** |
| 1275 | * Creates and initializes a GPBEnumArray with the enum validation function |
| 1276 | * given and the single raw value given. |
| 1277 | * |
| 1278 | * @param func The enum validation function for the array. |
| 1279 | * @param value The raw value to add to this array. |
| 1280 | * |
| 1281 | * @return A newly instanced GPBEnumArray. |
| 1282 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1283 | + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1284 | rawValue:(int32_t)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1285 | |
| 1286 | /** |
| 1287 | * Creates and initializes a GPBEnumArray that adds the elements from the |
| 1288 | * given array. |
| 1289 | * |
| 1290 | * @param array Array containing the values to add to the new array. |
| 1291 | * |
| 1292 | * @return A newly instanced GPBEnumArray. |
| 1293 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1294 | + (instancetype)arrayWithValueArray:(GPBEnumArray *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1295 | |
| 1296 | /** |
| 1297 | * Creates and initializes a GPBEnumArray with the given enum validation |
| 1298 | * function and with the givencapacity. |
| 1299 | * |
| 1300 | * @param func The enum validation function for the array. |
| 1301 | * @param count The capacity needed for the array. |
| 1302 | * |
| 1303 | * @return A newly instanced GPBEnumArray with a capacity of count. |
| 1304 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1305 | + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1306 | capacity:(NSUInteger)count; |
| 1307 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1308 | /** |
| 1309 | * Initializes the array with the given enum validation function. |
| 1310 | * |
| 1311 | * @param func The enum validation function for the array. |
| 1312 | * |
| 1313 | * @return A newly initialized GPBEnumArray with a copy of the values. |
| 1314 | **/ |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 1315 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
| 1316 | NS_DESIGNATED_INITIALIZER; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1317 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1318 | /** |
| 1319 | * Initializes the array, copying the given values. |
| 1320 | * |
| 1321 | * @param func The enum validation function for the array. |
| 1322 | * @param values An array with the values to put inside this array. |
| 1323 | * @param count The number of elements to copy into the array. |
| 1324 | * |
| 1325 | * @return A newly initialized GPBEnumArray with a copy of the values. |
| 1326 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1327 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1328 | rawValues:(const int32_t [__nullable])values |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 1329 | count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1330 | |
| 1331 | /** |
| 1332 | * Initializes the array, copying the given values. |
| 1333 | * |
| 1334 | * @param array An array with the values to put inside this array. |
| 1335 | * |
| 1336 | * @return A newly initialized GPBEnumArray with a copy of the values. |
| 1337 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1338 | - (instancetype)initWithValueArray:(GPBEnumArray *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1339 | |
| 1340 | /** |
| 1341 | * Initializes the array with the given capacity. |
| 1342 | * |
| 1343 | * @param func The enum validation function for the array. |
| 1344 | * @param count The capacity needed for the array. |
| 1345 | * |
| 1346 | * @return A newly initialized GPBEnumArray with a capacity of count. |
| 1347 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1348 | - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1349 | capacity:(NSUInteger)count; |
| 1350 | |
| 1351 | // These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a |
| 1352 | // valid enumerator as defined by validationFunc. If the actual value is |
| 1353 | // desired, use "raw" version of the method. |
| 1354 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1355 | /** |
| 1356 | * Gets the value at the given index. |
| 1357 | * |
| 1358 | * @param index The index of the value to get. |
| 1359 | * |
| 1360 | * @return The value at the given index. |
| 1361 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1362 | - (int32_t)valueAtIndex:(NSUInteger)index; |
| 1363 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1364 | /** |
| 1365 | * Enumerates the values on this array with the given block. |
| 1366 | * |
| 1367 | * @param block The block to enumerate with. |
| 1368 | * **value**: The current value being enumerated. |
| 1369 | * **idx**: The index of the current value. |
| 1370 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1371 | **/ |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 1372 | - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1373 | |
| 1374 | /** |
| 1375 | * Enumerates the values on this array with the given block. |
| 1376 | * |
| 1377 | * @param opts Options to control the enumeration. |
| 1378 | * @param block The block to enumerate with. |
| 1379 | * **value**: The current value being enumerated. |
| 1380 | * **idx**: The index of the current value. |
| 1381 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1382 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1383 | - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 1384 | usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1385 | |
| 1386 | // These methods bypass the validationFunc to provide access to values that were not |
| 1387 | // known at the time the binary was compiled. |
| 1388 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1389 | /** |
| 1390 | * Gets the raw enum value at the given index. |
| 1391 | * |
| 1392 | * @param index The index of the raw enum value to get. |
| 1393 | * |
| 1394 | * @return The raw enum value at the given index. |
| 1395 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1396 | - (int32_t)rawValueAtIndex:(NSUInteger)index; |
| 1397 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1398 | /** |
| 1399 | * Enumerates the values on this array with the given block. |
| 1400 | * |
| 1401 | * @param block The block to enumerate with. |
| 1402 | * **value**: The current value being enumerated. |
| 1403 | * **idx**: The index of the current value. |
| 1404 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1405 | **/ |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 1406 | - (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1407 | |
| 1408 | /** |
| 1409 | * Enumerates the values on this array with the given block. |
| 1410 | * |
| 1411 | * @param opts Options to control the enumeration. |
| 1412 | * @param block The block to enumerate with. |
| 1413 | * **value**: The current value being enumerated. |
| 1414 | * **idx**: The index of the current value. |
| 1415 | * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1416 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1417 | - (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 1418 | usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1419 | |
| 1420 | // If value is not a valid enumerator as defined by validationFunc, these |
| 1421 | // methods will assert in debug, and will log in release and assign the value |
| 1422 | // to the default value. Use the rawValue methods below to assign non enumerator |
| 1423 | // values. |
| 1424 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1425 | /** |
| 1426 | * Adds a value to this array. |
| 1427 | * |
| 1428 | * @param value The value to add to this array. |
| 1429 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1430 | - (void)addValue:(int32_t)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1431 | |
| 1432 | /** |
| 1433 | * Adds values to this array. |
| 1434 | * |
| 1435 | * @param values The values to add to this array. |
| 1436 | * @param count The number of elements to add. |
| 1437 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1438 | - (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1439 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1440 | |
| 1441 | /** |
| 1442 | * Inserts a value into the given position. |
| 1443 | * |
| 1444 | * @param value The value to add to this array. |
| 1445 | * @param index The index into which to insert the value. |
| 1446 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1447 | - (void)insertValue:(int32_t)value atIndex:(NSUInteger)index; |
| 1448 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1449 | /** |
| 1450 | * Replaces the value at the given index with the given value. |
| 1451 | * |
| 1452 | * @param index The index for which to replace the value. |
| 1453 | * @param value The value to replace with. |
| 1454 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1455 | - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value; |
| 1456 | |
| 1457 | // These methods bypass the validationFunc to provide setting of values that were not |
| 1458 | // known at the time the binary was compiled. |
| 1459 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1460 | /** |
| 1461 | * Adds a raw enum value to this array. |
| 1462 | * |
| 1463 | * @note This method bypass the validationFunc to enable the setting of values that |
| 1464 | * were not known at the time the binary was compiled. |
| 1465 | * |
| 1466 | * @param value The raw enum value to add to the array. |
| 1467 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1468 | - (void)addRawValue:(int32_t)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1469 | |
| 1470 | /** |
| 1471 | * Adds raw enum values to this array. |
| 1472 | * |
| 1473 | * @note This method bypass the validationFunc to enable the setting of values that |
| 1474 | * were not known at the time the binary was compiled. |
| 1475 | * |
| 1476 | * @param array Array containing the raw enum values to add to this array. |
| 1477 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1478 | - (void)addRawValuesFromArray:(GPBEnumArray *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1479 | |
| 1480 | /** |
| 1481 | * Adds raw enum values to this array. |
| 1482 | * |
| 1483 | * @note This method bypass the validationFunc to enable the setting of values that |
| 1484 | * were not known at the time the binary was compiled. |
| 1485 | * |
| 1486 | * @param values Array containing the raw enum values to add to this array. |
| 1487 | * @param count The number of raw values to add. |
| 1488 | **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1489 | - (void)addRawValues:(const int32_t [__nullable])values count:(NSUInteger)count; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1490 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1491 | /** |
| 1492 | * Inserts a raw enum value at the given index. |
| 1493 | * |
| 1494 | * @note This method bypass the validationFunc to enable the setting of values that |
| 1495 | * were not known at the time the binary was compiled. |
| 1496 | * |
| 1497 | * @param value Raw enum value to add. |
| 1498 | * @param index The index into which to insert the value. |
| 1499 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1500 | - (void)insertRawValue:(int32_t)value atIndex:(NSUInteger)index; |
| 1501 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1502 | /** |
| 1503 | * Replaces the raw enum value at the given index with the given value. |
| 1504 | * |
| 1505 | * @note This method bypass the validationFunc to enable the setting of values that |
| 1506 | * were not known at the time the binary was compiled. |
| 1507 | * |
| 1508 | * @param index The index for which to replace the value. |
| 1509 | * @param value The raw enum value to replace with. |
| 1510 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1511 | - (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(int32_t)value; |
| 1512 | |
| 1513 | // No validation applies to these methods. |
| 1514 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1515 | /** |
| 1516 | * Removes the value at the given index. |
| 1517 | * |
| 1518 | * @param index The index of the value to remove. |
| 1519 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1520 | - (void)removeValueAtIndex:(NSUInteger)index; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1521 | |
| 1522 | /** |
| 1523 | * Removes all the values from this array. |
| 1524 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1525 | - (void)removeAll; |
| 1526 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1527 | /** |
| 1528 | * Exchanges the values between the given indexes. |
| 1529 | * |
| 1530 | * @param idx1 The index of the first element to exchange. |
| 1531 | * @param idx2 The index of the second element to exchange. |
| 1532 | **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1533 | - (void)exchangeValueAtIndex:(NSUInteger)idx1 |
| 1534 | withValueAtIndex:(NSUInteger)idx2; |
| 1535 | |
| 1536 | @end |
| 1537 | |
| 1538 | //%PDDM-EXPAND-END DECLARE_ARRAYS() |
| 1539 | |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1540 | NS_ASSUME_NONNULL_END |
| 1541 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1542 | //%PDDM-DEFINE DECLARE_ARRAYS() |
| 1543 | //%ARRAY_INTERFACE_SIMPLE(Int32, int32_t) |
| 1544 | //%ARRAY_INTERFACE_SIMPLE(UInt32, uint32_t) |
| 1545 | //%ARRAY_INTERFACE_SIMPLE(Int64, int64_t) |
| 1546 | //%ARRAY_INTERFACE_SIMPLE(UInt64, uint64_t) |
| 1547 | //%ARRAY_INTERFACE_SIMPLE(Float, float) |
| 1548 | //%ARRAY_INTERFACE_SIMPLE(Double, double) |
| 1549 | //%ARRAY_INTERFACE_SIMPLE(Bool, BOOL) |
| 1550 | //%ARRAY_INTERFACE_ENUM(Enum, int32_t) |
| 1551 | |
| 1552 | // |
| 1553 | // The common case (everything but Enum) |
| 1554 | // |
| 1555 | |
| 1556 | //%PDDM-DEFINE ARRAY_INTERFACE_SIMPLE(NAME, TYPE) |
| 1557 | //%#pragma mark - NAME |
| 1558 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1559 | //%/** |
| 1560 | //% * Class used for repeated fields of ##TYPE## values. This performs better than |
| 1561 | //% * boxing into NSNumbers in NSArrays. |
| 1562 | //% * |
| 1563 | //% * @note This class is not meant to be subclassed. |
| 1564 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1565 | //%@interface GPB##NAME##Array : NSObject <NSCopying> |
| 1566 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1567 | //%/** The number of elements contained in the array. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1568 | //%@property(nonatomic, readonly) NSUInteger count; |
| 1569 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1570 | //%/** |
| 1571 | //% * @return A newly instanced and empty GPB##NAME##Array. |
| 1572 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1573 | //%+ (instancetype)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1574 | //% |
| 1575 | //%/** |
| 1576 | //% * Creates and initializes a GPB##NAME##Array with the single element given. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 1577 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1578 | //% * @param value The value to be placed in the array. |
| 1579 | //% * |
| 1580 | //% * @return A newly instanced GPB##NAME##Array with value in it. |
| 1581 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1582 | //%+ (instancetype)arrayWithValue:(TYPE)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1583 | //% |
| 1584 | //%/** |
| 1585 | //% * Creates and initializes a GPB##NAME##Array with the contents of the given |
| 1586 | //% * array. |
| 1587 | //% * |
| 1588 | //% * @param array Array with the contents to be put into the new array. |
| 1589 | //% * |
| 1590 | //% * @return A newly instanced GPB##NAME##Array with the contents of array. |
| 1591 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1592 | //%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1593 | //% |
| 1594 | //%/** |
| 1595 | //% * Creates and initializes a GPB##NAME##Array with the given capacity. |
| 1596 | //% * |
| 1597 | //% * @param count The capacity needed for the array. |
| 1598 | //% * |
| 1599 | //% * @return A newly instanced GPB##NAME##Array with a capacity of count. |
| 1600 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1601 | //%+ (instancetype)arrayWithCapacity:(NSUInteger)count; |
| 1602 | //% |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 1603 | //%/** |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1604 | //% * @return A newly initialized and empty GPB##NAME##Array. |
| 1605 | //% **/ |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 1606 | //%- (instancetype)init NS_DESIGNATED_INITIALIZER; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1607 | //% |
| 1608 | //%/** |
| 1609 | //% * Initializes the array, copying the given values. |
| 1610 | //% * |
| 1611 | //% * @param values An array with the values to put inside this array. |
| 1612 | //% * @param count The number of elements to copy into the array. |
| 1613 | //% * |
| 1614 | //% * @return A newly initialized GPB##NAME##Array with a copy of the values. |
| 1615 | //% **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1616 | //%- (instancetype)initWithValues:(const TYPE [__nullable])values |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 1617 | //% count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1618 | //% |
| 1619 | //%/** |
| 1620 | //% * Initializes the array, copying the given values. |
| 1621 | //% * |
| 1622 | //% * @param array An array with the values to put inside this array. |
| 1623 | //% * |
| 1624 | //% * @return A newly initialized GPB##NAME##Array with a copy of the values. |
| 1625 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1626 | //%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1627 | //% |
| 1628 | //%/** |
| 1629 | //% * Initializes the array with the given capacity. |
| 1630 | //% * |
| 1631 | //% * @param count The capacity needed for the array. |
| 1632 | //% * |
| 1633 | //% * @return A newly initialized GPB##NAME##Array with a capacity of count. |
| 1634 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1635 | //%- (instancetype)initWithCapacity:(NSUInteger)count; |
| 1636 | //% |
| 1637 | //%ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, Basic) |
| 1638 | //% |
| 1639 | //%ARRAY_MUTABLE_INTERFACE(NAME, TYPE, Basic) |
| 1640 | //% |
| 1641 | //%@end |
| 1642 | //% |
| 1643 | |
| 1644 | // |
| 1645 | // Macros specific to Enums (to tweak their interface). |
| 1646 | // |
| 1647 | |
| 1648 | //%PDDM-DEFINE ARRAY_INTERFACE_ENUM(NAME, TYPE) |
| 1649 | //%#pragma mark - NAME |
| 1650 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1651 | //%/** |
| 1652 | //% * This class is used for repeated fields of ##TYPE## values. This performs |
| 1653 | //% * better than boxing into NSNumbers in NSArrays. |
| 1654 | //% * |
| 1655 | //% * @note This class is not meant to be subclassed. |
| 1656 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1657 | //%@interface GPB##NAME##Array : NSObject <NSCopying> |
| 1658 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1659 | //%/** The number of elements contained in the array. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1660 | //%@property(nonatomic, readonly) NSUInteger count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1661 | //%/** The validation function to check if the enums are valid. */ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1662 | //%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; |
| 1663 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1664 | //%/** |
| 1665 | //% * @return A newly instanced and empty GPB##NAME##Array. |
| 1666 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1667 | //%+ (instancetype)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1668 | //% |
| 1669 | //%/** |
| 1670 | //% * Creates and initializes a GPB##NAME##Array with the enum validation function |
| 1671 | //% * given. |
| 1672 | //% * |
| 1673 | //% * @param func The enum validation function for the array. |
| 1674 | //% * |
| 1675 | //% * @return A newly instanced GPB##NAME##Array. |
| 1676 | //% **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1677 | //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1678 | //% |
| 1679 | //%/** |
| 1680 | //% * Creates and initializes a GPB##NAME##Array with the enum validation function |
| 1681 | //% * given and the single raw value given. |
| 1682 | //% * |
| 1683 | //% * @param func The enum validation function for the array. |
| 1684 | //% * @param value The raw value to add to this array. |
| 1685 | //% * |
| 1686 | //% * @return A newly instanced GPB##NAME##Array. |
| 1687 | //% **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1688 | //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1689 | //% rawValue:(TYPE)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1690 | //% |
| 1691 | //%/** |
| 1692 | //% * Creates and initializes a GPB##NAME##Array that adds the elements from the |
| 1693 | //% * given array. |
| 1694 | //% * |
| 1695 | //% * @param array Array containing the values to add to the new array. |
| 1696 | //% * |
| 1697 | //% * @return A newly instanced GPB##NAME##Array. |
| 1698 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1699 | //%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1700 | //% |
| 1701 | //%/** |
| 1702 | //% * Creates and initializes a GPB##NAME##Array with the given enum validation |
| 1703 | //% * function and with the givencapacity. |
| 1704 | //% * |
| 1705 | //% * @param func The enum validation function for the array. |
| 1706 | //% * @param count The capacity needed for the array. |
| 1707 | //% * |
| 1708 | //% * @return A newly instanced GPB##NAME##Array with a capacity of count. |
| 1709 | //% **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1710 | //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1711 | //% capacity:(NSUInteger)count; |
| 1712 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1713 | //%/** |
| 1714 | //% * Initializes the array with the given enum validation function. |
| 1715 | //% * |
| 1716 | //% * @param func The enum validation function for the array. |
| 1717 | //% * |
| 1718 | //% * @return A newly initialized GPB##NAME##Array with a copy of the values. |
| 1719 | //% **/ |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 1720 | //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
| 1721 | //% NS_DESIGNATED_INITIALIZER; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1722 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1723 | //%/** |
| 1724 | //% * Initializes the array, copying the given values. |
| 1725 | //% * |
| 1726 | //% * @param func The enum validation function for the array. |
| 1727 | //% * @param values An array with the values to put inside this array. |
| 1728 | //% * @param count The number of elements to copy into the array. |
| 1729 | //% * |
| 1730 | //% * @return A newly initialized GPB##NAME##Array with a copy of the values. |
| 1731 | //% **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1732 | //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1733 | //% rawValues:(const TYPE [__nullable])values |
Thomas Van Lenten | 4755bdc | 2016-05-10 10:28:09 -0400 | [diff] [blame] | 1734 | //% count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1735 | //% |
| 1736 | //%/** |
| 1737 | //% * Initializes the array, copying the given values. |
| 1738 | //% * |
| 1739 | //% * @param array An array with the values to put inside this array. |
| 1740 | //% * |
| 1741 | //% * @return A newly initialized GPB##NAME##Array with a copy of the values. |
| 1742 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1743 | //%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1744 | //% |
| 1745 | //%/** |
| 1746 | //% * Initializes the array with the given capacity. |
| 1747 | //% * |
| 1748 | //% * @param func The enum validation function for the array. |
| 1749 | //% * @param count The capacity needed for the array. |
| 1750 | //% * |
| 1751 | //% * @return A newly initialized GPB##NAME##Array with a capacity of count. |
| 1752 | //% **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 1753 | //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1754 | //% capacity:(NSUInteger)count; |
| 1755 | //% |
| 1756 | //%// These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a |
| 1757 | //%// valid enumerator as defined by validationFunc. If the actual value is |
| 1758 | //%// desired, use "raw" version of the method. |
| 1759 | //% |
| 1760 | //%ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, NAME) |
| 1761 | //% |
| 1762 | //%// These methods bypass the validationFunc to provide access to values that were not |
| 1763 | //%// known at the time the binary was compiled. |
| 1764 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1765 | //%/** |
| 1766 | //% * Gets the raw enum value at the given index. |
| 1767 | //% * |
| 1768 | //% * @param index The index of the raw enum value to get. |
| 1769 | //% * |
| 1770 | //% * @return The raw enum value at the given index. |
| 1771 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1772 | //%- (TYPE)rawValueAtIndex:(NSUInteger)index; |
| 1773 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1774 | //%/** |
| 1775 | //% * Enumerates the values on this array with the given block. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 1776 | //% * |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1777 | //% * @param block The block to enumerate with. |
| 1778 | //% * **value**: The current value being enumerated. |
| 1779 | //% * **idx**: The index of the current value. |
| 1780 | //% * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1781 | //% **/ |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 1782 | //%- (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1783 | //% |
| 1784 | //%/** |
| 1785 | //% * Enumerates the values on this array with the given block. |
| 1786 | //% * |
| 1787 | //% * @param opts Options to control the enumeration. |
| 1788 | //% * @param block The block to enumerate with. |
| 1789 | //% * **value**: The current value being enumerated. |
| 1790 | //% * **idx**: The index of the current value. |
| 1791 | //% * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1792 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1793 | //%- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 1794 | //% usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1795 | //% |
| 1796 | //%// If value is not a valid enumerator as defined by validationFunc, these |
| 1797 | //%// methods will assert in debug, and will log in release and assign the value |
| 1798 | //%// to the default value. Use the rawValue methods below to assign non enumerator |
| 1799 | //%// values. |
| 1800 | //% |
| 1801 | //%ARRAY_MUTABLE_INTERFACE(NAME, TYPE, NAME) |
| 1802 | //% |
| 1803 | //%@end |
| 1804 | //% |
| 1805 | |
| 1806 | //%PDDM-DEFINE ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME) |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1807 | //%/** |
| 1808 | //% * Gets the value at the given index. |
| 1809 | //% * |
| 1810 | //% * @param index The index of the value to get. |
| 1811 | //% * |
| 1812 | //% * @return The value at the given index. |
| 1813 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1814 | //%- (TYPE)valueAtIndex:(NSUInteger)index; |
| 1815 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1816 | //%/** |
| 1817 | //% * Enumerates the values on this array with the given block. |
| 1818 | //% * |
| 1819 | //% * @param block The block to enumerate with. |
| 1820 | //% * **value**: The current value being enumerated. |
| 1821 | //% * **idx**: The index of the current value. |
| 1822 | //% * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1823 | //% **/ |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 1824 | //%- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1825 | //% |
| 1826 | //%/** |
| 1827 | //% * Enumerates the values on this array with the given block. |
| 1828 | //% * |
| 1829 | //% * @param opts Options to control the enumeration. |
Sergio Campama | e7f5c9d | 2017-02-07 11:57:53 -0500 | [diff] [blame] | 1830 | //% * @param block The block to enumerate with. |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1831 | //% * **value**: The current value being enumerated. |
| 1832 | //% * **idx**: The index of the current value. |
| 1833 | //% * **stop**: A pointer to a boolean that when set stops the enumeration. |
| 1834 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1835 | //%- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts |
Thomas Van Lenten | 2af9c68 | 2018-12-04 10:47:35 -0500 | [diff] [blame^] | 1836 | //% usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1837 | |
| 1838 | //%PDDM-DEFINE ARRAY_MUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME) |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1839 | //%/** |
| 1840 | //% * Adds a value to this array. |
| 1841 | //% * |
| 1842 | //% * @param value The value to add to this array. |
| 1843 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1844 | //%- (void)addValue:(TYPE)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1845 | //% |
| 1846 | //%/** |
| 1847 | //% * Adds values to this array. |
| 1848 | //% * |
| 1849 | //% * @param values The values to add to this array. |
| 1850 | //% * @param count The number of elements to add. |
| 1851 | //% **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1852 | //%- (void)addValues:(const TYPE [__nullable])values count:(NSUInteger)count; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1853 | //% |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1854 | //%ARRAY_EXTRA_MUTABLE_METHODS1_##HELPER_NAME(NAME, TYPE) |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1855 | //%/** |
| 1856 | //% * Inserts a value into the given position. |
| 1857 | //% * |
| 1858 | //% * @param value The value to add to this array. |
| 1859 | //% * @param index The index into which to insert the value. |
| 1860 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1861 | //%- (void)insertValue:(TYPE)value atIndex:(NSUInteger)index; |
| 1862 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1863 | //%/** |
| 1864 | //% * Replaces the value at the given index with the given value. |
| 1865 | //% * |
| 1866 | //% * @param index The index for which to replace the value. |
| 1867 | //% * @param value The value to replace with. |
| 1868 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1869 | //%- (void)replaceValueAtIndex:(NSUInteger)index withValue:(TYPE)value; |
| 1870 | //%ARRAY_EXTRA_MUTABLE_METHODS2_##HELPER_NAME(NAME, TYPE) |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1871 | //%/** |
| 1872 | //% * Removes the value at the given index. |
| 1873 | //% * |
| 1874 | //% * @param index The index of the value to remove. |
| 1875 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1876 | //%- (void)removeValueAtIndex:(NSUInteger)index; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1877 | //% |
| 1878 | //%/** |
| 1879 | //% * Removes all the values from this array. |
| 1880 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1881 | //%- (void)removeAll; |
| 1882 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1883 | //%/** |
| 1884 | //% * Exchanges the values between the given indexes. |
| 1885 | //% * |
| 1886 | //% * @param idx1 The index of the first element to exchange. |
| 1887 | //% * @param idx2 The index of the second element to exchange. |
| 1888 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1889 | //%- (void)exchangeValueAtIndex:(NSUInteger)idx1 |
| 1890 | //% withValueAtIndex:(NSUInteger)idx2; |
| 1891 | |
| 1892 | // |
| 1893 | // These are hooks invoked by the above to do insert as needed. |
| 1894 | // |
| 1895 | |
| 1896 | //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS1_Basic(NAME, TYPE) |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1897 | //%/** |
| 1898 | //% * Adds the values from the given array to this array. |
| 1899 | //% * |
| 1900 | //% * @param array The array containing the elements to add to this array. |
| 1901 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1902 | //%- (void)addValuesFromArray:(GPB##NAME##Array *)array; |
| 1903 | //% |
| 1904 | //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS2_Basic(NAME, TYPE) |
| 1905 | // Empty |
| 1906 | //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS1_Enum(NAME, TYPE) |
| 1907 | // Empty |
| 1908 | //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS2_Enum(NAME, TYPE) |
| 1909 | //% |
| 1910 | //%// These methods bypass the validationFunc to provide setting of values that were not |
| 1911 | //%// known at the time the binary was compiled. |
| 1912 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1913 | //%/** |
| 1914 | //% * Adds a raw enum value to this array. |
| 1915 | //% * |
| 1916 | //% * @note This method bypass the validationFunc to enable the setting of values that |
| 1917 | //% * were not known at the time the binary was compiled. |
| 1918 | //% * |
| 1919 | //% * @param value The raw enum value to add to the array. |
| 1920 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1921 | //%- (void)addRawValue:(TYPE)value; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1922 | //% |
| 1923 | //%/** |
| 1924 | //% * Adds raw enum values to this array. |
| 1925 | //% * |
| 1926 | //% * @note This method bypass the validationFunc to enable the setting of values that |
| 1927 | //% * were not known at the time the binary was compiled. |
| 1928 | //% * |
| 1929 | //% * @param array Array containing the raw enum values to add to this array. |
| 1930 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1931 | //%- (void)addRawValuesFromArray:(GPB##NAME##Array *)array; |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1932 | //% |
| 1933 | //%/** |
| 1934 | //% * Adds raw enum values to this array. |
| 1935 | //% * |
| 1936 | //% * @note This method bypass the validationFunc to enable the setting of values that |
| 1937 | //% * were not known at the time the binary was compiled. |
| 1938 | //% * |
| 1939 | //% * @param values Array containing the raw enum values to add to this array. |
| 1940 | //% * @param count The number of raw values to add. |
| 1941 | //% **/ |
Sergio Campama | 3d7b42d | 2017-01-25 11:51:54 -0500 | [diff] [blame] | 1942 | //%- (void)addRawValues:(const TYPE [__nullable])values count:(NSUInteger)count; |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1943 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1944 | //%/** |
| 1945 | //% * Inserts a raw enum value at the given index. |
| 1946 | //% * |
| 1947 | //% * @note This method bypass the validationFunc to enable the setting of values that |
| 1948 | //% * were not known at the time the binary was compiled. |
| 1949 | //% * |
| 1950 | //% * @param value Raw enum value to add. |
| 1951 | //% * @param index The index into which to insert the value. |
| 1952 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1953 | //%- (void)insertRawValue:(TYPE)value atIndex:(NSUInteger)index; |
| 1954 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 1955 | //%/** |
| 1956 | //% * Replaces the raw enum value at the given index with the given value. |
| 1957 | //% * |
| 1958 | //% * @note This method bypass the validationFunc to enable the setting of values that |
| 1959 | //% * were not known at the time the binary was compiled. |
| 1960 | //% * |
| 1961 | //% * @param index The index for which to replace the value. |
| 1962 | //% * @param value The raw enum value to replace with. |
| 1963 | //% **/ |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1964 | //%- (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(TYPE)value; |
| 1965 | //% |
| 1966 | //%// No validation applies to these methods. |
| 1967 | //% |