You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

748 lines
23 KiB

6 years ago
  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. /**
  163. * Write a double for the given field number.
  164. *
  165. * @param fieldNumber The field number assigned to the value.
  166. * @param value The value to write out.
  167. **/
  168. - (void)writeDouble:(int32_t)fieldNumber value:(double)value;
  169. /**
  170. * Write a packed array of double for the given field number.
  171. *
  172. * @param fieldNumber The field number assigned to the values.
  173. * @param values The values to write out.
  174. * @param tag The tag assigned to the values.
  175. **/
  176. - (void)writeDoubleArray:(int32_t)fieldNumber
  177. values:(GPBDoubleArray *)values
  178. tag:(uint32_t)tag;
  179. /**
  180. * Write a double without any tag.
  181. *
  182. * @param value The value to write out.
  183. **/
  184. - (void)writeDoubleNoTag:(double)value;
  185. /**
  186. * Write a float for the given field number.
  187. *
  188. * @param fieldNumber The field number assigned to the value.
  189. * @param value The value to write out.
  190. **/
  191. - (void)writeFloat:(int32_t)fieldNumber value:(float)value;
  192. /**
  193. * Write a packed array of float for the given field number.
  194. *
  195. * @param fieldNumber The field number assigned to the values.
  196. * @param values The values to write out.
  197. * @param tag The tag assigned to the values.
  198. **/
  199. - (void)writeFloatArray:(int32_t)fieldNumber
  200. values:(GPBFloatArray *)values
  201. tag:(uint32_t)tag;
  202. /**
  203. * Write a float without any tag.
  204. *
  205. * @param value The value to write out.
  206. **/
  207. - (void)writeFloatNoTag:(float)value;
  208. /**
  209. * Write a uint64_t for the given field number.
  210. *
  211. * @param fieldNumber The field number assigned to the value.
  212. * @param value The value to write out.
  213. **/
  214. - (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value;
  215. /**
  216. * Write a packed array of uint64_t for the given field number.
  217. *
  218. * @param fieldNumber The field number assigned to the values.
  219. * @param values The values to write out.
  220. * @param tag The tag assigned to the values.
  221. **/
  222. - (void)writeUInt64Array:(int32_t)fieldNumber
  223. values:(GPBUInt64Array *)values
  224. tag:(uint32_t)tag;
  225. /**
  226. * Write a uint64_t without any tag.
  227. *
  228. * @param value The value to write out.
  229. **/
  230. - (void)writeUInt64NoTag:(uint64_t)value;
  231. /**
  232. * Write a int64_t for the given field number.
  233. *
  234. * @param fieldNumber The field number assigned to the value.
  235. * @param value The value to write out.
  236. **/
  237. - (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value;
  238. /**
  239. * Write a packed array of int64_t for the given field number.
  240. *
  241. * @param fieldNumber The field number assigned to the values.
  242. * @param values The values to write out.
  243. * @param tag The tag assigned to the values.
  244. **/
  245. - (void)writeInt64Array:(int32_t)fieldNumber
  246. values:(GPBInt64Array *)values
  247. tag:(uint32_t)tag;
  248. /**
  249. * Write a int64_t without any tag.
  250. *
  251. * @param value The value to write out.
  252. **/
  253. - (void)writeInt64NoTag:(int64_t)value;
  254. /**
  255. * Write a int32_t for the given field number.
  256. *
  257. * @param fieldNumber The field number assigned to the value.
  258. * @param value The value to write out.
  259. **/
  260. - (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value;
  261. /**
  262. * Write a packed array of int32_t for the given field number.
  263. *
  264. * @param fieldNumber The field number assigned to the values.
  265. * @param values The values to write out.
  266. * @param tag The tag assigned to the values.
  267. **/
  268. - (void)writeInt32Array:(int32_t)fieldNumber
  269. values:(GPBInt32Array *)values
  270. tag:(uint32_t)tag;
  271. /**
  272. * Write a int32_t without any tag.
  273. *
  274. * @param value The value to write out.
  275. **/
  276. - (void)writeInt32NoTag:(int32_t)value;
  277. /**
  278. * Write a uint32_t for the given field number.
  279. *
  280. * @param fieldNumber The field number assigned to the value.
  281. * @param value The value to write out.
  282. **/
  283. - (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value;
  284. /**
  285. * Write a packed array of uint32_t for the given field number.
  286. *
  287. * @param fieldNumber The field number assigned to the values.
  288. * @param values The values to write out.
  289. * @param tag The tag assigned to the values.
  290. **/
  291. - (void)writeUInt32Array:(int32_t)fieldNumber
  292. values:(GPBUInt32Array *)values
  293. tag:(uint32_t)tag;
  294. /**
  295. * Write a uint32_t without any tag.
  296. *
  297. * @param value The value to write out.
  298. **/
  299. - (void)writeUInt32NoTag:(uint32_t)value;
  300. /**
  301. * Write a uint64_t for the given field number.
  302. *
  303. * @param fieldNumber The field number assigned to the value.
  304. * @param value The value to write out.
  305. **/
  306. - (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value;
  307. /**
  308. * Write a packed array of uint64_t for the given field number.
  309. *
  310. * @param fieldNumber The field number assigned to the values.
  311. * @param values The values to write out.
  312. * @param tag The tag assigned to the values.
  313. **/
  314. - (void)writeFixed64Array:(int32_t)fieldNumber
  315. values:(GPBUInt64Array *)values
  316. tag:(uint32_t)tag;
  317. /**
  318. * Write a uint64_t without any tag.
  319. *
  320. * @param value The value to write out.
  321. **/
  322. - (void)writeFixed64NoTag:(uint64_t)value;
  323. /**
  324. * Write a uint32_t for the given field number.
  325. *
  326. * @param fieldNumber The field number assigned to the value.
  327. * @param value The value to write out.
  328. **/
  329. - (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value;
  330. /**
  331. * Write a packed array of uint32_t for the given field number.
  332. *
  333. * @param fieldNumber The field number assigned to the values.
  334. * @param values The values to write out.
  335. * @param tag The tag assigned to the values.
  336. **/
  337. - (void)writeFixed32Array:(int32_t)fieldNumber
  338. values:(GPBUInt32Array *)values
  339. tag:(uint32_t)tag;
  340. /**
  341. * Write a uint32_t without any tag.
  342. *
  343. * @param value The value to write out.
  344. **/
  345. - (void)writeFixed32NoTag:(uint32_t)value;
  346. /**
  347. * Write a int32_t for the given field number.
  348. *
  349. * @param fieldNumber The field number assigned to the value.
  350. * @param value The value to write out.
  351. **/
  352. - (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value;
  353. /**
  354. * Write a packed array of int32_t for the given field number.
  355. *
  356. * @param fieldNumber The field number assigned to the values.
  357. * @param values The values to write out.
  358. * @param tag The tag assigned to the values.
  359. **/
  360. - (void)writeSInt32Array:(int32_t)fieldNumber
  361. values:(GPBInt32Array *)values
  362. tag:(uint32_t)tag;
  363. /**
  364. * Write a int32_t without any tag.
  365. *
  366. * @param value The value to write out.
  367. **/
  368. - (void)writeSInt32NoTag:(int32_t)value;
  369. /**
  370. * Write a int64_t for the given field number.
  371. *
  372. * @param fieldNumber The field number assigned to the value.
  373. * @param value The value to write out.
  374. **/
  375. - (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value;
  376. /**
  377. * Write a packed array of int64_t for the given field number.
  378. *
  379. * @param fieldNumber The field number assigned to the values.
  380. * @param values The values to write out.
  381. * @param tag The tag assigned to the values.
  382. **/
  383. - (void)writeSInt64Array:(int32_t)fieldNumber
  384. values:(GPBInt64Array *)values
  385. tag:(uint32_t)tag;
  386. /**
  387. * Write a int64_t without any tag.
  388. *
  389. * @param value The value to write out.
  390. **/
  391. - (void)writeSInt64NoTag:(int64_t)value;
  392. /**
  393. * Write a int64_t for the given field number.
  394. *
  395. * @param fieldNumber The field number assigned to the value.
  396. * @param value The value to write out.
  397. **/
  398. - (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value;
  399. /**
  400. * Write a packed array of int64_t for the given field number.
  401. *
  402. * @param fieldNumber The field number assigned to the values.
  403. * @param values The values to write out.
  404. * @param tag The tag assigned to the values.
  405. **/
  406. - (void)writeSFixed64Array:(int32_t)fieldNumber
  407. values:(GPBInt64Array *)values
  408. tag:(uint32_t)tag;
  409. /**
  410. * Write a int64_t without any tag.
  411. *
  412. * @param value The value to write out.
  413. **/
  414. - (void)writeSFixed64NoTag:(int64_t)value;
  415. /**
  416. * Write a int32_t for the given field number.
  417. *
  418. * @param fieldNumber The field number assigned to the value.
  419. * @param value The value to write out.
  420. **/
  421. - (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value;
  422. /**
  423. * Write a packed array of int32_t for the given field number.
  424. *
  425. * @param fieldNumber The field number assigned to the values.
  426. * @param values The values to write out.
  427. * @param tag The tag assigned to the values.
  428. **/
  429. - (void)writeSFixed32Array:(int32_t)fieldNumber
  430. values:(GPBInt32Array *)values
  431. tag:(uint32_t)tag;
  432. /**
  433. * Write a int32_t without any tag.
  434. *
  435. * @param value The value to write out.
  436. **/
  437. - (void)writeSFixed32NoTag:(int32_t)value;
  438. /**
  439. * Write a BOOL for the given field number.
  440. *
  441. * @param fieldNumber The field number assigned to the value.
  442. * @param value The value to write out.
  443. **/
  444. - (void)writeBool:(int32_t)fieldNumber value:(BOOL)value;
  445. /**
  446. * Write a packed array of BOOL for the given field number.
  447. *
  448. * @param fieldNumber The field number assigned to the values.
  449. * @param values The values to write out.
  450. * @param tag The tag assigned to the values.
  451. **/
  452. - (void)writeBoolArray:(int32_t)fieldNumber
  453. values:(GPBBoolArray *)values
  454. tag:(uint32_t)tag;
  455. /**
  456. * Write a BOOL without any tag.
  457. *
  458. * @param value The value to write out.
  459. **/
  460. - (void)writeBoolNoTag:(BOOL)value;
  461. /**
  462. * Write a int32_t for the given field number.
  463. *
  464. * @param fieldNumber The field number assigned to the value.
  465. * @param value The value to write out.
  466. **/
  467. - (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value;
  468. /**
  469. * Write a packed array of int32_t for the given field number.
  470. *
  471. * @param fieldNumber The field number assigned to the values.
  472. * @param values The values to write out.
  473. * @param tag The tag assigned to the values.
  474. **/
  475. - (void)writeEnumArray:(int32_t)fieldNumber
  476. values:(GPBEnumArray *)values
  477. tag:(uint32_t)tag;
  478. /**
  479. * Write a int32_t without any tag.
  480. *
  481. * @param value The value to write out.
  482. **/
  483. - (void)writeEnumNoTag:(int32_t)value;
  484. /**
  485. * Write a NSString for the given field number.
  486. *
  487. * @param fieldNumber The field number assigned to the value.
  488. * @param value The value to write out.
  489. **/
  490. - (void)writeString:(int32_t)fieldNumber value:(NSString *)value;
  491. /**
  492. * Write an array of NSString for the given field number.
  493. *
  494. * @param fieldNumber The field number assigned to the values.
  495. * @param values The values to write out.
  496. **/
  497. - (void)writeStringArray:(int32_t)fieldNumber values:(NSArray<NSString*> *)values;
  498. /**
  499. * Write a NSString without any tag.
  500. *
  501. * @param value The value to write out.
  502. **/
  503. - (void)writeStringNoTag:(NSString *)value;
  504. /**
  505. * Write a GPBMessage for the given field number.
  506. *
  507. * @param fieldNumber The field number assigned to the value.
  508. * @param value The value to write out.
  509. **/
  510. - (void)writeMessage:(int32_t)fieldNumber value:(GPBMessage *)value;
  511. /**
  512. * Write an array of GPBMessage for the given field number.
  513. *
  514. * @param fieldNumber The field number assigned to the values.
  515. * @param values The values to write out.
  516. **/
  517. - (void)writeMessageArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
  518. /**
  519. * Write a GPBMessage without any tag.
  520. *
  521. * @param value The value to write out.
  522. **/
  523. - (void)writeMessageNoTag:(GPBMessage *)value;
  524. /**
  525. * Write a NSData for the given field number.
  526. *
  527. * @param fieldNumber The field number assigned to the value.
  528. * @param value The value to write out.
  529. **/
  530. - (void)writeBytes:(int32_t)fieldNumber value:(NSData *)value;
  531. /**
  532. * Write an array of NSData for the given field number.
  533. *
  534. * @param fieldNumber The field number assigned to the values.
  535. * @param values The values to write out.
  536. **/
  537. - (void)writeBytesArray:(int32_t)fieldNumber values:(NSArray<NSData*> *)values;
  538. /**
  539. * Write a NSData without any tag.
  540. *
  541. * @param value The value to write out.
  542. **/
  543. - (void)writeBytesNoTag:(NSData *)value;
  544. /**
  545. * Write a GPBMessage for the given field number.
  546. *
  547. * @param fieldNumber The field number assigned to the value.
  548. * @param value The value to write out.
  549. **/
  550. - (void)writeGroup:(int32_t)fieldNumber
  551. value:(GPBMessage *)value;
  552. /**
  553. * Write an array of GPBMessage for the given field number.
  554. *
  555. * @param fieldNumber The field number assigned to the values.
  556. * @param values The values to write out.
  557. **/
  558. - (void)writeGroupArray:(int32_t)fieldNumber values:(NSArray<GPBMessage*> *)values;
  559. /**
  560. * Write a GPBMessage without any tag (but does write the endGroup tag).
  561. *
  562. * @param fieldNumber The field number assigned to the value.
  563. * @param value The value to write out.
  564. **/
  565. - (void)writeGroupNoTag:(int32_t)fieldNumber
  566. value:(GPBMessage *)value;
  567. /**
  568. * Write a GPBUnknownFieldSet for the given field number.
  569. *
  570. * @param fieldNumber The field number assigned to the value.
  571. * @param value The value to write out.
  572. **/
  573. - (void)writeUnknownGroup:(int32_t)fieldNumber
  574. value:(GPBUnknownFieldSet *)value;
  575. /**
  576. * Write an array of GPBUnknownFieldSet for the given field number.
  577. *
  578. * @param fieldNumber The field number assigned to the values.
  579. * @param values The values to write out.
  580. **/
  581. - (void)writeUnknownGroupArray:(int32_t)fieldNumber values:(NSArray<GPBUnknownFieldSet*> *)values;
  582. /**
  583. * Write a GPBUnknownFieldSet without any tag (but does write the endGroup tag).
  584. *
  585. * @param fieldNumber The field number assigned to the value.
  586. * @param value The value to write out.
  587. **/
  588. - (void)writeUnknownGroupNoTag:(int32_t)fieldNumber
  589. value:(GPBUnknownFieldSet *)value;
  590. //%PDDM-EXPAND-END _WRITE_DECLS()
  591. /**
  592. Write a MessageSet extension field to the stream. For historical reasons,
  593. the wire format differs from normal fields.
  594. @param fieldNumber The extension field number to write out.
  595. @param value The message from where to get the extension.
  596. */
  597. - (void)writeMessageSetExtension:(int32_t)fieldNumber value:(GPBMessage *)value;
  598. /**
  599. Write an unparsed MessageSet extension field to the stream. For historical
  600. reasons, the wire format differs from normal fields.
  601. @param fieldNumber The extension field number to write out.
  602. @param value The raw message from where to get the extension.
  603. */
  604. - (void)writeRawMessageSetExtension:(int32_t)fieldNumber value:(NSData *)value;
  605. @end
  606. NS_ASSUME_NONNULL_END
  607. // Write methods for types that can be in packed arrays.
  608. //%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)
  609. //%/**
  610. //% * Write a TYPE for the given field number.
  611. //% *
  612. //% * @param fieldNumber The field number assigned to the value.
  613. //% * @param value The value to write out.
  614. //% **/
  615. //%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;
  616. //%/**
  617. //% * Write a packed array of TYPE for the given field number.
  618. //% *
  619. //% * @param fieldNumber The field number assigned to the values.
  620. //% * @param values The values to write out.
  621. //% * @param tag The tag assigned to the values.
  622. //% **/
  623. //%- (void)write##NAME##Array:(int32_t)fieldNumber
  624. //% NAME$S values:(GPB##ARRAY_TYPE##Array *)values
  625. //% NAME$S tag:(uint32_t)tag;
  626. //%/**
  627. //% * Write a TYPE without any tag.
  628. //% *
  629. //% * @param value The value to write out.
  630. //% **/
  631. //%- (void)write##NAME##NoTag:(TYPE)value;
  632. //%
  633. // Write methods for types that aren't in packed arrays.
  634. //%PDDM-DEFINE _WRITE_UNPACKABLE_DECLS(NAME, TYPE)
  635. //%/**
  636. //% * Write a TYPE for the given field number.
  637. //% *
  638. //% * @param fieldNumber The field number assigned to the value.
  639. //% * @param value The value to write out.
  640. //% **/
  641. //%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE *)value;
  642. //%/**
  643. //% * Write an array of TYPE for the given field number.
  644. //% *
  645. //% * @param fieldNumber The field number assigned to the values.
  646. //% * @param values The values to write out.
  647. //% **/
  648. //%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
  649. //%/**
  650. //% * Write a TYPE without any tag.
  651. //% *
  652. //% * @param value The value to write out.
  653. //% **/
  654. //%- (void)write##NAME##NoTag:(TYPE *)value;
  655. //%
  656. // Special write methods for Groups.
  657. //%PDDM-DEFINE _WRITE_GROUP_DECLS(NAME, TYPE)
  658. //%/**
  659. //% * Write a TYPE for the given field number.
  660. //% *
  661. //% * @param fieldNumber The field number assigned to the value.
  662. //% * @param value The value to write out.
  663. //% **/
  664. //%- (void)write##NAME:(int32_t)fieldNumber
  665. //% NAME$S value:(TYPE *)value;
  666. //%/**
  667. //% * Write an array of TYPE for the given field number.
  668. //% *
  669. //% * @param fieldNumber The field number assigned to the values.
  670. //% * @param values The values to write out.
  671. //% **/
  672. //%- (void)write##NAME##Array:(int32_t)fieldNumber values:(NSArray<##TYPE##*> *)values;
  673. //%/**
  674. //% * Write a TYPE without any tag (but does write the endGroup tag).
  675. //% *
  676. //% * @param fieldNumber The field number assigned to the value.
  677. //% * @param value The value to write out.
  678. //% **/
  679. //%- (void)write##NAME##NoTag:(int32_t)fieldNumber
  680. //% NAME$S value:(TYPE *)value;
  681. //%
  682. // One macro to hide it all up above.
  683. //%PDDM-DEFINE _WRITE_DECLS()
  684. //%_WRITE_PACKABLE_DECLS(Double, Double, double)
  685. //%_WRITE_PACKABLE_DECLS(Float, Float, float)
  686. //%_WRITE_PACKABLE_DECLS(UInt64, UInt64, uint64_t)
  687. //%_WRITE_PACKABLE_DECLS(Int64, Int64, int64_t)
  688. //%_WRITE_PACKABLE_DECLS(Int32, Int32, int32_t)
  689. //%_WRITE_PACKABLE_DECLS(UInt32, UInt32, uint32_t)
  690. //%_WRITE_PACKABLE_DECLS(Fixed64, UInt64, uint64_t)
  691. //%_WRITE_PACKABLE_DECLS(Fixed32, UInt32, uint32_t)
  692. //%_WRITE_PACKABLE_DECLS(SInt32, Int32, int32_t)
  693. //%_WRITE_PACKABLE_DECLS(SInt64, Int64, int64_t)
  694. //%_WRITE_PACKABLE_DECLS(SFixed64, Int64, int64_t)
  695. //%_WRITE_PACKABLE_DECLS(SFixed32, Int32, int32_t)
  696. //%_WRITE_PACKABLE_DECLS(Bool, Bool, BOOL)
  697. //%_WRITE_PACKABLE_DECLS(Enum, Enum, int32_t)
  698. //%_WRITE_UNPACKABLE_DECLS(String, NSString)
  699. //%_WRITE_UNPACKABLE_DECLS(Message, GPBMessage)
  700. //%_WRITE_UNPACKABLE_DECLS(Bytes, NSData)
  701. //%_WRITE_GROUP_DECLS(Group, GPBMessage)
  702. //%_WRITE_GROUP_DECLS(UnknownGroup, GPBUnknownFieldSet)