GPBArray.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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. // Initializes the array, copying the values.
  46. - (instancetype)initWithValues:(const int32_t [])values
  47. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  48. - (instancetype)initWithValueArray:(GPBInt32Array *)array;
  49. - (instancetype)initWithCapacity:(NSUInteger)count;
  50. - (int32_t)valueAtIndex:(NSUInteger)index;
  51. - (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
  52. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  53. usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
  54. - (void)addValue:(int32_t)value;
  55. - (void)addValues:(const int32_t [])values count:(NSUInteger)count;
  56. - (void)addValuesFromArray:(GPBInt32Array *)array;
  57. - (void)insertValue:(int32_t)value atIndex:(NSUInteger)index;
  58. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value;
  59. - (void)removeValueAtIndex:(NSUInteger)index;
  60. - (void)removeAll;
  61. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  62. withValueAtIndex:(NSUInteger)idx2;
  63. @end
  64. #pragma mark - UInt32
  65. @interface GPBUInt32Array : NSObject <NSCopying>
  66. @property(nonatomic, readonly) NSUInteger count;
  67. + (instancetype)array;
  68. + (instancetype)arrayWithValue:(uint32_t)value;
  69. + (instancetype)arrayWithValueArray:(GPBUInt32Array *)array;
  70. + (instancetype)arrayWithCapacity:(NSUInteger)count;
  71. // Initializes the array, copying the values.
  72. - (instancetype)initWithValues:(const uint32_t [])values
  73. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  74. - (instancetype)initWithValueArray:(GPBUInt32Array *)array;
  75. - (instancetype)initWithCapacity:(NSUInteger)count;
  76. - (uint32_t)valueAtIndex:(NSUInteger)index;
  77. - (void)enumerateValuesWithBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block;
  78. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  79. usingBlock:(void (^)(uint32_t value, NSUInteger idx, BOOL *stop))block;
  80. - (void)addValue:(uint32_t)value;
  81. - (void)addValues:(const uint32_t [])values count:(NSUInteger)count;
  82. - (void)addValuesFromArray:(GPBUInt32Array *)array;
  83. - (void)insertValue:(uint32_t)value atIndex:(NSUInteger)index;
  84. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint32_t)value;
  85. - (void)removeValueAtIndex:(NSUInteger)index;
  86. - (void)removeAll;
  87. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  88. withValueAtIndex:(NSUInteger)idx2;
  89. @end
  90. #pragma mark - Int64
  91. @interface GPBInt64Array : NSObject <NSCopying>
  92. @property(nonatomic, readonly) NSUInteger count;
  93. + (instancetype)array;
  94. + (instancetype)arrayWithValue:(int64_t)value;
  95. + (instancetype)arrayWithValueArray:(GPBInt64Array *)array;
  96. + (instancetype)arrayWithCapacity:(NSUInteger)count;
  97. // Initializes the array, copying the values.
  98. - (instancetype)initWithValues:(const int64_t [])values
  99. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  100. - (instancetype)initWithValueArray:(GPBInt64Array *)array;
  101. - (instancetype)initWithCapacity:(NSUInteger)count;
  102. - (int64_t)valueAtIndex:(NSUInteger)index;
  103. - (void)enumerateValuesWithBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block;
  104. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  105. usingBlock:(void (^)(int64_t value, NSUInteger idx, BOOL *stop))block;
  106. - (void)addValue:(int64_t)value;
  107. - (void)addValues:(const int64_t [])values count:(NSUInteger)count;
  108. - (void)addValuesFromArray:(GPBInt64Array *)array;
  109. - (void)insertValue:(int64_t)value atIndex:(NSUInteger)index;
  110. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int64_t)value;
  111. - (void)removeValueAtIndex:(NSUInteger)index;
  112. - (void)removeAll;
  113. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  114. withValueAtIndex:(NSUInteger)idx2;
  115. @end
  116. #pragma mark - UInt64
  117. @interface GPBUInt64Array : NSObject <NSCopying>
  118. @property(nonatomic, readonly) NSUInteger count;
  119. + (instancetype)array;
  120. + (instancetype)arrayWithValue:(uint64_t)value;
  121. + (instancetype)arrayWithValueArray:(GPBUInt64Array *)array;
  122. + (instancetype)arrayWithCapacity:(NSUInteger)count;
  123. // Initializes the array, copying the values.
  124. - (instancetype)initWithValues:(const uint64_t [])values
  125. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  126. - (instancetype)initWithValueArray:(GPBUInt64Array *)array;
  127. - (instancetype)initWithCapacity:(NSUInteger)count;
  128. - (uint64_t)valueAtIndex:(NSUInteger)index;
  129. - (void)enumerateValuesWithBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block;
  130. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  131. usingBlock:(void (^)(uint64_t value, NSUInteger idx, BOOL *stop))block;
  132. - (void)addValue:(uint64_t)value;
  133. - (void)addValues:(const uint64_t [])values count:(NSUInteger)count;
  134. - (void)addValuesFromArray:(GPBUInt64Array *)array;
  135. - (void)insertValue:(uint64_t)value atIndex:(NSUInteger)index;
  136. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint64_t)value;
  137. - (void)removeValueAtIndex:(NSUInteger)index;
  138. - (void)removeAll;
  139. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  140. withValueAtIndex:(NSUInteger)idx2;
  141. @end
  142. #pragma mark - Float
  143. @interface GPBFloatArray : NSObject <NSCopying>
  144. @property(nonatomic, readonly) NSUInteger count;
  145. + (instancetype)array;
  146. + (instancetype)arrayWithValue:(float)value;
  147. + (instancetype)arrayWithValueArray:(GPBFloatArray *)array;
  148. + (instancetype)arrayWithCapacity:(NSUInteger)count;
  149. // Initializes the array, copying the values.
  150. - (instancetype)initWithValues:(const float [])values
  151. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  152. - (instancetype)initWithValueArray:(GPBFloatArray *)array;
  153. - (instancetype)initWithCapacity:(NSUInteger)count;
  154. - (float)valueAtIndex:(NSUInteger)index;
  155. - (void)enumerateValuesWithBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block;
  156. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  157. usingBlock:(void (^)(float value, NSUInteger idx, BOOL *stop))block;
  158. - (void)addValue:(float)value;
  159. - (void)addValues:(const float [])values count:(NSUInteger)count;
  160. - (void)addValuesFromArray:(GPBFloatArray *)array;
  161. - (void)insertValue:(float)value atIndex:(NSUInteger)index;
  162. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(float)value;
  163. - (void)removeValueAtIndex:(NSUInteger)index;
  164. - (void)removeAll;
  165. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  166. withValueAtIndex:(NSUInteger)idx2;
  167. @end
  168. #pragma mark - Double
  169. @interface GPBDoubleArray : NSObject <NSCopying>
  170. @property(nonatomic, readonly) NSUInteger count;
  171. + (instancetype)array;
  172. + (instancetype)arrayWithValue:(double)value;
  173. + (instancetype)arrayWithValueArray:(GPBDoubleArray *)array;
  174. + (instancetype)arrayWithCapacity:(NSUInteger)count;
  175. // Initializes the array, copying the values.
  176. - (instancetype)initWithValues:(const double [])values
  177. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  178. - (instancetype)initWithValueArray:(GPBDoubleArray *)array;
  179. - (instancetype)initWithCapacity:(NSUInteger)count;
  180. - (double)valueAtIndex:(NSUInteger)index;
  181. - (void)enumerateValuesWithBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block;
  182. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  183. usingBlock:(void (^)(double value, NSUInteger idx, BOOL *stop))block;
  184. - (void)addValue:(double)value;
  185. - (void)addValues:(const double [])values count:(NSUInteger)count;
  186. - (void)addValuesFromArray:(GPBDoubleArray *)array;
  187. - (void)insertValue:(double)value atIndex:(NSUInteger)index;
  188. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(double)value;
  189. - (void)removeValueAtIndex:(NSUInteger)index;
  190. - (void)removeAll;
  191. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  192. withValueAtIndex:(NSUInteger)idx2;
  193. @end
  194. #pragma mark - Bool
  195. @interface GPBBoolArray : NSObject <NSCopying>
  196. @property(nonatomic, readonly) NSUInteger count;
  197. + (instancetype)array;
  198. + (instancetype)arrayWithValue:(BOOL)value;
  199. + (instancetype)arrayWithValueArray:(GPBBoolArray *)array;
  200. + (instancetype)arrayWithCapacity:(NSUInteger)count;
  201. // Initializes the array, copying the values.
  202. - (instancetype)initWithValues:(const BOOL [])values
  203. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  204. - (instancetype)initWithValueArray:(GPBBoolArray *)array;
  205. - (instancetype)initWithCapacity:(NSUInteger)count;
  206. - (BOOL)valueAtIndex:(NSUInteger)index;
  207. - (void)enumerateValuesWithBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block;
  208. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  209. usingBlock:(void (^)(BOOL value, NSUInteger idx, BOOL *stop))block;
  210. - (void)addValue:(BOOL)value;
  211. - (void)addValues:(const BOOL [])values count:(NSUInteger)count;
  212. - (void)addValuesFromArray:(GPBBoolArray *)array;
  213. - (void)insertValue:(BOOL)value atIndex:(NSUInteger)index;
  214. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(BOOL)value;
  215. - (void)removeValueAtIndex:(NSUInteger)index;
  216. - (void)removeAll;
  217. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  218. withValueAtIndex:(NSUInteger)idx2;
  219. @end
  220. #pragma mark - Enum
  221. @interface GPBEnumArray : NSObject <NSCopying>
  222. @property(nonatomic, readonly) NSUInteger count;
  223. @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  224. + (instancetype)array;
  225. + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  226. + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
  227. rawValue:(int32_t)value;
  228. + (instancetype)arrayWithValueArray:(GPBEnumArray *)array;
  229. + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
  230. capacity:(NSUInteger)count;
  231. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  232. // Initializes the array, copying the values.
  233. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  234. rawValues:(const int32_t [])values
  235. count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  236. - (instancetype)initWithValueArray:(GPBEnumArray *)array;
  237. - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  238. capacity:(NSUInteger)count;
  239. // These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a
  240. // valid enumerator as defined by validationFunc. If the actual value is
  241. // desired, use "raw" version of the method.
  242. - (int32_t)valueAtIndex:(NSUInteger)index;
  243. - (void)enumerateValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
  244. - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  245. usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
  246. // These methods bypass the validationFunc to provide access to values that were not
  247. // known at the time the binary was compiled.
  248. - (int32_t)rawValueAtIndex:(NSUInteger)index;
  249. - (void)enumerateRawValuesWithBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
  250. - (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
  251. usingBlock:(void (^)(int32_t value, NSUInteger idx, BOOL *stop))block;
  252. // If value is not a valid enumerator as defined by validationFunc, these
  253. // methods will assert in debug, and will log in release and assign the value
  254. // to the default value. Use the rawValue methods below to assign non enumerator
  255. // values.
  256. - (void)addValue:(int32_t)value;
  257. - (void)addValues:(const int32_t [])values count:(NSUInteger)count;
  258. - (void)insertValue:(int32_t)value atIndex:(NSUInteger)index;
  259. - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value;
  260. // These methods bypass the validationFunc to provide setting of values that were not
  261. // known at the time the binary was compiled.
  262. - (void)addRawValue:(int32_t)value;
  263. - (void)addRawValuesFromArray:(GPBEnumArray *)array;
  264. - (void)addRawValues:(const int32_t [])values count:(NSUInteger)count;
  265. - (void)insertRawValue:(int32_t)value atIndex:(NSUInteger)index;
  266. - (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(int32_t)value;
  267. // No validation applies to these methods.
  268. - (void)removeValueAtIndex:(NSUInteger)index;
  269. - (void)removeAll;
  270. - (void)exchangeValueAtIndex:(NSUInteger)idx1
  271. withValueAtIndex:(NSUInteger)idx2;
  272. @end
  273. //%PDDM-EXPAND-END DECLARE_ARRAYS()
  274. NS_ASSUME_NONNULL_END
  275. //%PDDM-DEFINE DECLARE_ARRAYS()
  276. //%ARRAY_INTERFACE_SIMPLE(Int32, int32_t)
  277. //%ARRAY_INTERFACE_SIMPLE(UInt32, uint32_t)
  278. //%ARRAY_INTERFACE_SIMPLE(Int64, int64_t)
  279. //%ARRAY_INTERFACE_SIMPLE(UInt64, uint64_t)
  280. //%ARRAY_INTERFACE_SIMPLE(Float, float)
  281. //%ARRAY_INTERFACE_SIMPLE(Double, double)
  282. //%ARRAY_INTERFACE_SIMPLE(Bool, BOOL)
  283. //%ARRAY_INTERFACE_ENUM(Enum, int32_t)
  284. //
  285. // The common case (everything but Enum)
  286. //
  287. //%PDDM-DEFINE ARRAY_INTERFACE_SIMPLE(NAME, TYPE)
  288. //%#pragma mark - NAME
  289. //%
  290. //%@interface GPB##NAME##Array : NSObject <NSCopying>
  291. //%
  292. //%@property(nonatomic, readonly) NSUInteger count;
  293. //%
  294. //%+ (instancetype)array;
  295. //%+ (instancetype)arrayWithValue:(TYPE)value;
  296. //%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array;
  297. //%+ (instancetype)arrayWithCapacity:(NSUInteger)count;
  298. //%
  299. //%// Initializes the array, copying the values.
  300. //%- (instancetype)initWithValues:(const TYPE [])values
  301. //% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  302. //%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array;
  303. //%- (instancetype)initWithCapacity:(NSUInteger)count;
  304. //%
  305. //%ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, Basic)
  306. //%
  307. //%ARRAY_MUTABLE_INTERFACE(NAME, TYPE, Basic)
  308. //%
  309. //%@end
  310. //%
  311. //
  312. // Macros specific to Enums (to tweak their interface).
  313. //
  314. //%PDDM-DEFINE ARRAY_INTERFACE_ENUM(NAME, TYPE)
  315. //%#pragma mark - NAME
  316. //%
  317. //%@interface GPB##NAME##Array : NSObject <NSCopying>
  318. //%
  319. //%@property(nonatomic, readonly) NSUInteger count;
  320. //%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc;
  321. //%
  322. //%+ (instancetype)array;
  323. //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  324. //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
  325. //% rawValue:(TYPE)value;
  326. //%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array;
  327. //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func
  328. //% capacity:(NSUInteger)count;
  329. //%
  330. //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func;
  331. //%
  332. //%// Initializes the array, copying the values.
  333. //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  334. //% rawValues:(const TYPE [])values
  335. //% count:(NSUInteger)count NS_DESIGNATED_INITIALIZER;
  336. //%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array;
  337. //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func
  338. //% capacity:(NSUInteger)count;
  339. //%
  340. //%// These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a
  341. //%// valid enumerator as defined by validationFunc. If the actual value is
  342. //%// desired, use "raw" version of the method.
  343. //%
  344. //%ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, NAME)
  345. //%
  346. //%// These methods bypass the validationFunc to provide access to values that were not
  347. //%// known at the time the binary was compiled.
  348. //%
  349. //%- (TYPE)rawValueAtIndex:(NSUInteger)index;
  350. //%
  351. //%- (void)enumerateRawValuesWithBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
  352. //%- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts
  353. //% usingBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
  354. //%
  355. //%// If value is not a valid enumerator as defined by validationFunc, these
  356. //%// methods will assert in debug, and will log in release and assign the value
  357. //%// to the default value. Use the rawValue methods below to assign non enumerator
  358. //%// values.
  359. //%
  360. //%ARRAY_MUTABLE_INTERFACE(NAME, TYPE, NAME)
  361. //%
  362. //%@end
  363. //%
  364. //%PDDM-DEFINE ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME)
  365. //%- (TYPE)valueAtIndex:(NSUInteger)index;
  366. //%
  367. //%- (void)enumerateValuesWithBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
  368. //%- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts
  369. //% usingBlock:(void (^)(TYPE value, NSUInteger idx, BOOL *stop))block;
  370. //%PDDM-DEFINE ARRAY_MUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME)
  371. //%- (void)addValue:(TYPE)value;
  372. //%- (void)addValues:(const TYPE [])values count:(NSUInteger)count;
  373. //%ARRAY_EXTRA_MUTABLE_METHODS1_##HELPER_NAME(NAME, TYPE)
  374. //%- (void)insertValue:(TYPE)value atIndex:(NSUInteger)index;
  375. //%
  376. //%- (void)replaceValueAtIndex:(NSUInteger)index withValue:(TYPE)value;
  377. //%ARRAY_EXTRA_MUTABLE_METHODS2_##HELPER_NAME(NAME, TYPE)
  378. //%- (void)removeValueAtIndex:(NSUInteger)index;
  379. //%- (void)removeAll;
  380. //%
  381. //%- (void)exchangeValueAtIndex:(NSUInteger)idx1
  382. //% withValueAtIndex:(NSUInteger)idx2;
  383. //
  384. // These are hooks invoked by the above to do insert as needed.
  385. //
  386. //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS1_Basic(NAME, TYPE)
  387. //%- (void)addValuesFromArray:(GPB##NAME##Array *)array;
  388. //%
  389. //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS2_Basic(NAME, TYPE)
  390. // Empty
  391. //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS1_Enum(NAME, TYPE)
  392. // Empty
  393. //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS2_Enum(NAME, TYPE)
  394. //%
  395. //%// These methods bypass the validationFunc to provide setting of values that were not
  396. //%// known at the time the binary was compiled.
  397. //%
  398. //%- (void)addRawValue:(TYPE)value;
  399. //%- (void)addRawValuesFromArray:(GPB##NAME##Array *)array;
  400. //%- (void)addRawValues:(const TYPE [])values count:(NSUInteger)count;
  401. //%
  402. //%- (void)insertRawValue:(TYPE)value atIndex:(NSUInteger)index;
  403. //%
  404. //%- (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(TYPE)value;
  405. //%
  406. //%// No validation applies to these methods.
  407. //%