GPBCodedOutputStream.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 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. #import <Foundation/Foundation.h>
  8. #import "GPBRuntimeTypes.h"
  9. #import "GPBWireFormat.h"
  10. #import "GPBArray.h"
  11. #import "GPBUnknownFieldSet.h"
  12. @class GPBUnknownFieldSet;
  13. NS_ASSUME_NONNULL_BEGIN
  14. /**
  15. * @c GPBCodedOutputStream exception names.
  16. **/
  17. extern NSString *const GPBCodedOutputStreamException_OutOfSpace;
  18. extern NSString *const GPBCodedOutputStreamException_WriteFailed;
  19. /**
  20. * Writes out protocol message fields.
  21. *
  22. * The common uses of protocol buffers shouldn't need to use this class.
  23. * GPBMessage's provide a -data method that will serialize the message for you.
  24. *
  25. * @note Any -write* api can raise the GPBCodedOutputStreamException_*
  26. * exceptions.
  27. *
  28. * @note Subclassing of GPBCodedOutputStream is NOT supported.
  29. **/
  30. __attribute__((objc_subclassing_restricted))
  31. @interface GPBCodedOutputStream : NSObject
  32. /**
  33. * Creates a stream to fill in the given data. Data must be sized to fit or
  34. * an error will be raised when out of space.
  35. *
  36. * @param data The data where the stream will be written to.
  37. *
  38. * @return A newly instanced GPBCodedOutputStream.
  39. **/
  40. + (instancetype)streamWithData:(NSMutableData *)data;
  41. /**
  42. * Creates a stream to write into the given NSOutputStream.
  43. *
  44. * @param output The output stream where the stream will be written to.
  45. *
  46. * @return A newly instanced GPBCodedOutputStream.
  47. **/
  48. + (instancetype)streamWithOutputStream:(NSOutputStream *)output;
  49. /**
  50. * Initializes a stream to fill in the given data. Data must be sized to fit
  51. * or an error will be raised when out of space.
  52. *
  53. * @param data The data where the stream will be written to.
  54. *
  55. * @return A newly initialized GPBCodedOutputStream.
  56. **/
  57. - (instancetype)initWithData:(NSMutableData *)data;
  58. /**
  59. * Initializes a stream to write into the given @c NSOutputStream.
  60. *
  61. * @param output The output stream where the stream will be written to.
  62. *
  63. * @return A newly initialized GPBCodedOutputStream.
  64. **/
  65. - (instancetype)initWithOutputStream:(NSOutputStream *)output;
  66. /**
  67. * Flush any buffered data out.
  68. **/
  69. - (void)flush;
  70. /**
  71. * @return The number of bytes written out. Includes bytes not yet flused.
  72. **/
  73. - (size_t)bytesWritten;
  74. /**
  75. * Write the raw byte out.
  76. *
  77. * @param value The value to write out.
  78. **/
  79. - (void)writeRawByte:(uint8_t)value;
  80. /**
  81. * Write the tag for the given field number and wire format.
  82. *
  83. * @param fieldNumber The field number.
  84. * @param format The wire format the data for the field will be in.
  85. **/
  86. - (void)writeTag:(uint32_t)fieldNumber format:(GPBWireFormat)format;
  87. /**
  88. * Write a 32bit value out in little endian format.
  89. *
  90. * @param value The value to write out.
  91. **/
  92. - (void)writeRawLittleEndian32:(int32_t)value;
  93. /**
  94. * Write a 64bit value out in little endian format.
  95. *
  96. * @param value The value to write out.
  97. **/
  98. - (void)writeRawLittleEndian64:(int64_t)value;
  99. /**
  100. * Write a 32bit value out in varint format.
  101. *
  102. * @param value The value to write out.
  103. **/
  104. - (void)writeRawVarint32:(int32_t)value;
  105. /**
  106. * Write a 64bit value out in varint format.
  107. *
  108. * @param value The value to write out.
  109. **/
  110. - (void)writeRawVarint64:(int64_t)value;
  111. /**
  112. * Write a size_t out as a 32bit varint value.
  113. *
  114. * @note This will truncate 64 bit values to 32.
  115. *
  116. * @param value The value to write out.
  117. **/
  118. - (void)writeRawVarintSizeTAs32:(size_t)value;
  119. /**
  120. * Writes the contents of an NSData out.
  121. *
  122. * @param data The data to write out.
  123. **/
  124. - (void)writeRawData:(NSData *)data;
  125. /**
  126. * Writes out the given data.
  127. *
  128. * @param data The data blob to write out.
  129. * @param offset The offset into the blob to start writing out.
  130. * @param length The number of bytes from the blob to write out.
  131. **/
  132. - (void)writeRawPtr:(const void *)data offset:(size_t)offset length:(size_t)length;
  133. // Disable clang-format for the macros.
  134. // clang-format off
  135. //%PDDM-EXPAND _WRITE_DECLS()
  136. // This block of code is generated, do not edit it directly.
  137. /**
  138. * Write a double for the given field number.
  139. *
  140. * @param fieldNumber The field number assigned to the value.
  141. * @param value The value to write out.
  142. **/
  143. - (void)writeDouble:(int32_t)fieldNumber value:(double)value;
  144. /**
  145. * Write a packed array of double for the given field number.
  146. *
  147. * @param fieldNumber The field number assigned to the values.
  148. * @param values The values to write out.
  149. * @param tag The tag assigned to the values.
  150. **/
  151. - (void)writeDoubleArray:(int32_t)fieldNumber
  152. values:(GPBDoubleArray *)values
  153. tag:(uint32_t)tag;
  154. /**
  155. * Write a double without any tag.
  156. *
  157. * @param value The value to write out.
  158. **/
  159. - (void)writeDoubleNoTag:(double)value;
  160. /**
  161. * Write a float for the given field number.
  162. *
  163. * @param fieldNumber The field number assigned to the value.
  164. * @param value The value to write out.
  165. **/
  166. - (void)writeFloat:(int32_t)fieldNumber value:(float)value;
  167. /**
  168. * Write a packed array of float for the given field number.
  169. *
  170. * @param fieldNumber The field number assigned to the values.
  171. * @param values The values to write out.
  172. * @param tag The tag assigned to the values.
  173. **/
  174. - (void)writeFloatArray:(int32_t)fieldNumber
  175. values:(GPBFloatArray *)values
  176. tag:(uint32_t)tag;
  177. /**
  178. * Write a float without any tag.
  179. *
  180. * @param value The value to write out.
  181. **/
  182. - (void)writeFloatNoTag:(float)value;
  183. /**
  184. * Write a uint64_t for the given field number.
  185. *
  186. * @param fieldNumber The field number assigned to the value.
  187. * @param value The value to write out.
  188. **/
  189. - (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value;
  190. /**
  191. * Write a packed array of uint64_t for the given field number.
  192. *
  193. * @param fieldNumber The field number assigned to the values.
  194. * @param values The values to write out.
  195. * @param tag The tag assigned to the values.
  196. **/
  197. - (void)writeUInt64Array:(int32_t)fieldNumber
  198. values:(GPBUInt64Array *)values
  199. tag:(uint32_t)tag;
  200. /**
  201. * Write a uint64_t without any tag.
  202. *
  203. * @param value The value to write out.
  204. **/
  205. - (void)writeUInt64NoTag:(uint64_t)value;
  206. /**
  207. * Write a int64_t for the given field number.
  208. *
  209. * @param fieldNumber The field number assigned to the value.
  210. * @param value The value to write out.
  211. **/
  212. - (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value;
  213. /**
  214. * Write a packed array of int64_t for the given field number.
  215. *
  216. * @param fieldNumber The field number assigned to the values.
  217. * @param values The values to write out.
  218. * @param tag The tag assigned to the values.
  219. **/
  220. - (void)writeInt64Array:(int32_t)fieldNumber
  221. values:(GPBInt64Array *)values
  222. tag:(uint32_t)tag;
  223. /**
  224. * Write a int64_t without any tag.
  225. *
  226. * @param value The value to write out.
  227. **/
  228. - (void)writeInt64NoTag:(int64_t)value;
  229. /**
  230. * Write a int32_t for the given field number.
  231. *
  232. * @param fieldNumber The field number assigned to the value.
  233. * @param value The value to write out.
  234. **/
  235. - (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value;
  236. /**
  237. * Write a packed array of int32_t for the given field number.
  238. *
  239. * @param fieldNumber The field number assigned to the values.
  240. * @param values The values to write out.
  241. * @param tag The tag assigned to the values.
  242. **/
  243. - (void)writeInt32Array:(int32_t)fieldNumber
  244. values:(GPBInt32Array *)values
  245. tag:(uint32_t)tag;
  246. /**
  247. * Write a int32_t without any tag.
  248. *
  249. * @param value The value to write out.
  250. **/
  251. - (void)writeInt32NoTag:(int32_t)value;
  252. /**
  253. * Write a uint32_t for the given field number.
  254. *
  255. * @param fieldNumber The field number assigned to the value.
  256. * @param value The value to write out.
  257. **/
  258. - (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value;
  259. /**
  260. * Write a packed array of uint32_t for the given field number.
  261. *
  262. * @param fieldNumber The field number assigned to the values.
  263. * @param values The values to write out.
  264. * @param tag The tag assigned to the values.
  265. **/
  266. - (void)writeUInt32Array:(int32_t)fieldNumber
  267. values:(GPBUInt32Array *)values
  268. tag:(uint32_t)tag;
  269. /**
  270. * Write a uint32_t without any tag.
  271. *
  272. * @param value The value to write out.
  273. **/
  274. - (void)writeUInt32NoTag:(uint32_t)value;
  275. /**
  276. * Write a uint64_t for the given field number.
  277. *
  278. * @param fieldNumber The field number assigned to the value.
  279. * @param value The value to write out.
  280. **/
  281. - (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value;
  282. /**
  283. * Write a packed array of uint64_t for the given field number.
  284. *
  285. * @param fieldNumber The field number assigned to the values.
  286. * @param values The values to write out.
  287. * @param tag The tag assigned to the values.
  288. **/
  289. - (void)writeFixed64Array:(int32_t)fieldNumber
  290. values:(GPBUInt64Array *)values
  291. tag:(uint32_t)tag;
  292. /**
  293. * Write a uint64_t without any tag.
  294. *
  295. * @param value The value to write out.
  296. **/
  297. - (void)writeFixed64NoTag:(uint64_t)value;
  298. /**
  299. * Write a uint32_t for the given field number.
  300. *
  301. * @param fieldNumber The field number assigned to the value.
  302. * @param value The value to write out.
  303. **/
  304. - (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value;
  305. /**
  306. * Write a packed array of uint32_t for the given field number.
  307. *
  308. * @param fieldNumber The field number assigned to the values.
  309. * @param values The values to write out.
  310. * @param tag The tag assigned to the values.
  311. **/
  312. - (void)writeFixed32Array:(int32_t)fieldNumber
  313. values:(GPBUInt32Array *)values
  314. tag:(uint32_t)tag;
  315. /**
  316. * Write a uint32_t without any tag.
  317. *
  318. * @param value The value to write out.
  319. **/
  320. - (void)writeFixed32NoTag:(uint32_t)value;
  321. /**
  322. * Write a int32_t for the given field number.
  323. *
  324. * @param fieldNumber The field number assigned to the value.
  325. * @param value The value to write out.
  326. **/
  327. - (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value;
  328. /**
  329. * Write a packed array of int32_t for the given field number.
  330. *
  331. * @param fieldNumber The field number assigned to the values.
  332. * @param values The values to write out.
  333. * @param tag The tag assigned to the values.
  334. **/
  335. - (void)writeSInt32Array:(int32_t)fieldNumber
  336. values:(GPBInt32Array *)values
  337. tag:(uint32_t)tag;
  338. /**
  339. * Write a int32_t without any tag.
  340. *
  341. * @param value The value to write out.
  342. **/
  343. - (void)writeSInt32NoTag:(int32_t)value;
  344. /**
  345. * Write a int64_t for the given field number.
  346. *
  347. * @param fieldNumber The field number assigned to the value.
  348. * @param value The value to write out.
  349. **/
  350. - (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value;
  351. /**
  352. * Write a packed array of int64_t for the given field number.
  353. *
  354. * @param fieldNumber The field number assigned to the values.
  355. * @param values The values to write out.
  356. * @param tag The tag assigned to the values.
  357. **/
  358. - (void)writeSInt64Array:(int32_t)fieldNumber
  359. values:(GPBInt64Array *)values
  360. tag:(uint32_t)tag;
  361. /**
  362. * Write a int64_t without any tag.
  363. *
  364. * @param value The value to write out.
  365. **/
  366. - (void)writeSInt64NoTag:(int64_t)value;
  367. /**
  368. * Write a int64_t for the given field number.
  369. *
  370. * @param fieldNumber The field number assigned to the value.
  371. * @param value The value to write out.
  372. **/
  373. - (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value;
  374. /**
  375. * Write a packed array of int64_t for the given field number.
  376. *
  377. * @param fieldNumber The field number assigned to the values.
  378. * @param values The values to write out.
  379. * @param tag The tag assigned to the values.
  380. **/
  381. - (void)writeSFixed64Array:(int32_t)fieldNumber
  382. values:(GPBInt64Array *)values
  383. tag:(uint32_t)tag;
  384. /**
  385. * Write a int64_t without any tag.
  386. *
  387. * @param value The value to write out.
  388. **/
  389. - (void)writeSFixed64NoTag:(int64_t)value;
  390. /**
  391. * Write a int32_t for the given field number.
  392. *
  393. * @param fieldNumber The field number assigned to the value.
  394. * @param value The value to write out.
  395. **/
  396. - (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value;
  397. /**
  398. * Write a packed array of int32_t for the given field number.
  399. *
  400. * @param fieldNumber The field number assigned to the values.
  401. * @param values The values to write out.
  402. * @param tag The tag assigned to the values.
  403. **/
  404. - (void)writeSFixed32Array:(int32_t)fieldNumber
  405. values:(GPBInt32Array *)values
  406. tag:(uint32_t)tag;
  407. /**
  408. * Write a int32_t without any tag.
  409. *
  410. * @param value The value to write out.
  411. **/
  412. - (void)writeSFixed32NoTag:(int32_t)value;
  413. /**
  414. * Write a BOOL for the given field number.
  415. *
  416. * @param fieldNumber The field number assigned to the value.
  417. * @param value The value to write out.
  418. **/
  419. - (void)writeBool:(int32_t)fieldNumber value:(BOOL)value;
  420. /**
  421. * Write a packed array of BOOL for the given field number.
  422. *
  423. * @param fieldNumber The field number assigned to the values.
  424. * @param values The values to write out.
  425. * @param tag The tag assigned to the values.
  426. **/
  427. - (void)writeBoolArray:(int32_t)fieldNumber
  428. values:(GPBBoolArray *)values
  429. tag:(uint32_t)tag;
  430. /**
  431. * Write a BOOL without any tag.
  432. *
  433. * @param value The value to write out.
  434. **/
  435. - (void)writeBoolNoTag:(BOOL)value;
  436. /**
  437. * Write a int32_t for the given field number.
  438. *
  439. * @param fieldNumber The field number assigned to the value.
  440. * @param value The value to write out.
  441. **/
  442. - (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value;
  443. /**
  444. * Write a packed array of int32_t for the given field number.
  445. *
  446. * @param fieldNumber The field number assigned to the values.
  447. * @param values The values to write out.
  448. * @param tag The tag assigned to the values.
  449. **/
  450. - (void)writeEnumArray:(int32_t)fieldNumber
  451. values:(GPBEnumArray *)values
  452. tag:(uint32_t)tag;
  453. /**
  454. * Write a int32_t without any tag.
  455. *
  456. * @param value The value to write out.
  457. **/
  458. - (void)writeEnumNoTag:(int32_t)value;
  459. /**
  460. * Write a NSString for the given field number.
  461. *
  462. * @param fieldNumber The field number assigned to the value.
  463. * @param value The value to write out.
  464. **/
  465. - (void)writeString:(int32_t)fieldNumber value:(NSString *)value;
  466. /**
  467. * Write an array of NSString for the given field number.
  468. *
  469. * @param fieldNumber The field number assigned to the values.
  470. * @param values The values to write out.
  471. **/
  472. - (void)writeStringArray:(int32_t)fieldNumber
  473. values:(NSArray<NSString*> *)values;
  474. /**
  475. * Write a NSString without any tag.
  476. *
  477. * @param value The value to write out.
  478. **/
  479. - (void)writeStringNoTag:(NSString *)value;
  480. /**
  481. * Write a GPBMessage for the given field number.
  482. *
  483. * @param fieldNumber The field number assigned to the value.
  484. * @param value The value to write out.
  485. **/
  486. - (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value;
  487. /**
  488. * Write an array of GPBMessage for the given field number.
  489. *
  490. * @param fieldNumber The field number assigned to the values.
  491. * @param values The values to write out.
  492. **/
  493. - (void)writeMessageArray:(int32_t)fieldNumber
  494. values:(NSArray<GPBMessage*> *)values;
  495. /**
  496. * Write a GPBMessage without any tag.
  497. *
  498. * @param value The value to write out.
  499. **/
  500. - (void)writeMessageNoTag:(GPBMessage *)value;
  501. /**
  502. * Write a NSData for the given field number.
  503. *
  504. * @param fieldNumber The field number assigned to the value.
  505. * @param value The value to write out.
  506. **/
  507. - (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value;
  508. /**
  509. * Write an array of NSData for the given field number.
  510. *
  511. * @param fieldNumber The field number assigned to the values.
  512. * @param values The values to write out.
  513. **/
  514. - (void)writeBytesArray:(int32_t)fieldNumber
  515. values:(NSArray<NSData*> *)values;
  516. /**
  517. * Write a NSData without any tag.
  518. *
  519. * @param value The value to write out.
  520. **/
  521. - (void)writeBytesNoTag:(NSData *)value;
  522. /**
  523. * Write a GPBMessage for the given field number.
  524. *
  525. * @param fieldNumber The field number assigned to the value.
  526. * @param value The value to write out.
  527. **/
  528. - (void)writeGroup:(int32_t)fieldNumber
  529. value:(GPBMessage *)value;
  530. /**
  531. * Write an array of GPBMessage for the given field number.
  532. *
  533. * @param fieldNumber The field number assigned to the values.
  534. * @param values The values to write out.
  535. **/
  536. - (void)writeGroupArray:(int32_t)fieldNumber
  537. values:(NSArray<GPBMessage*> *)values;
  538. /**
  539. * Write a GPBMessage without any tag (but does write the endGroup tag).
  540. *
  541. * @param fieldNumber The field number assigned to the value.
  542. * @param value The value to write out.
  543. **/
  544. - (void)writeGroupNoTag:(int32_t)fieldNumber
  545. value:(GPBMessage *)value;
  546. //%PDDM-EXPAND-END _WRITE_DECLS()
  547. // clang-format on
  548. /**
  549. * Write a GPBUnknownFieldSet for the given field number.
  550. *
  551. * @param fieldNumber The field number assigned to the value.
  552. * @param value The value to write out.
  553. **/
  554. - (void)writeUnknownGroup:(int32_t)fieldNumber
  555. value:(GPBUnknownFieldSet *)value
  556. __attribute__((deprecated("GPBUnknownFieldSet is going away.")));
  557. /**
  558. * Write an array of GPBUnknownFieldSet for the given field number.
  559. *
  560. * @param fieldNumber The field number assigned to the values.
  561. * @param values The values to write out.
  562. **/
  563. - (void)writeUnknownGroupArray:(int32_t)fieldNumber
  564. values:(NSArray<GPBUnknownFieldSet *> *)values
  565. __attribute__((deprecated("GPBUnknownFieldSet is going away.")));
  566. /**
  567. * Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag).
  568. *
  569. * @param fieldNumber The field number assigned to the value.
  570. * @param value The value to write out.
  571. **/
  572. - (void)writeUnknownGroupNoTag:(int32_t)fieldNumber
  573. value:(GPBUnknownFieldSet *)value
  574. __attribute__((deprecated("GPBUnknownFieldSet is going away.")));
  575. /**
  576. Write a MessageSet extension field to the stream. For historical reasons,
  577. the wire format differs from normal fields.
  578. @param fieldNumber The extension field number to write out.
  579. @param value The message from where to get the extension.
  580. */
  581. - (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value;
  582. /**
  583. Write an unparsed MessageSet extension field to the stream. For historical
  584. reasons, the wire format differs from normal fields.
  585. @param fieldNumber The extension field number to write out.
  586. @param value The raw message from where to get the extension.
  587. */
  588. - (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value;
  589. @end
  590. NS_ASSUME_NONNULL_END
  591. // Disable clang-format for the macros.
  592. // clang-format off
  593. // Write methods for types that can be in packed arrays.
  594. //%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)
  595. //%/**
  596. //% * Write a TYPE for the given field number.
  597. //% *
  598. //% * @param fieldNumber The field number assigned to the value.
  599. //% * @param value The value to write out.
  600. //% **/
  601. //%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;
  602. //%/**
  603. //% * Write a packed array of TYPE for the given field number.
  604. //% *
  605. //% * @param fieldNumber The field number assigned to the values.
  606. //% * @param values The values to write out.
  607. //% * @param tag The tag assigned to the values.
  608. //% **/
  609. //%- (void)write##NAME##Array:(int32_t)fieldNumber
  610. //% NAME$S values:(GPB##ARRAY_TYPE##Array *)values
  611. //% NAME$S tag:(uint32_t)tag;
  612. //%/**
  613. //% * Write a TYPE without any tag.
  614. //% *
  615. //% * @param value The value to write out.
  616. //% **/
  617. //%- (void)write##NAME##NoTag:(TYPE)value;
  618. //%
  619. // Write methods for types that aren't in packed arrays.
  620. //%PDDM-DEFINE _WRITE_UNPACKABLE_DECLS(NAME, TYPE)
  621. //%/**
  622. //% * Write a TYPE for the given field number.
  623. //% *
  624. //% * @param fieldNumber The field number assigned to the value.
  625. //% * @param value The value to write out.
  626. //% **/
  627. //%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value;
  628. //%/**
  629. //% * Write an array of TYPE for the given field number.
  630. //% *
  631. //% * @param fieldNumber The field number assigned to the values.
  632. //% * @param values The values to write out.
  633. //% **/
  634. //%- (void)write##NAME##Array:(int32_t)fieldNumber
  635. //% NAME$S values:(NSArray<##TYPE##*> *)values;
  636. //%/**
  637. //% * Write a TYPE without any tag.
  638. //% *
  639. //% * @param value The value to write out.
  640. //% **/
  641. //%- (void)write##NAME##NoTag:(TYPE *)value;
  642. //%
  643. // Special write methods for Groups.
  644. //%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE)
  645. //%/**
  646. //% * Write a TYPE for the given field number.
  647. //% *
  648. //% * @param fieldNumber The field number assigned to the value.
  649. //% * @param value The value to write out.
  650. //% **/
  651. //%- (void)write##NAME:(int32_t)fieldNumber
  652. //% NAME$S value:(TYPE *)value;
  653. //%/**
  654. //% * Write an array of TYPE for the given field number.
  655. //% *
  656. //% * @param fieldNumber The field number assigned to the values.
  657. //% * @param values The values to write out.
  658. //% **/
  659. //%- (void)write##NAME##Array:(int32_t)fieldNumber
  660. //% NAME$S values:(NSArray<##TYPE##*> *)values;
  661. //%/**
  662. //% * Write a TYPE without any tag (but does write the endGroup tag).
  663. //% *
  664. //% * @param fieldNumber The field number assigned to the value.
  665. //% * @param value The value to write out.
  666. //% **/
  667. //%- (void)write##NAME##NoTag:(int32_t)fieldNumber
  668. //% NAME$S value:(TYPE *)value;
  669. //%
  670. // One macro to hide it all up above.
  671. //%PDDM-DEFINE _WRITE_DECLS()
  672. //%_WRITE_PACKABLE_DECLS(Double, Double, double)
  673. //%_WRITE_PACKABLE_DECLS(Float, Float, float)
  674. //%_WRITE_PACKABLE_DECLS(UInt64, UInt64, uint64_t)
  675. //%_WRITE_PACKABLE_DECLS(Int64, Int64, int64_t)
  676. //%_WRITE_PACKABLE_DECLS(Int32, Int32, int32_t)
  677. //%_WRITE_PACKABLE_DECLS(UInt32, UInt32, uint32_t)
  678. //%_WRITE_PACKABLE_DECLS(Fixed64, UInt64, uint64_t)
  679. //%_WRITE_PACKABLE_DECLS(Fixed32, UInt32, uint32_t)
  680. //%_WRITE_PACKABLE_DECLS(SInt32, Int32, int32_t)
  681. //%_WRITE_PACKABLE_DECLS(SInt64, Int64, int64_t)
  682. //%_WRITE_PACKABLE_DECLS(SFixed64, Int64, int64_t)
  683. //%_WRITE_PACKABLE_DECLS(SFixed32, Int32, int32_t)
  684. //%_WRITE_PACKABLE_DECLS(Bool, Bool, BOOL)
  685. //%_WRITE_PACKABLE_DECLS(Enum, Enum, int32_t)
  686. //%_WRITE_UNPACKABLE_DECLS(String, NSString)
  687. //%_WRITE_UNPACKABLE_DECLS(Message, GPBMessage)
  688. //%_WRITE_UNPACKABLE_DECLS(Bytes, NSData)
  689. //%_WRITE_GROUP_DECLS(Group, GPBMessage)
  690. // clang-format on