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