GPBCodedOutputStream.h 22 KB

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