GPBArray.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2015 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. #import <Foundation/Foundation.h>
  31. #import "GPBRuntimeTypes.h"
  32. // These classes are used for repeated fields of basic data types. They are used because
  33. // they perform better than boxing into NSNumbers in NSArrays.
  34. // Note: These are not meant to be subclassed.
  35. NS_ASSUME_NONNULL_BEGIN
  36. //%PDDM-EXPAND DECLARE_ARRAYS()
  37. // This block of code is generated, do not edit it directly.
  38. #pragma mark - Int32
  39. @interface GPBInt32Array : NSObject <NSCopying>
  40. @property(nonatomic, readonly) NSUInteger count;
  41. + (instancetype)array;
  42. + (instancetype)arrayWithValue:(int32_t)value;
  43. + (instancetype)arrayWithValueArray:(GPBInt32Array *)array;
  44. + (instancetype)arrayWithCapacity:(NSUInteger)count;
  45. - (instancetype)init NS_DESIGNATED_INITIALIZER;
  46. // Initializes the array, copying the values.
  47. - (instancetype)initWithValues:(const int32_t [])values
  48. count:(NSUInteger)count;
  49. - (instancetype)initWithValueArray:(GPBInt32Array *)array;
  50. - (instancetype)initWithCapacity:(NSUInteger)count;
  51. - (int32_t)valueAtIndex:(NSUInteger)index;
  52. - (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
  53. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  54. usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
  55. - (void)addValue:(int32_t)value;
  56. - (void)addValues:(const int32_t [])values count:(NSUInteger)count;
  57. - (void)addValuesFromArray:(GPBInt32Array *)array;
  58. - (void)insertValue:(int32_t)value atIndex:(NSUInteger)index;
  59. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value;
  60. - (void)removeValueAtIndex:(NSUInteger)index;
  61. - (void)removeAll;
  62. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  63. withValueAtIndex:(NSUInteger)idx2;
  64. @end
  65. #pragma mark - UInt32
  66. @interface GPBUInt32Array : NSObject <NSCopying>
  67. @property(nonatomic, readonly) NSUInteger count;
  68. + (instancetype)array;
  69. + (instancetype)arrayWithValue:(uint32_t)value;
  70. + (instancetype)arrayWithValueArray:(GPBUInt32Array *)array;
  71. + (instancetype)arrayWithCapacity:(NSUInteger)count;
  72. - (instancetype)init NS_DESIGNATED_INITIALIZER;
  73. // Initializes the array, copying the values.
  74. - (instancetype)initWithValues:(const uint32_t [])values
  75. count:(NSUInteger)count;
  76. - (instancetype)initWithValueArray:(GPBUInt32Array *)array;
  77. - (instancetype)initWithCapacity:(NSUInteger)count;
  78. - (uint32_t)valueAtIndex:(NSUInteger)index;
  79. - (void)enumerateValuesWithBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block;
  80. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  81. usingBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block;
  82. - (void)addValue:(uint32_t)value;
  83. - (void)addValues:(const uint32_t [])values count:(NSUInteger)count;
  84. - (void)addValuesFromArray:(GPBUInt32Array *)array;
  85. - (void)insertValue:(uint32_t)value atIndex:(NSUInteger)index;
  86. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint32_t)value;
  87. - (void)removeValueAtIndex:(NSUInteger)index;
  88. - (void)removeAll;
  89. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  90. withValueAtIndex:(NSUInteger)idx2;
  91. @end
  92. #pragma mark - Int64
  93. @interface GPBInt64Array : NSObject <NSCopying>
  94. @property(nonatomic, readonly) NSUInteger count;
  95. + (instancetype)array;
  96. + (instancetype)arrayWithValue:(int64_t)value;
  97. + (instancetype)arrayWithValueArray:(GPBInt64Array *)array;
  98. + (instancetype)arrayWithCapacity:(NSUInteger)count;
  99. - (instancetype)init NS_DESIGNATED_INITIALIZER;
  100. // Initializes the array, copying the values.
  101. - (instancetype)initWithValues:(const int64_t [])values
  102. count:(NSUInteger)count;
  103. - (instancetype)initWithValueArray:(GPBInt64Array *)array;
  104. - (instancetype)initWithCapacity:(NSUInteger)count;
  105. - (int64_t)valueAtIndex:(NSUInteger)index;
  106. - (void)enumerateValuesWithBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block;
  107. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  108. usingBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block;
  109. - (void)addValue:(int64_t)value;
  110. - (void)addValues:(const int64_t [])values count:(NSUInteger)count;
  111. - (void)addValuesFromArray:(GPBInt64Array *)array;
  112. - (void)insertValue:(int64_t)value atIndex:(NSUInteger)index;
  113. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int64_t)value;
  114. - (void)removeValueAtIndex:(NSUInteger)index;
  115. - (void)removeAll;
  116. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  117. withValueAtIndex:(NSUInteger)idx2;
  118. @end
  119. #pragma mark - UInt64
  120. @interface GPBUInt64Array : NSObject <NSCopying>
  121. @property(nonatomic, readonly) NSUInteger count;
  122. + (instancetype)array;
  123. + (instancetype)arrayWithValue:(uint64_t)value;
  124. + (instancetype)arrayWithValueArray:(GPBUInt64Array *)array;
  125. + (instancetype)arrayWithCapacity:(NSUInteger)count;
  126. - (instancetype)init NS_DESIGNATED_INITIALIZER;
  127. // Initializes the array, copying the values.
  128. - (instancetype)initWithValues:(const uint64_t [])values
  129. count:(NSUInteger)count;
  130. - (instancetype)initWithValueArray:(GPBUInt64Array *)array;
  131. - (instancetype)initWithCapacity:(NSUInteger)count;
  132. - (uint64_t)valueAtIndex:(NSUInteger)index;
  133. - (void)enumerateValuesWithBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block;
  134. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  135. usingBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block;
  136. - (void)addValue:(uint64_t)value;
  137. - (void)addValues:(const uint64_t [])values count:(NSUInteger)count;
  138. - (void)addValuesFromArray:(GPBUInt64Array *)array;
  139. - (void)insertValue:(uint64_t)value atIndex:(NSUInteger)index;
  140. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint64_t)value;
  141. - (void)removeValueAtIndex:(NSUInteger)index;
  142. - (void)removeAll;
  143. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  144. withValueAtIndex:(NSUInteger)idx2;
  145. @end
  146. #pragma mark - Float
  147. @interface GPBFloatArray : NSObject <NSCopying>
  148. @property(nonatomic, readonly) NSUInteger count;
  149. + (instancetype)array;
  150. + (instancetype)arrayWithValue:(float)value;
  151. + (instancetype)arrayWithValueArray:(GPBFloatArray *)array;
  152. + (instancetype)arrayWithCapacity:(NSUInteger)count;
  153. - (instancetype)init NS_DESIGNATED_INITIALIZER;
  154. // Initializes the array, copying the values.
  155. - (instancetype)initWithValues:(const float [])values
  156. count:(NSUInteger)count;
  157. - (instancetype)initWithValueArray:(GPBFloatArray *)array;
  158. - (instancetype)initWithCapacity:(NSUInteger)count;
  159. - (float)valueAtIndex:(NSUInteger)index;
  160. - (void)enumerateValuesWithBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block;
  161. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  162. usingBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block;
  163. - (void)addValue:(float)value;
  164. - (void)addValues:(const float [])values count:(NSUInteger)count;
  165. - (void)addValuesFromArray:(GPBFloatArray *)array;
  166. - (void)insertValue:(float)value atIndex:(NSUInteger)index;
  167. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(float)value;
  168. - (void)removeValueAtIndex:(NSUInteger)index;
  169. - (void)removeAll;
  170. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  171. withValueAtIndex:(NSUInteger)idx2;
  172. @end
  173. #pragma mark - Double
  174. @interface GPBDoubleArray : NSObject <NSCopying>
  175. @property(nonatomic, readonly) NSUInteger count;
  176. + (instancetype)array;
  177. + (instancetype)arrayWithValue:(double)value;
  178. + (instancetype)arrayWithValueArray:(GPBDoubleArray *)array;
  179. + (instancetype)arrayWithCapacity:(NSUInteger)count;
  180. - (instancetype)init NS_DESIGNATED_INITIALIZER;
  181. // Initializes the array, copying the values.
  182. - (instancetype)initWithValues:(const double [])values
  183. count:(NSUInteger)count;
  184. - (instancetype)initWithValueArray:(GPBDoubleArray *)array;
  185. - (instancetype)initWithCapacity:(NSUInteger)count;
  186. - (double)valueAtIndex:(NSUInteger)index;
  187. - (void)enumerateValuesWithBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block;
  188. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  189. usingBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block;
  190. - (void)addValue:(double)value;
  191. - (void)addValues:(const double [])values count:(NSUInteger)count;
  192. - (void)addValuesFromArray:(GPBDoubleArray *)array;
  193. - (void)insertValue:(double)value atIndex:(NSUInteger)index;
  194. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(double)value;
  195. - (void)removeValueAtIndex:(NSUInteger)index;
  196. - (void)removeAll;
  197. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  198. withValueAtIndex:(NSUInteger)idx2;
  199. @end
  200. #pragma mark - Bool
  201. @interface GPBBoolArray : NSObject <NSCopying>
  202. @property(nonatomic, readonly) NSUInteger count;
  203. + (instancetype)array;
  204. + (instancetype)arrayWithValue:(BOOL)value;
  205. + (instancetype)arrayWithValueArray:(GPBBoolArray *)array;
  206. + (instancetype)arrayWithCapacity:(NSUInteger)count;
  207. - (instancetype)init NS_DESIGNATED_INITIALIZER;
  208. // Initializes the array, copying the values.
  209. - (instancetype)initWithValues:(const BOOL [])values
  210. count:(NSUInteger)count;
  211. - (instancetype)initWithValueArray:(GPBBoolArray *)array;
  212. - (instancetype)initWithCapacity:(NSUInteger)count;
  213. - (BOOL)valueAtIndex:(NSUInteger)index;
  214. - (void)enumerateValuesWithBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block;
  215. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  216. usingBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block;
  217. - (void)addValue:(BOOL)value;
  218. - (void)addValues:(const BOOL [])values count:(NSUInteger)count;
  219. - (void)addValuesFromArray:(GPBBoolArray *)array;
  220. - (void)insertValue:(BOOL)value atIndex:(NSUInteger)index;
  221. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(BOOL)value;
  222. - (void)removeValueAtIndex:(NSUInteger)index;
  223. - (void)removeAll;
  224. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  225. withValueAtIndex:(NSUInteger)idx2;
  226. @end
  227. #pragma mark - Enum
  228. @interface GPBEnumArray : NSObject <NSCopying>
  229. @property(nonatomic, readonly) NSUInteger count;
  230. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  231. + (instancetype)array;
  232. + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  233. + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
  234. rawValue:(int32_t)value;
  235. + (instancetype)arrayWithValueArray:(GPBEnumArray *)array;
  236. + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
  237. capacity:(NSUInteger)count;
  238. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  239. NS_DESIGNATED_INITIALIZER;
  240. // Initializes the array, copying the values.
  241. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  242. rawValues:(const int32_t [])values
  243. count:(NSUInteger)count;
  244. - (instancetype)initWithValueArray:(GPBEnumArray *)array;
  245. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  246. capacity:(NSUInteger)count;
  247. // These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a
  248. // valid enumerator as defined by validationFunc. If the actual value is
  249. // desired, use "raw" version of the method.
  250. - (int32_t)valueAtIndex:(NSUInteger)index;
  251. - (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
  252. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  253. usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
  254. // These methods bypass the validationFunc to provide access to values that were not
  255. // known at the time the binary was compiled.
  256. - (int32_t)rawValueAtIndex:(NSUInteger)index;
  257. - (void)enumerateRawValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
  258. - (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
  259. usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
  260. // If value is not a valid enumerator as defined by validationFunc, these
  261. // methods will assert in debug, and will log in release and assign the value
  262. // to the default value. Use the rawValue methods below to assign non enumerator
  263. // values.
  264. - (void)addValue:(int32_t)value;
  265. - (void)addValues:(const int32_t [])values count:(NSUInteger)count;
  266. - (void)insertValue:(int32_t)value atIndex:(NSUInteger)index;
  267. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value;
  268. // These methods bypass the validationFunc to provide setting of values that were not
  269. // known at the time the binary was compiled.
  270. - (void)addRawValue:(int32_t)value;
  271. - (void)addRawValuesFromArray:(GPBEnumArray *)array;
  272. - (void)addRawValues:(const int32_t [])values count:(NSUInteger)count;
  273. - (void)insertRawValue:(int32_t)value atIndex:(NSUInteger)index;
  274. - (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(int32_t)value;
  275. // No validation applies to these methods.
  276. - (void)removeValueAtIndex:(NSUInteger)index;
  277. - (void)removeAll;
  278. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  279. withValueAtIndex:(NSUInteger)idx2;
  280. @end
  281. //%PDDM-EXPAND-END DECLARE_ARRAYS()
  282. NS_ASSUME_NONNULL_END
  283. //%PDDM-DEFINE DECLARE_ARRAYS()
  284. //%ARRAY_INTERFACE_SIMPLE(Int32, int32_t)
  285. //%ARRAY_INTERFACE_SIMPLE(UInt32, uint32_t)
  286. //%ARRAY_INTERFACE_SIMPLE(Int64, int64_t)
  287. //%ARRAY_INTERFACE_SIMPLE(UInt64, uint64_t)
  288. //%ARRAY_INTERFACE_SIMPLE(Float, float)
  289. //%ARRAY_INTERFACE_SIMPLE(Double, double)
  290. //%ARRAY_INTERFACE_SIMPLE(Bool, BOOL)
  291. //%ARRAY_INTERFACE_ENUM(Enum, int32_t)
  292. //
  293. // The common case (everything but Enum)
  294. //
  295. //%PDDM-DEFINE ARRAY_INTERFACE_SIMPLE(NAME, TYPE)
  296. //%#pragma mark - NAME
  297. //%
  298. //%@interface GPB##NAME##Array : NSObject <NSCopying>
  299. //%
  300. //%@property(nonatomic, readonly) NSUInteger count;
  301. //%
  302. //%+ (instancetype)array;
  303. //%+ (instancetype)arrayWithValue:(TYPE)value;
  304. //%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array;
  305. //%+ (instancetype)arrayWithCapacity:(NSUInteger)count;
  306. //%
  307. //%- (instancetype)init NS_DESIGNATED_INITIALIZER;
  308. //%// Initializes the array, copying the values.
  309. //%- (instancetype)initWithValues:(const TYPE [])values
  310. //% count:(NSUInteger)count;
  311. //%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array;
  312. //%- (instancetype)initWithCapacity:(NSUInteger)count;
  313. //%
  314. //%ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, Basic)
  315. //%
  316. //%ARRAY_MUTABLE_INTERFACE(NAME, TYPE, Basic)
  317. //%
  318. //%@end
  319. //%
  320. //
  321. // Macros specific to Enums (to tweak their interface).
  322. //
  323. //%PDDM-DEFINE ARRAY_INTERFACE_ENUM(NAME, TYPE)
  324. //%#pragma mark - NAME
  325. //%
  326. //%@interface GPB##NAME##Array : NSObject <NSCopying>
  327. //%
  328. //%@property(nonatomic, readonly) NSUInteger count;
  329. //%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  330. //%
  331. //%+ (instancetype)array;
  332. //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  333. //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
  334. //% rawValue:(TYPE)value;
  335. //%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array;
  336. //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
  337. //% capacity:(NSUInteger)count;
  338. //%
  339. //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  340. //% NS_DESIGNATED_INITIALIZER;
  341. //%
  342. //%// Initializes the array, copying the values.
  343. //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  344. //% rawValues:(const TYPE [])values
  345. //% count:(NSUInteger)count;
  346. //%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array;
  347. //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  348. //% capacity:(NSUInteger)count;
  349. //%
  350. //%// These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a
  351. //%// valid enumerator as defined by validationFunc. If the actual value is
  352. //%// desired, use "raw" version of the method.
  353. //%
  354. //%ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, NAME)
  355. //%
  356. //%// These methods bypass the validationFunc to provide access to values that were not
  357. //%// known at the time the binary was compiled.
  358. //%
  359. //%- (TYPE)rawValueAtIndex:(NSUInteger)index;
  360. //%
  361. //%- (void)enumerateRawValuesWithBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
  362. //%- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
  363. //% usingBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
  364. //%
  365. //%// If value is not a valid enumerator as defined by validationFunc, these
  366. //%// methods will assert in debug, and will log in release and assign the value
  367. //%// to the default value. Use the rawValue methods below to assign non enumerator
  368. //%// values.
  369. //%
  370. //%ARRAY_MUTABLE_INTERFACE(NAME, TYPE, NAME)
  371. //%
  372. //%@end
  373. //%
  374. //%PDDM-DEFINE ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME)
  375. //%- (TYPE)valueAtIndex:(NSUInteger)index;
  376. //%
  377. //%- (void)enumerateValuesWithBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
  378. //%- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  379. //% usingBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
  380. //%PDDM-DEFINE ARRAY_MUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME)
  381. //%- (void)addValue:(TYPE)value;
  382. //%- (void)addValues:(const TYPE [])values count:(NSUInteger)count;
  383. //%ARRAY_EXTRA_MUTABLE_METHODS1_##HELPER_NAME(NAME, TYPE)
  384. //%- (void)insertValue:(TYPE)value atIndex:(NSUInteger)index;
  385. //%
  386. //%- (void)replaceValueAtIndex:(NSUInteger)index withValue:(TYPE)value;
  387. //%ARRAY_EXTRA_MUTABLE_METHODS2_##HELPER_NAME(NAME, TYPE)
  388. //%- (void)removeValueAtIndex:(NSUInteger)index;
  389. //%- (void)removeAll;
  390. //%
  391. //%- (void)exchangeValueAtIndex:(NSUInteger)idx1
  392. //% withValueAtIndex:(NSUInteger)idx2;
  393. //
  394. // These are hooks invoked by the above to do insert as needed.
  395. //
  396. //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS1_Basic(NAME, TYPE)
  397. //%- (void)addValuesFromArray:(GPB##NAME##Array *)array;
  398. //%
  399. //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS2_Basic(NAME, TYPE)
  400. // Empty
  401. //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS1_Enum(NAME, TYPE)
  402. // Empty
  403. //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS2_Enum(NAME, TYPE)
  404. //%
  405. //%// These methods bypass the validationFunc to provide setting of values that were not
  406. //%// known at the time the binary was compiled.
  407. //%
  408. //%- (void)addRawValue:(TYPE)value;
  409. //%- (void)addRawValuesFromArray:(GPB##NAME##Array *)array;
  410. //%- (void)addRawValues:(const TYPE [])values count:(NSUInteger)count;
  411. //%
  412. //%- (void)insertRawValue:(TYPE)value atIndex:(NSUInteger)index;
  413. //%
  414. //%- (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(TYPE)value;
  415. //%
  416. //%// No validation applies to these methods.
  417. //%