GPBCodedOutputStream.h 23 KB

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