blob: dc586626643bb7e97d59f28f50422e7b0f8c1f02 [file] [log] [blame]
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001// 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 Lentend846b0b2015-06-08 16:24:57 -040033#import "GPBRuntimeTypes.h"
Thomas Van Lenten30650d82015-05-01 08:57:16 -040034
Thomas Van Lenten8c889572015-06-16 16:45:14 -040035NS_ASSUME_NONNULL_BEGIN
36
Thomas Van Lenten9e069b22022-09-19 13:34:01 -040037// Disable clang-format for the macros.
38// clang-format off
39
Thomas Van Lenten30650d82015-05-01 08:57:16 -040040//%PDDM-EXPAND DECLARE_ARRAYS()
41// This block of code is generated, do not edit it directly.
42
43#pragma mark - Int32
44
Sergio Campamá32fadc02016-08-08 07:15:02 -070045/**
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 Bota185a6e2023-01-27 15:19:53 -080051__attribute__((objc_subclassing_restricted))
Thomas Van Lenten30650d82015-05-01 08:57:16 -040052@interface GPBInt32Array : NSObject <NSCopying>
53
Sergio Campamá32fadc02016-08-08 07:15:02 -070054/** The number of elements contained in the array. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -040055@property(nonatomic, readonly) NSUInteger count;
56
Sergio Campamá32fadc02016-08-08 07:15:02 -070057/**
58 * @return A newly instanced and empty GPBInt32Array.
59 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -040060+ (instancetype)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -070061
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 Lenten30650d82015-05-01 08:57:16 -040069+ (instancetype)arrayWithValue:(int32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -070070
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 Lenten30650d82015-05-01 08:57:16 -040079+ (instancetype)arrayWithValueArray:(GPBInt32Array *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -070080
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 Lenten30650d82015-05-01 08:57:16 -040088+ (instancetype)arrayWithCapacity:(NSUInteger)count;
89
Sergio Campamá32fadc02016-08-08 07:15:02 -070090/**
91 * @return A newly initialized and empty GPBInt32Array.
92 **/
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -040093- (instancetype)init NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -070094
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 Campama3d7b42d2017-01-25 11:51:54 -0500103- (instancetype)initWithValues:(const int32_t [__nullable])values
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -0400104 count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700105
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 Lenten30650d82015-05-01 08:57:16 -0400113- (instancetype)initWithValueArray:(GPBInt32Array *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700114
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 Lenten30650d82015-05-01 08:57:16 -0400122- (instancetype)initWithCapacity:(NSUInteger)count;
123
Sergio Campamá32fadc02016-08-08 07:15:02 -0700124/**
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 Lenten30650d82015-05-01 08:57:16 -0400131- (int32_t)valueAtIndex:(NSUInteger)index;
132
Sergio Campamá32fadc02016-08-08 07:15:02 -0700133/**
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 Lenten9e069b22022-09-19 13:34:01 -0400141- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx,
142 BOOL *stop))block;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700143
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 Lenten30650d82015-05-01 08:57:16 -0400153- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
Thomas Van Lenten9e069b22022-09-19 13:34:01 -0400154 usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx,
155 BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400156
Sergio Campamá32fadc02016-08-08 07:15:02 -0700157/**
158 * Adds a value to this array.
159 *
160 * @param value The value to add to this array.
161 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400162- (void)addValue:(int32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700163
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 Campama3d7b42d2017-01-25 11:51:54 -0500170- (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700171
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 Lenten30650d82015-05-01 08:57:16 -0400177- (void)addValuesFromArray:(GPBInt32Array *)array;
178
Sergio Campamá32fadc02016-08-08 07:15:02 -0700179/**
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 Lenten30650d82015-05-01 08:57:16 -0400185- (void)insertValue:(int32_t)value atIndex:(NSUInteger)index;
186
Sergio Campamá32fadc02016-08-08 07:15:02 -0700187/**
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 Lenten30650d82015-05-01 08:57:16 -0400193- (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value;
194
Sergio Campamá32fadc02016-08-08 07:15:02 -0700195/**
196 * Removes the value at the given index.
197 *
198 * @param index The index of the value to remove.
199 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400200- (void)removeValueAtIndex:(NSUInteger)index;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700201
202/**
203 * Removes all the values from this array.
204 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400205- (void)removeAll;
206
Sergio Campamá32fadc02016-08-08 07:15:02 -0700207/**
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 Lenten30650d82015-05-01 08:57:16 -0400213- (void)exchangeValueAtIndex:(NSUInteger)idx1
214 withValueAtIndex:(NSUInteger)idx2;
215
216@end
217
218#pragma mark - UInt32
219
Sergio Campamá32fadc02016-08-08 07:15:02 -0700220/**
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 Bota185a6e2023-01-27 15:19:53 -0800226__attribute__((objc_subclassing_restricted))
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400227@interface GPBUInt32Array : NSObject <NSCopying>
228
Sergio Campamá32fadc02016-08-08 07:15:02 -0700229/** The number of elements contained in the array. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400230@property(nonatomic, readonly) NSUInteger count;
231
Sergio Campamá32fadc02016-08-08 07:15:02 -0700232/**
233 * @return A newly instanced and empty GPBUInt32Array.
234 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400235+ (instancetype)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700236
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 Lenten30650d82015-05-01 08:57:16 -0400244+ (instancetype)arrayWithValue:(uint32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700245
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 Lenten30650d82015-05-01 08:57:16 -0400254+ (instancetype)arrayWithValueArray:(GPBUInt32Array *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700255
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 Lenten30650d82015-05-01 08:57:16 -0400263+ (instancetype)arrayWithCapacity:(NSUInteger)count;
264
Sergio Campamá32fadc02016-08-08 07:15:02 -0700265/**
266 * @return A newly initialized and empty GPBUInt32Array.
267 **/
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -0400268- (instancetype)init NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700269
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 Campama3d7b42d2017-01-25 11:51:54 -0500278- (instancetype)initWithValues:(const uint32_t [__nullable])values
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -0400279 count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700280
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 Lenten30650d82015-05-01 08:57:16 -0400288- (instancetype)initWithValueArray:(GPBUInt32Array *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700289
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 Lenten30650d82015-05-01 08:57:16 -0400297- (instancetype)initWithCapacity:(NSUInteger)count;
298
Sergio Campamá32fadc02016-08-08 07:15:02 -0700299/**
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 Lenten30650d82015-05-01 08:57:16 -0400306- (uint32_t)valueAtIndex:(NSUInteger)index;
307
Sergio Campamá32fadc02016-08-08 07:15:02 -0700308/**
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 Lenten9e069b22022-09-19 13:34:01 -0400316- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx,
317 BOOL *stop))block;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700318
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 Lenten30650d82015-05-01 08:57:16 -0400328- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
Thomas Van Lenten9e069b22022-09-19 13:34:01 -0400329 usingBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx,
330 BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400331
Sergio Campamá32fadc02016-08-08 07:15:02 -0700332/**
333 * Adds a value to this array.
334 *
335 * @param value The value to add to this array.
336 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400337- (void)addValue:(uint32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700338
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 Campama3d7b42d2017-01-25 11:51:54 -0500345- (void)addValues:(const uint32_t [__nullable])values count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700346
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 Lenten30650d82015-05-01 08:57:16 -0400352- (void)addValuesFromArray:(GPBUInt32Array *)array;
353
Sergio Campamá32fadc02016-08-08 07:15:02 -0700354/**
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 Lenten30650d82015-05-01 08:57:16 -0400360- (void)insertValue:(uint32_t)value atIndex:(NSUInteger)index;
361
Sergio Campamá32fadc02016-08-08 07:15:02 -0700362/**
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 Lenten30650d82015-05-01 08:57:16 -0400368- (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint32_t)value;
369
Sergio Campamá32fadc02016-08-08 07:15:02 -0700370/**
371 * Removes the value at the given index.
372 *
373 * @param index The index of the value to remove.
374 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400375- (void)removeValueAtIndex:(NSUInteger)index;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700376
377/**
378 * Removes all the values from this array.
379 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400380- (void)removeAll;
381
Sergio Campamá32fadc02016-08-08 07:15:02 -0700382/**
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 Lenten30650d82015-05-01 08:57:16 -0400388- (void)exchangeValueAtIndex:(NSUInteger)idx1
389 withValueAtIndex:(NSUInteger)idx2;
390
391@end
392
393#pragma mark - Int64
394
Sergio Campamá32fadc02016-08-08 07:15:02 -0700395/**
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 Bota185a6e2023-01-27 15:19:53 -0800401__attribute__((objc_subclassing_restricted))
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400402@interface GPBInt64Array : NSObject <NSCopying>
403
Sergio Campamá32fadc02016-08-08 07:15:02 -0700404/** The number of elements contained in the array. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400405@property(nonatomic, readonly) NSUInteger count;
406
Sergio Campamá32fadc02016-08-08 07:15:02 -0700407/**
408 * @return A newly instanced and empty GPBInt64Array.
409 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400410+ (instancetype)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700411
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 Lenten30650d82015-05-01 08:57:16 -0400419+ (instancetype)arrayWithValue:(int64_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700420
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 Lenten30650d82015-05-01 08:57:16 -0400429+ (instancetype)arrayWithValueArray:(GPBInt64Array *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700430
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 Lenten30650d82015-05-01 08:57:16 -0400438+ (instancetype)arrayWithCapacity:(NSUInteger)count;
439
Sergio Campamá32fadc02016-08-08 07:15:02 -0700440/**
441 * @return A newly initialized and empty GPBInt64Array.
442 **/
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -0400443- (instancetype)init NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700444
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 Campama3d7b42d2017-01-25 11:51:54 -0500453- (instancetype)initWithValues:(const int64_t [__nullable])values
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -0400454 count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700455
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 Lenten30650d82015-05-01 08:57:16 -0400463- (instancetype)initWithValueArray:(GPBInt64Array *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700464
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 Lenten30650d82015-05-01 08:57:16 -0400472- (instancetype)initWithCapacity:(NSUInteger)count;
473
Sergio Campamá32fadc02016-08-08 07:15:02 -0700474/**
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 Lenten30650d82015-05-01 08:57:16 -0400481- (int64_t)valueAtIndex:(NSUInteger)index;
482
Sergio Campamá32fadc02016-08-08 07:15:02 -0700483/**
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 Lenten9e069b22022-09-19 13:34:01 -0400491- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx,
492 BOOL *stop))block;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700493
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 Lenten30650d82015-05-01 08:57:16 -0400503- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
Thomas Van Lenten9e069b22022-09-19 13:34:01 -0400504 usingBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx,
505 BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400506
Sergio Campamá32fadc02016-08-08 07:15:02 -0700507/**
508 * Adds a value to this array.
509 *
510 * @param value The value to add to this array.
511 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400512- (void)addValue:(int64_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700513
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 Campama3d7b42d2017-01-25 11:51:54 -0500520- (void)addValues:(const int64_t [__nullable])values count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700521
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 Lenten30650d82015-05-01 08:57:16 -0400527- (void)addValuesFromArray:(GPBInt64Array *)array;
528
Sergio Campamá32fadc02016-08-08 07:15:02 -0700529/**
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 Lenten30650d82015-05-01 08:57:16 -0400535- (void)insertValue:(int64_t)value atIndex:(NSUInteger)index;
536
Sergio Campamá32fadc02016-08-08 07:15:02 -0700537/**
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 Lenten30650d82015-05-01 08:57:16 -0400543- (void)replaceValueAtIndex:(NSUInteger)index withValue:(int64_t)value;
544
Sergio Campamá32fadc02016-08-08 07:15:02 -0700545/**
546 * Removes the value at the given index.
547 *
548 * @param index The index of the value to remove.
549 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400550- (void)removeValueAtIndex:(NSUInteger)index;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700551
552/**
553 * Removes all the values from this array.
554 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400555- (void)removeAll;
556
Sergio Campamá32fadc02016-08-08 07:15:02 -0700557/**
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 Lenten30650d82015-05-01 08:57:16 -0400563- (void)exchangeValueAtIndex:(NSUInteger)idx1
564 withValueAtIndex:(NSUInteger)idx2;
565
566@end
567
568#pragma mark - UInt64
569
Sergio Campamá32fadc02016-08-08 07:15:02 -0700570/**
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 Bota185a6e2023-01-27 15:19:53 -0800576__attribute__((objc_subclassing_restricted))
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400577@interface GPBUInt64Array : NSObject <NSCopying>
578
Sergio Campamá32fadc02016-08-08 07:15:02 -0700579/** The number of elements contained in the array. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400580@property(nonatomic, readonly) NSUInteger count;
581
Sergio Campamá32fadc02016-08-08 07:15:02 -0700582/**
583 * @return A newly instanced and empty GPBUInt64Array.
584 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400585+ (instancetype)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700586
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 Lenten30650d82015-05-01 08:57:16 -0400594+ (instancetype)arrayWithValue:(uint64_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700595
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 Lenten30650d82015-05-01 08:57:16 -0400604+ (instancetype)arrayWithValueArray:(GPBUInt64Array *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700605
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 Lenten30650d82015-05-01 08:57:16 -0400613+ (instancetype)arrayWithCapacity:(NSUInteger)count;
614
Sergio Campamá32fadc02016-08-08 07:15:02 -0700615/**
616 * @return A newly initialized and empty GPBUInt64Array.
617 **/
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -0400618- (instancetype)init NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700619
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 Campama3d7b42d2017-01-25 11:51:54 -0500628- (instancetype)initWithValues:(const uint64_t [__nullable])values
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -0400629 count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700630
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 Lenten30650d82015-05-01 08:57:16 -0400638- (instancetype)initWithValueArray:(GPBUInt64Array *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700639
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 Lenten30650d82015-05-01 08:57:16 -0400647- (instancetype)initWithCapacity:(NSUInteger)count;
648
Sergio Campamá32fadc02016-08-08 07:15:02 -0700649/**
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 Lenten30650d82015-05-01 08:57:16 -0400656- (uint64_t)valueAtIndex:(NSUInteger)index;
657
Sergio Campamá32fadc02016-08-08 07:15:02 -0700658/**
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 Lenten9e069b22022-09-19 13:34:01 -0400666- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx,
667 BOOL *stop))block;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700668
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 Lenten30650d82015-05-01 08:57:16 -0400678- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
Thomas Van Lenten9e069b22022-09-19 13:34:01 -0400679 usingBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx,
680 BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400681
Sergio Campamá32fadc02016-08-08 07:15:02 -0700682/**
683 * Adds a value to this array.
684 *
685 * @param value The value to add to this array.
686 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400687- (void)addValue:(uint64_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700688
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 Campama3d7b42d2017-01-25 11:51:54 -0500695- (void)addValues:(const uint64_t [__nullable])values count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700696
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 Lenten30650d82015-05-01 08:57:16 -0400702- (void)addValuesFromArray:(GPBUInt64Array *)array;
703
Sergio Campamá32fadc02016-08-08 07:15:02 -0700704/**
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 Lenten30650d82015-05-01 08:57:16 -0400710- (void)insertValue:(uint64_t)value atIndex:(NSUInteger)index;
711
Sergio Campamá32fadc02016-08-08 07:15:02 -0700712/**
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 Lenten30650d82015-05-01 08:57:16 -0400718- (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint64_t)value;
719
Sergio Campamá32fadc02016-08-08 07:15:02 -0700720/**
721 * Removes the value at the given index.
722 *
723 * @param index The index of the value to remove.
724 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400725- (void)removeValueAtIndex:(NSUInteger)index;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700726
727/**
728 * Removes all the values from this array.
729 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400730- (void)removeAll;
731
Sergio Campamá32fadc02016-08-08 07:15:02 -0700732/**
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 Lenten30650d82015-05-01 08:57:16 -0400738- (void)exchangeValueAtIndex:(NSUInteger)idx1
739 withValueAtIndex:(NSUInteger)idx2;
740
741@end
742
743#pragma mark - Float
744
Sergio Campamá32fadc02016-08-08 07:15:02 -0700745/**
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 Bota185a6e2023-01-27 15:19:53 -0800751__attribute__((objc_subclassing_restricted))
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400752@interface GPBFloatArray : NSObject <NSCopying>
753
Sergio Campamá32fadc02016-08-08 07:15:02 -0700754/** The number of elements contained in the array. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400755@property(nonatomic, readonly) NSUInteger count;
756
Sergio Campamá32fadc02016-08-08 07:15:02 -0700757/**
758 * @return A newly instanced and empty GPBFloatArray.
759 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400760+ (instancetype)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700761
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 Lenten30650d82015-05-01 08:57:16 -0400769+ (instancetype)arrayWithValue:(float)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700770
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 Lenten30650d82015-05-01 08:57:16 -0400779+ (instancetype)arrayWithValueArray:(GPBFloatArray *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700780
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 Lenten30650d82015-05-01 08:57:16 -0400788+ (instancetype)arrayWithCapacity:(NSUInteger)count;
789
Sergio Campamá32fadc02016-08-08 07:15:02 -0700790/**
791 * @return A newly initialized and empty GPBFloatArray.
792 **/
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -0400793- (instancetype)init NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700794
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 Campama3d7b42d2017-01-25 11:51:54 -0500803- (instancetype)initWithValues:(const float [__nullable])values
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -0400804 count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700805
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 Lenten30650d82015-05-01 08:57:16 -0400813- (instancetype)initWithValueArray:(GPBFloatArray *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700814
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 Lenten30650d82015-05-01 08:57:16 -0400822- (instancetype)initWithCapacity:(NSUInteger)count;
823
Sergio Campamá32fadc02016-08-08 07:15:02 -0700824/**
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 Lenten30650d82015-05-01 08:57:16 -0400831- (float)valueAtIndex:(NSUInteger)index;
832
Sergio Campamá32fadc02016-08-08 07:15:02 -0700833/**
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 Lenten9e069b22022-09-19 13:34:01 -0400841- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx,
842 BOOL *stop))block;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700843
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 Lenten30650d82015-05-01 08:57:16 -0400853- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
Thomas Van Lenten9e069b22022-09-19 13:34:01 -0400854 usingBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx,
855 BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400856
Sergio Campamá32fadc02016-08-08 07:15:02 -0700857/**
858 * Adds a value to this array.
859 *
860 * @param value The value to add to this array.
861 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400862- (void)addValue:(float)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700863
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 Campama3d7b42d2017-01-25 11:51:54 -0500870- (void)addValues:(const float [__nullable])values count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700871
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 Lenten30650d82015-05-01 08:57:16 -0400877- (void)addValuesFromArray:(GPBFloatArray *)array;
878
Sergio Campamá32fadc02016-08-08 07:15:02 -0700879/**
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 Lenten30650d82015-05-01 08:57:16 -0400885- (void)insertValue:(float)value atIndex:(NSUInteger)index;
886
Sergio Campamá32fadc02016-08-08 07:15:02 -0700887/**
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 Lenten30650d82015-05-01 08:57:16 -0400893- (void)replaceValueAtIndex:(NSUInteger)index withValue:(float)value;
894
Sergio Campamá32fadc02016-08-08 07:15:02 -0700895/**
896 * Removes the value at the given index.
897 *
898 * @param index The index of the value to remove.
899 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400900- (void)removeValueAtIndex:(NSUInteger)index;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700901
902/**
903 * Removes all the values from this array.
904 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400905- (void)removeAll;
906
Sergio Campamá32fadc02016-08-08 07:15:02 -0700907/**
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 Lenten30650d82015-05-01 08:57:16 -0400913- (void)exchangeValueAtIndex:(NSUInteger)idx1
914 withValueAtIndex:(NSUInteger)idx2;
915
916@end
917
918#pragma mark - Double
919
Sergio Campamá32fadc02016-08-08 07:15:02 -0700920/**
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 Bota185a6e2023-01-27 15:19:53 -0800926__attribute__((objc_subclassing_restricted))
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400927@interface GPBDoubleArray : NSObject <NSCopying>
928
Sergio Campamá32fadc02016-08-08 07:15:02 -0700929/** The number of elements contained in the array. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400930@property(nonatomic, readonly) NSUInteger count;
931
Sergio Campamá32fadc02016-08-08 07:15:02 -0700932/**
933 * @return A newly instanced and empty GPBDoubleArray.
934 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -0400935+ (instancetype)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700936
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 Lenten30650d82015-05-01 08:57:16 -0400944+ (instancetype)arrayWithValue:(double)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700945
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 Lenten30650d82015-05-01 08:57:16 -0400954+ (instancetype)arrayWithValueArray:(GPBDoubleArray *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700955
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 Lenten30650d82015-05-01 08:57:16 -0400963+ (instancetype)arrayWithCapacity:(NSUInteger)count;
964
Sergio Campamá32fadc02016-08-08 07:15:02 -0700965/**
966 * @return A newly initialized and empty GPBDoubleArray.
967 **/
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -0400968- (instancetype)init NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700969
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 Campama3d7b42d2017-01-25 11:51:54 -0500978- (instancetype)initWithValues:(const double [__nullable])values
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -0400979 count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700980
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 Lenten30650d82015-05-01 08:57:16 -0400988- (instancetype)initWithValueArray:(GPBDoubleArray *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -0700989
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 Lenten30650d82015-05-01 08:57:16 -0400997- (instancetype)initWithCapacity:(NSUInteger)count;
998
Sergio Campamá32fadc02016-08-08 07:15:02 -0700999/**
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 Lenten30650d82015-05-01 08:57:16 -04001006- (double)valueAtIndex:(NSUInteger)index;
1007
Sergio Campamá32fadc02016-08-08 07:15:02 -07001008/**
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 Lenten9e069b22022-09-19 13:34:01 -04001016- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx,
1017 BOOL *stop))block;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001018
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 Lenten30650d82015-05-01 08:57:16 -04001028- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
Thomas Van Lenten9e069b22022-09-19 13:34:01 -04001029 usingBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx,
1030 BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001031
Sergio Campamá32fadc02016-08-08 07:15:02 -07001032/**
1033 * Adds a value to this array.
1034 *
1035 * @param value The value to add to this array.
1036 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001037- (void)addValue:(double)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001038
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 Campama3d7b42d2017-01-25 11:51:54 -05001045- (void)addValues:(const double [__nullable])values count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001046
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 Lenten30650d82015-05-01 08:57:16 -04001052- (void)addValuesFromArray:(GPBDoubleArray *)array;
1053
Sergio Campamá32fadc02016-08-08 07:15:02 -07001054/**
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 Lenten30650d82015-05-01 08:57:16 -04001060- (void)insertValue:(double)value atIndex:(NSUInteger)index;
1061
Sergio Campamá32fadc02016-08-08 07:15:02 -07001062/**
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 Lenten30650d82015-05-01 08:57:16 -04001068- (void)replaceValueAtIndex:(NSUInteger)index withValue:(double)value;
1069
Sergio Campamá32fadc02016-08-08 07:15:02 -07001070/**
1071 * Removes the value at the given index.
1072 *
1073 * @param index The index of the value to remove.
1074 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001075- (void)removeValueAtIndex:(NSUInteger)index;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001076
1077/**
1078 * Removes all the values from this array.
1079 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001080- (void)removeAll;
1081
Sergio Campamá32fadc02016-08-08 07:15:02 -07001082/**
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 Lenten30650d82015-05-01 08:57:16 -04001088- (void)exchangeValueAtIndex:(NSUInteger)idx1
1089 withValueAtIndex:(NSUInteger)idx2;
1090
1091@end
1092
1093#pragma mark - Bool
1094
Sergio Campamá32fadc02016-08-08 07:15:02 -07001095/**
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 Bota185a6e2023-01-27 15:19:53 -08001101__attribute__((objc_subclassing_restricted))
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001102@interface GPBBoolArray : NSObject <NSCopying>
1103
Sergio Campamá32fadc02016-08-08 07:15:02 -07001104/** The number of elements contained in the array. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001105@property(nonatomic, readonly) NSUInteger count;
1106
Sergio Campamá32fadc02016-08-08 07:15:02 -07001107/**
1108 * @return A newly instanced and empty GPBBoolArray.
1109 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001110+ (instancetype)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001111
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 Lenten30650d82015-05-01 08:57:16 -04001119+ (instancetype)arrayWithValue:(BOOL)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001120
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 Lenten30650d82015-05-01 08:57:16 -04001129+ (instancetype)arrayWithValueArray:(GPBBoolArray *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001130
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 Lenten30650d82015-05-01 08:57:16 -04001138+ (instancetype)arrayWithCapacity:(NSUInteger)count;
1139
Sergio Campamá32fadc02016-08-08 07:15:02 -07001140/**
1141 * @return A newly initialized and empty GPBBoolArray.
1142 **/
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -04001143- (instancetype)init NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001144
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 Campama3d7b42d2017-01-25 11:51:54 -05001153- (instancetype)initWithValues:(const BOOL [__nullable])values
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -04001154 count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001155
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 Lenten30650d82015-05-01 08:57:16 -04001163- (instancetype)initWithValueArray:(GPBBoolArray *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001164
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 Lenten30650d82015-05-01 08:57:16 -04001172- (instancetype)initWithCapacity:(NSUInteger)count;
1173
Sergio Campamá32fadc02016-08-08 07:15:02 -07001174/**
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 Lenten30650d82015-05-01 08:57:16 -04001181- (BOOL)valueAtIndex:(NSUInteger)index;
1182
Sergio Campamá32fadc02016-08-08 07:15:02 -07001183/**
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 Lenten9e069b22022-09-19 13:34:01 -04001191- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx,
1192 BOOL *stop))block;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001193
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 Lenten30650d82015-05-01 08:57:16 -04001203- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
Thomas Van Lenten9e069b22022-09-19 13:34:01 -04001204 usingBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx,
1205 BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001206
Sergio Campamá32fadc02016-08-08 07:15:02 -07001207/**
1208 * Adds a value to this array.
1209 *
1210 * @param value The value to add to this array.
1211 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001212- (void)addValue:(BOOL)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001213
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 Campama3d7b42d2017-01-25 11:51:54 -05001220- (void)addValues:(const BOOL [__nullable])values count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001221
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 Lenten30650d82015-05-01 08:57:16 -04001227- (void)addValuesFromArray:(GPBBoolArray *)array;
1228
Sergio Campamá32fadc02016-08-08 07:15:02 -07001229/**
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 Lenten30650d82015-05-01 08:57:16 -04001235- (void)insertValue:(BOOL)value atIndex:(NSUInteger)index;
1236
Sergio Campamá32fadc02016-08-08 07:15:02 -07001237/**
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 Lenten30650d82015-05-01 08:57:16 -04001243- (void)replaceValueAtIndex:(NSUInteger)index withValue:(BOOL)value;
1244
Sergio Campamá32fadc02016-08-08 07:15:02 -07001245/**
1246 * Removes the value at the given index.
1247 *
1248 * @param index The index of the value to remove.
1249 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001250- (void)removeValueAtIndex:(NSUInteger)index;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001251
1252/**
1253 * Removes all the values from this array.
1254 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001255- (void)removeAll;
1256
Sergio Campamá32fadc02016-08-08 07:15:02 -07001257/**
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 Lenten30650d82015-05-01 08:57:16 -04001263- (void)exchangeValueAtIndex:(NSUInteger)idx1
1264 withValueAtIndex:(NSUInteger)idx2;
1265
1266@end
1267
1268#pragma mark - Enum
1269
Sergio Campamá32fadc02016-08-08 07:15:02 -07001270/**
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 Bota185a6e2023-01-27 15:19:53 -08001276__attribute__((objc_subclassing_restricted))
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001277@interface GPBEnumArray : NSObject <NSCopying>
1278
Sergio Campamá32fadc02016-08-08 07:15:02 -07001279/** The number of elements contained in the array. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001280@property(nonatomic, readonly) NSUInteger count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001281/** The validation function to check if the enums are valid. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001282@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
1283
Sergio Campamá32fadc02016-08-08 07:15:02 -07001284/**
1285 * @return A newly instanced and empty GPBEnumArray.
1286 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001287+ (instancetype)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001288
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 Lenten8c889572015-06-16 16:45:14 -04001297+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001298
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 Lenten8c889572015-06-16 16:45:14 -04001308+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001309 rawValue:(int32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001310
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 Lenten30650d82015-05-01 08:57:16 -04001319+ (instancetype)arrayWithValueArray:(GPBEnumArray *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001320
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 Lenten8c889572015-06-16 16:45:14 -04001330+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001331 capacity:(NSUInteger)count;
1332
Sergio Campamá32fadc02016-08-08 07:15:02 -07001333/**
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 Lenten4755bdc2016-05-10 10:28:09 -04001340- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
1341 NS_DESIGNATED_INITIALIZER;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001342
Sergio Campamá32fadc02016-08-08 07:15:02 -07001343/**
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 Lenten8c889572015-06-16 16:45:14 -04001352- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Sergio Campama3d7b42d2017-01-25 11:51:54 -05001353 rawValues:(const int32_t [__nullable])values
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -04001354 count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001355
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 Lenten30650d82015-05-01 08:57:16 -04001363- (instancetype)initWithValueArray:(GPBEnumArray *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001364
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 Lenten8c889572015-06-16 16:45:14 -04001373- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001374 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á32fadc02016-08-08 07:15:02 -07001380/**
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 Lenten30650d82015-05-01 08:57:16 -04001387- (int32_t)valueAtIndex:(NSUInteger)index;
1388
Sergio Campamá32fadc02016-08-08 07:15:02 -07001389/**
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 Lenten9e069b22022-09-19 13:34:01 -04001397- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx,
1398 BOOL *stop))block;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001399
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 Lenten30650d82015-05-01 08:57:16 -04001409- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
Thomas Van Lenten9e069b22022-09-19 13:34:01 -04001410 usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx,
1411 BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001412
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á32fadc02016-08-08 07:15:02 -07001416/**
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 Lenten30650d82015-05-01 08:57:16 -04001423- (int32_t)rawValueAtIndex:(NSUInteger)index;
1424
Sergio Campamá32fadc02016-08-08 07:15:02 -07001425/**
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 Lenten9e069b22022-09-19 13:34:01 -04001433- (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx,
1434 BOOL *stop))block;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001435
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 Lenten30650d82015-05-01 08:57:16 -04001445- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
Thomas Van Lenten9e069b22022-09-19 13:34:01 -04001446 usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx,
1447 BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001448
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á32fadc02016-08-08 07:15:02 -07001454/**
1455 * Adds a value to this array.
1456 *
1457 * @param value The value to add to this array.
1458 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001459- (void)addValue:(int32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001460
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 Campama3d7b42d2017-01-25 11:51:54 -05001467- (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001468
Sergio Campamá32fadc02016-08-08 07:15:02 -07001469
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 Lenten30650d82015-05-01 08:57:16 -04001476- (void)insertValue:(int32_t)value atIndex:(NSUInteger)index;
1477
Sergio Campamá32fadc02016-08-08 07:15:02 -07001478/**
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 Lenten30650d82015-05-01 08:57:16 -04001484- (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á32fadc02016-08-08 07:15:02 -07001489/**
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 Lenten30650d82015-05-01 08:57:16 -04001497- (void)addRawValue:(int32_t)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001498
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 Lenten30650d82015-05-01 08:57:16 -04001507- (void)addRawValuesFromArray:(GPBEnumArray *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001508
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 Campama3d7b42d2017-01-25 11:51:54 -05001518- (void)addRawValues:(const int32_t [__nullable])values count:(NSUInteger)count;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001519
Sergio Campamá32fadc02016-08-08 07:15:02 -07001520/**
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 Lenten30650d82015-05-01 08:57:16 -04001529- (void)insertRawValue:(int32_t)value atIndex:(NSUInteger)index;
1530
Sergio Campamá32fadc02016-08-08 07:15:02 -07001531/**
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 Lenten30650d82015-05-01 08:57:16 -04001540- (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(int32_t)value;
1541
1542// No validation applies to these methods.
1543
Sergio Campamá32fadc02016-08-08 07:15:02 -07001544/**
1545 * Removes the value at the given index.
1546 *
1547 * @param index The index of the value to remove.
1548 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001549- (void)removeValueAtIndex:(NSUInteger)index;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001550
1551/**
1552 * Removes all the values from this array.
1553 **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001554- (void)removeAll;
1555
Sergio Campamá32fadc02016-08-08 07:15:02 -07001556/**
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 Lenten30650d82015-05-01 08:57:16 -04001562- (void)exchangeValueAtIndex:(NSUInteger)idx1
1563 withValueAtIndex:(NSUInteger)idx2;
1564
1565@end
1566
1567//%PDDM-EXPAND-END DECLARE_ARRAYS()
1568
Thomas Van Lenten8c889572015-06-16 16:45:14 -04001569NS_ASSUME_NONNULL_END
1570
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001571//%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á32fadc02016-08-08 07:15:02 -07001588//%/**
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 Bota185a6e2023-01-27 15:19:53 -08001594//%__attribute__((objc_subclassing_restricted))
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001595//%@interface GPB##NAME##Array : NSObject <NSCopying>
1596//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07001597//%/** The number of elements contained in the array. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001598//%@property(nonatomic, readonly) NSUInteger count;
1599//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07001600//%/**
1601//% * @return A newly instanced and empty GPB##NAME##Array.
1602//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001603//%+ (instancetype)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001604//%
1605//%/**
1606//% * Creates and initializes a GPB##NAME##Array with the single element given.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05001607//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07001608//% * @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 Lenten30650d82015-05-01 08:57:16 -04001612//%+ (instancetype)arrayWithValue:(TYPE)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001613//%
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 Lenten30650d82015-05-01 08:57:16 -04001622//%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001623//%
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 Lenten30650d82015-05-01 08:57:16 -04001631//%+ (instancetype)arrayWithCapacity:(NSUInteger)count;
1632//%
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05001633//%/**
Sergio Campamá32fadc02016-08-08 07:15:02 -07001634//% * @return A newly initialized and empty GPB##NAME##Array.
1635//% **/
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -04001636//%- (instancetype)init NS_DESIGNATED_INITIALIZER;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001637//%
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 Campama3d7b42d2017-01-25 11:51:54 -05001646//%- (instancetype)initWithValues:(const TYPE [__nullable])values
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -04001647//% count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001648//%
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 Lenten30650d82015-05-01 08:57:16 -04001656//%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001657//%
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 Lenten30650d82015-05-01 08:57:16 -04001665//%- (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á32fadc02016-08-08 07:15:02 -07001681//%/**
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 Bota185a6e2023-01-27 15:19:53 -08001687//%__attribute__((objc_subclassing_restricted))
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001688//%@interface GPB##NAME##Array : NSObject <NSCopying>
1689//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07001690//%/** The number of elements contained in the array. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001691//%@property(nonatomic, readonly) NSUInteger count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001692//%/** The validation function to check if the enums are valid. */
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001693//%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
1694//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07001695//%/**
1696//% * @return A newly instanced and empty GPB##NAME##Array.
1697//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001698//%+ (instancetype)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001699//%
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 Lenten8c889572015-06-16 16:45:14 -04001708//%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001709//%
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 Lenten8c889572015-06-16 16:45:14 -04001719//%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001720//% rawValue:(TYPE)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001721//%
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 Lenten30650d82015-05-01 08:57:16 -04001730//%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001731//%
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 Lenten8c889572015-06-16 16:45:14 -04001741//%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001742//% capacity:(NSUInteger)count;
1743//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07001744//%/**
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 Lenten4755bdc2016-05-10 10:28:09 -04001751//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
1752//% NS_DESIGNATED_INITIALIZER;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001753//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07001754//%/**
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 Lenten8c889572015-06-16 16:45:14 -04001763//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Sergio Campama3d7b42d2017-01-25 11:51:54 -05001764//% rawValues:(const TYPE [__nullable])values
Thomas Van Lenten4755bdc2016-05-10 10:28:09 -04001765//% count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001766//%
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 Lenten30650d82015-05-01 08:57:16 -04001774//%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001775//%
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 Lenten8c889572015-06-16 16:45:14 -04001784//%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001785//% 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á32fadc02016-08-08 07:15:02 -07001796//%/**
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 Lenten30650d82015-05-01 08:57:16 -04001803//%- (TYPE)rawValueAtIndex:(NSUInteger)index;
1804//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07001805//%/**
1806//% * Enumerates the values on this array with the given block.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05001807//% *
Sergio Campamá32fadc02016-08-08 07:15:02 -07001808//% * @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 Lenten9e069b22022-09-19 13:34:01 -04001813//%- (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx,
1814//% BOOL *stop))block;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001815//%
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 Lenten30650d82015-05-01 08:57:16 -04001825//%- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
Thomas Van Lenten9e069b22022-09-19 13:34:01 -04001826//% usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx,
1827//% BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001828//%
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á32fadc02016-08-08 07:15:02 -07001840//%/**
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 Lenten30650d82015-05-01 08:57:16 -04001847//%- (TYPE)valueAtIndex:(NSUInteger)index;
1848//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07001849//%/**
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 Lenten9e069b22022-09-19 13:34:01 -04001857//%- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx,
1858//% BOOL *stop))block;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001859//%
1860//%/**
1861//% * Enumerates the values on this array with the given block.
1862//% *
1863//% * @param opts Options to control the enumeration.
Sergio Campamae7f5c9d2017-02-07 11:57:53 -05001864//% * @param block The block to enumerate with.
Sergio Campamá32fadc02016-08-08 07:15:02 -07001865//% * **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 Lenten30650d82015-05-01 08:57:16 -04001869//%- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
Thomas Van Lenten9e069b22022-09-19 13:34:01 -04001870//% usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx,
1871//% BOOL *stop))block;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001872
1873//%PDDM-DEFINE ARRAY_MUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME)
Sergio Campamá32fadc02016-08-08 07:15:02 -07001874//%/**
1875//% * Adds a value to this array.
1876//% *
1877//% * @param value The value to add to this array.
1878//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001879//%- (void)addValue:(TYPE)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001880//%
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 Campama3d7b42d2017-01-25 11:51:54 -05001887//%- (void)addValues:(const TYPE [__nullable])values count:(NSUInteger)count;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001888//%
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001889//%ARRAY_EXTRA_MUTABLE_METHODS1_##HELPER_NAME(NAME, TYPE)
Sergio Campamá32fadc02016-08-08 07:15:02 -07001890//%/**
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 Lenten30650d82015-05-01 08:57:16 -04001896//%- (void)insertValue:(TYPE)value atIndex:(NSUInteger)index;
1897//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07001898//%/**
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 Lenten30650d82015-05-01 08:57:16 -04001904//%- (void)replaceValueAtIndex:(NSUInteger)index withValue:(TYPE)value;
1905//%ARRAY_EXTRA_MUTABLE_METHODS2_##HELPER_NAME(NAME, TYPE)
Sergio Campamá32fadc02016-08-08 07:15:02 -07001906//%/**
1907//% * Removes the value at the given index.
1908//% *
1909//% * @param index The index of the value to remove.
1910//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001911//%- (void)removeValueAtIndex:(NSUInteger)index;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001912//%
1913//%/**
1914//% * Removes all the values from this array.
1915//% **/
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001916//%- (void)removeAll;
1917//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07001918//%/**
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 Lenten30650d82015-05-01 08:57:16 -04001924//%- (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á32fadc02016-08-08 07:15:02 -07001932//%/**
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 Lenten30650d82015-05-01 08:57:16 -04001937//%- (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á32fadc02016-08-08 07:15:02 -07001948//%/**
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 Lenten30650d82015-05-01 08:57:16 -04001956//%- (void)addRawValue:(TYPE)value;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001957//%
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 Lenten30650d82015-05-01 08:57:16 -04001966//%- (void)addRawValuesFromArray:(GPB##NAME##Array *)array;
Sergio Campamá32fadc02016-08-08 07:15:02 -07001967//%
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 Campama3d7b42d2017-01-25 11:51:54 -05001977//%- (void)addRawValues:(const TYPE [__nullable])values count:(NSUInteger)count;
Thomas Van Lenten30650d82015-05-01 08:57:16 -04001978//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07001979//%/**
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 Lenten30650d82015-05-01 08:57:16 -04001988//%- (void)insertRawValue:(TYPE)value atIndex:(NSUInteger)index;
1989//%
Sergio Campamá32fadc02016-08-08 07:15:02 -07001990//%/**
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 Lenten30650d82015-05-01 08:57:16 -04001999//%- (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(TYPE)value;
2000//%
2001//%// No validation applies to these methods.
2002//%
Thomas Van Lenten9e069b22022-09-19 13:34:01 -04002003
2004// clang-format on