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