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