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