GPBCodedOutputStream.h 23 KB

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