GPBArray.h 20 KB

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